Fix a help dialog that appears in the top-left

This commit is contained in:
2025-02-14 15:37:44 -06:00
committed by Celtic Minstrel
parent e83ad32618
commit d3dff69d1a
3 changed files with 10 additions and 5 deletions

View File

@@ -533,6 +533,13 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
makeFrontWindow(*parentWin);
}
void cDialog::runWithHelp(short help1, short help2) {
extern void give_help(short help1, short help2, cDialog& parent);
run([help1, help2](cDialog& me) -> void {
give_help(help1, help2, me);
});
}
// This method is a main event event loop of the dialog.
void cDialog::handle_events() {
sf::Event currentEvent;

View File

@@ -115,6 +115,8 @@ public:
/// Show the dialog and start its event loop. All dialogs are modal.
/// @param onopen A function to be called after the dialog is displayed but before the event loop starts.
void run(std::function<void(cDialog&)> onopen = nullptr); // cd_run_dialog
/// Show this dialog. Before starting its event loop, show a help window if it hasn't been shown before.
void runWithHelp(short help1, short help2);
/// Get the result of the dialog.
/// @tparam type The result type.
/// @throw boost::bad_any_cast if the provided result type is different from the type set by setResult().

View File

@@ -553,11 +553,7 @@ bool spend_xp(short pc_num, short mode, cDialog* parent) {
xpDlog.attachClickHandlers(std::bind(spend_xp_navigate_filter,_1,_2,std::ref(save)),{"keep","cancel","left","right","help"});
xpDlog.attachClickHandlers(spend_xp_filter,{"sp-m","sp-p","hp-m","hp-p"});
// TODO on Mac (and maybe other platforms), when creating a new PC in the game, this help dialog appears
// in the top-left corner of the screen. It should be centered
give_help(10,11,xpDlog);
xpDlog.run();
xpDlog.runWithHelp(10,11);
return xpDlog.getResult<bool>();
}