2016-07-23 14:02:06 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 23.07.16.
|
|
|
|
//
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
#include "GUI.hpp"
|
2017-08-18 04:13:08 +00:00
|
|
|
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
|
2016-07-23 14:02:06 +00:00
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
|
2016-08-30 05:01:34 +00:00
|
|
|
void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept
|
2016-07-23 14:02:06 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
player->guiMessageBox.id = id;
|
|
|
|
player->guiMessageBox.label = label;
|
|
|
|
player->guiMessageBox.type = Player::GUIMessageBox::MessageBox;
|
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
packet->Send(false);
|
2016-07-23 14:02:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept
|
2016-07-23 14:02:06 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
player->guiMessageBox.id = id;
|
|
|
|
player->guiMessageBox.label = label;
|
|
|
|
player->guiMessageBox.buttons = buttons;
|
|
|
|
player->guiMessageBox.type = Player::GUIMessageBox::CustomMessageBox;
|
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
packet->Send(false);
|
2016-07-23 14:02:06 +00:00
|
|
|
}
|
|
|
|
|
2018-05-25 02:28:22 +00:00
|
|
|
void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label, const char *note) noexcept
|
2016-07-23 14:02:06 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
player->guiMessageBox.id = id;
|
|
|
|
player->guiMessageBox.label = label;
|
2018-05-25 02:28:22 +00:00
|
|
|
player->guiMessageBox.note = note;
|
2016-07-23 14:02:06 +00:00
|
|
|
player->guiMessageBox.type = Player::GUIMessageBox::InputDialog;
|
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
packet->Send(false);
|
2016-08-30 04:19:49 +00:00
|
|
|
}
|
|
|
|
|
2017-07-02 10:07:10 +00:00
|
|
|
void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept
|
2017-06-06 15:34:27 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
player->guiMessageBox.id = id;
|
|
|
|
player->guiMessageBox.label = label;
|
2017-07-02 10:07:10 +00:00
|
|
|
player->guiMessageBox.note = note;
|
2017-06-06 15:34:27 +00:00
|
|
|
player->guiMessageBox.type = Player::GUIMessageBox::PasswordDialog;
|
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
packet->Send(false);
|
2017-06-06 15:34:27 +00:00
|
|
|
}
|
|
|
|
|
2016-11-03 16:21:41 +00:00
|
|
|
void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const char *items)
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
player->guiMessageBox.id = id;
|
|
|
|
player->guiMessageBox.label = label;
|
|
|
|
player->guiMessageBox.data = items;
|
|
|
|
player->guiMessageBox.type = Player::GUIMessageBox::ListBox;
|
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
|
|
|
packet->Send(false);
|
2016-11-03 16:21:41 +00:00
|
|
|
}
|
|
|
|
|
2017-10-25 04:21:00 +00:00
|
|
|
void GUIFunctions::InitializeQuickKeyChanges(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
player->quickKeyChanges.quickKeys.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int GUIFunctions::GetQuickKeyChangesSize(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
return player->quickKeyChanges.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GUIFunctions::GetQuickKeySlot(unsigned short pid, unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
if (i >= player->quickKeyChanges.count)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return player->quickKeyChanges.quickKeys.at(i).slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GUIFunctions::GetQuickKeyType(unsigned short pid, unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
|
|
|
if (i >= player->quickKeyChanges.count)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return player->quickKeyChanges.quickKeys.at(i).type;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *GUIFunctions::GetQuickKeyItemId(unsigned short pid, unsigned int i) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, "");
|
|
|
|
|
|
|
|
if (i >= player->quickKeyChanges.count)
|
|
|
|
return "invalid";
|
|
|
|
|
|
|
|
return player->quickKeyChanges.quickKeys.at(i).itemId.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUIFunctions::AddQuickKey(unsigned short pid, unsigned short slot, int type, const char* itemId) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
mwmp::QuickKey quickKey;
|
|
|
|
quickKey.slot = slot;
|
|
|
|
quickKey.type = type;
|
|
|
|
quickKey.itemId = itemId;
|
|
|
|
|
|
|
|
player->quickKeyChanges.quickKeys.push_back(quickKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_QUICKKEYS)->setPlayer(player);
|
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_QUICKKEYS)->Send(false);
|
|
|
|
}
|
|
|
|
|
2018-04-18 08:02:18 +00:00
|
|
|
void GUIFunctions::SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept
|
2016-08-30 04:19:49 +00:00
|
|
|
{
|
2016-11-17 04:39:35 +00:00
|
|
|
LOG_MESSAGE(Log::LOG_WARN, "stub");
|
2016-08-30 04:19:49 +00:00
|
|
|
}
|
|
|
|
|
2018-04-18 08:02:18 +00:00
|
|
|
void GUIFunctions::SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept
|
2016-08-30 04:19:49 +00:00
|
|
|
{
|
2016-11-17 04:39:35 +00:00
|
|
|
LOG_MESSAGE(Log::LOG_WARN, "stub");
|
2016-11-03 18:59:39 +00:00
|
|
|
}
|