]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/scoreboard_ui 1027/head
authorterencehill <piuntn@gmail.com>
Sat, 11 Jun 2022 19:18:19 +0000 (21:18 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 11 Jun 2022 19:18:19 +0000 (21:18 +0200)
14 files changed:
binds-xonotic.cfg
commands.cfg
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/hud/panel/quickmenu.qc
qcsrc/client/hud/panel/radar.qc
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/scoreboard.qh
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/client/view.qc
qcsrc/menu/xonotic/keybinder.qc
qcsrc/server/client.qc
qcsrc/server/command/cmd.qc

index 390354b54ee51295be2f3d8cfbbbcf45f63c531b..8796d8cddc12de8d3f68aac1759bce70855ca81c 100644 (file)
@@ -57,7 +57,7 @@ bind F1 vyes
 bind F2 vno
 bind F3 spec
 bind F4 ready
-bind F5 menu_showteamselect
+bind F5 scoreboard_team_selection
 bind F6 team_auto
 bind F7 menu_showsandboxtools
 bind F8 "quickmenu"
@@ -75,7 +75,7 @@ bind JOY5 "+fire2"
 bind JOY6 "+fire"
 bind JOY7 "+zoom"
 bind JOY8 "dropweapon"
-bind JOY9 "menu_showteamselect"
+bind JOY9 "scoreboard_team_selection"
 bind JOY10 "+show_info"
 bind JOY11 "+showscores"
 bind JOY12 "+con_chat_maximize"
index 1e26673d42055b639a03f40bbc12d9358e842c07..51ba1845e35083d417e506a2a97c95e01f315e4f 100644 (file)
@@ -149,6 +149,7 @@ alias hud_save "qc_cmd_cl hud save ${* ?}"
 alias radar "qc_cmd_cl hud radar ${* ?}"
 alias scoreboard_columns_help "qc_cmd_cl hud scoreboard_columns_help"
 alias scoreboard_columns_set "qc_cmd_cl hud scoreboard_columns_set ${* ?}"
+alias scoreboard_team_selection "_scoreboard_team_selection 1"
 
 
 // ========================================================
index a02ff3688f262bac6f3581165e8e5f4b86d020a9..463dcd402da61fdc8317108e327f8f1b30f51d71 100644 (file)
@@ -127,6 +127,7 @@ int hudShiftState;
 const int S_SHIFT = 1;
 const int S_CTRL = 2;
 const int S_ALT = 4;
+const int S_TAB = 8;
 
 float hud_fade_alpha;
 
index 5169ea5f384d34ae16ea80f3b46da767fae0ed5d..554a05a475259ec38ef52300bcf81649e4f77af2 100644 (file)
@@ -194,7 +194,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"), "scoreboard_team_selection"), blinkcolor));
                                        InfoMessage(s);
                                }
                        }
index 01fae6e0203104e2df63874db8581b32bdced4b5..f274411ae5bd6aed5d490d45f2d2ec66dc2e0e05 100644 (file)
@@ -70,6 +70,7 @@ void QuickMenu_Page_ClearEntry(int i)
 bool HUD_QuickMenu_Forbidden()
 {
        return (mv_active
+               || scoreboard_ui_enabled
                || (hud_configure_prev && hud_configure_prev != -1)
                || HUD_MinigameMenu_IsOpened()
                || (QuickMenu_TimeOut && time > QuickMenu_TimeOut));
@@ -192,12 +193,7 @@ bool QuickMenu_Open(string mode, string submenu, string file)
        mouseClicked = 0;
        hudShiftState = 0;
 
-       // we must unset the player's buttons, as they aren't released elsewhere
-       localcmd("-fire\n");
-       localcmd("-fire2\n");
-       localcmd("-use\n");
-       localcmd("-hook\n");
-       localcmd("-jump\n");
+       Release_Common_Keys();
 
        QuickMenu_TimeOut_Set();
        return true;
index ef209633b76c08f61dec511b18d430cc5a72f44c..a5b17d75eec767e5004252d53dc5818b293d1f93 100644 (file)
@@ -1,6 +1,7 @@
 #include "radar.qh"
 
 #include <client/draw.qh>
+#include <client/hud/panel/scoreboard.qh>
 #include <client/mapvoting.qh>
 #include <client/teamradar.qh>
 #include <common/ent_cs.qh>
@@ -39,12 +40,7 @@ void HUD_Radar_Show_Maximized(bool doshow, bool clickable)
                {
                        hud_panel_radar_mouse = 1;
 
-                       // we must unset the player's buttons, as they aren't released elsewhere
-                       localcmd("-fire\n");
-                       localcmd("-fire2\n");
-                       localcmd("-use\n");
-                       localcmd("-hook\n");
-                       localcmd("-jump\n");
+                       Release_Common_Keys();
                }
        }
        else if ( hud_panel_radar_mouse )
