Added hotkeys for save areas of the map

This commit is contained in:
Viszkok Tamás
2016-04-16 19:01:50 +02:00
committed by Tamás Viszkok
parent 0538f0c66e
commit a89376daf0
2 changed files with 82 additions and 1 deletions

View File

@@ -207,6 +207,16 @@ namespace OpenRA
public Hotkey MapScrollLeft = new Hotkey(Keycode.LEFT, Modifiers.None);
public Hotkey MapScrollRight = new Hotkey(Keycode.RIGHT, Modifiers.None);
public Hotkey ViewPortBookmarkSaveSlot1 = new Hotkey(Keycode.Q, Modifiers.Ctrl);
public Hotkey ViewPortBookmarkSaveSlot2 = new Hotkey(Keycode.W, Modifiers.Ctrl);
public Hotkey ViewPortBookmarkSaveSlot3 = new Hotkey(Keycode.E, Modifiers.Ctrl);
public Hotkey ViewPortBookmarkSaveSlot4 = new Hotkey(Keycode.R, Modifiers.Ctrl);
public Hotkey ViewPortBookmarkUseSlot1 = new Hotkey(Keycode.Q, Modifiers.Alt);
public Hotkey ViewPortBookmarkUseSlot2 = new Hotkey(Keycode.W, Modifiers.Alt);
public Hotkey ViewPortBookmarkUseSlot3 = new Hotkey(Keycode.E, Modifiers.Alt);
public Hotkey ViewPortBookmarkUseSlot4 = new Hotkey(Keycode.R, Modifiers.Alt);
public Hotkey PauseKey = new Hotkey(Keycode.PAUSE, Modifiers.None);
public Hotkey PlaceBeaconKey = new Hotkey(Keycode.B, Modifiers.None);
public Hotkey SellKey = new Hotkey(Keycode.Z, Modifiers.None);

View File

@@ -72,6 +72,29 @@ namespace OpenRA.Mods.Common.Widgets
ScrollDirection edgeDirections;
World world;
WorldRenderer worldRenderer;
WPos?[] viewPortBookmarkSlots = new WPos?[4];
void SaveBookmark(int index, WPos position)
{
viewPortBookmarkSlots[index] = position;
}
void SaveCurrentPositionToBookmark(int index)
{
SaveBookmark(index, worldRenderer.Viewport.CenterPosition);
}
WPos? JumpToBookmark(int index)
{
return viewPortBookmarkSlots[index];
}
void JumpToSavedBookmark(int index)
{
var bookmark = JumpToBookmark(index);
if (bookmark != null)
worldRenderer.Viewport.Center((WPos)bookmark);
}
[ObjectCreator.UseCtor]
public ViewportControllerWidget(World world, WorldRenderer worldRenderer)
@@ -305,6 +328,54 @@ namespace OpenRA.Mods.Common.Widgets
return true;
}
if (key == ks.ViewPortBookmarkSaveSlot1)
{
SaveCurrentPositionToBookmark(0);
return false;
}
if (key == ks.ViewPortBookmarkSaveSlot2)
{
SaveCurrentPositionToBookmark(1);
return false;
}
if (key == ks.ViewPortBookmarkSaveSlot3)
{
SaveCurrentPositionToBookmark(2);
return false;
}
if (key == ks.ViewPortBookmarkSaveSlot4)
{
SaveCurrentPositionToBookmark(3);
return false;
}
if (key == ks.ViewPortBookmarkUseSlot1)
{
JumpToSavedBookmark(0);
return false;
}
if (key == ks.ViewPortBookmarkUseSlot2)
{
JumpToSavedBookmark(1);
return false;
}
if (key == ks.ViewPortBookmarkUseSlot3)
{
JumpToSavedBookmark(2);
return false;
}
if (key == ks.ViewPortBookmarkUseSlot4)
{
JumpToSavedBookmark(3);
return false;
}
return false;
}