]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/mainwindow.qc
Add Terms of Service Popup and server-specific Terms of Service tab
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / mainwindow.qc
index 3d41104488085fe1c629fc8980f728a055b921d6..4aa974835a58da15959f2d79e5b7be34d9324e0d 100644 (file)
@@ -1,40 +1,99 @@
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-#include "../item/modalcontroller.qc"
-CLASS(MainWindow, ModalController)
-       METHOD(MainWindow, configureMainWindow, void(entity));
-       METHOD(MainWindow, draw, void(entity));
-       ATTRIB(MainWindow, firstRunDialog, entity, NULL)
-       ATTRIB(MainWindow, advancedDialog, entity, NULL)
-       ATTRIB(MainWindow, mutatorsDialog, entity, NULL)
-       ATTRIB(MainWindow, mapInfoDialog, entity, NULL)
-       ATTRIB(MainWindow, userbindEditDialog, entity, NULL)
-       ATTRIB(MainWindow, winnerDialog, entity, NULL)
-       ATTRIB(MainWindow, serverInfoDialog, entity, NULL)
-       ATTRIB(MainWindow, cvarsDialog, entity, NULL)
-       ATTRIB(MainWindow, screenshotViewerDialog, entity, NULL)
-       ATTRIB(MainWindow, viewDialog, entity, NULL)
-       ATTRIB(MainWindow, hudconfirmDialog, entity, NULL)
-       ATTRIB(MainWindow, languageWarningDialog, entity, NULL)
-       ATTRIB(MainWindow, mainNexposee, entity, NULL)
-       ATTRIB(MainWindow, fadedAlpha, float, SKINALPHA_BEHIND)
-       ATTRIB(MainWindow, dialogToShow, entity, NULL)
-       ATTRIB(MainWindow, demostartconfirmDialog, entity, NULL)
-       ATTRIB(MainWindow, demotimeconfirmDialog, entity, NULL)
-       ATTRIB(MainWindow, resetDialog, entity, NULL)
-ENDCLASS(MainWindow)
-#endif
-
-#ifdef IMPLEMENTATION
+#include "mainwindow.qh"
+
+#include <menu/mutators/_mod.qh>
+
+#include "nexposee.qh"
+#include "inputbox.qh"
+#include "dialog_termsofservice.qh"
+#include "dialog_firstrun.qh"
+#include "dialog_hudsetup_exit.qh"
+#include "dialog_hudpanel_notification.qh"
+#include "dialog_hudpanel_ammo.qh"
+#include "dialog_hudpanel_healtharmor.qh"
+#include "dialog_hudpanel_chat.qh"
+#include "dialog_hudpanel_modicons.qh"
+#include "dialog_hudpanel_powerups.qh"
+#include "dialog_hudpanel_pressedkeys.qh"
+#include "dialog_hudpanel_racetimer.qh"
+#include "dialog_hudpanel_radar.qh"
+#include "dialog_hudpanel_score.qh"
+#include "dialog_hudpanel_timer.qh"
+#include "dialog_hudpanel_vote.qh"
+#include "dialog_hudpanel_weapons.qh"
+#include "dialog_hudpanel_engineinfo.qh"
+#include "dialog_hudpanel_infomessages.qh"
+#include "dialog_hudpanel_physics.qh"
+#include "dialog_hudpanel_centerprint.qh"
+#include "dialog_hudpanel_itemstime.qh"
+#include "dialog_hudpanel_quickmenu.qh"
+#include "dialog_hudpanel_strafehud.qh"
+
+#include "dialog_settings_input_userbind.qh"
+#include "dialog_settings_bindings_reset.qh"
+#include "dialog_settings_misc_cvars.qh"
+#include "dialog_settings_misc_reset.qh"
+#include "dialog_settings_user_languagewarning.qh"
+#include "dialog_settings_game_hudconfirm.qh"
+#include "dialog_singleplayer_winner.qh"
+#include "dialog_multiplayer_join_serverinfo.qh"
+#include "dialog_multiplayer_media_demo_startconfirm.qh"
+#include "dialog_multiplayer_media_demo_timeconfirm.qh"
+#include "dialog_multiplayer_media_screenshot_viewer.qh"
+#include "dialog_multiplayer_create_mapinfo.qh"
+#include "dialog_multiplayer_create_mutators.qh"
+#include "dialog_sandboxtools.qh"
+#include "dialog_monstertools.qh"
+#include "dialog_teamselect.qh"
+#include "dialog_uid2name.qh"
+#include "dialog_singleplayer.qh"
+#include "dialog_multiplayer.qh"
+#include "dialog_settings.qh"
+#include "dialog_credits.qh"
+#include "dialog_quit.qh"
+
+#include "dialog_disconnect.qh"
+
+
+
 void MainWindow_draw(entity me)
 {
        SUPER(MainWindow).draw(me);
 
-       if(me.dialogToShow)
+       if (me.firstDraw) {
+               if (me.ToSDialog.shouldShow())
+                       DialogOpenButton_Click_withCoords(NULL, me.ToSDialog, '0 0 0', eX * conwidth + eY * conheight);
+               else if(me.firstRunDialog.shouldShow())
+                       DialogOpenButton_Click_withCoords(NULL, me.firstRunDialog, '0 0 0', eX * conwidth + eY * conheight);
+               
+               me.firstDraw = false;
+       }
+
+       //-------------------------------------
+       // 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))) 
        {
-               DialogOpenButton_Click_withCoords(NULL, me.dialogToShow, '0 0 0', eX * conwidth + eY * conheight);
-               me.dialogToShow = NULL;
+               // 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)
@@ -49,6 +108,11 @@ void MainWindow_configureMainWindow(entity me)
 {
        entity n, i;
 
+       // terms of service dialog
+       me.ToSDialog = i = NEW(XonoticToSDialog);
+       i.configureDialog(i);
+       me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+
        // dialog run upon startup
        me.firstRunDialog = i = NEW(XonoticFirstRunDialog);
        i.configureDialog(i);
@@ -136,11 +200,19 @@ void MainWindow_configureMainWindow(entity me)
        i.configureDialog(i);
        me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
 
+       i = NEW(XonoticHUDStrafeHUDDialog);
+       i.configureDialog(i);
+       me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+
        // dialogs used by settings
        me.userbindEditDialog = i = NEW(XonoticUserbindEditDialog);
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
 
+       me.bindingsResetDialog = i = NEW(XonoticBindingsResetDialog);
+       i.configureDialog(i);
+       me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+
        me.cvarsDialog = i = NEW(XonoticCvarsDialog);
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
@@ -205,13 +277,20 @@ void MainWindow_configureMainWindow(entity me)
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
 
+       i = NEW(XonoticUid2NameDialog);
+       i.configureDialog(i);
+       me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+
        i = NEW(XonoticMonsterToolsDialog);
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
 
+       MUTATOR_CALLHOOK(ConfigureDialogs, me);
+
 
        // main dialogs/windows
        me.mainNexposee = n = NEW(XonoticNexposee);
+
        /*
                if(checkextension("DP_GECKO_SUPPORT"))
                {
@@ -221,6 +300,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);
@@ -242,6 +322,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);
@@ -252,10 +340,5 @@ void MainWindow_configureMainWindow(entity me)
        me.moveItemAfter(me, n, NULL);
 
        me.initializeDialog(me, n);
-
-       if(cvar_string("_cl_name") == cvar_defstring("_cl_name"))
-               me.dialogToShow = me.firstRunDialog;
+       me.disconnectDialogVisibility = 1;
 }
-#endif
-
-/* Click. The c-word is here so you can grep for it :-) */