]> git.lizzy.rs Git - dragonfireclient.git/blob - src/guiMainMenu.h
Filter worlds by selected game
[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 enum {
33         SERVERLIST_FAVORITES,
34         SERVERLIST_PUBLIC,
35 };
36
37 struct MainMenuData
38 {
39         // These are in the native format of the gui elements
40         // Generic
41         int selected_tab;
42         std::string selected_game;
43         // Client options
44         std::string servername;
45         std::string serverdescription;
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         bool clouds_3d;
53         bool opaque_water;
54         bool mip_map;
55         bool anisotropic_filter;
56         bool bilinear_filter;
57         bool trilinear_filter;
58         int enable_shaders;
59         bool preload_item_visuals;
60         bool enable_particles;
61         bool liquid_finite;
62         // Server options
63         bool creative_mode;
64         bool enable_damage;
65         bool enable_public;
66         int selected_world;
67         bool simple_singleplayer_mode;
68         // Actions
69         std::wstring create_world_name;
70         std::string create_world_gameid;
71         bool only_refresh;
72
73         int selected_serverlist;
74
75         std::vector<WorldSpec> worlds;
76         std::vector<SubgameSpec> games;
77         std::vector<ServerListSpec> servers;
78
79         MainMenuData():
80                 // Generic
81                 selected_tab(0),
82                 selected_game("minetest"),
83                 // Client opts
84                 fancy_trees(false),
85                 smooth_lighting(false),
86                 // Server opts
87                 creative_mode(false),
88                 enable_damage(false),
89                 enable_public(false),
90                 selected_world(0),
91                 simple_singleplayer_mode(false),
92                 // Actions
93                 only_refresh(false),
94
95                 selected_serverlist(SERVERLIST_FAVORITES)
96         {}
97 };
98
99 class GUIMainMenu : public GUIModalMenu
100 {
101 public:
102         GUIMainMenu(gui::IGUIEnvironment* env,
103                         gui::IGUIElement* parent, s32 id,
104                         IMenuManager *menumgr,
105                         MainMenuData *data,
106                         IGameCallback *gamecallback);
107         ~GUIMainMenu();
108         
109         void removeChildren();
110         // Remove and re-add (or reposition) stuff
111         void regenerateGui(v2u32 screensize);
112         void drawMenu();
113         void readInput(MainMenuData *dst);
114         void acceptInput();
115         bool getStatus()
116         { return m_accepted; }
117         bool OnEvent(const SEvent& event);
118         void createNewWorld(std::wstring name, std::string gameid);
119         void deleteWorld(const std::vector<std::string> &paths);
120         int getTab();
121         void displayMessageMenu(std::wstring msg);
122         
123 private:
124         MainMenuData *m_data;
125         bool m_accepted;
126         IGameCallback *m_gamecallback;
127
128         gui::IGUIEnvironment* env;
129         gui::IGUIElement* parent;
130         s32 id;
131         IMenuManager *menumgr;
132
133         std::vector<int> m_world_indices;
134
135         bool m_is_regenerating;
136         v2s32 m_topleft_client;
137         v2s32 m_size_client;
138         v2s32 m_topleft_server;
139         v2s32 m_size_server;
140         void updateGuiServerList();
141         void serverListOnSelected();
142         ServerListSpec getServerListSpec(std::string address, std::string port);
143 };
144
145 #endif
146