r2896 - in trunk/data/qcsrc/menu-div0test: . item nexuiz

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Nov 3 18:58:55 EDT 2007


Author: div0
Date: 2007-11-03 18:58:54 -0400 (Sat, 03 Nov 2007)
New Revision: 2896

Modified:
   trunk/data/qcsrc/menu-div0test/classes.c
   trunk/data/qcsrc/menu-div0test/item/button.c
   trunk/data/qcsrc/menu-div0test/item/checkbox.c
   trunk/data/qcsrc/menu-div0test/nexuiz/dialog_settings_player.c
   trunk/data/qcsrc/menu-div0test/skin.qh
   trunk/data/qcsrc/menu-div0test/todo
Log:
color buttons; checkbox/button cleanup


Modified: trunk/data/qcsrc/menu-div0test/classes.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/classes.c	2007-11-03 13:43:06 UTC (rev 2895)
+++ trunk/data/qcsrc/menu-div0test/classes.c	2007-11-03 22:58:54 UTC (rev 2896)
@@ -33,3 +33,4 @@
 #include "nexuiz/nexposee.c"
 #include "nexuiz/rootdialog.c"
 #include "nexuiz/textslider.c"
+#include "nexuiz/colorbutton.c"

Modified: trunk/data/qcsrc/menu-div0test/item/button.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/button.c	2007-11-03 13:43:06 UTC (rev 2895)
+++ trunk/data/qcsrc/menu-div0test/item/button.c	2007-11-03 22:58:54 UTC (rev 2896)
@@ -10,8 +10,11 @@
 	METHOD(Button, mouseRelease, float(entity, vector))
 	ATTRIB(Button, onClick, void(entity, entity), SUB_Null)
 	ATTRIB(Button, onClickEntity, entity, NULL)
-	ATTRIB(Button, src, string, "")
-	ATTRIB(Button, srcMulti, float, 1)
+	ATTRIB(Button, src, string, string_null)
+	ATTRIB(Button, srcSuffix, string, "")
+	ATTRIB(Button, src2, string, string_null) // is centered, same aspect, and stretched to label size
+	ATTRIB(Button, srcMulti, float, 1) // 0: button square left, text right; 1: button stretched, text over it
+	ATTRIB(Button, buttonLeftOfText, float, 0)
 	ATTRIB(Button, focusable, float, 1)
 	ATTRIB(Button, pressed, float, 0)
 	ATTRIB(Button, clickTime, float, 0)
