From 9b4c4a2a49e37ec1147e1ca58514744cac8c74a2 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 9 Jun 2020 10:39:05 +0200 Subject: [PATCH] Move cursor drawing functions to hud.qc --- qcsrc/client/hud/hud.qc | 52 +++++++++++++++++++++++++++++++++++++++++ qcsrc/client/hud/hud.qh | 6 +++++ qcsrc/client/main.qc | 52 ----------------------------------------- qcsrc/client/main.qh | 6 ----- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index bbb49199f..b00020fe5 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -28,6 +28,58 @@ Misc HUD functions ================== */ +void draw_cursor(vector pos, vector ofs, string img, vector col, float a) +{ + ofs = vec2(ofs.x * SIZE_CURSOR.x, ofs.y * SIZE_CURSOR.y); + drawpic(pos - ofs, strcat(draw_currentSkin, img), SIZE_CURSOR, col, a, DRAWFLAG_NORMAL); +} + +void draw_cursor_normal(vector pos, vector col, float a) +{ + draw_cursor(pos, OFFSET_CURSOR, "/cursor", col, a); +} + +void LoadMenuSkinValues() +{ + int fh = -1; + if(cvar_string("menu_skin") != "") + { + draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin")); + fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); + } + if(fh < 0 && cvar_defstring("menu_skin") != "") + { + cvar_set("menu_skin", cvar_defstring("menu_skin")); + draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin")); + fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); + } + if(fh < 0) + { + draw_currentSkin = "gfx/menu/default"; + fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); + } + + draw_currentSkin = strzone(draw_currentSkin); + + if(fh >= 0) + { + string s; + while((s = fgets(fh))) + { + int n = tokenize_console(s); + if (n < 2) + continue; + if(substring(argv(0), 0, 2) == "//") + continue; + if(argv(0) == "SIZE_CURSOR") + SIZE_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))); + else if(argv(0) == "OFFSET_CURSOR") + OFFSET_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))); + } + fclose(fh); + } +} + vector HUD_Get_Num_Color(float hp, float maxvalue, bool blink) { const vector COLOR100 = '0 1 0'; // green diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index f93033f07..1021d7067 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -3,6 +3,12 @@ #include #include +vector OFFSET_CURSOR = '0 0 0'; +vector SIZE_CURSOR = '32 32 0'; +void draw_cursor(vector pos, vector ofs, string img, vector col, float a); +void draw_cursor_normal(vector pos, vector col, float a); +void LoadMenuSkinValues(); + void Hud_Dynamic_Frame(); bool HUD_Radar_Clickable(); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 2d2a5c4fb..4d187e23c 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -38,58 +38,6 @@ #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED -void draw_cursor(vector pos, vector ofs, string img, vector col, float a) -{ - ofs = vec2(ofs.x * SIZE_CURSOR.x, ofs.y * SIZE_CURSOR.y); - drawpic(pos - ofs, strcat(draw_currentSkin, img), SIZE_CURSOR, col, a, DRAWFLAG_NORMAL); -} - -void draw_cursor_normal(vector pos, vector col, float a) -{ - draw_cursor(pos, OFFSET_CURSOR, "/cursor", col, a); -} - -void LoadMenuSkinValues() -{ - int fh = -1; - if(cvar_string("menu_skin") != "") - { - draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin")); - fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); - } - if(fh < 0 && cvar_defstring("menu_skin") != "") - { - cvar_set("menu_skin", cvar_defstring("menu_skin")); - draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin")); - fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); - } - if(fh < 0) - { - draw_currentSkin = "gfx/menu/default"; - fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ); - } - - draw_currentSkin = strzone(draw_currentSkin); - - if(fh >= 0) - { - string s; - while((s = fgets(fh))) - { - int n = tokenize_console(s); - if (n < 2) - continue; - if(substring(argv(0), 0, 2) == "//") - continue; - if(argv(0) == "SIZE_CURSOR") - SIZE_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))); - else if(argv(0) == "OFFSET_CURSOR") - OFFSET_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))); - } - fclose(fh); - } -} - // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load) // Useful for precaching things diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 50fa49ae9..12fc6180a 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -17,12 +17,6 @@ entity gametype; float FONT_USER = 8; -vector OFFSET_CURSOR = '0 0 0'; -vector SIZE_CURSOR = '32 32 0'; -void draw_cursor(vector pos, vector ofs, string img, vector col, float a); -void draw_cursor_normal(vector pos, vector col, float a); -void LoadMenuSkinValues(); - void PostInit(); void Ent_Remove(entity this); -- 2.39.2