New modsystem
authorPilzAdam <pilzadam@minetest.net>
Sat, 18 May 2013 15:00:47 +0000 (17:00 +0200)
committerPilzAdam <pilzadam@minetest.net>
Sun, 19 May 2013 00:15:36 +0000 (02:15 +0200)
Mods are placed in $path_<user/share>/mods
They can be enabled per world in world.mt or the configure world window

doc/lua_api.txt
mods/minetest/mods_here.txt [deleted file]
mods/mods_here.txt [new file with mode: 0644]
src/guiConfigureWorld.cpp
src/guiConfigureWorld.h
src/subgame.cpp

index cd90b5aa5c1711553656bc787b666e8700c024e3..b7be5020653fa2ad286637b4a4405396265125c4 100644 (file)
@@ -60,9 +60,9 @@ Mod load path
 -------------
 Generic:
   $path_share/games/gameid/mods/
-  $path_share/mods/gameid/
+  $path_share/mods/
   $path_user/games/gameid/mods/
-  $path_user/mods/gameid/ <-- User-installed mods
+  $path_user/mods/ <-- User-installed mods
   $worldpath/worldmods/
 
 In a run-in-place version (eg. the distributed windows version):
diff --git a/mods/minetest/mods_here.txt b/mods/minetest/mods_here.txt
deleted file mode 100644 (file)
index 5135cb9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-You can install Minetest mods by copying (and extracting) them into this folder.
diff --git a/mods/mods_here.txt b/mods/mods_here.txt
new file mode 100644 (file)
index 0000000..e105fbd
--- /dev/null
@@ -0,0 +1,4 @@
+You can install Minetest mods by copying (and extracting) them into this folder.
+To enable them, go to the configure world window in the main menu or write
+  load_mod_<modname> = true
+in world.mt in the world directory.
index f94ed7d17b4913cfb05259391fe3e5f79a07f78a..e33e87ef5f3e169525703b1b723be2eb5679063e 100644 (file)
@@ -116,40 +116,18 @@ GUIConfigureWorld::GUIConfigureWorld(gui::IGUIEnvironment* env,
                // mod_names
                if(!mod.is_modpack &&
                   mod_names.count(modname) == 0)
-                       m_new_mod_names.insert(modname);
+                       m_settings.setBool("load_mod_"+modname, false);
        }
-       if(!m_new_mod_names.empty())
-       {
-               wchar_t* text = wgettext("Warning: Some mods are not configured yet.\n"
-                               "They will be enabled by default when you save the configuration.  ");
-               GUIMessageMenu *menu = 
-                       new GUIMessageMenu(Environment, Parent, -1, m_menumgr, text);
-               menu->drop();
-               delete[] text;
-       }
-       
-
        // find missing mods (mentioned in world.mt, but not installed)
-       std::set<std::string> missing_mods;
        for(std::set<std::string>::iterator it = mod_names.begin();
                it != mod_names.end(); ++it)
        {
                std::string modname = *it;
                if(m_addonmods.count(modname) == 0)
-                       missing_mods.insert(modname);
+                       m_settings.remove("load_mod_"+modname);
        }
-       if(!missing_mods.empty())
-       {
-               wchar_t* text = wgettext("Warning: Some configured mods are missing.\n"
-                               "Their setting will be removed when you save the configuration.  ");
-               GUIMessageMenu *menu = 
-                       new GUIMessageMenu(Environment, Parent, -1, m_menumgr, text);
-               delete[] text;
-               for(std::set<std::string>::iterator it = missing_mods.begin();
-                       it != missing_mods.end(); ++it)
-                       m_settings.remove("load_mod_"+(*it));
-               menu->drop();
-       }       
+       std::string worldmtfile = m_wspec.path+DIR_DELIM+"world.mt";
+       m_settings.updateConfigFile(worldmtfile.c_str());
 }
 
 void GUIConfigureWorld::drawMenu()
