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

Add return to main menu and play map buttons to the editor #9512

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

zenseii
Copy link
Collaborator

@zenseii zenseii commented Jan 29, 2025

I had to add an extra button to keep symmetry of the dialog. The button can easily be changed to "test map" or similar.

image

Fix #8720

WIP. Need correct placing of button and design of new dialog
@zenseii zenseii added improvement New feature, request or improvement ui UI/GUI related stuff editor Map editor related stuff labels Jan 29, 2025
@zenseii zenseii added this to the 1.1.6 milestone Jan 29, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

src/fheroes2/editor/editor_interface.cpp Outdated Show resolved Hide resolved
src/fheroes2/editor/editor_interface.cpp Outdated Show resolved Hide resolved
@zenseii zenseii changed the title Add button to return to main menu from editor Add button to return to main menu from the editor Jan 29, 2025
@zenseii zenseii changed the title Add button to return to main menu from the editor Add button to return to main menu and play map buttons to the editor Jan 30, 2025
@zenseii zenseii marked this pull request as ready for review January 30, 2025 15:05
@Mr-Bajs
Copy link
Contributor

Mr-Bajs commented Jan 30, 2025

Looks nice. But would it look better if Load Map and Save Map where next to each other in the same row or column? Not that it really matters.

@zenseii zenseii changed the title Add button to return to main menu and play map buttons to the editor Add buttons to return to main menu and play map to the editor Jan 30, 2025
Copy link
Collaborator

@Districh-ru Districh-ru left a comment

Choose a reason for hiding this comment

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

Hi, @zenseii, I left several suggestions. Could you please take a look when you have time?

