From 271c921cf850be2e2340301048de802ebb5909f6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 7 Sep 2014 03:18:01 +0200 Subject: [PATCH] Add missing confirmation dialog for deleting map notes --- apps/openmw/mwgui/confirmationdialog.cpp | 5 ++++- apps/openmw/mwgui/confirmationdialog.hpp | 2 +- apps/openmw/mwgui/mapwindow.cpp | 10 ++++++++++ apps/openmw/mwgui/mapwindow.hpp | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/confirmationdialog.cpp b/apps/openmw/mwgui/confirmationdialog.cpp index 57c88bfa2..a4e10749a 100644 --- a/apps/openmw/mwgui/confirmationdialog.cpp +++ b/apps/openmw/mwgui/confirmationdialog.cpp @@ -13,12 +13,15 @@ namespace MWGui mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ConfirmationDialog::onOkButtonClicked); } - void ConfirmationDialog::open(const std::string& message) + void ConfirmationDialog::open(const std::string& message, const std::string& confirmMessage, const std::string& cancelMessage) { setVisible(true); mMessage->setCaptionWithReplacing(message); + mCancelButton->setCaptionWithReplacing(cancelMessage); + mOkButton->setCaptionWithReplacing(confirmMessage); + int height = mMessage->getTextSize().height + 72; mMainWidget->setSize(mMainWidget->getWidth(), height); diff --git a/apps/openmw/mwgui/confirmationdialog.hpp b/apps/openmw/mwgui/confirmationdialog.hpp index c50873c74..7ff16b10a 100644 --- a/apps/openmw/mwgui/confirmationdialog.hpp +++ b/apps/openmw/mwgui/confirmationdialog.hpp @@ -9,7 +9,7 @@ namespace MWGui { public: ConfirmationDialog(); - void open(const std::string& message); + void open(const std::string& message, const std::string& confirmMessage="#{sOk}", const std::string& cancelMessage="#{sCancel}"); virtual void exit(); typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 2271fc2e5..1968181ce 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -17,6 +17,7 @@ #include "../components/esm/globalmap.hpp" #include "widgets.hpp" +#include "confirmationdialog.hpp" namespace { @@ -567,6 +568,15 @@ namespace MWGui } void MapWindow::onNoteEditDelete() + { + ConfirmationDialog* confirmation = MWBase::Environment::get().getWindowManager()->getConfirmationDialog(); + confirmation->open("#{sDeleteNote}", "#{sYes}", "#{sNo}"); + confirmation->eventCancelClicked.clear(); + confirmation->eventOkClicked.clear(); + confirmation->eventOkClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditDeleteConfirm); + } + + void MapWindow::onNoteEditDeleteConfirm() { mCustomMarkers.deleteMarker(mEditingMarker); diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index 1c7ba34ed..a9edbe0b1 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -198,6 +198,7 @@ namespace MWGui void onMapDoubleClicked(MyGUI::Widget* sender); void onNoteEditOk(); void onNoteEditDelete(); + void onNoteEditDeleteConfirm(); void onNoteDoubleClicked(MyGUI::Widget* sender); void globalMapUpdatePlayer();