some more hax for the input

This commit is contained in:
Chris Forbes
2009-10-06 22:30:20 +13:00
parent 9eb03e3839
commit b0620dccb3
2 changed files with 42 additions and 1 deletions

View File

@@ -17,17 +17,45 @@ namespace OpenRa.Game
this.game = game;
}
float2 GetWorldPos(MouseInput mi)
{
return (1 / 24.0f) * (new float2(mi.Location.X, mi.Location.Y) + game.viewport.Location);
}
float2? dragStart, dragEnd;
public void HandleMouseInput(MouseInput mi)
{
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down)
{
var xy = (1 / 24.0f) * (new float2(mi.Location.X, mi.Location.Y) + game.viewport.Location);
var xy = GetWorldPos(mi);
if (orderGenerator != null)
orderGenerator.Order(game, new int2((int)xy.X, (int)xy.Y)).Apply(game);
else { dragStart = dragEnd = xy; }
// todo: route all orders through netcode
}
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Move)
if (dragEnd != null)
dragEnd = GetWorldPos(mi);
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Up)
if (dragStart.HasValue && !(dragStart.Value == GetWorldPos(mi)))
{
/* finalize drag selection */
}
else
{
/* finalize click selection */
}
if (mi.Button == MouseButtons.None && mi.Event == MouseInputEvent.Move)
{
/* update the cursor to reflect the thing under us - note this
* needs to also happen when the *thing* changes, so per-frame hook */
}
if (mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down)
orderGenerator = null;
}