3 #include <client/draw.qh>
4 #include <client/hud/hud.qh>
5 #include <client/hud/panel/timer.qh>
6 #include <common/items/inventory.qh>
10 void HUD_Pickup_Export(int fh)
12 // allow saving cvars that aesthetically change the panel into hud skin files
15 void Pickup_Update(entity it, int count)
17 if(last_pickup_item != it || time - STAT(LAST_PICKUP) > autocvar_hud_panel_pickup_time)
18 last_pickup_count = 0;
19 last_pickup_item = it;
20 last_pickup_count += count;
23 float HUD_Pickup_Time(float t)
25 float timelimit = (warmup_stage ? STAT(WARMUP_TIMELIMIT) : STAT(TIMELIMIT) * 60);
27 if(autocvar_hud_panel_timer_increment || timelimit <= 0)
28 return floor(t - STAT(GAMESTARTTIME));
30 return ceil(timelimit + STAT(GAMESTARTTIME) - t);
35 if(!autocvar_hud_panel_pickup) return;
37 HUD_Panel_LoadCvars();
42 if (autocvar_hud_panel_pickup_dynamichud)
49 pos += '1 1 0' * panel_bg_padding;
50 mySize -= '2 2 0' * panel_bg_padding;
53 float last_pickup_time = STAT(LAST_PICKUP);
54 float display_time = min(5, autocvar_hud_panel_pickup_time);
55 entity it = last_pickup_item;
57 if((last_pickup_time && last_pickup_time > time - display_time && it) || autocvar__hud_configure) {
58 string str_timer, str_name, icon;
60 vector fontsize = '1 1 0' * mySize.y;
61 vector iconsize = fontsize * autocvar_hud_panel_pickup_iconsize;
63 if(autocvar__hud_configure)
64 icon = strcat(hud_skin_path, "/armor_mega");
66 icon = strcat(hud_skin_path, "/", ((it.model2) ? it.model2 : it.m_icon));
68 sz = draw_getimagesize(icon);
69 sz2 = vec2(iconsize.y*(sz.x/sz.y), iconsize.y);
70 if(autocvar__hud_configure)
71 str_name = "Mega armor";
73 str_name = ((last_pickup_count > 1) ? sprintf("%s (x%d)", it.m_name, last_pickup_count) : it.m_name);
76 float fade_out_time = min(display_time, autocvar_hud_panel_pickup_fade_out);
78 if(autocvar__hud_configure)
80 else if(time < last_pickup_time + display_time - fade_out_time)
83 a = (last_pickup_time + display_time - time) / fade_out_time;
85 if(autocvar_hud_panel_pickup_showtimer) {
86 // 1 will show the timer always
87 // 2 will show the timer only if spectating
88 // forbid serverflag will force the 2nd behavior
89 if((autocvar_hud_panel_pickup_showtimer == 1 && !(serverflags & SERVERFLAG_FORBID_PICKUPTIMER)) || spectatee_status)
91 if(autocvar__hud_configure)
94 str_timer = seconds_tostring(HUD_Pickup_Time(last_pickup_time));
95 drawstring(pos, str_timer, fontsize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
96 pos.x += stringwidth(str_timer, false, fontsize) + fontsize.x * 0.25;
100 drawpic(pos - eY * ((iconsize.y - fontsize.y) / 2), icon, sz2, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
101 pos.x += sz2.x + fontsize.x * 0.25;
102 str_name = textShortenToWidth(str_name, mySize.x - (pos.x - panel_pos.x), fontsize, stringwidth_nocolors);
103 drawstring(pos, str_name, fontsize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);