1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 21:19:57 +00:00
openmw-tes3mp/apps/openmw/mwgui/confirmationdialog.cpp

60 lines
1.5 KiB
C++
Raw Normal View History

2012-05-23 03:28:25 +00:00
#include "confirmationdialog.hpp"
2015-01-10 01:50:43 +00:00
#include <MyGUI_Button.h>
#include <MyGUI_EditBox.h>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
2012-05-23 03:28:25 +00:00
namespace MWGui
{
ConfirmationDialog::ConfirmationDialog() :
WindowModal("openmw_confirmation_dialog.layout")
2012-05-23 03:28:25 +00:00
{
getWidget(mMessage, "Message");
getWidget(mOkButton, "OkButton");
getWidget(mCancelButton, "CancelButton");
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ConfirmationDialog::onCancelButtonClicked);
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ConfirmationDialog::onOkButtonClicked);
}
2017-03-30 13:05:56 +00:00
void ConfirmationDialog::askForConfirmation(const std::string& message)
2012-05-23 03:28:25 +00:00
{
setVisible(true);
mMessage->setCaptionWithReplacing(message);
2017-03-30 13:05:56 +00:00
int height = mMessage->getTextSize().height + 60;
2017-03-30 13:05:56 +00:00
int width = mMessage->getTextSize().width + 24;
2012-05-23 03:28:25 +00:00
2017-03-30 13:05:56 +00:00
mMainWidget->setSize(width, height);
2012-05-23 03:28:25 +00:00
2017-03-30 13:05:56 +00:00
mMessage->setSize(mMessage->getWidth(), mMessage->getTextSize().height + 24);
2012-05-23 03:28:25 +00:00
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mOkButton);
2012-05-23 03:28:25 +00:00
center();
}
2017-09-23 10:18:39 +00:00
bool ConfirmationDialog::exit()
2012-05-23 03:28:25 +00:00
{
2019-09-02 14:49:29 +00:00
setVisible(false);
eventCancelClicked();
2017-09-23 10:18:39 +00:00
return true;
2012-05-23 03:28:25 +00:00
}
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
{
exit();
}
2012-05-23 03:28:25 +00:00
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
{
setVisible(false);
eventOkClicked();
2012-05-23 03:28:25 +00:00
}
}