]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/Main.qc
initial work on notify panel, some centerprints now will be different depending on...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / Main.qc
index d16e91820e1a31cdda5a0406791331e1d1b777d8..a48c2c57c9777e26449414f7b0a4c2193e8c6720 100644 (file)
@@ -60,6 +60,10 @@ void CSQC_Init(void)
        
        check_unacceptable_compiler_bugs();
 
+#ifdef WATERMARK
+       print("^4CSQC Build information: ", WATERMARK(), "\n");
+#endif
+
        float i;
        CSQC_CheckEngine();
 
@@ -82,6 +86,8 @@ void CSQC_Init(void)
        // localcmd("alias order \"cmd order $*\""); enable if ctf-command thingy is used
        //registercmd("ctf_menu");
        registercmd("ons_map");
+       registercmd("hud_configure");
+       registercmd("hud_save");
        //registercmd("menu_action");
 
        registercmd("+button3");
@@ -105,14 +111,14 @@ void CSQC_Init(void)
 #ifndef CAMERATEST
        }
 #endif
-       registercvar("sbar_usecsqc", "1");
-       registercvar("sbar_columns", "default", CVAR_SAVE);
+       registercvar("hud_usecsqc", "1");
+       registercvar("hud_columns", "default", CVAR_SAVE);
 
        gametype = 0;
 
-       // sbar_fields uses strunzone on the titles!
-       for(i = 0; i < MAX_SBAR_FIELDS; ++i)
-               sbar_title[i] = strzone("(null)");
+       // hud_fields uses strunzone on the titles!
+       for(i = 0; i < MAX_HUD_FIELDS; ++i)
+               hud_title[i] = strzone("(null)");
 
        postinit = false;
 
@@ -321,9 +327,9 @@ void Playerchecker_Think()
                                e.ping_packetloss = 0;
                                e.ping_movementloss = 0;
                                //e.gotscores = 0; // we might already have the scores...
-                               SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with Sbar_UpdatePlayerTeams
+                               SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
                                RegisterPlayer(e);
-                               Sbar_UpdatePlayerPos(e);
+                               HUD_UpdatePlayerPos(e);
                        }
                }
        }
