Skip to content

Commit

Permalink
Place Minimap on MainMenuBar and add configurable hotkey for it
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Oct 2, 2024
1 parent 7651d4d commit 8e20244
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CentrED/Keymap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class Keymap
public const string MoveLeft = "move_left";
public const string MoveRight = "move_right";
public const string ToggleAnimatedStatics = "toggle_animated_statics";

public const string Minimap = "minimap";

public static void Update(KeyboardState newState)
{
Expand Down Expand Up @@ -100,6 +100,7 @@ private static (Keys[],Keys[]) GetDefault(string action)
MoveLeft => ([Keys.A], [Keys.Left]),
MoveRight => ([Keys.D], [Keys.Right]),
ToggleAnimatedStatics => ([Keys.LeftControl, Keys.A], NotAssigned),
Minimap => ([Keys.M], NotAssigned),
_ => (NotAssigned, NotAssigned)
};
}
Expand Down
5 changes: 5 additions & 0 deletions CentrED/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,11 @@ public void Update(GameTime gameTime, bool isActive, bool processMouse, bool pro
{
AnimatedStatics = !AnimatedStatics;
}
if(Keymap.IsKeyPressed(Keymap.Minimap))
{
var minimapWindow = CEDGame.UIManager.GetWindow<MinimapWindow>();
minimapWindow.Show = !minimapWindow.Show;
}
else
{
if (keyState.IsKeyDown(Keys.LeftControl) || keyState.IsKeyDown(Keys.RightControl))
Expand Down
9 changes: 5 additions & 4 deletions CentrED/UI/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public enum Category
internal List<Window> MainWindows = new();
internal List<Window> ToolsWindows = new();

internal MinimapWindow MinimapWindow;
internal DebugWindow DebugWindow;
public UIManager(GraphicsDevice gd)
{
Expand Down Expand Up @@ -81,12 +82,13 @@ public UIManager(GraphicsDevice gd)
AddWindow(Category.Tools, new LandBrushWindow());
AddWindow(Category.Tools, new HuesWindow());
AddWindow(Category.Tools, new FilterWindow());
AddWindow(Category.Tools, new MinimapWindow());
AddWindow(Category.Tools, new HistoryWindow());
AddWindow(Category.Tools, new LSOWindow());
AddWindow(Category.Tools, new ChatWindow());
AddWindow(Category.Tools, new ServerAdminWindow());

MinimapWindow = new MinimapWindow();
AllWindows.Add(MinimapWindow);
DebugWindow = new DebugWindow();
}

Expand Down Expand Up @@ -250,8 +252,7 @@ protected virtual void DrawUI()
DrawContextMenu();
DrawMainMenu();
DrawStatusBar();
MainWindows.ForEach(w => w.Draw());
ToolsWindows.ForEach(w => w.Draw());
AllWindows.ForEach(w => w.Draw());
DebugWindow.Draw();
}

Expand Down Expand Up @@ -369,7 +370,7 @@ private void DrawMainMenu()
ToolsWindows.ForEach(w => w.DrawMenuItem());
ImGui.EndMenu();
}

MinimapWindow.DrawMenuItem();
if (ImGui.BeginMenu("Help"))
{
if (ImGui.MenuItem("Reset layout", File.Exists("imgui.ini.default")))
Expand Down
1 change: 1 addition & 0 deletions CentrED/UI/Windows/OptionsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private void DrawKeymapOptions()
DrawSingleKey(Keymap.MoveRight);
ImGui.Separator();
DrawSingleKey(Keymap.ToggleAnimatedStatics);
DrawSingleKey(Keymap.Minimap);
ImGui.EndTabItem();
}
}
Expand Down

0 comments on commit 8e20244

Please sign in to comment.