From cdf56c278f3962b6495524ef51a8e73c755002e8 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 11 Oct 2009 10:54:09 +1300 Subject: [PATCH] fixed broken UiOverlay --- OpenRa.DataStructures/float2.cs | 1 + OpenRa.Game/MainWindow.cs | 10 +++++----- OpenRa.Game/UiOverlay.cs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/OpenRa.DataStructures/float2.cs b/OpenRa.DataStructures/float2.cs index 6d2943b75b..5280a333f8 100644 --- a/OpenRa.DataStructures/float2.cs +++ b/OpenRa.DataStructures/float2.cs @@ -82,5 +82,6 @@ namespace OpenRa public float2 Round() { return new float2((float)Math.Round(X), (float)Math.Round(Y)); } public override string ToString() { return string.Format("({0},{1})", X, Y); } + public int2 ToInt2() { return new int2((int)X, (int)Y); } } } diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index 3ad79841c0..cd5ba8c2a1 100644 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -95,11 +95,11 @@ namespace OpenRa.Game Button = e.Button, Event = MouseInputEvent.Move, Location = new int2(e.Location) - }); - - if (game.controller.orderGenerator != null) - game.controller.orderGenerator.PrepareOverlay(game, - new int2(e.Location.X / 24, e.Location.Y / 24)); + }); + + if (game.controller.orderGenerator != null) + game.controller.orderGenerator.PrepareOverlay(game, + ((1 / 24f) * (new float2(e.Location) + game.viewport.Location)).ToInt2()); } protected override void OnMouseUp(MouseEventArgs e) diff --git a/OpenRa.Game/UiOverlay.cs b/OpenRa.Game/UiOverlay.cs index 5c0b07281c..3433535c8f 100644 --- a/OpenRa.Game/UiOverlay.cs +++ b/OpenRa.Game/UiOverlay.cs @@ -49,7 +49,7 @@ namespace OpenRa.Game for (int i = 0; i < width; i++) for (int j = 0; j < height; j++) spriteRenderer.DrawSprite(passableAt(position.X + i, position.Y + j) ? buildOk : buildBlocked, - 24 * (position + new int2(i, j)) + game.viewport.Location, 0); + 24 * (position + new int2(i, j)), 0); spriteRenderer.Flush(); }