[Client] Implement PasswordDialog

0.6.1
Koncord 8 years ago
parent cef58fa164
commit b84f97ec2b

@ -97,7 +97,7 @@ add_openmw_dir (mwbase
)
add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer PlayerList LocalActor DedicatedActor ActorList WorldEvent
Cell CellController MechanicsHelper GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList
Cell CellController MechanicsHelper GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList TextInputDialog
BaseClientPacketProcessor PlayerProcessor WorldProcessor ActorProcessor ProcessorInitializer
)

@ -149,7 +149,10 @@ void mwmp::GUIController::showInputBox(const BasePlayer::GUIMessageBox &guiMessa
windowManager->removeDialog(mInputBox);
windowManager->pushGuiMode((MWGui::GuiMode)GM_TES3MP_InputBox);
mInputBox = 0;
mInputBox = new MWGui::TextInputDialog();
mInputBox = new TextInputDialog();
mInputBox->setEditPassword(guiMessageBox.type == BasePlayer::GUIMessageBox::PasswordDialog);
mInputBox->setTextLabel(guiMessageBox.label);
mInputBox->eventDone += MyGUI::newDelegate(this, &GUIController::onInputBoxDone);

@ -7,11 +7,11 @@
#include <components/settings/settings.hpp>
#include "../mwgui/textinput.hpp"
#include "../mwgui/mode.hpp"
#include <components/openmw-mp/Base/BasePlayer.hpp>
#include "PlayerMarkerCollection.hpp"
#include "TextInputDialog.hpp"
namespace MWGui
{
@ -70,7 +70,7 @@ namespace mwmp
long id;
bool calledMessageBox;
MWGui::TextInputDialog *mInputBox;
TextInputDialog *mInputBox;
GUIDialogList *mListBox;
void onInputBoxDone(MWGui::WindowBase* parWindow);
//MyGUI::Widget *oldFocusWidget, *currentFocusWidget;

@ -69,7 +69,7 @@ string comparePlugins(PacketPreInit::PluginContainer checksums, PacketPreInit::P
sstr << plugin << " (" << Utils::intToHexStr(checksums.at(i).second[0]) << ")";
lineLength = lineLength + plugin.size() + 13;
lineLength += + plugin.size() + 13;
}
sstr << "\n\nTo join this server, use:\n";
@ -104,7 +104,7 @@ string comparePlugins(PacketPreInit::PluginContainer checksums, PacketPreInit::P
sstr << ")";
lineLength = lineLength + plugin.size() + 13;
lineLength += + plugin.size() + 13;
}
return sstr.str();

@ -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

@ -25,16 +25,22 @@ namespace mwmp
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GUI_MESSAGEBOX, Type %d, MSG %s", player->guiMessageBox.type,
player->guiMessageBox.label.c_str());
int messageBoxType = player->guiMessageBox.type;
if (messageBoxType == BasePlayer::GUIMessageBox::MessageBox)
Main::get().getGUIController()->showMessageBox(player->guiMessageBox);
else if (messageBoxType == BasePlayer::GUIMessageBox::CustomMessageBox)
Main::get().getGUIController()->showCustomMessageBox(player->guiMessageBox);
else if (messageBoxType == BasePlayer::GUIMessageBox::InputDialog)
Main::get().getGUIController()->showInputBox(player->guiMessageBox);
else if (messageBoxType == BasePlayer::GUIMessageBox::ListBox)
Main::get().getGUIController()->showDialogList(player->guiMessageBox);
switch(player->guiMessageBox.type)
{
case BasePlayer::GUIMessageBox::MessageBox:
Main::get().getGUIController()->showMessageBox(player->guiMessageBox);
break;
case BasePlayer::GUIMessageBox::CustomMessageBox:
Main::get().getGUIController()->showCustomMessageBox(player->guiMessageBox);
break;
case BasePlayer::GUIMessageBox::InputDialog:
case BasePlayer::GUIMessageBox::PasswordDialog:
Main::get().getGUIController()->showInputBox(player->guiMessageBox);
break;
case BasePlayer::GUIMessageBox::ListBox:
Main::get().getGUIController()->showDialogList(player->guiMessageBox);
break;
}
}
}
};

Loading…
Cancel
Save