1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 06:19:55 +00:00
openmw-tes3mp/apps/openmw/mwmp/GUI/TextInputDialog.cpp

95 lines
2.5 KiB
C++
Raw Normal View History

2017-06-06 15:33:23 +00:00
#include "TextInputDialog.hpp"
2017-06-06 16:06:10 +00:00
#include "apps/openmw/mwbase/windowmanager.hpp"
#include "apps/openmw/mwbase/environment.hpp"
2017-06-06 15:33:23 +00:00
#include <MyGUI_EditBox.h>
#include <MyGUI_Button.h>
#include <MyGUI_InputManager.h>
2017-06-06 15:33:23 +00:00
namespace mwmp
{
TextInputDialog::TextInputDialog()
: MWGui::WindowModal("tes3mp_text_input.layout")
2017-06-06 15:33:23 +00:00
{
// Centre dialog
center();
getWidget(mTextEdit, "TextEdit");
mTextEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
MyGUI::Button *okButton;
getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked);
// Make sure the edit box has focus
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
2017-06-06 15:33:23 +00:00
}
void TextInputDialog::setNextButtonShow(bool shown)
{
MyGUI::Button *okButton;
getWidget(okButton, "OKButton");
if (shown)
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", ""));
else
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
}
void TextInputDialog::setEditPassword(bool value)
{
mTextEdit->setEditPassword(value);
}
void TextInputDialog::setTextLabel(const std::string &label)
{
setText("LabelT", label);
}
void TextInputDialog::setTextNote(const std::string &note)
{
setText("TextNote", note);
}
void TextInputDialog::onOpen()
2017-06-06 15:33:23 +00:00
{
WindowModal::onOpen();
2017-06-06 15:33:23 +00:00
// Make sure the edit box has focus
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
2017-06-06 15:33:23 +00:00
}
bool TextInputDialog::exit()
{
return false;
}
2017-06-06 15:33:23 +00:00
// widget controls
void TextInputDialog::onOkClicked(MyGUI::Widget *_sender)
{
if (mTextEdit->getCaption() == "")
{
//MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage37}");
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
2017-06-06 15:33:23 +00:00
}
else
eventDone(this);
}
void TextInputDialog::onTextAccepted(MyGUI::Edit *_sender)
{
onOkClicked(_sender);
}
std::string TextInputDialog::getTextInput() const
{
return mTextEdit->getCaption();
}
void TextInputDialog::setTextInput(const std::string &text)
{
mTextEdit->setCaption(text);
}
}