]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Load csqc cursor attributes from the current menu skin file rather than using constan... 283/head
authorterencehill <piuntn@gmail.com>
Sun, 7 Feb 2016 18:33:06 +0000 (19:33 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 7 Feb 2016 18:33:06 +0000 (19:33 +0100)
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/panel/radar.qc
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/client/mapvoting.qc
qcsrc/client/quickmenu.qc

index 9ca2a0ab5226f529c42af92c81777f13644c71f0..2ba78f798a1e45816a03043bbcafe2251fc3efe5 100644 (file)
@@ -1192,17 +1192,16 @@ void HUD_Panel_Mouse()
                        drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
        }
        // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
                        drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
        }
        // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
-       const vector cursorsize = '32 32 0';
        float cursor_alpha = 1 - autocvar__menu_alpha;
 
        if(!mouse_over_panel)
        float cursor_alpha = 1 - autocvar__menu_alpha;
 
        if(!mouse_over_panel)
-               drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
+               draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
        else if(mouse_over_panel == 1)
        else if(mouse_over_panel == 1)
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
+               draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
        else if(mouse_over_panel == 2)
        else if(mouse_over_panel == 2)
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
+               draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
        else
        else
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
+               draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
 
        prevMouseClicked = mouseClicked;
 }
 
        prevMouseClicked = mouseClicked;
 }
index 2082f70b1a3246046544fdff356918c62f311370..07677fcc42b59c974cae189164ee458127afe286 100644 (file)
@@ -156,8 +156,7 @@ void HUD_Radar_Mouse()
        }
 
 
        }
 
 
-       const vector cursor_size = '32 32 0';
-       drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursor_size, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+       draw_cursor_normal(mousepos, '1 1 1', 0.8);
 }
 
 void HUD_Radar()
 }
 
 void HUD_Radar()
index 0dcf6811dec488dd5306781bafd43956d6f5ba84..aa490aa505c21e8c38fc46c52f0813da9b266ed8 100644 (file)
 
 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
 
 
 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
 
+void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
+{
+       ofs = eX * (ofs.x * SIZE_CURSOR.x) + eY * (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
 
 // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
 // Useful for precaching things
 
@@ -125,26 +177,7 @@ void CSQC_Init()
        }
 
        hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
        }
 
        hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
-
-       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);
+       LoadMenuSkinValues();
 }
 
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
 }
 
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
index bed4daa268dc2a4afbe08995d70d7b3930913ca7..084dfba2f81ae92ca1a577c232b00353dedbf635 100644 (file)
@@ -40,6 +40,13 @@ float gametype;
 
 float FONT_USER = 8;
 
 
 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();
+
 // --------------------------------------------------------------------------
 // Scoreboard stuff
 
 // --------------------------------------------------------------------------
 // Scoreboard stuff
 
index 30c938aa33401debe100ee30941a2196ed04e22d..7071231651b2b69149bbbd2bf226abfe1df95496 100644 (file)
@@ -482,7 +482,7 @@ void MapVote_Draw()
                MapVote_DrawAbstain(pos, dist.x, xmax - xmin, tmp, i);
        }
 
                MapVote_DrawAbstain(pos, dist.x, xmax - xmin, tmp, i);
        }
 
-       drawpic(mv_mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), '32 32 0', '1 1 1', 1 - autocvar__menu_alpha, DRAWFLAG_NORMAL);
+       draw_cursor_normal(mv_mousepos, '1 1 1', 1 - autocvar__menu_alpha);
 }
 
 void Cmd_MapVote_MapDownload(float argc)
 }
 
 void Cmd_MapVote_MapDownload(float argc)
index 90f6c171c88c621a3b7b72ad3631f62bec7c87e7..63416f2b017cf31cb35a1f58f37c9dc023c186cb 100644 (file)
@@ -531,8 +531,7 @@ void QuickMenu_Mouse()
                }
        }
 
                }
        }
 
-       vector cursorsize = '32 32 0';
-       drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+       draw_cursor_normal(mousepos, '1 1 1', 0.8);
 
        prevMouseClicked = mouseClicked;
 }
 
        prevMouseClicked = mouseClicked;
 }