r3182 - trunk/data/qcsrc/menu-div0test/nexuiz

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Jan 19 04:09:26 EST 2008


Author: div0
Date: 2008-01-19 04:09:19 -0500 (Sat, 19 Jan 2008)
New Revision: 3182

Added:
   trunk/data/qcsrc/menu-div0test/nexuiz/credits.c
   trunk/data/qcsrc/menu-div0test/nexuiz/dialog_credits.c
Log:
Oops. I always forget to commit files.


Added: trunk/data/qcsrc/menu-div0test/nexuiz/credits.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/credits.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/credits.c	2008-01-19 09:09:19 UTC (rev 3182)
@@ -0,0 +1,134 @@
+#ifdef INTERFACE
+CLASS(NexuizCreditsList) EXTENDS(NexuizListBox)
+	METHOD(NexuizCreditsList, configureNexuizCreditsList, void(entity))
+	ATTRIB(NexuizCreditsList, rowsPerItem, float, 1)
+	METHOD(NexuizCreditsList, draw, void(entity))
+	METHOD(NexuizCreditsList, drawListBoxItem, void(entity, float, vector, float))
+	METHOD(NexuizCreditsList, resizeNotify, void(entity, vector, vector, vector, vector))
+	METHOD(NexuizCreditsList, keyDown, float(entity, float, float, float))
+
+	ATTRIB(NexuizCreditsList, realFontSize, vector, '0 0 0')
+	ATTRIB(NexuizCreditsList, realUpperMargin, float, 0)
+	ATTRIB(NexuizCreditsList, bufferIndex, float, 0)
+	ATTRIB(NexuizCreditsList, scrolling, float, 0)
+ENDCLASS(NexuizCreditsList)
+entity makeNexuizCreditsList();
+#endif
+
+#ifdef IMPLEMENTATION
+float SLIST_FIELD_CNAME;
+float SLIST_FIELD_PING;
+float SLIST_FIELD_GAME;
+float SLIST_FIELD_MOD;
+float SLIST_FIELD_MAP;
+float SLIST_FIELD_NAME;
+float SLIST_FIELD_MAXPLAYERS;
+float SLIST_FIELD_NUMPLAYERS;
+float SLIST_FIELD_NUMHUMANS;
+float SLIST_FIELD_NUMBOTS;
+float SLIST_FIELD_PROTOCOL;
+float SLIST_FIELD_FREESLOTS;
+void CreditsList_UpdateFieldIDs()
+{
+	SLIST_FIELD_CNAME = gethostcacheindexforkey( "cname" );
+	SLIST_FIELD_PING = gethostcacheindexforkey( "ping" );
+	SLIST_FIELD_GAME = gethostcacheindexforkey( "game" );
+	SLIST_FIELD_MOD = gethostcacheindexforkey( "mod" );
+	SLIST_FIELD_MAP = gethostcacheindexforkey( "map" );
+	SLIST_FIELD_NAME = gethostcacheindexforkey( "name" );
+	SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey( "maxplayers" );
+	SLIST_FIELD_NUMPLAYERS = gethostcacheindexforkey( "numplayers" );
+	SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey( "numhumans" );
+	SLIST_FIELD_NUMBOTS = gethostcacheindexforkey( "numbots" );
+	SLIST_FIELD_PROTOCOL = gethostcacheindexforkey( "protocol" );
+	SLIST_FIELD_FREESLOTS = gethostcacheindexforkey( "freeslots" );
+}
+
+entity makeNexuizCreditsList()
+{
+	entity me;
+	me = spawnNexuizCreditsList();
+	me.configureNexuizCreditsList(me);
+	return me;
+}
+void configureNexuizCreditsListNexuizCreditsList(entity me)
+{
+	me.configureNexuizListBox(me);
+	// load the file
+	me.bufferIndex = buf_load("nexuiz-credits.txt");
+	me.nItems = buf_getsize(me.bufferIndex);
+}
+void drawNexuizCreditsList(entity me)
+{
+	float i;
+	if(me.scrolling && time > me.scrolling)
+	{
+		me.scrollPos = min(me.scrollPos + frametime * me.itemHeight, me.nItems * me.itemHeight - 1);
+		i = min(me.selectedItem, floor((me.scrollPos + 1) / me.itemHeight - 1));
+		i = max(i, ceil(me.scrollPos / me.itemHeight));
+		me.setSelected(me, i);
+	}
+	drawListBox(me);
+}
+void resizeNotifyNexuizCreditsList(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+	resizeNotifyNexuizListBox(me, relOrigin, relSize, absOrigin, absSize);
+
+	me.realFontSize_y = me.fontSize / (absSize_y * me.itemHeight);
+	me.realFontSize_x = me.fontSize / (absSize_x * (1 - me.controlWidth));
+	me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
+}
+void drawListBoxItemNexuizCreditsList(entity me, float i, vector absSize, float isSelected)
+{
+	// layout: Ping, Credits name, Map name, NP, TP, MP
+	string s;
+	float theAlpha;
+	vector theColor;
+
+	s = bufstr_get(me.bufferIndex, i);
+
+	if(substring(s, 0, 2) == "**")
+	{
+		s = substring(s, 2, strlen(s) - 2);
+		theColor = SKINCOLOR_CREDITS_TITLE;
+		theAlpha = SKINALPHA_CREDITS_TITLE;
+	}
+	else if(substring(s, 0, 1) == "*")
+	{
+		s = substring(s, 1, strlen(s) - 1);
+		theColor = SKINCOLOR_CREDITS_FUNCTION;
+		theAlpha = SKINALPHA_CREDITS_FUNCTION;
+	}
+	else
+	{
+		theColor = SKINCOLOR_CREDITS_PERSON;
+		theAlpha = SKINALPHA_CREDITS_PERSON;
+	}
+
+	draw_CenterText(me.realUpperMargin * eY + 0.5 * eX, s, me.realFontSize, theColor, theAlpha, 0);
+}
+
+float keyDownNexuizCreditsList(entity me, float scan, float ascii, float shift)
+{
+	float i;
+	me.dragScrollTimer = 0;
+	me.scrolling = 0;
+
+	if(scan == K_PGUP)
+		me.scrollPos = max(me.scrollPos - 0.5, 0);
+	else if(scan == K_PGDN)
+		me.scrollPos = min(me.scrollPos + 0.5, me.nItems * me.itemHeight - 1);
+	else if(scan == K_UPARROW)
+		me.scrollPos = max(me.scrollPos - me.itemHeight, 0);
+	else if(scan == K_DOWNARROW)
+		me.scrollPos = min(me.scrollPos + me.itemHeight, me.nItems * me.itemHeight - 1);
+	else
+		return keyDownListBox(me, scan, ascii, shift);
+
+	i = min(me.selectedItem, floor((me.scrollPos + 1) / me.itemHeight - 1));
+	i = max(i, ceil(me.scrollPos / me.itemHeight));
+	me.setSelected(me, i);
+
+	return 1;
+}
+#endif

