diff options
author | madmaxoft <github@xoft.cz> | 2014-02-16 23:51:32 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-02-16 23:51:32 +0100 |
commit | ea55a22a71a6fd46877bc4b6b56d6205dd20608f (patch) | |
tree | 3effb7f1081a9930129d5f875af49d429c3a9211 /src | |
parent | Implemented cCompositeChat::ParseText(), incl. self-test. (diff) | |
download | cuberite-ea55a22a71a6fd46877bc4b6b56d6205dd20608f.tar cuberite-ea55a22a71a6fd46877bc4b6b56d6205dd20608f.tar.gz cuberite-ea55a22a71a6fd46877bc4b6b56d6205dd20608f.tar.bz2 cuberite-ea55a22a71a6fd46877bc4b6b56d6205dd20608f.tar.lz cuberite-ea55a22a71a6fd46877bc4b6b56d6205dd20608f.tar.xz cuberite-ea55a22a71a6fd46877bc4b6b56d6205dd20608f.tar.zst cuberite-ea55a22a71a6fd46877bc4b6b56d6205dd20608f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ClientHandle.cpp | 22 | ||||
-rw-r--r-- | src/CompositeChat.cpp | 15 | ||||
-rw-r--r-- | src/CompositeChat.h | 3 | ||||
-rw-r--r-- | src/Entities/Player.h | 3 |
4 files changed, 34 insertions, 9 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index b46bcfd47..c91a0c01b 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1089,14 +1089,20 @@ void cClientHandle::HandleChat(const AString & a_Message) return; } - // Not a command, broadcast as a simple message: - AString Msg; - Printf(Msg, "%s<%s>%s %s", - m_Player->GetColor().c_str(), - m_Player->GetName().c_str(), - cChatColor::White.c_str(), - Message.c_str() - ); + // Not a command, broadcast as a message: + cCompositeChat Msg; + AString Color = m_Player->GetColor(); + if (Color.length() == 3) + { + Color = AString("@") + Color[2]; + } + else + { + Color.empty(); + } + Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color); + Msg.ParseText(a_Message); + Msg.UnderlineUrls(); m_Player->GetWorld()->BroadcastChat(Msg); } diff --git a/src/CompositeChat.cpp b/src/CompositeChat.cpp index 1893585f6..3eec35657 100644 --- a/src/CompositeChat.cpp +++ b/src/CompositeChat.cpp @@ -299,6 +299,21 @@ void cCompositeChat::SetMessageType(eMessageType a_MessageType) +void cCompositeChat::UnderlineUrls(void) +{ + for (cParts::iterator itr = m_Parts.begin(), end = m_Parts.end(); itr != end; ++itr) + { + if ((*itr)->m_PartType == ptUrl) + { + (*itr)->m_Style.append("u"); + } + } // for itr - m_Parts[] +} + + + + + void cCompositeChat::AddStyle(AString & a_Style, const AString & a_AddStyle) { if (a_AddStyle.empty()) diff --git a/src/CompositeChat.h b/src/CompositeChat.h index 4b3523b08..8963bb520 100644 --- a/src/CompositeChat.h +++ b/src/CompositeChat.h @@ -155,6 +155,9 @@ public: /** Returns the message type set previously by SetMessageType(). */ eMessageType GetMessageType(void) const { return m_MessageType; } + /** Adds the "underline" style to each part that is an URL. */ + void UnderlineUrls(void); + // tolua_end const cParts & GetParts(void) const { return m_Parts; } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 53e4b56db..a795bb9eb 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -226,7 +226,8 @@ public: // tolua_begin - /// Returns the full color code to use for this player, based on their primary group or set in m_Color + /** Returns the full color code to use for this player, based on their primary group or set in m_Color. + The returned value includes the cChatColor::Delimiter. */ AString GetColor(void) const; /** tosses the item in the selected hotbar slot */ |