From: FruitieX Date: Fri, 12 Nov 2010 06:28:51 +0000 (+0200) Subject: use a default value on the colorpicker_string X-Git-Tag: xonotic-v0.1.0preview~134^2~7 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dee2594bc4afa62147d64d691c30d200dbbcc693;p=xonotic%2Fxonotic-data.pk3dir.git use a default value on the colorpicker_string --- diff --git a/qcsrc/menu/xonotic/colorpicker_string.c b/qcsrc/menu/xonotic/colorpicker_string.c index fd411d545..f57c768a5 100644 --- a/qcsrc/menu/xonotic/colorpicker_string.c +++ b/qcsrc/menu/xonotic/colorpicker_string.c @@ -1,6 +1,6 @@ #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)) @@ -12,23 +12,26 @@ CLASS(XonoticColorpickerString) EXTENDS(Image) 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) @@ -48,7 +51,6 @@ float XonoticColorpickerString_mouseDrag(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; } @@ -75,7 +77,10 @@ void XonoticColorpickerString_draw(entity me) 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 diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_ammo.c b/qcsrc/menu/xonotic/dialog_hudpanel_ammo.c index 1e0d4bf92..256dbe7df 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_ammo.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_ammo.c @@ -29,7 +29,7 @@ void XonoticHUDAmmoDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_chat.c b/qcsrc/menu/xonotic/dialog_hudpanel_chat.c index 74fabe051..c9a4eae6e 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_chat.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_chat.c @@ -29,7 +29,7 @@ void XonoticHUDChatDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_engineinfo.c b/qcsrc/menu/xonotic/dialog_hudpanel_engineinfo.c index 8d359e9cf..03ef106c7 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_engineinfo.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_engineinfo.c @@ -29,7 +29,7 @@ void XonoticHUDEngineInfoDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_healtharmor.c b/qcsrc/menu/xonotic/dialog_hudpanel_healtharmor.c index b276045b6..3e8a43aeb 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_healtharmor.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_healtharmor.c @@ -29,7 +29,7 @@ void XonoticHUDHealthArmorDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_infomessages.c b/qcsrc/menu/xonotic/dialog_hudpanel_infomessages.c index 56d4bf463..d8534a20e 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_infomessages.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_infomessages.c @@ -29,7 +29,7 @@ void XonoticHUDInfoMessagesDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_modicons.c b/qcsrc/menu/xonotic/dialog_hudpanel_modicons.c index ebd5f240b..d60a72473 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_modicons.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_modicons.c @@ -29,7 +29,7 @@ void XonoticHUDModIconsDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_notification.c b/qcsrc/menu/xonotic/dialog_hudpanel_notification.c index c811cb628..3eeaff284 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_notification.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_notification.c @@ -29,7 +29,7 @@ void XonoticHUDNotificationDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_powerups.c b/qcsrc/menu/xonotic/dialog_hudpanel_powerups.c index 14f4a1926..5d4e14c08 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_powerups.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_powerups.c @@ -29,7 +29,7 @@ void XonoticHUDPowerupsDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_pressedkeys.c b/qcsrc/menu/xonotic/dialog_hudpanel_pressedkeys.c index 7d32914dd..30f6bfc1f 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_pressedkeys.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_pressedkeys.c @@ -33,7 +33,7 @@ void XonoticHUDPressedKeysDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_racetimer.c b/qcsrc/menu/xonotic/dialog_hudpanel_racetimer.c index febbd5449..35fdc55f3 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_racetimer.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_racetimer.c @@ -29,7 +29,7 @@ void XonoticHUDRaceTimerDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_radar.c b/qcsrc/menu/xonotic/dialog_hudpanel_radar.c index 90de04795..d1202846e 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_radar.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_radar.c @@ -33,7 +33,7 @@ void XonoticHUDRadarDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_score.c b/qcsrc/menu/xonotic/dialog_hudpanel_score.c index 8c8561ea7..fc51921e2 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_score.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_score.c @@ -29,7 +29,7 @@ void XonoticHUDScoreDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_timer.c b/qcsrc/menu/xonotic/dialog_hudpanel_timer.c index 748d2911e..96dc4aa69 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_timer.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_timer.c @@ -29,7 +29,7 @@ void XonoticHUDTimerDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_vote.c b/qcsrc/menu/xonotic/dialog_hudpanel_vote.c index 6c935d9e7..b5f5b6e27 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_vote.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_vote.c @@ -29,7 +29,7 @@ void XonoticHUDVoteDialog_fill(entity 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(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); diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_weapons.c b/qcsrc/menu/xonotic/dialog_hudpanel_weapons.c index 538723bce..ad3d08041 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_weapons.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_weapons.c @@ -29,11 +29,11 @@ void XonoticHUDWeaponsDialog_fill(entity 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(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:")); @@ -103,7 +103,7 @@ void XonoticHUDWeaponsDialog_fill(entity me) 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); diff --git a/qcsrc/menu/xonotic/dialog_hudsetup_exit.c b/qcsrc/menu/xonotic/dialog_hudsetup_exit.c index 3f8bcebd7..751b3cf95 100644 --- a/qcsrc/menu/xonotic/dialog_hudsetup_exit.c +++ b/qcsrc/menu/xonotic/dialog_hudsetup_exit.c @@ -28,7 +28,7 @@ void XonoticHUDExitDialog_fill(entity 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); @@ -75,7 +75,7 @@ void XonoticHUDExitDialog_fill(entity 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_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);