1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 10:23:51 +00:00
openmw-tes3mp/components/openmw-mp/Packets/Player/PacketGUIWindow.cpp

61 lines
1.4 KiB
C++
Raw Normal View History

2017-11-25 15:36:42 +00:00
//
// Created by koncord on 15.11.17.
//
#include <components/openmw-mp/NetworkMessages.hpp>
#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)
2017-11-28 13:37:46 +00:00
size = static_cast<int32_t>(player->guiWindow.widgets.size());
2017-11-25 15:36:42 +00:00
RW(size, send);
2017-11-29 11:00:22 +00:00
if (!send)
2017-11-25 15:36:42 +00:00
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);
2017-11-29 11:00:22 +00:00
if (widget.type != BasePlayer::GUIWindow::WidgetType::Button)
2017-11-25 15:36:42 +00:00
{
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);
}
}
}
}