@@ -335,7 +341,7 @@ void TrueAim_Init();
 void PostInit(void)
 {
        print(strcat("PostInit\n    maxclients = ", ftos(maxclients), "\n"));
-       localcmd(strcat("\nsbar_columns_set ", cvar_string("sbar_columns"), ";\n"));
+       localcmd(strcat("\nhud_columns_set ", cvar_string("hud_columns"), ";\n"));
 
        entity playerchecker;
        playerchecker = spawn();
@@ -351,8 +357,8 @@ void PostInit(void)
 // CSQC_ConsoleCommand : Used to parse commands in the console that have been registered with the "registercmd" function
 // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
 float button_zoom;
-void Cmd_Sbar_SetFields(float);
-void Cmd_Sbar_Help(float);
+void Cmd_HUD_SetFields(float);
+void Cmd_HUD_Help(float);
 float CSQC_ConsoleCommand(string strMessage)
 {
        float argc;
@@ -364,7 +370,18 @@ float CSQC_ConsoleCommand(string strMessage)
        local string strCmd;
        strCmd = argv(0);
 
-       if(strCmd == "+button4") { // zoom
+       if(strCmd == "hud_configure") { // config hud
+               cvar_set("_hud_configure", ftos(!cvar("_hud_configure")));
+               return true;
+       } else if(strCmd == "hud_save") { // save hud config
+               if(argv(1) == "" || argv(2)) {
+                       print("Usage:\n");
+                       print("hud_save configname   (saves to hud_skinname_configname.cfg)\n");
+               }
+               else
+                       HUD_Panel_ExportCfg(argv(1));
+               return true;
+       } else if(strCmd == "+button4") { // zoom
                // return false, because the message shall be sent to the server anyway (for demos/speccing)
                if(ignore_plus_zoom)
                {
@@ -505,9 +522,8 @@ void GameCommand(string msg)
        {
                print("Usage: cl_cmd COMMAND..., where possible commands are:\n");
                print("  settemp cvar value\n");
-               print("  radar\n");
-               print("  sbar_columns_set ...\n");
-               print("  sbar_columns_help\n");
+               print("  hud_columns_set ...\n");
+               print("  hud_columns_help\n");
                GameCommand_Generic("help");
                return;
        }
@@ -523,14 +539,11 @@ void GameCommand(string msg)
        else if(cmd == "settemp") {
                cvar_clientsettemp(argv(1), argv(2));
        }
-       else if(cmd == "radar") {
-               ons_showmap = !ons_showmap;
-       }
-       else if(cmd == "sbar_columns_set") {
-               Cmd_Sbar_SetFields(argc);
+       else if(cmd == "hud_columns_set") {
+               Cmd_HUD_SetFields(argc);
        }
-       else if(cmd == "sbar_columns_help") {
-               Cmd_Sbar_Help(argc);
+       else if(cmd == "hud_columns_help") {
+               Cmd_HUD_Help(argc);
        }
 #ifdef BLURTEST
        else if(cmd == "blurtest") {
@@ -584,12 +597,16 @@ void GameCommand(string msg)
                localcmd("sv_cmd debug_shotorg\n");
        }
        else if(cmd == "sendcvar") {
-               s = cvar_string(argv(1));
-               if(argv(1) == "cl_weaponpriority")
+               // W_FixWeaponOrder will trash argv, so save what we need.
+               string thiscvar;
+               thiscvar = strzone(argv(1));
+               s = cvar_string(thiscvar);
+               if(thiscvar == "cl_weaponpriority")
                        s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
-               else if(substring(argv(1), 0, 17) == "cl_weaponpriority" && strlen(argv(1)) == 18)
+               else if(substring(thiscvar, 0, 17) == "cl_weaponpriority" && strlen(thiscvar) == 18)
                        s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
-               localcmd("cmd sentcvar ", argv(1), " \"", s, "\"\n");
+               localcmd("cmd sentcvar ", thiscvar, " \"", s, "\"\n");
+               strunzone(thiscvar);
        }
        else if(cmd == "spawn") {
                s = argv(1);
@@ -615,11 +632,16 @@ void GameCommand(string msg)
 // bInputType = 0 is key pressed, 1 is key released, 2 is mouse input.
 // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
 // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
+float hudconf_active;
 float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 {
        local float bSkipKey;
        bSkipKey = false;
 
+       if(hudconf_active)
+               if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
+                       return true;
+
        if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
                return true;
 
@@ -670,7 +692,7 @@ void Ent_ReadPlayerScore()
        float isNew;
        entity o;
 
-       // damnit -.- don't want to go change every single .sv_entnum in sbar.qc AGAIN
+       // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
        // (no I've never heard of M-x replace-string, sed, or anything like that)
        isNew = !self.owner; // workaround for DP bug
        n = ReadByte()-1;
@@ -716,7 +738,7 @@ void Ent_ReadPlayerScore()
                }
 
        if(o.sort_prev)
-               Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
+               HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
 
        self.entremove = Ent_RemovePlayerScore;
 }
@@ -747,7 +769,7 @@ void Ent_ReadTeamScore()
                                o.(teamscores[i]) = ReadChar();
                }
 
-       Sbar_UpdateTeamPos(o);
+       HUD_UpdateTeamPos(o);
 }
 
 void Net_Reset()
@@ -995,7 +1017,7 @@ void Ent_ScoresInfo()
                teamscores_label[i] = strzone(ReadString());
                teamscores_flags[i] = ReadByte();
        }
-       Sbar_InitScores();
+       HUD_InitScores();
        Gamemode_Init();
 }
 
@@ -1221,6 +1243,20 @@ void Net_VoteDialogReset() {
        vote_active = 0;
 }
 
+void Net_Notify() {
+       float type;
+       type = ReadByte();
+
+       if(type == CSQC_KILLNOTIFY)
+       {
+               HUD_KillNotify(ReadString(), ReadString(), ReadByte());
+       }
+       else if(type == CSQC_CENTERPRINT)
+       {
+               HUD_Centerprint(ReadString(), ReadByte());
+       }
+}
+
 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
@@ -1287,6 +1323,10 @@ float CSQC_Parse_TempEntity()
                        announce_snd = strzone(ReadString());
                        bHandled = true;
                        break;
+               case TE_CSQC_NOTIFY:
+                       Net_Notify();
+                       bHandled = true;
+                       break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;
@@ -1301,7 +1341,7 @@ string getcommandkey(string text, string command)
        string keys;
        float n, j, k, l;
 
-       if (!sbar_showbinds)
+       if (!hud_showbinds)
                return text;
 
        keys = db_get(binddb, command);
@@ -1319,7 +1359,7 @@ string getcommandkey(string text, string command)
                                        keys = strcat(keys, ", ", keynumtostring(k));
 
                                ++l;
-                               if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break;
+                               if (hud_showbinds_limit > 0 && hud_showbinds_limit >= l) break;
                        }
 
                }
@@ -1327,12 +1367,12 @@ string getcommandkey(string text, string command)
        }
 
        if ("" == keys) {
-               if (sbar_showbinds > 1)
+               if (hud_showbinds > 1)
                        return strcat(text, " (not bound)");
                else
                        return text;
        }
-       else if (sbar_showbinds > 1)
+       else if (hud_showbinds > 1)
                return strcat(text, " (", keys, ")");
        else
                return keys;