1
0

Added system and above action bar chat messages

This commit is contained in:
jan64 2015-06-02 19:59:46 +02:00
parent a42daecd0b
commit d37e0eb72b
12 changed files with 286 additions and 15 deletions

View File

@ -9,6 +9,7 @@ Diusrex
Duralex
FakeTruth (founder)
Howaner
jan64
jasperarmstrong
keyboard
Lapayo

View File

@ -2113,6 +2113,64 @@ void cClientHandle::SendChat(const cCompositeChat & a_Message)
void cClientHandle::SendChatAboveActionBar(const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData)
{
cWorld * World = GetPlayer()->GetWorld();
if (World == nullptr)
{
World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
if (World == nullptr)
{
World = cRoot::Get()->GetDefaultWorld();
}
}
AString Message = FormatMessageType(World->ShouldUseChatPrefixes(), a_ChatPrefix, a_AdditionalData);
m_Protocol->SendChatAboveActionBar(Message.append(a_Message));
}
void cClientHandle::SendChatAboveActionBar(const cCompositeChat & a_Message)
{
m_Protocol->SendChatAboveActionBar(a_Message);
}
void cClientHandle::SendChatSystem(const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData)
{
cWorld * World = GetPlayer()->GetWorld();
if (World == nullptr)
{
World = cRoot::Get()->GetWorld(GetPlayer()->GetLoadedWorldName());
if (World == nullptr)
{
World = cRoot::Get()->GetDefaultWorld();
}
}
AString Message = FormatMessageType(World->ShouldUseChatPrefixes(), a_ChatPrefix, a_AdditionalData);
m_Protocol->SendChatSystem(Message.append(a_Message));
}
void cClientHandle::SendChatSystem(const cCompositeChat & a_Message)
{
m_Protocol->SendChatSystem(a_Message);
}
void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
ASSERT(m_Player != nullptr);

View File

@ -150,6 +150,10 @@ public: // tolua_export
void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes);
void SendChat (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
void SendChat (const cCompositeChat & a_Message);
void SendChatAboveActionBar (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
void SendChatAboveActionBar (const cCompositeChat & a_Message);
void SendChatSystem (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
void SendChatSystem (const cCompositeChat & a_Message);
void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer);
void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player);
void SendDestroyEntity (const cEntity & a_Entity);

View File

@ -133,6 +133,17 @@ enum eGameMode
enum eChatType
{
ctChatBox = 0,
ctSystem = 1,
ctAboveActionBar = 2,
} ;
enum eWeather
{
eWeather_Sunny = 0,

View File

@ -235,14 +235,19 @@ public:
// tolua_begin
void SendMessage (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtCustom); }
void SendMessageInfo (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtInformation); }
void SendMessageFailure (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
void SendMessageSuccess (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtSuccess); }
void SendMessageWarning (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtWarning); }
void SendMessageFatal (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
void SendMessagePrivateMsg(const AString & a_Message, const AString & a_Sender) { m_ClientHandle->SendChat(a_Message, mtPrivateMessage, a_Sender); }
void SendMessage (const cCompositeChat & a_Message) { m_ClientHandle->SendChat(a_Message); }
void SendMessage (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtCustom); }
void SendMessageInfo (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtInformation); }
void SendMessageFailure (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
void SendMessageSuccess (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtSuccess); }
void SendMessageWarning (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtWarning); }
void SendMessageFatal (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
void SendMessagePrivateMsg (const AString & a_Message, const AString & a_Sender) { m_ClientHandle->SendChat(a_Message, mtPrivateMessage, a_Sender); }
void SendMessage (const cCompositeChat & a_Message) { m_ClientHandle->SendChat(a_Message); }
void SendSystemMessage (const AString & a_Message) { m_ClientHandle->SendChatSystem(a_Message, mtCustom); }
void SendAboveActionBarMessage(const AString & a_Message) { m_ClientHandle->SendChatAboveActionBar(a_Message, mtCustom); }
void SendSystemMessage (const cCompositeChat & a_Message) { m_ClientHandle->SendChatSystem(a_Message); }
void SendAboveActionBarMessage(const cCompositeChat & a_Message) { m_ClientHandle->SendChatAboveActionBar(a_Message); }
const AString & GetName(void) const { return m_PlayerName; }
void SetName(const AString & a_Name) { m_PlayerName = a_Name; }

View File

@ -70,6 +70,12 @@ public:
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) = 0;
virtual void SendChat (const AString & a_Message) = 0;
virtual void SendChat (const cCompositeChat & a_Message) = 0;
virtual void SendChatAboveActionBar (const AString & a_Message) = 0;
virtual void SendChatAboveActionBar (const cCompositeChat & a_Message) = 0;
virtual void SendChatSystem (const AString & a_Message) = 0;
virtual void SendChatSystem (const cCompositeChat & a_Message) = 0;
virtual void SendChatType (const AString & a_Message, eChatType type) = 0;
virtual void SendChatType (const cCompositeChat & a_Message, eChatType type) = 0;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) = 0;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) = 0;
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;

View File

