Change Minetest-c55 to Minetest
[oweals/minetest.git] / src / guiConfigureWorld.h
1 /*
2 Minetest
3 Copyright (C) 2012 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 GUICONFIGUREWORLD_HEADER
21 #define GUICONFIGUREWORLD_HEADER
22
23 #include "irrlichttypes_extrabloated.h"
24 #include "modalMenu.h"
25 #include "mods.h"
26 #include "subgame.h"
27 #include "settings.h"
28
29
30 namespace irr{
31         namespace gui{
32                 class IGUITreeViewNode;
33         }
34 }
35
36 class GUIConfigureWorld : public GUIModalMenu
37 {
38 public:
39         GUIConfigureWorld(gui::IGUIEnvironment* env,
40                 gui::IGUIElement* parent, s32 id,
41                           IMenuManager *menumgr, WorldSpec wspec);
42
43         void regenerateGui(v2u32 screensize);
44
45         void drawMenu();
46
47         bool OnEvent(const SEvent& event);
48
49 private:
50         WorldSpec m_wspec;
51         SubgameSpec m_gspec;
52
53         // tree of installed add-on mods. key is the mod name, modpacks
54         // are not expanded.
55         std::map<std::string, ModSpec> m_addontree;
56
57         // like m_addontree, but modpacks are expanded.
58         std::map<std::string, ModSpec> m_addonmods;
59
60         // list of game mods (flattened)
61         std::map<std::string, ModSpec> m_gamemods;
62
63         // list of world mods (flattened)
64         std::map<std::string, ModSpec> m_worldmods;
65         
66         // for each mod, the set of mods depending on it
67         std::multimap<std::string, std::string> m_reverse_depends;
68
69         // the settings in the world.mt file
70         Settings m_settings;
71
72         // mods that are installed but not mentioned in world.mt file
73         std::set<std::string> m_new_mod_names;
74
75         // maps modnames to nodes in m_treeview
76         std::map<std::string,gui::IGUITreeViewNode*> m_nodes;
77
78         gui::IGUIStaticText* m_modname_text;
79         gui::IGUITreeView* m_treeview;
80         gui::IGUIButton* m_enableall;
81         gui::IGUIButton* m_disableall;
82         gui::IGUICheckBox* m_enabled_checkbox;
83         gui::IGUIListBox* m_dependencies_listbox;
84         gui::IGUIListBox* m_rdependencies_listbox;
85         void buildTreeView(std::map<std::string,ModSpec> mods, 
86                                            gui::IGUITreeViewNode* node);
87         void adjustSidebar();
88         void enableAllMods(std::map<std::string,ModSpec> mods, bool enable);
89         void setEnabled(std::string modname, bool enable)
90         {
91                 if(enable)
92                         enableMod(modname);
93                 else
94                         disableMod(modname);
95         };
96
97         void enableMod(std::string modname);
98         void disableMod(std::string modname);
99
100         // hack to work around wonky handling of double-click in
101         // irrlicht. store selected index of listbox items here so event
102         // handling can check whether it was a real double click on the
103         // same item. (irrlicht also reports a double click if you rapidly
104         // select two different items.)
105         int selecting_dep;
106         int selecting_rdep;
107
108         IMenuManager* m_menumgr;
109 };
110 #endif