Comment on lines +1128 to +1135
fheroes2::Sprite mainMenuReleased;
fheroes2::Sprite mainMenuPressed;
fheroes2::getTextAdaptedButton( mainMenuReleased, mainMenuPressed, gettext_noop( "MAIN\nMENU" ),
isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK );
fheroes2::Sprite playMapReleased;
fheroes2::Sprite playMapPressed;
fheroes2::getTextAdaptedButton( playMapReleased, playMapPressed, gettext_noop( "PLAY\nMAP" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON,
isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we generate these button's images in agg_file.cpp like it is done for the other buttons?

Copy link
Owner

Choose a reason for hiding this comment

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

We want to avoid polluting agg_file.cpp file as it became too big to maintain. Having a function to do the work without increasing the number of ICN entries is a better solution.

@zenseii , I believe fheroes2::getTextAdaptedButton() function should be renamed into fheroes2::getTextAdaptedButtonSprites() function as it doesn't generate a button but only creates Sprites.

Going forward, we can create fheroes2::getTextAdaptedButton() function which will return fheroes2::ButtonSprite object so we can use it here. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So then it should be better to remove all other buttons from agg_image.cpp used in this dialog and generate them here to have the same code and to avoid questions like "Why this button image is made this way and that button - the other way?" ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ihhub and @Districh-ru. I will pause this PR and make a new one that makes these changes so that we can tidy up the button code and avoid confusion moving forward.

Copy link
Owner

Choose a reason for hiding this comment

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

Hi @Districh-ru , not all buttons from agg_file.cpp file can be removed easily. Some of them have logic for button generation, others support original resources.

}
}
else {
fheroes2::showStandardTextMessage( _( "Invalid Map" ), _( "This map is not valid. Try to save the latest changes." ), Dialog::OK );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we say about the need of 1 or more players on the map?
In example: "This map is not valid. The map should have at least one human player and be saved on your storage."

if ( le.MouseClickLeft( buttonPlayMap.area() ) ) {
// The map either hasn't been saved to a file or there aren't any human-playable colors.
if ( !conf.getCurrentMapInfo().name.empty() && conf.getCurrentMapInfo().colorsAvailableForHumans > 0 ) {
if ( fheroes2::showStandardTextMessage( _( "Play Map" ), _( "Do you wish to leave the editor and play the current map?" ), Dialog::YES | Dialog::NO )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we mention that all unsaved changes will be lost or allow to open the Save Map dialog?

Comment on lines +1251 to +1253
else if ( le.isMouseRightButtonPressedInArea( buttonMainMenu.area() ) ) {
fheroes2::showStandardTextMessage( _( "Main Menu" ), _( "Return to the game's Main Menu." ), Dialog::ZERO );
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice if we add such dialog for the PLAY MAP button :)

@zenseii
Copy link
Collaborator Author

zenseii commented Jan 30, 2025

Looks nice. But would it look better if Load Map and Save Map where next to each other in the same row or column? Not that it really matters.

Hi, @Mr-Bajs. I wanted to mimic as much as possible how the original buttons were placed but I'm really impartial to it. I guess Main Menu should be where it is and quit should be lower right, the rest is the same for me.

@Mr-Bajs
Copy link
Contributor

Mr-Bajs commented Jan 30, 2025

Looks nice. But would it look better if Load Map and Save Map where next to each other in the same row or column? Not that it really matters.

Hi, @Mr-Bajs. I wanted to mimic as much as possible how the original buttons were placed but I'm really impartial to it. I guess Main Menu should be where it is and quit should be lower right, the rest is the same for me.

Swapping places save map and play map might look better. But since also the same menu ingame would also benefit with a Main Menu button. You layout keeps the menus more similar to each other maybe thats better, atleast until or if the in game menu gets an update with a main menu button.

@zenseii zenseii changed the title Add buttons to return to main menu and play map to the editor Add return to main menu and play map buttons to the editor Jan 30, 2025
Comment on lines +1128 to +1135
fheroes2::Sprite mainMenuReleased;
fheroes2::Sprite mainMenuPressed;
fheroes2::getTextAdaptedButton( mainMenuReleased, mainMenuPressed, gettext_noop( "MAIN\nMENU" ),
isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK );
fheroes2::Sprite playMapReleased;
fheroes2::Sprite playMapPressed;
fheroes2::getTextAdaptedButton( playMapReleased, playMapPressed, gettext_noop( "PLAY\nMAP" ), isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON,
isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK );
Copy link
Owner

Choose a reason for hiding this comment

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

We want to avoid polluting agg_file.cpp file as it became too big to maintain. Having a function to do the work without increasing the number of ICN entries is a better solution.

@zenseii , I believe fheroes2::getTextAdaptedButton() function should be renamed into fheroes2::getTextAdaptedButtonSprites() function as it doesn't generate a button but only creates Sprites.

Going forward, we can create fheroes2::getTextAdaptedButton() function which will return fheroes2::ButtonSprite object so we can use it here. What do you think?

if ( le.MouseClickLeft( buttonPlayMap.area() ) ) {
// The map either hasn't been saved to a file or there aren't any human-playable colors.
if ( !conf.getCurrentMapInfo().name.empty() && conf.getCurrentMapInfo().colorsAvailableForHumans > 0 ) {
if ( fheroes2::showStandardTextMessage( _( "Play Map" ), _( "Do you wish to leave the editor and play the current map?" ), Dialog::YES | Dialog::NO )
Copy link
Owner

Choose a reason for hiding this comment

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

Should Editor start from a capital letter?

@zenseii
Copy link
Collaborator Author

zenseii commented Jan 31, 2025

@Districh-ru. I noticed that when the Play Map button is used and you arrive at the scenario info dialog, if you then press cancel the screen will flash as if a fadeout was triggered. Are fade out's somehow cued? I'm not entirely sure where to look to solve this.

@Districh-ru
Copy link
Collaborator

@Districh-ru. I noticed that when the Play Map button is used and you arrive at the scenario info dialog, if you then press cancel the screen will flash as if a fadeout was triggered. Are fade out's somehow cued? I'm not entirely sure where to look to solve this.

@zenseii, I've fixed this issue - added a check when rendering the Select Scenario dialog that also resets the need of fade effect.
Previously it was not needed because there was no way to open this dialog bypassing the main menu. :)

@Districh-ru
Copy link
Collaborator

Looks nice. But would it look better if Load Map and Save Map where next to each other in the same row or column? Not that it really matters.

Hi, @Mr-Bajs. I wanted to mimic as much as possible how the original buttons were placed but I'm really impartial to it. I guess Main Menu should be where it is and quit should be lower right, the rest is the same for me.

I'd also prefer to swap PLAY MAP and SAVE MAP so there the upper row will be for the map manipulations (new/load/save) and the lower row for the quit from Editor (to new game/main menu/OS).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Map editor related stuff improvement New feature, request or improvement ui UI/GUI related stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor: Exit option should redirect back to game main menu
4 participants