From 1f682749d60b6f5b06f8c6d1e268b5cee81f3255 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 2 Jul 2017 13:07:10 +0300 Subject: [PATCH] [General] Add optional notes to PasswordDialogs --- apps/openmw-mp/Script/Functions/GUI.cpp | 3 +- apps/openmw-mp/Script/Functions/GUI.hpp | 2 +- apps/openmw/mwmp/GUI/TextInputDialog.cpp | 7 +++- apps/openmw/mwmp/GUI/TextInputDialog.hpp | 1 + apps/openmw/mwmp/GUIController.cpp | 2 ++ components/openmw-mp/Base/BasePlayer.hpp | 1 + .../Packets/Player/PacketGUIBoxes.cpp | 2 ++ files/mygui/tes3mp_text_input.layout | 34 +++++++++++++++++++ 8 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 files/mygui/tes3mp_text_input.layout diff --git a/apps/openmw-mp/Script/Functions/GUI.cpp b/apps/openmw-mp/Script/Functions/GUI.cpp index 34d8405eb..d82085a17 100644 --- a/apps/openmw-mp/Script/Functions/GUI.cpp +++ b/apps/openmw-mp/Script/Functions/GUI.cpp @@ -47,13 +47,14 @@ void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label) no mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false); } -void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label) noexcept +void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept { Player *player; GET_PLAYER(pid, player,); player->guiMessageBox.id = id; player->guiMessageBox.label = label; + player->guiMessageBox.note = note; player->guiMessageBox.type = Player::GUIMessageBox::PasswordDialog; mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player); diff --git a/apps/openmw-mp/Script/Functions/GUI.hpp b/apps/openmw-mp/Script/Functions/GUI.hpp index 0b38a22dd..f76fda70a 100644 --- a/apps/openmw-mp/Script/Functions/GUI.hpp +++ b/apps/openmw-mp/Script/Functions/GUI.hpp @@ -22,7 +22,7 @@ public: static void CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept; static void InputDialog(unsigned short pid, int id, const char *label) noexcept; - static void PasswordDialog(unsigned short pid, int id, const char *label) noexcept; + static void PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept; static void ListBox(unsigned short pid, int id, const char *label, const char *items); diff --git a/apps/openmw/mwmp/GUI/TextInputDialog.cpp b/apps/openmw/mwmp/GUI/TextInputDialog.cpp index d6159c4b2..484bb64d0 100644 --- a/apps/openmw/mwmp/GUI/TextInputDialog.cpp +++ b/apps/openmw/mwmp/GUI/TextInputDialog.cpp @@ -13,7 +13,7 @@ namespace mwmp { TextInputDialog::TextInputDialog() - : MWGui::WindowModal("openmw_text_input.layout") + : MWGui::WindowModal("tes3mp_text_input.layout") { // Centre dialog center(); @@ -50,6 +50,11 @@ namespace mwmp setText("LabelT", label); } + void TextInputDialog::setTextNote(const std::string ¬e) + { + setText("TextNote", note); + } + void TextInputDialog::open() { WindowModal::open(); diff --git a/apps/openmw/mwmp/GUI/TextInputDialog.hpp b/apps/openmw/mwmp/GUI/TextInputDialog.hpp index 48b557361..1c755e12d 100644 --- a/apps/openmw/mwmp/GUI/TextInputDialog.hpp +++ b/apps/openmw/mwmp/GUI/TextInputDialog.hpp @@ -25,6 +25,7 @@ namespace mwmp void setNextButtonShow(bool shown); void setTextLabel(const std::string &label); + void setTextNote(const std::string ¬e); void setEditPassword(bool value); diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index 70d96db12..af08db6f9 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -154,6 +154,8 @@ void mwmp::GUIController::showInputBox(const BasePlayer::GUIMessageBox &guiMessa mInputBox->setEditPassword(guiMessageBox.type == BasePlayer::GUIMessageBox::PasswordDialog); mInputBox->setTextLabel(guiMessageBox.label); + mInputBox->setTextNote(guiMessageBox.note); + mInputBox->eventDone += MyGUI::newDelegate(this, &GUIController::onInputBoxDone); } diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index 7edc980e0..ef4d20fd6 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -168,6 +168,7 @@ namespace mwmp ListBox }; std::string label; + std::string note; std::string buttons; std::string data; diff --git a/components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp b/components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp index 1dd233f27..2283da3a1 100644 --- a/components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp +++ b/components/openmw-mp/Packets/Player/PacketGUIBoxes.cpp @@ -25,5 +25,7 @@ void PacketGUIBoxes::Packet(RakNet::BitStream *bs, bool send) if (player->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox) RW(player->guiMessageBox.buttons, send); + else if (player->guiMessageBox.type == BasePlayer::GUIMessageBox::PasswordDialog) + RW(player->guiMessageBox.note, send); } diff --git a/files/mygui/tes3mp_text_input.layout b/files/mygui/tes3mp_text_input.layout new file mode 100644 index 000000000..fd73ab168 --- /dev/null +++ b/files/mygui/tes3mp_text_input.layout @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +