X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Fcenterprint.qc;h=d5601e5a34f86387a532baef847a42e52f903793;hb=87390523a589c3bb63ee6826efe4a261544d7241;hp=e2e82acffe4efa33ab7275d2bfdb776399da0f70;hpb=c13fdf2b49eff1d26abc73d42e33636162a9b527;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index e2e82acff..d5601e5a3 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -1,6 +1,9 @@ #include "centerprint.qh" -#include +#include "scoreboard.qh" +#include +#include +#include // CenterPrint (#16) @@ -17,7 +20,7 @@ bool centerprint_showing; void centerprint_generic(int new_id, string strMessage, float duration, int countdown_num) { - TC(int, new_id); TC(int, countdown_num); + TC(int, new_id); TC(int, countdown_num); //printf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num); int i, j; @@ -57,8 +60,7 @@ void centerprint_generic(int new_id, string strMessage, float duration, int coun { // fade out the current msg (duration and countdown_num are ignored) centerprint_time[j] = min(5, autocvar_hud_panel_centerprint_fade_out); - if (centerprint_expire_time[j] > time + min(5, autocvar_hud_panel_centerprint_fade_out) || centerprint_expire_time[j] < time) - centerprint_expire_time[j] = time + min(5, autocvar_hud_panel_centerprint_fade_out); + centerprint_expire_time[j] = -1; // don't use the variable time here! return; } break; // found a msg with the same id, at position j @@ -73,28 +75,26 @@ void centerprint_generic(int new_id, string strMessage, float duration, int coun cpm_index = CENTERPRINT_MAX_MSGS - 1; j = cpm_index; } - if(centerprint_messages[j]) - strunzone(centerprint_messages[j]); - centerprint_messages[j] = strzone(strMessage); + strcpy(centerprint_messages[j], strMessage); centerprint_msgID[j] = new_id; if (duration < 0) { centerprint_time[j] = -1; - centerprint_expire_time[j] = time; + centerprint_expire_time[j] = -1; // don't use the variable time here! } else { if(duration == 0) duration = max(1, autocvar_hud_panel_centerprint_time); centerprint_time[j] = duration; - centerprint_expire_time[j] = time + duration; + centerprint_expire_time[j] = -1; // don't use the variable time here! } centerprint_countdown_num[j] = countdown_num; } void centerprint_kill(int id) { - TC(int, id); + TC(int, id); centerprint_generic(id, "", 0, 0); } @@ -110,9 +110,7 @@ void reset_centerprint_messages() centerprint_expire_time[i] = 0; centerprint_time[i] = 1; centerprint_msgID[i] = 0; - if(centerprint_messages[i]) - strunzone(centerprint_messages[i]); - centerprint_messages[i] = string_null; + strfree(centerprint_messages[i]); } } float hud_configure_cp_generation_time; @@ -139,49 +137,38 @@ void HUD_CenterPrint () float r; r = random(); if (r > 0.8) - centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: ^COUNT"), 1, 10); + centerprint_generic(floor(r*1000), sprintf(_("^3Countdown message at time %s, seconds left: ^COUNT"), seconds_tostring(time)), 1, 10); else if (r > 0.55) - centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0); + centerprint_generic(0, sprintf(_("^1Multiline message at time %s that\n^1lasts longer than normal"), seconds_tostring(time)), 20, 0); else - centerprint_hud(sprintf("Message at time %s", seconds_tostring(time))); + centerprint_hud(sprintf(_("Message at time %s"), seconds_tostring(time))); hud_configure_cp_generation_time = time + 1 + random()*4; } else { - centerprint_generic(0, sprintf("Centerprint message", seconds_tostring(time)), 10, 0); + centerprint_generic(0, _("Generic message"), 10, 0); hud_configure_cp_generation_time = time + 10 - random()*3; } } } - // this panel fades only when the menu does - float hud_fade_alpha_save = 0; - if(scoreboard_fade_alpha) - { - hud_fade_alpha_save = hud_fade_alpha; - hud_fade_alpha = 1 - autocvar__menu_alpha; - } - HUD_Panel_UpdateCvars(); + HUD_Panel_LoadCvars(); if ( HUD_Radar_Clickable() ) { if (hud_panel_radar_bottom >= 0.96 * vid_conheight) return; - panel_pos = eY * hud_panel_radar_bottom + eX * 0.5 * (vid_conwidth - panel_size_x); - panel_size_y = min(panel_size_y, vid_conheight - hud_panel_radar_bottom); + panel_pos.x = 0.5 * (vid_conwidth - panel_size.x); + panel_pos.y = hud_panel_radar_bottom; + panel_size.y = min(panel_size.y, vid_conheight - hud_panel_radar_bottom); } - else if(scoreboard_fade_alpha) + else if(!autocvar__hud_configure && scoreboard_fade_alpha) { - hud_fade_alpha = hud_fade_alpha_save; - // move the panel below the scoreboard if (scoreboard_bottom >= 0.96 * vid_conheight) return; - vector target_pos; - - target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size.x); - + vector target_pos = vec2(0.5 * (vid_conwidth - panel_size.x), scoreboard_bottom); if(target_pos.y > panel_pos.y) { panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha); @@ -193,7 +180,7 @@ void HUD_CenterPrint () HUD_Scale_Enable(); else HUD_Scale_Disable(); - HUD_Panel_DrawBg(1); + HUD_Panel_DrawBg(); if (!centerprint_showing) return; @@ -228,6 +215,13 @@ void HUD_CenterPrint () { if (j == CENTERPRINT_MAX_MSGS) j = 0; + if (centerprint_expire_time[j] == -1) + { + // here we are sure the time variable is not altered by CSQC_Ent_Update + centerprint_expire_time[j] = time; + if (centerprint_time[j] > 0) + centerprint_expire_time[j] += centerprint_time[j]; + } if (centerprint_expire_time[j] <= time) { if (centerprint_countdown_num[j] && centerprint_time[j] > 0) @@ -251,6 +245,9 @@ void HUD_CenterPrint () else // Expiring soon, so fade it out. a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out); + if(centerprint_msgID[j] == CPID_TIMEIN) + a = 1; + // while counting down show it anyway in order to hold the current message position if (a <= 0.5/255.0 && centerprint_countdown_num[j] == 0) // Guaranteed invisible - don't show. continue;