@@ -388,11 +366,6 @@ bool GUIConfigureWorld::OnEvent(const SEvent& event)
                                return true;
                        }
                        case GUI_ID_SAVE: {
-                               for(std::set<std::string>::iterator it = m_new_mod_names.begin();
-                                       it!= m_new_mod_names.end(); ++it)
-                               {
-                                       m_settings.setBool("load_mod_"+(*it),true);
-                               }
                                std::string worldmtfile = m_wspec.path+DIR_DELIM+"world.mt";
                                m_settings.updateConfigFile(worldmtfile.c_str());
 
@@ -558,22 +531,14 @@ void GUIConfigureWorld::buildTreeView(std::map<std::string, ModSpec> mods,
                        buildTreeView(mod.modpack_content, new_node);
                else
                {
-                       // set icon for node: ? for new mods, x for disabled mods,
-                       // checkmark for enabled mods
-                       if(m_new_mod_names.count(modname) > 0)
-                       {
-                               new_node->setIcon(QUESTIONMARK_STR);
-                       }
+                       // set icon for node: x for disabled mods, checkmark for enabled mods
+                       bool mod_enabled = false;
+                       if(m_settings.exists("load_mod_"+modname))
+                               mod_enabled = m_settings.getBool("load_mod_"+modname);
+                       if(mod_enabled)
+                               new_node->setIcon(CHECKMARK_STR);
                        else
-                       {
-                               bool mod_enabled = true;
-                               if(m_settings.exists("load_mod_"+modname))
-                                       mod_enabled = m_settings.getBool("load_mod_"+modname);
-                               if(mod_enabled)
-                                       new_node->setIcon(CHECKMARK_STR);
-                               else 
-                                       new_node->setIcon(CROSS_STR);
-                       }
+                               new_node->setIcon(CROSS_STR);
                }
        }
 }
@@ -690,7 +655,6 @@ void GUIConfigureWorld::enableMod(std::string modname)
                m_nodes.find(modname);
        if(it != m_nodes.end())
                (*it).second->setIcon(CHECKMARK_STR);
-       m_new_mod_names.erase(modname);
        //also enable all dependencies
        for(std::set<std::string>::iterator it=mspec.depends.begin();
                it != mspec.depends.end(); ++it)
@@ -715,7 +679,6 @@ void GUIConfigureWorld::disableMod(std::string modname)
                m_nodes.find(modname);
        if(it != m_nodes.end())
                (*it).second->setIcon(CROSS_STR);
-       m_new_mod_names.erase(modname);
        //also disable all mods that depend on this one
        std::pair<std::multimap<std::string, std::string>::iterator, 
                          std::multimap<std::string, std::string>::iterator > rdep = 
index 8a77c5f898fab1546e89491390ff1326df508083..23ebac66d1a6820bc37e1508977491c563e2fe93 100644 (file)
@@ -69,9 +69,6 @@ private:
        // the settings in the world.mt file
        Settings m_settings;
 
-       // mods that are installed but not mentioned in world.mt file
-       std::set<std::string> m_new_mod_names;
-
        // maps modnames to nodes in m_treeview
        std::map<std::string,gui::IGUITreeViewNode*> m_nodes;
 
index cdb5466197554cab4f411f1901536a8822ad6c09..7fee3899d4ace353f7555735034f25390475c215 100644 (file)
@@ -91,9 +91,9 @@ SubgameSpec findSubgame(const std::string &id)
        // Find mod directories
        std::set<std::string> mods_paths;
        if(!user_game)
-               mods_paths.insert(share + DIR_DELIM + "mods" + DIR_DELIM + id);
+               mods_paths.insert(share + DIR_DELIM + "mods");
        if(user != share || user_game)
-               mods_paths.insert(user + DIR_DELIM + "mods" + DIR_DELIM + id);
+               mods_paths.insert(user + DIR_DELIM + "mods");
        std::string game_name = getGameName(game_path);
        if(game_name == "")
                game_name = id;