Merge branch 'master' into terencehill/centerprint_stuff
authorterencehill <piuntn@gmail.com>
Tue, 24 May 2011 14:12:36 +0000 (16:12 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 24 May 2011 14:12:36 +0000 (16:12 +0200)
17 files changed:
hud_luminos.cfg
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/hud_config.qc
qcsrc/client/miscfunctions.qc
qcsrc/common/constants.qh
qcsrc/common/util.qh
qcsrc/server/arena.qc
qcsrc/server/campaign.qc
qcsrc/server/cl_client.qc
qcsrc/server/g_damage.qc
qcsrc/server/mutators/mutator_nix.qc
qcsrc/server/t_items.qc
qcsrc/server/teamplay.qc
qcsrc/server/w_minstanex.qc

index 4c11d42..372839a 100644 (file)
@@ -23,7 +23,7 @@ seta hud_progressbar_speed_color "1 0.75 0"
 seta hud_progressbar_acceleration_color "0.5 0.75 1"
 seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5"
 
-seta _hud_panelorder "15 12 9 10 5 6 14 0 7 4 11 2 1 3 8 13 "
+seta _hud_panelorder "15 12 9 10 5 6 14 0 7 4 11 2 1 3 8 13 16 "
 
 seta hud_configure_grid "1"
 seta hud_configure_grid_xsize "0.010000"
@@ -101,6 +101,19 @@ seta hud_panel_healtharmor_progressbar_health "progressbar"
 seta hud_panel_healtharmor_progressbar_armor "progressbar"
 seta hud_panel_healtharmor_text "1"
 
+seta hud_panel_centerprint 1
+seta hud_panel_centerprint_pos "0.180000 0.260000"
+seta hud_panel_centerprint_size "0.650000 0.210000"
+seta hud_panel_centerprint_bg "0"
+seta hud_panel_centerprint_bg_color ""
+seta hud_panel_centerprint_bg_color_team ""
+seta hud_panel_centerprint_bg_alpha ""
+seta hud_panel_centerprint_bg_border ""
+seta hud_panel_centerprint_bg_padding ""
+seta hud_panel_centerprint_align "0.5"
+seta hud_panel_centerprint_fontscale "1"
+seta hud_panel_centerprint_time "2"
+
 seta hud_panel_notify 1
 seta hud_panel_notify_pos "0.710000 0.800000"
 seta hud_panel_notify_size "0.290000 0.190000"
index c39daf2..3745240 100644 (file)
@@ -1421,7 +1421,6 @@ void CSQC_SPIDER_HUD()
        if (scoreboard_showscores)
        {
                HUD_DrawScoreboard();
-               HUD_DrawCenterPrint();
        }
 
 }
@@ -1488,7 +1487,6 @@ void CSQC_RAPTOR_HUD()
        if (scoreboard_showscores)
        {
                HUD_DrawScoreboard();
-               HUD_DrawCenterPrint();
        }
 
 }
@@ -1598,7 +1596,6 @@ const float STAT_VEHICLESTAT_RELOAD2 = 66;
        if (scoreboard_showscores)
        {
                HUD_DrawScoreboard();
-               HUD_DrawCenterPrint();
        }
 
 }
@@ -1637,25 +1634,12 @@ void CSQC_common_hud(void)
                        HUD_DrawScoreboard();
 
                        if (scoreboard_active) // scoreboard/accuracy
-                       {       
                                HUD_Reset();
-                               // HUD_DrawScoreboard takes care of centerprint_start
-                       }
                        else if (intermission == 2) // map voting screen
                        {
                                HUD_FinaleOverlay();
                                HUD_Reset();
-
-                               centerprint_start_x = 0;
-                               centerprint_start_y = autocvar_scr_centerpos * vid_conheight;
                        }
-                       else // hud
-                       {
-                               centerprint_start_x = 0;
-                               centerprint_start_y = autocvar_scr_centerpos * vid_conheight;
-                       }
-
-                       HUD_DrawCenterPrint();
                        break;
 
                case HUD_SPIDERBOT:
index b2a1602..fc7fd4e 100644 (file)
@@ -205,6 +205,10 @@ float autocvar_hud_panel_healtharmor_progressbar_gfx_damage;
 float autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth;
 float autocvar_hud_panel_healtharmor_progressbar_gfx_smooth;
 
+float autocvar_hud_panel_centerprint;
+float autocvar_hud_panel_centerprint_align;
+float autocvar_hud_panel_centerprint_fontscale;
+float autocvar_hud_panel_centerprint_time;
 float autocvar_hud_panel_healtharmor_text;
 float autocvar_hud_panel_infomessages;
 float autocvar_hud_panel_infomessages_flip;
