]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/infomessages.qc
Create queue system to prevent team imbalance in teamplay
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / infomessages.qc
index 1e5a0c9f2f293403c18408e3ff0cdae1fc72d649..ff5bd8d5d8e30e407a34b780a452713a3ca27def 100644 (file)
@@ -1,13 +1,16 @@
 #include "infomessages.qh"
 
-#include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
-
+#include <client/draw.qh>
 #include <common/ent_cs.qh>
-#include <common/mapinfo.qh>
 
 // Info messages (#14)
 
+void HUD_InfoMessages_Export(int fh)
+{
+       // allow saving cvars that aesthetically change the panel into hud skin files
+       HUD_Write_Cvar("hud_panel_infomessages_flip");
+}
+
 float autocvar_hud_panel_infomessages_group0 = 1;
 float autocvar_hud_panel_infomessages_group_fadetime = 0.4;
 float autocvar_hud_panel_infomessages_group_time = 6;
@@ -33,7 +36,6 @@ int img_select(int group_id)
        return img_cur_msg[group_id];
 }
 
-float stringwidth_colors(string s, vector theSize);
 vector InfoMessages_drawstring(string s, vector pos, vector sz, float a, vector fontsize)
 {
        getWrappedLine_remaining = s;
@@ -51,10 +53,10 @@ vector InfoMessages_drawstring(string s, vector pos, vector sz, float a, vector
        return pos;
 }
 
-#define InfoMessage(s) MACRO_BEGIN \
+#define InfoMessage(s) MACRO_BEGIN \
        pos = InfoMessages_drawstring(s, pos, mySize, ((img_curr_group >= 0) ? panel_fg_alpha * img_fade[img_curr_group] : panel_fg_alpha), fontsize); \
        img_curr_group = -1; \
-MACRO_END
+MACRO_END
 
 void HUD_InfoMessages()
 {
@@ -107,8 +109,10 @@ void HUD_InfoMessages()
                                        case 1:
                                                if(spectatee_status == -1)
                                                        s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey(_("next weapon"), "weapnext"), getcommandkey(_("previous weapon"), "weapprev"));
-                                               else
+                                               else if(!observe_blocked)
                                                        s = sprintf(_("^1Press ^3%s^1 to observe, ^3%s^1 to change camera mode"), getcommandkey(_("secondary fire"), "+fire2"), getcommandkey(_("drop weapon"), "dropweapon"));
+                                               else
+                                                       s = sprintf(_("^1Press ^3%s^1 to change camera mode"), getcommandkey(_("drop weapon"), "dropweapon"));
                                                break;
                                        case 2:
                                                s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey(_("server info"), "+show_info"));
@@ -117,22 +121,21 @@ void HUD_InfoMessages()
                                InfoMessage(s);
                        }
 
-                       MUTATOR_CALLHOOK(DrawInfoMessages, pos, mySize);
+                       bool mutator_returnvalue = MUTATOR_CALLHOOK(DrawInfoMessages, pos, mySize, img_curr_group);
+                       pos = M_ARGV(0, vector);
+                       img_curr_group = M_ARGV(2, int);
 
-                       if(!warmup_stage && gametype == MAPINFO_TYPE_LMS)
+                       if(!mutator_returnvalue)
                        {
-                               entity sk;
-                               sk = playerslots[player_localnum];
-                               if(sk.(scores(ps_primary)) >= 666)
-                                       s = _("^1Match has already begun");
-                               else if(sk.(scores(ps_primary)) > 0)
-                                       s = _("^1You have no more lives left");
+                               if(entcs_GetWantsJoin(current_player))
+                               {
+                                       int tm = Team_IndexToTeam(entcs_GetWantsJoin(current_player));
+                                       s = sprintf(_("^2You're queued to join the %s%s^2 team"), Team_ColorCode(tm), Team_ColorName(tm));
+                               }
                                else
                                        s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump"));
+                               InfoMessage(s);
                        }
-                       else
-                               s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump"));
-                       InfoMessage(s);
                }
 
                if (time < STAT(GAMESTARTTIME))
@@ -143,40 +146,44 @@ void HUD_InfoMessages()
                        InfoMessage(s);
                }
 
-               if(warmup_stage)
-               {
-                       s = _("^2Currently in ^1warmup^2 stage!");
-                       InfoMessage(s);
-               }
-
                string blinkcolor;
                if(time % 1 >= 0.5)
                        blinkcolor = "^1";
                else
                        blinkcolor = "^3";
 
-               if(ready_waiting && !spectatee_status)
+               if(warmup_stage)
                {
-                       if(ready_waiting_for_me)
+                       InfoMessage(_("^2Currently in ^1warmup^2 stage!"));
+
+                       int players_needed = 0;
+                       if(STAT(WARMUP_TIMELIMIT) <= 0 && srv_minplayers)
+                       {
+                               Scoreboard_UpdatePlayerTeams(); // ensure numplayers is current
+                               players_needed = srv_minplayers - numplayers;
+                       }
+
+                       if(players_needed > 0)
                        {
-                               if(warmup_stage)
-                                       s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey(_("ready"), "ready"), blinkcolor);
+                               if(players_needed == 1)
+                                       s = _("^31^2 more player is needed for the match to start.");
                                else
-                                       s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey(_("ready"), "ready"), blinkcolor);
+                                       s = sprintf(_("^3%d^2 more players are needed for the match to start."), players_needed);
+                               InfoMessage(s);
                        }
-                       else
+                       else if(!spectatee_status)
                        {
-                               if(warmup_stage)
-                                       s = _("^2Waiting for others to ready up to end warmup...");
+                               if(ready_waiting)
+                               {
+                                       if(ready_waiting_for_me)
+                                               s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey(_("ready"), "ready"), blinkcolor);
+                                       else
+                                               s = _("^2Waiting for others to ready up to end warmup...");
+                               }
                                else
-                                       s = _("^2Waiting for others to ready up...");
+                                       s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey(_("ready"), "ready"));
+                               InfoMessage(s);
                        }
-                       InfoMessage(s);
-               }
-               else if(warmup_stage && !spectatee_status)
-               {
-                       s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey(_("ready"), "ready"));
-                       InfoMessage(s);
                }
 
                if(teamplay && !spectatee_status && teamnagger)
@@ -199,7 +206,7 @@ void HUD_InfoMessages()
                                        s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
                                        tm = GetTeam(myteam, false);
                                        if (tm && tm.team != NUM_SPECTATOR && tm.team_size == ts_max)
-                                               s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey(_("team menu"), "menu_showteamselect"), blinkcolor));
+                                               s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey(_("team selection"), "team_selection_show"), blinkcolor));
                                        InfoMessage(s);
                                }
                        }