@@ -27,13 +30,17 @@
 #ifdef IMPLEMENTATION
 void resizeNotifyButton(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 {
+	if(me.srcMulti)
+		me.keepspaceLeft = 0;
+	else
+		me.keepspaceLeft = min(0.8, absSize_y / absSize_x);
 	resizeNotifyLabel(me, relOrigin, relSize, absOrigin, absSize);
 	me.origin = absOrigin;
 	me.size = absSize;
 }
 void configureButtonButton(entity me, string txt, float sz, string gfx)
 {
-	configureLabelLabel(me, txt, sz, 0.5);
+	configureLabelLabel(me, txt, sz, me.srcMulti ? 0.5 : 0);
 	me.src = gfx;
 }
 float keyDownButton(entity me, float key, float ascii, float shift)
@@ -76,31 +83,54 @@
 }
 void drawButton(entity me)
 {
+	vector bOrigin, bSize;
+
 	me.focusable = !me.disabled;
 	if(me.disabled)
 		draw_alpha *= 0.5;
 
-	if(me.srcMulti)
+	if(me.src)
 	{
-		if(me.disabled)
-			draw_ButtonPicture('0 0 0', strcat(me.src, "_d"), '1 1 0', '1 1 1', 1);
-		else if(me.forcePressed || me.pressed || me.clickTime > 0)
-			draw_ButtonPicture('0 0 0', strcat(me.src, "_c"), '1 1 0', me.color, 1);
-		else if(me.focused)
-			draw_ButtonPicture('0 0 0', strcat(me.src, "_f"), '1 1 0', me.color, 1);
+		if(me.srcMulti)
+		{
+			bOrigin = '0 0 0';
+			bSize = '1 1 0';
+			if(me.disabled)
+				draw_ButtonPicture(bOrigin, strcat(me.src, "_d", me.srcSuffix), bSize, '1 1 1', 1);
+			else if(me.forcePressed || me.pressed || me.clickTime > 0)
+				draw_ButtonPicture(bOrigin, strcat(me.src, "_c", me.srcSuffix), bSize, me.color, 1);
+			else if(me.focused)
+				draw_ButtonPicture(bOrigin, strcat(me.src, "_f", me.srcSuffix), bSize, me.color, 1);
+			else
+				draw_ButtonPicture(bOrigin, strcat(me.src, "_n", me.srcSuffix), bSize, me.color, 1);
+		}
 		else
-			draw_ButtonPicture('0 0 0', strcat(me.src, "_n"), '1 1 0', me.color, 1);
+		{
+			if(me.realFontSize_y == 0)
+			{
+				bOrigin = '0 0 0';
+				bSize = '1 1 0';
+			}
+			else
+			{
+				bOrigin = eY * (0.5 * (1 - me.realFontSize_y)) + eX * (0.5 * (me.keepspaceLeft - me.realFontSize_x));
+				bSize = me.realFontSize;
+			}
+			if(me.disabled)
+				draw_Picture(bOrigin, strcat(me.src, "_d", me.srcSuffix), bSize, '1 1 1', 1);
+			else if(me.forcePressed || me.pressed || me.clickTime > 0)
+				draw_Picture(bOrigin, strcat(me.src, "_c", me.srcSuffix), bSize, me.color, 1);
+			else if(me.focused)
+				draw_Picture(bOrigin, strcat(me.src, "_f", me.srcSuffix), bSize, me.color, 1);
+			else
+				draw_Picture(bOrigin, strcat(me.src, "_n", me.srcSuffix), bSize, me.color, 1);
+		}
 	}
-	else
+	if(me.src2)
 	{
-		if(me.disabled)
-			draw_Picture('0 0 0', strcat(me.src, "_d"), '1 1 0', '1 1 1', 1);
-		else if(me.forcePressed || me.pressed || me.clickTime > 0)
-			draw_Picture('0 0 0', strcat(me.src, "_c"), '1 1 0', me.color, 1);
-		else if(me.focused)
-			draw_Picture('0 0 0', strcat(me.src, "_f"), '1 1 0', me.color, 1);
-		else
-			draw_Picture('0 0 0', strcat(me.src, "_n"), '1 1 0', me.color, 1);
+		bOrigin = me.keepspaceLeft * eX;
+		bSize = eY + eX * (1 - me.keepspaceLeft);
+		draw_Picture(bOrigin, me.src2, bSize, me.color, 1);
 	}
 	drawLabel(me);
 

Modified: trunk/data/qcsrc/menu-div0test/item/checkbox.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/checkbox.c	2007-11-03 13:43:06 UTC (rev 2895)
+++ trunk/data/qcsrc/menu-div0test/item/checkbox.c	2007-11-03 22:58:54 UTC (rev 2896)
@@ -2,10 +2,10 @@
 void CheckBox_Click(entity me, entity other);
 CLASS(CheckBox) EXTENDS(Button)
 	METHOD(CheckBox, configureCheckBox, void(entity, string, float, string))
-	METHOD(CheckBox, resizeNotify, void(entity, vector, vector, vector, vector))
 	METHOD(CheckBox, draw, void(entity))
 	METHOD(CheckBox, toString, string(entity))
 	METHOD(CheckBox, setChecked, void(entity, float))
+	ATTRIB(CheckBox, useDownAsChecked, float, 0)
 	ATTRIB(CheckBox, checked, float, 0)
 	ATTRIB(CheckBox, onClick, void(entity, entity), CheckBox_Click)
 	ATTRIB(CheckBox, srcMulti, float, 0)
@@ -31,55 +31,22 @@
 	me.configureButton(me, txt, sz, gfx);
 	me.align = 0;
 }
