summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/listeners/inputactionreplayconfirmlistener.cpp68
-rw-r--r--src/listeners/inputactionreplayconfirmlistener.h52
-rw-r--r--src/progs/manaverse/actions/commands.cpp18
5 files changed, 141 insertions, 1 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6195f9260..ef30cd3cb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1520,6 +1520,8 @@ SET(SRCS
listeners/guitableactionlistener.h
listeners/inputactionremotelistener.cpp
listeners/inputactionremotelistener.h
+ listeners/inputactionreplayconfirmlistener.cpp
+ listeners/inputactionreplayconfirmlistener.h
listeners/inputactionreplaylistener.cpp
listeners/inputactionreplaylistener.h
listeners/insertcardlistener.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 5b50a3ed7..141e4897b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1386,6 +1386,8 @@ SRC = ${BASE_SRC} \
listeners/playerpostdeathlistener.h \
listeners/inputactionremotelistener.cpp \
listeners/inputactionremotelistener.h \
+ listeners/inputactionreplayconfirmlistener.cpp \
+ listeners/inputactionreplayconfirmlistener.h \
listeners/inputactionreplaylistener.cpp \
listeners/inputactionreplaylistener.h \
listeners/insertcardlistener.h \
diff --git a/src/listeners/inputactionreplayconfirmlistener.cpp b/src/listeners/inputactionreplayconfirmlistener.cpp
new file mode 100644
index 000000000..0ac28677b
--- /dev/null
+++ b/src/listeners/inputactionreplayconfirmlistener.cpp
@@ -0,0 +1,68 @@
+/*
+ * The ManaVerse Client
+ * Copyright (C) 2024-2025 The ManaVerse Developers
+ *
+ * This file is part of The ManaVerse Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "listeners/inputactionreplayconfirmlistener.h"
+
+#include "gui/windows/confirmdialog.h"
+
+#include "gui/widgets/createwidget.h"
+
+#include "input/inputmanager.h"
+
+#include "const/sound.h"
+
+#include "debug.h"
+
+InputActionReplayConfirmListener inputActionReplayConfirmListener;
+
+InputActionReplayConfirmListener::InputActionReplayConfirmListener() :
+ ActionListener(),
+ mDialog(nullptr),
+ mAction(InputAction::NO_VALUE)
+{
+}
+
+void InputActionReplayConfirmListener::openDialog(
+ const std::string &title,
+ const std::string &text,
+ const InputActionT action0)
+{
+ CREATEWIDGETV(mDialog, ConfirmDialog,
+ title, text,
+ SOUND_REQUEST,
+ false,
+ Modal_true,
+ nullptr);
+
+ mDialog->addActionListener(this);
+ mAction = action0;
+}
+
+void InputActionReplayConfirmListener::action(const ActionEvent &event)
+{
+ if (mDialog != nullptr)
+ {
+ const std::string &eventId = event.getId();
+ inputManager.executeChatCommand(mAction, eventId, nullptr);
+ // the dialog deletes itself with scheduleDelete()
+ mDialog = nullptr;
+ }
+ mAction = InputAction::NO_VALUE;
+}
diff --git a/src/listeners/inputactionreplayconfirmlistener.h b/src/listeners/inputactionreplayconfirmlistener.h
new file mode 100644
index 000000000..c7c60e2ff
--- /dev/null
+++ b/src/listeners/inputactionreplayconfirmlistener.h
@@ -0,0 +1,52 @@
+/*
+ * The ManaVerse Client
+ * Copyright (C) 2024-2025 The ManaVerse Developers
+ *
+ * This file is part of The ManaVerse Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LISTENERS_INPUTACTIONREPLAYCONFIRMLISTENER_H
+#define LISTENERS_INPUTACTIONREPLAYCONFIRMLISTENER_H
+
+#include "enums/input/inputaction.h"
+
+#include "listeners/actionlistener.h"
+
+#include "localconsts.h"
+
+class ConfirmDialog;
+
+class InputActionReplayConfirmListener final : public ActionListener
+{
+ public:
+ InputActionReplayConfirmListener();
+
+ A_DELETE_COPY(InputActionReplayConfirmListener)
+
+ void action(const ActionEvent &event) override final;
+
+ void openDialog(const std::string &title,
+ const std::string &text,
+ const InputActionT action0);
+
+ protected:
+ ConfirmDialog *mDialog;
+ InputActionT mAction;
+};
+
+extern InputActionReplayConfirmListener inputActionReplayConfirmListener;
+
+#endif // LISTENERS_INPUTACTIONREPLAYCONFIRMLISTENER_H
diff --git a/src/progs/manaverse/actions/commands.cpp b/src/progs/manaverse/actions/commands.cpp
index 9a622b627..668c54b80 100644
--- a/src/progs/manaverse/actions/commands.cpp
+++ b/src/progs/manaverse/actions/commands.cpp
@@ -58,6 +58,7 @@
#include "input/inputactionoperators.h"
#include "listeners/inputactionreplaylistener.h"
+#include "listeners/inputactionreplayconfirmlistener.h"
#include "net/adminhandler.h"
#include "net/chathandler.h"
@@ -966,7 +967,22 @@ impHandler(setHomunculusName)
impHandler0(fireHomunculus)
{
- if (homunculusHandler != nullptr)
+ const HomunculusInfo *const info = PlayerInfo::getHomunculus();
+ if (info == nullptr)
+ return false;
+
+ const std::string &args = event.args;
+ if (args.empty())
+ {
+ inputActionReplayConfirmListener.openDialog(
+ // TRANSLATORS: dialog title
+ _("Really?"),
+ // TRANSLATORS: dialog question
+ _("Really kill your homunculous? This is irreversible!"),
+ InputAction::HOMUNCULUS_FIRE);
+ return true;
+ }
+ else if (args == "yes" && homunculusHandler != nullptr)
{
homunculusHandler->fire();
return true;