Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape menu cleanup #2576

Closed

Conversation

DerekGooding
Copy link
Contributor

This should fix the layout so it looks like this now:

image

Might need to make an update to the Asset repo to reflect these changes. The label edits are overridden by the EscapeMenu.json unless you completely comment out the label, compile and run, then uncomment.

Maybe I'll take a look at how the load and save json works later. Save that headache.

Fixes Issue #2546

Comment on lines 95 to 110
private SettingsWindow SettingsWindow
{
_settingsWindow ??= new SettingsWindow(GameCanvas)
get
{
IsVisible = false,
};

return _settingsWindow;
return _settingsWindow ??= new SettingsWindow(GameCanvas)
{
IsVisible = false,
};
}
}

public GameInterface(Canvas canvas) : base(canvas)
{
GameCanvas = canvas;
EscapeMenu = new EscapeMenu(GameCanvas, GetOrCreateSettingsWindow) {IsHidden = true};
SimplifiedEscapeMenu = new SimplifiedEscapeMenu(GameCanvas, GetOrCreateSettingsWindow) {IsHidden = true};
EscapeMenu = new EscapeMenu(GameCanvas, SettingsWindow) {IsHidden = true};
SimplifiedEscapeMenu = new SimplifiedEscapeMenu(GameCanvas, SettingsWindow) {IsHidden = true};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl;dr: Revert the changes in this file

SettingsWindow is a bit heavy and I intentionally wanted to defer creation until it's needed. To that end, passing a delegate was necessary and the getter, while on the surface is doing the same thing, isn't actually having the same effect.

In this case it's creating only one, but it's creating it immediately in the constructor of GameInterface. With the methods, it was only ever created when _settingsWindowProvider() was invoked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also revert, since the only changes are SettingsWindow related

Comment on lines 15 to 23
private readonly SettingsWindow _settingsWindow;
private readonly Button _buttonCharacterSelect;
private readonly Panel _versionPanel;

public EscapeMenu(Canvas gameCanvas, Func<SettingsWindow> settingsWindowProvider) : base(gameCanvas, nameof(EscapeMenu))
private readonly Framework.Graphics.GameFont _font;

public EscapeMenu(Canvas gameCanvas, SettingsWindow settingsWindow) : base(gameCanvas, nameof(EscapeMenu))
{
_settingsWindowProvider = settingsWindowProvider;
_settingsWindow = settingsWindow;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely want to continue using the delegate, revert the SettingsWindow changes here (but keep the font one)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I hadn't considered the lazy implementation. I guess I assumed settingsmenu would be called long before the EscapeMenu would be constructed. But you're correct. If someone plays the game and exits without ever hitting settings, the delegate version saves having to load the settings menu.

…ference instead of a func<>."

This reverts commit 2abebfa.
@DerekGooding
Copy link
Contributor Author

This is no longer required. New PR obsoletes these changes.

@DerekGooding DerekGooding deleted the Escape-Menu-Cleanup branch February 17, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants