From 3d2ca5ba3c10a021af73079d163a8e7f9ba659ca Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Sun, 6 Nov 2011 17:30:04 +0200 Subject: [PATCH] Color picker for the HUD --- data/defaultVT.cfg | 4 +-- data/qcsrc/client/sbar.qc | 35 ++++++------------- .../dialog_multiplayer_playersetup_hud.c | 14 ++------ 3 files changed, 13 insertions(+), 40 deletions(-) diff --git a/data/defaultVT.cfg b/data/defaultVT.cfg index 6368811c..944483fc 100644 --- a/data/defaultVT.cfg +++ b/data/defaultVT.cfg @@ -1192,9 +1192,7 @@ sbar_info_pos 50 seta sbar_alpha_bg 0.8 "alpha value of the HUD background" seta sbar_alpha_fg 1 "alpha value of the HUD foreground items" seta sbar_border_thickness 1 "scoreboard border thickness" -seta sbar_color_bg_r 0.5 "red color component of the HUD background" -seta sbar_color_bg_g 0.25 "green color component of the HUD background" -seta sbar_color_bg_b 1 "blue color component of the HUD background" +seta sbar_color_bg "0.5 0.25 1" "default color of the HUD background" seta sbar_color_bg_team 1 "team color multiplier of the HUD background" seta sbar_scoreboard_offset 100 "scoreboard vertical position" seta sbar_scoreboard_alpha_bg 0.6 "scoreboard background alpha" diff --git a/data/qcsrc/client/sbar.qc b/data/qcsrc/client/sbar.qc index 56395d20..61d7e8f2 100644 --- a/data/qcsrc/client/sbar.qc +++ b/data/qcsrc/client/sbar.qc @@ -795,11 +795,9 @@ void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_num float is_spec; is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR); - if((rgb == '1 1 1') && (!is_spec)) { - rgb_x = cvar("sbar_color_bg_r") + 0.5; - rgb_y = cvar("sbar_color_bg_g") + 0.5; - rgb_z = cvar("sbar_color_bg_b") + 0.5; } - + if((rgb == '1 1 1') && (!is_spec)) + rgb = stov(cvar_string("sbar_color_bg")) + '0.5 0.5 0.5'; + // Layout: tmp_x = sbwidth; tmp_y = sbar_fontsize_y * 1.25; @@ -1270,9 +1268,7 @@ vector Sbar_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg float is_spec; is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR); vector hl_rgb; - hl_rgb_x = cvar("sbar_color_bg_r") + 0.5; - hl_rgb_y = cvar("sbar_color_bg_g") + 0.5; - hl_rgb_z = cvar("sbar_color_bg_b") + 0.5; + hl_rgb = stov(cvar_string("sbar_color_bg")) + '0.5 0.5 0.5'; pos_y += sbar_fontsize_y; drawstring(pos, strcat("Rankings"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL); @@ -1395,9 +1391,7 @@ void Sbar_DrawScoreboard() } else { - rgb_x = cvar("sbar_color_bg_r"); - rgb_y = cvar("sbar_color_bg_g"); - rgb_z = cvar("sbar_color_bg_b"); + rgb = stov(cvar_string("sbar_color_bg")); for(tm = teams.sort_next; tm; tm = tm.sort_next) { @@ -1946,9 +1940,7 @@ void Sbar_Status() drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color else { // allow for custom HUD colors in non-teamgames - color_x = cvar("sbar_color_bg_r"); - color_y = cvar("sbar_color_bg_g"); - color_z = cvar("sbar_color_bg_b"); + color = stov(cvar_string("sbar_color_bg")); drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL); } @@ -2093,9 +2085,7 @@ void Sbar_Timer() if (teamplay) drawpic(bgpos, "gfx/hud/bg_timer", '120 30 0' * scale, GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // timer bg color = myteam color else { - color_x = cvar("sbar_color_bg_r"); - color_y = cvar("sbar_color_bg_g"); - color_z = cvar("sbar_color_bg_b"); + color = stov(cvar_string("sbar_color_bg")); drawpic(bgpos, "gfx/hud/bg_timer", '120 30 0' * scale, color, sbar_alpha_bg, DRAWFLAG_NORMAL); } @@ -3014,11 +3004,8 @@ void Sbar_Draw (void) if (teamplay) color = GetTeamRGB(myteam) * sbar_color_bg_team; - else { - color_x = cvar("sbar_color_bg_r"); - color_y = cvar("sbar_color_bg_g"); - color_z = cvar("sbar_color_bg_b"); - } + else + color = stov(cvar_string("sbar_color_bg")); vector voteorigin = bottomright - '290 135 0'; vector votesize = '280 70 0'; @@ -3099,9 +3086,7 @@ void Sbar_Draw (void) drawpic(bottomleft- '0 256 0', "gfx/hud/bg_stomach", '256 256 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color else { // allow for custom HUD colors in non-teamgames - color_x = cvar("sbar_color_bg_r"); - color_y = cvar("sbar_color_bg_g"); - color_z = cvar("sbar_color_bg_b"); + color = stov(cvar_string("sbar_color_bg")); drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach", '256 256 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL); } diff --git a/data/qcsrc/menu/voret/dialog_multiplayer_playersetup_hud.c b/data/qcsrc/menu/voret/dialog_multiplayer_playersetup_hud.c index f3c370ad..6c1f50cd 100644 --- a/data/qcsrc/menu/voret/dialog_multiplayer_playersetup_hud.c +++ b/data/qcsrc/menu/voret/dialog_multiplayer_playersetup_hud.c @@ -58,19 +58,9 @@ void fillVoretHudDialog(entity me) setDependent(e, "viewsize", 0, 100); me.TR(me); me.TDempty(me, 0.2); - me.TD(me, 1, 0.8, e = makeVoretTextLabel(0, "Default ^1red^7:")); - me.TD(me, 1, 3, e = makeVoretSlider(0, 1, 0.01, "sbar_color_bg_r")); - setDependent(e, "viewsize", 0, 100); - me.TR(me); - me.TDempty(me, 0.2); - me.TD(me, 1, 0.8, e = makeVoretTextLabel(0, "Default ^2green^7:")); - me.TD(me, 1, 3, e = makeVoretSlider(0, 1, 0.01, "sbar_color_bg_g")); - setDependent(e, "viewsize", 0, 100); + me.TD(me, 1, 0.8, e = makeVoretTextLabel(0, "Default color:")); + me.TD(me, 2, 2, e = makeVoretColorpickerString("sbar_color_bg", "sbar_color_bg")); me.TR(me); - me.TDempty(me, 0.2); - me.TD(me, 1, 0.8, e = makeVoretTextLabel(0, "Default ^4blue^7:")); - me.TD(me, 1, 3, e = makeVoretSlider(0, 1, 0.01, "sbar_color_bg_b")); - setDependent(e, "viewsize", 0, 100); me.TR(me); me.TDempty(me, 0.2); me.TD(me, 1, 0.8, e = makeVoretTextLabel(0, "Team color:")); -- 2.39.2