r5313 - in trunk/data: gfx gfx/menu/default gfx/menu/silver gfx/menu/simplygray gfx/menu/wickedblack gfx/menu/wickedblue gfx/menu/wickedgreen gfx/menu/wickedred gfx/menu/wickedwhite gfx/menu/wickedyellow gfx/menu/wickedz gfx/menu/xaw qcsrc/common qcsrc/menu qcsrc/menu/item qcsrc/menu/nexuiz
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Dec 26 09:29:00 EST 2008
Author: div0
Date: 2008-12-26 09:29:00 -0500 (Fri, 26 Dec 2008)
New Revision: 5313
Added:
trunk/data/gfx/hslimage.tga
trunk/data/gfx/menu/default/colorpicker.tga
trunk/data/gfx/menu/silver/colorpicker.tga
trunk/data/gfx/menu/simplygray/colorpicker.tga
trunk/data/gfx/menu/wickedblack/colorpicker.tga
trunk/data/gfx/menu/wickedblue/colorpicker.tga
trunk/data/gfx/menu/wickedgreen/colorpicker.tga
trunk/data/gfx/menu/wickedred/colorpicker.tga
trunk/data/gfx/menu/wickedwhite/colorpicker.tga
trunk/data/gfx/menu/wickedyellow/colorpicker.tga
trunk/data/gfx/menu/wickedz/colorpicker.tga
trunk/data/gfx/menu/xaw/colorpicker.tga
trunk/data/qcsrc/menu/nexuiz/colorpicker.c
Modified:
trunk/data/gfx/menu/default/skinvalues.txt
trunk/data/gfx/menu/silver/skinvalues.txt
trunk/data/gfx/menu/simplygray/skinvalues.txt
trunk/data/gfx/menu/wickedblack/skinvalues.txt
trunk/data/gfx/menu/wickedblue/skinvalues.txt
trunk/data/gfx/menu/wickedgreen/skinvalues.txt
trunk/data/gfx/menu/wickedred/skinvalues.txt
trunk/data/gfx/menu/wickedwhite/skinvalues.txt
trunk/data/gfx/menu/wickedyellow/skinvalues.txt
trunk/data/gfx/menu/wickedz/skinvalues.txt
trunk/data/gfx/menu/xaw/skinvalues.txt
trunk/data/qcsrc/common/gamecommand.qc
trunk/data/qcsrc/common/util.qc
trunk/data/qcsrc/common/util.qh
trunk/data/qcsrc/menu/classes.c
trunk/data/qcsrc/menu/item/inputbox.c
trunk/data/qcsrc/menu/mbuiltin.qh
trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c
trunk/data/qcsrc/menu/skin-customizables.inc
Log:
menu: add a color picker for player names
Added: trunk/data/gfx/hslimage.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/hslimage.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/gfx/menu/default/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/default/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/default/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/default/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/default/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '1 1 1'
COLOR_CHECKBOX_D '1 1 1'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/silver/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/silver/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/silver/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/silver/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/silver/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '1 1 1'
COLOR_CHECKBOX_D '1 1 1'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/simplygray/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/simplygray/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/simplygray/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/simplygray/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/simplygray/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '1 1 1'
COLOR_CHECKBOX_D '1 1 1'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/wickedblack/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/wickedblack/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/wickedblack/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/wickedblack/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/wickedblack/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '0.75 0.75 0.75'
COLOR_CHECKBOX_D '1 1 1'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/wickedblue/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/wickedblue/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/wickedblue/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/wickedblue/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/wickedblue/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '0.25 0.5 0.75'
COLOR_CHECKBOX_D '0.5 0.75 1'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/wickedgreen/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/wickedgreen/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/wickedgreen/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/wickedgreen/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/wickedgreen/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '0.25 0.75 0'
COLOR_CHECKBOX_D '0.5 1 0'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/wickedred/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/wickedred/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/wickedred/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/wickedred/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/wickedred/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '0.75 0 0'
COLOR_CHECKBOX_D '1 0 0'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/wickedwhite/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/wickedwhite/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/wickedwhite/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/wickedwhite/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/wickedwhite/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '0.75 0.75 0.75'
COLOR_CHECKBOX_D '1 1 1'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/wickedyellow/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/wickedyellow/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/wickedyellow/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/wickedyellow/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/wickedyellow/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '1 0.75 0'
COLOR_CHECKBOX_D '1 0.875 0'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/wickedz/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/wickedz/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/wickedz/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/wickedz/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/wickedz/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -84,6 +84,10 @@
COLOR_CHECKBOX_F '0.6 0.4 0'
COLOR_CHECKBOX_D '0 0.75 0.75'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Added: trunk/data/gfx/menu/xaw/colorpicker.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/gfx/menu/xaw/colorpicker.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/gfx/menu/xaw/skinvalues.txt
===================================================================
--- trunk/data/gfx/menu/xaw/skinvalues.txt 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/gfx/menu/xaw/skinvalues.txt 2008-12-26 14:29:00 UTC (rev 5313)
@@ -70,6 +70,10 @@
COLOR_CHECKBOX_F '1 1 1'
COLOR_CHECKBOX_D '1 1 1'
+// item: color picker
+// uses "colorpicker" images
+MARGIN_COLORPICKER '0 0 0'
+
// item: credits list
COLOR_CREDITS_TITLE '1 1 1'
ALPHA_CREDITS_TITLE 1
Modified: trunk/data/qcsrc/common/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/common/gamecommand.qc 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/qcsrc/common/gamecommand.qc 2008-12-26 14:29:00 UTC (rev 5313)
@@ -48,7 +48,8 @@
{
float argc;
float i, j, f, n;
- string s, s2;
+ vector rgb;
+ string s, s2, c;
argc = tokenize_sane(command);
if(argv(0) == "help")
{
@@ -140,6 +141,33 @@
return TRUE;
}
}
+ else if(argv(0) == "BRLOGENSHFEGLE" && argc >= 2)
+ {
+ // test case for terrencehill's color codes
+ s = substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2));
+ s2 = "";
+ n = strlen(s);
+
+ j = random() * 0.1 + 0.05;
+ f = random();
+
+ for(i = 0; i < n; ++i)
+ {
+ c = substring(s, i, 1);
+ if(c == ";")
+ c = ":";
+ if(c != " ")
+ {
+ rgb = hsl_to_rgb('1 0 0' * (j * i + f) + '0 1 .5');
+ c = strcat(rgb_to_hexcolor(rgb), c);
+ }
+ s2 = strcat(s2, c);
+ }
+
+ localcmd(strcat(argv(1), " ", s2));
+
+ return TRUE;
+ }
else if(argv(0) == "rpn")
{
if(!rpn_db)
Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/qcsrc/common/util.qc 2008-12-26 14:29:00 UTC (rev 5313)
@@ -1140,3 +1140,110 @@
else
return 0;
}
+
+vector rgb_to_hsl(vector rgb)
+{
+ float mi, ma;
+ vector hsl;
+
+ mi = min3(rgb_x, rgb_y, rgb_z);
+ ma = max3(rgb_x, rgb_y, rgb_z);
+
+ if(mi == ma)
+ hsl_x = 0;
+ else if(ma == rgb_x)
+ hsl_x = (rgb_y - rgb_z) / (ma - mi);
+ else if(ma == rgb_y)
+ hsl_x = (rgb_z - rgb_x) / (ma - mi) + 2;
+ else // if(ma == rgb_z)
+ hsl_x = (rgb_x - rgb_y) / (ma - mi) + 4;
+ if(hsl_x < 0)
+ hsl_x += 6;
+
+ hsl_z = 0.5 * (mi + ma);
+
+ if(mi == ma)
+ hsl_y = 0;
+ else if(hsl_z <= 0.5)
+ hsl_y = (ma - mi) / (2*hsl_z);
+ else // if(hsl_z > 0.5)
+ hsl_y = (ma - mi) / (2 - 2*hsl_z);
+
+ return hsl;
+}
+
+vector hsl_to_rgb(vector hsl)
+{
+ float mi, ma, maminusmi, h;
+ vector rgb;
+
+ if(hsl_z <= 0.5)
+ maminusmi = hsl_y * 2 * hsl_z;
+ else
+ maminusmi = hsl_y * (2 - 2 * hsl_z);
+
+ // hsl_z = 0.5 * mi + 0.5 * ma
+ // maminusmi = - mi + ma
+ mi = hsl_z - 0.5 * maminusmi;
+ ma = hsl_z + 0.5 * maminusmi;
+
+ h = hsl_x - 6 * floor(hsl_x / 6);
+
+ //else if(ma == rgb_x)
+ // h = 60 * (rgb_y - rgb_z) / (ma - mi);
+ if(h <= 1)
+ {
+ rgb_x = ma;
+ rgb_y = h * (ma - mi) + mi;
+ rgb_z = mi;
+ }
+ //else if(ma == rgb_y)
+ // h = 60 * (rgb_z - rgb_x) / (ma - mi) + 120;
+ else if(h <= 2)
+ {
+ rgb_x = (2 - h) * (ma - mi) + mi;
+ rgb_y = ma;
+ rgb_z = mi;
+ }
+ else if(h <= 3)
+ {
+ rgb_x = mi;
+ rgb_y = ma;
+ rgb_z = (h - 2) * (ma - mi) + mi;
+ }
+ //else // if(ma == rgb_z)
+ // h = 60 * (rgb_x - rgb_y) / (ma - mi) + 240;
+ else if(h <= 4)
+ {
+ rgb_x = mi;
+ rgb_y = (4 - h) * (ma - mi) + mi;
+ rgb_z = ma;
+ }
+ else if(h <= 5)
+ {
+ rgb_x = (h - 4) * (ma - mi) + mi;
+ rgb_y = mi;
+ rgb_z = ma;
+ }
+ //else if(ma == rgb_x)
+ // h = 60 * (rgb_y - rgb_z) / (ma - mi);
+ else // if(h <= 6)
+ {
+ rgb_x = ma;
+ rgb_y = mi;
+ rgb_z = (6 - h) * (ma - mi) + mi;
+ }
+
+ return rgb;
+}
+
+string rgb_to_hexcolor(vector rgb)
+{
+ return
+ strcat(
+ "^x",
+ DEC_TO_HEXDIGIT(floor(rgb_x * 15 + 0.5)),
+ DEC_TO_HEXDIGIT(floor(rgb_y * 15 + 0.5)),
+ DEC_TO_HEXDIGIT(floor(rgb_z * 15 + 0.5))
+ );
+}
Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/qcsrc/common/util.qh 2008-12-26 14:29:00 UTC (rev 5313)
@@ -119,3 +119,12 @@
float power2of(float e);
float log2of(float x);
+
+string HEXDIGITS = "0123456789ABCDEF0123456789abcdef";
+#define HEXDIGIT_TO_DEC_RAW(d) (strstrofs(HEXDIGITS, (d), 0))
+#define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10)
+#define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS, (d), 1))
+
+vector rgb_to_hsl(vector rgb);
+vector hsl_to_rgb(vector hsl);
+string rgb_to_hexcolor(vector rgb);
Modified: trunk/data/qcsrc/menu/classes.c
===================================================================
--- trunk/data/qcsrc/menu/classes.c 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/qcsrc/menu/classes.c 2008-12-26 14:29:00 UTC (rev 5313)
@@ -74,3 +74,4 @@
#include "nexuiz/dialog_multiplayer_playersetup_radar.c"
#include "nexuiz/dialog_settings_demo.c"
#include "nexuiz/demolist.c"
+#include "nexuiz/colorpicker.c"
Modified: trunk/data/qcsrc/menu/item/inputbox.c
===================================================================
--- trunk/data/qcsrc/menu/item/inputbox.c 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/qcsrc/menu/item/inputbox.c 2008-12-26 14:29:00 UTC (rev 5313)
@@ -211,44 +211,17 @@
theColor = '1 1 1' * (1 - brightness) + brightness * '1 1 1';
theTempColor = '0 0 0';
- component = str2chr(me.text, i+2);
- if (component >= '0' && component <= '9')
- component = component - '0';
- else if (component >= 'a' && component <= 'f')
- component = component - 87;
- else if (component >= 'A' && component <= 'F')
- component = component - 55;
- else
- component = -1;
-
+ component = HEXDIGIT_TO_DEC(substring(me.text, i+2, 1));
if (component >= 0) // ^xr found
{
theTempColor_x = component/15;
- component = str2chr(me.text, i+3);
- if (component >= '0' && component <= '9')
- component = component - '0';
- else if (component >= 'a' && component <= 'f')
- component = component - 87;
- else if (component >= 'A' && component <= 'F')
- component = component - 55;
- else
- component = -1;
-
+ component = HEXDIGIT_TO_DEC(substring(me.text, i+3, 1));
if (component >= 0) // ^xrg found
{
theTempColor_y = component/15;
- component = str2chr(me.text, i+4);
- if (component >= '0' && component <= '9')
- component = component - '0';
- else if (component >= 'a' && component <= 'f')
- component = component - 87;
- else if (component >= 'A' && component <= 'F')
- component = component - 55;
- else
- component = -1;
-
+ component = HEXDIGIT_TO_DEC(substring(me.text, i+4, 1));
if (component >= 0) // ^xrgb found
{
theTempColor_z = component/15;
Modified: trunk/data/qcsrc/menu/mbuiltin.qh
===================================================================
--- trunk/data/qcsrc/menu/mbuiltin.qh 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/qcsrc/menu/mbuiltin.qh 2008-12-26 14:29:00 UTC (rev 5313)
@@ -83,7 +83,19 @@
float registercvar(string name, string value, float flags) = #42; // returns 1 if success
float min(float f,...) = #43;
+float (float a, float b, float c) min3 = #43;
+float (float a, float b, float c, float d) min4 = #43;
+float (float a, float b, float c, float d, float e) min5 = #43;
+float (float a, float b, float c, float d, float e, float f) min6 = #43;
+float (float a, float b, float c, float d, float e, float f, float g) min7 = #43;
+float (float a, float b, float c, float d, float e, float f, float g, float h) min8 = #43;
float max(float f,...) = #44;
+float (float a, float b, float c) max3 = #44;
+float (float a, float b, float c, float d) max4 = #44;
+float (float a, float b, float c, float d, float e) max5 = #44;
+float (float a, float b, float c, float d, float e, float f) max6 = #44;
+float (float a, float b, float c, float d, float e, float f, float g) max7 = #44;
+float (float a, float b, float c, float d, float e, float f, float g, float h) max8 = #44;
float bound(float min,float value, float max) = #45;
float pow(float a, float b) = #46;
void copyentity(entity src, entity dst) = #47;
Added: trunk/data/qcsrc/menu/nexuiz/colorpicker.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/colorpicker.c (rev 0)
+++ trunk/data/qcsrc/menu/nexuiz/colorpicker.c 2008-12-26 14:29:00 UTC (rev 5313)
@@ -0,0 +1,113 @@
+#ifdef INTERFACE
+CLASS(NexuizColorpicker) EXTENDS(Image)
+ METHOD(NexuizColorpicker, configureNexuizColorpicker, void(entity, entity))
+ METHOD(NexuizColorpicker, mousePress, float(entity, vector))
+ METHOD(NexuizColorpicker, mouseRelease, float(entity, vector))
+ METHOD(NexuizColorpicker, mouseDrag, float(entity, vector))
+ ATTRIB(NexuizColorpicker, controlledTextbox, entity, NULL)
+ ATTRIB(NexuizColorpicker, image, string, SKINGFX_COLORPICKER)
+ ATTRIB(NexuizColorpicker, imagemargin, vector, SKINMARGIN_COLORPICKER)
+ ATTRIB(NexuizColorpicker, focusable, float, 1)
+ METHOD(NexuizColorpicker, focusLeave, void(entity))
+ METHOD(NexuizColorpicker, keyDown, float(entity, float, float, float))
+ENDCLASS(NexuizColorpicker)
+entity makeNexuizColorpicker(entity theTextbox);
+#endif
+
+#ifdef IMPLEMENTATION
+entity makeNexuizColorpicker(entity theTextbox)
+{
+ entity me;
+ me = spawnNexuizColorpicker();
+ me.configureNexuizColorpicker(me, theTextbox);
+ return me;
+}
+
+void configureNexuizColorpickerNexuizColorpicker(entity me, entity theTextbox)
+{
+ me.controlledTextbox = theTextbox;
+ me.configureImage(me, me.image);
+}
+
+float mousePressNexuizColorpicker(entity me, vector coords)
+{
+ me.mouseDrag(me, coords);
+ return 1;
+}
+
+// must match hslimage.c
+vector hslimage_color(vector v, vector margin)
+{
+ v_x = (v_x - margin_x) / (1 - 2 * margin_x);
+ v_y = (v_y - margin_y) / (1 - 2 * margin_y);
+ if(v_x < 0) v_x = 0;
+ if(v_y < 0) v_y = 0;
+ if(v_x > 1) v_x = 1;
+ if(v_y > 1) v_y = 1;
+ if(v_y > 0.875) // grey bar
+ return hsl_to_rgb(eZ * v_x);
+ else
+ return hsl_to_rgb(v_x * 6 * eX + eY + v_y / 0.875 * eZ);
+}
+
+float mouseDragNexuizColorpicker(entity me, vector coords)
+{
+ float i;
+ for(;;)
+ {
+ i = me.controlledTextbox.cursorPos;
+ if(i >= 2)
+ {
+ if(substring(me.controlledTextbox.text, i-2, 1) == "^")
+ if(strstrofs("0123456789", substring(me.controlledTextbox.text, i-1, 1), 0) >= 0)
+ {
+ me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
+ me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
+ continue;
+ }
+ }
+
+ if(i >= 5)
+ {
+ if(substring(me.controlledTextbox.text, i-5, 2) == "^x")
+ if(strstrofs("0123456789abcdefABCDEF", substring(me.controlledTextbox.text, i-3, 1), 0) >= 0)
+ if(strstrofs("0123456789abcdefABCDEF", substring(me.controlledTextbox.text, i-2, 1), 0) >= 0)
+ if(strstrofs("0123456789abcdefABCDEF", substring(me.controlledTextbox.text, i-1, 1), 0) >= 0)
+ {
+ me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
+ me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
+ me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
+ me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
+ me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
+ continue;
+ }
+ }
+ break;
+ }
+
+ vector margin;
+ margin = me.imagemargin;
+ if(coords_x >= margin_x)
+ if(coords_y >= margin_y)
+ if(coords_x <= 1 - margin_x)
+ if(coords_y <= 1 - margin_y)
+ me.controlledTextbox.enterText(me.controlledTextbox, rgb_to_hexcolor(hslimage_color(coords, margin)));
+
+ return 1;
+}
+
+float mouseReleaseNexuizColorpicker(entity me, vector coords)
+{
+ me.mouseDrag(me, coords);
+ return 1;
+}
+
+void focusLeaveNexuizColorpicker(entity me)
+{
+ me.controlledTextbox.saveCvars(me.controlledTextbox);
+}
+float keyDownNexuizColorpicker(entity me, float key, float ascii, float shift)
+{
+ return me.controlledTextbox.keyDown(me.controlledTextbox, key, ascii, shift);
+}
+#endif
Modified: trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c 2008-12-26 14:29:00 UTC (rev 5313)
@@ -30,17 +30,17 @@
}
void fillNexuizPlayerSettingsTab(entity me)
{
- entity e, pms, sl, e0;
+ entity e, pms, sl, e0, box;
float i, n;
me.TR(me);
me.TD(me, 1, 1, me.playerNameLabel = makeNexuizTextLabel(0, "Player Name:"));
me.playerNameLabelAlpha = me.playerNameLabel.alpha;
- me.TD(me, 1, 2, e = makeNexuizInputBox(1, "_cl_name"));
- e.forbiddenCharacters = "\r\n\\\"$"; // don't care, isn't getting saved
+ me.TD(me, 1, 2, box = makeNexuizInputBox(1, "_cl_name"));
+ box.forbiddenCharacters = "\r\n\\\"$"; // don't care, isn't getting saved
me.TR(me);
- me.TDempty(me, 1);
- me.TD(me, 5, 2, e = makeNexuizCharmap(e));
+ me.TD(me, 5, 1, e = makeNexuizColorpicker(box));
+ me.TD(me, 5, 2, e = makeNexuizCharmap(box));
me.TR(me);
me.TR(me);
me.TR(me);
Modified: trunk/data/qcsrc/menu/skin-customizables.inc
===================================================================
--- trunk/data/qcsrc/menu/skin-customizables.inc 2008-12-26 14:25:58 UTC (rev 5312)
+++ trunk/data/qcsrc/menu/skin-customizables.inc 2008-12-26 14:29:00 UTC (rev 5313)
@@ -102,6 +102,10 @@
SKINVECTOR(COLOR_CHECKBOX_F, '1 1 1');
SKINVECTOR(COLOR_CHECKBOX_D, '1 1 1');
+ // item: color picker
+ SKINSTRING(GFX_COLORPICKER, "colorpicker");
+ SKINVECTOR(MARGIN_COLORPICKER, '0 0 0');
+
// item: credits list
SKINVECTOR(COLOR_CREDITS_TITLE, '1 1 1');
SKINFLOAT(ALPHA_CREDITS_TITLE, 1);
More information about the nexuiz-commits
mailing list