08c585b88b038d870c2808888cf438b7794fd0b0
[oweals/minetest.git] / src / guiMainMenu.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2012 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 <string>
26 #include <list>
27 #include "subgame.h"
28 class IGameCallback;
29
30 struct MainMenuData
31 {
32         // These are in the native format of the gui elements
33         // Client options
34         std::wstring address;
35         std::wstring port;
36         std::wstring name;
37         std::wstring password;
38         bool fancy_trees;
39         bool smooth_lighting;
40         bool clouds_3d;
41         bool opaque_water;
42         // Server options
43         bool creative_mode;
44         bool enable_damage;
45         int selected_world;
46         // Actions
47         bool delete_world;
48         std::wstring create_world_name;
49         std::string create_world_gameid;
50
51         std::list<std::wstring> worlds;
52         std::vector<SubgameSpec> games;
53
54         MainMenuData():
55                 // Client opts
56                 fancy_trees(false),
57                 smooth_lighting(false),
58                 // Server opts
59                 creative_mode(false),
60                 enable_damage(false),
61                 selected_world(0),
62                 // Actions
63                 delete_world(false)
64         {}
65 };
66
67 class GUIMainMenu : public GUIModalMenu
68 {
69 public:
70         GUIMainMenu(gui::IGUIEnvironment* env,
71                         gui::IGUIElement* parent, s32 id,
72                         IMenuManager *menumgr,
73                         MainMenuData *data,
74                         IGameCallback *gamecallback);
75         ~GUIMainMenu();
76         
77         void removeChildren();
78         // Remove and re-add (or reposition) stuff
79         void regenerateGui(v2u32 screensize);
80         void drawMenu();
81         void readInput(MainMenuData *dst);
82         void acceptInput();
83         bool getStatus()
84         { return m_accepted; }
85         bool OnEvent(const SEvent& event);
86         void createNewWorld(std::wstring name, std::string gameid);
87         
88 private:
89         MainMenuData *m_data;
90         bool m_accepted;
91         IGameCallback *m_gamecallback;
92
93         gui::IGUIEnvironment* env;
94         gui::IGUIElement* parent;
95         s32 id;
96         IMenuManager *menumgr;
97 };
98
99 #endif
100