From b4411b11fe2feed40d92287a69ee315238646d4b Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 26 Nov 2021 18:29:22 +0800 Subject: [PATCH] Fix #4677 --- src/states_screens/dialogs/message_dialog.cpp | 9 +++++---- src/states_screens/dialogs/message_dialog.hpp | 10 ++++++---- src/states_screens/race_result_gui.cpp | 4 +++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/states_screens/dialogs/message_dialog.cpp b/src/states_screens/dialogs/message_dialog.cpp index f493918b8..bdef21d64 100644 --- a/src/states_screens/dialogs/message_dialog.cpp +++ b/src/states_screens/dialogs/message_dialog.cpp @@ -40,14 +40,14 @@ MessageDialog::MessageDialog(const irr::core::stringw &msg, MessageDialogType type, IConfirmDialogListener* listener, bool own_listener, bool from_queue, - float width, float height) + float width, float height, bool focus_on_cancel) : ModalDialog(width, height) { m_msg = msg; m_type = type; m_listener = listener; m_own_listener = own_listener; - m_focus_on_cancel = false; + m_focus_on_cancel = focus_on_cancel; doInit(from_queue); } // MessageDialog(stringw, type, listener, own_listener) @@ -58,14 +58,15 @@ MessageDialog::MessageDialog(const irr::core::stringw &msg, * loadFromFile() is not called (it will be called when the dialog * is finally being removed from the queue and shown). */ -MessageDialog::MessageDialog(const irr::core::stringw &msg, bool from_queue) +MessageDialog::MessageDialog(const irr::core::stringw &msg, bool from_queue, + bool focus_on_cancel) : ModalDialog(0.6f, 0.6f) { m_msg = msg; m_type = MessageDialog::MESSAGE_DIALOG_OK; m_listener = NULL; m_own_listener = false; - m_focus_on_cancel = false; + m_focus_on_cancel = focus_on_cancel; if (!from_queue) doInit(false); } // MessageDialog(stringw) diff --git a/src/states_screens/dialogs/message_dialog.hpp b/src/states_screens/dialogs/message_dialog.hpp index a98956f83..57c192485 100644 --- a/src/states_screens/dialogs/message_dialog.hpp +++ b/src/states_screens/dialogs/message_dialog.hpp @@ -89,14 +89,16 @@ public: */ MessageDialog(const irr::core::stringw &msg, MessageDialogType type, IConfirmDialogListener* listener, bool delete_listener, - bool from_queue = false, float width = 0.6f, float height = 0.6f); - + bool from_queue = false, float width = 0.6f, float height = 0.6f, + bool focus_on_cancel = false); + /** * Variant of MessageDialog where cancelling is not possible (i.e. just shows a message box with OK) * \param msg Message to display in the dialog */ - MessageDialog(const irr::core::stringw &msg, bool from_queue = false); - + MessageDialog(const irr::core::stringw &msg, bool from_queue = false, + bool focus_on_cancel = false); + ~MessageDialog(); virtual void onEnterPressedInternal() OVERRIDE; diff --git a/src/states_screens/race_result_gui.cpp b/src/states_screens/race_result_gui.cpp index 6e2103878..9760cb33a 100644 --- a/src/states_screens/race_result_gui.cpp +++ b/src/states_screens/race_result_gui.cpp @@ -528,7 +528,9 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget, else if (action == "right") // Abort { new MessageDialog(_("Do you really want to abort the Grand Prix?"), - MessageDialog::MESSAGE_DIALOG_CONFIRM, this, false); + MessageDialog::MESSAGE_DIALOG_CONFIRM, this, + /*delete_listener*/false, /*from_queue*/false, + /*width*/0.6f, /*height*/0.6f, /*focus_on_cancel*/true); } else if (!getWidget(action.c_str())->isVisible()) {