1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-06-23 16:11:37 +00:00

[Client] Implement PasswordDialog

This commit is contained in:
Koncord 2017-06-06 23:33:23 +08:00
parent cef58fa164
commit b84f97ec2b
7 changed files with 160 additions and 16 deletions

View file

@ -97,7 +97,7 @@ add_openmw_dir (mwbase
) )
add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer PlayerList LocalActor DedicatedActor ActorList WorldEvent 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 BaseClientPacketProcessor PlayerProcessor WorldProcessor ActorProcessor ProcessorInitializer
) )

View file

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

View file

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

View file

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

View file

@ -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);
}
}

View file

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

View file

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