diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index 01073c1f2..bafa2a09e 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -195,6 +195,33 @@ namespace mwmp std::string data; }; + struct GUIWindow + { + int32_t id; + short width, height; + enum class WidgetType: int + { + Button, + Editbox, + Label, + ListBoxActive, + ListBoxPassive, + Slider + }; + + struct Widget + { + WidgetType type; + std::string name; + bool disabled; + short posX, posY; + short width, height; + std::vector data; + }; + + std::vector widgets; + }; + BasePlayer(RakNet::RakNetGUID guid) : guid(guid) { inventoryChanges.action = 0; @@ -219,6 +246,7 @@ namespace mwmp GUIMessageBox guiMessageBox; int month; int day; + GUIWindow guiWindow; double hour; AttributeChanges attributeChanges; diff --git a/components/openmw-mp/Controllers/PlayerPacketController.cpp b/components/openmw-mp/Controllers/PlayerPacketController.cpp index d155b5066..362dd8c83 100644 --- a/components/openmw-mp/Controllers/PlayerPacketController.cpp +++ b/components/openmw-mp/Controllers/PlayerPacketController.cpp @@ -3,6 +3,7 @@ #include "../Packets/Player/PacketPlayerCharGen.hpp" #include "../Packets/Player/PacketHandshake.hpp" #include "../Packets/Player/PacketGUIBoxes.hpp" +#include "../Packets/Player/PacketGUIWindow.hpp" #include "../Packets/Player/PacketLoaded.hpp" #include "../Packets/Player/PacketGameSettings.hpp" #include "../Packets/Player/PacketGameTime.hpp" @@ -54,6 +55,7 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); + AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); @@ -95,7 +97,7 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p mwmp::PlayerPacket *mwmp::PlayerPacketController::GetPacket(RakNet::MessageID id) { - return packets[(unsigned char)id].get(); + return packets[(RakNet::MessageID)id].get(); } void mwmp::PlayerPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream) diff --git a/components/openmw-mp/Controllers/PlayerPacketController.hpp b/components/openmw-mp/Controllers/PlayerPacketController.hpp index 4516bfe3d..d143f7df3 100644 --- a/components/openmw-mp/Controllers/PlayerPacketController.hpp +++ b/components/openmw-mp/Controllers/PlayerPacketController.hpp @@ -18,7 +18,7 @@ namespace mwmp bool ContainsPacket(RakNet::MessageID id); - typedef std::unordered_map > packets_t; + typedef std::unordered_map > packets_t; private: packets_t packets; }; diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 7c4823a15..bd63ace19 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -17,6 +17,7 @@ enum GameMessages ID_HANDSHAKE, ID_LOADED, ID_GUI_MESSAGEBOX, + ID_GUI_WINDOW, ID_GAME_TIME, ID_GAME_WEATHER, diff --git a/components/openmw-mp/Packets/Player/PacketGUIWindow.cpp b/components/openmw-mp/Packets/Player/PacketGUIWindow.cpp new file mode 100644 index 000000000..c2509196f --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketGUIWindow.cpp @@ -0,0 +1,60 @@ +// +// Created by koncord on 15.11.17. +// + +#include +#include "PacketGUIWindow.hpp" + +using namespace mwmp; + +PacketGUIWindow::PacketGUIWindow(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) +{ + + packetID = ID_GUI_WINDOW; + orderChannel = CHANNEL_SYSTEM; +} + +void PacketGUIWindow::Packet(RakNet::BitStream *bs, bool send) +{ + BasePacket::Packet(bs, send); + + RW(player->guiWindow.id, send); + RW(player->guiWindow.height, send); + RW(player->guiWindow.width, send); + + int32_t size; + if (send) + size = player->guiWindow.widgets.size(); + RW(size, send); + + if(!send) + player->guiWindow.widgets.resize(size); + + + for (auto &&widget : player->guiWindow.widgets) + { + RW(widget.type, send); + RW(widget.name, send); + RW(widget.posX, send); + RW(widget.posY, send); + + if (widget.type != BasePlayer::GUIWindow::WidgetType::Label) + { + RW(widget.disabled, send); + + if(widget.type != BasePlayer::GUIWindow::WidgetType::Button) + { + RW(widget.width, send); + RW(widget.height, send); + + size = widget.data.size(); + RW(size, send); + if (!send) + widget.data.resize(size); + for (auto &&str : widget.data) + RW(str, send); + } + } + } + +} diff --git a/components/openmw-mp/Packets/Player/PacketGUIWindow.hpp b/components/openmw-mp/Packets/Player/PacketGUIWindow.hpp new file mode 100644 index 000000000..9bd6a340f --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketGUIWindow.hpp @@ -0,0 +1,19 @@ +// +// Created by koncord on 15.11.17. +// + +#pragma once + + +#include + +namespace mwmp +{ + class PacketGUIWindow : public PlayerPacket + { + public: + PacketGUIWindow(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, bool send); + }; +}