Keys should be s32, not u32
[oweals/minetest.git] / src / guiKeyChangeMenu.h
1 /*
2  Minetest-c55
3  Copyright (C) 2010-11 celeron55, Perttu Ahola <celeron55@gmail.com>
4  Copyright (C) 2011 Ciaran Gultnieks <ciaran@ciarang.com>
5  Copyright (C) 2011 teddydestodes <derkomtur@schattengang.net>
6
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  GNU General Public License for more details.
16
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef GUIKEYCHANGEMENU_HEADER
23 #define GUIKEYCHANGEMENU_HEADER
24
25 #include "common_irrlicht.h"
26 #include "utility.h"
27 #include "modalMenu.h"
28 #include "client.h"
29 #include "gettext.h"
30 #include <string>
31
32 static const char *KeyNames[] =
33         { "-", N_("Left Button"), N_("Right Button"), N_("Cancel"), N_("Middle Button"), N_("X Button 1"),
34                         N_("X Button 2"), "-", N_("Back"), N_("Tab"), "-", "-", N_("Clear"), N_("Return"), "-",
35                         "-", N_("Shift"), N_("Control"), N_("Menu"), N_("Pause"), N_("Capital"), N_("Kana"), "-",
36                         N_("Junja"), N_("Final"), N_("Kanji"), "-", N_("Escape"), N_("Convert"), N_("Nonconvert"),
37                         N_("Accept"), N_("Mode Change"), N_("Space"), N_("Priot"), N_("Next"), N_("End"), N_("Home"),
38                         N_("Left"), N_("Up"), N_("Right"), N_("Down"), N_("Select"), N_("Print"), N_("Execute"),
39                         N_("Snapshot"), N_("Insert"), N_("Delete"), N_("Help"), "0", "1", "2", "3", "4", "5",
40                         "6", "7", "8", "9", "-", "-", "-", "-", "-", "-", "-", "A", "B", "C",
41                         "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q",
42                         "R", "S", "T", "U", "V", "W", "X", "Y", "Z", N_("Left Windows"),
43                         N_("Right Windows"), N_("Apps"), "-", N_("Sleep"), N_("Numpad 0"), N_("Numpad 1"),
44                         N_("Numpad 2"), N_("Numpad 3"), N_("Numpad 4"), N_("Numpad 5"), N_("Numpad 6"), N_("Numpad 7"),
45                         N_("Numpad 8"), N_("Numpad 9"), N_("Numpad *"), N_("Numpad +"), N_("Numpad /"), N_("Numpad -"),
46                         "Numpad .", "Numpad /", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8",
47                         "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18",
48                         "F19", "F20", "F21", "F22", "F23", "F24", "-", "-", "-", "-", "-", "-",
49                         "-", "-", N_("Num Lock"), N_("Scroll Lock"), "-", "-", "-", "-", "-", "-", "-",
50                         "-", "-", "-", "-", "-", "-", "-", N_("Left Shift"), N_("Right Shight"),
51                         N_("Left Control"), N_("Right Control"), N_("Left Menu"), N_("Right Menu"), "-", "-",
52                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
53                         "-", "-", "-", "-", "-", N_("Plus"), N_("Comma"), N_("Minus"), N_("Period"), "-", "-",
54                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
55                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
56                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
57                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", N_("Attn"), N_("CrSel"),
58                         N_("ExSel"), N_("Erase OEF"), N_("Play"), N_("Zoom"), N_("PA1"), N_("OEM Clear"), "-" };
59         enum
60         {
61                 GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR,
62                 //buttons
63                 GUI_ID_KEY_FORWARD_BUTTON,
64                 GUI_ID_KEY_BACKWARD_BUTTON,
65                 GUI_ID_KEY_LEFT_BUTTON,
66                 GUI_ID_KEY_RIGHT_BUTTON,
67                 GUI_ID_KEY_USE_BUTTON,
68                 GUI_ID_KEY_FLY_BUTTON,
69                 GUI_ID_KEY_FAST_BUTTON,
70                 GUI_ID_KEY_JUMP_BUTTON,
71                 GUI_ID_KEY_CHAT_BUTTON,
72                 GUI_ID_KEY_SNEAK_BUTTON,
73                 GUI_ID_KEY_INVENTORY_BUTTON,
74                 GUI_ID_KEY_DUMP_BUTTON,
75                 GUI_ID_KEY_RANGE_BUTTON
76         };
77
78 class GUIKeyChangeMenu: public GUIModalMenu
79 {
80 public:
81         GUIKeyChangeMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
82                         s32 id, IMenuManager *menumgr);
83         ~GUIKeyChangeMenu();
84
85         void removeChildren();
86         /*
87          Remove and re-add (or reposition) stuff
88          */
89         void regenerateGui(v2u32 screensize);
90
91         void drawMenu();
92
93         bool acceptInput();
94
95         bool OnEvent(const SEvent& event);
96
97 private:
98
99         void init_keys();
100
101         bool resetMenu();
102
103         gui::IGUIButton *forward;
104         gui::IGUIButton *backward;
105         gui::IGUIButton *left;
106         gui::IGUIButton *right;
107         gui::IGUIButton *use;
108         gui::IGUIButton *sneak;
109         gui::IGUIButton *jump;
110         gui::IGUIButton *inventory;
111         gui::IGUIButton *fly;
112         gui::IGUIButton *fast;
113         gui::IGUIButton *range;
114         gui::IGUIButton *dump;
115         gui::IGUIButton *chat;
116
117         s32 activeKey;
118         s32 key_forward;
119         s32 key_backward;
120         s32 key_left;
121         s32 key_right;
122         s32 key_use;
123         s32 key_sneak;
124         s32 key_jump;
125         s32 key_inventory;
126         s32 key_fly;
127         s32 key_fast;
128         s32 key_range;
129         s32 key_chat;
130         s32 key_dump;
131 };
132
133 #endif
134