r4475 - in trunk/data/qcsrc/menu: . nexuiz

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Sep 21 07:13:48 EDT 2008


Author: div0
Date: 2008-09-21 07:13:47 -0400 (Sun, 21 Sep 2008)
New Revision: 4475

Modified:
   trunk/data/qcsrc/menu/menu.qc
   trunk/data/qcsrc/menu/nexuiz/serverlist.c
   trunk/data/qcsrc/menu/skin-customizables.inc
Log:
experimental favorites feature (right click a server)


Modified: trunk/data/qcsrc/menu/menu.qc
===================================================================
--- trunk/data/qcsrc/menu/menu.qc	2008-09-20 15:20:16 UTC (rev 4474)
+++ trunk/data/qcsrc/menu/menu.qc	2008-09-21 11:13:47 UTC (rev 4475)
@@ -150,13 +150,13 @@
 	else
 	{
 		draw_reset();
+		if(key >= K_MOUSE1 && key <= K_MOUSE3)
+			if(!mouseButtonsPressed)
+				main.mousePress(main, menuMousePos);
 		if(!main.keyDown(main, key, ascii, menuShiftState))
 			if(key == K_ESCAPE)
 				if(gamestatus & (GAME_ISSERVER | GAME_CONNECTED)) // don't back out to console only
 					m_hide(); // disable menu on unhandled ESC
-		if(key >= K_MOUSE1 && key <= K_MOUSE3)
-			if(!mouseButtonsPressed)
-				main.mousePress(main, menuMousePos);
 	}
 	if(key >= K_MOUSE1 && key <= K_MOUSE3)
 	{

Modified: trunk/data/qcsrc/menu/nexuiz/serverlist.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/serverlist.c	2008-09-20 15:20:16 UTC (rev 4474)
+++ trunk/data/qcsrc/menu/nexuiz/serverlist.c	2008-09-21 11:13:47 UTC (rev 4475)
@@ -66,6 +66,7 @@
 float SLIST_FIELD_FREESLOTS;
 float SLIST_FIELD_PLAYERS;
 float SLIST_FIELD_QCSTATUS;
+float SLIST_FIELD_ISFAVORITE;
 void ServerList_UpdateFieldIDs()
 {
 	SLIST_FIELD_CNAME = gethostcacheindexforkey( "cname" );
@@ -82,6 +83,7 @@
 	SLIST_FIELD_FREESLOTS = gethostcacheindexforkey( "freeslots" );
 	SLIST_FIELD_PLAYERS = gethostcacheindexforkey( "players" );
 	SLIST_FIELD_QCSTATUS = gethostcacheindexforkey( "qcstatus" );
+	SLIST_FIELD_ISFAVORITE = gethostcacheindexforkey( "isfavorite" );
 }
 
 entity makeNexuizServerList()
@@ -130,7 +132,7 @@
 	}
 	else */
 	{
-		float m;
+		float m, o;
 		string s, typestr;
 		s = me.filterString;
 
@@ -161,7 +163,10 @@
 			sethostcachemaskstring(++m, SLIST_FIELD_PLAYERS, s, SLIST_TEST_CONTAINS);
 			sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(s, ":"), SLIST_TEST_STARTSWITH);
 		}
-		sethostcachesort(me.currentSortField, me.currentSortOrder < 0);
+		o = 2; // favorites first
+		if(me.currentSortOrder < 0)
+			o |= 1; // descending
+		sethostcachesort(me.currentSortField, o);
 		resorthostcache();
 		if(mode >= 1)
 			refreshhostcache();
@@ -428,6 +433,12 @@
 		theAlpha *= SKINALPHA_SERVERLIST_HIGHPING;
 	}
 
+	if(gethostcachenumber(SLIST_FIELD_ISFAVORITE, i))
+	{
+		theColor = theColor * (1 - SKINALPHA_SERVERLIST_FAVORITE) + SKINCOLOR_SERVERLIST_FAVORITE * SKINALPHA_SERVERLIST_FAVORITE;
+		theAlpha = theAlpha * (1 - SKINALPHA_SERVERLIST_FAVORITE) + SKINALPHA_SERVERLIST_FAVORITE;
+	}
+
 	s = ftos(p);
 	draw_Text(me.realUpperMargin * eY + (me.columnPingSize - draw_TextWidth(s, 0) * me.realFontSize_x) * eX, s, me.realFontSize, theColor, theAlpha, 0);
 	s = draw_TextShortenToWidth(gethostcachestring(SLIST_FIELD_NAME, i), me.columnNameSize / me.realFontSize_x, 0);
@@ -448,11 +459,37 @@
 
 float keyDownNexuizServerList(entity me, float scan, float ascii, float shift)
 {
+	float i, o;
+	string s;
+
 	if(scan == K_ENTER)
 	{
 		ServerList_Connect_Click(NULL, me);
 		return 1;
 	}
+	else if(scan == K_INS || scan == K_MOUSE2 || scan == K_MOUSE3)
+	{
+		i = me.selectedItem;
+		if(i < me.nItems)
+		{
+			s = cvar_string("net_slist_favorites");
+			o = strstrofs(strcat(" ", s, " "), strcat(" ", me.selectedServer, " "), 0);
+			if(o == -1)
+			{
+				cvar_set("net_slist_favorites", strcat(s, " ", me.selectedServer));
+			}
+			else
+			{
+				cvar_set("net_slist_favorites", strcat(
+					substring(s, 0, o - 1), substring(s, o + strlen(me.selectedServer), strlen(s) - o - strlen(me.selectedServer))
+				));
+			}
+			resorthostcache();
+		}
+		me.lastClickedServer = -1; // inhibit double clicks using these buttons
+		if(scan != K_INS)
+			me.setSelected(me, me.selectedItem);
+	}
 	else if(keyDownListBox(me, scan, ascii, shift))
 		return 1;
 	else if(!me.controlledTextbox)

Modified: trunk/data/qcsrc/menu/skin-customizables.inc
===================================================================
--- trunk/data/qcsrc/menu/skin-customizables.inc	2008-09-20 15:20:16 UTC (rev 4474)
+++ trunk/data/qcsrc/menu/skin-customizables.inc	2008-09-21 11:13:47 UTC (rev 4475)
@@ -184,6 +184,8 @@
 	SKINVECTOR(COLOR_SERVERLIST_MEDPING, '1 1 0');
 	SKINVECTOR(COLOR_SERVERLIST_HIGHPING, '1 0 0');
 	SKINFLOAT(ALPHA_SERVERLIST_HIGHPING, 0.4);
+	SKINFLOAT(ALPHA_SERVERLIST_FAVORITE, 0.8);
+	SKINVECTOR(COLOR_SERVERLIST_FAVORITE, '1 1 1');
 
 	// item: slider
 	SKINSTRING(GFX_SLIDER, "slider");




More information about the nexuiz-commits mailing list