]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move disconnect button to dialog from multiplayer menu to main menu
authorAriosJentu <darthpoezd@gmail.com>
Fri, 16 Aug 2019 03:15:24 +0000 (13:15 +1000)
committerAriosJentu <darthpoezd@gmail.com>
Fri, 16 Aug 2019 03:15:24 +0000 (13:15 +1000)
qcsrc/menu/xonotic/dialog_disconnect.qc [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_disconnect.qh [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_multiplayer_join.qc
qcsrc/menu/xonotic/mainwindow.qc
qcsrc/menu/xonotic/mainwindow.qh

diff --git a/qcsrc/menu/xonotic/dialog_disconnect.qc b/qcsrc/menu/xonotic/dialog_disconnect.qc
new file mode 100644 (file)
index 0000000..b50f4bd
--- /dev/null
@@ -0,0 +1,25 @@
+#include "dialog_disconnect.qh"
+
+#include "textlabel.qh"
+#include "button.qh"
+
+void Disconnect_Click(entity btn, entity me)
+{
+       localcmd("disconnect");
+       Dialog_Close(btn, me);
+}
+
+void XonoticDisconnectDialog_fill(entity me)
+{
+       entity e;
+       me.TR(me);
+               me.TD(me, 1, 2, makeXonoticTextLabel(0.5, _("Are you sure to disconnect from server?")));
+       me.TR(me);
+       me.TR(me);
+               me.TD(me, 1, 1, e = makeXonoticButton_T(_("Yes"), '1 0 0', _("I would disconnect from server...")));
+                       e.onClick = Disconnect_Click;
+                       e.onClickEntity = me;
+               me.TD(me, 1, 1, e = makeXonoticButton_T(_("No"), '0 1 0', _("I would play more!")));
+                       e.onClick = Dialog_Close;
+                       e.onClickEntity = me;
+}
\ No newline at end of file
diff --git a/qcsrc/menu/xonotic/dialog_disconnect.qh b/qcsrc/menu/xonotic/dialog_disconnect.qh
new file mode 100644 (file)
index 0000000..e4ea22b
--- /dev/null
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "dialog.qh"
+CLASS(XonoticDisconnectDialog, XonoticDialog)
+       METHOD(XonoticDisconnectDialog, fill, void(entity));
+       ATTRIB(XonoticDisconnectDialog, title, string, _("Disconnect"));
+       ATTRIB(XonoticDisconnectDialog, tooltip, string, _("Disconnect server"));
+       ATTRIB(XonoticDisconnectDialog, color, vector, SKINCOLOR_DIALOG_QUIT);
+       ATTRIB(XonoticDisconnectDialog, intendedWidth, float, 0.5);
+       ATTRIB(XonoticDisconnectDialog, rows, float, 3);
+       ATTRIB(XonoticDisconnectDialog, colums, float, 2);
+       ATTRIB(XonoticDisconnectDialog, name, string, "Disconnect");
+ENDCLASS(XonoticDisconnectDialog)
\ No newline at end of file
index 1792ec635b41f1e594e3be4fbf6b455980f9d204..c79b124d66659f43e062e39341d5e4125b86b68e 100644 (file)
@@ -82,10 +82,14 @@ void XonoticServerListTab_fill(entity me)
                        e.onClickEntity = slist;
                        slist.infoButton = e;
        me.TR(me);
+       
+               /*
                me.TD(me, 1, 1, e = makeXonoticCommandButton_T(_("Disconnect"), '0 0 0', "disconnect", 0,
                        _("Disconnect from the server")));
                        slist.disconnectButton = e;
-               me.TD(me, 1, me.columns-1, e = makeXonoticButton(_("Join!"), '0 0 0'));
+               */
+
+               me.TD(me, 1, me.columns, e = makeXonoticButton(_("Join!"), '0 0 0'));
                        e.onClick = ServerList_Connect_Click;
                        e.onClickEntity = slist;
                        slist.connectButton = e;
index 602fcc33cccf5f068995d07a558a3ce376e17c18..cde317d68bfbf72989d66306193802c4f261a8d3 100644 (file)
 #include "dialog_credits.qh"
 #include "dialog_quit.qh"
 
+#include "dialog_disconnect.qc" //Including QH file breaking build, IDK why
+
+
+
 void MainWindow_draw(entity me)
 {
        SUPER(MainWindow).draw(me);
@@ -58,6 +62,33 @@ void MainWindow_draw(entity me)
                DialogOpenButton_Click_withCoords(NULL, me.dialogToShow, '0 0 0', eX * conwidth + eY * conheight);
                me.dialogToShow = NULL;
        }
+
+       //-------------------------------------
+       // Part of Disconnect Dialog button:
+       // In case of this function is recalling every time, need to use condition of visibility 
+       
+       if (me.disconnectDialogVisibility && !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED))) 
+       {
+               // If gamestate is not "ingame" (and it is a first "frame" of drawing (or dialog is visible)), 
+               // disconnect button is unnecessary, remove it
+               me.removeItem(me.mainNexposee, me.disconnectDialog);
+               me.disconnectDialogVisibility = 0;
+
+       } else if(!me.disconnectDialogVisibility && (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))) {
+               
+               // If gamestate is "ingame" (and dialog is not visible), 
+               // make disconnect button visible
+               entity n, i;
+               n = me.mainNexposee;
+               i = me.disconnectDialog;
+               n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+               n.setNexposee(n, i, '0.5 1.2 0.0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
+               me.disconnectDialogVisibility = 1;
+       }
+
+       // I haven't found the best solution for making button visible. 
+       // Alpha channel is the worst thing, because dialog with alpha is also clickable
+       //-------------------------------------
 }
 
 void DemoButton_Click(entity me, entity other)
