Added dialog for keybindings reset.
authorbyteManiak <bytemaniak98@gmail.com>
Sat, 30 Mar 2019 00:22:52 +0000 (00:22 +0000)
committerbyteManiak <bytemaniak98@gmail.com>
Sat, 30 Mar 2019 00:22:52 +0000 (00:22 +0000)
qcsrc/menu/xonotic/_mod.inc
qcsrc/menu/xonotic/_mod.qh
qcsrc/menu/xonotic/dialog_settings_bindings_reset.qc [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_settings_bindings_reset.qh [new file with mode: 0644]
qcsrc/menu/xonotic/dialog_settings_input.qc
qcsrc/menu/xonotic/keybinder.qc
qcsrc/menu/xonotic/mainwindow.qc
qcsrc/menu/xonotic/mainwindow.qh

index fd83718..00a9e54 100644 (file)
@@ -70,6 +70,7 @@
 #include <menu/xonotic/dialog_settings_game_weapons.qc>
 #include <menu/xonotic/dialog_settings_input.qc>
 #include <menu/xonotic/dialog_settings_input_userbind.qc>
+#include <menu/xonotic/dialog_settings_bindings_reset.qc>
 #include <menu/xonotic/dialog_settings_misc.qc>
 #include <menu/xonotic/dialog_settings_misc_cvars.qc>
 #include <menu/xonotic/dialog_settings_misc_reset.qc>
index f1644a2..5d72a56 100644 (file)
@@ -70,6 +70,7 @@
 #include <menu/xonotic/dialog_settings_game_weapons.qh>
 #include <menu/xonotic/dialog_settings_input.qh>
 #include <menu/xonotic/dialog_settings_input_userbind.qh>
+#include <menu/xonotic/dialog_settings_bindings_reset.qh>
 #include <menu/xonotic/dialog_settings_misc.qh>
 #include <menu/xonotic/dialog_settings_misc_cvars.qh>
 #include <menu/xonotic/dialog_settings_misc_reset.qh>
diff --git a/qcsrc/menu/xonotic/dialog_settings_bindings_reset.qc b/qcsrc/menu/xonotic/dialog_settings_bindings_reset.qc
new file mode 100644 (file)
index 0000000..0ceda25
--- /dev/null
@@ -0,0 +1,21 @@
+#include "dialog_settings_bindings_reset.qh"
+
+#include "textlabel.qh"
+#include "commandbutton.qh"
+#include "button.qh"
+#include "keybinder.qh"
+
+void XonoticBindingsResetDialog_fill(entity me)
+{
+       entity e;
+       me.TR(me);
+               me.TD(me, 1, 2, makeXonoticTextLabel(0.5, _("Are you sure you want to reset all keybindings?")));
+       me.TR(me);
+       me.TR(me);
+               me.TD(me, 1, 1, e = makeXonoticButton(_("Yes"), '1 0 0'));
+                       e.onClick = KeyBinder_Bind_Reset_All;
+                       e.onClickEntity = me;
+               me.TD(me, 1, 1, e = makeXonoticButton(_("No"), '0 1 0'));
+                       e.onClick = Dialog_Close;
+                       e.onClickEntity = me;
+}
diff --git a/qcsrc/menu/xonotic/dialog_settings_bindings_reset.qh b/qcsrc/menu/xonotic/dialog_settings_bindings_reset.qh
new file mode 100644 (file)
index 0000000..ad1e387
--- /dev/null
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "dialog.qh"
+CLASS(XonoticBindingsResetDialog, XonoticDialog)
+       METHOD(XonoticBindingsResetDialog, fill, void(entity));
+       ATTRIB(XonoticBindingsResetDialog, title, string, _("Reset bindings"));
+       ATTRIB(XonoticBindingsResetDialog, color, vector, SKINCOLOR_DIALOG_QUIT);
+       ATTRIB(XonoticBindingsResetDialog, intendedWidth, float, 0.5);
+       ATTRIB(XonoticBindingsResetDialog, rows, float, 3);
+       ATTRIB(XonoticBindingsResetDialog, columns, float, 2);
+       ATTRIB(XonoticBindingsResetDialog, name, string, "Reset bindings");
+ENDCLASS(XonoticBindingsResetDialog)
index 7f3af39..c5e3bb4 100644 (file)
@@ -50,8 +50,8 @@ void XonoticInputSettingsTab_fill(entity me)
                        kb.clearButton = e;
        me.TR(me);
                me.TD(me, 1, 3, e = makeXonoticButton(_("Reset all"), '0 0 0'));
-                       e.onClick = KeyBinder_Bind_Reset_All;
-                       e.onClickEntity = kb;
+                       e.onClick = DialogOpenButton_Click;
+                       e.onClickEntity = main.bindingsResetDialog;
 
        me.gotoRC(me, 0, 3.2); me.setFirstColumn(me, me.currentColumn);
                me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Mouse")));
index 69734ef..90712bb 100644 (file)
@@ -313,6 +313,7 @@ void KeyBinder_Bind_Reset_All(entity btn, entity me)
        localcmd("exec binds-xonotic.cfg\n");
        localcmd("-zoom\n"); // to make sure we aren't in togglezoom'd state
        cvar_set("_hud_showbinds_reload", "1");
+       me.close(me);
 }
 void XonoticKeyBinder_doubleClickListBoxItem(entity me, float i, vector where)
 {
index 110b796..602fcc3 100644 (file)
@@ -27,6 +27,7 @@
 #include "dialog_hudpanel_quickmenu.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"
@@ -163,6 +164,10 @@ void MainWindow_configureMainWindow(entity me)
        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);
index 2397d41..924f145 100644 (file)
@@ -10,6 +10,7 @@ CLASS(MainWindow, ModalController)
        ATTRIB(MainWindow, mutatorsDialog, entity);
        ATTRIB(MainWindow, mapInfoDialog, entity);
        ATTRIB(MainWindow, userbindEditDialog, entity);
+       ATTRIB(MainWindow, bindingsResetDialog, entity);
        ATTRIB(MainWindow, winnerDialog, entity);
        ATTRIB(MainWindow, serverInfoDialog, entity);
        ATTRIB(MainWindow, cvarsDialog, entity);