forked from mirror/openmw-tes3mp
Add new API function: SetConsoleAllow
example: tes3mp.SetConsoleAllow(pid, 0) -- disallow console to the player The console is allowed by default
This commit is contained in:
parent
3759127627
commit
37e9cafbf7
10 changed files with 70 additions and 3 deletions
|
@ -68,3 +68,13 @@ void GUIFunctions::SetMapVisibilityAll(unsigned short targetPID, unsigned short
|
||||||
{
|
{
|
||||||
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
|
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUIFunctions::SetConsoleAllow(unsigned short pid, char state)
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player,);
|
||||||
|
|
||||||
|
player->consoleAllowed = state;
|
||||||
|
|
||||||
|
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CONSOLE)->Send(player, false);
|
||||||
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
{"InputDialog", GUIFunctions::InputDialog},\
|
{"InputDialog", GUIFunctions::InputDialog},\
|
||||||
{"ListBox", GUIFunctions::ListBox},\
|
{"ListBox", GUIFunctions::ListBox},\
|
||||||
{"SetMapVisibility", GUIFunctions::SetMapVisibility},\
|
{"SetMapVisibility", GUIFunctions::SetMapVisibility},\
|
||||||
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll}\
|
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll},\
|
||||||
|
{"SetConsoleAllow", GUIFunctions::SetConsoleAllow}\
|
||||||
|
|
||||||
class GUIFunctions
|
class GUIFunctions
|
||||||
{
|
{
|
||||||
|
@ -27,6 +28,8 @@ public:
|
||||||
//state 0 - disallow, 1 - allow
|
//state 0 - disallow, 1 - allow
|
||||||
static void SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept;
|
static void SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept;
|
||||||
static void SetMapVisibilityAll(unsigned short targetPID, unsigned short state) noexcept;
|
static void SetMapVisibilityAll(unsigned short targetPID, unsigned short state) noexcept;
|
||||||
|
|
||||||
|
static void SetConsoleAllow(unsigned short pid, char state);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OPENMW_GUI_HPP
|
#endif //OPENMW_GUI_HPP
|
||||||
|
|
|
@ -200,6 +200,8 @@ void mwmp::GUIController::update(float dt)
|
||||||
Main::get().getNetworking()->GetPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
|
Main::get().getNetworking()->GetPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockConsole();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mwmp::GUIController::WM_UpdateVisible(MWGui::GuiMode mode)
|
void mwmp::GUIController::WM_UpdateVisible(MWGui::GuiMode mode)
|
||||||
|
@ -369,3 +371,13 @@ void mwmp::GUIController::updateGlobalMapMarkerTooltips(MWGui::MapWindow *mapWin
|
||||||
setGlobalMapMarkerTooltip(mapWindow, markerWidget, x, y);
|
setGlobalMapMarkerTooltip(mapWindow, markerWidget, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mwmp::GUIController::blockConsole()
|
||||||
|
{
|
||||||
|
if (Main::get().getLocalPlayer()->consoleAllowed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||||
|
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console)
|
||||||
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||||
|
}
|
|
@ -72,6 +72,7 @@ namespace mwmp
|
||||||
GUIDialogList *mListBox;
|
GUIDialogList *mListBox;
|
||||||
void OnInputBoxDone(MWGui::WindowBase* parWindow);
|
void OnInputBoxDone(MWGui::WindowBase* parWindow);
|
||||||
//MyGUI::Widget *oldFocusWidget, *currentFocusWidget;
|
//MyGUI::Widget *oldFocusWidget, *currentFocusWidget;
|
||||||
|
void blockConsole();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ LocalPlayer::LocalPlayer()
|
||||||
{
|
{
|
||||||
CharGenStage()->current = 0;
|
CharGenStage()->current = 0;
|
||||||
CharGenStage()->end = 1;
|
CharGenStage()->end = 1;
|
||||||
|
consoleAllowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalPlayer::~LocalPlayer()
|
LocalPlayer::~LocalPlayer()
|
||||||
|
|
|
@ -675,6 +675,11 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ID_GAME_CONSOLE:
|
||||||
|
{
|
||||||
|
myPacket->Packet(&bsIn, getLocalPlayer(), false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Unhandled PlayerPacket with identifier %i has arrived",
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Unhandled PlayerPacket with identifier %i has arrived",
|
||||||
packet->data[0]);
|
packet->data[0]);
|
||||||
|
|
|
@ -168,6 +168,7 @@ namespace mwmp
|
||||||
int day;
|
int day;
|
||||||
double hour;
|
double hour;
|
||||||
Inventory inventory;
|
Inventory inventory;
|
||||||
|
bool consoleAllowed;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ESM::Position pos;
|
ESM::Position pos;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "../Packets/Player/PacketTime.hpp"
|
#include "../Packets/Player/PacketTime.hpp"
|
||||||
#include "../Packets/Player/PacketLoaded.hpp"
|
#include "../Packets/Player/PacketLoaded.hpp"
|
||||||
#include "../Packets/Player/PacketInventory.hpp"
|
#include "../Packets/Player/PacketInventory.hpp"
|
||||||
|
#include "../Packets/Player/PacketConsole.hpp"
|
||||||
|
|
||||||
#include "PlayerPacketController.hpp"
|
#include "PlayerPacketController.hpp"
|
||||||
|
|
||||||
|
@ -63,6 +64,8 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p
|
||||||
AddPacket<PacketTime>(&packets, peer);
|
AddPacket<PacketTime>(&packets, peer);
|
||||||
AddPacket<PacketLoaded>(&packets, peer);
|
AddPacket<PacketLoaded>(&packets, peer);
|
||||||
AddPacket<PacketInventory>(&packets, peer);
|
AddPacket<PacketInventory>(&packets, peer);
|
||||||
|
|
||||||
|
AddPacket<PacketConsole>(&packets, peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,9 @@ enum GameMessages
|
||||||
ID_SCRIPT_LOCAL_SHORT,
|
ID_SCRIPT_LOCAL_SHORT,
|
||||||
ID_SCRIPT_LOCAL_FLOAT,
|
ID_SCRIPT_LOCAL_FLOAT,
|
||||||
ID_SCRIPT_MEMBER_SHORT,
|
ID_SCRIPT_MEMBER_SHORT,
|
||||||
ID_SCRIPT_GLOBAL_SHORT
|
ID_SCRIPT_GLOBAL_SHORT,
|
||||||
|
|
||||||
|
ID_GAME_CONSOLE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
29
components/openmw-mp/Packets/Player/PacketConsole.hpp
Normal file
29
components/openmw-mp/Packets/Player/PacketConsole.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// Created by koncord on 04.11.16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef OPENMW_PACKETCONSOLE_HPP
|
||||||
|
#define OPENMW_PACKETCONSOLE_HPP
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class PacketConsole: public PlayerPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PacketConsole(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
||||||
|
{
|
||||||
|
packetID = ID_GAME_CONSOLE;
|
||||||
|
}
|
||||||
|
void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
||||||
|
{
|
||||||
|
PlayerPacket::Packet(bs, player, send);
|
||||||
|
RW(player->consoleAllowed, send);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //OPENMW_PACKETCONSOLE_HPP
|
Loading…
Reference in a new issue