]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Campaign: replace the "Join!" button with a "Restart level" button in the game menu...
authorterencehill <piuntn@gmail.com>
Tue, 12 Apr 2022 16:40:39 +0000 (18:40 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 12 Apr 2022 16:40:39 +0000 (18:40 +0200)
qcsrc/menu/xonotic/dialog_gamemenu.qc
qcsrc/menu/xonotic/dialog_gamemenu.qh

index 6ab4973cce87f82cdf781b8218d85cd0e584071c..68d612de37620d44259ac837c4f1204ceb0e7574 100644 (file)
@@ -10,6 +10,28 @@ void XonoticGameMenuDialog_destroy(entity me)
        cvar_set("_menu_gamemenu_dialog_available", "0");
 }
 
+void XonoticGameMenuDialog_draw(entity me)
+{
+       entity btn = me.joinButton;
+       if(cvar("g_campaign"))
+       {
+               if (btn.toString(btn) == _("Join!"))
+               {
+                       btn.setText(btn, _("Restart level"));
+                       btn.onClickCommand = "resetmatch";
+               }
+       }
+       else
+       {
+               if (btn.toString(btn) == _("Restart level"))
+               {
+                       btn.setText(btn, _("Join!"));
+                       btn.onClickCommand = "join";
+               }
+       }
+       SUPER(XonoticGameMenuDialog).draw(me);
+}
+
 void XonoticGameMenuDialog_fill(entity me)
 {
        registercvar("_menu_gamemenu_dialog_available", "0", 0);
@@ -34,7 +56,7 @@ void XonoticGameMenuDialog_fill(entity me)
                me.TD(me, 1, 1, e = makeXonoticCommandButton(_("Quick menu"), '0 0 0', "quickmenu", COMMANDBUTTON_CLOSE));
        me.TR(me);
        me.TR(me);
-               me.TD(me, 1, 1, e = makeXonoticCommandButton(_("Join!"), '0 0 0', "join", COMMANDBUTTON_CLOSE));
+               me.TD(me, 1, 1, e = me.joinButton = makeXonoticCommandButton(_("Join!"), '0 0 0', "join", COMMANDBUTTON_CLOSE));
        me.TR(me);
                me.TD(me, 1, 1, e = makeXonoticCommandButton(_("Spectate"), '0 0 0', "spec", COMMANDBUTTON_CLOSE));
        me.TR(me);
index 56ba58049efdd08a0fb85dc4575f7dd86026af2a..0aa0cf4017b565b67585bbc4462257fe1acabeff 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "rootdialog.qh"
 CLASS(XonoticGameMenuDialog, XonoticRootDialog)
+       METHOD(XonoticGameMenuDialog, draw, void(entity));
        METHOD(XonoticGameMenuDialog, destroy, void(entity));
        METHOD(XonoticGameMenuDialog, fill, void(entity));
        ATTRIB(XonoticGameMenuDialog, title, string, _("Game menu"));
@@ -11,4 +12,5 @@ CLASS(XonoticGameMenuDialog, XonoticRootDialog)
        ATTRIB(XonoticGameMenuDialog, columns, float, 1);
        ATTRIB(XonoticGameMenuDialog, name, string, "GameMenu");
        ATTRIB(XonoticGameMenuDialog, requiresConnection, bool, true);
+       ATTRIB(XonoticGameMenuDialog, joinButton, entity, world);
 ENDCLASS(XonoticGameMenuDialog)