guiConfigureWorld.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef GUICONFIGUREWORLD_HEADER
  17. #define GUICONFIGUREWORLD_HEADER
  18. #include "irrlichttypes_extrabloated.h"
  19. #include "modalMenu.h"
  20. #include "mods.h"
  21. #include "subgame.h"
  22. #include "settings.h"
  23. namespace irr{
  24. namespace gui{
  25. class IGUITreeViewNode;
  26. }
  27. }
  28. class GUIConfigureWorld : public GUIModalMenu
  29. {
  30. public:
  31. GUIConfigureWorld(gui::IGUIEnvironment* env,
  32. gui::IGUIElement* parent, s32 id,
  33. IMenuManager *menumgr, WorldSpec wspec);
  34. void regenerateGui(v2u32 screensize);
  35. void drawMenu();
  36. bool OnEvent(const SEvent& event);
  37. private:
  38. WorldSpec m_wspec;
  39. SubgameSpec m_gspec;
  40. // tree of installed add-on mods. key is the mod name, modpacks
  41. // are not expanded.
  42. std::map<std::string, ModSpec> m_addontree;
  43. // like m_addontree, but modpacks are expanded.
  44. std::map<std::string, ModSpec> m_addonmods;
  45. // list of game mods (flattened)
  46. std::map<std::string, ModSpec> m_gamemods;
  47. // list of world mods (flattened)
  48. std::map<std::string, ModSpec> m_worldmods;
  49. // for each mod, the set of mods depending on it
  50. std::multimap<std::string, std::string> m_reverse_depends;
  51. // the settings in the world.mt file
  52. Settings m_settings;
  53. // maps modnames to nodes in m_treeview
  54. std::map<std::string,gui::IGUITreeViewNode*> m_nodes;
  55. gui::IGUIStaticText* m_modname_text;
  56. gui::IGUITreeView* m_treeview;
  57. gui::IGUIButton* m_enableall;
  58. gui::IGUIButton* m_disableall;
  59. gui::IGUICheckBox* m_enabled_checkbox;
  60. gui::IGUIListBox* m_dependencies_listbox;
  61. gui::IGUIListBox* m_rdependencies_listbox;
  62. void buildTreeView(std::map<std::string,ModSpec> mods,
  63. gui::IGUITreeViewNode* node);
  64. void adjustSidebar();
  65. void enableAllMods(std::map<std::string,ModSpec> mods, bool enable);
  66. void setEnabled(std::string modname, bool enable)
  67. {
  68. if(enable)
  69. enableMod(modname);
  70. else
  71. disableMod(modname);
  72. };
  73. void enableMod(std::string modname);
  74. void disableMod(std::string modname);
  75. // hack to work around wonky handling of double-click in
  76. // irrlicht. store selected index of listbox items here so event
  77. // handling can check whether it was a real double click on the
  78. // same item. (irrlicht also reports a double click if you rapidly
  79. // select two different items.)
  80. int selecting_dep;
  81. int selecting_rdep;
  82. IMenuManager* m_menumgr;
  83. };
  84. #endif