strcpy(prev_pl2_name, pl2_name);
// There are new duelers, update title
- float offset = stringwidth(pl2_name, true, hud_fontsize) - stringwidth(pl1_name, true, hud_fontsize) - 1;
- centerprint_SetTitle(sprintf("^BG%s^BG %s %s", pl1_name, _("vs"), pl2_name), offset / 2);
+ centerprint_SetDuelTitle(pl1_name, pl2_name, _("vs"));
}
void Announcer_ClearTitle()
if (gametype.m_1v1)
Announcer_Duel();
else
- centerprint_SetTitle(strcat("^BG", MapInfo_Type_ToText(gametype)), 0); // Show game type as title
+ centerprint_SetTitle(strcat("^BG", MapInfo_Type_ToText(gametype))); // Show game type as title
if(time + 5.0 < startTime) // if connecting to server while restart was active don't always play prepareforbattle
Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
bool centerprint_showing;
string centerprint_title;
-float centerprint_title_offset;
+string centerprint_title_left;
+string centerprint_title_right;
void centerprint_Add(int new_id, string strMessage, float duration, int countdown_num)
{
}
}
-void centerprint_ClearTitle()
+void centerprint_SetDuelTitle(string left, string right, string div)
{
- strfree(centerprint_title);
- centerprint_title_offset = 0;
+ strcpy(centerprint_title_left, left);
+ strcpy(centerprint_title_right, right);
+ centerprint_SetTitle(sprintf("^BG%s^BG %s %s", left, div, right));
}
-void centerprint_SetTitle(string title, float offset)
+void centerprint_SetTitle(string title)
{
- if(title != centerprint_title) {
+ if(title != centerprint_title)
strcpy(centerprint_title, CCR(title));
- centerprint_title_offset = offset;
- }
+}
+
+void centerprint_ClearTitle()
+{
+ strfree(centerprint_title);
+ strfree(centerprint_title_left);
+ strfree(centerprint_title_right);
}
float hud_configure_cp_generation_time;
{
if(highlightedPanel == HUD_PANEL(CENTERPRINT))
{
- centerprint_SetTitle(sprintf(_("Title at %s"), seconds_tostring(hud_configure_cp_generation_time)), 0);
+ centerprint_SetTitle(sprintf(_("Title at %s"), seconds_tostring(hud_configure_cp_generation_time)));
float r;
r = random();
if (autocvar_hud_panel_centerprint_flip)
pos.y -= fontsize.y;
- if (centerprint_title_offset && align == 0.5)
- pos.x += centerprint_title_offset * CENTERPRINT_BASE_SIZE * autocvar_hud_panel_centerprint_fontscale_title;
+ if (centerprint_title_left != "" && align == 0.5) // Center line at the main word (for duels)
+ pos.x += (stringwidth(centerprint_title_right, true, fontsize) - stringwidth(centerprint_title_left, true, fontsize)) / 2;
drawcolorcodedstring(pos, centerprint_title, fontsize, 1, DRAWFLAG_NORMAL);