]> git.lizzy.rs Git - minetest.git/blob - src/guiMainMenu.h
a451a9c21ffb40bbac2e45b8e24623cc2af0f9ad
[minetest.git] / src / guiMainMenu.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010 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 "utility.h"
26 #include <string>
27 // For IGameCallback
28 #include "guiPauseMenu.h"
29
30 enum
31 {
32         GUI_ID_QUIT_BUTTON = 101,
33         GUI_ID_NAME_INPUT,
34         GUI_ID_ADDRESS_INPUT,
35         GUI_ID_PORT_INPUT,
36         GUI_ID_FANCYTREE_CB,
37         GUI_ID_SMOOTH_LIGHTING_CB,
38         GUI_ID_3D_CLOUDS_CB,
39         GUI_ID_DAMAGE_CB,
40         GUI_ID_CREATIVE_CB,
41         GUI_ID_JOIN_GAME_BUTTON,
42         GUI_ID_CHANGE_KEYS_BUTTON,
43         GUI_ID_DELETE_MAP_BUTTON
44 };
45
46 struct MainMenuData
47 {
48         MainMenuData():
49                 // Client opts
50                 fancy_trees(false),
51                 smooth_lighting(false),
52                 // Server opts
53                 creative_mode(false),
54                 enable_damage(false),
55                 // Actions
56                 delete_map(false)
57         {}
58
59         // These are in the native format of the gui elements
60         
61         // Client options
62         std::wstring address;
63         std::wstring port;
64         std::wstring name;
65         std::wstring password;
66         bool fancy_trees;
67         bool smooth_lighting;
68         bool clouds_3d;
69         // Server options
70         bool creative_mode;
71         bool enable_damage;
72         // If map deletion is requested, this is set to true
73         bool delete_map;
74 };
75
76 class GUIMainMenu : public GUIModalMenu
77 {
78 public:
79         GUIMainMenu(gui::IGUIEnvironment* env,
80                         gui::IGUIElement* parent, s32 id,
81                         IMenuManager *menumgr,
82                         MainMenuData *data,
83                         IGameCallback *gamecallback);
84         ~GUIMainMenu();
85         
86         void removeChildren();
87         /*
88                 Remove and re-add (or reposition) stuff
89         */
90         void regenerateGui(v2u32 screensize);
91
92         void drawMenu();
93
94         void acceptInput();
95
96         bool getStatus()
97         {
98                 return m_accepted;
99         }
100
101         bool OnEvent(const SEvent& event);
102         
103 private:
104         MainMenuData *m_data;
105         bool m_accepted;
106         IGameCallback *m_gamecallback;
107
108         gui::IGUIEnvironment* env;
109         gui::IGUIElement* parent;
110         s32 id;
111         IMenuManager *menumgr;
112 };
113
114 #endif
115