pull mouse button preference from global property
This commit is contained in:
committed by
Chris Forbes
parent
2503ddfde4
commit
c5313375f0
@@ -29,6 +29,8 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
public static int CellSize { get { return modData.Manifest.TileSize; } }
|
public static int CellSize { get { return modData.Manifest.TileSize; } }
|
||||||
|
|
||||||
|
public static MouseButtonPreference mouseButtonPreference = new MouseButtonPreference();
|
||||||
|
|
||||||
public static ModData modData;
|
public static ModData modData;
|
||||||
static WorldRenderer worldRenderer;
|
static WorldRenderer worldRenderer;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#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
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -15,32 +15,53 @@ namespace OpenRA
|
|||||||
public class NullInputHandler : IInputHandler
|
public class NullInputHandler : IInputHandler
|
||||||
{
|
{
|
||||||
// ignore all input
|
// ignore all input
|
||||||
public void ModifierKeys( Modifiers mods ) { }
|
public void ModifierKeys(Modifiers mods) { }
|
||||||
public void OnKeyInput( KeyInput input ) { }
|
public void OnKeyInput(KeyInput input) { }
|
||||||
public void OnMouseInput( MouseInput input ) { }
|
public void OnMouseInput(MouseInput input) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DefaultInputHandler : IInputHandler
|
public class DefaultInputHandler : IInputHandler
|
||||||
{
|
{
|
||||||
readonly World world;
|
readonly World world;
|
||||||
public DefaultInputHandler( World world )
|
public DefaultInputHandler(World world)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ModifierKeys( Modifiers mods )
|
public void ModifierKeys(Modifiers mods)
|
||||||
{
|
{
|
||||||
Game.HandleModifierKeys( mods );
|
Game.HandleModifierKeys(mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnKeyInput( KeyInput input )
|
public void OnKeyInput(KeyInput input)
|
||||||
{
|
{
|
||||||
Sync.CheckSyncUnchanged(world, () => Ui.HandleKeyPress(input));
|
Sync.CheckSyncUnchanged(world, () => Ui.HandleKeyPress(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMouseInput( MouseInput input )
|
public void OnMouseInput(MouseInput input)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,15 +69,13 @@ namespace OpenRA.Orders
|
|||||||
|
|
||||||
static UnitOrderResult OrderForUnit(Actor self, CPos xy, MouseInput mi, Actor underCursor)
|
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)
|
if (self.Owner != self.World.LocalPlayer)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (self.Destroyed)
|
if (self.Destroyed)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (mi.Button == ActionMouseButton)
|
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
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace OpenRA.Widgets
|
|||||||
var mi = new MouseInput
|
var mi = new MouseInput
|
||||||
{
|
{
|
||||||
Location = pos,
|
Location = pos,
|
||||||
Button = Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right,
|
Button = Game.mouseButtonPreference.Action,
|
||||||
Modifiers = Game.GetModifierKeys()
|
Modifiers = Game.GetModifierKeys()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == (Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left))
|
if (mi.Button == Game.mouseButtonPreference.Cancel)
|
||||||
{
|
{
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
yield break;
|
yield break;
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == (Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left))
|
if (mi.Button == Game.mouseButtonPreference.Cancel)
|
||||||
{
|
{
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
yield break;
|
yield break;
|
||||||
@@ -111,8 +111,7 @@ namespace OpenRA.Mods.RA
|
|||||||
? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
|
? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (mi.Button == (Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right)
|
if (mi.Button == Game.mouseButtonPreference.Action && underCursor == null)
|
||||||
&& 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 };
|
||||||
|
|||||||
@@ -86,11 +86,9 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
var actors = World.Selection.Actors
|
var actors = World.Selection.Actors
|
||||||
.Where(a => a.Owner == World.LocalPlayer).ToArray();
|
.Where(a => a.Owner == World.LocalPlayer).ToArray();
|
||||||
|
|
||||||
var ActionMouseButton = (Game.Settings.Game.UseClassicMouseStyle) ? MouseButton.Left : MouseButton.Right;
|
|
||||||
|
|
||||||
if (actors.Length > 0)
|
if (actors.Length > 0)
|
||||||
World.OrderGenerator = new GenericSelectTarget(actors, "AttackMove",
|
World.OrderGenerator = new GenericSelectTarget(actors, "AttackMove",
|
||||||
"attackmove", ActionMouseButton);
|
"attackmove", Game.mouseButtonPreference.Action);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user