688e393ad5ca90f6f626d18d76c77815fcf5e881
[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         WorldSpec delete_world_spec;
48         std::wstring create_world_name;
49         std::string create_world_gameid;
50
51         std::vector<WorldSpec> 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         {}
63 };
64
65 class GUIMainMenu : public GUIModalMenu
66 {
67 public:
68         GUIMainMenu(gui::IGUIEnvironment* env,
69                         gui::IGUIElement* parent, s32 id,
70                         IMenuManager *menumgr,
71                         MainMenuData *data,
72                         IGameCallback *gamecallback);
73         ~GUIMainMenu();
74         
75         void removeChildren();
76         // Remove and re-add (or reposition) stuff
77         void regenerateGui(v2u32 screensize);
78         void drawMenu();
79         void readInput(MainMenuData *dst);
80         void acceptInput();
81         bool getStatus()
82         { return m_accepted; }
83         bool OnEvent(const SEvent& event);
84         void createNewWorld(std::wstring name, std::string gameid);
85         void deleteWorld(WorldSpec spec);
86         
87 private:
88         MainMenuData *m_data;
89         bool m_accepted;
90         IGameCallback *m_gamecallback;
91
92         gui::IGUIEnvironment* env;
93         gui::IGUIElement* parent;
94         s32 id;
95         IMenuManager *menumgr;
96 };
97
98 #endif
99