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