]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move cursor drawing functions to hud.qc
authorterencehill <piuntn@gmail.com>
Tue, 9 Jun 2020 08:39:05 +0000 (10:39 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 9 Jun 2020 08:39:05 +0000 (10:39 +0200)
qcsrc/client/hud/hud.qc
qcsrc/client/hud/hud.qh
qcsrc/client/main.qc
qcsrc/client/main.qh

index bbb49199f9d727f342b5775c1456e1532b897842..b00020fe50880a1194791bafe706d9aece0dab1c 100644 (file)
@@ -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
index f93033f07e5fa0804d594f2e532ec9cc9bf35748..1021d7067e06f3db382643a172be9a6463bd3999 100644 (file)
@@ -3,6 +3,12 @@
 #include <common/weapons/_all.qh>
 #include <common/scores.qh>
 
+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();
index 2d2a5c4fbf3427d1555b274ff089919ac3cfaba7..4d187e23cf02f12a800cffbd02a5328fa511bb73 100644 (file)
 
 #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
 
index 50fa49ae962f9576b09d00da780dd8ebb2cc19fe..12fc6180a1f08e04db5f4df8ea46c6b4c08b996c 100644 (file)
@@ -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);