@@ -136,13 +132,7 @@ void HUD_Radar_Mouse()
        if ( !hud_panel_radar_mouse ) return;
        if(mv_active) return;
 
-       if ( intermission )
-       {
-               HUD_Radar_Hide_Maximized();
-               return;
-       }
-
-       if(mouseClicked & S_MOUSE2)
+       if (intermission || scoreboard_ui_enabled || (mouseClicked & S_MOUSE2))
        {
                HUD_Radar_Hide_Maximized();
                return;
index 01df92c4b4d14e8a08bdb6f931ad5a60d79a76eb..22c93b1f8a56d7bdee4b66f61d2d55a99af4d7ba 100644 (file)
@@ -108,6 +108,8 @@ bool autocvar_hud_panel_scoreboard_playerid = false;
 string autocvar_hud_panel_scoreboard_playerid_prefix = "#";
 string autocvar_hud_panel_scoreboard_playerid_suffix = " ";
 
+float scoreboard_time;
+
 // mode 0: returns translated label
 // mode 1: prints name and description of all the labels
 string Label_getInfo(string label, int mode)
@@ -164,6 +166,335 @@ string Label_getInfo(string label, int mode)
        return label;
 }
 
+bool scoreboard_ui_disabling;
+void HUD_Scoreboard_UI_Disable()
+{
+       scoreboard_ui_disabling = true;
+       scoreboard_showscores = false;
+}
+
+void HUD_Scoreboard_UI_Disable_Instantly()
+{
+       scoreboard_ui_disabling = false;
+       scoreboard_ui_enabled = 0;
+       scoreboard_selected_panel = 0;
+       scoreboard_selected_player = NULL;
+       scoreboard_selected_team = NULL;
+}
+
+// mode: 0 normal, 1 team selection
+void Scoreboard_UI_Enable(int mode)
+{
+       if (mode == 1)
+       {
+               if (scoreboard_ui_enabled == 2 || !teamplay || intermission)
+                       return;
+
+               // release player's pressed keys as they aren't released elsewhere
+               // in particular jump needs to be released as it may open the team selection
+               // (when server detects jump has been pressed it sends the command to open the team selection)
+               Release_Common_Keys();
+               scoreboard_ui_enabled = 2;
+               scoreboard_selected_panel = SB_PANEL_SCOREBOARD;
+       }
+       else
+       {
+               if (scoreboard_ui_enabled == 1)
+                       return;
+               scoreboard_ui_enabled = 1;
+               scoreboard_selected_panel = SB_PANEL_FIRST;
+       }
+       scoreboard_selected_player = NULL;
+       scoreboard_selected_team = NULL;
+       scoreboard_selected_panel_time = time;
+}
+
+int rankings_start_column;
+int rankings_rows = 0;
+int rankings_columns = 0;
+int rankings_cnt = 0;
+float HUD_Scoreboard_InputEvent(float bInputType, float nPrimary, float nSecondary)
+{
+       string s;
+
+       if(!scoreboard_ui_enabled || scoreboard_ui_disabling)
+               return false;
+
+       if(bInputType == 3)
+       {
+               mousepos.x = nPrimary;
+               mousepos.y = nSecondary;
+               return true;
+       }
+
+       if(bInputType == 2)
+               return false;
+
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
+
+       // ESC to exit (TAB-ESC works too)
+       if(nPrimary == K_ESCAPE)
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_Scoreboard_UI_Disable();
+               return true;
+       }
+
+       // block any input while a menu dialog is fading
+       if(autocvar__menu_alpha)
+       {
+               hudShiftState = 0;
+               return true;
+       }
+
+       // allow console bind to work
+       string con_keys = findkeysforcommand("toggleconsole", 0);
+       int keys = tokenize(con_keys); // findkeysforcommand returns data for this
+
+       bool hit_con_bind = false;
+       int i;
+       for (i = 0; i < keys; ++i)
+       {
+               if(nPrimary == stof(argv(i)))
+                       hit_con_bind = true;
+       }
+
+       if(key_pressed) {
+               if(nPrimary == K_ALT) hudShiftState |= S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
+               if(nPrimary == K_TAB) hudShiftState |= S_TAB;
+       }
+       else {
+               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
+               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
+               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
+               if(nPrimary == K_TAB) hudShiftState -= (hudShiftState & S_TAB);
+       }
+
+       if(nPrimary == K_TAB)
+       {
+               if (!key_pressed)
+                       return true;
+               if (scoreboard_ui_enabled == 2)
+               {
+                       if (hudShiftState & S_SHIFT)
+                               goto uparrow_action;
+                       else
+                               goto downarrow_action;
+               }
+
+               if (hudShiftState & S_SHIFT)
+               {
+                       --scoreboard_selected_panel;
+                       if (scoreboard_selected_panel == SB_PANEL_RANKINGS && !rankings_cnt)
+                               --scoreboard_selected_panel;
+                       if (scoreboard_selected_panel < SB_PANEL_FIRST)
+                               scoreboard_selected_panel = SB_PANEL_MAX;
+               }
+               else
+               {
+                       ++scoreboard_selected_panel;
+                       if (scoreboard_selected_panel == SB_PANEL_RANKINGS && !rankings_cnt)
+                               ++scoreboard_selected_panel;
+                       if (scoreboard_selected_panel > SB_PANEL_MAX)
+                               scoreboard_selected_panel = SB_PANEL_FIRST;
+               }
+
+               scoreboard_selected_panel_time = time;
+       }
+       else if(nPrimary == K_DOWNARROW)
+       {
+               if (!key_pressed)
+                       return true;
+               LABEL(downarrow_action);
+               if (scoreboard_selected_panel == SB_PANEL_SCOREBOARD)
+               {
+                       if (scoreboard_ui_enabled == 2)
+                       {
+                               entity curr_team = NULL;
+                               bool scoreboard_selected_team_found = false;
+                               if (!scoreboard_selected_team)
+                                       scoreboard_selected_team_found = true;
+
+                               for(entity tm = teams.sort_next; tm; tm = tm.sort_next)
+                               {
+                                       if(tm.team == NUM_SPECTATOR)
+                                               continue;
+                                       curr_team = tm;
+                                       if (scoreboard_selected_team_found)
+                                               goto ok_team;
+                                       if (scoreboard_selected_team == tm)
+                                               scoreboard_selected_team_found = true;
+                               }
+                               LABEL(ok_team);
+                               if (curr_team == scoreboard_selected_team) // loop reached the last team
+                                       curr_team = NULL;
+                               scoreboard_selected_team = curr_team;
+                       }
+                       else
+                       {
+                               entity pl, tm;
+                               entity curr_pl = NULL;
+                               bool scoreboard_selected_player_found = false;
+                               if (!scoreboard_selected_player)
+                                       scoreboard_selected_player_found = true;
+
+                               for(tm = teams.sort_next; tm; tm = tm.sort_next)
+                               {
+                                       if(tm.team != NUM_SPECTATOR)
+                                       for(pl = players.sort_next; pl; pl = pl.sort_next)
+                                       {
+                                               if(pl.team != tm.team)
+                                                       continue;
+                                               curr_pl = pl;
+                                               if (scoreboard_selected_player_found)
+                                                       goto ok_done;
+                                               if (scoreboard_selected_player == pl)
+                                                       scoreboard_selected_player_found = true;
+                                       }
+                               }
+                               LABEL(ok_done);
+                               if (curr_pl == scoreboard_selected_player) // loop reached the last player
+                                       curr_pl = NULL;
+                               scoreboard_selected_player = curr_pl;
+                       }
+               }
+       }
+       else if(nPrimary == K_UPARROW)
+       {
+               if (!key_pressed)
+                       return true;
+               LABEL(uparrow_action);
+               if (scoreboard_selected_panel == SB_PANEL_SCOREBOARD)
+               {
+                       if (scoreboard_ui_enabled == 2)
+                       {
+                               entity prev_team = NULL;
+                               for(entity tm = teams.sort_next; tm; tm = tm.sort_next)
+                               {
+                                       if(tm.team == NUM_SPECTATOR)
+                                               continue;
+                                       if (tm == scoreboard_selected_team)
+                                               goto ok_team2;
+                                       prev_team = tm;
+                               }
+                               LABEL(ok_team2);
+                               scoreboard_selected_team = prev_team;
+                       }
+                       else
+                       {
+                               entity prev_pl = NULL;
+                               entity pl, tm;
+                               for(tm = teams.sort_next; tm; tm = tm.sort_next)
+                               {
+                                       if(tm.team != NUM_SPECTATOR)
+                                       for(pl = players.sort_next; pl; pl = pl.sort_next)
+                                       {
+                                               if(pl.team != tm.team)
+                                                       continue;
+                                               if (pl == scoreboard_selected_player)
+                                                       goto ok_done2;
+                                               prev_pl = pl;
+                                       }
+                               }
+                               LABEL(ok_done2);
+                               scoreboard_selected_player = prev_pl;
+                       }
+               }
+       }
+       else if(nPrimary == K_RIGHTARROW)
+       {
+               if (!key_pressed)
+                       return true;
+               if (scoreboard_selected_panel == SB_PANEL_RANKINGS)
+                       rankings_start_column = min(rankings_start_column + 1, (ceil(RANKINGS_RECEIVED_CNT / rankings_rows) - rankings_columns));
+       }
+       else if(nPrimary == K_LEFTARROW)
+       {
+               if (!key_pressed)
+                       return true;
+               if (scoreboard_selected_panel == SB_PANEL_RANKINGS)
+                       rankings_start_column = max(rankings_start_column - 1, 0);
+       }
+       else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
+       {
+               if (!key_pressed)
+                       return true;
+               if (scoreboard_selected_panel == SB_PANEL_SCOREBOARD)
+               {
+                       if (scoreboard_ui_enabled == 2)
+                       {
+                               string team_name;
+                               if (!scoreboard_selected_team || (hudShiftState & S_SHIFT))
+                                       team_name = "auto";
+                               else
+                                       team_name = Static_Team_ColorName(scoreboard_selected_team.team);
+                               localcmd(sprintf("cmd selectteam %s; cmd join\n", team_name));
+                               HUD_Scoreboard_UI_Disable();
+                       }
+                       else if (scoreboard_selected_player)
+                               localcmd(sprintf("spectate %d\n", scoreboard_selected_player.sv_entnum + 1));
+               }
+       }
+       else if(nPrimary == 'c' && (hudShiftState & S_CTRL))
+       {
+               if (!key_pressed)
+                       return true;
+               if (scoreboard_ui_enabled == 1 && scoreboard_selected_panel == SB_PANEL_SCOREBOARD)
+               {
+                       switch (scoreboard_selected_columns_layout)
+                       {
+                               case 0:
+                                       if (autocvar_scoreboard_columns != "" && autocvar_scoreboard_columns != "all" && autocvar_scoreboard_columns != "default")
+                                       {
+                                               localcmd(sprintf("scoreboard_columns_set\n")); // sets the layout saved in scoreboard_columns
+                                               scoreboard_selected_columns_layout = 1;
+                                               break;
+                                       }
+                                       // fallthrough
+                               case 1:
+                                       localcmd(sprintf("scoreboard_columns_set default\n"));
+                                       scoreboard_selected_columns_layout = 2;
+                                       break;
+                               case 2:
+                                       localcmd(sprintf("scoreboard_columns_set all\n"));
+                                       scoreboard_selected_columns_layout = 0;
+                                       break;
+                       }
+               }
+       }
+       else if(nPrimary == 't' && (hudShiftState & S_CTRL))
+       {
+               if (!key_pressed)
+                       return true;
+               if (scoreboard_selected_panel == SB_PANEL_SCOREBOARD)
+               {
+                       if (scoreboard_selected_player)
+                       {
+                               localcmd(sprintf("commandmode tell \"%s^7\"\n", entcs_GetName(scoreboard_selected_player.sv_entnum)));
+                               HUD_Scoreboard_UI_Disable();
+                       }
+               }
+       }
+       else if(nPrimary == 'k' && (hudShiftState & S_CTRL))
+       {
+               if (!key_pressed)
+                       return true;
+               if (scoreboard_selected_panel == SB_PANEL_SCOREBOARD)
+               {
+                       if (scoreboard_selected_player)
+                               localcmd(sprintf("vcall kick \"%s^7\"\n", entcs_GetName(scoreboard_selected_player.sv_entnum)));
+               }
+       }
+       else if(hit_con_bind || nPrimary == K_PAUSE)
+               return false;
+
+       return true;
+}
+
 void PrintScoresLabels() { Label_getInfo(string_null, 1); }
 string TranslateScoresLabel(string label) { return Label_getInfo(label, 0); }
 