@@ -319,9 +323,6 @@ var float autocvar_scoreboard_highlight_alpha = 0.10;
 var float autocvar_scoreboard_highlight_alpha_self = 0.25;
 float autocvar_scoreboard_offset_left;
 float autocvar_scoreboard_offset_right;
-float autocvar_scr_centerpos;
-float autocvar_scr_centersize;
-float autocvar_scr_centertime;
 float autocvar_v_flipped;
 float autocvar_vid_conheight;
 float autocvar_vid_conwidth;
index 65fe92c..3299648 100644 (file)
@@ -142,183 +142,6 @@ float stringwidth_nocolors(string s, vector theSize)
        return stringwidth(s, FALSE, theSize);
 }
 
-#define CENTERPRINT_MAX_LINES 30
-string centerprint_messages[CENTERPRINT_MAX_LINES];
-float centerprint_width[CENTERPRINT_MAX_LINES];
-float centerprint_time;
-float centerprint_expire;
-float centerprint_num;
-float centerprint_offset_hint;
-vector centerprint_fontsize;
-
-void centerprint(string strMessage)
-{
-       float i, j, n, hcount;
-       string s;
-
-       centerprint_fontsize = HUD_GetFontsize("scr_centersize");
-
-       centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
-
-       if(autocvar_scr_centertime <= 0)
-               return;
-
-       if(strMessage == "")
-               return;
-
-       // strip trailing newlines
-       j = strlen(strMessage) - 1;
-       while(substring(strMessage, j, 1) == "\n" && j >= 0)
-               j = j - 1;
-       strMessage = substring(strMessage, 0, j + 1);
-
-       if(strMessage == "")
-               return;
-
-       // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
-       j = 0;
-       while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
-               j = j + 1;
-       strMessage = substring(strMessage, j, strlen(strMessage) - j);
-       centerprint_offset_hint = j;
-
-       if(strMessage == "")
-               return;
-
-       // if we get here, we have a message. Initialize its height.
-       centerprint_num = 0;
-
-       n = tokenizebyseparator(strMessage, "\n");
-       i = hcount = 0;
-       for(j = 0; j < n; ++j)
-       {
-               getWrappedLine_remaining = argv(j);
-               while(getWrappedLine_remaining)
-               {
-                       s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
-                       if(centerprint_messages[i] != s) // don't fade the same message in, looks stupid
-                               centerprint_time = time;
-                       if(centerprint_messages[i])
-                               strunzone(centerprint_messages[i]);
-                       centerprint_messages[i] = strzone(s);
-                       centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
-                       ++i;
-
-                       // half height for empty lines looks better
-                       if(s == "")
-                               hcount += 0.5;
-                       else
-                               hcount += 1;
-
-                       if(i >= CENTERPRINT_MAX_LINES)
-                               break;
-               }
-       }
-
-       float h, havail;
-       h = centerprint_fontsize_y*hcount;
-
-       havail = vid_conheight;
-       if(autocvar_con_chatpos < 0)
-               havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
-       if(havail > vid_conheight - 70)
-               havail = vid_conheight - 70; // avoid overlapping HUD
-
-#if 0
-       float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
-
-       // here, the centerprint would cover the crosshair. REALLY BAD.
-       forbiddenmin = vid_conheight * 0.5 - h - 16;
-       forbiddenmax = vid_conheight * 0.5 + 16;
-
-       allowedmin = scoreboard_bottom;
-       allowedmax = havail - h;
-       preferred = (havail - h)/2;
-
-
-       // possible orderings (total: 4! / 4 = 6)
-       //  allowedmin allowedmax forbiddenmin forbiddenmax
-       //  forbiddenmin forbiddenmax allowedmin allowedmax
-       if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
-       {
-               // forbidden doesn't matter in this case
-               centerprint_start_y = bound(allowedmin, preferred, allowedmax);
-       }
-       //  allowedmin forbiddenmin allowedmax forbiddenmax
-       else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
-       {
-               centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
-       }
-       //  allowedmin forbiddenmin forbiddenmax allowedmax
-       else if(allowedmin < forbiddenmin)
-       {
-               // make sure the forbidden zone is not covered
-               if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
-                       centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
-               else
-                       centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
-       }
-       //  forbiddenmin allowedmin allowedmax forbiddenmax
-       else if(allowedmax < forbiddenmax)
-       {
-               // it's better to leave the allowed zone (overlap with scoreboard) than
-               // to cover the forbidden zone (crosshair)
-               if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
-                       centerprint_start_y = forbiddenmax;
-               else
-                       centerprint_start_y = forbiddenmin;
-       }
-       //  forbiddenmin allowedmin forbiddenmax allowedmax
-       else
-       {
-               centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
-       }
-#else
-#endif
-
-       centerprint_num = i;
-
-       centerprint_expire = time + autocvar_scr_centertime;
-}
-
-void HUD_DrawCenterPrint (void)
-{
-       float i;
-       vector pos;
-       string ts;
-       float a, sz;
-
-       if(time - centerprint_time < 0.25)
-               a = (time - centerprint_time) / 0.25;
-       else
-               a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
-
-       if(a <= 0)
-               return;
-
-       sz = 0.8 + (a / 5);
-
-       if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
-               centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
-
-       pos = centerprint_start;
-       for (i=0; i<centerprint_num; i = i + 1)
-       {
-               ts = centerprint_messages[i];
-               drawfontscale = sz * '1 1 0';
-               pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
-               if (ts != "")
-               {
-                       drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
-                       pos_y = pos_y + centerprint_fontsize_y;
-               }
-               else
-                       // half height for empty lines looks better
-                       pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
-               drawfontscale = '1 1 0';
-       }
-}
-
 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
 {
        position_x -= 2 / 3 * strlen(text) * scale_x;
@@ -1992,92 +1815,90 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
        }
 }
 
