X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Ftimer.qc;h=8bb4ade6a17f49aca0f69be10c5ffa303069af2f;hb=06a08d0c6b573f2562297147171aff3d990fa42d;hp=dc40368179d36f6e235175b786d26c8958593cb9;hpb=826222f84e886d85179a032b07edc71d99982040;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud/panel/timer.qc b/qcsrc/client/hud/panel/timer.qc index dc4036817..8bb4ade6a 100644 --- a/qcsrc/client/hud/panel/timer.qc +++ b/qcsrc/client/hud/panel/timer.qc @@ -1,4 +1,16 @@ #include "timer.qh" + +#include +#include +#include + +// Timer (#5) + +void HUD_Timer_Export(int fh) +{ + // allow saving cvars that aesthetically change the panel into hud skin files +} + void HUD_Timer() { if(!autocvar__hud_configure) @@ -6,7 +18,7 @@ void HUD_Timer() if(!autocvar_hud_panel_timer) return; } - HUD_Panel_UpdateCvars(); + HUD_Panel_LoadCvars(); draw_beginBoldFont(); @@ -14,7 +26,11 @@ void HUD_Timer() pos = panel_pos; mySize = panel_size; - HUD_Panel_DrawBg(1); + if (autocvar_hud_panel_timer_dynamichud) + HUD_Scale_Enable(); + else + HUD_Scale_Disable(); + HUD_Panel_DrawBg(); if(panel_bg_padding) { pos += '1 1 0' * panel_bg_padding; @@ -22,7 +38,7 @@ void HUD_Timer() } string timer; - float timelimit, elapsedTime, timeleft, minutesLeft; + float timelimit, timeleft, minutesLeft; timelimit = STAT(TIMELIMIT); @@ -31,24 +47,39 @@ void HUD_Timer() minutesLeft = floor(timeleft / 60); + float warmup_timeleft = 0; + if(warmup_stage) + { + float warmup_timelimit = STAT(WARMUP_TIMELIMIT); + if(warmup_timelimit > 0) + warmup_timeleft = max(0, warmup_timelimit - time); + else if(warmup_timelimit == 0) + warmup_timeleft = timeleft; + warmup_timeleft = ceil(warmup_timeleft); + } + vector timer_color; - if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit + if(intermission_time || minutesLeft >= 5 || warmup_stage || timelimit == 0) timer_color = '1 1 1'; //white else if(minutesLeft >= 1) timer_color = '1 1 0'; //yellow else timer_color = '1 0 0'; //red - if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) { - if (time < STAT(GAMESTARTTIME)) { - //while restart is still active, show 00:00 - timer = seconds_tostring(0); - } else { - elapsedTime = floor(time - STAT(GAMESTARTTIME)); //127 - timer = seconds_tostring(elapsedTime); - } + if (intermission_time) { + timer = seconds_tostring(max(0, floor(intermission_time - STAT(GAMESTARTTIME)))); + } else if (warmup_stage && warmup_timeleft >= 60) { + timer = _("WARMUP"); + } else if (autocvar_hud_panel_timer_increment || (!warmup_stage && timelimit == 0) || (warmup_stage && warmup_timeleft <= 0)) { + if (time < STAT(GAMESTARTTIME)) + timer = seconds_tostring(0); //while restart is still active, show 00:00 + else + timer = seconds_tostring(floor(time - STAT(GAMESTARTTIME))); } else { - timer = seconds_tostring(timeleft); + if(warmup_stage) + timer = seconds_tostring(warmup_timeleft); + else + timer = seconds_tostring(timeleft); } drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);