From 181e8d3be1cd81d6610a13f763449985205fc199 Mon Sep 17 00:00:00 2001 From: FruitieX Date: Fri, 14 May 2010 15:16:07 +0300 Subject: [PATCH] HUD config exporting --- qcsrc/client/Main.qc | 15 ++++++++++++++- qcsrc/client/hud.qc | 29 +++++++++++++++++++++++++++++ qcsrc/client/hud.qh | 5 +++++ qcsrc/common/constants.qh | 3 --- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 8891586c1..b1e418215 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -82,6 +82,8 @@ void CSQC_Init(void) // localcmd("alias order \"cmd order $*\""); enable if ctf-command thingy is used //registercmd("ctf_menu"); registercmd("ons_map"); + registercmd("hud_configure"); + registercmd("hud_save"); //registercmd("menu_action"); registercmd("+button3"); @@ -364,7 +366,18 @@ float CSQC_ConsoleCommand(string strMessage) local string strCmd; strCmd = argv(0); - if(strCmd == "+button4") { // zoom + if(strCmd == "hud_configure") { // config hud + cvar_set("_hud_configure", ftos(!cvar("_hud_configure"))); + return true; + } else if(strCmd == "hud_save") { // save hud config + if(argv(1) == "" || argv(2)) { + print("Usage:\n"); + print("hud_save configname (saves to hud_skinname_configname.cfg)\n"); + } + else + HUD_Panel_ExportCfg(argv(1)); + return true; + } else if(strCmd == "+button4") { // zoom // return false, because the message shall be sent to the server anyway (for demos/speccing) if(ignore_plus_zoom) { diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index b6b71d252..ee8695187 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -555,6 +555,31 @@ string HUD_Panel_GetName(float id) } } +// Save the config +void HUD_Panel_ExportCfg(string cfgname) +{ + float fh; + fh = fopen(strcat("hud_", hud_skin, "_", cfgname, ".cfg"), FILE_WRITE); + if(fh >= 0) + { + float i; + for (i = 0; i < panel_cnt; ++i) + { + fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), " ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i)))))); + fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_pos \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_pos")), "\"")); + fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"")); + fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"")); + fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"")); + fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha"))))); + fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_bg_border"))))); + fputs(fh, ""); + } + + print("^2Successfully exported to hud_", hud_skin, "_", cfgname, ".cfg"); + } + fclose(fh); +} + vector HUD_Panel_CheckLimitSize(float id, vector mySize) { switch(id) { @@ -2846,6 +2871,10 @@ void HUD_Main (void) hud_fontsize = HUD_GetFontsize("hud_fontsize"); hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec"); + //hud_configure = cvar("_hud_configure"); + hud_skin = cvar_string("hud_skin"); + + // Drawing stuff if(cvar_string("hud_dock") != "0") drawpic('0 0 0', strcat("gfx/hud/", cvar_string("hud_dock")), eX * vid_conwidth + eY * vid_conheight, stov(cvar_string("hud_dock_color")), cvar("hud_dock_alpha"), DRAWFLAG_NORMAL); diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh index 5aaa75079..5f911917c 100644 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@ -1,3 +1,5 @@ +float panel_cnt = 11; // NOTE: IDs start from 0! + void CSQC_kh_hudreset(); void CSQC_kh_hud(); void CSQC_ctf_hudreset(); @@ -24,3 +26,6 @@ float hud_hudselector; float hud_accuracy_hud; float hud_border_thickness; float hud_accuracy_border_thickness; + +string hud_skin; +string hud_configure; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 40b3c0ad3..3f15a1784 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -509,6 +509,3 @@ float WATERLEVEL_SWIMMING = 2; float WATERLEVEL_SUBMERGED = 3; float MAX_SHOT_DISTANCE = 32768; - -// panel hud constants -float panel_cnt = 11; // NOTE: IDs start from 0! -- 2.39.2