Skip to content

Commit

Permalink
fix: ♻️ Apply review changes (II)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arufonsu committed Nov 26, 2024
1 parent c3f32e8 commit b33cc08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Intersect.Client/Interface/Game/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public partial class Menu

private readonly ImagePanel mMenuBackground;

public readonly Button mMenuButton;
private readonly Button mMenuButton;

//Menu Container
private readonly ImagePanel mMenuContainer;
Expand Down Expand Up @@ -355,13 +355,13 @@ public bool HasWindowsOpen()
}

//Input Handlers
private static void MenuButtonClicked(Base sender, ClickedEventArgs arguments)
private void MenuButtonClicked(Base sender, ClickedEventArgs arguments)
{
var simplifiedEscapeMenuSetting = Globals.Database.SimplifiedEscapeMenu;

if (simplifiedEscapeMenuSetting)
{
Interface.GameUi?.SimplifiedEscapeMenu?.ToggleHidden();
Interface.GameUi?.SimplifiedEscapeMenu?.ToggleHidden(mMenuButton);
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions Intersect.Client/Interface/Game/SimplifiedEscapeMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ public SimplifiedEscapeMenu(Canvas gameCanvas) : base(gameCanvas, nameof(Simplif
LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer?.GetResolutionString());
}

public override void ToggleHidden()
public void ToggleHidden(Button? target)
{
if (!_settingsWindow.IsHidden)
if (!_settingsWindow.IsHidden || target == null)
{
return;
}

if (this.IsHidden)
{
// Position the context menu within the game canvas if near borders.
var menuPosX = Interface.GameUi.GameMenu.mMenuButton.LocalPosToCanvas(new Point(0, 0)).X;
var menuPosY = Interface.GameUi.GameMenu.mMenuButton.LocalPosToCanvas(new Point(0, 0)).Y;
var menuPosX = target.LocalPosToCanvas(new Point(0, 0)).X;
var menuPosY = target.LocalPosToCanvas(new Point(0, 0)).Y;
var newX = menuPosX;
var newY = menuPosY + Interface.GameUi.GameMenu.mMenuButton.Height + 6;
var newY = menuPosY + target.Height + 6;

if (newX + Width >= Canvas?.Width)
{
newX = menuPosX - Width + Interface.GameUi.GameMenu.mMenuButton.Width;
newX = menuPosX - Width + target.Width;
}

if (newY + Height >= Canvas?.Height)
Expand Down

0 comments on commit b33cc08

Please sign in to comment.