add classic left-click orders

This commit is contained in:
Matthias Mailänder
2013-01-13 02:40:10 +01:00
committed by Chris Forbes
parent 1da2d89ced
commit d52394bb47
8 changed files with 93 additions and 58 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -112,6 +112,8 @@ namespace OpenRA.GameRules
public MouseScrollType MouseScroll = MouseScrollType.Standard;
public float ViewportEdgeScrollStep = 10f;
public bool UseClassicMouseStyle = false;
// Internal game settings
public int Timestep = 40;

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -69,13 +69,15 @@ namespace OpenRA.Orders
static UnitOrderResult OrderForUnit(Actor self, CPos xy, MouseInput mi, Actor underCursor)
{
var ActionMouseButton = (Game.Settings.Game.UseClassicMouseStyle) ? MouseButton.Left : MouseButton.Right;
if (self.Owner != self.World.LocalPlayer)
return null;
if (self.Destroyed)
return null;
if( mi.Button == MouseButton.Right )
if (mi.Button == ActionMouseButton)
{
foreach( var o in self.TraitsImplementing<IIssueOrder>()
.SelectMany(trait => trait.Orders

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -52,12 +52,21 @@ namespace OpenRA.Widgets
public override bool HandleMouseInput(MouseInput mi)
{
var xy = Game.viewport.ViewToWorldPx(mi);
var UseClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle;
var HasBox = (SelectionBox != null) ? true : false;
var MultiClick = (mi.MultiTapCount >= 2) ? true : false;
var NothingSelected = !world.Selection.Actors.Any();
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
{
if (!TakeFocus(mi))
return false;
dragStart = dragEnd = xy;
if (UseClassicMouseStyle)
ApplyOrders(world, xy, mi);
}
@@ -68,17 +77,19 @@ namespace OpenRA.Widgets
{
if (world.OrderGenerator is UnitOrderGenerator)
{
if (mi.MultiTapCount == 2)
if ((UseClassicMouseStyle && NothingSelected) || (!UseClassicMouseStyle))
{
if (MultiClick)
{
var unit = SelectActorsInBox(world, xy, xy, _ => true).FirstOrDefault();
var visibleWorld = Game.viewport.ViewBounds(world);
var topLeft = Game.viewport.ViewToWorldPx(new int2(visibleWorld.Left, visibleWorld.Top));
var bottomRight = Game.viewport.ViewToWorldPx(new int2(visibleWorld.Right, visibleWorld.Bottom));
var newSelection = SelectActorsInBox(world, topLeft, bottomRight,
var newSelection2 = SelectActorsInBox(world, topLeft, bottomRight,
a => unit != null && a.Info.Name == unit.Info.Name && a.Owner == unit.Owner);
world.Selection.Combine(world, newSelection, true, false);
world.Selection.Combine(world, newSelection2, true, false);
}
else
{
@@ -86,6 +97,7 @@ namespace OpenRA.Widgets
world.Selection.Combine(world, newSelection, mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == xy);
}
}
}
dragStart = dragEnd = xy;
LoseFocus(mi);
@@ -95,12 +107,17 @@ namespace OpenRA.Widgets
dragStart = dragEnd = xy;
if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down)
if (SelectionBox == null) /* don't issue orders while selecting */
{
if (UseClassicMouseStyle)
world.Selection.Clear();
else if (!HasBox) // don't issue orders while selecting
ApplyOrders(world, xy, mi);
}
return true;
}
public Pair<PPos, PPos>? SelectionBox
{
get
@@ -130,7 +147,7 @@ namespace OpenRA.Widgets
var mi = new MouseInput
{
Location = pos,
Button = MouseButton.Right,
Button = Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right,
Modifiers = Game.GetModifierKeys()
};

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -118,7 +118,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
inputButton.OnClick = () => Settings = PanelType.Input;
inputButton.IsDisabled = () => Settings == PanelType.Input;
inputPane.Get<CheckboxWidget>("CLASSICORDERS_CHECKBOX").IsDisabled = () => true;
var classicMouseCheckbox = inputPane.Get<CheckboxWidget>("CLASSICORDERS_CHECKBOX");
classicMouseCheckbox.IsChecked = () => gameSettings.UseClassicMouseStyle;
classicMouseCheckbox.OnClick = () => gameSettings.UseClassicMouseStyle ^= true;
var scrollSlider = inputPane.Get<SliderWidget>("SCROLLSPEED_SLIDER");
scrollSlider.Value = gameSettings.ViewportEdgeScrollStep;

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -69,6 +69,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
showShellmapCheckbox.IsChecked = () => Game.Settings.Game.ShowShellmap;
showShellmapCheckbox.OnClick = () => Game.Settings.Game.ShowShellmap ^= true;
var useClassicMouseStyleCheckbox = general.Get<CheckboxWidget>("USE_CLASSIC_MOUSE_STYLE_CHECKBOX");
useClassicMouseStyleCheckbox.IsChecked = () => Game.Settings.Game.UseClassicMouseStyle;
useClassicMouseStyleCheckbox.OnClick = () => Game.Settings.Game.UseClassicMouseStyle ^= true;
// Audio
var audio = bg.Get("AUDIO_PANE");
var soundSettings = Game.Settings.Sound;

View File

@@ -86,9 +86,11 @@ namespace OpenRA.Mods.RA.Widgets
var actors = World.Selection.Actors
.Where(a => a.Owner == World.LocalPlayer).ToArray();
var ActionMouseButton = (Game.Settings.Game.UseClassicMouseStyle) ? MouseButton.Left : MouseButton.Right;
if (actors.Length > 0)
World.OrderGenerator = new GenericSelectTarget(actors, "AttackMove",
"attackmove", MouseButton.Right);
"attackmove", ActionMouseButton);
return true;
}

View File

@@ -208,7 +208,7 @@ Container@SETTINGS_PANEL:
Width:250
Height:20
Font:Regular
Text:Left-Click Orders (Coming soon!)
Text:Left-Click Orders
Label@SCROLL_TITLE:
Font:Bold
Text:Scroll Behavior

View File

@@ -109,6 +109,12 @@ Background@SETTINGS_MENU:
Width:200
Height:20
Text: Show Shellmap
Checkbox@USE_CLASSIC_MOUSE_STYLE_CHECKBOX:
X:0
Y:180
Width:200
Height:20
Text: Left-Click Orders
Container@AUDIO_PANE:
X:37
Y:100