]> git.lizzy.rs Git - dragonfireclient.git/blob - src/guiMainMenu.h
Closed add object <-> object collision handling
[dragonfireclient.git] / src / guiMainMenu.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 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 Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser 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 "irrlichttypes_extrabloated.h"
24 #include "modalMenu.h"
25 #include <string>
26 #include <list>
27 #include "subgame.h"
28 #include "serverlist.h"
29
30 class IGameCallback;
31
32 struct MainMenuData
33 {
34         // These are in the native format of the gui elements
35         // Generic
36         int selected_tab;
37         // Client options
38         std::string servername;
39         std::string serverdescription;
40         std::wstring address;
41         std::wstring port;
42         std::wstring name;
43         std::wstring password;
44         bool fancy_trees;
45         bool smooth_lighting;
46         bool clouds_3d;
47         bool opaque_water;
48         bool mip_map;
49         bool anisotropic_filter;
50         bool bilinear_filter;
51         bool trilinear_filter;
52         int enable_shaders;
53         bool preload_item_visuals;
54         bool enable_particles;
55         bool liquid_finite;
56         // Server options
57         bool creative_mode;
58         bool enable_damage;
59         bool enable_public;
60         int selected_world;
61         bool simple_singleplayer_mode;
62         // Actions
63         std::wstring create_world_name;
64         std::string create_world_gameid;
65         bool only_refresh;
66
67         bool serverlist_show_available; // if false show local favorites only
68
69         std::vector<WorldSpec> worlds;
70         std::vector<SubgameSpec> games;
71         std::vector<ServerListSpec> servers;
72
73         MainMenuData():
74                 // Generic
75                 selected_tab(
76 #if USE_CURL
77                     1
78 #else
79                     0
80 #endif
81                 ),
82                 // Client opts
83                 fancy_trees(false),
84                 smooth_lighting(false),
85                 // Server opts
86                 creative_mode(false),
87                 enable_damage(false),
88                 enable_public(false),
89                 selected_world(0),
90                 simple_singleplayer_mode(false),
91                 // Actions
92                 only_refresh(false),
93
94                 serverlist_show_available(
95 #if USE_CURL
96                     true
97 #else
98                     false
99 #endif
100 )
101         {}
102 };
103
104 class GUIMainMenu : public GUIModalMenu
105 {
106 public:
107         GUIMainMenu(gui::IGUIEnvironment* env,
108                         gui::IGUIElement* parent, s32 id,
109                         IMenuManager *menumgr,
110                         MainMenuData *data,
111                         IGameCallback *gamecallback);
112         ~GUIMainMenu();
113         
114         void removeChildren();
115         // Remove and re-add (or reposition) stuff
116         void regenerateGui(v2u32 screensize);
117         void drawMenu();
118         void readInput(MainMenuData *dst);
119         void acceptInput();
120         bool getStatus()
121         { return m_accepted; }
122         bool OnEvent(const SEvent& event);
123         void createNewWorld(std::wstring name, std::string gameid);
124         void deleteWorld(const std::vector<std::string> &paths);
125         int getTab();
126         void displayMessageMenu(std::wstring msg);
127         
128 private:
129         MainMenuData *m_data;
130         bool m_accepted;
131         IGameCallback *m_gamecallback;
132
133         gui::IGUIEnvironment* env;
134         gui::IGUIElement* parent;
135         s32 id;
136         IMenuManager *menumgr;
137
138         bool m_is_regenerating;
139         v2s32 m_topleft_client;
140         v2s32 m_size_client;
141         v2s32 m_topleft_server;
142         v2s32 m_size_server;
143         void updateGuiServerList();
144         void serverListOnSelected();
145         ServerListSpec getServerListSpec(std::string address, std::string port);
146 };
147
148 #endif
149