--- /dev/null
+#ifdef INTERFACE
+CLASS(VoretColorpickerString) EXTENDS(Image)
+ METHOD(VoretColorpickerString, configureVoretColorpickerString, void(entity, string, string))
+ METHOD(VoretColorpickerString, mousePress, float(entity, vector))
+ METHOD(VoretColorpickerString, mouseRelease, float(entity, vector))
+ METHOD(VoretColorpickerString, mouseDrag, float(entity, vector))
+ ATTRIB(VoretColorpickerString, cvarName, string, string_null)
+ ATTRIB(VoretColorpickerString, prevcoords, vector, '0 0 0')
+ ATTRIB(VoretColorpickerString, image, string, SKINGFX_COLORPICKER)
+ ATTRIB(VoretColorpickerString, imagemargin, vector, SKINMARGIN_COLORPICKER)
+ ATTRIB(VoretColorpickerString, focusable, float, 1)
+ METHOD(VoretColorpickerString, focusLeave, void(entity))
+ METHOD(VoretColorpickerString, keyDown, float(entity, float, float, float))
+ METHOD(VoretColorpickerString, draw, void(entity))
+ENDCLASS(VoretColorpickerString)
+entity makeVoretColorpickerString(string theCvar, string theDefaultCvar);
+#endif
+
+#ifdef IMPLEMENTATION
+entity makeVoretColorpickerString(string theCvar, string theDefaultCvar)
+{
+ entity me;
+ me = spawnVoretColorpickerString();
+ me.configureVoretColorpickerString(me, theCvar, theDefaultCvar);
+ return me;
+}
+
+void configureVoretColorpickerStringVoretColorpickerString(entity me, string theCvar, string theDefaultCvar)
+{
+ me.cvarName = theCvar;
+ me.configureImage(me, me.image);
+ if(cvar_string(theCvar) != "")
+ me.prevcoords = hslimage_color(stov(cvar_string(theCvar)), me.imagemargin);
+ else // use default
+ me.prevcoords = hslimage_color(stov(cvar_string(theDefaultCvar)), me.imagemargin);
+}
+
+float mousePressVoretColorpickerString(entity me, vector coords)
+{
+ me.mouseDrag(me, coords);
+ return 1;
+}
+
+// must match hslimage.c
+
+
+float mouseDragVoretColorpickerString(entity me, vector coords)
+{
+ if(me.disabled)
+ return 0;
+ 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.prevcoords = coords;
+ }
+
+ return 1;
+}
+
+float mouseReleaseVoretColorpickerString(entity me, vector coords)
+{
+ me.mouseDrag(me, coords);
+ return 1;
+}
+
+void focusLeaveVoretColorpickerString(entity me)
+{
+ me.controlledTextbox.saveCvars(me.controlledTextbox);
+}
+float keyDownVoretColorpickerString(entity me, float key, float ascii, float shift)
+{
+ return me.controlledTextbox.keyDown(me.controlledTextbox, key, ascii, shift);
+}
+void drawVoretColorpickerString(entity me)
+{
+ drawImage(me);
+
+ float B, C, aC;
+ C = cvar("r_textcontrast");
+ B = cvar("r_textbrightness");
+
+ // for this to work, C/(1-B) must be in 0..1
+ // B must be < 1
+ // C must be < 1-B
+
+ B = bound(0, B, 1);
+ C = bound(0, C, 1-B);
+
+ aC = 1 - C / (1 - B);
+
+ draw_Picture(me.imgOrigin, strcat(me.src, "_m"), me.imgSize, '0 0 0', aC);
+ draw_Picture(me.imgOrigin, strcat(me.src, "_m"), me.imgSize, me.color, B);
+}
+#endif