From 3363acba6f1e8e51937ae2e354a8086c5c56b8cd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 20 May 2018 06:11:17 +0300 Subject: Show gm revive button in death dialog if player have rights for @alive command. --- src/gui/dialogsmanager.cpp | 43 ++++++++++++++++++++++++++++----------- src/gui/windows/confirmdialog.cpp | 31 ++++++++++++++++++++++++---- src/gui/windows/confirmdialog.h | 16 +++++++++++++++ 3 files changed, 74 insertions(+), 16 deletions(-) (limited to 'src/gui') diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp index 2a4f407ee..288fadc94 100644 --- a/src/gui/dialogsmanager.cpp +++ b/src/gui/dialogsmanager.cpp @@ -48,6 +48,7 @@ #include "net/inventoryhandler.h" #include "resources/db/deaddb.h" +#include "resources/db/groupdb.h" #include "utils/gettext.h" @@ -57,7 +58,7 @@ #undef ERROR #endif // WIN32 -OkDialog *deathNotice = nullptr; +Window *deathNotice = nullptr; DialogsManager *dialogsManager = nullptr; OkDialog *weightNotice = nullptr; time_t weightNoticeTime = 0; @@ -141,17 +142,35 @@ void DialogsManager::playerDeath() #ifndef DYECMD if (deathNotice == nullptr) { - CREATEWIDGETV(deathNotice, OkDialog, - // TRANSLATORS: message header - _("Message"), - DeadDB::getRandomString(), - // TRANSLATORS: ok dialog button - _("Revive"), - DialogType::OK, - Modal_false, - ShowCenter_true, - nullptr, - 260); + if (GroupDb::isAllowCommand(ServerCommandType::alive)) + { + CREATEWIDGETV(deathNotice, ConfirmDialog, + // TRANSLATORS: message header + _("Message"), + DeadDB::getRandomString(), + // TRANSLATORS: ok dialog button + _("Revive"), + // TRANSLATORS: ok dialog button + _("GM revive"), + SOUND_REQUEST, + false, + Modal_false, + nullptr); + } + else + { + CREATEWIDGETV(deathNotice, OkDialog, + // TRANSLATORS: message header + _("Message"), + DeadDB::getRandomString(), + // TRANSLATORS: ok dialog button + _("Revive"), + DialogType::OK, + Modal_false, + ShowCenter_true, + nullptr, + 260); + } deathNotice->addActionListener(&postDeathListener); } #endif // DYECMD diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index a77d3bece..73f23e172 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -41,6 +41,31 @@ ConfirmDialog::ConfirmDialog(const std::string &restrict title, Window *const parent) : Window(title, modal, parent, "confirm.xml"), ActionListener(), + // TRANSLATORS: confirm dialog button + mYesMsg(_("Yes")), + // TRANSLATORS: confirm dialog button + mNoMsg(_("No")), + mTextBox(new TextBox(this)), + mIgnore(ignore) +{ + mTextBox->setEditable(false); + mTextBox->setOpaque(Opaque_false); + mTextBox->setTextWrapped(msg, 260); + soundManager.playGuiSound(soundEvent); +} + +ConfirmDialog::ConfirmDialog(const std::string &restrict title, + const std::string &restrict msg, + const std::string &restrict yesMsg, + const std::string &restrict noMsg, + const std::string &restrict soundEvent, + const bool ignore, + const Modal modal, + Window *const parent) : + Window(title, modal, parent, "confirm.xml"), + ActionListener(), + mYesMsg(yesMsg), + mNoMsg(noMsg), mTextBox(new TextBox(this)), mIgnore(ignore) { @@ -54,14 +79,12 @@ void ConfirmDialog::postInit() { Window::postInit(); Button *const yesButton = new Button(this, - // TRANSLATORS: confirm dialog button - _("Yes"), + mYesMsg, "yes", BUTTON_SKIN, this); Button *const noButton = new Button(this, - // TRANSLATORS: confirm dialog button - _("No"), + mNoMsg, "no", BUTTON_SKIN, this); diff --git a/src/gui/windows/confirmdialog.h b/src/gui/windows/confirmdialog.h index f2a7f9094..58522c2e2 100644 --- a/src/gui/windows/confirmdialog.h +++ b/src/gui/windows/confirmdialog.h @@ -52,6 +52,20 @@ class ConfirmDialog notfinal : public Window, const Modal modal, Window *const parent); + /** + * Constructor. + * + * @see Window::Window + */ + ConfirmDialog(const std::string &restrict title, + const std::string &restrict msg, + const std::string &restrict yesMsg, + const std::string &restrict noMsg, + const std::string &restrict soundEvent, + const bool ignore, + const Modal modal, + Window *const parent); + A_DELETE_COPY(ConfirmDialog) /** @@ -62,6 +76,8 @@ class ConfirmDialog notfinal : public Window, void postInit() override final; private: + std::string mYesMsg; + std::string mNoMsg; TextBox *mTextBox A_NONNULLPOINTER; bool mIgnore; }; -- cgit v1.2.3-60-g2f50