From 9ab77cb1233a8f04867356da8d1b4d852e611c9e Mon Sep 17 00:00:00 2001 From: Koncord Date: Sat, 23 Jul 2016 22:02:06 +0800 Subject: [PATCH] New API functions: MessageBox, CustomMessageBox, InputDialog New Callback: OnGUIAction --- apps/openmw-mp/CMakeLists.txt | 2 +- apps/openmw-mp/Networking.cpp | 10 ++ apps/openmw-mp/Script/Functions/GUI.cpp | 46 +++++ apps/openmw-mp/Script/ScriptFunctions.hpp | 10 +- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwmp/GUIChat.cpp | 2 + apps/openmw/mwmp/GUIChat.hpp | 2 + apps/openmw/mwmp/GUIController.cpp | 158 ++++++++++++++++++ apps/openmw/mwmp/GUIController.hpp | 49 ++++++ apps/openmw/mwmp/Main.cpp | 41 ++--- apps/openmw/mwmp/Main.hpp | 12 +- apps/openmw/mwmp/Networking.cpp | 19 ++- components/CMakeLists.txt | 2 +- components/openmw-mp/Base/BasePlayer.hpp | 18 ++ components/openmw-mp/NetworkMessages.hpp | 3 +- .../openmw-mp/Packets/PacketGUIBoxes.cpp | 28 ++++ .../openmw-mp/Packets/PacketGUIBoxes.hpp | 22 +++ components/openmw-mp/PacketsController.cpp | 8 + components/openmw-mp/PacketsController.hpp | 3 + 19 files changed, 392 insertions(+), 45 deletions(-) create mode 100644 apps/openmw-mp/Script/Functions/GUI.cpp create mode 100644 apps/openmw/mwmp/GUIController.cpp create mode 100644 apps/openmw/mwmp/GUIController.hpp create mode 100644 components/openmw-mp/Packets/PacketGUIBoxes.cpp create mode 100644 components/openmw-mp/Packets/PacketGUIBoxes.hpp diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 2219de99b..c67945eef 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -49,7 +49,7 @@ set(SERVER Script/Script.cpp Script/ScriptFunction.cpp Script/ScriptFunctions.cpp Script/Functions/Translocations.cpp Script/Functions/Stats.cpp Script/Functions/Items.cpp - Script/Functions/Timer.cpp Script/Functions/Chat.cpp + Script/Functions/Timer.cpp Script/Functions/Chat.cpp Script/Functions/GUI.cpp Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp ${PawnScript_Sources} ${LuaScript_Sources} diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 340f15084..c6cf08e98 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -270,6 +270,16 @@ void Networking::Update(RakNet::Packet *packet) break; } + case ID_GUI_MESSAGEBOX: + { + DEBUG_PRINTF("ID_GUI_MESSAGEBOX\n"); + myPacket->Read(player); + + Script::Call(player->GetID(), (int)player->guiMessageBox.id, + player->guiMessageBox.data.c_str()); + break; + } + default: printf("Message with identifier %i has arrived.\n", packet->data[1]); break; diff --git a/apps/openmw-mp/Script/Functions/GUI.cpp b/apps/openmw-mp/Script/Functions/GUI.cpp new file mode 100644 index 000000000..5c76b1120 --- /dev/null +++ b/apps/openmw-mp/Script/Functions/GUI.cpp @@ -0,0 +1,46 @@ +// +// Created by koncord on 23.07.16. +// + +#include +#include +#include + + + +void ScriptFunctions::MessageBox(unsigned short pid, int id, const char *label) noexcept +{ + Player *player; + GET_PLAYER(pid, player,); + + player->guiMessageBox.id = id; + player->guiMessageBox.label = label; + player->guiMessageBox.type = Player::GUIMessageBox::MessageBox; + + mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); +} + +void ScriptFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept +{ + Player *player; + GET_PLAYER(pid, player,); + + player->guiMessageBox.id = id; + player->guiMessageBox.label = label; + player->guiMessageBox.buttons = buttons; + player->guiMessageBox.type = Player::GUIMessageBox::CustomMessageBox; + + mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); +} + +void ScriptFunctions::InputDialog(unsigned short pid, int id, const char *label) noexcept +{ + Player *player; + GET_PLAYER(pid, player,); + + player->guiMessageBox.id = id; + player->guiMessageBox.label = label; + player->guiMessageBox.type = Player::GUIMessageBox::InputDialog; + + mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); +} \ No newline at end of file diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 725b11c36..41dc8c275 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -129,6 +129,10 @@ public: static void Kick(unsigned short pid) noexcept; + static void MessageBox(unsigned short pid, int id, const char *label) noexcept; + 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 constexpr ScriptFunctionData functions[]{ {"CreateTimer", ScriptFunctions::CreateTimer}, {"CreateTimerEx", reinterpret_cast>(ScriptFunctions::CreateTimerEx)}, @@ -219,6 +223,9 @@ public: {"SendMessage", ScriptFunctions::SendMessage}, {"SetCharGenStage", ScriptFunctions::SetCharGenStage}, {"Resurrect", ScriptFunctions::Resurrect}, + {"MessageBox", ScriptFunctions::MessageBox}, + {"CustomMessageBox", ScriptFunctions::CustomMessageBox}, + {"InputDialog", ScriptFunctions::InputDialog}, {"Kick", ScriptFunctions::Kick}, }; @@ -234,7 +241,8 @@ public: {"OnPlayerChangeCell", Function()}, {"OnPlayerUpdateEquiped", Function()}, {"OnPlayerSendMessage", Function()}, - {"OnPlayerEndCharGen", Function()} + {"OnPlayerEndCharGen", Function()}, + {"OnGUIAction", Function()} }; }; diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 6dec9b42e..87b9e114e 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -96,7 +96,7 @@ add_openmw_dir (mwbase inputmanager windowmanager statemanager ) -add_openmw_dir (mwmp DedicatedPlayer LocalPlayer Networking Main GUIChat GUILogin) +add_openmw_dir (mwmp DedicatedPlayer LocalPlayer Networking Main GUIChat GUILogin GUIController) # Main executable diff --git a/apps/openmw/mwmp/GUIChat.cpp b/apps/openmw/mwmp/GUIChat.cpp index 6c4c46199..e99128f4a 100644 --- a/apps/openmw/mwmp/GUIChat.cpp +++ b/apps/openmw/mwmp/GUIChat.cpp @@ -17,6 +17,8 @@ #include "Networking.hpp" #include "Main.hpp" +#include "GUIController.hpp" + namespace mwmp { diff --git a/apps/openmw/mwmp/GUIChat.hpp b/apps/openmw/mwmp/GUIChat.hpp index ad583c067..0259ab075 100644 --- a/apps/openmw/mwmp/GUIChat.hpp +++ b/apps/openmw/mwmp/GUIChat.hpp @@ -22,8 +22,10 @@ namespace mwmp { + class GUIController; class GUIChat : public MWGui::WindowBase, public MWGui::ReferenceInterface { + friend class GUIController; public: enum { diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp new file mode 100644 index 000000000..1d0bb462d --- /dev/null +++ b/apps/openmw/mwmp/GUIController.cpp @@ -0,0 +1,158 @@ +// +// Created by koncord on 20.07.16. +// + +#include +#include +#include +#include +#include +#include + + +#include "GUIController.hpp" +#include "Main.hpp" + + +mwmp::GUIController::GUIController(): mInputBox(0) +{ + mChat = nullptr; + keySay = SDLK_y; + keyChatMode = SDLK_F2; + calledMessageBox = false; +} + +mwmp::GUIController::~GUIController() +{ + /* if(mChat != nullptr) + delete mChat; + mChat = nullptr;*/ +} + +void mwmp::GUIController::setupChat(const Settings::Manager &mgr) +{ + assert(mChat == nullptr); + + float chatDelay = mgr.getFloat("delay", "Chat"); + int chatY = mgr.getInt("y", "Chat"); + int chatX = mgr.getInt("x", "Chat"); + int chatW = mgr.getInt("w", "Chat"); + int chatH = mgr.getInt("h", "Chat"); + + keySay = SDL_GetKeyFromName(mgr.getString("keySay", "Chat").c_str()); + keyChatMode = SDL_GetKeyFromName(mgr.getString("keyChatMode", "Chat").c_str()); + + mChat = new GUIChat(chatX, chatY, chatW, chatH); + mChat->SetDelay(chatDelay); +} + +void mwmp::GUIController::PrintChatMessage(std::string &msg) +{ + if(mChat != nullptr) + mChat->print(msg); +} + + +void mwmp::GUIController::setChatVisible(bool chatVisible) +{ + mChat->setVisible(chatVisible); +} + +void mwmp::GUIController::ShowMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox) +{ + MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); + std::vector buttons; + buttons.push_back("Ok"); + windowManager->interactiveMessageBox(guiMessageBox.label, buttons); + calledMessageBox = true; +} + +std::vector splitString(const std::string &str, char delim = ';') +{ + std::istringstream ss(str); + std::vector result; + std::string token; + while(std::getline(ss, token, delim)) + result.push_back(token); + return result; +} + +void mwmp::GUIController::ShowCustomMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox) +{ + MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); + std::vector buttons = splitString(guiMessageBox.buttons); + windowManager->interactiveMessageBox(guiMessageBox.label, buttons); + calledMessageBox = true; +} + +void mwmp::GUIController::ShowInputBox(const BasePlayer::GUIMessageBox &guiMessageBox) +{ + printf("test adf\n"); + MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); + + windowManager->removeDialog(mInputBox); + mInputBox = 0; + mInputBox = new MWGui::TextInputDialog(); + mInputBox->setTextLabel(guiMessageBox.label); + mInputBox->eventDone += MyGUI::newDelegate(this, &GUIController::OnInputBoxDone); + mInputBox->setVisible(true); + +} + +void mwmp::GUIController::OnInputBoxDone(MWGui::WindowBase *parWindow) +{ + //MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); + printf("GUIController::OnInputBoxDone: %s.\n",mInputBox->getTextInput().c_str()); + + Main::get().getLocalPlayer()->guiMessageBox.data = mInputBox->getTextInput(); + Main::get().getNetworking()->GetPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer()); + + MWBase::Environment::get().getWindowManager()->removeDialog(mInputBox); + mInputBox = 0; +} + +bool mwmp::GUIController::pressedKey(int key) +{ + MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); + if(mChat == nullptr || windowManager->getMode() != MWGui::GM_None) + return false; + if(key == keyChatMode) + { + mChat->PressedChatMode(); + return true; + } + else if(key == keySay) + { + //MyGUI::Widget *oldFocus = MyGUI::InputManager::getInstance().getKeyFocusWidget(); + mChat->PressedSay(); + /*MyGUI::Widget *newFocus = MyGUI::InputManager::getInstance().getKeyFocusWidget(); + printf("mwmp::GUIController::pressedKey. oldFocus: %s.\n", oldFocus ? oldFocus->getName().c_str() : "nil"); + printf("mwmp::GUIController::pressedKey.newFocus: %s.\n", newFocus ? newFocus->getName().c_str() : "nil");*/ + return true; + } + return false; +} + +bool mwmp::GUIController::HaveFocusedElement() +{ + return false; +} + + +void mwmp::GUIController::update(float dt) +{ + if(mChat != nullptr) + mChat->Update(dt); + + int pressedButton = MWBase::Environment::get().getWindowManager()->readPressedButton(); + if(pressedButton != -1 && calledMessageBox) + { + printf("Pressed: %d\n", pressedButton); + calledMessageBox = false; + Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(pressedButton); + Main::get().getNetworking()->GetPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer()); + } + +} + + diff --git a/apps/openmw/mwmp/GUIController.hpp b/apps/openmw/mwmp/GUIController.hpp new file mode 100644 index 000000000..73a806bda --- /dev/null +++ b/apps/openmw/mwmp/GUIController.hpp @@ -0,0 +1,49 @@ +// +// Created by koncord on 20.07.16. +// + +#ifndef OPENMW_GUICONTROLLER_HPP +#define OPENMW_GUICONTROLLER_HPP + +#include +#include +#include +#include "GUIChat.hpp" + +namespace mwmp +{ + class GUIController + { + public: + GUIController(); + ~GUIController(); + void setupChat(const Settings::Manager &manager); + + void PrintChatMessage(std::string &msg); + void setChatVisible(bool chatVisible); + + void ShowMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox); + void ShowCustomMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox); + void ShowInputBox(const BasePlayer::GUIMessageBox &guiMessageBox); + + /// Return true if any tes3mp gui element in active state + bool HaveFocusedElement(); + /// Returns 0 if there was no events + bool pressedKey(int key); + + void update(float dt); + + private: + GUIChat *mChat; + int keySay; + int keyChatMode; + + long id; + bool calledMessageBox; + MWGui::TextInputDialog *mInputBox; + void OnInputBoxDone(MWGui::WindowBase* parWindow); + //MyGUI::Widget *oldFocusWidget, *currentFocusWidget; + }; +} + +#endif //OPENMW_GUICONTROLLER_HPP diff --git a/apps/openmw/mwmp/Main.cpp b/apps/openmw/mwmp/Main.cpp index f7de5d9c5..a00a93861 100644 --- a/apps/openmw/mwmp/Main.cpp +++ b/apps/openmw/mwmp/Main.cpp @@ -26,7 +26,6 @@ #include "DedicatedPlayer.hpp" #include "LocalPlayer.hpp" -#include "GUIChat.hpp" using namespace mwmp; using namespace std; @@ -61,12 +60,11 @@ Main::Main() std::cout << "Main::Main" << std::endl; mNetworking = new Networking(); mLocalPlayer = new LocalPlayer(); + mGUIController = new GUIController(); //mLocalPlayer->CharGen(0, 4); server = "mp.tes3mp.com"; port = 25565; - keySay = SDLK_y; - keyChatMode = SDLK_F2; } Main::~Main() @@ -74,6 +72,7 @@ Main::~Main() std::cout << "Main::~Main" << std::endl; delete mNetworking; delete mLocalPlayer; + delete mGUIController; Players::CleanUp(); } @@ -94,17 +93,7 @@ void Main::Create() pMain->server = mgr.getString("server", "General"); pMain->port = (unsigned short)mgr.getInt("port", "General"); - float chatDelay = mgr.getFloat("delay", "Chat"); - int chatY = mgr.getInt("y", "Chat"); - int chatX = mgr.getInt("x", "Chat"); - int chatW = mgr.getInt("w", "Chat"); - int chatH = mgr.getInt("h", "Chat"); - pMain->keySay = SDL_GetKeyFromName(mgr.getString("keySay", "Chat").c_str()); - pMain->keyChatMode = SDL_GetKeyFromName(mgr.getString("keyChatMode", "Chat").c_str()); - - - pMain->mChat = new GUIChat(chatX, chatY, chatW, chatH); - pMain->getChatBox()->SetDelay(chatDelay); + pMain->mGUIController->setupChat(mgr); mgr.mUserSettings = saveUserSettings; mgr.mDefaultSettings = saveDefaultSettings; @@ -119,7 +108,7 @@ void Main::Destroy() { assert(pMain); - delete pMain->mChat; + delete pMain->mGUIController; delete pMain; pMain = 0; @@ -138,7 +127,7 @@ void Main::Frame(float dt) Players::Update(dt); get().UpdateWorld(dt); - get().getChatBox()->Update(dt); + get().getGUIConroller()->update(dt); } @@ -160,7 +149,7 @@ void Main::UpdateWorld(float dt) const mNetworking->Connect(server, port); player.getClass().getCreatureStats(player).getSpells().add("fireball"); mLocalPlayer->updateBaseStats(true); - mChat->setVisible(true); + get().getGUIConroller()->setChatVisible(true); } else mLocalPlayer->Update(); @@ -181,23 +170,15 @@ LocalPlayer *Main::getLocalPlayer() const return mLocalPlayer; } -GUIChat *Main::getChatBox() const -{ - return mChat; -} -GUILogin *Main::getGUILogin() const +GUIController *Main::getGUIConroller() const { - return mGUILogin; + return mGUIController; } - void Main::PressedKey(int key) { - - if(pMain == nullptr || get().getChatBox() == nullptr) return; - if(key == get().keyChatMode) - get().getChatBox()->PressedChatMode(); - else if(key == get().keySay) - get().getChatBox()->PressedSay(); + if(pMain == nullptr) return; + if(get().getGUIConroller()->pressedKey(key)) + return; // if any gui bind pressed } \ No newline at end of file diff --git a/apps/openmw/mwmp/Main.hpp b/apps/openmw/mwmp/Main.hpp index 2be74cdba..e1753e8dc 100644 --- a/apps/openmw/mwmp/Main.hpp +++ b/apps/openmw/mwmp/Main.hpp @@ -1,8 +1,7 @@ #include #include "Networking.hpp" #include "LocalPlayer.hpp" -#include "GUIChat.hpp" -#include "GUILogin.hpp" +#include "GUIController.hpp" namespace mwmp { @@ -20,8 +19,7 @@ namespace mwmp Networking *getNetworking() const; LocalPlayer *getLocalPlayer() const; - GUIChat *getChatBox() const; - GUILogin *getGUILogin() const; + GUIController *getGUIConroller() const; void UpdateWorld(float dt) const; @@ -34,13 +32,9 @@ namespace mwmp Networking *mNetworking; LocalPlayer *mLocalPlayer; - GUIChat *mChat; - GUILogin *mGUILogin; + GUIController *mGUIController; std::string server; unsigned short port; - - int keySay; - int keyChatMode; }; } diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index e7284c1c6..0c9a616d9 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -459,7 +459,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet) myPacket->Packet(&bsIn, pl, false); message = *pl->ChatMessage(); } - Main::get().getChatBox()->print(message); + Main::get().getGUIConroller()->PrintChatMessage(message); break; } case ID_GAME_CHARGEN: @@ -530,6 +530,23 @@ void Networking::ReciveMessage(RakNet::Packet *packet) break; } + case ID_GUI_MESSAGEBOX: + { + if(id == myid) + { + myPacket->Packet(&bsIn, getLocalPlayer(), false); + + printf("ID_GUI_MESSAGEBOX, Type %d, MSG %s\n", getLocalPlayer()->guiMessageBox.type, getLocalPlayer()->guiMessageBox.label.c_str()); + + if(getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::MessageBox) + Main::get().getGUIConroller()->ShowMessageBox(getLocalPlayer()->guiMessageBox); + else if(getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox) + Main::get().getGUIConroller()->ShowCustomMessageBox(getLocalPlayer()->guiMessageBox); + else if(getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::InputDialog) + Main::get().getGUIConroller()->ShowInputBox(getLocalPlayer()->guiMessageBox); + } + break; + } default: printf("Custom message with identifier %i has arrived in initialization.\n", packet->data[1]); } diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index ee6f64788..f65117ab3 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -145,7 +145,7 @@ add_component_dir (openmw-mp PacketsController Packets/BasePacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquiped Packets/PacketAttributesAndStats Packets/PacketAttack Packets/PacketMainStats Packets/PacketCell Packets/PacketDrawState Packets/PacketChatMessage - Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketHandshake) + Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketHandshake Packets/PacketGUIBoxes) add_component_dir (fallback fallback validate diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index dfddf32fe..cd661ef66 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -42,6 +42,23 @@ namespace mwmp int current, end; }; + struct GUIMessageBox + { + int id; + int type; + enum GUI_TYPE + { + MessageBox = 0, + CustomMessageBox, + InputDialog, + PasswordDialog + }; + std::string label; + std::string buttons; + + std::string data; + }; + BasePlayer(RakNet::RakNetGUID guid) : guid(guid) { @@ -124,6 +141,7 @@ namespace mwmp return &passw; } RakNet::RakNetGUID guid; + GUIMessageBox guiMessageBox; protected: ESM::Position pos; diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 80d6bccfc..2b3ed3399 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -36,7 +36,8 @@ enum MyGameMesages ID_GAME_SKILL, ID_GAME_CHARCLASS, ID_GAME_SKILLPRIORITY, - ID_HANDSHAKE + ID_HANDSHAKE, + ID_GUI_MESSAGEBOX }; diff --git a/components/openmw-mp/Packets/PacketGUIBoxes.cpp b/components/openmw-mp/Packets/PacketGUIBoxes.cpp new file mode 100644 index 000000000..d9b563cca --- /dev/null +++ b/components/openmw-mp/Packets/PacketGUIBoxes.cpp @@ -0,0 +1,28 @@ +// +// Created by koncord on 23.07.16. +// + +#include "PacketGUIBoxes.hpp" +#include + +using namespace mwmp; + +PacketGUIBoxes::PacketGUIBoxes(RakNet::RakPeerInterface *peer) : BasePacket(peer) +{ + packetID = ID_GUI_MESSAGEBOX; +} + +void PacketGUIBoxes::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send) +{ + BasePacket::Packet(bs, player, send); + + RW(player->guiMessageBox.id, send); + RW(player->guiMessageBox.type, send); + RW(player->guiMessageBox.label, send); + + RW(player->guiMessageBox.data, send); + + if(player->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox) + RW(player->guiMessageBox.buttons, send); +} + diff --git a/components/openmw-mp/Packets/PacketGUIBoxes.hpp b/components/openmw-mp/Packets/PacketGUIBoxes.hpp new file mode 100644 index 000000000..06a353a04 --- /dev/null +++ b/components/openmw-mp/Packets/PacketGUIBoxes.hpp @@ -0,0 +1,22 @@ +// +// Created by koncord on 23.07.16. +// + +#ifndef OPENMW_PACKETGUIBOXES_HPP +#define OPENMW_PACKETGUIBOXES_HPP + + +#include + +namespace mwmp +{ + class PacketGUIBoxes : public BasePacket + { + public: + PacketGUIBoxes(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send); + }; +} + +#endif //OPENMW_PACKETGUIBOXES_HPP diff --git a/components/openmw-mp/PacketsController.cpp b/components/openmw-mp/PacketsController.cpp index c5b1d64cc..48e324604 100644 --- a/components/openmw-mp/PacketsController.cpp +++ b/components/openmw-mp/PacketsController.cpp @@ -19,6 +19,7 @@ #include "Packets/PacketAttribute.hpp" #include "Packets/PacketSkill.hpp" #include "Packets/PacketHandshake.hpp" +#include "Packets/PacketGUIBoxes.hpp" #include "PacketsController.hpp" @@ -46,6 +47,8 @@ mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer) packetSkill = new PacketSkill(peer); packetHandshake = new PacketHandshake(peer); + + packetGUIBoxes = new PacketGUIBoxes(peer); } @@ -105,6 +108,9 @@ mwmp::BasePacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id) case ID_HANDSHAKE: packet = packetHandshake; break; + case ID_GUI_MESSAGEBOX: + packet = packetGUIBoxes; + break; default: packet = 0; } @@ -134,4 +140,6 @@ void mwmp::PacketsController::SetStream(RakNet::BitStream *inStream, RakNet::Bit packetSkill->SetStreams(inStream, outStream); packetHandshake->SetStreams(inStream, outStream); + + packetGUIBoxes->SetStreams(inStream, outStream); } \ No newline at end of file diff --git a/components/openmw-mp/PacketsController.hpp b/components/openmw-mp/PacketsController.hpp index 71f15bd1f..cdb5c0e57 100644 --- a/components/openmw-mp/PacketsController.hpp +++ b/components/openmw-mp/PacketsController.hpp @@ -32,6 +32,8 @@ namespace mwmp class PacketSkill; class PacketHandshake; + class PacketGUIBoxes; + class PacketsController { public: @@ -61,6 +63,7 @@ namespace mwmp PacketAttribute *packetAttribute; PacketSkill *packetSkill; PacketHandshake *packetHandshake; + PacketGUIBoxes *packetGUIBoxes; }; }