This way it's no longer possible to start a multiplayer game while the campaign settings are still visible in Multiplayer / Create window (these settings are temporary and won't be applied anyway)
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
+const string QUITGAME_CMD = "defer 0.4 disconnect; defer 0.4 wait; defer 0.4 \"g_campaign 0\"; defer 0.4 menu_sync";
+
const int S_SHIFT = 1;
const int S_CTRL = 2;
const int S_ALT = 4;
return me;
}
+.entity quitGameButton;
+void XonoticServerCreateTab_draw(entity me)
+{
+ entity e = me.quitGameButton;
+ e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
+ if(cvar("g_campaign"))
+ e.setText(e, _("Quit campaign"));
+ else
+ e.setText(e, _("Quit current game"));
+ SUPER(XonoticServerCreateTab).draw(me);
+}
+
void XonoticServerCreateTab_fill(entity me)
{
entity e, e0;
e.onClick = MapList_Remove_All;
e.onClickEntity = me.mapListBox;
- // The big button at the bottom
-
+ // bottom row
me.gotoRC(me, me.rows - 1, 0);
- me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Multiplayer!"), '0 0 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, e = makeXonoticButton(_("Start multiplayer!"), '0 0 0'));
e.onClick = MapList_LoadMap;
e.onClickEntity = me.mapListBox;
me.mapListBox.startButton = e;
#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));
cvar_set("lastlevel", "1");
}
+.entity quitGameButton;
+void XonoticSingleplayerDialog_draw(entity me)
+{
+ entity e = me.quitGameButton;
+ e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
+ if(cvar("g_campaign"))
+ e.setText(e, _("Quit campaign"));
+ else
+ e.setText(e, _("Quit current game"));
+ SUPER(XonoticSingleplayerDialog).draw(me);
+}
+
void XonoticSingleplayerDialog_fill(entity me)
{
entity e, btnPrev, btnNext, lblTitle;
me.TD(me, 1, 1, e = makeXonoticRadioButton(1, "g_campaign_skill", "-2", ZCTX(_("CSKL^Easy"))));
me.TD(me, 1, 1, e = makeXonoticRadioButton(1, "g_campaign_skill", "0", ZCTX(_("CSKL^Medium"))));
me.TD(me, 1, 1, e = makeXonoticRadioButton(1, "g_campaign_skill", "2", ZCTX(_("CSKL^Hard"))));
- me.TR(me);
- me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Singleplayer!"), '0 0 0'));
+ 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.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;
e.onClickEntity = me.campaignBox;
}
#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"));
void XonoticMapList_draw(entity me)
{
if(me.startButton)
- me.startButton.disabled = ((me.selectedItem < 0) || (me.selectedItem >= me.nItems));
+ me.startButton.disabled = ((me.selectedItem < 0) || (me.selectedItem >= me.nItems)
+ || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED) && cvar("g_campaign")));
SUPER(XonoticMapList).draw(me);
}