1
0

Added more SendMessageXXX() functions

This commit is contained in:
Tiger Wang 2014-02-04 22:39:57 +00:00
parent 01c723e89e
commit 9eeeb91fa6
3 changed files with 62 additions and 47 deletions

View File

@ -465,51 +465,54 @@ inline AString AppendChatEpithet(const AString & a_ChatMessage, ChatPrefixCodes
{ {
switch (a_ChatPrefix) switch (a_ChatPrefix)
{ {
case mtCustom: return a_ChatMessage; case mtCustom: return a_ChatMessage;
case mtFailure: case mtFailure:
{ {
AString Message(Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str())); AString Message(Printf("%s[INFO] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage); Message.append(a_ChatMessage);
return Message; return Message;
}
case mtInformation:
{
AString Message(Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtSuccess:
{
AString Message(Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtWarning:
{
AString Message(Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtFatal:
{
AString Message(Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtDeath:
{
AString Message(Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtPrivateMessage:
{
AString Message(Printf("%s[MSG] %s%s", cChatColor::LightBlue.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()));
Message.append(a_ChatMessage);
return Message;
}
default: ASSERT(!"Unhandled chat prefix type!"); return "";
} }
case mtInformation: }
{
AString Message(Printf("%s[INFO] %s", cChatColor::Yellow.c_str(), cChatColor::White.c_str())); // tolua_begin
Message.append(a_ChatMessage);
return Message;
}
case mtSuccess:
{
AString Message(Printf("%s[INFO] %s", cChatColor::Green.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtWarning:
{
AString Message(Printf("%s[WARN] %s", cChatColor::Rose.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtFatal:
{
AString Message(Printf("%s[FATAL] %s", cChatColor::Red.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtDeath:
{
AString Message(Printf("%s[DEATH] %s", cChatColor::Gray.c_str(), cChatColor::White.c_str()));
Message.append(a_ChatMessage);
return Message;
}
case mtPrivateMessage:
{
AString Message(Printf("%s[MSG] %s%s", cChatColor::LightBlue.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str()));
Message.append(a_ChatMessage);
return Message;
}
}
}// tolua_begin
/// Normalizes an angle in degrees to the [-180, +180) range: /// Normalizes an angle in degrees to the [-180, +180) range:
inline double NormalizeAngleDegrees(const double a_Degrees) inline double NormalizeAngleDegrees(const double a_Degrees)

View File

@ -199,6 +199,10 @@ public:
void SendMessageInfo(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtInformation)); } void SendMessageInfo(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtInformation)); }
void SendMessageFailure(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); } void SendMessageFailure(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); }
void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); } void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); }
void SendMessageWarning(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtWarning)); }
void SendMessageFatal(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); }
void SendMessageDeath(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtDeath)); }
void SendMessagePrivateMsg(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtPrivateMessage)); }
const AString & GetName(void) const { return m_PlayerName; } const AString & GetName(void) const { return m_PlayerName; }
void SetName(const AString & a_Name) { m_PlayerName = a_Name; } void SetName(const AString & a_Name) { m_PlayerName = a_Name; }

View File

@ -3,6 +3,7 @@
#include "Authenticator.h" #include "Authenticator.h"
#include "HTTPServer/HTTPServer.h" #include "HTTPServer/HTTPServer.h"
#include "Defines.h"
@ -98,9 +99,6 @@ public:
/// Saves all chunks in all worlds /// Saves all chunks in all worlds
void SaveAllChunks(void); // tolua_export void SaveAllChunks(void); // tolua_export
/// Sends a chat message to all connected clients (in all worlds)
void BroadcastChat(const AString & a_Message); // tolua_export
/// Calls the callback for each player in all worlds /// Calls the callback for each player in all worlds
bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
@ -109,6 +107,16 @@ public:
// tolua_begin // tolua_begin
/// Sends a chat message to all connected clients (in all worlds)
void BroadcastChat(const AString & a_Message);
void BroadcastChatInfo(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtInformation)); }
void BroadcastChatFailure(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtFailure)); }
void BroadcastChatSuccess(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtSuccess)); }
void BroadcastChatWarning(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtWarning)); }
void BroadcastChatFatal(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtFailure)); }
void BroadcastChatDeath(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtDeath)); }
void BroadcastChatPrivateMsg(const AString & a_Message) { BroadcastChat(AppendChatEpithet(a_Message, mtPrivateMessage)); }
/// Returns the textual description of the protocol version: 49 -> "1.4.4". Provided specifically for Lua API /// Returns the textual description of the protocol version: 49 -> "1.4.4". Provided specifically for Lua API
static AString GetProtocolVersionTextFromInt(int a_ProtocolVersionNum); static AString GetProtocolVersionTextFromInt(int a_ProtocolVersionNum);