@@ -901,7 +1232,12 @@ void Scoreboard_DrawItem(vector item_pos, vector rgb, entity pl, bool is_self, i
        vector h_pos = item_pos;
        vector h_size = vec2(panel_size.x, hud_fontsize.y * 1.25);
        // alternated rows highlighting
-       if(is_self)
+       if (scoreboard_selected_panel == SB_PANEL_SCOREBOARD && scoreboard_ui_enabled == 1)
+       {
+               if (pl == scoreboard_selected_player)
+                       drawfill(h_pos, h_size, rgb, 0.44 * panel_fg_alpha, DRAWFLAG_NORMAL);
+       }
+       else if(is_self)
                drawfill(h_pos, h_size, rgb, sbt_highlight_alpha_self, DRAWFLAG_NORMAL);
        else if((sbt_highlight) && (!(pl_number % 2)))
                drawfill(h_pos, h_size, rgb, sbt_highlight_alpha, DRAWFLAG_NORMAL);
@@ -1070,6 +1406,16 @@ vector Scoreboard_DrawOthers(vector item_pos, vector rgb, int this_team, entity
                        }
                }
 
+               if (scoreboard_selected_panel == SB_PANEL_SCOREBOARD && scoreboard_ui_enabled == 1)
+               {
+                       if (pl == scoreboard_selected_player)
+                       {
+                               h_size.x = column_width + hud_fontsize.x * 0.25;
+                               h_size.y = hud_fontsize.y;
+                               drawfill(pos - hud_fontsize.x * 0.25 * eX, h_size, rgb, 0.44 * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       }
+               }
+
                vector name_pos = pos;
                if((this_team == NUM_SPECTATOR) && autocvar_hud_panel_scoreboard_spectators_aligned)
                        name_pos.x += max(fieldsize, min_fieldsize) + 2 * fieldpadding + hud_fontsize.x * 0.25;
@@ -1124,6 +1470,12 @@ vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
        panel_pos = pos;
        panel_size.y = 1.25 * hud_fontsize.y * (1 + bound(1, tm.team_size, max_players));
        panel_size.y += panel_bg_padding * 2;
+
+       vector scoreboard_selected_hl_pos = pos;
+       vector scoreboard_selected_hl_size = '0 0 0';
+       scoreboard_selected_hl_size.x = scoreboard_right - scoreboard_left;
+       scoreboard_selected_hl_size.y = panel_size.y;
+
        HUD_Panel_DrawBg();
 
        vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
@@ -1185,13 +1537,39 @@ vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
                ++i;
        }
 
