]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a welcome dialog to the menu that shows up upon connection to the server
authorterencehill <piuntn@gmail.com>
Mon, 19 Aug 2013 20:27:05 +0000 (22:27 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 19 Aug 2013 20:27:05 +0000 (22:27 +0200)
qcsrc/client/Main.qc
qcsrc/common/constants.qh
qcsrc/menu/classes.c
qcsrc/menu/command/menu_cmd.qc
qcsrc/menu/skin-customizables.inc
qcsrc/menu/xonotic/dialog_welcome.c [new file with mode: 0644]
qcsrc/menu/xonotic/mainwindow.c
qcsrc/server/cl_client.qc

index 42fadc0c18a86b0cc0cec1eb145409adebe08efb..973325c382b1e925077947e98e8c70f27e278997 100644 (file)
@@ -1187,6 +1187,11 @@ void Net_WeaponComplain()
        }
 }
 
+void Net_ReadServerInfo()
+{
+       localcmd("\nmenu_cmd directmenu Welcome serverinfo_name \"", ReadString() , "\" serverinfo_ip \"", ReadString(), "\" serverinfo_MOTD \"", ReadString(), "\"\n");
+}
+
 // 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.
@@ -1248,6 +1253,10 @@ float CSQC_Parse_TempEntity()
                        cl_notice_read();
                        bHandled = true;
                        break;
+               case TE_CSQC_SERVERINFO:
+                       Net_ReadServerInfo();
+                       bHandled = true;
+                       break;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
                        bHandled = false;
index 1a70b341d3d8118aef7ecff219d5c8bb13e445d0..7ec36abe1102d49ec24011dbf28663aee8a27f9f 100644 (file)
@@ -42,6 +42,7 @@ const float TE_CSQC_MINELAYER_MAXMINES = 110;
 const float TE_CSQC_HAGAR_MAXROCKETS = 111;
 const float TE_CSQC_VEHICLESETUP = 112;
 const float TE_CSQC_SVNOTICE = 113;
+const float TE_CSQC_SERVERINFO = 114;
 
 const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder
 const float RACE_NET_CHECKPOINT_CLEAR = 1;
index f00971674ef8bca06675809fcc1526744450969b..f1f4905bfda5c014a2963219b892ff2e77305dd8 100644 (file)
@@ -27,6 +27,7 @@
 #include "xonotic/commandbutton.c"
 #include "xonotic/bigcommandbutton.c"
 #include "xonotic/dialog_firstrun.c"
+#include "xonotic/dialog_welcome.c"
 #include "xonotic/dialog_teamselect.c"
 #include "xonotic/dialog_sandboxtools.c"
 #include "xonotic/dialog_settings.c"