-#define DAMAGE_CENTERPRINT_SPACER NEWLINES
-
 void HUD_Centerprint(string s1, string s2, float type, float msg)
 {
        float gentle;
        gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
        if(msg == MSG_SUICIDE) {
                if (type == DEATH_TEAMCHANGE) {
-                       centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You are now on: %s"), s1)));
+                       centerprint(strcat(sprintf(_("You are now on: %s"), s1)));
                } else if (type == DEATH_AUTOTEAMCHANGE) {
-                       centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
+                       centerprint(strcat(sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1)));
                } else if (type == DEATH_CAMP) {
                        if(gentle)
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Reconsider your tactics, camper!")));
+                               centerprint(strcat(_("^1Reconsider your tactics, camper!")));
                        else
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Die camper!")));
+                               centerprint(strcat(_("^1Die camper!")));
                } else if (type == DEATH_NOAMMO) {
                        if(gentle)
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You are reinserted into the game for running out of ammo...")));
+                               centerprint(strcat(_("^1You are reinserted into the game for running out of ammo...")));
                        else
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You were killed for running out of ammo...")));
+                               centerprint(strcat(_("^1You were killed for running out of ammo...")));
                } else if (type == DEATH_ROT) {
                        if(gentle)
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to preserve your health")));
+                               centerprint(strcat(_("^1You need to preserve your health")));
                        else
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You grew too old without taking your medicine")));
+                               centerprint(strcat(_("^1You grew too old without taking your medicine")));
                } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
                        if(gentle)
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't go against team mates!")));
+                               centerprint(strcat(_("^1Don't go against team mates!")));
                        else
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Don't shoot your team mates!")));
+                               centerprint(strcat(_("^1Don't shoot your team mates!")));
                } else if (type == DEATH_QUIET) {
                        // do nothing
                } else { // generic message
                        if(gentle)
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You need to be more careful!")));
+                               centerprint(strcat(_("^1You need to be more careful!")));
                        else
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1You killed your own dumb self!")));
+                               centerprint(strcat(_("^1You killed your own dumb self!")));
                }
        } else if(msg == MSG_KILL) {
                if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
                        if(gentle) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
+                               centerprint(strcat(sprintf(_("^1Moron! You went against %s, a team mate!"), s1)));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
+                               centerprint(strcat(sprintf(_("^1Moron! You fragged %s, a team mate!"), s1)));
                        }
                } else if (type == KILL_FIRST_BLOOD) {
                        if(gentle) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First score")));
+                               centerprint(strcat(_("^1First score")));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First blood")));
+                               centerprint(strcat(_("^1First blood")));
                        }
                } else if (type == KILL_FIRST_VICTIM) {
                        if(gentle) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First casualty")));
+                               centerprint(strcat(_("^1First casualty")));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1First victim")));
+                               centerprint(strcat(_("^1First victim")));
                        }
                } else if (type == KILL_TYPEFRAG) { // s2 contains "advanced kill messages" such as ping, handicap...
                        if(gentle) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
+                               centerprint(strcat(sprintf(_("^1You scored against ^7%s^1 who was typing!"), s1), s2));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You typefragged ^7%s"), s1), s2));
+                               centerprint(strcat(sprintf(_("^1You typefragged ^7%s"), s1), s2));
                        }
                } else if (type == KILL_TYPEFRAGGED) {
                        if(gentle) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
+                               centerprint(strcat(sprintf(_("^1You were scored against by ^7%s^1 while you were typing!"), s1), s2));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
+                               centerprint(strcat(sprintf(_("^1You were typefragged by ^7%s"), s1), s2));
                        }
                } else if (type == KILL_FRAG) {
                        if(gentle) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You scored against ^7%s"), s1), s2));
+                               centerprint(strcat(sprintf(_("^4You scored against ^7%s"), s1), s2));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^4You fragged ^7%s"), s1), s2));
+                               centerprint(strcat(sprintf(_("^4You fragged ^7%s"), s1), s2));
                        }
                } else { // generic message
                        if(gentle) {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were scored against by ^7%s"), s1), s2));
+                               centerprint(strcat(sprintf(_("^1You were scored against by ^7%s"), s1), s2));
                        } else {
-                               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, sprintf(_("^1You were fragged by ^7%s"), s1), s2));
+                               centerprint(strcat(sprintf(_("^1You were fragged by ^7%s"), s1), s2));
                        }
                }
        } else if(msg == MSG_KILL_ACTION) {
                // TODO: invent more centerprints here?
-               centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, _("^1Watch your step!")));
+               centerprint(strcat(_("^1Watch your step!")));
        }
 }
 
