]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_settings_input_userbind.c
Merge remote-tracking branch 'origin/samual/serverlist'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_settings_input_userbind.c
1 #ifdef INTERFACE
2 CLASS(XonoticUserbindEditDialog) EXTENDS(XonoticDialog)
3         METHOD(XonoticUserbindEditDialog, loadUserBind, void(entity, string, string, string))
4         METHOD(XonoticUserbindEditDialog, fill, void(entity))
5         ATTRIB(XonoticUserbindEditDialog, title, string, _("User defined key bind"))
6         ATTRIB(XonoticUserbindEditDialog, color, vector, SKINCOLOR_DIALOG_USERBIND)
7         ATTRIB(XonoticUserbindEditDialog, intendedWidth, float, 0.7)
8         ATTRIB(XonoticUserbindEditDialog, rows, float, 4)
9         ATTRIB(XonoticUserbindEditDialog, columns, float, 3)
10         ATTRIB(XonoticUserbindEditDialog, keybindBox, entity, NULL)
11
12         ATTRIB(XonoticUserbindEditDialog, nameBox, entity, NULL)
13         ATTRIB(XonoticUserbindEditDialog, commandPressBox, entity, NULL)
14         ATTRIB(XonoticUserbindEditDialog, commandReleaseBox, entity, NULL)
15 ENDCLASS(XonoticUserbindEditDialog)
16 #endif
17
18 #ifdef IMPLEMENTATION
19 void XonoticUserbindEditDialog_Save(entity btn, entity me)
20 {
21         me.keybindBox.editUserbind(me.keybindBox, me.nameBox.text, me.commandPressBox.text, me.commandReleaseBox.text);
22         Dialog_Close(btn, me);
23 }
24
25 void XonoticUserbindEditDialog_loadUserBind(entity me, string theName, string theCommandPress, string theCommandRelease)
26 {
27         me.nameBox.setText(me.nameBox, theName);
28                 me.nameBox.keyDown(me.nameBox, K_END, 0, 0);
29         me.commandPressBox.setText(me.commandPressBox, theCommandPress);
30                 me.nameBox.keyDown(me.commandPressBox, K_END, 0, 0);
31         me.commandReleaseBox.setText(me.commandReleaseBox, theCommandRelease);
32                 me.nameBox.keyDown(me.commandReleaseBox, K_END, 0, 0);
33 }
34
35 void XonoticUserbindEditDialog_fill(entity me)
36 {
37         entity e;
38         me.TR(me);
39                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Name:")));
40                 me.TD(me, 1, me.columns - 1, me.nameBox = makeXonoticInputBox(0, string_null));
41         me.TR(me);
42                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Command when pressed:")));
43                 me.TD(me, 1, me.columns - 1, me.commandPressBox = makeXonoticInputBox(0, string_null));
44         me.TR(me);
45                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Command when released:")));
46                 me.TD(me, 1, me.columns - 1, me.commandReleaseBox = makeXonoticInputBox(0, string_null));
47         me.TR(me);
48                 me.TD(me, 1, me.columns / 2, e = makeXonoticButton(_("Save"), '0 0 0'));
49                         e.onClick = XonoticUserbindEditDialog_Save;
50                         e.onClickEntity = me;
51                 me.TD(me, 1, me.columns / 2, e = makeXonoticButton(_("Cancel"), '0 0 0'));
52                         e.onClick = Dialog_Close;
53                         e.onClickEntity = me;
54 }
55 #endif