]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Hud editor: allow displaying more than one vertical line at the desired position
authorterencehill <piuntn@gmail.com>
Mon, 10 Apr 2023 21:49:20 +0000 (23:49 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 10 Apr 2023 21:49:20 +0000 (23:49 +0200)
_hud_common.cfg
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/hud_config.qh

index 0028a732265d8f9dfec02bf3b604ed8a38a88a27..5f03a479038da70ac91d1bba2db29a0683d22d0c 100644 (file)
@@ -4,6 +4,7 @@ seta hud_configure_teamcolorforced 0 "1 = force display of team colors in config
 seta hud_configure_checkcollisions 0 "check for collisions against other panels when in hud configure mode"
 seta hud_configure_bg_minalpha 0.25 "minimum panel background alpha when in hud configure mode"
 seta hud_configure_grid_alpha 0.15 "alpha for visible grid when in configure mode"
+seta hud_configure_vertical_lines 0.5 "list of space-separated intervals at which to draw a vertical line, useful for aligning panels; e.g. 0.5 draws a vertical line in the center, \"0.25 0.5 0.75\" draws a vertical line every quarter of the screen width"
 
 seta hud_cursormode 1 "handle mouse input in cursor mode when CSQC displays a cursor"
 
index ac4d48a422553d04e70f036069b77b9f1b2b25fd..8bdf0c4b8cdca708c3f1de89082c5d72b7a3183d 100644 (file)
@@ -1056,7 +1056,12 @@ void HUD_Configure_DrawGrid()
                vector s;
                // vertical center line, wider than vertical grid lines so that it's more visible
                // NOTE: depending on grid size the vertical center line may not overlap any vertical grid line
-               drawfill(eX * (0.5 * vid_conwidth - 1), vec2(3, vid_conheight), '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
+               int n = tokenize(autocvar_hud_configure_vertical_lines);
+               for (i = 0; i < n; ++i)
+               {
+                       float xpos_rel = stof(argv(i));
+                       drawfill(eX * (xpos_rel * vid_conwidth - 1), vec2(3, vid_conheight), '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
+               }
                // x-axis
                s = vec2(1, vid_conheight);
                for(i = 1; i < 1/hud_configure_gridSize.x; ++i)
@@ -1124,15 +1129,20 @@ void HUD_Panel_HlCenterLine(float myBorder)
        if (time > hud_configure_centerline_time)
                return;
        float panel_centerpos_x = (panel_pos.x + panel_size.x * 0.5);
-       float ofs = fabs(panel_centerpos_x / vid_conwidth - 0.5);
-       if (ofs < 0.02) // don't bother showing the center line if it's evident that the panel is not centered
+       int n = tokenize(autocvar_hud_configure_vertical_lines);
+       for (int i = 0; i < n; ++i)
        {
-               float f = map_bound_ranges(ofs, 0.001, 0.01, 0, 1);
-               vector col = '1 0 0' * f + '0 1 0' * (1 - f); // from red (far) to green (close)
-               float theAlpha = 0.3 + 0.1 * sin(6 * time); // blink
-               theAlpha *= (1 - autocvar__menu_alpha) * bound(0, hud_configure_centerline_time - time, 0.5) * 2; // fade
-               vector pos = vec2(panel_centerpos_x - 1, panel_pos.y - myBorder);
-               drawfill(pos, vec2(3, panel_size.y + 2 * myBorder), col, theAlpha, DRAWFLAG_NORMAL);
+               float xpos_rel = stof(argv(i));
+               float ofs = fabs(panel_centerpos_x / vid_conwidth - xpos_rel);
+               if (ofs < 0.02) // don't bother showing the center line if it's evident that the panel is not centered
+               {
+                       float f = map_bound_ranges(ofs, 0.001, 0.01, 0, 1);
+                       vector col = '1 0 0' * f + '0 1 0' * (1 - f); // from red (far) to green (close)
+                       float theAlpha = 0.3 + 0.1 * sin(6 * time); // blink
+                       theAlpha *= (1 - autocvar__menu_alpha) * bound(0, hud_configure_centerline_time - time, 0.5) * 2; // fade
+                       vector pos = vec2(panel_centerpos_x - 1, panel_pos.y - myBorder);
+                       drawfill(pos, vec2(3, panel_size.y + 2 * myBorder), col, theAlpha, DRAWFLAG_NORMAL);
+               }
        }
 }
 
index 79558c259dfd524b4ccd8e3526357f8321af3b99..81182c65af6a50c5a52df26e042d5f593abd6f8e 100644 (file)
@@ -4,6 +4,7 @@ bool autocvar__hud_configure;
 bool autocvar_hud_configure_checkcollisions;
 bool autocvar_hud_configure_grid;
 float autocvar_hud_configure_grid_alpha;
+string autocvar_hud_configure_vertical_lines = "0.5";
 bool autocvar_hud_configure_teamcolorforced;
 
 const int S_MOUSE1 = 1;