@@ -4496,6 +4317,152 @@ void HUD_Physics(void)
                drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 }
 
+#define CENTERPRINT_MAX_MSGS 10
+#define CENTERPRINT_MAX_ENTRIES 50
+float cpm_index;
+string centerprint_messages[CENTERPRINT_MAX_MSGS];
+float centerprint_msgID[CENTERPRINT_MAX_MSGS];
+float centerprint_time[CENTERPRINT_MAX_MSGS];
+
+string msg_without_CPID(string s)
+{
+       return substring(s, strstrofs(s, " ", 0) + 1, strlen(s));
+}
+float get_CPID(string s)
+{
+       if(substring(s, 0, 1) != "\r")
+               return 0;
+       return stof(substring(s, 1, strstrofs(s, " ", 0)));
+}
+void centerprint(string strMessage)
+{
+       float i, j;
+
+       if(autocvar_hud_panel_centerprint_time <= 0)
+               return;
+
+       if(strMessage == "")
+               return;
+
+       float new_id = get_CPID(strMessage);
+
+       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] && centerprint_time[j] + autocvar_hud_panel_centerprint_time >= time)
+               {
+                       if(centerprint_messages[j])
+                               strunzone(centerprint_messages[j]);
+                       centerprint_messages[j] == strzone(msg_without_CPID(strMessage));
+                       centerprint_time[j] = time;
+                       return;
+               }
+               if(centerprint_messages[j] == strMessage)
+               {
+                       centerprint_time[j] = time;
+                       centerprint_msgID[j] = new_id;
+                       return;
+               }
+       }
+
+       --cpm_index;
+       if (cpm_index == -1)
+               cpm_index = CENTERPRINT_MAX_MSGS - 1;
+       if(centerprint_messages[cpm_index])
+               strunzone(centerprint_messages[cpm_index]);
+       if (new_id)
+               centerprint_messages[cpm_index] = strzone(msg_without_CPID(strMessage));
+       else
+               centerprint_messages[cpm_index] = strzone(strMessage);
+       centerprint_msgID[cpm_index] = new_id;
+       centerprint_time[cpm_index] = time;
+}
+
+// CenterPrint (#16)
+//
+void HUD_CenterPrint (void)
+{
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_centerprint) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_CENTERPRINT;
+
+       HUD_Panel_UpdateCvars(centerprint);
+
+       HUD_Panel_DrawBg(1);
+       if(panel_bg_padding)
+       {
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
+       }
+
+       float entries, height;
+       vector fontsize;
+       // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
+       // height = panel_size_y/entries;
+       // fontsize = '1 1 0' * height;
+       height = vid_conheight/40 * autocvar_hud_panel_centerprint_fontscale;
+       fontsize = '1 1 0' * height;
+       entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
+
+       float i, j, k, n;
+       float a, sz, fade, align;
+       vector pos;
+       string ts;
+
+       pos = panel_pos;
+       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] + autocvar_hud_panel_centerprint_time < time)
+                       continue;
+               else if (centerprint_time[j] + autocvar_hud_panel_centerprint_time - fade > time)
+               {
+                       a = 1;
+                       sz = 1;
+               }
+               else if (centerprint_time[j] + autocvar_hud_panel_centerprint_time > time)
+               {
+                       a = (centerprint_time[j] + autocvar_hud_panel_centerprint_time - time) / fade;
+                       sz = 0.8 + a * (1 - 0.8);
+               }
+
+               drawfontscale = sz * '1 1 0';
+               n = tokenizebyseparator(centerprint_messages[j], "\n");
+               for(k = 0; k < n; ++k)
+               {
+                       getWrappedLine_remaining = argv(k);
+                       while(getWrappedLine_remaining)
+                       {
+                               ts = getWrappedLine(panel_size_x, 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, DRAWFLAG_NORMAL);
+                                       pos_y += fontsize_y * 1.5;
+                               }
+                               else
+                                       pos_y += fontsize_y;
+                               if (pos_y > panel_pos_y + panel_size_y - fontsize_y)
+                               {
+                                       drawfontscale = '1 1 0';
+                                       return;
+                               }
+                       }
+               }
+               if (a < 1)
+                       pos_y -= 1.5 * fontsize_y * (1 - a*a);
+               drawfontscale = '1 1 0';
+       }
+}
+
 /*
 ==================
 Main HUD system
@@ -4545,6 +4512,8 @@ switch (id) {\
                 HUD_InfoMessages(); break;\
        case (HUD_PANEL_PHYSICS):\
                 HUD_Physics(); break;\
+       case (HUD_PANEL_CENTERPRINT):\
+                HUD_CenterPrint(); break;\
 } ENDS_WITH_CURLY_BRACE
 
 void HUD_Main (void)
index d2fbfeb..dc28565 100644 (file)
@@ -283,6 +283,7 @@ if(menu_enabled == 2 && hud_configure_active_panel == highlightedPanel) {\
 switch(id) { \
        case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
        case HUD_PANEL_PHYSICS: HUD_Panel_UpdateCvars(physics); break;\
+       case HUD_PANEL_CENTERPRINT: HUD_Panel_UpdateCvars(centerprint); break;\
 }
 
 #define HUD_Panel_UpdateCvarsForId(id) \
@@ -320,6 +321,7 @@ HUD_Panel_GetBorder()
 switch(id) { \
        case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages) break;\
        case HUD_PANEL_PHYSICS: HUD_Panel_UpdatePosSize(physics); break;\
+       case HUD_PANEL_CENTERPRINT: HUD_Panel_UpdatePosSize(centerprint); break;\
 }
 
 #define HUD_Panel_UpdatePosSizeForId(id) \
index 0923e4e..80a28a4 100644 (file)
@@ -45,9 +45,6 @@ void HUD_Panel_ExportCfg(string cfgname)
                HUD_Write_Cvar_q("hud_configure_grid_ysize");
                HUD_Write("\n");
 
-               HUD_Write_Cvar_q("scr_centerpos");
-               HUD_Write("\n");
-
                // common cvars for all panels
                float i;
                for (i = 0; i < HUD_PANEL_NUM; ++i)
@@ -124,6 +121,11 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        HUD_Write_PanelCvar_q("_progressbar");
                                        HUD_Write_PanelCvar_q("_acceleration_mode");
                                        break;
+                               case HUD_PANEL_CENTERPRINT:
+                                       HUD_Write_PanelCvar_q("_align");
+                                       HUD_Write_PanelCvar_q("_fontscale");
+                                       HUD_Write_PanelCvar_q("_time");
+                                       break;
                        }
                        HUD_Write("\n");
                }
index d59c75b..e47734c 100644 (file)
@@ -20,7 +20,7 @@ void restartAnnouncer_Think() {
        countdown_rounded = floor(0.5 + countdown);
        if(countdown <= 0) {
                if (!spectatee_status) //do cprint only for players
-                       centerprint(_("^1Begin!"));
+                       centerprint(strcat(CPID_GAME_STARTING, _("^1Begin!")));
 
                sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/begin.wav"), VOL_BASEVOICE, ATTN_NONE);
                //reset maptime announcers now as well
@@ -31,7 +31,7 @@ void restartAnnouncer_Think() {
        }
        else {
                if (!spectatee_status) //do cprint only for players
-                       centerprint(sprintf(_("^1Game starts in %d seconds"), countdown_rounded));
+                       centerprint(strcat(CPID_GAME_STARTING, sprintf(_("^1Game starts in %d seconds"), countdown_rounded)));
 
                if(countdown_rounded <= 3 && countdown_rounded >= 1) {
                        sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
index 507cff8..31dcf71 100644 (file)
@@ -580,6 +580,17 @@ float WATERLEVEL_SUBMERGED = 3;
 
 float MAX_SHOT_DISTANCE = 32768;
 
+//centerprint ID list
+#define CPID_TEAMCHANGE                        "\r1 "
+#define CPID_KILL                              "\r2 "
+#define CPID_MINSTA_FINDAMMO   "\r3 "
+#define CPID_NIX_WPNCHANGE             "\r4 "
+#define CPID_DISCONNECT_IDLING "\r5 "
+#define CPID_ROUND_STARTING            "\r6 "
+#define CPID_GAME_STARTING             "\r7 "
+#define CPID_TIMEOUT_COUNTDOWN "\r8 "
+#define CPID_MOTD                              "\r9 "
+
 // CSQC centerprint/notify message types
 float MSG_SUICIDE = 0;
 float MSG_KILL = 1;
@@ -654,7 +665,8 @@ float HUD_PANEL_CHAT                = 12;
 float HUD_PANEL_ENGINEINFO     = 13;
 float HUD_PANEL_INFOMESSAGES   = 14;
 float HUD_PANEL_PHYSICS        = 15;
-float HUD_PANEL_NUM            = 16; // always last panel id + 1, please increment when adding a new panel
+float HUD_PANEL_CENTERPRINT    = 16;
+float HUD_PANEL_NUM            = 17; // always last panel id + 1, please increment when adding a new panel
 
 string HUD_PANELNAME_WEAPONS           = "weapons";
 string HUD_PANELNAME_AMMO              = "ammo";
@@ -672,6 +684,7 @@ string HUD_PANELNAME_CHAT           = "chat";
 string HUD_PANELNAME_ENGINEINFO                = "engineinfo";
 string HUD_PANELNAME_INFOMESSAGES      = "infomessages";
 string HUD_PANELNAME_PHYSICS   = "physics";
+string HUD_PANELNAME_CENTERPRINT       = "centerprint";
 
 float HUD_MENU_ENABLE          = 0;
 
index 49afad2..40ef287 100644 (file)
@@ -222,6 +222,7 @@ switch(id) {\
        case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; break; \
        case HUD_PANEL_INFOMESSAGES: panel_name = HUD_PANELNAME_INFOMESSAGES; break; \
        case HUD_PANEL_PHYSICS: panel_name = HUD_PANELNAME_PHYSICS; break; \
+       case HUD_PANEL_CENTERPRINT: panel_name = HUD_PANELNAME_CENTERPRINT; break; \
 } ENDS_WITH_CURLY_BRACE
 
 // Get name of specified panel id
index a58ccb2..6c70e7e 100644 (file)
@@ -224,18 +224,15 @@ void Arena_Warmup()
        if(ca_players < required_ca_players)
                allowed_to_spawn = 1;
 
-       msg = NEWLINES;
        if(time < warmup && !inWarmupStage)
        {
                if (g_ca)
                        allowed_to_spawn = 1;
                if(champion && g_arena)
                        msg = strcat("The Champion is ", champion_name, "^7\n");
-                       //centerprint(self, strcat(msg, "The Champion is ", champion.netname, "^7\n"));
 
                if(f != roundStartTime_prev) {
-                       msg = strcat(msg, "Round will start in ", ftos(f),"\n");
-                       //centerprint(self, strcat("Round will start in ", ftos(f),"\n"));
+                       msg = strcat(CPID_ROUND_STARTING, msg, "Round will start in ", ftos(f),"\n");
                        roundStartTime_prev = f;
                        if(f == 5)
                                Announce("prepareforbattle");
@@ -265,7 +262,7 @@ void Arena_Warmup()
        {
                roundStartTime_prev = f;
                Announce("begin");
-               centerprint(self, "^1Begin!\n");
+               centerprint(self, strcat(CPID_ROUND_STARTING, "^1Begin!\n"));
 
                if(g_ca) {
                        ca_players = 0;
@@ -375,6 +372,7 @@ void count_alive_players()
  *
  * Gets called in StartFrame()
  */
