Merge pull request #11130 from viszkoktamas/viewportBookmark
Add hotkeys for save areas of the map
This commit is contained in:
@@ -209,6 +209,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);
|
||||
|
||||
@@ -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)
|
||||
@@ -308,6 +331,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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user