#ifdef INTERFACE
CLASS(XonoticColorpickerString) EXTENDS(Image)
- METHOD(XonoticColorpickerString, configureXonoticColorpickerString, void(entity, string))
+ METHOD(XonoticColorpickerString, configureXonoticColorpickerString, void(entity, string, string))
METHOD(XonoticColorpickerString, mousePress, float(entity, vector))
METHOD(XonoticColorpickerString, mouseRelease, float(entity, vector))
METHOD(XonoticColorpickerString, mouseDrag, float(entity, vector))
METHOD(XonoticColorpickerString, draw, void(entity))
ATTRIB(XonoticColorpickerString, disabledAlpha, float, 0.3)
ENDCLASS(XonoticColorpickerString)
-entity makeXonoticColorpickerString(string theCvar);
+entity makeXonoticColorpickerString(string theCvar, string theDefaultCvar);
#endif
#ifdef IMPLEMENTATION
-entity makeXonoticColorpickerString(string theCvar)
+entity makeXonoticColorpickerString(string theCvar, string theDefaultCvar)
{
entity me;
me = spawnXonoticColorpickerString();
- me.configureXonoticColorpickerString(me, theCvar);
+ me.configureXonoticColorpickerString(me, theCvar, theDefaultCvar);
return me;
}
-void XonoticColorpickerString_configureXonoticColorpickerString(entity me, string theCvar)
+void XonoticColorpickerString_configureXonoticColorpickerString(entity me, string theCvar, string theDefaultCvar)
{
me.cvarName = theCvar;
me.configureImage(me, me.image);
- me.prevcoords = color_hslimage(stov(cvar_string(theCvar)), me.imagemargin);
+ if(cvar_string(theCvar) != "")
+ me.prevcoords = color_hslimage(stov(cvar_string(theCvar)), me.imagemargin);
+ else // use default
+ me.prevcoords = color_hslimage(stov(cvar_string(theDefaultCvar)), me.imagemargin);
}
float XonoticColorpickerString_mousePress(entity me, vector coords)
if(coords_x <= 1 - margin_x)
if(coords_y <= 1 - margin_y)
{
- cvar_set(me.cvarName, sprintf("%v", hslimage_color(coords, margin)));
me.prevcoords = coords;
}
sz = globalToBoxSize(sz, draw_scale);
if(!me.disabled)
+ {
+ cvar_set(me.cvarName, sprintf("%v", hslimage_color(me.prevcoords, me.imagemargin)));
draw_Picture(me.imgOrigin + me.prevcoords - 0.5 * sz, strcat(me.src, "_selected"), sz, '1 1 1', 1);
+ }
draw_alpha = save;
}
#endif
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color"))));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
me.TR(me);
me.TDempty(me, 0.2);
- me.TD(me, 1, 1.2, e = makeXonoticCheckBoxString("", "1 1 1", strzone(strcat("hud_panel_", panelname, "_bg_color")), "Use default"));
+ me.TD(me, 1, 1.2, e = makeXonoticCheckBoxString("", cvar_string("hud_panel_bg_color"), strzone(strcat("hud_panel_", panelname, "_bg_color")), "Use default"));
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Border size:"));
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Ammo bar color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString("hud_panel_weapons_ammo_color"));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString("hud_panel_weapons_ammo_color", "hud_panel_weapons_ammo_color"));
setDependent(e, "hud_panel_weapons_ammo", 1, 1);
me.TR(me);
me.TR(me);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString("hud_panel_bg_color"));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString("hud_panel_bg_color", "hud_panel_bg_color"));
me.TR(me);
me.TR(me);
me.TDempty(me, 0.2);
me.TR(me);
me.TDempty(me, 0.2);
me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Color:"));
- me.TD(me, 2, 2.4, e = makeXonoticColorpickerString("hud_dock_color"));
+ me.TD(me, 2, 2.4, e = makeXonoticColorpickerString("hud_dock_color", "hud_dock_color"));
me.TR(me);
me.TR(me);
me.TDempty(me, 0.2);