@@ -245,6 +276,7 @@ void MainWindow_configureMainWindow(entity me)
 
        // main dialogs/windows
        me.mainNexposee = n = NEW(XonoticNexposee);
+       
        /*
                if(checkextension("DP_GECKO_SUPPORT"))
                {
@@ -254,6 +286,7 @@ void MainWindow_configureMainWindow(entity me)
                        n.setNexposee(n, i, '0.1 0.1 0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
                }
        */
+       
                i = NEW(XonoticSingleplayerDialog);
                i.configureDialog(i);
                n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
@@ -275,6 +308,14 @@ void MainWindow_configureMainWindow(entity me)
                n.setNexposee(n, i, SKINPOSITION_DIALOG_CREDITS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
                n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
 
+               //Disconnect dialog at center of screen (between credits and quit)
+               i = NEW(XonoticDisconnectDialog);
+               i.configureDialog(i);
+               n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+               n.setNexposee(n, i, '0.5 1.2 0.0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
+               n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
+               me.disconnectDialog = i;
+       
                i = NEW(XonoticQuitDialog);
                i.configureDialog(i);
                n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
@@ -285,6 +326,7 @@ void MainWindow_configureMainWindow(entity me)
        me.moveItemAfter(me, n, NULL);
 
        me.initializeDialog(me, n);
+       me.disconnectDialogVisibility = 1;
 
        if(cvar_string("_cl_name") == cvar_defstring("_cl_name"))
                me.dialogToShow = me.firstRunDialog;
index 924f145ba7d5f27143029d03417d8042d2b503e6..1e8afa4a39b1b3344ee7c4990247cdec9acd120e 100644 (file)
@@ -24,4 +24,6 @@ CLASS(MainWindow, ModalController)
        ATTRIB(MainWindow, demostartconfirmDialog, entity);
        ATTRIB(MainWindow, demotimeconfirmDialog, entity);
        ATTRIB(MainWindow, resetDialog, entity);
+       ATTRIB(MainWindow, disconnectDialog, entity);
+       ATTRIB(MainWindow, disconnectDialogVisibility, float, 1);
 ENDCLASS(MainWindow)