+       if (scoreboard_selected_panel == SB_PANEL_SCOREBOARD)
+       {
+               if (scoreboard_ui_enabled == 1 || (tm && scoreboard_selected_team == tm))
+               {
+                       float _alpha = (scoreboard_ui_enabled == 2) ? 0.2 : 0.3 * max(0, (1 - (time - scoreboard_selected_panel_time) * 2));
+                       _alpha *= panel_fg_alpha;
+                       if (_alpha)
+                               drawfill(scoreboard_selected_hl_pos, scoreboard_selected_hl_size, '1 1 1', _alpha, DRAWFLAG_NORMAL);
+               }
+       }
+
        panel_size.x += panel_bg_padding * 2; // restore initial width
        return end_pos;
 }
 
 bool Scoreboard_WouldDraw()
 {
-       if (MUTATOR_CALLHOOK(DrawScoreboard))
+       if (scoreboard_ui_enabled)
+       {
+               if (scoreboard_ui_disabling)
+               {
+                       if (scoreboard_fade_alpha == 0)
+                               HUD_Scoreboard_UI_Disable_Instantly();
+                       return false;
+               }
+               if (intermission && scoreboard_ui_enabled == 2)
+               {
+                       HUD_Scoreboard_UI_Disable_Instantly();
+                       return false;
+               }
+               return true;
+       }
+       else if (MUTATOR_CALLHOOK(DrawScoreboard))
                return false;
        else if (QuickMenu_IsOpened())
                return false;
@@ -1564,9 +1942,6 @@ vector Scoreboard_MapStats_Draw(vector pos, vector rgb, vector bg_size) {
        return end_pos;
 }
 
-int rankings_rows = 0;
-int rankings_columns = 0;
-int rankings_cnt = 0;
 vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector rgb, vector bg_size)
 {
        int i;
@@ -1580,11 +1955,17 @@ vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector
 
        vector hl_rgb = rgb + '0.5 0.5 0.5';
 
+       vector scoreboard_selected_hl_pos = pos;
+
        drawstring(pos + eX * panel_bg_padding, ranktitle, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
        pos.y += 1.25 * hud_fontsize.y;
        if(panel.current_panel_bg != "0")
                pos.y += panel_bg_border;
 
+       vector scoreboard_selected_hl_size = '0 0 0';
+       scoreboard_selected_hl_size.x = scoreboard_right - scoreboard_left;
+       scoreboard_selected_hl_size.y = pos.y - scoreboard_selected_hl_pos.y;
+
        panel_pos = pos;
 
        float namesize = 0;
@@ -1619,6 +2000,7 @@ vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector
 
        panel_size.y = rankings_rows * 1.25 * hud_fontsize.y;
        panel_size.y += panel_bg_padding * 2;
+       scoreboard_selected_hl_size.y += panel_size.y;
 
        HUD_Panel_DrawBg();
 
@@ -1641,16 +2023,16 @@ vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector
        string str = "";
        int column = 0, j = 0;
        string zoned_name_self = strzone(strdecolorize(entcs_GetName(player_localnum)));
-       for(i = 0; i < rankings_cnt; ++i)
+       int start_item = rankings_start_column * rankings_rows;
+       for(i = start_item; i < start_item + rankings_cnt; ++i)
        {
-               float t;
-               t = grecordtime[i];
+               int t = grecordtime[i];
                if (t == 0)
                        continue;
 
                if(strdecolorize(grecordholder[i]) == zoned_name_self)
                        drawfill(pos, columnsize, hl_rgb, sbt_highlight_alpha_self, DRAWFLAG_NORMAL);
-               else if(!((j + column) & 1) && sbt_highlight)
+               else if(!((j + rankings_start_column + column) & 1) && sbt_highlight)
                        drawfill(pos, columnsize, hl_rgb, sbt_highlight_alpha, DRAWFLAG_NORMAL);
 
                str = count_ordinal(i+1);
@@ -1673,11 +2055,16 @@ vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector
        }
        strfree(zoned_name_self);
 
+       if (scoreboard_selected_panel == SB_PANEL_RANKINGS)
+       {
+               float fade = max(0, (1 - (time - scoreboard_selected_panel_time) * 2));
+               drawfill(scoreboard_selected_hl_pos, scoreboard_selected_hl_size, '1 1 1', fade * 0.44, DRAWFLAG_NORMAL);
+       }
+
        panel_size.x += panel_bg_padding * 2; // restore initial width
        return end_pos;
 }
 
-float scoreboard_time;
 bool have_weapon_stats;
 bool Scoreboard_AccuracyStats_WouldDraw(float ypos)
 {
@@ -1862,73 +2249,90 @@ void Scoreboard_Draw()
        sb_gameinfo_detail_fontsize = hud_fontsize * 1.3;
 
        // Game Info: Game Type
-       str = MapInfo_Type_ToText(gametype);
+       if (scoreboard_ui_enabled == 2)
+               str = _("Team Selection");
+       else
+               str = MapInfo_Type_ToText(gametype);
        draw_beginBoldFont();
        drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_type_fontsize)), str, sb_gameinfo_type_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
        draw_endBoldFont();
 
