bool Menu_Active;
int gamestatus;
-// resets g_campaign and updates menu items to reflect cvar values that may have been restored after leaving the campaign
-// the delay is for allowing listening to the button sound (if enabled), since the disconnect command stops all sounds
-// menu_sync is also useful when quitting Instant Action mode
-// see also m_draw
-const string QUITGAME_CMD = "defer 0.4 disconnect; defer 0.4 wait; defer 0.4 \"g_campaign 0\"; defer 0.4 menu_sync\n";
-
const int S_SHIFT = 1;
const int S_CTRL = 2;
const int S_ALT = 4;
#include <menu/xonotic/playerlist.qc>
#include <menu/xonotic/playermodel.qc>
#include <menu/xonotic/playlist.qc>
+#include <menu/xonotic/quitbutton.qc>
#include <menu/xonotic/radiobutton.qc>
#include <menu/xonotic/rootdialog.qc>
#include <menu/xonotic/screenshotimage.qc>
#include <menu/xonotic/playerlist.qh>
#include <menu/xonotic/playermodel.qh>
#include <menu/xonotic/playlist.qh>
+#include <menu/xonotic/quitbutton.qh>
#include <menu/xonotic/radiobutton.qh>
#include <menu/xonotic/rootdialog.qh>
#include <menu/xonotic/screenshotimage.qh>
#include "mainwindow.qh"
#include "button.qh"
#include "commandbutton.qh"
+#include "quitbutton.qh"
#include "inputbox.qh"
void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip)
}
.entity quitGameButton;
-void XonoticServerCreateTab_draw(entity me)
-{
- entity e = me.quitGameButton;
- e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
- e.setText(e, quitGameButton_getText(e));
- setZonedTooltip(e, quitGameButton_getTooltip(e), string_null);
- SUPER(XonoticServerCreateTab).draw(me);
-}
void XonoticServerCreateTab_fill(entity me)
{
// bottom row
me.gotoRC(me, me.rows - 1, 0);
me.TDempty(me, me.columns * 1/12);
- me.TD(me, 1, me.columns * 5/12, me.quitGameButton = makeXonoticCommandButton(string_null, '0 0 0', QUITGAME_CMD, 0));
+ me.TD(me, 1, me.columns * 5/12, me.quitGameButton = makeXonoticQuitButton('0 0 0', 0));
me.TD(me, 1, me.columns * 5/12, e = makeXonoticButton(_("Start multiplayer!"), '0 0 0'));
e.onClick = MapList_LoadMap;
e.onClickEntity = me.mapListBox;
#include "tab.qh"
CLASS(XonoticServerCreateTab, XonoticTab)
- METHOD(XonoticServerCreateTab, draw, void(entity));
METHOD(XonoticServerCreateTab, fill, void(entity));
METHOD(XonoticServerCreateTab, gameTypeChangeNotify, void(entity));
METHOD(XonoticServerCreateTab, gameTypeSelectNotify, void(entity));
#include "inputbox.qh"
#include "checkbox.qh"
#include "commandbutton.qh"
+#include "quitbutton.qh"
#include "button.qh"
entity makeXonoticServerListTab()
}
.entity quitGameButton;
-void XonoticServerListTab_draw(entity me)
-{
- entity e = me.quitGameButton;
- e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
- e.setText(e, quitGameButton_getText(e));
- setZonedTooltip(e, quitGameButton_getTooltip(e), string_null);
- SUPER(XonoticServerListTab).draw(me);
-}
void XonoticServerListTab_fill(entity me)
{
e.onClickEntity = slist;
slist.infoButton = e;
me.TR(me);
- me.TD(me, 1, me.columns * 0.5, me.quitGameButton = makeXonoticCommandButton(string_null, '0 0 0', QUITGAME_CMD, 0));
+ me.TD(me, 1, me.columns * 0.5, me.quitGameButton = makeXonoticQuitButton('0 0 0', 0));
me.TD(me, 1, me.columns * 0.5, e = makeXonoticButton(_("Join!"), '0 0 0'));
e.onClick = ServerList_Connect_Click;
e.onClickEntity = slist;
#include "tab.qh"
CLASS(XonoticServerListTab, XonoticTab)
METHOD(XonoticServerListTab, fill, void(entity));
- METHOD(XonoticServerListTab, draw, void(entity));
ATTRIB(XonoticServerListTab, intendedWidth, float, 0.9);
ATTRIB(XonoticServerListTab, rows, float, 23);
ATTRIB(XonoticServerListTab, columns, float, 6.5);
#include "textlabel.qh"
#include "commandbutton.qh"
+#include "quitbutton.qh"
#include "button.qh"
-void Disconnect_Click(entity btn, entity me)
-{
- localcmd(QUITGAME_CMD);
- Dialog_Close(btn, me);
-}
-
-void XonoticQuitDialog_draw(entity me)
-{
- entity e = me.disconnectButton;
- e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
- e.setText(e, quitGameButton_getText(e));
- setZonedTooltip(e, quitGameButton_getTooltip(e), string_null);
- SUPER(XonoticQuitDialog).draw(me);
-}
-
void XonoticQuitDialog_fill(entity me)
{
entity e;
me.TR(me);
me.TDempty(me, 0.5);
- me.TD(me, 1, 1, me.disconnectButton = makeXonoticButton(string_null, '0 0 0'));
- me.disconnectButton.onClick = Disconnect_Click;
- me.disconnectButton.onClickEntity = me;
+ me.TD(me, 1, 1, me.disconnectButton = makeXonoticQuitButton('0 0 0', COMMANDBUTTON_CLOSE));
me.TR(me);
me.TR(me);
me.TD(me, 1, 1, e = makeXonoticCommandButton(_("Quit Xonotic"), '1 0 0', "echo ]quit; quit", 0));
#include "dialog.qh"
CLASS(XonoticQuitDialog, XonoticDialog)
METHOD(XonoticQuitDialog, fill, void(entity));
- METHOD(XonoticQuitDialog, draw, void(entity));
ATTRIB(XonoticQuitDialog, title, string, _("Quit"));
ATTRIB(XonoticQuitDialog, tooltip, string, _("Quit the game"));
ATTRIB(XonoticQuitDialog, color, vector, SKINCOLOR_DIALOG_QUIT);
#include <common/gamemodes/_mod.qh>
#include "bigbutton.qh"
#include "commandbutton.qh"
+#include "quitbutton.qh"
#include "radiobutton.qh"
#include "textlabel.qh"
#include "campaign.qh"
}
.entity quitGameButton;
-void XonoticSingleplayerDialog_draw(entity me)
-{
- entity e = me.quitGameButton;
- e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
- e.setText(e, quitGameButton_getText(e));
- setZonedTooltip(e, quitGameButton_getTooltip(e), string_null);
- SUPER(XonoticSingleplayerDialog).draw(me);
-}
void XonoticSingleplayerDialog_fill(entity me)
{
me.TD(me, 1, 1, e = makeXonoticRadioButton(1, "g_campaign_skill", "2", ZCTX(_("CSKL^Hard"))));
me.TR(me);
me.TDempty(me, me.columns * 1/13);
- me.TD(me, 1, me.columns * 5/13, me.quitGameButton = makeXonoticCommandButton(string_null, '0 0 0', QUITGAME_CMD, 0));
+ me.TD(me, 1, me.columns * 5/13, me.quitGameButton = makeXonoticQuitButton('0 0 0', 0));
me.TDempty(me, me.columns * 1/13);
me.TD(me, 1, me.columns * 5/13, e = makeXonoticButton(_("Play campaign!"), '0 0 0'));
e.onClick = CampaignList_LoadMap;
#include "dialog.qh"
CLASS(XonoticSingleplayerDialog, XonoticDialog)
- METHOD(XonoticSingleplayerDialog, draw, void(entity));
METHOD(XonoticSingleplayerDialog, fill, void(entity));
ATTRIB(XonoticSingleplayerDialog, title, string, _("Singleplayer"));
ATTRIB(XonoticSingleplayerDialog, tooltip, string, _("Play the singleplayer campaign or instant action matches against bots"));
--- /dev/null
+#include "quitbutton.qh"
+
+// resets g_campaign and updates menu items to reflect cvar values that may have been restored after leaving the campaign
+// the delay is for allowing listening to the button sound (if enabled), since the disconnect command stops all sounds
+// menu_sync is also useful when quitting Instant Action mode
+// see also m_draw
+const string QUITGAME_CMD = "defer 0.4 disconnect; defer 0.4 wait; defer 0.4 \"g_campaign 0\"; defer 0.4 menu_sync\n";
+
+string quitGameButton_getText(entity me)
+{
+ if (me.disabled)
+ return _("Quit current game");
+ else if(cvar("g_campaign"))
+ return _("Quit campaign");
+ else if (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1")
+ return _("Quit singleplayer");
+ else
+ return _("Quit multiplayer");
+}
+
+string quitGameButton_getTooltip(entity me)
+{
+ if (me.disabled)
+ return "-";
+ else if(cvar("g_campaign"))
+ return "-";
+ else if (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1")
+ return "-";
+ else
+ return _("Quit multiplayer / Disconnect from the server");
+}
+
+entity makeXonoticQuitButton(vector theColor, int theFlags)
+{
+ entity me;
+ me = NEW(XonoticQuitButton);
+ me.configureXonoticQuitButton(me, theColor, theFlags);
+ return me;
+}
+
+void XonoticQuitButton_draw(entity me)
+{
+ SUPER(XonoticCommandButton).draw(me);
+ me.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
+ me.setText(me, quitGameButton_getText(me));
+ setZonedTooltip(me, quitGameButton_getTooltip(me), string_null);
+}
+
+void XonoticQuitButton_configureXonoticQuitButton(entity me, vector theColor, int theFlags)
+{
+ me.configureXonoticCommandButton(me, string_null, theColor, QUITGAME_CMD, theFlags, string_null);
+ me.draw = XonoticQuitButton_draw;
+}
--- /dev/null
+#pragma once
+
+#include "commandbutton.qh"
+CLASS(XonoticQuitButton, XonoticCommandButton)
+ METHOD(XonoticQuitButton, draw, void(entity));
+ METHOD(XonoticQuitButton, configureXonoticQuitButton, void(entity, vector, int));
+ENDCLASS(XonoticQuitButton)
+
+entity makeXonoticQuitButton(vector theColor, int theFlags);
localcmd("defer 0.1 \"sv_cmd settemp net_address_ipv6 ::1\"\n");
}
-string quitGameButton_getText(entity btn)
-{
- if (btn.disabled)
- return _("Quit current game");
- else if(cvar("g_campaign"))
- return _("Quit campaign");
- else if (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1")
- return _("Quit singleplayer");
- else
- return _("Quit multiplayer");
-}
-
-string quitGameButton_getTooltip(entity btn)
-{
- if (btn.disabled)
- return "-";
- else if(cvar("g_campaign"))
- return "-";
- else if (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1")
- return "-";
- else
- return _("Quit multiplayer / Disconnect from the server");
-}
-
float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
{
if(startAlpha < targetAlpha)
void dialog_hudpanel_main_settings(entity me, string panelname);
void makeServerSingleplayer();
-string quitGameButton_getText(entity btn);
-string quitGameButton_getTooltip(entity btn);
-
float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha);
string _Nex_ExtResponseSystem_BannedServers;