+float warntime;
 void Spawnqueue_Check()
 {
        count_spawned_players();
@@ -392,8 +390,12 @@ void Spawnqueue_Check()
                        reset_map(TRUE);
                }
                else if(ca_players < required_ca_players) {
-                       FOR_EACH_PLAYER(self)
-                               centerprint(self, strcat("^1Need at least 1 player in each team to play CA", "^7\n"));
+                       if (time > warntime)
+                       {
+                               FOR_EACH_PLAYER(self)
+                                       centerprint(self, strcat("^1Need at least 1 player in each team to play CA", "^7\n"));
+                               warntime = time + 1;
+                       }
                        return;
                }
                else if(!next_round) {
index 9a36546..bca53cb 100644 (file)
@@ -108,7 +108,7 @@ void CampaignPreInit()
 
        title = campaign_shortdesc[0];
        title = strzone(strcat("Level ", ftos(campaign_level + 1), ": ", title));
-       campaign_message = strzone(strcat("\n\n\n\n\n\n\n\n\n\n^1\n", title, "\n^3\n", campaign_longdesc[0], "\n\n^1press jump to enter the game"));
+       campaign_message = strzone(strcat("^1\n", title, "\n^3\n", campaign_longdesc[0], "\n\n^1press jump to enter the game"));
        strunzone(title);
 }
 
