From: byteManiak Date: Sat, 30 Mar 2019 00:22:52 +0000 (+0000) Subject: Added dialog for keybindings reset. X-Git-Tag: xonotic-v0.8.5~1556^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=98c650ac374a423e726807bf0da1d2b4fd120cee;p=xonotic%2Fxonotic-data.pk3dir.git Added dialog for keybindings reset. --- diff --git a/qcsrc/menu/xonotic/_mod.inc b/qcsrc/menu/xonotic/_mod.inc index fd8371828..00a9e5403 100644 --- a/qcsrc/menu/xonotic/_mod.inc +++ b/qcsrc/menu/xonotic/_mod.inc @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/_mod.qh b/qcsrc/menu/xonotic/_mod.qh index f1644a2f5..5d72a5617 100644 --- a/qcsrc/menu/xonotic/_mod.qh +++ b/qcsrc/menu/xonotic/_mod.qh @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include diff --git a/qcsrc/menu/xonotic/dialog_settings_bindings_reset.qc b/qcsrc/menu/xonotic/dialog_settings_bindings_reset.qc new file mode 100644 index 000000000..0ceda25ac --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_settings_bindings_reset.qc @@ -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 index 000000000..ad1e387ee --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_settings_bindings_reset.qh @@ -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) diff --git a/qcsrc/menu/xonotic/dialog_settings_input.qc b/qcsrc/menu/xonotic/dialog_settings_input.qc index 7f3af39f8..c5e3bb439 100644 --- a/qcsrc/menu/xonotic/dialog_settings_input.qc +++ b/qcsrc/menu/xonotic/dialog_settings_input.qc @@ -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"))); diff --git a/qcsrc/menu/xonotic/keybinder.qc b/qcsrc/menu/xonotic/keybinder.qc index 69734ef18..90712bbeb 100644 --- a/qcsrc/menu/xonotic/keybinder.qc +++ b/qcsrc/menu/xonotic/keybinder.qc @@ -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) { diff --git a/qcsrc/menu/xonotic/mainwindow.qc b/qcsrc/menu/xonotic/mainwindow.qc index 110b796be..602fcc33c 100644 --- a/qcsrc/menu/xonotic/mainwindow.qc +++ b/qcsrc/menu/xonotic/mainwindow.qc @@ -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); diff --git a/qcsrc/menu/xonotic/mainwindow.qh b/qcsrc/menu/xonotic/mainwindow.qh index 2397d4143..924f145ba 100644 --- a/qcsrc/menu/xonotic/mainwindow.qh +++ b/qcsrc/menu/xonotic/mainwindow.qh @@ -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);