]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Autocompletion by # SHIFT-TAB: display the next 3 players names too in the infobar...
authorterencehill <piuntn@gmail.com>
Fri, 27 Sep 2024 10:18:13 +0000 (12:18 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 27 Sep 2024 21:01:53 +0000 (23:01 +0200)
cl_screen.c
cl_screen.h
console.c

index 7c2ab0dc02a1cc4360038acc9c6b2b584a37f7f9..cb14dbb5cc5a99b55c9b5fe1a4e14920b7a02951 100644 (file)
@@ -684,6 +684,13 @@ static int SCR_InfobarHeight(void)
        return offset;
 }
 
+int SCR_Infobar(float bartime, char *barstring)
+{
+       scr_infobartime_off = bartime;
+       dp_strlcpy(scr_infobarstring, barstring, sizeof(scr_infobarstring));
+}
+
+
 /*
 ==============
 SCR_InfoBar_f
index 57cfd282a135f2b2c027afda24556d6f455f51e9..798861e76e12fa7ec3b8c598b7e1e687f4d451de 100644 (file)
@@ -27,5 +27,7 @@ void CL_UpdateScreen(void);
 qbool R_Stereo_Active(void);
 qbool R_Stereo_ColorMasking(void);
 
+int SCR_Infobar(float bartime, char *barstring);
+
 #endif
 
index 4b5dc8169436441c76cc2602d8aecf06b33a25f0..3667204fc9ce27f017aef0b109a15df713bebbdc 100644 (file)
--- a/console.c
+++ b/console.c
@@ -2619,10 +2619,36 @@ static int Nicks_CompleteCountPossible(char *line, int pos, char *s, qbool isCon
        return count;
 }
 
-static void Cmd_CompleteNicksPrint(int count, int hash_completion)
+static void Cmd_CompleteNicksPrint(int count, int hash_completion, qbool infobar)
 {
-       int i;
-       for(i = 0; i < count; ++i)
+       if (infobar)
+       {
+               char pl_list[MAX_INPUTLINE] = "";
+               int initial = hash_completion_player;
+               int next = initial;
+               int next_players_count = 3;
+
+               dpsnprintf(pl_list, sizeof(pl_list), "#%d %s", hash_completion_player + 1, Nicks_list[0]);
+               while(next_players_count >= 0)
+               {
+                       next = (next + 1) % cl.maxclients;
+                       if (next == initial)
+                               break;
+                       if (cl.scores[next].name[0])
+                       {
+                               if (next_players_count == 0)
+                                       dpsnprintf(pl_list, sizeof(pl_list), "%s^8, ...", pl_list);
+                               else
+                                       dpsnprintf(pl_list, sizeof(pl_list), "%s^8, #%d ^7%s", pl_list, next + 1, cl.scores[next].name);
+                               --next_players_count;
+                       }
+               }
+
+               SCR_Infobar(2, pl_list);
+               return;
+       }
+
+       for(int i = 0; i < count; ++i)
        {
                if (hash_completion == 1 && hash_completion_player >= 0)
                        Con_Printf("#%d %s\n", hash_completion_player + 1, Nicks_list[i]);
@@ -3181,10 +3207,18 @@ nicks:
        n = Nicks_CompleteCountPossible(line, linepos, s, is_console, hash_completion);
        if (n)
        {
-               Con_Printf("\n%i possible nick%s\n", n, (n > 1) ? "s: " : ":");
-               Cmd_CompleteNicksPrint(n, hash_completion);
-               if (hash_completion == 1 && hash_completion_player >= 0)
+               if (!is_console && hash_completion == 1 && hash_completion_player >= 0)
+               {
+                       Cmd_CompleteNicksPrint(n, hash_completion, true); // print to infobar
                        n = 0; // cycle player names without autocompleting
+               }
+               else
+               {
+                       Con_Printf("\n%i possible nick%s\n", n, (n > 1) ? "s: " : ":");
+                       Cmd_CompleteNicksPrint(n, hash_completion, false);
+                       if (hash_completion == 1 && hash_completion_player >= 0)
+                               n = 0; // cycle player names without autocompleting
+               }
        }
 
        if (!(c + v + a + n))   // No possible matches