Restored faulty left-click logic for now.

This commit is contained in:
Bynnar18
2015-02-10 19:48:41 -06:00
committed by Bynnar18
parent 75bfd0fb31
commit 36d59d6b1d
12 changed files with 156 additions and 95 deletions

View File

@@ -27,6 +27,8 @@ namespace OpenRA
{ {
public static class Game public static class Game
{ {
public static MouseButtonPreference mouseButtonPreference = new MouseButtonPreference();
public const int NetTickScale = 3; // 120 ms net tick for 40 ms local tick public const int NetTickScale = 3; // 120 ms net tick for 40 ms local tick
public const int Timestep = 40; public const int Timestep = 40;
public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms

View File

@@ -49,4 +49,25 @@ namespace OpenRA
Sync.CheckSyncUnchanged(world, () => Ui.HandleInput(input)); Sync.CheckSyncUnchanged(world, () => Ui.HandleInput(input));
} }
} }
public class MouseButtonPreference
{
public MouseButton Action
{
get
{
return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right;
}
}
public MouseButton Cancel
{
get
{
return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left;
}
}
}
} }

View File

@@ -96,7 +96,7 @@ namespace OpenRA.Orders
if (self.Destroyed || !target.IsValidFor(self)) if (self.Destroyed || !target.IsValidFor(self))
return null; return null;
if (mi.Button == MouseButton.Right) if (mi.Button == Game.mouseButtonPreference.Action)
{ {
foreach (var o in self.TraitsImplementing<IIssueOrder>() foreach (var o in self.TraitsImplementing<IIssueOrder>()
.SelectMany(trait => trait.Orders .SelectMany(trait => trait.Orders

View File

@@ -130,6 +130,7 @@ namespace OpenRA
public float ViewportEdgeScrollStep = 10f; public float ViewportEdgeScrollStep = 10f;
public float UIScrollSpeed = 50f; public float UIScrollSpeed = 50f;
public bool UseClassicMouseStyle = false;
public bool AlwaysShowStatusBars = false; public bool AlwaysShowStatusBars = false;
public bool TeamHealthColors = false; public bool TeamHealthColors = false;

View File

@@ -55,6 +55,9 @@ namespace OpenRA.Widgets
public override bool HandleMouseInput(MouseInput mi) public override bool HandleMouseInput(MouseInput mi)
{ {
var xy = worldRenderer.Viewport.ViewToWorldPx(mi.Location); var xy = worldRenderer.Viewport.ViewToWorldPx(mi.Location);
var useClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle;
var hasBox = SelectionBox != null; var hasBox = SelectionBox != null;
var multiClick = mi.MultiTapCount >= 2; var multiClick = mi.MultiTapCount >= 2;
@@ -66,6 +69,7 @@ namespace OpenRA.Widgets
dragStart = xy; dragStart = xy;
// place buildings // place buildings
if(!useClassicMouseStyle)
ApplyOrders(World, xy, mi); ApplyOrders(World, xy, mi);
} }
@@ -74,6 +78,18 @@ namespace OpenRA.Widgets
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up) if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
{ {
if (useClassicMouseStyle && HasMouseFocus)
{
// order units around
if (!hasBox && World.Selection.Actors.Any() && !multiClick)
{
ApplyOrders(World, xy, mi);
YieldMouseFocus(mi);
return true;
}
}
if (World.OrderGenerator is UnitOrderGenerator) if (World.OrderGenerator is UnitOrderGenerator)
{ {
if (multiClick) if (multiClick)
@@ -97,9 +113,14 @@ namespace OpenRA.Widgets
YieldMouseFocus(mi); YieldMouseFocus(mi);
} }
// don't issue orders while selecting if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down)
if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down && !hasBox) {
if (useClassicMouseStyle)
World.Selection.Clear();
if (!hasBox) // don't issue orders while selecting
ApplyOrders(World, xy, mi); ApplyOrders(World, xy, mi);
}
lastMousePosition = xy; lastMousePosition = xy;
@@ -172,7 +193,7 @@ namespace OpenRA.Widgets
var mi = new MouseInput var mi = new MouseInput
{ {
Location = screenPos, Location = screenPos,
Button = MouseButton.Right, Button = Game.mouseButtonPreference.Action,
Modifiers = Game.GetModifierKeys() Modifiers = Game.GetModifierKeys()
}; };

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi) public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
{ {
if (mi.Button == MouseButton.Left) if (mi.Button == Game.mouseButtonPreference.Cancel)
{ {
world.CancelInputMode(); world.CancelInputMode();
yield break; yield break;

View File

@@ -312,6 +312,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var gs = Game.Settings.Game; var gs = Game.Settings.Game;
var ks = Game.Settings.Keys; var ks = Game.Settings.Keys;
BindCheckboxPref(panel, "CLASSICORDERS_CHECKBOX", gs, "UseClassicMouseStyle");
BindCheckboxPref(panel, "EDGESCROLL_CHECKBOX", gs, "ViewportEdgeScroll"); BindCheckboxPref(panel, "EDGESCROLL_CHECKBOX", gs, "ViewportEdgeScroll");
BindCheckboxPref(panel, "LOCKMOUSE_CHECKBOX", gs, "LockMouseWindow"); BindCheckboxPref(panel, "LOCKMOUSE_CHECKBOX", gs, "LockMouseWindow");
BindSliderPref(panel, "SCROLLSPEED_SLIDER", gs, "ViewportEdgeScrollStep"); BindSliderPref(panel, "SCROLLSPEED_SLIDER", gs, "ViewportEdgeScrollStep");
@@ -472,6 +473,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return () => return () =>
{ {
gs.UseClassicMouseStyle = dgs.UseClassicMouseStyle;
gs.MouseScroll = dgs.MouseScroll; gs.MouseScroll = dgs.MouseScroll;
gs.LockMouseWindow = dgs.LockMouseWindow; gs.LockMouseWindow = dgs.LockMouseWindow;
gs.ViewportEdgeScroll = dgs.ViewportEdgeScroll; gs.ViewportEdgeScroll = dgs.ViewportEdgeScroll;

View File

@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets
if (actors.Any()) if (actors.Any())
world.OrderGenerator = new GenericSelectTarget(actors, world.OrderGenerator = new GenericSelectTarget(actors,
"AttackMove", "attackmove", MouseButton.Right); "AttackMove", "attackmove", Game.mouseButtonPreference.Action);
return true; return true;
} }

View File

@@ -146,7 +146,7 @@ namespace OpenRA.Mods.RA.Traits
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi) public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
{ {
if (mi.Button == MouseButton.Left) if (mi.Button == Game.mouseButtonPreference.Cancel)
{ {
world.CancelInputMode(); world.CancelInputMode();
yield break; yield break;
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.RA.Traits
.MaxByOrDefault(a => a.Info.Traits.Contains<SelectableInfo>() .MaxByOrDefault(a => a.Info.Traits.Contains<SelectableInfo>()
? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue); ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue);
if (mi.Button == MouseButton.Right && underCursor == null) if (mi.Button == Game.mouseButtonPreference.Action && underCursor == null)
{ {
minelayer.World.CancelInputMode(); minelayer.World.CancelInputMode();
yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = xy }; yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = xy };

View File

@@ -153,7 +153,7 @@ namespace OpenRA.Mods.RA.Traits
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi) public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
{ {
if (mi.Button == MouseButton.Left) if (mi.Button == Game.mouseButtonPreference.Cancel)
{ {
world.CancelInputMode(); world.CancelInputMode();
yield break; yield break;

View File

@@ -320,53 +320,16 @@ Container@SETTINGS_PANEL:
Font: Bold Font: Bold
Text: Input Text: Input
Align: Center Align: Center
Checkbox@EDGESCROLL_CHECKBOX: Checkbox@CLASSICORDERS_CHECKBOX:
X: 15 X: 15
Y: 40 Y: 40
Width: 130
Height: 20
Font: Regular
Text: Edge Scrolling
Checkbox@LOCKMOUSE_CHECKBOX:
X: 15
Y: 70
Width: 130
Height: 20
Font: Regular
Text: Lock mouse to window
Label@SCROLL_SPEED_LABEL:
X: PARENT_RIGHT - WIDTH - 270
Y: 37
Width: 95
Height: 25
Text: Scroll Speed:
Align: Right
Slider@SCROLLSPEED_SLIDER:
X: PARENT_RIGHT - WIDTH - 15
Y: 43
Width: 250 Width: 250
Height: 20 Height: 20
Ticks: 5 Font: Regular
MinimumValue: 10 Text: Left-Click Orders
MaximumValue: 50
Label@UI_SCROLL_SPEED_LABEL:
X: PARENT_RIGHT - WIDTH - 270
Y: 67
Width: 95
Height: 25
Text: UI Scroll Speed:
Align: Right
Slider@UI_SCROLLSPEED_SLIDER:
X: PARENT_RIGHT - WIDTH - 15
Y: 73
Width: 250
Height: 20
Ticks: 5
MinimumValue: 1
MaximumValue: 100
Label@MOUSE_SCROLL_LABEL: Label@MOUSE_SCROLL_LABEL:
X: PARENT_RIGHT - WIDTH - 120 X: PARENT_RIGHT - WIDTH - 120
Y: 99 Y: 39
Width: 160 Width: 160
Height: 20 Height: 20
Font: Regular Font: Regular
@@ -374,11 +337,55 @@ Container@SETTINGS_PANEL:
Align: Right Align: Right
DropDownButton@MOUSE_SCROLL: DropDownButton@MOUSE_SCROLL:
X: PARENT_RIGHT - WIDTH - 15 X: PARENT_RIGHT - WIDTH - 15
Y: 98 Y: 38
Width: 100 Width: 100
Height: 25 Height: 25
Font: Regular Font: Regular
Text: Enabled Text: Enabled
Checkbox@EDGESCROLL_CHECKBOX:
X: 15
Y: 70
Width: 130
Height: 20
Font: Regular
Text: Edge Scrolling
Checkbox@LOCKMOUSE_CHECKBOX:
X: 15
Y: 100
Width: 130
Height: 20
Font: Regular
Text: Lock mouse to window
Label@SCROLL_SPEED_LABEL:
X: PARENT_RIGHT - WIDTH - 270
Y: 67
Width: 95
Height: 25
Text: Scroll Speed:
Align: Right
Slider@SCROLLSPEED_SLIDER:
X: PARENT_RIGHT - WIDTH - 15
Y: 73
Width: 250
Height: 20
Ticks: 5
MinimumValue: 10
MaximumValue: 50
Label@UI_SCROLL_SPEED_LABEL:
X: PARENT_RIGHT - WIDTH - 270
Y: 97
Width: 95
Height: 25
Text: UI Scroll Speed:
Align: Right
Slider@UI_SCROLLSPEED_SLIDER:
X: PARENT_RIGHT - WIDTH - 15
Y: 103
Width: 250
Height: 20
Ticks: 5
MinimumValue: 1
MaximumValue: 100
Label@HOTKEYS_TITLE: Label@HOTKEYS_TITLE:
Y: 135 Y: 135
Width: PARENT_RIGHT Width: PARENT_RIGHT

View File

@@ -324,53 +324,16 @@ Background@SETTINGS_PANEL:
Width: PARENT_RIGHT - 10 Width: PARENT_RIGHT - 10
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Children: Children:
Checkbox@EDGESCROLL_CHECKBOX: Checkbox@CLASSICORDERS_CHECKBOX:
X: 15 X: 15
Y: 40 Y: 40
Width: 130
Height: 20
Font: Regular
Text: Edge Scrolling
Checkbox@LOCKMOUSE_CHECKBOX:
X: 15
Y: 70
Width: 130
Height: 20
Font: Regular
Text: Lock mouse to window
Label@SCROLL_SPEED_LABEL:
X: PARENT_RIGHT - WIDTH - 270
Y: 37
Width: 95
Height: 25
Text: Scroll Speed:
Align: Right
Slider@SCROLLSPEED_SLIDER:
X: PARENT_RIGHT - WIDTH - 15
Y: 43
Width: 250 Width: 250
Height: 20 Height: 20
Ticks: 5 Font: Regular
MinimumValue: 10 Text: Left-Click Orders
MaximumValue: 50
Label@UI_SCROLL_SPEED_LABEL:
X: PARENT_RIGHT - WIDTH - 270
Y: 67
Width: 95
Height: 25
Text: UI Scroll Speed:
Align: Right
Slider@UI_SCROLLSPEED_SLIDER:
X: PARENT_RIGHT - WIDTH - 15
Y: 73
Width: 250
Height: 20
Ticks: 5
MinimumValue: 1
MaximumValue: 100
Label@MOUSE_SCROLL_LABEL: Label@MOUSE_SCROLL_LABEL:
X: PARENT_RIGHT - WIDTH - 120 X: PARENT_RIGHT - WIDTH - 120
Y: 99 Y: 39
Width: 160 Width: 160
Height: 20 Height: 20
Font: Regular Font: Regular
@@ -378,11 +341,55 @@ Background@SETTINGS_PANEL:
Align: Right Align: Right
DropDownButton@MOUSE_SCROLL: DropDownButton@MOUSE_SCROLL:
X: PARENT_RIGHT - WIDTH - 15 X: PARENT_RIGHT - WIDTH - 15
Y: 98 Y: 38
Width: 100 Width: 100
Height: 25 Height: 25
Font: Regular Font: Regular
Text: Enabled Text: Enabled
Checkbox@EDGESCROLL_CHECKBOX:
X: 15
Y: 70
Width: 130
Height: 20
Font: Regular
Text: Edge Scrolling
Checkbox@LOCKMOUSE_CHECKBOX:
X: 15
Y: 100
Width: 130
Height: 20
Font: Regular
Text: Lock mouse to window
Label@SCROLL_SPEED_LABEL:
X: PARENT_RIGHT - WIDTH - 270
Y: 67
Width: 95
Height: 25
Text: Scroll Speed:
Align: Right
Slider@SCROLLSPEED_SLIDER:
X: PARENT_RIGHT - WIDTH - 15
Y: 73
Width: 250
Height: 20
Ticks: 5
MinimumValue: 10
MaximumValue: 50
Label@UI_SCROLL_SPEED_LABEL:
X: PARENT_RIGHT - WIDTH - 270
Y: 97
Width: 95
Height: 25
Text: UI Scroll Speed:
Align: Right
Slider@UI_SCROLLSPEED_SLIDER:
X: PARENT_RIGHT - WIDTH - 15
Y: 103
Width: 250
Height: 20
Ticks: 5
MinimumValue: 1
MaximumValue: 100
Label@HOTKEYS_TITLE: Label@HOTKEYS_TITLE:
Y: 135 Y: 135
Width: PARENT_RIGHT Width: PARENT_RIGHT