index ffeba55..e95c949 100644 (file)
@@ -1302,14 +1302,14 @@ void KillIndicator_Think()
                        if(self.owner.killindicator_teamchange)
                        {
                                if(self.owner.killindicator_teamchange == -1)
-                                       centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
+                                       centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Changing team in ", ftos(self.cnt), " seconds"));
                                else if(self.owner.killindicator_teamchange == -2)
-                                       centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds"));
+                                       centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Spectating in ", ftos(self.cnt), " seconds"));
                                else
-                                       centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
+                                       centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
                        }
                        else
-                               centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds"));
+                               centerprint(self.owner, strcat(CPID_KILL, "^1Suicide in ", ftos(self.cnt), " seconds"));
                }
                self.nextthink = time + 1;
                self.cnt -= 1;
@@ -1986,24 +1986,24 @@ string getTimeoutText(float addOneSecond) {
                else {
                        retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n");
                }
-               return retStr;
+               return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
        }
        else if (timeoutStatus == 2) {
                if (addOneSecond) {
                        retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime + 1), " seconds!\n");
                        //don't show messages like "Timeout ends in 0 seconds"...
                        if ((remainingTimeoutTime + 1) > 0)
-                               return retStr;
+                               return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
                        else
-                               return "";
+                               return strcat(CPID_TIMEOUT_COUNTDOWN, "");
                }
                else {
                        retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n");
                        //don't show messages like "Timeout ends in 0 seconds"...
-                       if (remainingTimeoutTime > 0)
-                               return retStr;
+                       if ((remainingTimeoutTime) > 0)
+                               return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
                        else
-                               return "";
+                               return strcat(CPID_TIMEOUT_COUNTDOWN, "");
                }
        }
        else return "";
