Skip to content

Commit 45fcc9d

Browse files
committedMay 19, 2013
New modsystem
Mods are placed in $path_<user/share>/mods They can be enabled per world in world.mt or the configure world window
1 parent 6074163 commit 45fcc9d

File tree

6 files changed

+19
-56
lines changed

6 files changed

+19
-56
lines changed
 

‎doc/lua_api.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ Mod load path
6060
-------------
6161
Generic:
6262
$path_share/games/gameid/mods/
63-
$path_share/mods/gameid/
63+
$path_share/mods/
6464
$path_user/games/gameid/mods/
65-
$path_user/mods/gameid/ <-- User-installed mods
65+
$path_user/mods/ <-- User-installed mods
6666
$worldpath/worldmods/
6767

6868
In a run-in-place version (eg. the distributed windows version):

‎mods/minetest/mods_here.txt

-1
This file was deleted.

‎mods/mods_here.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
You can install Minetest mods by copying (and extracting) them into this folder.
2+
To enable them, go to the configure world window in the main menu or write
3+
load_mod_<modname> = true
4+
in world.mt in the world directory.

‎src/guiConfigureWorld.cpp

+11-48
Original file line numberDiff line numberDiff line change
@@ -116,40 +116,18 @@ GUIConfigureWorld::GUIConfigureWorld(gui::IGUIEnvironment* env,
116116
// mod_names
117117
if(!mod.is_modpack &&
118118
mod_names.count(modname) == 0)
119-
m_new_mod_names.insert(modname);
119+
m_settings.setBool("load_mod_"+modname, false);
120120
}
121-
if(!m_new_mod_names.empty())
122-
{
123-
wchar_t* text = wgettext("Warning: Some mods are not configured yet.\n"
124-
"They will be enabled by default when you save the configuration. ");
125-
GUIMessageMenu *menu =
126-
new GUIMessageMenu(Environment, Parent, -1, m_menumgr, text);
127-
menu->drop();
128-
delete[] text;
129-
}
130-
131-
132121
// find missing mods (mentioned in world.mt, but not installed)
133-
std::set<std::string> missing_mods;
134122
for(std::set<std::string>::iterator it = mod_names.begin();
135123
it != mod_names.end(); ++it)
136124
{
137125
std::string modname = *it;
138126
if(m_addonmods.count(modname) == 0)
139-
missing_mods.insert(modname);
127+
m_settings.remove("load_mod_"+modname);
140128
}
141-
if(!missing_mods.empty())
142-
{
143-
wchar_t* text = wgettext("Warning: Some configured mods are missing.\n"
144-
"Their setting will be removed when you save the configuration. ");
145-
GUIMessageMenu *menu =
146-
new GUIMessageMenu(Environment, Parent, -1, m_menumgr, text);
147-
delete[] text;
148-
for(std::set<std::string>::iterator it = missing_mods.begin();
149-
it != missing_mods.end(); ++it)
150-
m_settings.remove("load_mod_"+(*it));
151-
menu->drop();
152-
}
129+
std::string worldmtfile = m_wspec.path+DIR_DELIM+"world.mt";
130+
m_settings.updateConfigFile(worldmtfile.c_str());
153131
}
154132

155133
void GUIConfigureWorld::drawMenu()
@@ -388,11 +366,6 @@ bool GUIConfigureWorld::OnEvent(const SEvent& event)
388366
return true;
389367
}
390368
case GUI_ID_SAVE: {
391-
for(std::set<std::string>::iterator it = m_new_mod_names.begin();
392-
it!= m_new_mod_names.end(); ++it)
393-
{
394-
m_settings.setBool("load_mod_"+(*it),true);
395-
}
396369
std::string worldmtfile = m_wspec.path+DIR_DELIM+"world.mt";
397370
m_settings.updateConfigFile(worldmtfile.c_str());
398371

@@ -558,22 +531,14 @@ void GUIConfigureWorld::buildTreeView(std::map<std::string, ModSpec> mods,
558531
buildTreeView(mod.modpack_content, new_node);
559532
else
560533
{
561-
// set icon for node: ? for new mods, x for disabled mods,
562-
// checkmark for enabled mods
563-
if(m_new_mod_names.count(modname) > 0)
564-
{
565-
new_node->setIcon(QUESTIONMARK_STR);
566-
}
534+
// set icon for node: x for disabled mods, checkmark for enabled mods
535+
bool mod_enabled = false;
536+
if(m_settings.exists("load_mod_"+modname))
537+
mod_enabled = m_settings.getBool("load_mod_"+modname);
538+
if(mod_enabled)
539+
new_node->setIcon(CHECKMARK_STR);
567540
else
568-
{
569-
bool mod_enabled = true;
570-
if(m_settings.exists("load_mod_"+modname))
571-
mod_enabled = m_settings.getBool("load_mod_"+modname);
572-
if(mod_enabled)
573-
new_node->setIcon(CHECKMARK_STR);
574-
else
575-
new_node->setIcon(CROSS_STR);
576-
}
541+
new_node->setIcon(CROSS_STR);
577542
}
578543
}
579544
}
@@ -690,7 +655,6 @@ void GUIConfigureWorld::enableMod(std::string modname)
690655
m_nodes.find(modname);
691656
if(it != m_nodes.end())
692657
(*it).second->setIcon(CHECKMARK_STR);
693-
m_new_mod_names.erase(modname);
694658
//also enable all dependencies
695659
for(std::set<std::string>::iterator it=mspec.depends.begin();
696660
it != mspec.depends.end(); ++it)
@@ -715,7 +679,6 @@ void GUIConfigureWorld::disableMod(std::string modname)
715679
m_nodes.find(modname);
716680
if(it != m_nodes.end())
717681
(*it).second->setIcon(CROSS_STR);
718-
m_new_mod_names.erase(modname);
719682
//also disable all mods that depend on this one
720683
std::pair<std::multimap<std::string, std::string>::iterator,
721684
std::multimap<std::string, std::string>::iterator > rdep =

‎src/guiConfigureWorld.h

-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ class GUIConfigureWorld : public GUIModalMenu
6969
// the settings in the world.mt file
7070
Settings m_settings;
7171

72-
// mods that are installed but not mentioned in world.mt file
73-
std::set<std::string> m_new_mod_names;
74-
7572
// maps modnames to nodes in m_treeview
7673
std::map<std::string,gui::IGUITreeViewNode*> m_nodes;
7774

‎src/subgame.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ SubgameSpec findSubgame(const std::string &id)
9191
// Find mod directories
9292
std::set<std::string> mods_paths;
9393
if(!user_game)
94-
mods_paths.insert(share + DIR_DELIM + "mods" + DIR_DELIM + id);
94+
mods_paths.insert(share + DIR_DELIM + "mods");
9595
if(user != share || user_game)
96-
mods_paths.insert(user + DIR_DELIM + "mods" + DIR_DELIM + id);
96+
mods_paths.insert(user + DIR_DELIM + "mods");
9797
std::string game_name = getGameName(game_path);
9898
if(game_name == "")
9999
game_name = id;

0 commit comments

Comments
 (0)