added new submenu for key assignment
[oweals/minetest.git] / src / guiMainMenu.h
1 /*
2  Minetest-c55
3  Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19
20 #ifndef GUIMAINMENU_HEADER
21 #define GUIMAINMENU_HEADER
22
23 #include "common_irrlicht.h"
24 #include "modalMenu.h"
25 #include "utility.h"
26 #include <string>
27 // For IGameCallback
28 #include "guiPauseMenu.h"
29
30 enum
31 {
32         GUI_ID_QUIT_BUTTON = 101,
33         GUI_ID_NAME_INPUT,
34         GUI_ID_ADDRESS_INPUT,
35         GUI_ID_PORT_INPUT,
36         GUI_ID_FANCYTREE_CB,
37         GUI_ID_SMOOTH_LIGHTING_CB,
38         GUI_ID_DAMAGE_CB,
39         GUI_ID_CREATIVE_CB,
40         GUI_ID_JOIN_GAME_BUTTON,
41         GUI_ID_CHANGE_KEYS_BUTTON,
42         GUI_ID_DELETE_MAP_BUTTON
43 };
44
45 struct MainMenuData
46 {
47         MainMenuData() :
48                 // Client opts
49                                 fancy_trees(false), smooth_lighting(false),
50                                 // Server opts
51                                 creative_mode(false), enable_damage(false),
52                                 // Actions
53                                 delete_map(false)
54         {
55         }
56
57         // These are in the native format of the gui elements
58
59         // Client options
60         std::wstring address;
61         std::wstring port;
62         std::wstring name;
63         std::wstring password;
64         bool fancy_trees;
65         bool smooth_lighting;
66         // Server options
67         bool creative_mode;
68         bool enable_damage;
69         // If map deletion is requested, this is set to true
70         bool delete_map;
71 };
72
73 class GUIMainMenu: public GUIModalMenu
74 {
75 public:
76         GUIMainMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id,
77                         IMenuManager *menumgr, MainMenuData *data,
78                         IGameCallback *gamecallback);
79         ~GUIMainMenu();
80
81         gui::IGUIEnvironment* env;
82         gui::IGUIElement* parent;
83         s32 id;
84         IMenuManager *menumgr;
85
86         void removeChildren();
87         /*
88          Remove and re-add (or reposition) stuff
89          */
90         void regenerateGui(v2u32 screensize);
91
92         void drawMenu();
93
94         void acceptInput();
95
96         bool getStatus()
97         {
98                 return m_accepted;
99         }
100
101         bool OnEvent(const SEvent& event);
102
103 private:
104         MainMenuData *m_data;
105         bool m_accepted;
106         IGameCallback *m_gamecallback;
107 };
108
109 #endif
110