@@ -2443,7 +2443,7 @@ void LeaveSpectatorMode()
                                bprint ("^4", self.netname, "^4 is playing now\n");
 
                        if(!autocvar_g_campaign)
-                               centerprint(self,""); // clear MOTD
+                               centerprint(self, CPID_MOTD); // clear MOTD
 
                        return;
                } else {
@@ -3019,7 +3019,7 @@ void PlayerPostThink (void)
                {
                        if(timeleft != self.idlekick_lasttimeleft)
                        {
-                               centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat("^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
+                               centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat(CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
                                AnnounceTo(self, strcat(ftos(timeleft), ""));
                        }
                }
index 29fc297..73914d4 100644 (file)
@@ -41,8 +41,6 @@ void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad
        Net_LinkEntity(e, FALSE, 0.2, Damage_DamageInfo_SendEntity);
 }
 
-#define DAMAGE_CENTERPRINT_SPACER NEWLINES
-
 float checkrules_firstblood;
 
 float yoda;
@@ -647,7 +645,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
                        if (targ.armorvalue && (deathtype == WEP_MINSTANEX) && damage)
                        {
                                targ.armorvalue -= 1;
-                               centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(targ.armorvalue)));
+                               centerprint(targ, strcat("^3Remaining extra lives: ",ftos(targ.armorvalue)));
                                damage = 0;
                                targ.hitsound += 1;
                                attacker.hitsound += 1; // TODO change this to a future specific hitsound for armor hit
@@ -659,7 +657,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
                                if (targ != attacker)
                                {
                                        if ((targ.health >= 1) && (targ.classname == "player"))
-                                               centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "Secondary fire inflicts no damage!"));
+                                               centerprint(attacker, "Secondary fire inflicts no damage!");
                                        force = '0 0 0';
                                        // keep mirrorforce
                                        attacker = targ;
