Merge branch 'master' of https://github.com/erlehmann/minetest-delta.git into upstrea...
[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),
50                 smooth_lighting(false),
51                 // Server opts
52                 creative_mode(false),
53                 enable_damage(false),
54                 // Actions
55                 delete_map(false)
56         {}
57
58         // These are in the native format of the gui elements
59         
60         // Client options
61         std::wstring address;
62         std::wstring port;
63         std::wstring name;
64         std::wstring password;
65         bool fancy_trees;
66         bool smooth_lighting;
67         // Server options
68         bool creative_mode;
69         bool enable_damage;
70         // If map deletion is requested, this is set to true
71         bool delete_map;
72 };
73
74 class GUIMainMenu : public GUIModalMenu
75 {
76 public:
77         GUIMainMenu(gui::IGUIEnvironment* env,
78                         gui::IGUIElement* parent, s32 id,
79                         IMenuManager *menumgr,
80                         MainMenuData *data,
81                         IGameCallback *gamecallback);
82         ~GUIMainMenu();
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         void acceptInput();
93
94         bool getStatus()
95         {
96                 return m_accepted;
97         }
98
99         bool OnEvent(const SEvent& event);
100         
101 private:
102         MainMenuData *m_data;
103         bool m_accepted;
104         IGameCallback *m_gamecallback;
105
106         gui::IGUIEnvironment* env;
107         gui::IGUIElement* parent;
108         s32 id;
109         IMenuManager *menumgr;
110 };
111
112 #endif
113