r2934 - in trunk/data/qcsrc/menu-div0test: . nexuiz

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Nov 10 10:00:10 EST 2007


Author: div0
Date: 2007-11-10 10:00:08 -0500 (Sat, 10 Nov 2007)
New Revision: 2934

Added:
   trunk/data/qcsrc/menu-div0test/nexuiz/inputbox.c
Modified:
   trunk/data/qcsrc/menu-div0test/classes.c
   trunk/data/qcsrc/menu-div0test/nexuiz/dialog_multiplayer_join.c
   trunk/data/qcsrc/menu-div0test/nexuiz/serverlist.c
   trunk/data/qcsrc/menu-div0test/skin.qh
Log:
made server filter work! Hooray, JOIN dialog is complete!


Modified: trunk/data/qcsrc/menu-div0test/classes.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/classes.c	2007-11-10 14:41:38 UTC (rev 2933)
+++ trunk/data/qcsrc/menu-div0test/classes.c	2007-11-10 15:00:08 UTC (rev 2934)
@@ -40,3 +40,4 @@
 #include "nexuiz/dialog_multiplayer_join.c"
 #include "nexuiz/listbox.c"
 #include "nexuiz/serverlist.c"
+#include "nexuiz/inputbox.c"

Modified: trunk/data/qcsrc/menu-div0test/nexuiz/dialog_multiplayer_join.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog_multiplayer_join.c	2007-11-10 14:41:38 UTC (rev 2933)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog_multiplayer_join.c	2007-11-10 15:00:08 UTC (rev 2934)
@@ -10,15 +10,6 @@
 #endif
 
 #ifdef IMPLEMENTATION
