From 7de4a86f3f1bc8f16ed3c356ae8612c8d3462fad Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Sat, 2 Feb 2013 12:52:26 +0200 Subject: [PATCH] Get prey list to work properly with the customizable HUD --- data/hudVT.cfg | 16 ++++++++++++--- data/qcsrc/client/hud.qc | 42 ++++++++++++++++++++++++--------------- data/qcsrc/server/vore.qc | 6 +++--- 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/data/hudVT.cfg b/data/hudVT.cfg index 7072a139..a5f6b166 100644 --- a/data/hudVT.cfg +++ b/data/hudVT.cfg @@ -23,6 +23,16 @@ set hud_item_ammo_load_text_scale 12 set hud_item_clip_load_text_position "0.03 -0.89 0" set hud_item_clip_load_text_scale 16 -set hud_item_preylist_position "0 0 0" -set hud_item_preylist_scale "0.25 0.25 0" -set hud_item_preylist_items 9 \ No newline at end of file +set hud_item_preylist_spacing 1.25 +set hud_item_preylist_entries 9 +set hud_item_preylist_position "110 475 0" +set hud_item_preylist_scale "190 10 0" +set hud_item_preylist_colors_location 0 +set hud_item_preylist_colors_length 0.1 +set hud_item_preylist_name_location 0.1 +set hud_item_preylist_name_length 0.75 +set hud_item_preylist_health_icon_location 0.85 +set hud_item_preylist_health_icon_length 0.05 +set hud_item_preylist_health_text_location 0.9 +set hud_item_preylist_health_text_length 0.1 +set hud_item_preylist_items 9 diff --git a/data/qcsrc/client/hud.qc b/data/qcsrc/client/hud.qc index 16251aad..7ad5b9d8 100644 --- a/data/qcsrc/client/hud.qc +++ b/data/qcsrc/client/hud.qc @@ -959,6 +959,14 @@ void Sbar_PrintStomachboardItem(entity pl, vector position, vector dimensions) vector hl_color; field_number = 3; // the number of components each row has + // center defined position on the x axis + position_x -= dimensions_x / 2; + + // limit the font size to the maximum of the HUD + vector font_sz; + font_sz_x = bound(0, sbar_fontsize_x, dimensions_y); + font_sz_y = bound(0, sbar_fontsize_y, dimensions_y); + for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter) { vector pos, sz; @@ -984,32 +992,32 @@ void Sbar_PrintStomachboardItem(entity pl, vector position, vector dimensions) } if(field == ST_NAME) { - pos_x = position_x / 9; - sz_x = dimensions_x / 9; + pos_x = position_x + dimensions_x * cvar("hud_item_preylist_colors_location"); + sz_x = dimensions_x * cvar("hud_item_preylist_colors_length"); f = stof(getplayerkey(pl.sv_entnum, "colors")); drawpic(pos, "gfx/sb_playercolor_base", sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); drawpic(pos, "gfx/sb_playercolor_shirt", sz, colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL); drawpic(pos, "gfx/sb_playercolor_pants", sz, colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL); - pos_x = position_x / 4; - sz_x = dimensions_x / 4; - drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, '1 1 0' * sz_y, stringwidth_colors), '1 1 0' * sz_y, sbar_alpha_fg, DRAWFLAG_NORMAL); + pos_x = position_x + dimensions_x * cvar("hud_item_preylist_name_location"); + sz_x = dimensions_x * cvar("hud_item_preylist_name_length"); + drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL); } if(field == ST_HEALTH) { - pos_x = position_x / 1.05; - sz_x = sz_y = dimensions_y; + pos_x = position_x + dimensions_x * cvar("hud_item_preylist_health_icon_location"); + sz_x = dimensions_x * cvar("hud_item_preylist_health_icon_length"); if(pl.sv_entnum == player_localentnum - 1 || (spectatee_status && pl.sv_entnum == spectatee_status - 1)) - drawcolorcodedstring(pos, "self", sz, sbar_alpha_fg, DRAWFLAG_NORMAL); + drawcolorcodedstring(pos, textShortenToWidth("self", sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL); else { drawpic(pos, "gfx/hud/sb_health", sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - pos_x = position_x / 1.05; - sz_x = sz_y = dimensions_y; - drawcolorcodedstring(pos, str, sz, sbar_alpha_fg, DRAWFLAG_NORMAL); + pos_x = position_x + dimensions_x * cvar("hud_item_preylist_health_text_location"); + sz_x = dimensions_x * cvar("hud_item_preylist_health_text_length"); + drawcolorcodedstring(pos, textShortenToWidth(str, sz_x, font_sz, stringwidth_colors), font_sz, sbar_alpha_fg, DRAWFLAG_NORMAL); } } } @@ -1565,7 +1573,6 @@ void Sbar_DrawScoreboard() // print information about respawn status float respawn_time = getstatf(STAT_RESPAWN_TIME); - dprint(strcat(ftos(respawn_time), " --------\n")); if(respawn_time) { if(respawn_time < 0) @@ -3269,8 +3276,9 @@ void Sbar_Draw (void) entity pl, pred; float f, l; - pos = bottomleft; hud_total_prey = 0; + pos = stov(cvar_string("hud_item_preylist_position")); + vector sz = stov(cvar_string("hud_item_preylist_scale")); for(pl = players.sort_next; pl; pl = pl.sort_next) { if(pl.team == COLOR_SPECTATOR) @@ -3288,10 +3296,12 @@ void Sbar_Draw (void) if(f) { - if(l <= 8) // limit the stomach board to 9 entries due to the HUD design + if(l < cvar("hud_item_preylist_entries")) // limit the stomach board to the given number of entries { - Sbar_PrintStomachboardItem(pl, stov(cvar_string("hud_item_preylist_position")), stov(cvar_string("hud_item_preylist_scale"))); - pos_y += 1.1 * sbar_fontsize_y; + Sbar_PrintStomachboardItem(pl, pos, sz); + + // advance y position for each entry + pos_y += sz_y * cvar("hud_item_preylist_spacing"); l += 1; } ++hud_total_prey; diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index 54faf616..719a2b18 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -360,8 +360,8 @@ void Vore_SwallowStep(entity e) fill = cvar("g_balance_vore_swallow_speed_fill_player") * frametime; if(cvar("g_healthsize") && cvar("g_balance_vore_swallow_speed_fill_scalediff_player")) // fill rate depends on predator size compared to prey size fill *= pow(self.scale / e.scale, cvar("g_balance_vore_swallow_speed_fill_scalediff_player")); - if(cvar("g_balance_vore_swallow_speed_fill_player_stomachload") && e.stomach_load) // fill rate is influenced by the prey's stomach load - fill *= (1 - ((e.stomach_load / e.stomach_maxload) * bound(0, cvar("g_balance_vore_swallow_speed_fill_player_stomachload"), 1))); + if(cvar("g_balance_vore_swallow_speed_fill_stomachload") && e.stomach_load) // fill rate is influenced by the prey's stomach load + fill *= (1 - ((e.stomach_load / e.stomach_maxload) * bound(0, cvar("g_balance_vore_swallow_speed_fill_stomachload"), 1))); // skill-based speed offset for bots if(skill && cvar("skill_offset")) @@ -933,4 +933,4 @@ void Vore() // always position camera at the center of the stomach, to reduce probability of the view poking out self.view_ofs_z = PL_PREY_VIEW_OFS_z * self.predator.scale; -} \ No newline at end of file +} -- 2.39.2