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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Oct 27 18:44:24 EDT 2007


Author: div0
Date: 2007-10-27 18:44:23 -0400 (Sat, 27 Oct 2007)
New Revision: 2859

Added:
   trunk/data/qcsrc/menu-div0test/basebuttongray_c.tga
   trunk/data/qcsrc/menu-div0test/basebuttongray_f.tga
   trunk/data/qcsrc/menu-div0test/basebuttongray_n.tga
   trunk/data/qcsrc/menu-div0test/item/slider.c
   trunk/data/qcsrc/menu-div0test/nexuiz/commandbutton.c
   trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c
   trunk/data/qcsrc/menu-div0test/nexuiz/dialog_teamselect.c
   trunk/data/qcsrc/menu-div0test/skin.qh
Modified:
   trunk/data/qcsrc/menu-div0test/classes.c
   trunk/data/qcsrc/menu-div0test/draw.qc
   trunk/data/qcsrc/menu-div0test/gamecommand.qc
   trunk/data/qcsrc/menu-div0test/item/borderimage.c
   trunk/data/qcsrc/menu-div0test/item/container.c
   trunk/data/qcsrc/menu-div0test/item/inputcontainer.c
   trunk/data/qcsrc/menu-div0test/item/modalcontroller.c
   trunk/data/qcsrc/menu-div0test/item/nexposee.c
   trunk/data/qcsrc/menu-div0test/item/radiobutton.c
   trunk/data/qcsrc/menu-div0test/menu.qc
   trunk/data/qcsrc/menu-div0test/menu.qh
   trunk/data/qcsrc/menu-div0test/nexuiz/mainwindow.c
   trunk/data/qcsrc/menu-div0test/progs.src
   trunk/data/qcsrc/menu-div0test/todo
Log:
first attempt at teamselect dialog... not good yet (need a better way to implement a size calculator)


Added: trunk/data/qcsrc/menu-div0test/basebuttongray_c.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basebuttongray_c.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/basebuttongray_f.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basebuttongray_f.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/data/qcsrc/menu-div0test/basebuttongray_n.tga
===================================================================
(Binary files differ)


Property changes on: trunk/data/qcsrc/menu-div0test/basebuttongray_n.tga
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/data/qcsrc/menu-div0test/classes.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/classes.c	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/classes.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -10,4 +10,7 @@
 #include "item/radiobutton.c"
 #include "item/borderimage.c"
 #include "item/slider.c"
+#include "nexuiz/dialog.c"
 #include "nexuiz/mainwindow.c"
+#include "nexuiz/commandbutton.c"
+#include "nexuiz/dialog_teamselect.c"

Modified: trunk/data/qcsrc/menu-div0test/draw.qc
===================================================================
--- trunk/data/qcsrc/menu-div0test/draw.qc	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/draw.qc	2007-10-27 22:44:23 UTC (rev 2859)
@@ -158,6 +158,8 @@
 }
 void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha)
 {
+	if(theSize_x <= 0 || theSize_y <= 0)
+		error("Drawing zero size text?\n");
 	drawstring(boxToGlobal(theOrigin, draw_shift, draw_scale), theText, boxToGlobalSize(theSize, draw_scale), theColor, theAlpha * draw_alpha, 0);
 }
 

Modified: trunk/data/qcsrc/menu-div0test/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/menu-div0test/gamecommand.qc	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/gamecommand.qc	2007-10-27 22:44:23 UTC (rev 2859)
@@ -1,24 +1,24 @@
 void GameCommand_Init()
 {
-	// make gg call menu QC commands
+	// make gg call menu QC theCommands
 	localcmd("alias qc_cmd \"menu_cmd $*\"\n");
 }
 
-void GameCommand(string command)
+void GameCommand(string theCommand)
 {
 	float argc;
-	argc = tokenize(command);
+	argc = tokenize(theCommand);
 
 	if(argv(0) == "help" || argc == 0)
 	{
-		print("Usage: menu_cmd COMMAND..., where possible commands are:\n");
+		print("Usage: menu_cmd theCommand..., where possible theCommands are:\n");
 		print("  sync - reloads all cvars on the current menu page\n");
 		print("  directmenu ITEM - select a menu item as main item\n");
 		GameCommand_Generic("help");
 		return;
 	}
 
-	if(GameCommand_Generic(command))
+	if(GameCommand_Generic(theCommand))
 		return;
 
 	if(argv(0) == "sync")
@@ -30,8 +30,9 @@
 	if(argv(0) == "directmenu") if(argc == 2)
 	{
 		// switch to a menu item
+		m_goto(argv(1));
 		return;
 	}
 
-	print("Invalid command. For a list of supported commands, try menu_cmd help.\n");
+	print("Invalid theCommand. For a list of supported theCommands, try menu_cmd help.\n");
 }

Modified: trunk/data/qcsrc/menu-div0test/item/borderimage.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/borderimage.c	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/item/borderimage.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -25,9 +25,9 @@
 		me.closeButton.color = me.color;
 	}
 }
