really fix modifier keys

This commit is contained in:
Chris Forbes
2010-02-22 21:25:47 +13:00
parent c2ac8ad096
commit 28215387cb
3 changed files with 21 additions and 18 deletions

View File

@@ -29,17 +29,9 @@ namespace OpenRa
{
public class Controller : IHandleInput
{
public IOrderGenerator orderGenerator;
public IOrderGenerator orderGenerator = new UnitOrderGenerator();
public Selection selection = new Selection();
readonly Func<Modifiers> GetModifierKeys;
public Controller(Func<Modifiers> getModifierKeys)
{
GetModifierKeys = getModifierKeys;
CancelInputMode();
}
public void CancelInputMode() { orderGenerator = new UnitOrderGenerator(); }
public bool ToggleInputMode<T>() where T : IOrderGenerator, new()
@@ -123,6 +115,7 @@ namespace OpenRa
}
public float2 MousePosition { get { return dragEnd; } }
Modifiers modifiers;
public string ChooseCursor( World world )
{
@@ -134,7 +127,7 @@ namespace OpenRa
{
Location = ( Game.CellSize * MousePosition - Game.viewport.Location ).ToInt2(),
Button = MouseButton.Right,
Modifiers = GetModifierKeys(),
Modifiers = modifiers
};
return orderGenerator.GetCursor( world, MousePosition.ToInt2(), mi );
@@ -145,5 +138,7 @@ namespace OpenRa
throw new InvalidOperationException( "Desync in Controller.ChooseCursor" );
}
}
public void SetModifiers(Modifiers mods) { modifiers = mods; }
}
}

View File

@@ -341,6 +341,11 @@ namespace OpenRa
throw new InvalidOperationException( "Desync in OnKeyPress" );
}
public static void HandleModifierKeys(Modifiers mods)
{
controller.SetModifiers(mods);
}
static Size GetResolution(Settings settings)
{
var desktopResolution = Screen.PrimaryScreen.Bounds.Size;
@@ -354,9 +359,6 @@ namespace OpenRa
desktopResolution.Height);
}
// [DllImport("user32")]
// static extern int ShowCursor([MarshalAs(UnmanagedType.Bool)] bool visible);
public static void PreInit(Settings settings)
{
while (!Directory.Exists("mods"))
@@ -383,7 +385,7 @@ namespace OpenRa
renderer = new Renderer(resolution, windowed);
resolution = renderer.Resolution;
var controller = new Controller(() => (Modifiers)(int)0/*ModifierKeys*/); /* a bit of insane input routing */
var controller = new Controller(); /* a bit of insane input routing */
Game.Initialize(Game.Settings.Map, renderer, new int2(resolution), Game.Settings.Player, controller);