From 669aaab6b46b0a91602784e46dd5e8b6ce1f4bb0 Mon Sep 17 00:00:00 2001 From: Paolo Chiodi Date: Thu, 2 Sep 2010 20:28:17 +0200 Subject: [PATCH] change mouse sequence to blocked whene map borders are reached --- OpenRA.Game/Graphics/Viewport.cs | 19 +++++++ .../Widgets/ViewportScrollControllerWidget.cs | 56 +++++++++++++++---- mods/ra/sequences.xml | 27 +++++---- 3 files changed, 80 insertions(+), 22 deletions(-) diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index ed3b4fc652..85262556bf 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -55,6 +55,25 @@ namespace OpenRA.Graphics scrollPosition = newScrollPosition; } + + public ScrollDirection GetBlockedDirections() + { + int2 topLeftBorder = (Game.CellSize* mapStart); + int2 bottomRightBorder = (Game.CellSize* mapEnd); + + ScrollDirection blockedDirections = ScrollDirection.None; + + if(scrollPosition.Y <= topLeftBorder.Y) + blockedDirections = blockedDirections.Set(ScrollDirection.Up, true); + if(scrollPosition.X <= topLeftBorder.X) + blockedDirections = blockedDirections.Set(ScrollDirection.Left, true); + if(scrollPosition.Y >= bottomRightBorder.Y - screenSize.Y) + blockedDirections = blockedDirections.Set(ScrollDirection.Down, true); + if(scrollPosition.X >= bottomRightBorder.X - screenSize.X) + blockedDirections = blockedDirections.Set(ScrollDirection.Right, true); + + return blockedDirections; + } public Viewport(float2 screenSize, int2 mapStart, int2 mapEnd, Renderer renderer) { diff --git a/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs b/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs index f82530b569..e56eb36856 100644 --- a/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs +++ b/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs @@ -51,23 +51,55 @@ namespace OpenRA.Widgets if (!Game.Settings.Game.ViewportEdgeScroll) return null; - if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left)) - return "scroll-tl"; - if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Right)) - return "scroll-tr"; - if (Edge.Includes(ScrollDirection.Down) && Edge.Includes(ScrollDirection.Left)) - return "scroll-bl"; - if (Edge.Includes(ScrollDirection.Down) && Edge.Includes(ScrollDirection.Right)) - return "scroll-br"; + if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left)){ + ScrollDirection BlockedDirections = Game.viewport.GetBlockedDirections(); + if(BlockedDirections.Includes(ScrollDirection.Up) && BlockedDirections.Includes(ScrollDirection.Left)) + return "scroll-tl-blocked"; + else + return "scroll-tl"; + } + if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Right)){ + ScrollDirection BlockedDirections = Game.viewport.GetBlockedDirections(); + if (BlockedDirections.Includes(ScrollDirection.Up) && BlockedDirections.Includes(ScrollDirection.Right)) + return "scroll-tr-blocked"; + else + return "scroll-tr"; + } + if (Edge.Includes(ScrollDirection.Down) && Edge.Includes(ScrollDirection.Left)){ + ScrollDirection BlockedDirections = Game.viewport.GetBlockedDirections(); + if (BlockedDirections.Includes(ScrollDirection.Down) && BlockedDirections.Includes(ScrollDirection.Left)) + return "scroll-bl-blocked"; + else + return "scroll-bl"; + } + if (Edge.Includes(ScrollDirection.Down) && Edge.Includes(ScrollDirection.Right)){ + ScrollDirection BlockedDirections = Game.viewport.GetBlockedDirections(); + if (BlockedDirections.Includes(ScrollDirection.Down) && BlockedDirections.Includes(ScrollDirection.Right)) + return "scroll-br-blocked"; + else + return "scroll-br"; + } if (Edge.Includes(ScrollDirection.Up)) - return "scroll-t"; + if (Game.viewport.GetBlockedDirections().Includes(ScrollDirection.Up)) + return "scroll-t-blocked"; + else + return "scroll-t"; if (Edge.Includes(ScrollDirection.Down)) - return "scroll-b"; + if (Game.viewport.GetBlockedDirections().Includes(ScrollDirection.Down)) + return "scroll-b-blocked"; + else + return "scroll-b"; if (Edge.Includes(ScrollDirection.Left)) - return "scroll-l"; + if (Game.viewport.GetBlockedDirections().Includes(ScrollDirection.Left)) + return "scroll-l-blocked"; + else + return "scroll-l"; if (Edge.Includes(ScrollDirection.Right)) - return "scroll-r"; + if (Game.viewport.GetBlockedDirections().Includes(ScrollDirection.Right)) + return "scroll-r-blocked"; + else + return "scroll-r"; return null; } diff --git a/mods/ra/sequences.xml b/mods/ra/sequences.xml index 6707f93835..dd143170e7 100644 --- a/mods/ra/sequences.xml +++ b/mods/ra/sequences.xml @@ -327,18 +327,25 @@ - - - - - - - - - + + + + + + + + + + + + + + + + - +