]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/hud.qc
Get prey list to work properly with the customizable HUD
[voretournament/voretournament.git] / data / qcsrc / client / hud.qc
index 16251aad7c5b253c6e7a98db74d23ddf0513e0cf..7ad5b9d86a5a3ae0297d8f071698271b6ed0aac9 100644 (file)
@@ -959,6 +959,14 @@ void Sbar_PrintStomachboardItem(entity pl, vector position, vector dimensions)
        vector hl_color;\r
        field_number = 3; // the number of components each row has\r
 \r
+       // center defined position on the x axis\r
+       position_x -= dimensions_x / 2;\r
+\r
+       // limit the font size to the maximum of the HUD\r
+       vector font_sz;\r
+       font_sz_x = bound(0, sbar_fontsize_x, dimensions_y);\r
+       font_sz_y = bound(0, sbar_fontsize_y, dimensions_y);\r
+\r
        for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)\r
        {\r
                vector pos, sz;\r
@@ -984,32 +992,32 @@ void Sbar_PrintStomachboardItem(entity pl, vector position, vector dimensions)
                }\r
 \r
                if(field == ST_NAME) {\r
-                       pos_x = position_x / 9;\r
-                       sz_x = dimensions_x / 9;\r
+                       pos_x = position_x + dimensions_x * cvar("hud_item_preylist_colors_location");\r
+                       sz_x = dimensions_x * cvar("hud_item_preylist_colors_length");\r
 \r
                        f = stof(getplayerkey(pl.sv_entnum, "colors"));\r
                        drawpic(pos, "gfx/sb_playercolor_base", sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                        drawpic(pos, "gfx/sb_playercolor_shirt", sz, colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                        drawpic(pos, "gfx/sb_playercolor_pants", sz, colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
-                       pos_x = position_x / 4;\r
-                       sz_x = dimensions_x / 4;\r
-                       drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, '1 1 0' * sz_y, stringwidth_colors), '1 1 0' * sz_y, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                       pos_x = position_x + dimensions_x * cvar("hud_item_preylist_name_location");\r
+                       sz_x = dimensions_x * cvar("hud_item_preylist_name_length");\r
+                       drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                }\r
 \r
                if(field == ST_HEALTH) {\r
-                       pos_x = position_x / 1.05;\r
-                       sz_x = sz_y = dimensions_y;\r
+                       pos_x = position_x + dimensions_x * cvar("hud_item_preylist_health_icon_location");\r
+                       sz_x = dimensions_x * cvar("hud_item_preylist_health_icon_length");\r
 \r
                        if(pl.sv_entnum == player_localentnum - 1 || (spectatee_status && pl.sv_entnum == spectatee_status - 1))\r
-                               drawcolorcodedstring(pos, "self", sz, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                               drawcolorcodedstring(pos, textShortenToWidth("self", sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                        else\r
                        {\r
                                drawpic(pos, "gfx/hud/sb_health", sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
-                               pos_x = position_x / 1.05;\r
-                               sz_x = sz_y = dimensions_y;\r
-                               drawcolorcodedstring(pos, str, sz, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                               pos_x = position_x + dimensions_x * cvar("hud_item_preylist_health_text_location");\r
+                               sz_x = dimensions_x * cvar("hud_item_preylist_health_text_length");\r
+                               drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                        }\r
                }\r
        }\r
@@ -1565,7 +1573,6 @@ void Sbar_DrawScoreboard()
 \r
        // print information about respawn status\r
        float respawn_time = getstatf(STAT_RESPAWN_TIME);\r
-       dprint(strcat(ftos(respawn_time), " --------\n"));\r
        if(respawn_time)\r
        {\r
                if(respawn_time < 0)\r
@@ -3269,8 +3276,9 @@ void Sbar_Draw (void)
                        entity pl, pred;\r
                        float f, l;\r
 \r
-                       pos = bottomleft;\r
                        hud_total_prey = 0;\r
+                       pos = stov(cvar_string("hud_item_preylist_position"));\r
+                       vector sz = stov(cvar_string("hud_item_preylist_scale"));\r
                        for(pl = players.sort_next; pl; pl = pl.sort_next)\r
                        {\r
                                if(pl.team == COLOR_SPECTATOR)\r
@@ -3288,10 +3296,12 @@ void Sbar_Draw (void)
 \r
                                if(f)\r
                                {\r
-                                       if(l <= 8) // limit the stomach board to 9 entries due to the HUD design\r
+                                       if(l < cvar("hud_item_preylist_entries")) // limit the stomach board to the given number of entries\r
                                        {\r
-                                               Sbar_PrintStomachboardItem(pl, stov(cvar_string("hud_item_preylist_position")), stov(cvar_string("hud_item_preylist_scale")));\r
-                                               pos_y += 1.1 * sbar_fontsize_y;\r
+                                               Sbar_PrintStomachboardItem(pl, pos, sz);\r
+\r
+                                               // advance y position for each entry\r
+                                               pos_y += sz_y * cvar("hud_item_preylist_spacing");\r
                                                l += 1;\r
                                        }\r
                                        ++hud_total_prey;\r