Added: trunk/data/qcsrc/menu-div0test/nexuiz/dialog_credits.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog_credits.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog_credits.c	2008-01-19 09:09:19 UTC (rev 3182)
@@ -0,0 +1,30 @@
+#ifdef INTERFACE
+CLASS(NexuizCreditsDialog) EXTENDS(NexuizDialog)
+	METHOD(NexuizCreditsDialog, fill, void(entity))
+	METHOD(NexuizCreditsDialog, focusEnter, void(entity))
+	ATTRIB(NexuizCreditsDialog, title, string, "Credits")
+	ATTRIB(NexuizCreditsDialog, color, vector, SKINCOLOR_DIALOG_CREDITS)
+	ATTRIB(NexuizCreditsDialog, intendedWidth, float, 0.5)
+	ATTRIB(NexuizCreditsDialog, rows, float, 20)
+	ATTRIB(NexuizCreditsDialog, columns, float, 2)
+	ATTRIB(NexuizCreditsDialog, creditsList, entity, NULL)
+ENDCLASS(NexuizCreditsDialog)
+#endif
+
+#ifdef IMPLEMENTATION
+void fillNexuizCreditsDialog(entity me)
+{
+	entity e;
+	me.TR(me);
+		me.TD(me, me.rows - 1, me.columns, me.creditsList = makeNexuizCreditsList());
+	me.gotoXY(me, me.rows - 1, 0);
+		me.TD(me, 1, me.columns, e = makeNexuizButton("OK", '0 0 0'));
+			e.onClick = Dialog_Close;
+			e.onClickEntity = me;
+}
+void focusEnterNexuizCreditsDialog(entity me)
+{
+	me.creditsList.scrollPos = 0;
+	me.creditsList.scrolling = time + 1;
+}
+#endif




More information about the nexuiz-commits mailing list