mirror of
https://github.com/minetest/minetest.git
synced 2025-07-04 17:00:23 +02:00
Basic support for configuring which mods to load for each world
settings.h: added function to return all keys used in settings, and a function to remove a setting mods.{h,cpp}: added class ModConfiguration that represents a subset of the installed mods. server.{h,cpp}: server does not load add-on mods that are disabled in the world.mt file. mods are disabled by a setting of the form "load_mod_<modname> = false". if no load_mod_<modname> = ... setting is found, the mod is loaded anyways for backwards compatibilty. server also complains to errorstream about mods with unstatisfied dependencies and about mods that are not installed. guiConfigureWorld.{h,cpp}: shows a treeview of installed add-on mods and modpacks with little icons in front of their name indicating their status: a checkmark for enabled mods, a cross for disabled mods, a question mark for "new" mods Mods can be enabled/disabled by a checkbox. Mods also show a list of dependencies and reverse dependencies. double-click on a mod in dependency or reverse dependency listbox selects the corresponding mod. Enabling a mod also enables all its dependencies. Disabling a mod also disables all its reverse dependencies. For modpacks, show buttons to enable/disable all mods (recursively, including their dependencies) in it. Button "Save" saves the current settings to the world.mt file and returns to the main menu. Button "Cancel" returns to main menu without saving. basic keyboard controls (if the proper widget has keyboard focus): up/down: scroll through tree of mods left/right: collaps/expand a modpack space: enable/disable the selected mod
This commit is contained in:
committed by
Perttu Ahola
parent
6f93c01af9
commit
6af8a34d91
@ -980,33 +980,65 @@ Server::Server(
|
||||
std::string rollback_path = m_path_world+DIR_DELIM+"rollback.txt";
|
||||
m_rollback = createRollbackManager(rollback_path, this);
|
||||
|
||||
// Add world mod search path
|
||||
m_modspaths.push_front(m_path_world + DIR_DELIM + "worldmods");
|
||||
// Add addon mod search path
|
||||
for(std::set<std::string>::const_iterator i = m_gamespec.mods_paths.begin();
|
||||
i != m_gamespec.mods_paths.end(); i++)
|
||||
m_modspaths.push_front((*i));
|
||||
|
||||
// Print out mod search paths
|
||||
for(core::list<std::string>::Iterator i = m_modspaths.begin();
|
||||
i != m_modspaths.end(); i++){
|
||||
std::string modspath = *i;
|
||||
infostream<<"- mods: "<<modspath<<std::endl;
|
||||
}
|
||||
|
||||
// Path to builtin.lua
|
||||
std::string builtinpath = getBuiltinLuaPath() + DIR_DELIM + "builtin.lua";
|
||||
|
||||
// Create world if it doesn't exist
|
||||
if(!initializeWorld(m_path_world, m_gamespec.id))
|
||||
throw ServerError("Failed to initialize world");
|
||||
|
||||
ModConfiguration modconf(m_path_world);
|
||||
m_mods = modconf.getMods();
|
||||
// complain about mods with unsatisfied dependencies
|
||||
if(!modconf.isConsistent())
|
||||
{
|
||||
errorstream << "The following mods have unsatisfied dependencies: ";
|
||||
std::list<ModSpec> modlist = modconf.getUnsatisfiedMods();
|
||||
for(std::list<ModSpec>::iterator it = modlist.begin();
|
||||
it != modlist.end(); ++it)
|
||||
{
|
||||
errorstream << (*it).name << " ";
|
||||
}
|
||||
errorstream << std::endl;
|
||||
}
|
||||
|
||||
Settings worldmt_settings;
|
||||
std::string worldmt = m_path_world + DIR_DELIM + "world.mt";
|
||||
worldmt_settings.readConfigFile(worldmt.c_str());
|
||||
std::vector<std::string> names = worldmt_settings.getNames();
|
||||
std::set<std::string> exclude_mod_names;
|
||||
std::set<std::string> load_mod_names;
|
||||
for(std::vector<std::string>::iterator it = names.begin();
|
||||
it != names.end(); ++it)
|
||||
{
|
||||
std::string name = *it;
|
||||
if (name.compare(0,9,"load_mod_")==0)
|
||||
{
|
||||
if(worldmt_settings.getBool(name))
|
||||
load_mod_names.insert(name.substr(9));
|
||||
else
|
||||
exclude_mod_names.insert(name.substr(9));
|
||||
}
|
||||
}
|
||||
// complain about mods declared to be loaded, but not found
|
||||
for(std::vector<ModSpec>::iterator it = m_mods.begin();
|
||||
it != m_mods.end(); ++it)
|
||||
load_mod_names.erase((*it).name);
|
||||
if(!load_mod_names.empty())
|
||||
{
|
||||
errorstream << "The following mods could not be found: ";
|
||||
for(std::set<std::string>::iterator it = load_mod_names.begin();
|
||||
it != load_mod_names.end(); ++it)
|
||||
errorstream << (*it) << " ";
|
||||
errorstream << std::endl;
|
||||
}
|
||||
|
||||
// Path to builtin.lua
|
||||
std::string builtinpath = getBuiltinLuaPath() + DIR_DELIM + "builtin.lua";
|
||||
|
||||
// Lock environment
|
||||
JMutexAutoLock envlock(m_env_mutex);
|
||||
JMutexAutoLock conlock(m_con_mutex);
|
||||
|
||||
// Initialize scripting
|
||||
|
||||
|
||||
infostream<<"Server: Initializing Lua"<<std::endl;
|
||||
m_lua = script_init();
|
||||
assert(m_lua);
|
||||
@ -1021,18 +1053,16 @@ Server::Server(
|
||||
<<builtinpath<<std::endl;
|
||||
throw ModError("Failed to load and run "+builtinpath);
|
||||
}
|
||||
// Find mods in mod search paths
|
||||
m_mods = getMods(m_modspaths);
|
||||
// Print 'em
|
||||
infostream<<"Server: Loading mods: ";
|
||||
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
||||
for(std::vector<ModSpec>::iterator i = m_mods.begin();
|
||||
i != m_mods.end(); i++){
|
||||
const ModSpec &mod = *i;
|
||||
infostream<<mod.name<<" ";
|
||||
}
|
||||
infostream<<std::endl;
|
||||
// Load and run "mod" scripts
|
||||
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
||||
for(std::vector<ModSpec>::iterator i = m_mods.begin();
|
||||
i != m_mods.end(); i++){
|
||||
const ModSpec &mod = *i;
|
||||
std::string scriptpath = mod.path + DIR_DELIM + "init.lua";
|
||||
@ -4105,7 +4135,7 @@ void Server::fillMediaCache()
|
||||
|
||||
// Collect all media file paths
|
||||
std::list<std::string> paths;
|
||||
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
||||
for(std::vector<ModSpec>::iterator i = m_mods.begin();
|
||||
i != m_mods.end(); i++){
|
||||
const ModSpec &mod = *i;
|
||||
paths.push_back(mod.path + DIR_DELIM + "textures");
|
||||
@ -4770,7 +4800,7 @@ IWritableCraftDefManager* Server::getWritableCraftDefManager()
|
||||
|
||||
const ModSpec* Server::getModSpec(const std::string &modname)
|
||||
{
|
||||
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
||||
for(std::vector<ModSpec>::iterator i = m_mods.begin();
|
||||
i != m_mods.end(); i++){
|
||||
const ModSpec &mod = *i;
|
||||
if(mod.name == modname)
|
||||
@ -4780,7 +4810,7 @@ const ModSpec* Server::getModSpec(const std::string &modname)
|
||||
}
|
||||
void Server::getModNames(core::list<std::string> &modlist)
|
||||
{
|
||||
for(core::list<ModSpec>::Iterator i = m_mods.begin(); i != m_mods.end(); i++)
|
||||
for(std::vector<ModSpec>::iterator i = m_mods.begin(); i != m_mods.end(); i++)
|
||||
{
|
||||
modlist.push_back((*i).name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user