change mouse sequence to blocked whene map borders are reached

This commit is contained in:
Paolo Chiodi
2010-09-02 20:28:17 +02:00
committed by Chris Forbes
parent 73017d3f5c
commit 669aaab6b4
3 changed files with 80 additions and 22 deletions

View File

@@ -56,6 +56,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)
{
this.screenSize = screenSize;

View File

@@ -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;
}

View File

@@ -327,18 +327,25 @@
<sequence name="idle" start="0" length="*" />
</unit>
<cursor src="mouse" palette="cursor">
<sequence name="scroll-t" start="1" x="12" y="12" />
<sequence name="scroll-tr" start="2" x="12" y="12" />
<sequence name="scroll-r" start="3" x="12" y="12" />
<sequence name="scroll-br" start="4" x="12" y="12" />
<sequence name="scroll-b" start="5" x="12" y="12" />
<sequence name="scroll-bl" start="6" x="12" y="12" />
<sequence name="scroll-l" start="7" x="12" y="12" />
<sequence name="scroll-tl" start="8" x="12" y="12" />
<sequence name="scroll-blocked" start="124" length="8" />
<sequence name="scroll-t" start="1" x="12" y="12" />
<sequence name="scroll-tr" start="2" x="12" y="12" />
<sequence name="scroll-r" start="3" x="12" y="12" />
<sequence name="scroll-br" start="4" x="12" y="12" />
<sequence name="scroll-b" start="5" x="12" y="12" />
<sequence name="scroll-bl" start="6" x="12" y="12" />
<sequence name="scroll-l" start="7" x="12" y="12" />
<sequence name="scroll-tl" start="8" x="12" y="12" />
<sequence name="scroll-t-blocked" start="124" x="12" y="12" />
<sequence name="scroll-tr-blocked" start="125" x="12" y="12" />
<sequence name="scroll-r-blocked" start="126" x="12" y="12" />
<sequence name="scroll-br-blocked" start="127" x="12" y="12" />
<sequence name="scroll-b-blocked" start="128" x="12" y="12" />
<sequence name="scroll-bl-blocked" start="129" x="12" y="12" />
<sequence name="scroll-l-blocked" start="130" x="12" y="12" />
<sequence name="scroll-lt-blocked" start="131" x="12" y="12" />
<sequence name="select" start="15" length="6" x="12" y="12" />
<sequence name="default" start="0" />
<sequence name="default" start="0" />
<sequence name="default-minimap" start="80" />
<sequence name="generic-blocked" start="9" />
<sequence name="generic-blocked-minimap" start="33" />