@ -246,6 +246,60 @@ void cProtocol172::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV
void cProtocol172::SendChat(const AString & a_Message)
{
this->SendChatType(a_Message, ctChatBox);
}
void cProtocol172::SendChat(const cCompositeChat & a_Message)
{
this->SendChatType(a_Message, ctChatBox);
}
void cProtocol172::SendChatSystem(const AString & a_Message)
{
this->SendChatType(a_Message, ctSystem);
}
void cProtocol172::SendChatSystem(const cCompositeChat & a_Message)
{
this->SendChatType(a_Message, ctSystem);
}
void cProtocol172::SendChatAboveActionBar(const AString & a_Message)
{
this->SendChatType(a_Message, ctAboveActionBar);
}
void cProtocol172::SendChatAboveActionBar(const cCompositeChat & a_Message)
{
this->SendChatType(a_Message, ctAboveActionBar);
}
void cProtocol172::SendChatType(const AString & a_Message, eChatType type)
{
ASSERT(m_State == 3); // In game mode?
@ -257,7 +311,7 @@ void cProtocol172::SendChat(const AString & a_Message)
void cProtocol172::SendChat(const cCompositeChat & a_Message)
void cProtocol172::SendChatType(const cCompositeChat & a_Message, eChatType type)
{
ASSERT(m_State == 3); // In game mode?

View File

@ -68,6 +68,12 @@ public:
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChatAboveActionBar (const AString & a_Message) override;
virtual void SendChatAboveActionBar (const cCompositeChat & a_Message) override;
virtual void SendChatSystem (const AString & a_Message) override;
virtual void SendChatSystem (const cCompositeChat & a_Message) override;
virtual void SendChatType (const AString & a_Message, eChatType type) override;
virtual void SendChatType (const cCompositeChat & a_Message, eChatType type) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;

View File

@ -234,11 +234,7 @@ void cProtocol180::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV
void cProtocol180::SendChat(const AString & a_Message)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x02); // Chat Message packet
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Message).c_str()));
Pkt.WriteBEInt8(0);
this->SendChatType(a_Message, ctChatBox);
}
@ -246,6 +242,64 @@ void cProtocol180::SendChat(const AString & a_Message)
void cProtocol180::SendChat(const cCompositeChat & a_Message)
{
this->SendChatType(a_Message, ctChatBox);
}
void cProtocol180::SendChatSystem(const AString & a_Message)
{
this->SendChatType(a_Message, ctSystem);
}
void cProtocol180::SendChatSystem(const cCompositeChat & a_Message)
{
this->SendChatType(a_Message, ctSystem);
}
void cProtocol180::SendChatAboveActionBar(const AString & a_Message)
{
this->SendChatType(a_Message, ctAboveActionBar);
}
void cProtocol180::SendChatAboveActionBar(const cCompositeChat & a_Message)
{
this->SendChatType(a_Message, ctAboveActionBar);
}
void cProtocol180::SendChatType(const AString & a_Message, eChatType type)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x02); // Chat Message packet
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Message).c_str()));
Pkt.WriteBEInt8(type);
}
void cProtocol180::SendChatType(const cCompositeChat & a_Message, eChatType type)
{
ASSERT(m_State == 3); // In game mode?
@ -255,7 +309,7 @@ void cProtocol180::SendChat(const cCompositeChat & a_Message)
// Send the message to the client:
cPacketizer Pkt(*this, 0x02);
Pkt.WriteString(a_Message.CreateJsonString(ShouldUseChatPrefixes));
Pkt.WriteBEInt8(0);
Pkt.WriteBEInt8(type);
}

View File

@ -67,6 +67,12 @@ public:
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChatAboveActionBar (const AString & a_Message) override;
virtual void SendChatAboveActionBar (const cCompositeChat & a_Message) override;
virtual void SendChatSystem (const AString & a_Message) override;
virtual void SendChatSystem (const cCompositeChat & a_Message) override;
virtual void SendChatType (const AString & a_Message, eChatType type) override;
virtual void SendChatType (const cCompositeChat & a_Message, eChatType type) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;

View File

@ -158,6 +158,66 @@ void cProtocolRecognizer::SendChat(const cCompositeChat & a_Message)
void cProtocolRecognizer::SendChatAboveActionBar(const AString & a_Message)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendChatAboveActionBar(a_Message);
}
void cProtocolRecognizer::SendChatAboveActionBar(const cCompositeChat & a_Message)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendChatAboveActionBar(a_Message);
}
void cProtocolRecognizer::SendChatSystem(const AString & a_Message)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendChatSystem(a_Message);
}
void cProtocolRecognizer::SendChatSystem(const cCompositeChat & a_Message)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendChatSystem(a_Message);
}
void cProtocolRecognizer::SendChatType(const AString & a_Message, eChatType type)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendChatType(a_Message, type);
}
void cProtocolRecognizer::SendChatType(const cCompositeChat & a_Message, eChatType type)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendChatType(a_Message, type);
}
void cProtocolRecognizer::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
ASSERT(m_Protocol != nullptr);

View File

@ -55,6 +55,12 @@ public:
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
virtual void SendChat (const AString & a_Message) override;
virtual void SendChat (const cCompositeChat & a_Message) override;
virtual void SendChatAboveActionBar (const AString & a_Message) override;
virtual void SendChatAboveActionBar (const cCompositeChat & a_Message) override;
virtual void SendChatSystem (const AString & a_Message) override;
virtual void SendChatSystem (const cCompositeChat & a_Message) override;
virtual void SendChatType (const AString & a_Message, eChatType type) override;
virtual void SendChatType (const cCompositeChat & a_Message, eChatType type) override;
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;