-entity makeNexuizTextBox()
-{
-	entity e;
-	e = spawnInputBox();
-	e.configureInputBox(e, "hello world", 3, 12, "qcsrc/menu-div0test/basebutton");
-	e.keepspaceLeft = 0.1;
-	e.keepspaceRight = 0.2;
-	return e;
-}
 
 entity makeNexuizServerListTab()
 {
@@ -35,7 +26,9 @@
 
 	me.TR(me);
 		me.TD(me, 1, 0.5, e = makeNexuizTextLabel(0, "Filter:"));
-		me.TD(me, 1, me.columns - 2, e = makeNexuizTextBox());
+		me.TD(me, 1, me.columns - 2, e = makeNexuizInputBox(0, string_null));
+			e.onChange = ServerList_Filter_Change;
+			e.onChangeEntity = slist;
 		me.TD(me, 1, 0.75, e = makeNexuizCheckBox(0, string_null, "Empty"));
 			e.checked = slist.filterShowEmpty;
 			e.onClickEntity = slist;

Added: trunk/data/qcsrc/menu-div0test/nexuiz/inputbox.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/inputbox.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/inputbox.c	2007-11-10 15:00:08 UTC (rev 2934)
@@ -0,0 +1,60 @@
+#ifdef INTERFACE
+CLASS(NexuizInputBox) EXTENDS(InputBox)
+	METHOD(NexuizInputBox, configureNexuizInputBox, void(entity, float, string))
+	METHOD(NexuizInputBox, focusLeave, void(entity))
+	METHOD(NexuizInputBox, setText, void(entity, string))
+	ATTRIB(NexuizInputBox, fontSize, float, SKINFONTSIZE_NORMAL)
+	ATTRIB(NexuizInputBox, image, string, SKINGFX_INPUTBOX)
+	ATTRIB(NexuizInputBox, onChange, void(entity, entity), SUB_Null)
+	ATTRIB(NexuizInputBox, onChangeEntity, entity, NULL)
+
+	ATTRIB(NexuizInputBox, cvarName, string, string_null)
+	METHOD(NexuizInputBox, loadCvars, void(entity))
+	METHOD(NexuizInputBox, saveCvars, void(entity))
+ENDCLASS(NexuizInputBox)
+entity makeNexuizInputBox(float, string);
+#endif
+
+#ifdef IMPLEMENTATION
+entity makeNexuizInputBox(float doEditColorCodes, string theCvar)
+{
+	entity me;
+	me = spawnNexuizInputBox();
+	me.configureNexuizInputBox(me, doEditColorCodes, theCvar);
+	return me;
+}
+void configureNexuizInputBoxNexuizInputBox(entity me, float doEditColorCodes, string theCvar)
+{
+	me.configureInputBox(me, "", 0, me.fontSize, me.image);
+	me.editColorCodes = doEditColorCodes;
+	if(theCvar)
+	{
+		me.cvarName = theCvar;
+		me.loadCvars(me);
+	}
+	me.cursorPos = strlen(me.text);
+}
+void focusLeaveNexuizInputBox(entity me)
+{
+	if(me.cvarName)
+		me.saveCvars(me);
+}
+void setTextNexuizInputBox(entity me, string new)
+{
+	if(me.text != new)
+	{
+		setTextInputBox(me, new);
+		me.onChange(me, me.onChangeEntity);
+	}
+	else
+		setTextInputBox(me, new);
+}
+void loadCvarsNexuizInputBox(entity me)
+{
+	setTextInputBox(me, cvar_string(me.cvarName));
+}
+void saveCvarsNexuizInputBox(entity me)
+{
+	cvar_set(me.cvarName, me.text);
+}
+#endif

Modified: trunk/data/qcsrc/menu-div0test/nexuiz/serverlist.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/serverlist.c	2007-11-10 14:41:38 UTC (rev 2933)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/serverlist.c	2007-11-10 15:00:08 UTC (rev 2934)
@@ -23,6 +23,7 @@
 	METHOD(NexuizServerList, setSortOrder, void(entity, float, float))
 	ATTRIB(NexuizServerList, filterShowEmpty, float, 1)
 	ATTRIB(NexuizServerList, filterShowFull, float, 1)
+	ATTRIB(NexuizServerList, filterString, string, string_null)
 	ATTRIB(NexuizServerList, nextRefreshTime, float, 0)
 	METHOD(NexuizServerList, refreshServerList, void(entity, float)) // refresh mode: 0 = just reparametrize, 1 = send new requests, 2 = clear
 	ATTRIB(NexuizServerList, needsRefresh, float, 1)
@@ -42,6 +43,7 @@
 void ServerList_Connect_Click(entity btn, entity me);
 void ServerList_ShowEmpty_Click(entity box, entity me);
 void ServerList_ShowFull_Click(entity box, entity me);
+void ServerList_Filter_Change(entity box, entity me);
 #endif
 
 #ifdef IMPLEMENTATION
@@ -126,6 +128,12 @@
 			sethostcachemasknumber(m++, SLIST_FIELD_FREESLOTS, 1, SLIST_TEST_GREATEREQUAL);
 		if(!me.filterShowEmpty)
 			sethostcachemasknumber(m++, SLIST_FIELD_NUMHUMANS, 1, SLIST_TEST_GREATEREQUAL);
+		m = SLIST_MASK_OR;
+		if(me.filterString)
+		{
+			sethostcachemaskstring(m++, SLIST_FIELD_NAME, me.filterString, SLIST_TEST_CONTAINS);
+			sethostcachemaskstring(m++, SLIST_FIELD_MAP, me.filterString, SLIST_TEST_CONTAINS);
+		}
 		sethostcachesort(me.currentSortField, me.currentSortOrder < 0);
 		resorthostcache();
 		if(mode >= 1)
@@ -207,6 +215,16 @@
 {
 	me.setSortOrder(me, SLIST_FIELD_NUMHUMANS, -1);
 }
+void ServerList_Filter_Change(entity box, entity me)
+{
+	if(me.filterString)
+		strunzone(me.filterString);
+	if(box.text != "")
+		me.filterString = strzone(box.text);
+	else
+		me.filterString = string_null;
+	me.refreshServerList(me, 0);
+}
 void ServerList_ShowEmpty_Click(entity box, entity me)
 {
 	box.checked = me.filterShowEmpty = !me.filterShowEmpty;

Modified: trunk/data/qcsrc/menu-div0test/skin.qh
===================================================================
--- trunk/data/qcsrc/menu-div0test/skin.qh	2007-11-10 14:41:38 UTC (rev 2933)
+++ trunk/data/qcsrc/menu-div0test/skin.qh	2007-11-10 15:00:08 UTC (rev 2934)
@@ -10,6 +10,7 @@
 const string SKINGFX_COLORBUTTON = "qcsrc/menu-div0test/basebutton";
 const string SKINGFX_COLORBUTTON_COLOR = "qcsrc/menu-div0test/color";
 const string SKINGFX_SCROLLBAR = "qcsrc/menu-div0test/basescrollbar";
+const string SKINGFX_INPUTBOX = "qcsrc/menu-div0test/basebuttongray";
 
 const float SKINMARGIN_TOP = 8;
 const float SKINMARGIN_LEFT = 8;




More information about the nexuiz-commits mailing list