From 31c50d2a6ee7029c3cfa8c2127ee912e9a693bd5 Mon Sep 17 00:00:00 2001 From: otta8634 Date: Thu, 12 Sep 2024 13:04:12 +0800 Subject: [PATCH] Optimise CCR slightly, remove unused CCR_* cvars & macros Cvars & macros were commented out in case they're needed in future ... R1,R2,R3 likely will be Added the ^ into the cvars to prevent unnecessary strcat calls This does break the config of whoever's changed them from default though Also slightly improved the description of hud_colorset_background --- _hud_common.cfg | 36 +++++++++---------- qcsrc/lib/string.qh | 87 +++++++++++++++++++++++---------------------- 2 files changed, 62 insertions(+), 61 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 03d5ddc41..02b48795f 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -11,24 +11,24 @@ seta hud_cursormode 1 "handle mouse input in cursor mode when CSQC displays a cu seta hud_fontsize 11 "text fontsize for the hud" seta hud_width 560 "2D virtual width for the hud" -seta hud_colorset_foreground_1 "2" "primary priority (important names, etc)" -seta hud_colorset_foreground_2 "3" "secondary priority (items, locations, numbers, etc)" -seta hud_colorset_foreground_3 "4" "tertiary priority or relatively inconsequential text" -seta hud_colorset_foreground_4 "1" "notice/attention grabbing text" -seta hud_colorset_foreground_5 "5" "secondary attention grabbing text" -seta hud_colorset_kill_1 "1" "'bad' or 'dangerous' text (death messages against you, kill notifications, etc)" -seta hud_colorset_kill_2 "3" "similar to above, but less important... OR, a highlight out of above message type" -seta hud_colorset_kill_3 "4" "'good' or 'beneficial' text (you fragging someone, etc)" -seta hud_colorset_compare_1 "1" "'bad'/'no' in terms of some comparison (slower time in race, vote no, etc)" -seta hud_colorset_compare_2 "3" "'neutral' in terms of some comparison (same time in race, etc)" -seta hud_colorset_compare_3 "2" "'good'/'yes' in terms of some comparison (faster time in race, vote yes, etc)" -seta hud_colorset_relative_1 "5" "'better' in terms of another comparison (faster speed in race, etc)" -seta hud_colorset_relative_2 "3" "'neutral' in terms of another comparison (same speed in race, etc)" -seta hud_colorset_relative_3 "6" "'worse' in terms of another comparison (slower speed in race, etc)" -seta hud_colorset_background "7" "neutral/unimportant text" -seta hud_colorset_grey_1 "8" "light grey text (less important text, etc)" -seta hud_colorset_grey_2 "9" "grey text" -seta hud_colorset_grey_3 "0" "dark grey text" +seta hud_colorset_foreground_1 "^2" "primary priority (important names, etc)" +seta hud_colorset_foreground_2 "^3" "secondary priority (items, locations, numbers, etc)" +seta hud_colorset_foreground_3 "^4" "tertiary priority or relatively inconsequential text" +seta hud_colorset_foreground_4 "^1" "notice/attention grabbing text" +seta hud_colorset_foreground_5 "^5" "secondary attention grabbing text" +seta hud_colorset_kill_1 "^1" "'bad' or 'dangerous' text (death messages against you, kill notifications, etc)" +seta hud_colorset_kill_2 "^3" "similar to above, but less important... OR, a highlight out of above message type" +seta hud_colorset_kill_3 "^4" "'good' or 'beneficial' text (you fragging someone, etc)" +seta hud_colorset_compare_1 "^1" "'bad'/'no' in terms of some comparison (slower time in race, vote no, etc)" +seta hud_colorset_compare_2 "^3" "'neutral' in terms of some comparison (same time in race, etc)" +seta hud_colorset_compare_3 "^2" "'good'/'yes' in terms of some comparison (faster time in race, vote yes, etc)" +//seta hud_colorset_relative_1 "^5" "'better' in terms of another comparison (faster speed in race, etc)" +//seta hud_colorset_relative_2 "^3" "'neutral' in terms of another comparison (same speed in race, etc)" +//seta hud_colorset_relative_3 "^6" "'worse' in terms of another comparison (slower speed in race, etc)" +seta hud_colorset_background "^7" "neutral/unimportant/default text" +//seta hud_colorset_grey_1 "^8" "light grey text (less important text, etc)" +seta hud_colorset_grey_2 "^9" "grey text" +//seta hud_colorset_grey_3 "^0" "dark grey text" seta hud_speed_unit "1" "speed unit (1 = qu/s, 2 = m/s, 3 = km/h, 4 = mph, 5 = knots)" diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index 77e0c7f0b..4b0ff0f12 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -200,51 +200,52 @@ string ColorTranslateRGB(string s) #ifdef GAMEQC // color code replace, place inside of sprintf and parse the string... defaults described as constants +// unused color codes are commented out // foreground/normal colors -string autocvar_hud_colorset_foreground_1 = "2"; // F1 - Green // primary priority (important names, etc) -string autocvar_hud_colorset_foreground_2 = "3"; // F2 - Yellow // secondary priority (items, locations, numbers, etc) -string autocvar_hud_colorset_foreground_3 = "4"; // F3 - Blue // tertiary priority or relatively inconsequential text -string autocvar_hud_colorset_foreground_4 = "1"; // F4 - Red // notice/attention grabbing text -string autocvar_hud_colorset_foreground_5 = "5"; // F4 - Light Blue // secondary attention grabbing text +string autocvar_hud_colorset_foreground_1 = "^2"; // F1 - Green // primary priority (important names, etc) +string autocvar_hud_colorset_foreground_2 = "^3"; // F2 - Yellow // secondary priority (items, locations, numbers, etc) +string autocvar_hud_colorset_foreground_3 = "^4"; // F3 - Blue // tertiary priority or relatively inconsequential text +string autocvar_hud_colorset_foreground_4 = "^1"; // F4 - Red // notice/attention grabbing text +string autocvar_hud_colorset_foreground_5 = "^5"; // F4 - Light Blue // secondary attention grabbing text // "kill" colors -string autocvar_hud_colorset_kill_1 = "1"; // K1 - Red // "bad" or "dangerous" text (death messages against you, kill notifications, etc) -string autocvar_hud_colorset_kill_2 = "3"; // K2 - Yellow // similar to above, but less important... OR, a highlight out of above message type -string autocvar_hud_colorset_kill_3 = "4"; // K3 - Blue // "good" or "beneficial" text (you fragging someone, etc) +string autocvar_hud_colorset_kill_1 = "^1"; // K1 - Red // "bad" or "dangerous" text (death messages against you, kill notifications, etc) +string autocvar_hud_colorset_kill_2 = "^3"; // K2 - Yellow // similar to above, but less important... OR, a highlight out of above message type +string autocvar_hud_colorset_kill_3 = "^4"; // K3 - Blue // "good" or "beneficial" text (you fragging someone, etc) // comparison colors -string autocvar_hud_colorset_compare_1 = "1"; // C1 - Red // "bad"/"no" in terms of some comparison (slower time in race, vote no, etc) -string autocvar_hud_colorset_compare_2 = "3"; // C2 - Yellow // "neutral" in terms of some comparison (same time in race, etc) -string autocvar_hud_colorset_compare_3 = "2"; // C3 - Green // "good"/"yes" in terms of some comparison (faster time in race, vote yes, etc) +string autocvar_hud_colorset_compare_1 = "^1"; // C1 - Red // "bad"/"no" in terms of some comparison (slower time in race, vote no, etc) +string autocvar_hud_colorset_compare_2 = "^3"; // C2 - Yellow // "neutral" in terms of some comparison (same time in race, etc) +string autocvar_hud_colorset_compare_3 = "^2"; // C3 - Green // "good"/"yes" in terms of some comparison (faster time in race, vote yes, etc) // relativity colors (alternatives to comparison colors) -string autocvar_hud_colorset_relative_1 = "5"; // R1 - Light Blue // "better" in terms of another comparison (faster speed in race, etc) -string autocvar_hud_colorset_relative_2 = "3"; // R2 - Yellow // "neutral" in terms of another comparison (same speed in race, etc) -string autocvar_hud_colorset_relative_3 = "6"; // R3 - Pink // "worse" in terms of another comparison (slower speed in race, etc) +//string autocvar_hud_colorset_relative_1 = "^5"; // R1 - Light Blue // "better" in terms of another comparison (faster speed in race, etc) +//string autocvar_hud_colorset_relative_2 = "^3"; // R2 - Yellow // "neutral" in terms of another comparison (same speed in race, etc) +//string autocvar_hud_colorset_relative_3 = "^6"; // R3 - Pink // "worse" in terms of another comparison (slower speed in race, etc) // background color -string autocvar_hud_colorset_background = "7"; // BG - White // neutral/unimportant text +string autocvar_hud_colorset_background = "^7"; // BG - White // neutral/unimportant/default text // grey shades -string autocvar_hud_colorset_grey_1 = "8"; // G1 - Light Grey // light grey text (less important text, etc) -string autocvar_hud_colorset_grey_2 = "9"; // G2 - Grey // grey text -string autocvar_hud_colorset_grey_3 = "0"; // G3 - Dark Grey // dark grey text +//string autocvar_hud_colorset_grey_1 = "^8"; // G1 - Light Grey // light grey text (less important text, etc) +string autocvar_hud_colorset_grey_2 = "^9"; // G2 - Grey // grey text +//string autocvar_hud_colorset_grey_3 = "^0"; // G3 - Dark Grey // dark grey text /** color code replace macros for efficiency over the CCR function */ -#define CCR_F1 strcat("^", autocvar_hud_colorset_foreground_1) -#define CCR_F2 strcat("^", autocvar_hud_colorset_foreground_2) -#define CCR_F3 strcat("^", autocvar_hud_colorset_foreground_3) -#define CCR_F4 strcat("^", autocvar_hud_colorset_foreground_4) -#define CCR_F5 strcat("^", autocvar_hud_colorset_foreground_5) -#define CCR_K1 strcat("^", autocvar_hud_colorset_kill_1) -#define CCR_K2 strcat("^", autocvar_hud_colorset_kill_2) -#define CCR_K3 strcat("^", autocvar_hud_colorset_kill_3) -#define CCR_C1 strcat("^", autocvar_hud_colorset_compare_1) -#define CCR_C2 strcat("^", autocvar_hud_colorset_compare_2) -#define CCR_C3 strcat("^", autocvar_hud_colorset_compare_3) -#define CCR_R1 strcat("^", autocvar_hud_colorset_relative_1) -#define CCR_R2 strcat("^", autocvar_hud_colorset_relative_2) -#define CCR_R3 strcat("^", autocvar_hud_colorset_relative_3) -#define CCR_BG strcat("^", autocvar_hud_colorset_background) -#define CCR_N "^7" -#define CCR_G1 strcat("^", autocvar_hud_colorset_grey_1) -#define CCR_G2 strcat("^", autocvar_hud_colorset_grey_2) -#define CCR_G3 strcat("^", autocvar_hud_colorset_grey_3) +#define CCR_F1 autocvar_hud_colorset_foreground_1 +#define CCR_F2 autocvar_hud_colorset_foreground_2 +#define CCR_F3 autocvar_hud_colorset_foreground_3 +#define CCR_F4 autocvar_hud_colorset_foreground_4 +#define CCR_F5 autocvar_hud_colorset_foreground_5 +#define CCR_K1 autocvar_hud_colorset_kill_1 +#define CCR_K2 autocvar_hud_colorset_kill_2 +#define CCR_K3 autocvar_hud_colorset_kill_3 +#define CCR_C1 autocvar_hud_colorset_compare_1 +#define CCR_C2 autocvar_hud_colorset_compare_2 +#define CCR_C3 autocvar_hud_colorset_compare_3 +//#define CCR_R1 autocvar_hud_colorset_relative_1 +//#define CCR_R2 autocvar_hud_colorset_relative_2 +//#define CCR_R3 autocvar_hud_colorset_relative_3 +#define CCR_BG autocvar_hud_colorset_background +//#define CCR_N "^7" +//#define CCR_G1 autocvar_hud_colorset_grey_1 +#define CCR_G2 autocvar_hud_colorset_grey_2 +//#define CCR_G3 autocvar_hud_colorset_grey_3 /** color code replace, place inside of sprintf and parse the string */ string CCR(string input) @@ -267,18 +268,18 @@ string CCR(string input) input = strreplace("^C3", CCR_C3, input); // relativity colors - input = strreplace("^R1", CCR_R1, input); - input = strreplace("^R2", CCR_R2, input); - input = strreplace("^R3", CCR_R3, input); + //input = strreplace("^R1", CCR_R1, input); + //input = strreplace("^R2", CCR_R2, input); + //input = strreplace("^R3", CCR_R3, input); // background colors input = strreplace("^BG", CCR_BG, input); - input = strreplace("^N", CCR_N, input); // "none" -- reset to white... + //input = strreplace("^N", CCR_N, input); // "none" -- reset to white... // grey shades - input = strreplace("^G1", CCR_G1, input); + //input = strreplace("^G1", CCR_G1, input); input = strreplace("^G2", CCR_G2, input); - input = strreplace("^G3", CCR_G3, input); + //input = strreplace("^G3", CCR_G3, input); return input; } -- 2.39.2