diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 53cf04cc6..e26ffd37b 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -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 ) diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index 064d4a1d8..7cfcc0eaa 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -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); diff --git a/apps/openmw/mwmp/GUIController.hpp b/apps/openmw/mwmp/GUIController.hpp index 30326fd71..93eefadda 100644 --- a/apps/openmw/mwmp/GUIController.hpp +++ b/apps/openmw/mwmp/GUIController.hpp @@ -7,11 +7,11 @@ #include -#include "../mwgui/textinput.hpp" #include "../mwgui/mode.hpp" #include #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; diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index e56fe8c1d..29e31a05b 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -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(); diff --git a/apps/openmw/mwmp/TextInputDialog.cpp b/apps/openmw/mwmp/TextInputDialog.cpp new file mode 100644 index 000000000..b07f654b7 --- /dev/null +++ b/apps/openmw/mwmp/TextInputDialog.cpp @@ -0,0 +1,87 @@ +// +// Created by koncord on 06.06.17. +// + +#include "TextInputDialog.hpp" + +#include "../mwbase/windowmanager.hpp" +#include "../mwbase/environment.hpp" + +#include +#include + +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); + } +} \ No newline at end of file diff --git a/apps/openmw/mwmp/TextInputDialog.hpp b/apps/openmw/mwmp/TextInputDialog.hpp new file mode 100644 index 000000000..6b57f9966 --- /dev/null +++ b/apps/openmw/mwmp/TextInputDialog.hpp @@ -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 \ No newline at end of file diff --git a/apps/openmw/mwmp/processors/player/ProcessorGUIMessageBox.hpp b/apps/openmw/mwmp/processors/player/ProcessorGUIMessageBox.hpp index 790be60e1..671f1e30e 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorGUIMessageBox.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorGUIMessageBox.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; + } } } };