Added support for colored nicknames

Fri, 15 May 2015 22:46:53 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Fri, 15 May 2015 22:46:53 +0300
changeset 132
8a4690db252e
parent 129
a556ce001e26
child 133
4d8fa5394d67
child 137
485cb6d6b98c

Added support for colored nicknames

sources/coloredline.cpp file | annotate | diff | comparison | revisions
sources/coloredline.h file | annotate | diff | comparison | revisions
sources/interface.cpp file | annotate | diff | comparison | revisions
sources/interface.h file | annotate | diff | comparison | revisions
sources/network/rconsession.h file | annotate | diff | comparison | revisions
--- a/sources/coloredline.cpp	Mon Jan 11 16:58:59 2016 +0200
+++ b/sources/coloredline.cpp	Fri May 15 22:46:53 2015 +0300
@@ -176,6 +176,14 @@
 
 // -------------------------------------------------------------------------------------------------
 //
+void ColoredLine::add_string (const String& text)
+{
+	for (char a : text)
+		add_char (a);
+}
+
+// -------------------------------------------------------------------------------------------------
+//
 void ColoredLine::set_color (Color a, bool on)
 {
 	assert (a < 8);
--- a/sources/coloredline.h	Mon Jan 11 16:58:59 2016 +0200
+++ b/sources/coloredline.h	Fri May 15 22:46:53 2015 +0300
@@ -69,6 +69,7 @@
 	const Vector<int>& 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;
 
--- a/sources/interface.cpp	Mon Jan 11 16:58:59 2016 +0200
+++ b/sources/interface.cpp	Fri May 15 22:46:53 2015 +0300
@@ -392,17 +392,7 @@
 		mvhline (y, x, ' ', width);
 
 		if (i < m_playerNames.size())
-		{
-			String displaynick = m_playerNames[i];
-
-			if (displaynick.length() > width)
-			{
-				displaynick = displaynick.mid (0, width - 3);
-				displaynick += "...";
-			}
-
-			mvprintw (y, x, "%s", displaynick.chars());
-		}
+			render_colorline (y, x, width, m_playerNames[i], false);
 
 		y++;
 	}
@@ -1029,7 +1019,16 @@
 //
 void Interface::set_player_names (const StringList& names)
 {
-	m_playerNames = names;
+	m_playerNames.clear();
+
+	for (const String& name : names)
+	{
+		ColoredLine coloredname;
+		coloredname.add_string (name);
+		coloredname.finalize();
+		m_playerNames.append (coloredname);
+	}
+
 	m_needNicklistRender = true;
 }
 
--- a/sources/interface.h	Mon Jan 11 16:58:59 2016 +0200
+++ b/sources/interface.h	Fri May 15 22:46:53 2015 +0300
@@ -86,7 +86,7 @@
 	std::function<void(bool)> m_disconnectCallback;
 	IPAddress m_remoteAddress;
 	String m_statusBarText;
-	StringList m_playerNames;
+	List<ColoredLine> m_playerNames;
 	String m_pasteBuffer;
 	RCONSession m_session;
 
--- a/sources/network/rconsession.h	Mon Jan 11 16:58:59 2016 +0200
+++ b/sources/network/rconsession.h	Fri May 15 22:46:53 2015 +0300
@@ -38,7 +38,7 @@
 //
 enum
 {
-	RCON_PROTOCOL_VERSION = 4
+	RCON_PROTOCOL_VERSION = 5
 };
 
 // -------------------------------------------------------------------------------------------------

mercurial