merged fix to decapitated trees; other bugs now exists
[oweals/minetest.git] / src / guiKeyChangeMenu.h
1 /*
2  Minetest-delta
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 <string>
30
31 static const char *KeyNames[] =
32         { "-", "Left Button", "Right Button", "Cancel", "Middle Button", "X Button 1",
33                         "X Button 2", "-", "Back", "Tab", "-", "-", "Clear", "Return", "-",
34                         "-", "Shift", "Control", "Menu", "Pause", "Capital", "Kana", "-",
35                         "Junja", "Final", "Kanji", "-", "Escape", "Convert", "Nonconvert",
36                         "Accept", "Mode Change", "Space", "Priot", "Next", "End", "Home",
37                         "Left", "Up", "Right", "Down", "Select", "Print", "Execute",
38                         "Snapshot", "Insert", "Delete", "Help", "0", "1", "2", "3", "4", "5",
39                         "6", "7", "8", "9", "-", "-", "-", "-", "-", "-", "-", "A", "B", "C",
40                         "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q",
41                         "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Left Windows",
42                         "Right Windows", "Apps", "-", "Sleep", "Numpad 0", "Numpad 1",
43                         "Numpad 2", "Numpad 3", "Numpad 4", "Numpad 5", "Numpad 6", "Numpad 7",
44                         "Numpad 8", "Numpad 9", "Numpad *", "Numpad +", "Numpad /", "Numpad -",
45                         "Numpad .", "Numpad /", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8",
46                         "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18",
47                         "F19", "F20", "F21", "F22", "F23", "F24", "-", "-", "-", "-", "-", "-",
48                         "-", "-", "Num Lock", "Scroll Lock", "-", "-", "-", "-", "-", "-", "-",
49                         "-", "-", "-", "-", "-", "-", "-", "Left Shift", "Right Shight",
50                         "Left Control", "Right Control", "Left Menu", "Right Menu", "-", "-",
51                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
52                         "-", "-", "-", "-", "-", "Plus", "Comma", "Minus", "Period", "-", "-",
53                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
54                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
55                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-",
56                         "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "Attn", "CrSel",
57                         "ExSel", "Erase OEF", "Play", "Zoom", "PA1", "OEM Clear", "-" };
58         enum
59         {
60                 GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR,
61                 //buttons
62                 GUI_ID_KEY_FORWARD_BUTTON,
63                 GUI_ID_KEY_BACKWARD_BUTTON,
64                 GUI_ID_KEY_LEFT_BUTTON,
65                 GUI_ID_KEY_RIGHT_BUTTON,
66                 GUI_ID_KEY_USE_BUTTON,
67                 GUI_ID_KEY_FLY_BUTTON,
68                 GUI_ID_KEY_FAST_BUTTON,
69                 GUI_ID_KEY_JUMP_BUTTON,
70                 GUI_ID_KEY_CHAT_BUTTON,
71                 GUI_ID_KEY_SNEAK_BUTTON,
72                 GUI_ID_KEY_INVENTORY_BUTTON,
73                 GUI_ID_KEY_DUMP_BUTTON,
74                 GUI_ID_KEY_RANGE_BUTTON
75         };
76
77 class GUIKeyChangeMenu: public GUIModalMenu
78 {
79 public:
80         GUIKeyChangeMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
81                         s32 id, IMenuManager *menumgr);
82         ~GUIKeyChangeMenu();
83
84         void removeChildren();
85         /*
86          Remove and re-add (or reposition) stuff
87          */
88         void regenerateGui(v2u32 screensize);
89
90         void drawMenu();
91
92         bool acceptInput();
93
94         bool OnEvent(const SEvent& event);
95
96 private:
97
98         void init_keys();
99
100         bool resetMenu();
101
102         gui::IGUIButton *forward;
103         gui::IGUIButton *backward;
104         gui::IGUIButton *left;
105         gui::IGUIButton *right;
106         gui::IGUIButton *use;
107         gui::IGUIButton *sneak;
108         gui::IGUIButton *jump;
109         gui::IGUIButton *inventory;
110         gui::IGUIButton *fly;
111         gui::IGUIButton *fast;
112         gui::IGUIButton *range;
113         gui::IGUIButton *dump;
114         gui::IGUIButton *chat;
115
116         u32 activeKey;
117         u32 key_forward;
118         u32 key_backward;
119         u32 key_left;
120         u32 key_right;
121         u32 key_use;
122         u32 key_sneak;
123         u32 key_jump;
124         u32 key_inventory;
125         u32 key_fly;
126         u32 key_fast;
127         u32 key_range;
128         u32 key_chat;
129         u32 key_dump;
130 };
131
132 #endif
133