# HG changeset patch # User Teemu Piippo # Date 1431719213 -10800 # Node ID c1d43ade656e301a9eb295f8a002feb109de2bf4 # Parent 32ef969adeed3bd0e131db27d710d0d556321a7a Added support for colored nicknames diff -r 32ef969adeed -r c1d43ade656e sources/coloredline.cpp --- a/sources/coloredline.cpp Fri May 15 21:43:21 2015 +0300 +++ b/sources/coloredline.cpp Fri May 15 22:46:53 2015 +0300 @@ -125,6 +125,14 @@ // ------------------------------------------------------------------------------------------------- // +void ColoredLine::add_string (const String& text) +{ + for (char a : text) + add_char (a); +} + +// ------------------------------------------------------------------------------------------------- +// void ColoredLine::set_color (Color a, bool on) { switch (a) diff -r 32ef969adeed -r c1d43ade656e sources/coloredline.h --- a/sources/coloredline.h Fri May 15 21:43:21 2015 +0300 +++ b/sources/coloredline.h Fri May 15 22:46:53 2015 +0300 @@ -65,6 +65,7 @@ const Vector& data() const { return m_data; } int length() const { return m_length; } void add_char (char ch); + void add_string (const String& msg); void finalize(); int rows (int cols) const; diff -r 32ef969adeed -r c1d43ade656e sources/interface.cpp --- a/sources/interface.cpp Fri May 15 21:43:21 2015 +0300 +++ b/sources/interface.cpp Fri May 15 22:46:53 2015 +0300 @@ -378,17 +378,7 @@ mvhline (y, x, ' ', width); if (i < PlayerNames.size()) - { - String displaynick = PlayerNames[i]; - - if (displaynick.length() > width) - { - displaynick = displaynick.mid (0, width - 3); - displaynick += "..."; - } - - mvprintw (y, x, "%s", displaynick.chars()); - } + render_colorline (y, x, width, PlayerNames[i], false); y++; } @@ -936,7 +926,16 @@ // void Interface::set_player_names (const StringList& names) { - PlayerNames = names; + PlayerNames.clear(); + + for (const String& name : names) + { + ColoredLine coloredname; + coloredname.add_string (name); + coloredname.finalize(); + PlayerNames.append (coloredname); + } + NeedNicklistRender = true; } diff -r 32ef969adeed -r c1d43ade656e sources/interface.h --- a/sources/interface.h Fri May 15 21:43:21 2015 +0300 +++ b/sources/interface.h Fri May 15 22:46:53 2015 +0300 @@ -93,7 +93,7 @@ Function DisconnectConfirmFunction = nullptr; IPAddress CurrentAddress; String StatusBarText; - StringList PlayerNames; + List PlayerNames; String PasteBuffer; RCONSession Session; diff -r 32ef969adeed -r c1d43ade656e sources/network/rconsession.cpp --- a/sources/network/rconsession.cpp Fri May 15 21:43:21 2015 +0300 +++ b/sources/network/rconsession.cpp Fri May 15 22:46:53 2015 +0300 @@ -375,4 +375,4 @@ } else m_interface->print ("Server protocol is %1, cannot tab-complete\n", m_serverProtocol); -} \ No newline at end of file +} diff -r 32ef969adeed -r c1d43ade656e sources/network/rconsession.h --- a/sources/network/rconsession.h Fri May 15 21:43:21 2015 +0300 +++ b/sources/network/rconsession.h Fri May 15 22:46:53 2015 +0300 @@ -37,7 +37,7 @@ // enum { - RCON_PROTOCOL_VERSION = 4 + RCON_PROTOCOL_VERSION = 5 }; // -------------------------------------------------------------------------------------------------