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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Oct 27 02:38:23 EDT 2008


Author: div0
Date: 2008-10-27 02:38:23 -0400 (Mon, 27 Oct 2008)
New Revision: 4901

Modified:
   trunk/data/qcsrc/menu/menu.qc
   trunk/data/qcsrc/menu/nexuiz/skinlist.c
   trunk/data/qcsrc/menu/skin-customizables.inc
Log:
show title and author of each skin


Modified: trunk/data/qcsrc/menu/menu.qc
===================================================================
--- trunk/data/qcsrc/menu/menu.qc	2008-10-26 21:42:18 UTC (rev 4900)
+++ trunk/data/qcsrc/menu/menu.qc	2008-10-27 06:38:23 UTC (rev 4901)
@@ -83,6 +83,11 @@
 	draw_currentSkin = strzone(draw_currentSkin);
 	while((s = fgets(fh)))
 	{
+		// these two are handled by skinlist.qc
+		if(substring(s, 0, 6) == "title ")
+			continue;
+		if(substring(s, 0, 7) == "author ")
+			continue;
 		n = tokenize_sane(s);
 		if(n >= 2)
 			Skin_ApplySetting(argv(0), substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));

Modified: trunk/data/qcsrc/menu/nexuiz/skinlist.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/skinlist.c	2008-10-26 21:42:18 UTC (rev 4900)
+++ trunk/data/qcsrc/menu/nexuiz/skinlist.c	2008-10-27 06:38:23 UTC (rev 4901)
@@ -8,7 +8,7 @@
 	METHOD(NexuizSkinList, setSkin, void(entity))
 	METHOD(NexuizSkinList, loadCvars, void(entity))
 	METHOD(NexuizSkinList, saveCvars, void(entity))
-	METHOD(NexuizSkinList, skinName, string(entity, float))
+	METHOD(NexuizSkinList, skinParameter, string(entity, float, float))
 	METHOD(NexuizSkinList, clickListBoxItem, void(entity, float, vector))
 	METHOD(NexuizSkinList, keyDown, float(entity, float, float, float))
 	METHOD(NexuizSkinList, destroy, void(entity))
@@ -19,7 +19,8 @@
 	ATTRIB(NexuizSkinList, columnPreviewSize, float, 0)
 	ATTRIB(NexuizSkinList, columnNameOrigin, float, 0)
 	ATTRIB(NexuizSkinList, columnNameSize, float, 0)
-	ATTRIB(NexuizSkinList, realUpperMargin, float, 0)	
+	ATTRIB(NexuizSkinList, realUpperMargin1, float, 0)
+	ATTRIB(NexuizSkinList, realUpperMargin2, float, 0)
 	ATTRIB(NexuizSkinList, origin, vector, '0 0 0')
 	ATTRIB(NexuizSkinList, itemAbsSize, vector, '0 0 0')
 
@@ -35,6 +36,12 @@
 
 #ifdef IMPLEMENTATION
 
+#define SKINPARM_NAME 0
+#define SKINPARM_TITLE 1
+#define SKINPARM_AUTHOR 2
+#define SKINPARM_PREVIEW 3
+#define SKINPARM_COUNT 4
+
 entity makeNexuizSkinList()
 {
 	entity me;
@@ -58,7 +65,7 @@
 	n = me.nItems;
 	for(i = 0; i < n; ++i)
 	{
-		if(me.skinName(me, i) == s)
+		if(me.skinParameter(me, i, SKINPARM_NAME) == s)
 		{
 			me.selectedItem = i;
 			break;
@@ -68,21 +75,56 @@
 
 void saveCvarsNexuizSkinList(entity me)
 {
-	cvar_set("menu_skin", me.skinName(me, me.selectedItem));
+	cvar_set("menu_skin", me.skinParameter(me, me.selectedItem, SKINPARM_NAME));
 }
 
-string skinNameNexuizSkinList(entity me, float i)
+string skinParameterNexuizSkinList(entity me, float i, float key)
 {
-	string s;
-	s = search_getfilename(me.skinlist, i);
-	s = substring(s, 9, strlen(s) - 9 - 15);  // gfx/menu/, skinvalues.txt
-	return s;
+	return bufstr_get(me.skinlist, i * SKINPARM_COUNT + key);
 }
 
 void getSkinsNexuizSkinList(entity me)
 {
-	me.skinlist = search_begin("gfx/menu/*/skinvalues.txt", TRUE, TRUE);
-	me.nItems = search_getsize(me.skinlist);
+	float glob, buf, i, n, fh;
+	string s;
+
+	buf = buf_create();
+	glob = search_begin("gfx/menu/*/skinvalues.txt", TRUE, TRUE);
+	if(glob < 0)
+	{
+		me.skinlist = buf;
+		me.nItems = 0;
+		return;
+	}
+
+	n = search_getsize(glob);
+	for(i = 0; i < n; ++i)
+	{
+		s = search_getfilename(glob, i);
+		bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_NAME, substring(s, 9, strlen(s) - 24)); // the * part
+		bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, "<TITLE>");
+		bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_AUTHOR, "<AUTHOR>");
+		bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_PREVIEW, strcat("/gfx/menu/", substring(s, 9, strlen(s) - 24), "/skinpreview"));
+		fh = fopen(s, FILE_READ);
+		if(fh < 0)
+		{
+			print("Warning: can't open skinvalues.txt file\n");
+			continue;
+		}
+		while((s = fgets(fh)))
+		{
+			// these two are handled by skinlist.qc
+			if(substring(s, 0, 6) == "title ")
+				bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, substring(s, 6, strlen(s) - 6));
+			else if(substring(s, 0, 7) == "author ")
+				bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_AUTHOR, substring(s, 7, strlen(s) - 7));
+		}
+	}
+
+	search_end(glob);
+
+	me.skinlist = buf;
+	me.nItems = n;
 }
 
 void destroyNexuizSkinList(entity me)
