From 711f3271388a9716e0fed8b7705824577229b005 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sun, 25 May 2025 22:36:18 -0500 Subject: [PATCH] warn about overwriting monster ability --- rsrc/dialogs/edit-mabil-overwrite.xml | 13 +++++++++++++ src/scenedit/scen.core.cpp | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 rsrc/dialogs/edit-mabil-overwrite.xml diff --git a/rsrc/dialogs/edit-mabil-overwrite.xml b/rsrc/dialogs/edit-mabil-overwrite.xml new file mode 100644 index 00000000..7c72e26d --- /dev/null +++ b/rsrc/dialogs/edit-mabil-overwrite.xml @@ -0,0 +1,13 @@ + + + + + + + This ability will be overwritten:
+
+ {{abil}} +
+ + +
diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index 5a714051..e3ae9a17 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -1237,9 +1237,13 @@ static bool edit_monst_abil_detail(cDialog& me, std::string hit, cMonster& monst showError("Failed to add the new ability because the ability was not implemented. When reporting this, mention which ability you tried to add.", &me); return true; } + // An ability of the same basic type exists and must be overwritten if(save_abils.find(iter->first) != save_abils.end() && save_abils[iter->first].active) { - // TODO: Warn about overwriting an ability and give a choce between keeping the old or the new - bool overwrite = true; + // Warn first + cChoiceDlog confirm("edit-mabil-overwrite", {"okay", "cancel"}); + std::string name = save_abils[iter->first].to_string(iter->first); + confirm->getControl("warning").replaceText("{{abil}}", name); + bool overwrite = confirm.show() == "okay"; if(!overwrite) { monst.abil = save_abils; return true;