diff --git a/src/dialogxml/dialogs/dialog.hpp b/src/dialogxml/dialogs/dialog.hpp index bd9e27af..1b6e712b 100644 --- a/src/dialogxml/dialogs/dialog.hpp +++ b/src/dialogxml/dialogs/dialog.hpp @@ -114,11 +114,22 @@ public: void run(std::function onopen = nullptr); // cd_run_dialog /// 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 getResult(). + /// @throw boost::bad_any_cast if the provided result type is different from the type set by setResult(). /// @return The dialog's result. template type getResult() const { return boost::any_cast(result); } + /// Check if the dialog has a result. + /// @return true if setResult() was called, otherwise false. + bool hasResult() const { + return !result.empty(); + } + /// Query the type of the result. + /// @tparam type The result type to query. + /// @return true if the type matches that set by setResult(). + template bool resultIs() const { + return result.type() == typeid(type); + } /// Set the result of the dialog. /// @tparam type The result type. /// @param val The result value. diff --git a/src/game/boe.dlgutil.cpp b/src/game/boe.dlgutil.cpp index 05a683d1..63f0ffd2 100644 --- a/src/game/boe.dlgutil.cpp +++ b/src/game/boe.dlgutil.cpp @@ -1508,8 +1508,6 @@ class cChooseScenario { } bool doCancel() { - scen_header_type null; - me.setResult(null); me.toast(false); return true; } @@ -1576,6 +1574,7 @@ public: } me.run(); + if(!me.hasResult()) return scen_header_type{}; scen_header_type scen = me.getResult(); if(scen.file.empty()){ std::ostringstream error;