-void resizeNotifyCheckBox(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
-{
-	me.keepspaceLeft = min(0.8, absSize_y / absSize_x);
-	resizeNotifyButton(me, relOrigin, relSize, absOrigin, absSize);
-}
 void showNotifyCheckBox(entity me)
 {
 	me.focusable = !me.disabled;
 }
 void drawCheckBox(entity me)
 {
-	vector cbOrigin;
-	vector cbSize;
-
-	me.focusable = !me.disabled;
-	if(me.disabled)
-		draw_alpha *= 0.5;
-
-	cbOrigin = eY * (0.5 * (1 - me.realFontSize_y)) + eX * (0.5 * (me.keepspaceLeft - me.realFontSize_x));
-	cbSize = me.realFontSize;
-	if(me.checked)
+	float s;
+	s = me.pressed;
+	if(me.useDownAsChecked)
 	{
-		if(me.disabled)
-			draw_Picture(cbOrigin, strcat(me.src, "_d1"), cbSize, '1 1 1', 1);
-		else if(me.forcePressed || me.pressed || me.clickTime > 0)
-			draw_Picture(cbOrigin, strcat(me.src, "_c1"), cbSize, '1 1 1', 1);
-		else if(me.focused)
-			draw_Picture(cbOrigin, strcat(me.src, "_f1"), cbSize, '1 1 1', 1);
-		else
-			draw_Picture(cbOrigin, strcat(me.src, "_n1"), cbSize, '1 1 1', 1);
+		me.srcSuffix = "";
+		me.forcePressed = me.checked;
 	}
 	else
-	{
-		if(me.disabled)
-			draw_Picture(cbOrigin, strcat(me.src, "_d0"), cbSize, '1 1 1', 1);
-		else if(me.forcePressed || me.pressed || me.clickTime > 0)
-			draw_Picture(cbOrigin, strcat(me.src, "_c0"), cbSize, '1 1 1', 1);
-		else if(me.focused)
-			draw_Picture(cbOrigin, strcat(me.src, "_f0"), cbSize, '1 1 1', 1);
-		else
-			draw_Picture(cbOrigin, strcat(me.src, "_n0"), cbSize, '1 1 1', 1);
-	}
-	drawLabel(me); // skip drawButton!
-
-	if(me.clickTime > 0 && me.clickTime < frametime)
-	{
-		// keyboard click timer expired? Fire the event then.
-		me.onClick(me, me.onClickEntity);
-	}
-	me.clickTime -= frametime;
+		me.srcSuffix = (me.checked ? "1" : "0");
+	drawButton(me);
+	me.pressed = s;
 }
 #endif

Modified: trunk/data/qcsrc/menu-div0test/nexuiz/dialog_settings_player.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog_settings_player.c	2007-11-03 13:43:06 UTC (rev 2895)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog_settings_player.c	2007-11-03 22:58:54 UTC (rev 2896)
@@ -20,16 +20,19 @@
 void fillNexuizPlayerSettingsTab(entity me)
 {
 	entity e;
+	float i;
 
 	me.TR(me);
 		me.TD(me, 1, 1, e = makeNexuizTextLabel(0, "Player Name:"));
 		me.TD(me, 1, 2, e = makeNexuizResolutionSlider());
 	me.TR(me);
 		me.TD(me, 1, 1, e = makeNexuizTextLabel(0, "Shirt Color:"));
-		me.TD(me, 1, 2, e = makeNexuizResolutionSlider());
+		for(i = 0; i < 15; ++i)
+			me.TD(me, 1, 2 / 15, e = makeNexuizColorButton(1, 0, i));
 	me.TR(me);
 		me.TD(me, 1, 1, e = makeNexuizTextLabel(0, "Pants Color:"));
-		me.TD(me, 1, 2, e = makeNexuizResolutionSlider());
+		for(i = 0; i < 15; ++i)
+			me.TD(me, 1, 2 / 15, e = makeNexuizColorButton(2, 1, i));
 
 	me.gotoXY(me, 0, 3.5); me.setFirstColumn(me, me.currentColumn);
 		me.TD(me, 1, 1, e = makeNexuizTextLabel(0, "Field of View:"));
@@ -68,5 +71,8 @@
 			e.addValue(e, "Simple", "110");
 			e.addValue(e, "Full", "100");
 			e.configureNexuizTextSliderValues(e);
+
+	me.gotoXY(me, me.rows - 1, 0);
+		me.TD(me, 1, me.columns, makeNexuizCommandButton("Apply immediately", '0 0 0', "color -1 -1", COMMANDBUTTON_APPLY));
 }
 #endif

Modified: trunk/data/qcsrc/menu-div0test/skin.qh
===================================================================
--- trunk/data/qcsrc/menu-div0test/skin.qh	2007-11-03 13:43:06 UTC (rev 2895)
+++ trunk/data/qcsrc/menu-div0test/skin.qh	2007-11-03 22:58:54 UTC (rev 2896)
@@ -7,6 +7,8 @@
 const string SKINGFX_SLIDER = "qcsrc/menu-div0test/baseslider";
 const string SKINGFX_CHECKBOX = "qcsrc/menu-div0test/basecheckbox";
 const string SKINGFX_RADIOBUTTON = "qcsrc/menu-div0test/baseradiobutton";
+const string SKINGFX_COLORBUTTON = "qcsrc/menu-div0test/basebutton";
+const string SKINGFX_COLORBUTTON_COLOR = "qcsrc/menu-div0test/color";
 
 const float SKINMARGIN_TOP = 8;
 const float SKINMARGIN_LEFT = 8;

Modified: trunk/data/qcsrc/menu-div0test/todo
===================================================================
--- trunk/data/qcsrc/menu-div0test/todo	2007-11-03 13:43:06 UTC (rev 2895)
+++ trunk/data/qcsrc/menu-div0test/todo	2007-11-03 22:58:54 UTC (rev 2896)
@@ -10,11 +10,10 @@
 TODO listbox (with draw callback and scroll bar)
 DONE value slider
 DONE tabbed dialog
-TODO alternate button drawing (like: "Image Text" as in checkbox, or overlay two images); move that stuff out of CheckBox
-TODO NexuizImageRadioButton (color, crosshair)
+DONE alternate button drawing (like: "Image Text" as in checkbox, or overlay two images); move that stuff out of CheckBox
+DONE NexuizImageRadioButton (color, crosshair)
+DONE "half-automatically" self-sizing dialog (by specifying number of "lines" in advance)
 
-TODO "half-automatically" self-sizing dialog (by specifying number of "lines" in advance)
-
 TODO options dialog:
 	DONE video/effects
 	TODO misc




More information about the nexuiz-commits mailing list