]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util.qh
Make the CCR() color replacement function common and add the cvars for it
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util.qh
index 10e680e562615a818f62f7297294681158ed03aa..6b1e5d39a3fd6f1f91dedc75f11371680afb6c47 100644 (file)
@@ -1,6 +1,9 @@
 // a dummy macro that prevents the "hanging ;" warning
 #define ENDS_WITH_CURLY_BRACE
 
+// return the actual code name of a var as a string
+#define VAR_TO_TEXT(var) #var
+
 #ifdef HAVE_YO_DAWG_CPP
 // TODO make ascii art pic of xzibit
 // YO DAWG!
@@ -37,6 +40,11 @@ void ACCUMULATE_call(string func)
        ACCUMULATE_call(#func)
 #endif
 
+// used for simplifying ACCUMULATE_FUNCTIONs
+#define SET_FIRST_OR_LAST(input,first,count) if(!input) { input = (first + count); }
+#define SET_FIELD_COUNT(field,first,count) if(!field) { field = (first + count); ++count; }
+#define CHECK_MAX_COUNT(name,max,count,type) if(count == max) { error(strcat("Maximum ", type, " hit: ", VAR_TO_TEXT(name), ": ", ftos(count), ".\n")); }
+
 // this returns a tempstring containing a copy of s with additional \n newlines added, it also replaces \n in the text with a real newline
 // NOTE: s IS allowed to be a tempstring
 string wordwrap(string s, float l);
@@ -364,3 +372,24 @@ float cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor);
 typedef entity(entity cur, entity near, entity pass) findNextEntityNearFunction_t;
 typedef float(entity a, entity b, entity pass) isConnectedFunction_t;
 void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t nxt, isConnectedFunction_t iscon, entity pass);
+
+// expand multiple arguments into one argument by stripping parenthesis
+#define XPD(...) __VA_ARGS__
+
+float Count_Proper_Strings(string improper, string...count);
+float Count_Proper_Floats(float improper, float...count);
+
+void backtrace(string msg);
+
+// color code replace, place inside of sprintf and parse the string
+// defaults described as comments
+var string autocvar_hud_colorset_foreground_1 = "^2"; // F1 - Green  // primary priority (important names, etc)
+var string autocvar_hud_colorset_foreground_2 = "^3"; // F2 - Yellow // secondary priority (items, locations, numbers, etc)
+var string autocvar_hud_colorset_foreground_3 = "^4"; // F3 - Blue   // tertiary priority or relatively inconsequential text
+var string autocvar_hud_colorset_foreground_4 = "^1"; // F4 - Red    // notice/attention grabbing texting
+var string autocvar_hud_colorset_kill_1 = "^1"; // K1 - Red    // "bad" or "dangerous" text (death messages against you, kill notifications, etc)
+var string autocvar_hud_colorset_kill_2 = "^3"; // K2 - Yellow // similar to above, but less important... OR, a highlight out of above message type
+var string autocvar_hud_colorset_kill_3 = "^4"; // K3 - Blue   // "good" or "beneficial" text (you fragging someone, etc)
+var string autocvar_hud_colorset_background = "^7"; // BG - White // neutral/unimportant text
+
+string CCR(string input);