@@ -896,7 +894,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
                        if(attacker.armorvalue > 0)
                        {
                                attacker.armorvalue = attacker.armorvalue - 1;
-                               centerprint(attacker, strcat(DAMAGE_CENTERPRINT_SPACER, "^3Remaining extra lives: ",ftos(attacker.armorvalue)));
+                               centerprint(attacker, strcat("^3Remaining extra lives: ",ftos(attacker.armorvalue)));
                                attacker.hitsound += 1;
                        }
                        mirrordamage = 0;
index a4131af..b306b65 100644 (file)
@@ -98,13 +98,13 @@ void NIX_GiveCurrentWeapon()
                if(dt >= 1 && dt <= 5)
                        self.nix_lastinfotime = -42;
                else
-                       centerprint(self, strcat("\n\n^2Active weapon: ^3", W_Name(nix_weapon)));
+                       centerprint(self, strcat(CPID_NIX_WPNCHANGE, "\n\n^2Active weapon: ^3", W_Name(nix_weapon)));
        }
        if(self.nix_lastinfotime != dt)
        {
                self.nix_lastinfotime = dt; // initial value 0 should count as "not seen"
                if(dt >= 1 && dt <= 5)
-                       centerprint(self, strcat("^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n"));
+                       centerprint(self, strcat(CPID_NIX_WPNCHANGE, "^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n"));
        }
 
        if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr)
index 5a591e0..0eea40b 100644 (file)
@@ -283,7 +283,7 @@ float Item_GiveTo(entity item, entity player)
                        {
                                pickedup = TRUE;
                                // play some cool sounds ;)
-                               centerprint(player, "\n");
+                               centerprint(player, CPID_MINSTA_FINDAMMO); //clear countdown
                                if (clienttype(player) == CLIENTTYPE_REAL)
                                {
                                        if(player.health <= 5)
index f9321b8..68aa07a 100644 (file)
@@ -484,12 +484,11 @@ void PrintWelcomeMessage(entity pl)
        {
                // TODO get rid of this too
                local string specString;
-               specString = NEWLINES;
                //if(time < game_starttime) //also show the countdown when being a spectator
                //      specString = strcat(specString, "\n\n^1Game starts in ", ftos(ceil(game_starttime - time)), " seconds^7");
                //else
                if (timeoutStatus != 0)
-                       specString = strcat(specString, "\n\n", getTimeoutText(1));
+                       specString = getTimeoutText(1);
                else
                {
                        if(self.classname == "player")
@@ -536,7 +535,7 @@ void PrintWelcomeMessage(entity pl)
        local string versionmessage;
        versionmessage = GetClientVersionMessage();
 
-       s = strcat(s, NEWLINES, "This is Xonotic ", autocvar_g_xonoticversion, "\n", versionmessage);
+       s = strcat(CPID_MOTD, "This is Xonotic ", autocvar_g_xonoticversion, "\n", versionmessage);
        s = strcat(s, "^8\n\nmatch type is ^1", gamemode_name, "^8\n");
 
        if(modifications != "")
index 4481178..920d03f 100644 (file)
@@ -98,67 +98,67 @@ void minstagib_ammocheck (void)
        {
                if (self.health == 5)
                {
-                       centerprint(self, "you're dead now...\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "you're dead now...\n"));
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "terminated");
                }
                else if (self.health == 10)
                {
-                       centerprint(self, "^11^7 second left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^11^7 second left to find some ammo\n"));
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "1");
                }
                else if (self.health == 20)
                {
-                       centerprint(self, "^12^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^12^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "2");
                }
                else if (self.health == 30)
                {
-                       centerprint(self, "^13^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^13^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "3");
                }
                else if (self.health == 40)
                {
-                       centerprint(self, "^14^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^14^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "4");
                }
                else if (self.health == 50)
                {
-                       centerprint(self, "^15^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^15^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "5");
                }
                else if (self.health == 60)
                {
-                       centerprint(self, "^36^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^36^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "6");
                }
                else if (self.health == 70)
                {
-                       centerprint(self, "^37^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^37^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "7");
                }
                else if (self.health == 80)
                {
-                       centerprint(self, "^38^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^38^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "8");
                }
                else if (self.health == 90)
                {
-                       centerprint(self, "^39^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^39^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "9");
                }
                else if (self.health == 100)
                {
-                       centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "get some ammo or\nyou'll be dead in ^310^7 seconds..."));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        if not(self.flags & FL_GODMODE)
                                AnnounceTo(self, "10");