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