merged an old head into main branch
[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 struct MainMenuData
31 {
32         MainMenuData():
33                 // Client opts
34                 fancy_trees(false),
35                 smooth_lighting(false),
36                 // Server opts
37                 creative_mode(false),
38                 enable_damage(false),
39                 // Actions
40                 delete_map(false)
41         {}
42
43         // These are in the native format of the gui elements
44         
45         // Client options
46         std::wstring address;
47         std::wstring port;
48         std::wstring name;
49         std::wstring password;
50         bool fancy_trees;
51         bool smooth_lighting;
52         // Server options
53         bool creative_mode;
54         bool enable_damage;
55         // If map deletion is requested, this is set to true
56         bool delete_map;
57 };
58
59 class GUIMainMenu : public GUIModalMenu
60 {
61 public:
62         GUIMainMenu(gui::IGUIEnvironment* env,
63                         gui::IGUIElement* parent, s32 id,
64                         IMenuManager *menumgr,
65                         MainMenuData *data,
66                         IGameCallback *gamecallback);
67         ~GUIMainMenu();
68         
69         void removeChildren();
70         /*
71                 Remove and re-add (or reposition) stuff
72         */
73         void regenerateGui(v2u32 screensize);
74
75         void drawMenu();
76
77         void acceptInput();
78
79         bool getStatus()
80         {
81                 return m_accepted;
82         }
83
84         bool OnEvent(const SEvent& event);
85         
86 private:
87         MainMenuData *m_data;
88         bool m_accepted;
89         IGameCallback *m_gamecallback;
90 };
91
92 #endif
93