From: terencehill Date: Sun, 22 May 2011 16:57:27 +0000 (+0200) Subject: Unify series of countdown messages in one message. Also now the messages can be displ... X-Git-Tag: xonotic-v0.5.0~228 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=574f0f2a1839a0dc08b7ab54b9448d7f244a7799;p=xonotic%2Fxonotic-data.pk3dir.git Unify series of countdown messages in one message. Also now the messages can be displayed lower on the screen when they have EOLS at the beginning --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index fb7ddcf6e..15ca2b9b6 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -145,13 +145,23 @@ float stringwidth_nocolors(string s, vector theSize) #define CENTERPRINT_MAX_LINES 10 float cpm_index; string centerprint_messages[CENTERPRINT_MAX_LINES]; +float centerprint_msgID[CENTERPRINT_MAX_LINES]; float centerprint_width[CENTERPRINT_MAX_LINES]; float centerprint_time[CENTERPRINT_MAX_LINES]; float centerprint_expire; float centerprint_num; -float centerprint_offset_hint; vector centerprint_fontsize; +string strip_CPID(string s) +{ + return substring(s, strstrofs(s, " ", 0) + 1, strlen(s)); +} +float get_CPID(string s) +{ + if(substring(s, 0, 1) != "#") + return 0; + return stof(substring(s, 1, strstrofs(s, " ", 0))); +} void centerprint(string strMessage) { float i, j, n, hcount; @@ -167,32 +177,24 @@ void centerprint(string strMessage) 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; + float new_id = get_CPID(strMessage); for (i=0, j=cpm_index; i= 1) { sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE); diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 507cff85a..e2f2ac2a6 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -580,6 +580,16 @@ float WATERLEVEL_SUBMERGED = 3; float MAX_SHOT_DISTANCE = 32768; +//centerprint ID list +#define CPID_TEAMCHANGE "#1 " +#define CPID_KILL "#2 " +#define CPID_MINSTA_FINDAMMO "#3 " +#define CPID_NIX_WPNCHANGE "#4 " +#define CPID_DISCONNECT_IDLING "#5 " +#define CPID_ROUND_STARTING "#6 " +#define CPID_GAME_STARTING "#7 " +#define CPID_TIMEOUT_COUNTDOWN "#8 " + // CSQC centerprint/notify message types float MSG_SUICIDE = 0; float MSG_KILL = 1; diff --git a/qcsrc/server/arena.qc b/qcsrc/server/arena.qc index 681e86fa0..6072c1512 100644 --- a/qcsrc/server/arena.qc +++ b/qcsrc/server/arena.qc @@ -231,11 +231,9 @@ void Arena_Warmup() 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"); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 561b755c9..6df11cc02 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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; @@ -1983,24 +1983,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 ""; @@ -3016,7 +3016,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), "")); } } diff --git a/qcsrc/server/mutators/mutator_nix.qc b/qcsrc/server/mutators/mutator_nix.qc index a4131af40..b306b653c 100644 --- a/qcsrc/server/mutators/mutator_nix.qc +++ b/qcsrc/server/mutators/mutator_nix.qc @@ -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) diff --git a/qcsrc/server/w_minstanex.qc b/qcsrc/server/w_minstanex.qc index 4481178de..920d03f71 100644 --- a/qcsrc/server/w_minstanex.qc +++ b/qcsrc/server/w_minstanex.qc @@ -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");