Merge pull request #1213 from mc-server/chat-color
Refactored cChatColor
This commit is contained in:
commit
b41bd2da5c
@ -2,31 +2,31 @@
|
|||||||
|
|
||||||
#include "ChatColor.h"
|
#include "ChatColor.h"
|
||||||
|
|
||||||
const std::string cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8
|
const char * cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8
|
||||||
const std::string cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8
|
const char * cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8
|
||||||
const std::string cChatColor::Black = cChatColor::Color + "0";
|
const char * cChatColor::Black = "\xc2\xa7""0";
|
||||||
const std::string cChatColor::Navy = cChatColor::Color + "1";
|
const char * cChatColor::Navy = "\xc2\xa7""1";
|
||||||
const std::string cChatColor::Green = cChatColor::Color + "2";
|
const char * cChatColor::Green = "\xc2\xa7""2";
|
||||||
const std::string cChatColor::Blue = cChatColor::Color + "3";
|
const char * cChatColor::Blue = "\xc2\xa7""3";
|
||||||
const std::string cChatColor::Red = cChatColor::Color + "4";
|
const char * cChatColor::Red = "\xc2\xa7""4";
|
||||||
const std::string cChatColor::Purple = cChatColor::Color + "5";
|
const char * cChatColor::Purple = "\xc2\xa7""5";
|
||||||
const std::string cChatColor::Gold = cChatColor::Color + "6";
|
const char * cChatColor::Gold = "\xc2\xa7""6";
|
||||||
const std::string cChatColor::LightGray = cChatColor::Color + "7";
|
const char * cChatColor::LightGray = "\xc2\xa7""7";
|
||||||
const std::string cChatColor::Gray = cChatColor::Color + "8";
|
const char * cChatColor::Gray = "\xc2\xa7""8";
|
||||||
const std::string cChatColor::DarkPurple = cChatColor::Color + "9";
|
const char * cChatColor::DarkPurple = "\xc2\xa7""9";
|
||||||
const std::string cChatColor::LightGreen = cChatColor::Color + "a";
|
const char * cChatColor::LightGreen = "\xc2\xa7""a";
|
||||||
const std::string cChatColor::LightBlue = cChatColor::Color + "b";
|
const char * cChatColor::LightBlue = "\xc2\xa7""b";
|
||||||
const std::string cChatColor::Rose = cChatColor::Color + "c";
|
const char * cChatColor::Rose = "\xc2\xa7""c";
|
||||||
const std::string cChatColor::LightPurple = cChatColor::Color + "d";
|
const char * cChatColor::LightPurple = "\xc2\xa7""d";
|
||||||
const std::string cChatColor::Yellow = cChatColor::Color + "e";
|
const char * cChatColor::Yellow = "\xc2\xa7""e";
|
||||||
const std::string cChatColor::White = cChatColor::Color + "f";
|
const char * cChatColor::White = "\xc2\xa7""f";
|
||||||
|
|
||||||
const std::string cChatColor::Random = cChatColor::Color + "k";
|
const char * cChatColor::Random = "\xc2\xa7""k";
|
||||||
const std::string cChatColor::Bold = cChatColor::Color + "l";
|
const char * cChatColor::Bold = "\xc2\xa7""l";
|
||||||
const std::string cChatColor::Strikethrough = cChatColor::Color + "m";
|
const char * cChatColor::Strikethrough = "\xc2\xa7""m";
|
||||||
const std::string cChatColor::Underlined = cChatColor::Color + "n";
|
const char * cChatColor::Underlined = "\xc2\xa7""n";
|
||||||
const std::string cChatColor::Italic = cChatColor::Color + "o";
|
const char * cChatColor::Italic = "\xc2\xa7""o";
|
||||||
const std::string cChatColor::Plain = cChatColor::Color + "r";
|
const char * cChatColor::Plain = "\xc2\xa7""r";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,33 +9,35 @@
|
|||||||
class cChatColor
|
class cChatColor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const std::string Color;
|
static const char * Delimiter;
|
||||||
static const std::string Delimiter;
|
|
||||||
|
/** @deprecated use ChatColor::Delimiter instead */
|
||||||
|
static const char * Color;
|
||||||
|
|
||||||
static const std::string Black;
|
static const char * Black;
|
||||||
static const std::string Navy;
|
static const char * Navy;
|
||||||
static const std::string Green;
|
static const char * Green;
|
||||||
static const std::string Blue;
|
static const char * Blue;
|
||||||
static const std::string Red;
|
static const char * Red;
|
||||||
static const std::string Purple;
|
static const char * Purple;
|
||||||
static const std::string Gold;
|
static const char * Gold;
|
||||||
static const std::string LightGray;
|
static const char * LightGray;
|
||||||
static const std::string Gray;
|
static const char * Gray;
|
||||||
static const std::string DarkPurple;
|
static const char * DarkPurple;
|
||||||
static const std::string LightGreen;
|
static const char * LightGreen;
|
||||||
static const std::string LightBlue;
|
static const char * LightBlue;
|
||||||
static const std::string Rose;
|
static const char * Rose;
|
||||||
static const std::string LightPurple;
|
static const char * LightPurple;
|
||||||
static const std::string Yellow;
|
static const char * Yellow;
|
||||||
static const std::string White;
|
static const char * White;
|
||||||
|
|
||||||
// Styles ( source: http://wiki.vg/Chat )
|
// Styles ( source: http://wiki.vg/Chat )
|
||||||
static const std::string Random;
|
static const char * Random;
|
||||||
static const std::string Bold;
|
static const char * Bold;
|
||||||
static const std::string Strikethrough;
|
static const char * Strikethrough;
|
||||||
static const std::string Underlined;
|
static const char * Underlined;
|
||||||
static const std::string Italic;
|
static const char * Italic;
|
||||||
static const std::string Plain;
|
static const char * Plain;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -210,11 +210,11 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
|
|||||||
{
|
{
|
||||||
if (ShouldAppendChatPrefixes)
|
if (ShouldAppendChatPrefixes)
|
||||||
{
|
{
|
||||||
return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str());
|
return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue, a_AdditionalData.c_str(), cChatColor::White, cChatColor::Italic);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
|
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -533,9 +533,9 @@ void cClientHandle::HandlePing(void)
|
|||||||
|
|
||||||
Printf(Reply, "%s%s%i%s%i",
|
Printf(Reply, "%s%s%i%s%i",
|
||||||
Server.GetDescription().c_str(),
|
Server.GetDescription().c_str(),
|
||||||
cChatColor::Delimiter.c_str(),
|
cChatColor::Delimiter,
|
||||||
Server.GetNumPlayers(),
|
Server.GetNumPlayers(),
|
||||||
cChatColor::Delimiter.c_str(),
|
cChatColor::Delimiter,
|
||||||
Server.GetMaxPlayers()
|
Server.GetMaxPlayers()
|
||||||
);
|
);
|
||||||
Kick(Reply);
|
Kick(Reply);
|
||||||
|
@ -1524,7 +1524,7 @@ AString cPlayer::GetColor(void) const
|
|||||||
{
|
{
|
||||||
if ( m_Color != '-' )
|
if ( m_Color != '-' )
|
||||||
{
|
{
|
||||||
return cChatColor::Color + m_Color;
|
return cChatColor::Delimiter + m_Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_Groups.size() < 1 )
|
if ( m_Groups.size() < 1 )
|
||||||
|
@ -153,7 +153,7 @@ bool cGroupManager::LoadGroups()
|
|||||||
AString Color = IniFile.GetValue(KeyName, "Color", "-");
|
AString Color = IniFile.GetValue(KeyName, "Color", "-");
|
||||||
if ((Color != "-") && (Color.length() >= 1))
|
if ((Color != "-") && (Color.length() >= 1))
|
||||||
{
|
{
|
||||||
Group->SetColor(cChatColor::Color + Color[0]);
|
Group->SetColor(cChatColor::Delimiter + Color[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1021,9 +1021,9 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
|
|||||||
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29
|
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29
|
||||||
Printf(Reply, "%s%s%i%s%i",
|
Printf(Reply, "%s%s%i%s%i",
|
||||||
Server->GetDescription().c_str(),
|
Server->GetDescription().c_str(),
|
||||||
cChatColor::Delimiter.c_str(),
|
cChatColor::Delimiter,
|
||||||
Server->GetNumPlayers(),
|
Server->GetNumPlayers(),
|
||||||
cChatColor::Delimiter.c_str(),
|
cChatColor::Delimiter,
|
||||||
Server->GetMaxPlayers()
|
Server->GetMaxPlayers()
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user