@@ -98,7 +140,8 @@
 
 	me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize_y * me.itemHeight));
 	me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize_x * (1 - me.controlWidth)));
-	me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
+	me.realUpperMargin1 = 0.5 * (1 - 2.5 * me.realFontSize_y);
+	me.realUpperMargin2 = me.realUpperMargin1 + 1.5 * me.realFontSize_y;
 
 	me.columnPreviewOrigin = 0;
 	me.columnPreviewSize = me.itemAbsSize_y / me.itemAbsSize_x * 4 / 3;
@@ -113,11 +156,17 @@
 	if(isSelected)
 		draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
 		
-	s = me.skinName(me, i);
-	draw_Picture(me.columnPreviewOrigin * eX, strcat("/gfx/menu/", s, "/skinpreview"), me.columnPreviewSize * eX + eY, '1 1 1', 1);
+	s = me.skinParameter(me, i, SKINPARM_PREVIEW);
+	draw_Picture(me.columnPreviewOrigin * eX, s, me.columnPreviewSize * eX + eY, '1 1 1', 1);
 	
+	s = me.skinParameter(me, i, SKINPARM_NAME);
+	s = strcat(s, ": ", me.skinParameter(me, i, SKINPARM_TITLE));
 	s = draw_TextShortenToWidth(s, me.columnNameSize / me.realFontSize_x, 0);
-	draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0) * me.realFontSize_x)) * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+	draw_Text(me.realUpperMargin1 * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0) * me.realFontSize_x)) * eX, s, me.realFontSize, SKINCOLOR_SKINLIST_TITLE, SKINALPHA_TEXT, 0);
+
+	s = me.skinParameter(me, i, SKINPARM_AUTHOR);
+	s = draw_TextShortenToWidth(s, me.columnNameSize / me.realFontSize_x, 0);
+	draw_Text(me.realUpperMargin2 * eY + (me.columnNameOrigin + 1.00 * (me.columnNameSize - draw_TextWidth(s, 0) * me.realFontSize_x)) * eX, s, me.realFontSize, SKINCOLOR_SKINLIST_AUTHOR, SKINALPHA_TEXT, 0);
 }
 
 void setSkinNexuizSkinList(entity me)

Modified: trunk/data/qcsrc/menu/skin-customizables.inc
===================================================================
--- trunk/data/qcsrc/menu/skin-customizables.inc	2008-10-26 21:42:18 UTC (rev 4900)
+++ trunk/data/qcsrc/menu/skin-customizables.inc	2008-10-27 06:38:23 UTC (rev 4901)
@@ -1,5 +1,8 @@
 #if 0
 "Perl code to convert this to a skinvalues.txt file.";
+print "title <TITLE>\n";
+print "author <AUTHOR>\n";
+print "\n";
 while(<DATA>)
 {
 	chomp;
@@ -188,6 +191,10 @@
 	SKINFLOAT(ALPHA_SERVERLIST_FAVORITE, 0.8);
 	SKINVECTOR(COLOR_SERVERLIST_FAVORITE, '1 1 1');
 
+	// item: skin list
+	SKINVECTOR(COLOR_SKINLIST_TITLE, '1 1 1');
+	SKINVECTOR(COLOR_SKINLIST_AUTHOR, '0.4 0.4 0.7');
+
 	// item: slider
 	SKINSTRING(GFX_SLIDER, "slider");
 	SKINVECTOR(COLOR_SLIDER_N, '1 1 1');




More information about the nexuiz-commits mailing list