Clean up key names handling
[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 enum
33 {
34         GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR,
35         //buttons
36         GUI_ID_KEY_FORWARD_BUTTON,
37         GUI_ID_KEY_BACKWARD_BUTTON,
38         GUI_ID_KEY_LEFT_BUTTON,
39         GUI_ID_KEY_RIGHT_BUTTON,
40         GUI_ID_KEY_USE_BUTTON,
41         GUI_ID_KEY_FLY_BUTTON,
42         GUI_ID_KEY_FAST_BUTTON,
43         GUI_ID_KEY_JUMP_BUTTON,
44         GUI_ID_KEY_CHAT_BUTTON,
45         GUI_ID_KEY_SNEAK_BUTTON,
46         GUI_ID_KEY_INVENTORY_BUTTON,
47         GUI_ID_KEY_DUMP_BUTTON,
48         GUI_ID_KEY_RANGE_BUTTON
49 };
50
51 class GUIKeyChangeMenu: public GUIModalMenu
52 {
53 public:
54         GUIKeyChangeMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
55                         s32 id, IMenuManager *menumgr);
56         ~GUIKeyChangeMenu();
57
58         void removeChildren();
59         /*
60          Remove and re-add (or reposition) stuff
61          */
62         void regenerateGui(v2u32 screensize);
63
64         void drawMenu();
65
66         bool acceptInput();
67
68         bool OnEvent(const SEvent& event);
69
70 private:
71
72         void init_keys();
73
74         bool resetMenu();
75
76         gui::IGUIButton *forward;
77         gui::IGUIButton *backward;
78         gui::IGUIButton *left;
79         gui::IGUIButton *right;
80         gui::IGUIButton *use;
81         gui::IGUIButton *sneak;
82         gui::IGUIButton *jump;
83         gui::IGUIButton *inventory;
84         gui::IGUIButton *fly;
85         gui::IGUIButton *fast;
86         gui::IGUIButton *range;
87         gui::IGUIButton *dump;
88         gui::IGUIButton *chat;
89
90         s32 activeKey;
91         s32 key_forward;
92         s32 key_backward;
93         s32 key_left;
94         s32 key_right;
95         s32 key_use;
96         s32 key_sneak;
97         s32 key_jump;
98         s32 key_inventory;
99         s32 key_fly;
100         s32 key_fast;
101         s32 key_range;
102         s32 key_chat;
103         s32 key_dump;
104 };
105
106 #endif
107