mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 05:53:26 +02:00
BEAWARE all game functionality is disabled with this commit for a while
* rework client modules * hide main window when loading * remake top menu functions * rework modules autoload * improve path resolving for otml and lua * move core_widgets to core_lib * fix tooltip issues * split some styles * add bit32 lua library * fix assert issues * fix compilation on linux 32 systems * rework gcc compile options * renable and fix some warnings * remove unused constants * speedup sprite cache * move UIGame to lua (not funcional yet) * fix a lot of issues in x11 window * fix crash handler * add some warnings do uiwidget and much more...
This commit is contained in:
@@ -56,6 +56,14 @@ bool Module::load()
|
||||
logInfo("Loaded module '", m_name, "'");
|
||||
g_modules.updateModuleLoadOrder(asModule());
|
||||
|
||||
for(const std::string& modName : m_loadLaterModules) {
|
||||
ModulePtr dep = g_modules.getModule(modName);
|
||||
if(!dep)
|
||||
logError("Unable to find module '", modName, "' required by '", m_name, "'");
|
||||
else if(!dep->isLoaded())
|
||||
dep->load();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,8 +108,8 @@ void Module::discover(const OTMLNodePtr& moduleNode)
|
||||
m_website = moduleNode->valueAt("website", none);
|
||||
m_version = moduleNode->valueAt("version", none);
|
||||
m_autoLoad = moduleNode->valueAt<bool>("autoload", false);
|
||||
m_unloadable = moduleNode->valueAt<bool>("unloadable", true);
|
||||
m_autoLoadAntecedence = moduleNode->valueAt<int>("autoload-antecedence", 9999);
|
||||
m_reloadable = moduleNode->valueAt<bool>("reloadable", false);
|
||||
m_autoLoadPriority = moduleNode->valueAt<int>("autoload-priority", 9999);
|
||||
|
||||
if(OTMLNodePtr node = moduleNode->get("dependencies")) {
|
||||
for(const OTMLNodePtr& tmp : node->children())
|
||||
@@ -109,16 +117,21 @@ void Module::discover(const OTMLNodePtr& moduleNode)
|
||||
}
|
||||
|
||||
// set onLoad callback
|
||||
if(OTMLNodePtr node = moduleNode->get("onLoad")) {
|
||||
if(OTMLNodePtr node = moduleNode->get("@onLoad")) {
|
||||
g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]");
|
||||
g_lua.useValue();
|
||||
m_loadCallback = g_lua.polymorphicPop<SimpleCallback>();
|
||||
}
|
||||
|
||||
// set onUnload callback
|
||||
if(OTMLNodePtr node = moduleNode->get("onUnload")) {
|
||||
if(OTMLNodePtr node = moduleNode->get("@onUnload")) {
|
||||
g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]");
|
||||
g_lua.useValue();
|
||||
m_unloadCallback = g_lua.polymorphicPop<SimpleCallback>();
|
||||
}
|
||||
|
||||
if(OTMLNodePtr node = moduleNode->get("load-later")) {
|
||||
for(const OTMLNodePtr& tmp : node->children())
|
||||
m_loadLaterModules.push_back(tmp->value());
|
||||
}
|
||||
}
|
||||
|
@@ -37,8 +37,10 @@ public:
|
||||
void unload();
|
||||
bool reload();
|
||||
|
||||
bool canUnload() { return m_loaded && m_unloadable && !isDependent(); }
|
||||
bool canUnload() { return m_loaded && m_reloadable && !isDependent(); }
|
||||
bool canReload() { return m_reloadable && !isDependent(); }
|
||||
bool isLoaded() { return m_loaded; }
|
||||
bool isReloadable() { return m_reloadable; }
|
||||
bool isDependent();
|
||||
bool hasDependency(const std::string& name);
|
||||
|
||||
@@ -48,7 +50,7 @@ public:
|
||||
std::string getWebsite() { return m_website; }
|
||||
std::string getVersion() { return m_version; }
|
||||
bool isAutoLoad() { return m_autoLoad; }
|
||||
int getAutoLoadAntecedence() { return m_autoLoadAntecedence; }
|
||||
int getAutoLoadPriority() { return m_autoLoadPriority; }
|
||||
|
||||
ModulePtr asModule() { return std::static_pointer_cast<Module>(shared_from_this()); }
|
||||
|
||||
@@ -59,8 +61,8 @@ protected:
|
||||
private:
|
||||
Boolean<false> m_loaded;
|
||||
Boolean<false> m_autoLoad;
|
||||
Boolean<true> m_unloadable;
|
||||
int m_autoLoadAntecedence;
|
||||
Boolean<false> m_reloadable;
|
||||
int m_autoLoadPriority;
|
||||
std::string m_name;
|
||||
std::string m_description;
|
||||
std::string m_author;
|
||||
@@ -69,6 +71,7 @@ private:
|
||||
SimpleCallback m_loadCallback;
|
||||
SimpleCallback m_unloadCallback;
|
||||
std::list<std::string> m_dependencies;
|
||||
std::list<std::string> m_loadLaterModules;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -40,17 +40,17 @@ void ModuleManager::discoverModules()
|
||||
if(boost::ends_with(moduleFile, ".otmod")) {
|
||||
ModulePtr module = discoverModule("/" + moduleDir + "/" + moduleFile);
|
||||
if(module && module->isAutoLoad())
|
||||
m_autoLoadModules.insert(make_pair(module->getAutoLoadAntecedence(), module));
|
||||
m_autoLoadModules.insert(make_pair(module->getAutoLoadPriority(), module));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleManager::autoLoadModules(int maxAntecedence)
|
||||
void ModuleManager::autoLoadModules(int maxPriority)
|
||||
{
|
||||
for(auto& pair : m_autoLoadModules) {
|
||||
int priority = pair.first;
|
||||
if(priority > maxAntecedence)
|
||||
if(priority > maxPriority)
|
||||
break;
|
||||
ModulePtr module = pair.second;
|
||||
if(!module->isLoaded() && !module->load())
|
||||
|
@@ -30,7 +30,7 @@ class ModuleManager
|
||||
public:
|
||||
void discoverModulesPath();
|
||||
void discoverModules();
|
||||
void autoLoadModules(int maxAntecedence);
|
||||
void autoLoadModules(int maxPriority);
|
||||
ModulePtr discoverModule(const std::string& moduleFile);
|
||||
void ensureModuleLoaded(const std::string& moduleName);
|
||||
void unloadModules();
|
||||
|
@@ -160,7 +160,6 @@ std::list<std::string> ResourceManager::listDirectoryFiles(const std::string& di
|
||||
|
||||
std::string ResourceManager::checkPath(const std::string& path)
|
||||
{
|
||||
/*
|
||||
std::string fullPath;
|
||||
if(boost::starts_with(path, "/"))
|
||||
fullPath = path;
|
||||
@@ -170,10 +169,9 @@ std::string ResourceManager::checkPath(const std::string& path)
|
||||
fullPath += scriptPath + "/";
|
||||
fullPath += path;
|
||||
}
|
||||
*/
|
||||
if(!(boost::starts_with(path, "/")))
|
||||
if(!(boost::starts_with(fullPath, "/")))
|
||||
logTraceWarning("the following file path is not fully resolved: ", path);
|
||||
return path;
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
std::string ResourceManager::getBaseDir()
|
||||
|
Reference in New Issue
Block a user