forked from mirror/openmw-tes3mp
[Client] Implement PasswordDialog
parent
cef58fa164
commit
b84f97ec2b
@ -0,0 +1,87 @@
|
||||
//
|
||||
// Created by koncord on 06.06.17.
|
||||
//
|
||||
|
||||
#include "TextInputDialog.hpp"
|
||||
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
#include <MyGUI_EditBox.h>
|
||||
#include <MyGUI_Button.h>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
TextInputDialog::TextInputDialog()
|
||||
: MWGui::WindowModal("openmw_text_input.layout")
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
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::open()
|
||||
{
|
||||
WindowModal::open();
|
||||
// Make sure the edit box has focus
|
||||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
||||
void TextInputDialog::onOkClicked(MyGUI::Widget *_sender)
|
||||
{
|
||||
if (mTextEdit->getCaption() == "")
|
||||
{
|
||||
//MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage37}");
|
||||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
//
|
||||
// Created by koncord on 06.06.17.
|
||||
//
|
||||
|
||||
|
||||
#ifndef OPENMW_TEXTINPUTDIALOG_HPP
|
||||
#define OPENMW_TEXTINPUTDIALOG_HPP
|
||||
|
||||
#include "../mwgui/windowbase.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class WindowManager;
|
||||
}
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class TextInputDialog : public MWGui::WindowModal
|
||||
{
|
||||
public:
|
||||
TextInputDialog();
|
||||
|
||||
std::string getTextInput() const;
|
||||
void setTextInput(const std::string &text);
|
||||
|
||||
void setNextButtonShow(bool shown);
|
||||
void setTextLabel(const std::string &label);
|
||||
|
||||
void setEditPassword(bool value);
|
||||
|
||||
virtual void open();
|
||||
|
||||
/** Event : Dialog finished, OK button clicked.\n
|
||||
signature : void method()\n
|
||||
*/
|
||||
EventHandle_WindowBase eventDone;
|
||||
|
||||
protected:
|
||||
void onOkClicked(MyGUI::Widget *_sender);
|
||||
void onTextAccepted(MyGUI::Edit *_sender);
|
||||
|
||||
private:
|
||||
MyGUI::EditBox *mTextEdit;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //OPENMW_TEXTINPUTDIALOG_HPP
|
Loading…
Reference in New Issue