gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
if(msg == MSG_SUICIDE) {
if (type == DEATH_TEAMCHANGE) {
- centerprint(strcat(sprintf(_("You are now on: %s"), s1)));
+ centerprint(sprintf(_("You are now on: %s"), s1));
} else if (type == DEATH_AUTOTEAMCHANGE) {
centerprint(sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1));
} else if (type == DEATH_CAMP) {
} else if(msg == MSG_KILL) {
if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
if(gentle) {
- centerprint(strcat(sprintf(_("^1Moron! You went against ^7%s^1, a team mate!"), s1)));
+ centerprint(sprintf(_("^1Moron! You went against ^7%s^1, a team mate!"), s1));
} else {
- centerprint(strcat(sprintf(_("^1Moron! You fragged ^7%s^1, a team mate!"), s1)));
+ centerprint(sprintf(_("^1Moron! You fragged ^7%s^1, a team mate!"), s1));
}
} else if (type == KILL_FIRST_BLOOD) {
if(gentle) {
pos = panel_pos;
mySize = panel_size;
- a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
+ a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
HUD_Panel_DrawBg(a);
a = panel_fg_alpha * a;
drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
}
- else if(vote_highlighted == 2) {
+ else if(vote_highlighted == -1) {
drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
}
}
drawresetcliparea();
-
- if(!vote_active) {
- vote_highlighted = 0;
- }
}
// Mod icons panel (#10)
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_physics) return;
- if(spectatee_status == -1 && autocvar_hud_panel_physics < 2) return;
+ if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return;
+ if(autocvar_hud_panel_physics == 3 && !(gametype == GAME_RACE || gametype == GAME_CTS)) return;
}
else
hud_configure_active_panel = HUD_PANEL_PHYSICS;
drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
}
+// CenterPrint (#16)
+//
#define CENTERPRINT_MAX_MSGS 10
#define CENTERPRINT_MAX_ENTRIES 50
+#define CENTERPRINT_SPACING 0.7
float cpm_index;
string centerprint_messages[CENTERPRINT_MAX_MSGS];
float centerprint_msgID[CENTERPRINT_MAX_MSGS];
float centerprint_time[CENTERPRINT_MAX_MSGS];
float centerprint_expire_time[CENTERPRINT_MAX_MSGS];
float centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
+float centerprint_fadetime;
+float centerprint_showing;
void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num)
{
if(strMessage == "" && new_id == 0)
return;
- if(duration == 0)
- duration = max(1, autocvar_hud_panel_centerprint_time);
+ if (!centerprint_showing)
+ centerprint_showing = TRUE;
+
+ centerprint_fadetime = bound(0, autocvar_hud_panel_centerprint_fadetime, 1);
for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
{
if (j == CENTERPRINT_MAX_MSGS)
j = 0;
if (new_id && new_id == centerprint_msgID[j])
+ {
+ if (strMessage == "" && centerprint_messages[j] != "" && centerprint_countdown_num[j] == 0)
+ {
+ // fade out the current msg (duration and countdown_num are ignored)
+ centerprint_time[j] = centerprint_fadetime;
+ if (centerprint_expire_time[j] > time + centerprint_fadetime || centerprint_expire_time[j] < time)
+ centerprint_expire_time[j] = time + centerprint_fadetime;
+ return;
+ }
break; // found a msg with the same id, at position j
+ }
}
if (i == CENTERPRINT_MAX_MSGS)
centerprint_time[j] = -1;
else
{
+ if(duration == 0)
+ duration = max(1, autocvar_hud_panel_centerprint_time);
centerprint_time[j] = duration;
centerprint_expire_time[j] = time + duration;
}
centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0);
}
-// CenterPrint (#16)
-//
-float hud_configure_cp_generation_time;
void reset_centerprint_messages(void)
{
float i;
centerprint_msgID[i] = 0;
if(centerprint_messages[i])
strunzone(centerprint_messages[i]);
- centerprint_messages[i] = strzone("");
+ centerprint_messages[i] = string_null;
}
}
+float hud_configure_cp_generation_time;
void HUD_CenterPrint (void)
{
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_centerprint) return;
- if (hud_configure_prev)
+ if (hud_configure_prev && hud_configure_prev != -1)
reset_centerprint_messages();
}
else
}
HUD_Panel_DrawBg(1);
+
+ if (!centerprint_showing)
+ return;
+
if(panel_bg_padding)
{
panel_pos += '1 1 0' * panel_bg_padding;
entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
float i, j, k, n;
- float a, sz, fade, align, current_msg_pos_y;
+ float a, sz, align, current_msg_pos_y, msg_size;
vector pos;
string ts;
+ n = -1; // if no msg will be displayed, n stays -1
+
pos = panel_pos;
if (autocvar_hud_panel_centerprint_flip)
pos_y += panel_size_y;
- fade = min(autocvar_hud_panel_centerprint_time/8, 0.25);
align = bound(0, autocvar_hud_panel_centerprint_align, 1);
for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
{
if (j == CENTERPRINT_MAX_MSGS)
j = 0;
- if (centerprint_time[j] > 0 && centerprint_expire_time[j] < time)
+ if (centerprint_expire_time[j] < time)
{
- if (centerprint_countdown_num[j])
+ if (centerprint_countdown_num[j] && centerprint_time[j] > 0)
{
centerprint_countdown_num[j] = centerprint_countdown_num[j] - 1;
if (centerprint_countdown_num[j] == 0)
else
continue;
}
- if (centerprint_time[j] < 0 || centerprint_expire_time[j] - fade > time)
+
+ //print("testing: ", ftos(time - (centerprint_expire_time[j] - centerprint_time[j])), ". \n");
+ if (centerprint_time[j] < 0 || centerprint_expire_time[j] - centerprint_fadetime > time)
{
- a = 1;
- sz = 1;
+ a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / centerprint_fadetime, 1);
+ sz = 0.8 + a * (1 - 0.8);
}
else if (centerprint_expire_time[j] > time)
{
- a = (centerprint_expire_time[j] - time) / fade;
+ a = (centerprint_expire_time[j] - time) / centerprint_fadetime;
sz = 0.8 + a * (1 - 0.8);
}
for(k = 0; k < n; ++k)
{
getWrappedLine_remaining = argv(k);
- ts = getWrappedLine(panel_size_x, fontsize, stringwidth_colors);
- if (ts != "")
- pos_y -= fontsize_y;
- else
- pos_y -= fontsize_y * 0.35;
- if (pos_y < panel_pos_y) // check if the next line can be shown
- return;
+ while(getWrappedLine_remaining)
+ {
+ ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
+ if (ts != "")
+ pos_y -= fontsize_y;
+ else
+ pos_y -= fontsize_y * CENTERPRINT_SPACING/2;
+ if (pos_y < panel_pos_y) // check if the next line can be shown
+ {
+ drawfontscale = '1 1 0';
+ return;
+ }
+ }
}
current_msg_pos_y = pos_y; // save starting pos (first line) of the current message
}
+ msg_size = pos_y;
for(k = 0; k < n; ++k)
{
getWrappedLine_remaining = argv(k);
while(getWrappedLine_remaining)
{
- ts = getWrappedLine(panel_size_x, fontsize, stringwidth_colors);
+ ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
if (ts != "")
{
if (align)
pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align;
- drawcolorcodedstring(pos + '0 1 0' * 1.5 * (1 - sz) * fontsize_y, ts, fontsize, a * panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a * panel_fg_alpha, DRAWFLAG_NORMAL);
pos_y += fontsize_y;
}
else
- pos_y += fontsize_y * 0.35;
+ pos_y += fontsize_y * CENTERPRINT_SPACING/2;
if (!autocvar_hud_panel_centerprint_flip && pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next line can be shown
{
drawfontscale = '1 1 0';
}
}
}
+ msg_size = pos_y - msg_size;
if (autocvar_hud_panel_centerprint_flip)
{
- pos_y = current_msg_pos_y - 0.7 * fontsize_y;
+ pos_y = current_msg_pos_y - CENTERPRINT_SPACING * fontsize_y;
if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
- pos_y += 1.5 * fontsize_y * (1 - a*a);
+ pos_y += (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(a));
}
else
{
- pos_y += 0.7 * fontsize_y;
+ pos_y += CENTERPRINT_SPACING * fontsize_y;
if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
- pos_y -= 1.5 * fontsize_y * (1 - a*a);
+ pos_y -= (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(a));
}
- drawfontscale = '1 1 0';
+ }
+ drawfontscale = '1 1 0';
+ if (n == -1)
+ {
+ centerprint_showing = FALSE;
+ reset_centerprint_messages();
}
}