-void configureBorderImageBorderImage(entity me, string title, float sz, vector theColor, string path, float theBorderHeight)
+void configureBorderImageBorderImage(entity me, string theTitle, float sz, vector theColor, string path, float theBorderHeight)
 {
-	me.configureLabel(me, title, sz, 0.5);
+	me.configureLabel(me, theTitle, sz, 0.5);
 	me.src = path;
 	me.color = theColor;
 	me.borderHeight = theBorderHeight;

Modified: trunk/data/qcsrc/menu-div0test/item/container.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/container.c	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/item/container.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -11,6 +11,7 @@
 	METHOD(Container, resizeNotify, void(entity, vector, vector, vector, vector))
 	METHOD(Container, resizeNotifyLie, void(entity, vector, vector, vector, vector, .vector, .vector))
 	METHOD(Container, addItem, void(entity, entity, vector, vector, float))
+	METHOD(Container, moveItemAfter, void(entity, entity, entity))
 	METHOD(Container, removeItem, void(entity, entity))
 	METHOD(Container, setFocus, void(entity, entity))
 	METHOD(Container, itemFromPoint, entity(entity, vector))
@@ -25,14 +26,14 @@
 .vector Container_origin;
 .vector Container_size;
 .float Container_alpha;
-.entity Container_nextSibling;
-.entity Container_prevSibling;
+.entity nextSibling;
+.entity prevSibling;
 
 void resizeNotifyLieContainer(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize, .vector originField, .vector sizeField)
 {
 	entity e;
 	vector o, s;
-	for(e = me.lastChild; e; e = e.Container_prevSibling)
+	for(e = me.lastChild; e; e = e.prevSibling)
 	{
 		o = e.originField;
 		s = e.sizeField;
@@ -50,7 +51,7 @@
 {
 	entity e;
 	vector o, s;
-	for(e = me.lastChild; e; e = e.Container_prevSibling)
+	for(e = me.lastChild; e; e = e.prevSibling)
 	{
 		o = e.Container_origin;
 		s = e.Container_size;
@@ -74,7 +75,7 @@
 	oldscale = draw_scale;
 	oldalpha = draw_alpha;
 	me.focusable = 0;
-	for(e = me.firstChild; e; e = e.Container_nextSibling)
+	for(e = me.firstChild; e; e = e.nextSibling)
 	{
 		if(e.focusable)
 			me.focusable += 1;
@@ -164,12 +165,12 @@
 	l = me.lastChild;
 
 	if(l)
-		l.Container_nextSibling = other;
+		l.nextSibling = other;
 	else
 		me.firstChild = other;
 
-	other.Container_prevSibling = l;
-	other.Container_nextSibling = NULL;
+	other.prevSibling = l;
+	other.nextSibling = NULL;
 	me.lastChild = other;
 
 	draw_NeedResizeNotify = 1;
@@ -188,16 +189,16 @@
 	entity n, p, f, l;
 	f = me.firstChild;
 	l = me.lastChild;
-	n = other.Container_nextSibling;
-	p = other.Container_prevSibling;
+	n = other.nextSibling;
+	p = other.prevSibling;
 
 	if(p)
-		p.Container_nextSibling = n;
+		p.nextSibling = n;
 	else
 		me.firstChild = n;
 
 	if(n)
-		n.Container_prevSibling = p;
+		n.prevSibling = p;
 	else
 		me.lastChild = p;
 }
@@ -222,4 +223,45 @@
 	}
 	me.focusedChild = other;
 }
+
+void moveItemAfterContainer(entity me, entity other, entity dest)
+{
+	// first: remove other from the chain
+	entity n, p, f, l;
+
+	if(other.parent != me)
+		error("Can't move in wrong container!");
+
+	f = me.firstChild;
+	l = me.lastChild;
+	n = other.nextSibling;
+	p = other.prevSibling;
+
+	if(p)
+		p.nextSibling = n;
+	else
+		me.firstChild = n;
+
+	if(n)
+		n.prevSibling = p;
+	else
+		me.lastChild = p;
+	
+	// now other got removed. Insert it behind dest now.
+	other.prevSibling = dest;
+	if(dest)
+		other.nextSibling = dest.nextSibling;
+	else
+		other.nextSibling = me.firstChild;
+
+	if(dest)
+		dest.nextSibling = other;
+	else
+		me.firstChild = other;
+
+	if(other.nextSibling)
+		other.nextSibling.prevSibling = other;
+	else
+		me.lastChild = other;
+}
 #endif

Modified: trunk/data/qcsrc/menu-div0test/item/inputcontainer.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/inputcontainer.c	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/item/inputcontainer.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -52,7 +52,7 @@
 		{
 			if(f)
 			{
-				for(ff = f.Container_prevSibling; ff; ff = ff.Container_prevSibling)
+				for(ff = f.prevSibling; ff; ff = ff.prevSibling)
 				{
 					if(!ff.focusable)
 						continue;
@@ -62,7 +62,7 @@
 			}
 			if(!f || me.isTabRoot)
 			{
-				for(ff = me.lastChild; ff; ff = ff.Container_prevSibling)
+				for(ff = me.lastChild; ff; ff = ff.prevSibling)
 				{
 					if(!ff.focusable)
 						continue;
@@ -76,7 +76,7 @@
 		{
 			if(f)
 			{
-				for(ff = f.Container_nextSibling; ff; ff = ff.Container_nextSibling)
+				for(ff = f.nextSibling; ff; ff = ff.nextSibling)
 				{
 					if(!ff.focusable)
 						continue;
@@ -86,7 +86,7 @@
 			}
 			if(!f || me.isTabRoot)
 			{
-				for(ff = me.firstChild; ff; ff = ff.Container_nextSibling)
+				for(ff = me.firstChild; ff; ff = ff.nextSibling)
 				{
 					if(!ff.focusable)
 						continue;

Modified: trunk/data/qcsrc/menu-div0test/item/modalcontroller.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/modalcontroller.c	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/item/modalcontroller.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -137,7 +137,7 @@
 	vector targetOrigin, targetSize; float targetAlpha;
 	animating = 0;
 
-	for(e = me.firstChild; e; e = e.Container_nextSibling)
+	for(e = me.firstChild; e; e = e.nextSibling)
 		if(e.ModalController_state)
 		{
 			if(front)
@@ -149,7 +149,7 @@
 
 	df = frametime * 3; // animation speed
 
-	for(e = me.firstChild; e; e = e.Container_nextSibling)
+	for(e = me.firstChild; e; e = e.nextSibling)
 	{
 		f = (e.ModalController_factor = min(1, e.ModalController_factor + df));
 		if(e.ModalController_state)
@@ -255,7 +255,7 @@
 void hideAllModalController(entity me, float skipAnimation)
 {
 	entity e;
-	for(e = me.firstChild; e; e = e.Container_nextSibling)
+	for(e = me.firstChild; e; e = e.nextSibling)
 		me.hideChild(me, e, skipAnimation);
 }
 

Modified: trunk/data/qcsrc/menu-div0test/item/nexposee.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/nexposee.c	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/item/nexposee.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -66,17 +66,17 @@
 	
 	for(scale = 0.7;; scale *= 0.9)
 	{
-		for(e = me.firstChild; e; e = e.Container_nextSibling)
+		for(e = me.firstChild; e; e = e.nextSibling)
 		{
 			e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
 			e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
 		}
 
-		for(e = me.firstChild; e; e = e.Container_nextSibling)
+		for(e = me.firstChild; e; e = e.nextSibling)
 		{
 			emins = e.Nexposee_smallOrigin;
 			emaxs = emins + e.Nexposee_smallSize;
-			for(e2 = e.Container_nextSibling; e2; e2 = e2.Container_nextSibling)
+			for(e2 = e.nextSibling; e2; e2 = e2.nextSibling)
 			{
 				e2mins = e2.Nexposee_smallOrigin;
 				e2maxs = e2mins + e2.Nexposee_smallSize;
@@ -99,7 +99,7 @@
 	}
 
 	scale *= 0.9;
-	for(e = me.firstChild; e; e = e.Container_nextSibling)
+	for(e = me.firstChild; e; e = e.nextSibling)
 	{
 		e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
 		e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
@@ -157,7 +157,7 @@
 	}
 
 	f = min(1, frametime * 10);
-	for(e = me.firstChild; e; e = e.Container_nextSibling)
+	for(e = me.firstChild; e; e = e.nextSibling)
 	{
 		float a;
 		float a0;
@@ -261,14 +261,14 @@
 			if(shift & S_SHIFT)
 			{
 				if(me.selectedChild)
-					me.selectedChild = me.selectedChild.Container_prevSibling;
+					me.selectedChild = me.selectedChild.prevSibling;
 				if(!me.selectedChild)
 					me.selectedChild = me.lastChild;
 			}
 			else
 			{
 				if(me.selectedChild)
-					me.selectedChild = me.selectedChild.Container_nextSibling;
+					me.selectedChild = me.selectedChild.nextSibling;
 				if(!me.selectedChild)
 					me.selectedChild = me.firstChild;
 			}

Modified: trunk/data/qcsrc/menu-div0test/item/radiobutton.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/radiobutton.c	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/item/radiobutton.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -27,7 +27,7 @@
 	else
 	{
 		entity e;
-		for(e = me.parent.firstChild; e; e = e.Container_nextSibling)
+		for(e = me.parent.firstChild; e; e = e.nextSibling)
 			if(e != me)
 				if(e.group == me.group)
 					e.checked = 0;

Added: trunk/data/qcsrc/menu-div0test/item/slider.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/slider.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/item/slider.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -0,0 +1,142 @@
+#ifdef INTERFACE
+CLASS(Slider) EXTENDS(Label)
+	METHOD(Slider, resizeNotify, void(entity, vector, vector, vector, vector))
+	METHOD(Slider, configureSliderVisuals, void(entity, string, string, float, float, string))
+	METHOD(Slider, configureSliderValues, void(entity, float, float, float, float, float, float))
+	METHOD(Slider, draw, void(entity))
+	METHOD(Slider, keyDown, float(entity, float, float, float))
+	METHOD(Slider, mousePress, float(entity, vector))
+	METHOD(Slider, mouseDrag, float(entity, vector))
+	METHOD(Slider, mouseRelease, float(entity, vector))
+	ATTRIB(Slider, src, string, "")
+	ATTRIB(Slider, focusable, float, 1)
+	ATTRIB(Slider, value, float, 0)
+	ATTRIB(Slider, valueMin, float, 0)
+	ATTRIB(Slider, valueMax, float, 0)
+	ATTRIB(Slider, valueStep, float, 0)
+	ATTRIB(Slider, valueKeyStep, float, 0)
+	ATTRIB(Slider, valuePageStep, float, 0)
+	ATTRIB(Slider, valueSpace, float, 0)
+	ATTRIB(Slider, controlWidth, float, 0)
+	ATTRIB(Slider, pressed, float, 0)
+	ATTRIB(Slider, pressOffset, float, 0)
+	ATTRIB(Slider, prefix, string, "")
+	ATTRIB(Slider, suffix, string, "")
+	ATTRIB(Slider, previousValue, float, 0)
+ENDCLASS(Slider)
+#endif
+
+#ifdef IMPLEMENTATION
+void resizeNotifySlider(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+	resizeNotifyLabel(me, relOrigin, relSize, absOrigin, absSize);
+	me.controlWidth = absSize_y / absSize_x;
+}
+void configureSliderVisualsSlider(entity me, string thePrefix, string theSuffix, float sz, float theValueSpace, string gfx)
+{
+	configureLabelLabel(me, "", sz, 1);
+	me.prefix = thePrefix;
+	me.suffix = theSuffix;
+	me.valueSpace = theValueSpace;
+	me.src = gfx;
+}
+void configureSliderValuesSlider(entity me, float theValueMin, float theValue, float theValueMax, float theValueStep, float theValueKeyStep, float theValuePageStep)
+{
+	me.value = theValue;
+	me.valueStep = theValueStep;
+	me.valueMin = theValueMin;
+	me.valueMax = theValueMax;
+	me.valueKeyStep = theValueKeyStep;
+	me.valuePageStep = theValuePageStep;
+}
+float keyDownSlider(entity me, float key, float ascii, float shift)
+{
+	if(key == K_LEFTARROW)
+	{
+		me.value = bound(me.valueMin, me.value - me.valueKeyStep, me.valueMax);
+		return 1;
+	}
+	if(key == K_RIGHTARROW)
+	{
+		me.value = bound(me.valueMin, me.value + me.valueKeyStep, me.valueMax);
+		return 1;
+	}
+	if(key == K_PGUP)
+	{
+		me.value = bound(me.valueMin, me.value - me.valuePageStep, me.valueMax);
+		return 1;
+	}
+	if(key == K_PGDN)
+	{
+		me.value = bound(me.valueMin, me.value + me.valuePageStep, me.valueMax);
+		return 1;
+	}
+	// TODO more keys
+	return 0;
+}
+float mouseDragSlider(entity me, vector pos)
+{
+	float hit;
+	if(me.pressed)
+	{
+		hit = 1;
+		if(pos_x < 0) hit = 0;
+		if(pos_y < 0) hit = 0;
+		if(pos_x >= 1 - me.valueSpace) hit = 0;
+		if(pos_y >= 1) hit = 0;
+		if(hit)
+		{
+			me.value = bound(0, (pos_x - me.pressOffset - 0.5 * me.controlWidth) / (1 - me.valueSpace - me.controlWidth), 1) * (me.valueMax - me.valueMin) + me.valueMin;
+			if(me.valueStep)
+				me.value = floor(0.5 + me.value / me.valueStep) * me.valueStep;
+		}
+		else
+			me.value = me.previousValue;
+	}
+	return 1;
+}
+float mousePressSlider(entity me, vector pos)
+{
+	float controlCenter;
+	if(pos_x < 0) return 0;
+	if(pos_y < 0) return 0;
+	if(pos_x >= 1 - me.valueSpace) return 0;
+	if(pos_y < 0) return 0;
+	controlCenter = (me.value - me.valueMin) / (me.valueMax - me.valueMin) * (1 - me.valueSpace - me.controlWidth) + 0.5 * me.controlWidth;
+	if(fabs(pos_x - controlCenter) <= 0.5 * me.controlWidth)
+	{
+		me.pressed = 1;
+		me.pressOffset = pos_x - controlCenter;
+		me.previousValue = me.value;
+		me.mouseDrag(me, pos);
+	}
+	else
+	{
+		if(pos_x < controlCenter)
+			me.keyDown(me, K_PGUP, 0, 0);
+		else
+			me.keyDown(me, K_PGDN, 0, 0);
+	}
+	return 1;
+}
+float mouseReleaseSlider(entity me, vector pos)
+{
+	me.pressed = 0;
+	return 1;
+}
+void drawSlider(entity me)
+{
+	float controlLeft;
+	controlLeft = (me.value - me.valueMin) / (me.valueMax - me.valueMin) * (1 - me.valueSpace - me.controlWidth);
+	draw_ButtonPicture('0 0 0', strcat(me.src, "_s"), eX * (1 - me.valueSpace) + eY, '1 1 1', 1);
+	if(me.pressed)
+		draw_Picture(eX * controlLeft, strcat(me.src, "_c"), eX * me.controlWidth + eY, '1 1 1', 1);
+	else if(me.focused)
+		draw_Picture(eX * controlLeft, strcat(me.src, "_f"), eX * me.controlWidth + eY, '1 1 1', 1);
+	else
+		draw_Picture(eX * controlLeft, strcat(me.src, "_n"), eX * me.controlWidth + eY, '1 1 1', 1);
+	me.setText(me, strcat(me.prefix, ftos(me.value), me.suffix));
+	drawLabel(me);
+	me.text = ""; // TEMPSTRING!
+}
+#endif

Modified: trunk/data/qcsrc/menu-div0test/menu.qc
===================================================================
--- trunk/data/qcsrc/menu-div0test/menu.qc	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/menu.qc	2007-10-27 22:44:23 UTC (rev 2859)
@@ -5,12 +5,12 @@
 // AK contains all menu functions (especially the required ones)
 ///////////////////////////////////////////////
 
-entity main;
 float mouseButtonsPressed;
-vector mousePos;
-float shiftState;
-float prevTime;
+vector menuMousePos;
+float menuShiftState;
+float menuPrevTime;
 float menuAlpha;
+float prevMenuAlpha;
 
 void SUB_Null() { };
 
@@ -25,7 +25,7 @@
 	draw_reset();
 	main.resizeNotify(main, draw_shift, draw_scale, draw_shift, draw_scale);
 	main.focused = 1;
-	shiftState = 0;
+	menuShiftState = 0;
 };
 
 void(float key, float ascii) m_keyup =
@@ -33,21 +33,21 @@
 	if(!Menu_Active)
 		return;
 	draw_reset();
-	main.keyUp(main, key, ascii, shiftState);
+	main.keyUp(main, key, ascii, menuShiftState);
 	if(key >= K_MOUSE1 && key <= K_MOUSE10)
 	{
 		--mouseButtonsPressed;
 		if(!mouseButtonsPressed)
-			main.mouseRelease(main, mousePos);
+			main.mouseRelease(main, menuMousePos);
 		if(mouseButtonsPressed < 0)
 		{
 			mouseButtonsPressed = 0;
 			print("Warning: released an already released button\n");
 		}
 	}
-	if(key == K_ALT) shiftState -= (shiftState & S_ALT);
-	if(key == K_CTRL) shiftState -= (shiftState & S_CTRL);
-	if(key == K_SHIFT) shiftState -= (shiftState & S_SHIFT);
+	if(key == K_ALT) menuShiftState -= (menuShiftState & S_ALT);
+	if(key == K_CTRL) menuShiftState -= (menuShiftState & S_CTRL);
+	if(key == K_SHIFT) menuShiftState -= (menuShiftState & S_SHIFT);
 };
 
 void(float key, float ascii) m_keydown =
@@ -64,13 +64,13 @@
 	else
 	{
 		draw_reset();
-		if(!main.keyDown(main, key, ascii, shiftState))
+		if(!main.keyDown(main, key, ascii, menuShiftState))
 			if(key == K_ESCAPE)
 				if(gamestatus & (GAME_ISSERVER | GAME_CONNECTED)) // don't back out to console only
 					m_hide(); // disable menu on unhandled ESC
 		if(key >= K_MOUSE1 && key <= K_MOUSE10)
 			if(!mouseButtonsPressed)
-				main.mousePress(main, mousePos);
+				main.mousePress(main, menuMousePos);
 	}
 	if(key >= K_MOUSE1 && key <= K_MOUSE10)
 	{
@@ -81,9 +81,9 @@
 			print("Warning: pressed an already pressed button\n");
 		}
 	}
-	if(key == K_ALT) shiftState |= S_ALT;
-	if(key == K_CTRL) shiftState |= S_CTRL;
-	if(key == K_SHIFT) shiftState |= S_SHIFT;
+	if(key == K_ALT) menuShiftState |= S_ALT;
+	if(key == K_CTRL) menuShiftState |= S_CTRL;
+	if(key == K_SHIFT) menuShiftState |= S_SHIFT;
 };
 
 void() m_draw =
@@ -91,19 +91,24 @@
 	float t;
 	float realFrametime;
 	t = gettime();
-	realFrametime = frametime = min(0.2, t - prevTime);
-	prevTime = t;
+	realFrametime = frametime = min(0.2, t - menuPrevTime);
+	menuPrevTime = t;
 
 	if(cvar("cl_capturevideo"))
 		frametime = 1 / cvar("cl_capturevideo_fps"); // make capturevideo work smoothly
 
+	prevMenuAlpha = menuAlpha;
 	if(Menu_Active)
 		menuAlpha = min(1, menuAlpha + frametime * 5);
 	else
 		menuAlpha = max(0, menuAlpha - frametime * 5);
 
 	if(menuAlpha <= 0)
+	{
+		if(prevMenuAlpha > 0)
+			main.initializeDialog(main, main.firstChild);
 		return;
+	}
 
 	dprint_load();
 	gamestatus = 0;
@@ -123,16 +128,16 @@
 	if(dMouse != '0 0 0')
 	{
 		dMouse = globalToBoxSize(dMouse, draw_scale);
-		mousePos += dMouse * 1; // TODO use a cvar here
-		mousePos_x = bound(0, mousePos_x, 1);
-		mousePos_y = bound(0, mousePos_y, 1);
+		menuMousePos += dMouse * 1; // TODO use a cvar here
+		menuMousePos_x = bound(0, menuMousePos_x, 1);
+		menuMousePos_y = bound(0, menuMousePos_y, 1);
 		if(mouseButtonsPressed)
-			main.mouseDrag(main, mousePos);
+			main.mouseDrag(main, menuMousePos);
 		else
-			main.mouseMove(main, mousePos);
+			main.mouseMove(main, menuMousePos);
 	}
 	main.draw(main);
-	draw_drawMousePointer(mousePos);
+	draw_drawMousePointer(menuMousePos);
 };
 
 void() m_display =
@@ -165,3 +170,21 @@
 {
 	m_hide();
 };
+
+void(string itemname) m_goto =
+{
+	entity e;
+	if(itemname == "")
+	{
+		m_hide();
+	}
+	else
+	{
+		e = findstring(NULL, name, itemname);
+		if(e && e.parent == main)
+		{
+			main.initializeDialog(main, e);
+			m_display();
+		}
+	}
+}

Modified: trunk/data/qcsrc/menu-div0test/menu.qh
===================================================================
--- trunk/data/qcsrc/menu-div0test/menu.qh	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/menu.qh	2007-10-27 22:44:23 UTC (rev 2859)
@@ -23,5 +23,11 @@
 
 float frametime;
 
+entity main;
+void m_hide();
+void m_display();
+void m_goto(string name);
+.string name;
+
 entity keyGrabber;
 .void(entity me, float key, float ascii) keyGrabbed;

Added: trunk/data/qcsrc/menu-div0test/nexuiz/commandbutton.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/commandbutton.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/commandbutton.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -0,0 +1,35 @@
+#ifdef INTERFACE
+CLASS(CommandButton) EXTENDS(Button)
+	METHOD(CommandButton, configureCommandButton, void(entity, string, vector, string, float))
+	ATTRIB(CommandButton, onClickCommand, string, "")
+	ATTRIB(CommandButton, closes, float, 0)
+ENDCLASS(CommandButton)
+#endif
+
+#ifdef IMPLEMENTATION
+void CommandButton_Click(entity me, entity other)
+{
+	cmd("\n", me.onClickCommand, "\n");
+	if(me.closes)
+	{
+		m_goto("");
+	}
+}
+
+void configureCommandButtonCommandButton(entity me, string theText, vector theColor, string theCommand, float closesMenu)
+{
+	if(theColor == '0 0 0')
+	{
+		me.configureButton(me, theText, SKINFONTSIZE_NORMAL, SKINGFX_BUTTON);
+	}
+	else
+	{
+		me.configureButton(me, theText, SKINFONTSIZE_NORMAL, SKINGFX_BUTTON_GRAY);
+		me.color = theColor;
+	}
+	me.onClickCommand = theCommand;
+	me.closes = closesMenu;
+	me.onClick = CommandButton_Click;
+	me.onClickEntity = me;
+}
+#endif

Added: trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -0,0 +1,104 @@
+#ifdef INTERFACE
+CLASS(Dialog) EXTENDS(InputContainer)
+	METHOD(Dialog, configureDialog, void(entity)) // no runtime configuration, all parameters are given in the code!
+	METHOD(Dialog, fill, void(entity)) // to be overridden by user to fill the dialog with controls
+	METHOD(Dialog, keyDown, float(entity, float, float, float))
+	METHOD(Dialog, close, void(entity))
+	METHOD(Dialog, addItemSimple, void(entity, float, float, float, entity))
+	ATTRIB(Dialog, isTabRoot, float, 1)
+	ATTRIB(Dialog, closeButton, entity, NULL)
+	ATTRIB(Dialog, firstLine, float, 0)
+	ATTRIB(Dialog, lineSpacing, float, 0)
+	ATTRIB(Dialog, firstColumn, float, 0)
+	ATTRIB(Dialog, columnWidth, float, 0)
+	ATTRIB(Dialog, lineHeight, float, 0)
+
+	// to be customized
+	ATTRIB(Dialog, closable, float, 1)
+	ATTRIB(Dialog, rootDialog, float, 1)
+	ATTRIB(Dialog, title, string, "Form1") // ;)
+	ATTRIB(Dialog, color, vector, '1 0.5 1')
+	ATTRIB(Dialog, intendedWidth, float, 0.96)
+	ATTRIB(Dialog, intendedHeight, float, 0.96)
+	ATTRIB(Dialog, lines, float, 5)
+ENDCLASS(Dialog)
+#endif
+
+#ifdef IMPLEMENTATION
+void Dialog_Close(entity button, entity me)
+{
+	me.close(me);
+}
+
+void fillDialog(entity me)
+{
+}
+
+void addItemSimpleDialog(entity me, float line, float col, float cols, entity e)
+{
+	me.addItem(me, e, (me.firstLine + (line - 1) * me.lineSpacing) * eY + (me.firstColumn + (col - 1) / cols * me.columnWidth) * eX, me.lineHeight * eY + me.columnWidth / cols * eX, 1);
+}
+
+void configureDialogDialog(entity me)
+{
+	entity frame, closebutton;
+	float ch, cw;
+
+	frame = spawnBorderImage();
+	frame.configureBorderImage(frame, me.title, SKINFONTSIZE_TITLE, me.color, SKINGFX_DIALOGBORDER, SKINHEIGHT_TITLE);
+	me.addItem(me, frame, '0 0 0', '1 1 0', 1);
+
+	ch = me.intendedHeight * cvar("vid_conheight");
+	cw = me.intendedWidth * cvar("vid_conwidth");
+
+	me.firstLine = (SKINFONTSIZE_TITLE * SKINHEIGHT_TITLE + SKINMARGIN_TOP) / ch;
+	me.lineSpacing = SKINFONTSIZE_NORMAL * SKINHEIGHT_NORMAL_WITHSPACING / ch;
+	me.lineHeight = SKINFONTSIZE_NORMAL * SKINHEIGHT_NORMAL/ ch;
+	me.firstColumn = SKINMARGIN_LEFT / cw;
+	me.columnWidth = 1 - 2 * SKINMARGIN_LEFT / cw;
+
+	me.lines = (1 - SKINMARGIN_TOP / ch - me.firstLine + me.lineSpacing - me.lineHeight) / me.lineSpacing;
+
+	me.fill(me);
+
+	if(me.closable)
+	{
+		closebutton = me.closeButton = spawnButton();
+		closebutton.configureButton(closebutton, "", 12, SKINGFX_CLOSEBUTTON);
+		closebutton.onClick = Dialog_Close; closebutton.onClickEntity = me;
+		closebutton.srcMulti = 0;
+		me.addItem(me, closebutton, '0 0 0', '1 1 0', 1); // put it as LAST
+	}
+
+	frame.closeButton = closebutton;
+}
+
+void closeDialog(entity me)
+{
+	if(me.parent.instanceOfNexposee)
+	{
+		ExposeeCloseButton_Click(me, me.parent);
+	}
+	else if(me.parent.instanceOfModalController)
+	{
+		DialogCloseButton_Click(me, me);
+	}
+	if(me.rootDialog)
+	{
+		m_goto("");
+	}
+}
+
+float keyDownDialog(entity me, float key, float ascii, float shift)
+{
+	if(me.closable)
+	{
+		if(key == K_ESCAPE)
+		{
+			me.close(me);
+			return 1;
+		}
+	}
+	return keyDownInputContainer(me, key, ascii, shift);
+}
+#endif

Added: trunk/data/qcsrc/menu-div0test/nexuiz/dialog_teamselect.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog_teamselect.c	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog_teamselect.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -0,0 +1,37 @@
+#ifdef INTERFACE
+CLASS(TeamSelectDialog) EXTENDS(Dialog)
+	METHOD(TeamSelectDialog, fill, void(entity)) // to be overridden by user to fill the dialog with controls
+	ATTRIB(TeamSelectDialog, closable, float, 1)
+	ATTRIB(TeamSelectDialog, title, string, "Team selection") // ;)
+	ATTRIB(TeamSelectDialog, color, vector, '1 1 1')
+	ATTRIB(TeamSelectDialog, intendedWidth, float, 0.6)
+	ATTRIB(TeamSelectDialog, intendedHeight, float, 0.15)
+	ATTRIB(TeamSelectDialog, name, string, "TeamSelect")
+ENDCLASS(TeamSelectDialog)
+#endif
+
+#ifdef IMPLEMENTATION
+void fillTeamSelectDialog(entity me)
+{
+	entity e;
+
+	e = spawnCommandButton();
+	e.configureCommandButton(e, "Auto", '0 0 0', "cmd selectteam auto; cmd join", 1);
+	me.addItemSimple(me, 1, 1, 1, e);
+
+	e = spawnCommandButton();
+	e.configureCommandButton(e, "Red", '1 0 0', "cmd selectteam red; cmd join", 1);
+	me.addItemSimple(me, me.lines, 1, 4, e);
+	e = spawnCommandButton();
+	e.configureCommandButton(e, "Blue", '0 0 1', "cmd selectteam blue; cmd join", 1);
+	me.addItemSimple(me, me.lines, 2, 4, e);
+	e = spawnCommandButton();
+	e.configureCommandButton(e, "Yellow", '1 1 0', "cmd selectteam yellow; cmd join", 1);
+	me.addItemSimple(me, me.lines, 3, 4, e);
+	e = spawnCommandButton();
+	e.configureCommandButton(e, "Pink", '1 0 1', "cmd selectteam pink; cmd join", 1);
+	me.addItemSimple(me, me.lines, 4, 4, e);
+}
+#endif
+
+// click. The C-word so you can grep for it.

Modified: trunk/data/qcsrc/menu-div0test/nexuiz/mainwindow.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/mainwindow.c	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/mainwindow.c	2007-10-27 22:44:23 UTC (rev 2859)
@@ -33,7 +33,7 @@
 		dlg.addItem(dlg, i, '0 0 0', '1 1 0', 1);
 
 		i = spawnLabel();
-		i.configureLabel(i, "Swim swim hungry, swim swim hungry...", 8, 0.5);
+		i.configureLabel(i, "Swim swim hungry, swim swim hungry...", 10, 0.5);
 		dlg.addItem(dlg, i, '0 0.3 0', '1 0.1 0', 1);
 
 		i = spawnRadioButton();
@@ -62,6 +62,10 @@
 		dlg.addItem(dlg, cb, '0.3 0.7 0', '0.4 0.2 0', 1);
 	me.addItem(me, dlg, '0.2 0.3 0', '0.6 0.4 0', 1);
 	
+	i = spawnTeamSelectDialog();
+	i.configureDialog(i);
+	me.addItem(me, i, ('1 1 0' - i.intendedWidth * eX - i.intendedHeight * eY) * 0.5, i.intendedWidth * eX + i.intendedHeight * eY, 1);
+
 	i = spawnImage();
 	i.configureImage(i, "gfx/0.tga");
 	n.addItem(n, i, '0.4 0.45 0', '0.2 0.1 0', 1);
@@ -121,6 +125,7 @@
 	n.setNexposee(n, i, '0.1 0.9 0', 0.2, 0.5);
 
 	me.initializeDialog(me, n);
+
 }
 #endif
 

Modified: trunk/data/qcsrc/menu-div0test/progs.src
===================================================================
--- trunk/data/qcsrc/menu-div0test/progs.src	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/progs.src	2007-10-27 22:44:23 UTC (rev 2859)
@@ -9,6 +9,7 @@
 gamecommand.qh
 menu.qh
 draw.qh
+skin.qh
 
 oo/classdefs.h
 	classes.c

Added: trunk/data/qcsrc/menu-div0test/skin.qh
===================================================================
--- trunk/data/qcsrc/menu-div0test/skin.qh	                        (rev 0)
+++ trunk/data/qcsrc/menu-div0test/skin.qh	2007-10-27 22:44:23 UTC (rev 2859)
@@ -0,0 +1,13 @@
+const float SKINFONTSIZE_TITLE = 12;
+const float SKINHEIGHT_TITLE = 1.5;
+const string SKINGFX_DIALOGBORDER = "qcsrc/menu-div0test/baseborder";
+const string SKINGFX_CLOSEBUTTON = "qcsrc/menu-div0test/baseclosebutton";
+const string SKINGFX_BUTTON = "qcsrc/menu-div0test/basebutton";
+const string SKINGFX_BUTTON_GRAY = "qcsrc/menu-div0test/basebuttongray";
+
+const float SKINMARGIN_TOP = 8;
+const float SKINMARGIN_LEFT = 8;
+
+const float SKINFONTSIZE_NORMAL = 10;
+const float SKINHEIGHT_NORMAL = 1.5;
+const float SKINHEIGHT_NORMAL_WITHSPACING = 2;

Modified: trunk/data/qcsrc/menu-div0test/todo
===================================================================
--- trunk/data/qcsrc/menu-div0test/todo	2007-10-27 18:22:43 UTC (rev 2858)
+++ trunk/data/qcsrc/menu-div0test/todo	2007-10-27 22:44:23 UTC (rev 2859)
@@ -5,12 +5,14 @@
 DONE image displayer
 DONE text label
 DONE button
-TODO radio button
-TODO checkbox (+ tristate)
+DONE radio button
+DONE checkbox
 TODO listbox (with draw callback and scroll bar)
-TODO value slider
+DONE value slider
 DONE tabbed dialog
 
+TODO "half-automatically" self-sizing dialog (by specifying number of "lines" in advance)
+
 TODO options dialog:
 	TODO video/effects
 	TODO preferences




More information about the nexuiz-commits mailing list