2013-04-10 04:32:05 +00:00
|
|
|
#include "textinput.hpp"
|
|
|
|
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
namespace MWGui
|
2013-04-10 04:32:05 +00:00
|
|
|
{
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
TextInputDialog::TextInputDialog()
|
|
|
|
: WindowModal("openmw_text_input.layout")
|
|
|
|
{
|
|
|
|
// Centre dialog
|
|
|
|
center();
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
getWidget(mTextEdit, "TextEdit");
|
|
|
|
mTextEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
MyGUI::Button* okButton;
|
|
|
|
getWidget(okButton, "OKButton");
|
|
|
|
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked);
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
// Make sure the edit box has focus
|
2013-06-16 16:06:55 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void TextInputDialog::setNextButtonShow(bool shown)
|
|
|
|
{
|
|
|
|
MyGUI::Button* okButton;
|
|
|
|
getWidget(okButton, "OKButton");
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
if (shown)
|
|
|
|
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", ""));
|
|
|
|
else
|
|
|
|
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
|
|
|
|
}
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void TextInputDialog::setTextLabel(const std::string &label)
|
|
|
|
{
|
|
|
|
setText("LabelT", label);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextInputDialog::open()
|
|
|
|
{
|
|
|
|
WindowModal::open();
|
|
|
|
// Make sure the edit box has focus
|
2013-06-16 16:06:55 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
// widget controls
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void TextInputDialog::onOkClicked(MyGUI::Widget* _sender)
|
2013-04-10 04:32:05 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
if (mTextEdit->getCaption() == "")
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage37}");
|
2013-06-16 16:06:55 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget (mTextEdit);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
eventDone(this);
|
2013-04-10 04:32:05 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 22:56:48 +00:00
|
|
|
void TextInputDialog::onTextAccepted(MyGUI::Edit* _sender)
|
2013-04-10 04:32:05 +00:00
|
|
|
{
|
2013-04-17 22:56:48 +00:00
|
|
|
if (mTextEdit->getCaption() == "")
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage37}");
|
2013-06-16 16:06:55 +00:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget (mTextEdit);
|
2013-04-17 22:56:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
eventDone(this);
|
2013-04-10 04:32:05 +00:00
|
|
|
}
|
2013-04-17 22:56:48 +00:00
|
|
|
|
2013-04-10 04:32:05 +00:00
|
|
|
}
|