+       pos.y += sb_gameinfo_type_fontsize.y;
        // Game Info: Game Detail
-       float tl = STAT(TIMELIMIT);
-       float fl = STAT(FRAGLIMIT);
-       float ll = STAT(LEADLIMIT);
-       float ll_and_fl = STAT(LEADLIMIT_AND_FRAGLIMIT);
-       str = "";
-       if(tl > 0)
-               str = strcat(str, sprintf(_("^3%1.0f minutes"), tl));
-       if(!gametype.m_hidelimits)
-       {
-               if(fl > 0)
-               {
-                       if(tl > 0)
-                               str = strcat(str, "^7 / "); // delimiter
-                       if(teamplay)
-                       {
-                               str = strcat(str, sprintf(_("^5%s %s"), ScoreString(teamscores_flags(ts_primary), fl),
-                                       (teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
-                                       (teamscores_label(ts_primary) == "fastest") ? "" :
-                                       TranslateScoresLabel(teamscores_label(ts_primary))));
-                       }
-                       else
-                       {
-                               str = strcat(str, sprintf(_("^5%s %s"), ScoreString(scores_flags(ps_primary), fl),
-                                       (scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
-                                       (scores_label(ps_primary) == "fastest") ? "" :
-                                       TranslateScoresLabel(scores_label(ps_primary))));
-                       }
-               }
-               if(ll > 0)
+       if (scoreboard_ui_enabled == 2)
+       {
+               if (scoreboard_selected_team)
+                       str = sprintf(_("^7Press ^3%s^7 to join the selected team"), getcommandkey(_("jump"), "+jump"));
+               else
+                       str = sprintf(_("^7Press ^3%s^7 to auto-select a team and join"), getcommandkey(_("jump"), "+jump"));
+               drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+
+               pos.y += sb_gameinfo_detail_fontsize.y + hud_fontsize.y * 0.3;
+               str = sprintf(_("^7Press ^3%s ^7to select a specific team"), translate_key("TAB"));
+               drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+       }
+       else
+       {
+               float tl = STAT(TIMELIMIT);
+               float fl = STAT(FRAGLIMIT);
+               float ll = STAT(LEADLIMIT);
+               float ll_and_fl = STAT(LEADLIMIT_AND_FRAGLIMIT);
+               str = "";
+               if(tl > 0)
+                       str = strcat(str, sprintf(_("^3%1.0f minutes"), tl));
+               if(!gametype.m_hidelimits)
                {
-                       if(tl > 0 || fl > 0)
+                       if(fl > 0)
                        {
-                               // delimiter
-                               if (ll_and_fl && fl > 0)
-                                       str = strcat(str, "^7 & ");
+                               if(tl > 0)
+                                       str = strcat(str, "^7 / "); // delimiter
+                               if(teamplay)
+                               {
+                                       str = strcat(str, sprintf(_("^5%s %s"), ScoreString(teamscores_flags(ts_primary), fl),
+                                               (teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
+                                               (teamscores_label(ts_primary) == "fastest") ? "" :
+                                               TranslateScoresLabel(teamscores_label(ts_primary))));
+                               }
                                else
-                                       str = strcat(str, "^7 / ");
-                       }
-
-                       if(teamplay)
-                       {
-                               str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(teamscores_flags(ts_primary), ll),
-                                       (teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
-                                       (teamscores_label(ts_primary) == "fastest") ? "" :
-                                       TranslateScoresLabel(teamscores_label(ts_primary))));
+                               {
+                                       str = strcat(str, sprintf(_("^5%s %s"), ScoreString(scores_flags(ps_primary), fl),
+                                               (scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
+                                               (scores_label(ps_primary) == "fastest") ? "" :
+                                               TranslateScoresLabel(scores_label(ps_primary))));
+                               }
                        }
-                       else
+                       if(ll > 0)
                        {
-                               str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(scores_flags(ps_primary), ll),
-                                       (scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
-                                       (scores_label(ps_primary) == "fastest") ? "" :
-                                       TranslateScoresLabel(scores_label(ps_primary))));
+                               if(tl > 0 || fl > 0)
+                               {
+                                       // delimiter
+                                       if (ll_and_fl && fl > 0)
+                                               str = strcat(str, "^7 & ");
+                                       else
+                                               str = strcat(str, "^7 / ");
+                               }
+
+                               if(teamplay)
+                               {
+                                       str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(teamscores_flags(ts_primary), ll),
+                                               (teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
+                                               (teamscores_label(ts_primary) == "fastest") ? "" :
+                                               TranslateScoresLabel(teamscores_label(ts_primary))));
+                               }
+                               else
+                               {
+                                       str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(scores_flags(ps_primary), ll),
+                                               (scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
+                                               (scores_label(ps_primary) == "fastest") ? "" :
+                                               TranslateScoresLabel(scores_label(ps_primary))));
+                               }
                        }
                }
+               drawcolorcodedstring(pos + '1 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align right
+               // map name
+               str = sprintf(_("^7Map: ^2%s"), shortmapname);
+               drawcolorcodedstring(pos, str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align left
        }
-
-       pos.y += sb_gameinfo_type_fontsize.y;
-       drawcolorcodedstring(pos + '1 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align right
-       // map name
-       str = sprintf(_("^7Map: ^2%s"), shortmapname);
-       drawcolorcodedstring(pos, str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align left
        // End of Game Info Section
 
        pos.y += sb_gameinfo_detail_fontsize.y + hud_fontsize.y * 0.3; // space between Game Info Section and score table
@@ -2080,16 +2484,22 @@ void Scoreboard_Draw()
        if(MUTATOR_CALLHOOK(ShowRankings)) {
                string ranktitle = M_ARGV(0, string);
                string unit = GetSpeedUnit(autocvar_hud_panel_physics_speed_unit);
-               if(race_speedaward) {
-                       drawcolorcodedstring(pos, sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, unit, ColorTranslateRGB(race_speedaward_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
-                       pos.y += 1.25 * hud_fontsize.y;
-               }
-               if(race_speedaward_alltimebest) {
-                       drawcolorcodedstring(pos, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, unit, ColorTranslateRGB(race_speedaward_alltimebest_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
-                       pos.y += 1.25 * hud_fontsize.y;
+               if(race_speedaward_alltimebest)
+               {
+                       string name;
+                       float namesize = autocvar_hud_panel_scoreboard_namesize * hud_fontsize.x;
+                       str = "";
+                       if(race_speedaward)
+                       {
+                               name = textShortenToWidth(ColorTranslateRGB(race_speedaward_holder), namesize, hud_fontsize, stringwidth_colors);
+                               str = sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, unit, name);
+                               str = strcat(str, " / ");
+                       }
+                       name = textShortenToWidth(ColorTranslateRGB(race_speedaward_alltimebest_holder), namesize, hud_fontsize, stringwidth_colors);
+                       str = strcat(str, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, unit, name));
+                       drawcolorcodedstring(pos, str, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       pos.y += 1.25 * hud_fontsize.y; // line height + line spacing
                }
-               if (race_speedaward || race_speedaward_alltimebest)
-                       pos.y += 0.25 * hud_fontsize.y;
                pos = Scoreboard_Rankings_Draw(pos, ranktitle, playerslots[player_localnum], panel_bg_color, bg_size);
        }
        else
index cd43b341ec78ab041ab7a04db67b1135decb7a64..76a22d533d8a645cdbd9c88b05291206dad3356d 100644 (file)
@@ -23,3 +23,20 @@ void Scoreboard_UpdatePlayerTeams();
 void Scoreboard_UpdatePlayerPos(entity pl);
 void Scoreboard_UpdateTeamPos(entity Team);
 bool Scoreboard_WouldDraw();
+void Scoreboard_UI_Enable(int mode);
+
+int scoreboard_ui_enabled;
+bool autocvar__scoreboard_team_selection;
+float HUD_Scoreboard_InputEvent(float bInputType, float nPrimary, float nSecondary);
+
+int scoreboard_selected_panel;
+float scoreboard_selected_panel_time;
+entity scoreboard_selected_player;
+entity scoreboard_selected_team;
+int scoreboard_selected_columns_layout;
+
+// start from 1
+int SB_PANEL_FIRST = 1;
+int SB_PANEL_SCOREBOARD = 1;
+int SB_PANEL_RANKINGS = 2;
+int SB_PANEL_MAX = 2;
index 091cc466183efecd96bda5291383c2aab720acda..f7bcb25957c8c5d3f49cdf9e8eea546f86320400 100644 (file)
@@ -443,6 +443,15 @@ void PostInit()
        postinit = true;
 }
 
+void Release_Common_Keys()
+{
+       localcmd("-fire\n");
+       localcmd("-fire2\n");
+       localcmd("-use\n");
+       localcmd("-hook\n");
+       localcmd("-jump\n");
+}
+
 // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
 // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
 // All keys are in ascii.
@@ -455,6 +464,10 @@ float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary)
        TC(int, bInputType);
        bool override = false;
 
+       override |= HUD_Scoreboard_InputEvent(bInputType, nPrimary, nSecondary);
+       if (override)
+               return true;
+
        override |= HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary);
        if (override)
                return true;
@@ -482,15 +495,23 @@ float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary)
                if(nPrimary == K_ALT) hudShiftState |= S_ALT;
                if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
                if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
+               if(nPrimary == K_TAB) hudShiftState |= S_TAB;
        }
        else {
                if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
                if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
                if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
+               if(nPrimary == K_TAB) hudShiftState -= (hudShiftState & S_TAB);
        }
 
+       // NOTE: Shift-Escape must be filtered out because it's the hardcoded console shortcut
        if (nPrimary == K_ESCAPE && !(hudShiftState & S_SHIFT) && key_pressed)
        {
+               if (hudShiftState & S_TAB)
+               {
+                       Scoreboard_UI_Enable(0);
+                       return true;
+               }
                if (!isdemo() && cvar("_menu_gamemenu_dialog_available"))
                {
                        localcmd("\nmenu_showgamemenudialog\n");
index 7be53f6dee116b558d6a14a931c7aee72bf5d991..4d1271c4195b519ae11c6e952ac0bcd12f39da93 100644 (file)
@@ -115,6 +115,8 @@ string _getcommandkey(string text, string command, bool forcename);
 #define getcommandkey(cmd_name, command) _getcommandkey(cmd_name, command, false)
 #define getcommandkey_forcename(cmd_name, command) _getcommandkey(cmd_name, command, true)
 
+void Release_Common_Keys();
+
 string vote_called_vote;
 bool ready_waiting;
 bool ready_waiting_for_me;
index a183c82d0ad04e2482cf522e73b94399d596cffd..f10d03379aeba37f82bc30858cc822e38ec5765f 100644 (file)
@@ -1711,6 +1711,11 @@ void CSQC_UpdateView(entity this, float w, float h)
        Debug_Draw();
 #endif
 
+       if (autocvar__scoreboard_team_selection)
+       {
+               Scoreboard_UI_Enable(1);
+               cvar_set("_scoreboard_team_selection", "0");
+       }
        scoreboard_active = Scoreboard_WouldDraw();
 
        HUD_Draw(this); // this parameter for deep vehicle function
index c76af8ceed148338342b68afcef70798071d3768..abaac730949ea2238a4ddbcfb55e2b2910017edb 100644 (file)
@@ -111,7 +111,7 @@ void KeyBinds_BuildList()
 
        KEYBIND_HEADER(_("Teamplay"));
        KEYBIND_DEF("team_auto"                             , _("auto-join team"));
-       KEYBIND_DEF("menu_showteamselect"                   , _("team menu"));
+       KEYBIND_DEF("scoreboard_team_selection"             , _("team selection"));
        KEYBIND_DEF("spec"                                  , _("spectate"));
        KEYBIND_EMPTY_LINE();
 
index 2e6e9e6b852c84a6b6ffe5bec87524fb59e6a260..68d396d60a7827beb1d8e75e9aa06e74cc291c83 100644 (file)
@@ -1949,7 +1949,8 @@ bool ShowTeamSelection(entity this)
 {
        if (!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || this.team_selected || (CS(this).wasplayer && autocvar_g_changeteam_banned) || Player_HasRealForcedTeam(this))
                return false;
-       stuffcmd(this, "menu_showteamselect\n");
+       if (frametime) // once per frame is more than enough
+               stuffcmd(this, "scoreboard_team_selection\n");
        return true;
 }
 void Join(entity this)
index 9feb068a812bdd377f7bf9a6822cdf0217a52104..0ffd87e866480ecfc097f5fb1c272eb1dba3ba8a 100644 (file)
@@ -114,7 +114,7 @@ void ClientCommand_clientversion(entity caller, int request, int argc)  // inter
                                        else if (teamplay && !autocvar_sv_spectate && !(Player_GetForcedTeamIndex(caller) > 0))
                                        {
                                                TRANSMUTE(Observer, caller);  // really?
-                                               stuffcmd(caller, "menu_showteamselect\n");
+                                               stuffcmd(caller, "scoreboard_team_selection\n");
                                        }
                                }