r3812 - in trunk/data: . qcsrc/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Jul 10 17:55:42 EDT 2008


Author: blub0
Date: 2008-07-10 17:55:36 -0400 (Thu, 10 Jul 2008)
New Revision: 3812

Added:
   trunk/data/qcsrc/client/miscfunctions.qc
Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/client/csqc_builtins.qc
   trunk/data/qcsrc/client/main.qh
   trunk/data/qcsrc/client/progs.src
   trunk/data/qcsrc/client/sbar.qc
Log:
add csqc_flags cvar for client compatibility
defaults to 0, flag 1 enables the stringwidth() builtins and the new font for the scoreboard


Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2008-07-10 17:20:16 UTC (rev 3811)
+++ trunk/data/defaultNexuiz.cfg	2008-07-10 21:55:36 UTC (rev 3812)
@@ -1052,3 +1052,6 @@
 set sbar_fontsize 11
 alias sbar_font "loadfont user1 $*; sbar_columns_set"
 sbar_font gfx/vera-sans
+
+// supporting stringwidth
+seta csqc_flags 1

Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2008-07-10 17:20:16 UTC (rev 3811)
+++ trunk/data/qcsrc/client/Main.qc	2008-07-10 21:55:36 UTC (rev 3812)
@@ -21,6 +21,7 @@
 void CSQC_Init(void)
 {
 	float i;
+	CSQC_CheckEngine();
 	drawfont = 0;
 	menu_visible = FALSE;
 	menu_show = menu_show_error;

Modified: trunk/data/qcsrc/client/csqc_builtins.qc
===================================================================
--- trunk/data/qcsrc/client/csqc_builtins.qc	2008-07-10 17:20:16 UTC (rev 3811)
+++ trunk/data/qcsrc/client/csqc_builtins.qc	2008-07-10 21:55:36 UTC (rev 3812)
@@ -97,7 +97,8 @@
 void	drawsetcliparea(float x, float y, float width, float height) = #324;
 void	drawresetcliparea(void) = #325;
 float	drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #326;
-float	stringwidth(string text, float handleColors) = #327;
+float	stringwidth_engine(string text, float handleColors) = #327;
+float	stringwidth(string text, float handleColors);
 float	drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
 
 

Modified: trunk/data/qcsrc/client/main.qh
===================================================================
--- trunk/data/qcsrc/client/main.qh	2008-07-10 17:20:16 UTC (rev 3811)
+++ trunk/data/qcsrc/client/main.qh	2008-07-10 21:55:36 UTC (rev 3812)
@@ -83,3 +83,7 @@
 float sbar_size[MAX_SBAR_FIELDS + 1];
 string sbar_title[MAX_SBAR_FIELDS + 1];
 float sbar_num_fields;
+float sbar_font;
+
+float csqc_flags;
+#define CSQC_FLAG_STRINGWIDTH 1

Added: trunk/data/qcsrc/client/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/client/miscfunctions.qc	                        (rev 0)
+++ trunk/data/qcsrc/client/miscfunctions.qc	2008-07-10 21:55:36 UTC (rev 3812)
@@ -0,0 +1,45 @@
+float stringwidth_oldfont(string text, float handleColors)
+{
+	float i, len, ch, width;
+	len = strlen(text);
+	if(!handleColors)
+		return len;
+	width = 0;
+	for(i = 0; i < len; ++i)
+	{
+		if(substring(text, i, 1) == "^")
+		{
+			ch = str2chr(text, i+1);
+			if(ch >= '0' && ch <= '9')
+				++i;
+			else
+				++width;
+		}
+		else
+			++width;
+	}
+	return width;
+}
+
+void CSQC_CheckEngine()
+{
+	float i, tmp;
+	registercvar("csqc_flags", "0");
+	csqc_flags = cvar("csqc_flags");
+
+	if(csqc_flags & CSQC_FLAG_STRINGWIDTH)
+	{
+		stringwidth = stringwidth_engine;
+		sbar_font = FONT_USER+1;
+	} else {
+		stringwidth = stringwidth_oldfont;
+		sbar_font = FONT_DEFAULT;
+	}
+}
+
+vector Sbar_GetFontsize()
+{
+	if(csqc_flags & CSQC_FLAG_STRINGWIDTH)
+		return stov(cvar_string("sbar_fontsize"));
+	return '8 8' ;
+}

Modified: trunk/data/qcsrc/client/progs.src
===================================================================
--- trunk/data/qcsrc/client/progs.src	2008-07-10 17:20:16 UTC (rev 3811)
+++ trunk/data/qcsrc/client/progs.src	2008-07-10 21:55:36 UTC (rev 3812)
@@ -7,6 +7,7 @@
 
 main.qh
 
+miscfunctions.qc
 sortlist.qc
 teamplay.qc
 

Modified: trunk/data/qcsrc/client/sbar.qc
===================================================================
--- trunk/data/qcsrc/client/sbar.qc	2008-07-10 17:20:16 UTC (rev 3811)
+++ trunk/data/qcsrc/client/sbar.qc	2008-07-10 21:55:36 UTC (rev 3812)
@@ -285,7 +285,7 @@
 	
 	argc = min(MAX_SBAR_FIELDS, argc);
 	sbar_num_fields = 0;
-	drawfont = FONT_USER+1;
+	drawfont = sbar_font;
 	digit = stringwidth("0123456789", FALSE) / 10;
 	for(i = 0; i < argc-1; ++i)
 	{
@@ -519,7 +519,7 @@
 	float center_x;
 	string str;
 
-	sbar_fontsize = stov(cvar_string("sbar_fontsize"));
+	sbar_fontsize = Sbar_GetFontsize();
 	if(sbar_fontsize_x == 0)
 		sbar_fontsize = '8 8 0';
 	if(sbar_fontsize_y == 0)
@@ -544,7 +544,7 @@
 	pos_z = 0;
 
 	// Heading
-	drawfont = FONT_USER+1;
+	drawfont = sbar_font;
 	pos_x = center_x - stringwidth("Scoreboard", TRUE)*0.5*24;
 	drawstring(pos, "Scoreboard", '24 24', '1 1 1', 1, DRAWFLAG_NORMAL);
 	pos_x = xmin;




More information about the nexuiz-commits mailing list