index 2c0b1edf38aa33fcd42e6117bf4a5c6c108bd04a..f4d0565395730ec728e53d484a0e98b9bc2ce4d4 100644 (file)
@@ -53,6 +53,9 @@ void GameCommand(string theCommand)
 
        if(argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
        {
+               float i;
+               entity e;
+               string s;
                string filter = string_null;
                if(argv(0) == "directpanelhudmenu")
                        filter = strzone("HUD");
@@ -60,9 +63,6 @@ void GameCommand(string theCommand)
                if(argc == 1)
                {
                        print(_("Available options:\n"));
-                       float i;
-                       entity e;
-                       string s;
 
                        for(i = 0, e = world; (e = nextent(e)); )
                                if(e.classname != "vtbl" && e.name != "")
@@ -80,6 +80,16 @@ void GameCommand(string theCommand)
                }
                else if(argc == 2 && !isdemo()) // don't allow this command in demos
                        m_goto(strcat(filter, argv(1))); // switch to a menu item
+               else if(argc > 2 && !isdemo())
+               {
+                       for(i = 0, e = world; (e = nextent(e)); )
+                               if(e.classname != "vtbl" && e.name == strcat(filter, argv(1)))
+                                       if(e.readInputArgs)
+                                       {
+                                               e.readInputArgs(e, 2, argc - 1);
+                                               m_goto(strcat(filter, argv(1)));
+                                       }
+               }
                if(filter)
                        strunzone(filter);
                return;
index 6b5cac042ca970af7df0cc83c1c4e9f5e5e14585..9a9f124ba3859d904498a60d581b7c23c57f5827 100644 (file)
@@ -69,6 +69,7 @@ SKINBEGIN
        SKINVECTOR(COLOR_DIALOG_CROSSHAIR, '1 0.7 0.7');
        SKINVECTOR(COLOR_DIALOG_HUD, '1 0.7 0.7');
        SKINVECTOR(COLOR_DIALOG_SERVERINFO, '0.7 0.7 1');
+       SKINVECTOR(COLOR_DIALOG_WELCOME, '1 0.7 0.7');
        SKINVECTOR(COLOR_DIALOG_CVARS, '1 0 0');
        SKINVECTOR(COLOR_DIALOG_HUDCONFIRM, '1 0 0');
 
diff --git a/qcsrc/menu/xonotic/dialog_welcome.c b/qcsrc/menu/xonotic/dialog_welcome.c
new file mode 100644 (file)
index 0000000..8377978
--- /dev/null
@@ -0,0 +1,89 @@
+#ifdef INTERFACE
+CLASS(XonoticWelcomeDialog) EXTENDS(XonoticRootDialog)
+       METHOD(XonoticWelcomeDialog, fill, void(entity))
+       ATTRIB(XonoticWelcomeDialog, title, string, _("Welcome"))
+       ATTRIB(XonoticWelcomeDialog, color, vector, SKINCOLOR_DIALOG_WELCOME)
+       ATTRIB(XonoticWelcomeDialog, intendedWidth, float, 0.7)
+       ATTRIB(XonoticWelcomeDialog, rows, float, 16)
+       ATTRIB(XonoticWelcomeDialog, columns, float, 4)
+       ATTRIB(XonoticWelcomeDialog, name, string, "Welcome")
+
+       METHOD(XonoticWelcomeDialog, configureDialog, void(entity))
+       METHOD(XonoticWelcomeDialog, readInputArgs, void(entity, float, float))
+       ATTRIB(XonoticWelcomeDialog, serverinfo_name, string, string_null)
+       ATTRIB(XonoticWelcomeDialog, serverinfo_name_ent, entity, world)
+       ATTRIB(XonoticWelcomeDialog, serverinfo_ip, string, string_null)
+       ATTRIB(XonoticWelcomeDialog, serverinfo_ip_ent, entity, world)
+       ATTRIB(XonoticWelcomeDialog, serverinfo_MOTD, string, string_null)
+       ATTRIB(XonoticWelcomeDialog, serverinfo_MOTD_ent, entity, world)
+ENDCLASS(XonoticWelcomeDialog)
+#endif
+
+#ifdef IMPLEMENTATION
+void welcomeDialog_resetStrings(entity me)
+{
+       if(me.serverinfo_name)
+               strunzone(me.serverinfo_name);
+       me.serverinfo_name = strzone(_("<NO NAME>"));
+
+       if(me.serverinfo_ip)
+               strunzone(me.serverinfo_ip);
+       me.serverinfo_ip = strzone(_("<NO IP>"));
+
+       if(me.serverinfo_MOTD)
+               strunzone(me.serverinfo_MOTD);
+       me.serverinfo_MOTD = strzone(_("<NO MOTD>"));
+}
+void XonoticWelcomeDialog_configureDialog(entity me)
+{
+       welcomeDialog_resetStrings(me);
+       SUPER(XonoticWelcomeDialog).configureDialog(me);
+}
+void XonoticWelcomeDialog_readInputArgs(entity me, float starting_arg, float arg_count)
+{
+       float i;
+       welcomeDialog_resetStrings(me);
+       for(i = starting_arg; i < arg_count; ++i)
+       {
+               if(argv(i) == "serverinfo_name")
+               {
+                       if(me.serverinfo_name)
+                               strunzone(me.serverinfo_name);
+                       me.serverinfo_name = strzone(argv(i + 1));
+                       me.serverinfo_name_ent.setText(me.serverinfo_name_ent, me.serverinfo_name);
+                       ++i;
+               }
+               else if(argv(i) == "serverinfo_ip")
+               {
+                       if(me.serverinfo_ip)
+                               strunzone(me.serverinfo_ip);
+                       me.serverinfo_ip = strzone(argv(i + 1));
+                       me.serverinfo_ip_ent.setText(me.serverinfo_ip_ent, me.serverinfo_ip);
+                       ++i;
+               }
+               else if(argv(i) == "serverinfo_MOTD")
+               {
+                       if(me.serverinfo_MOTD)
+                               strunzone(me.serverinfo_MOTD);
+                       me.serverinfo_MOTD = strzone(argv(i + 1));
+                       me.serverinfo_MOTD_ent.setText(me.serverinfo_MOTD_ent, me.serverinfo_MOTD);
+                       ++i;
+               }
+       }
+}
+
+void XonoticWelcomeDialog_fill(entity me)
+{
+       entity e;
+
+       me.TR(me);
+               me.TD(me, 1, 4, me.serverinfo_name_ent = makeXonoticTextLabel(0.5, ""));
+       me.TR(me);
+               me.TD(me, 1, 4, me.serverinfo_ip_ent = makeXonoticTextLabel(0.5, ""));
+       me.TR(me);
+       me.TR(me);
+               me.TD(me, 1, 4, e = makeXonoticTextLabel(0.5, _("MOTD")));
+       me.TR(me);
+               me.TD(me, 1, 4, me.serverinfo_MOTD_ent = makeXonoticTextLabel(0.5, ""));
+}
+#endif
index f9d86c2dd229276aadb7272c9484f165bb1ad606..5dc781e7246c88677619c2f4cf46d8c8a37fbb8e 100644 (file)
@@ -198,8 +198,12 @@ void MainWindow_configureMainWindow(entity me)
        i = spawnXonoticTeamSelectDialog();
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
-       
-       
+
+       i = spawnXonoticWelcomeDialog();
+       i.configureDialog(i);
+       me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+
+
        // main dialogs/windows
        me.mainNexposee = n = spawnXonoticNexposee();
        /*
index d7ca62ba01a800c4ee8f7ee848940649b84206a0..3e897f343cf7e4e5518770c181d168d56b8f4353 100644 (file)
@@ -726,6 +726,17 @@ void DecodeLevelParms (void)
        self.parm_idlesince = max(self.parm_idlesince, time - sv_maxidle + 60);
 }
 
+void MOTD_send()
+{
+       msg_entity = self;
+       WriteByte(MSG_ONE, SVC_TEMPENTITY);
+       WriteByte(MSG_ONE, TE_CSQC_SERVERINFO);
+       WriteString(MSG_ONE, "128.03.192.999"); // FIXME: send the real server ip
+       WriteString(MSG_ONE, autocvar_hostname);
+       //WriteString(MSG_ONE, getwelcomemessage());
+       WriteString(MSG_ONE, "Welcome to this server. Have fun!");
+}
+
 /*
 =============
 ClientKill
@@ -1225,7 +1236,10 @@ void ClientConnect (void)
        self.model_randomizer = random();
 
        if(IS_REAL_CLIENT(self))
+       {
+               MOTD_send();
                sv_notice_join();
+       }
 
        MUTATOR_CALLHOOK(ClientConnect);
 }