improvements to skins

This commit is contained in:
Henrique Santiago
2012-06-19 05:46:49 -03:00
parent 5a048eb7ea
commit 4bdcae2f8b
74 changed files with 155 additions and 87 deletions

View File

@@ -77,6 +77,7 @@ void ModuleManager::discoverModulesPath()
// try to add module directory
if(g_resources.addToSearchPath(dir, false)) {
//g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str()));
m_modulesPath = dir;
found = true;
break;
}

View File

@@ -37,6 +37,7 @@ public:
void ensureModuleLoaded(const std::string& moduleName);
void unloadModules();
void reloadModules();
std::string getModulesPath() { return m_modulesPath; }
ModulePtr getModule(const std::string& moduleName);
std::deque<ModulePtr> getModules() { return m_modules; }
@@ -47,6 +48,7 @@ protected:
friend class Module;
private:
std::string m_modulesPath;
std::deque<ModulePtr> m_modules;
std::multimap<int, ModulePtr> m_autoLoadModules;
};

View File

@@ -66,6 +66,13 @@ bool ResourceManager::addToSearchPath(const std::string& path, bool insertInFron
return true;
}
bool ResourceManager::removeFromSearchPath(const std::string& path)
{
if(!PHYSFS_removeFromSearchPath(path.c_str()))
return false;
return true;
}
void ResourceManager::searchAndAddPackages(const std::string& packagesDir, const std::string& packageExt, bool append)
{
auto files = listDirectoryFiles(resolvePath(packagesDir));

View File

@@ -34,6 +34,7 @@ public:
bool setupWriteDir(const std::string& appWriteDirName);
bool addToSearchPath(const std::string& path, bool insertInFront = true);
bool removeFromSearchPath(const std::string& path);
void searchAndAddPackages(const std::string& packagesDir, const std::string& packagesExt, bool append);
bool fileExists(const std::string& fileName);

View File

@@ -38,6 +38,12 @@ void FontManager::terminate()
m_defaultFont = nullptr;
}
void FontManager::clearFonts()
{
m_fonts.clear();
m_defaultFont = BitmapFontPtr(new BitmapFont("emptyfont"));
}
bool FontManager::importFont(std::string fontFile)
{
try {

View File

@@ -31,6 +31,7 @@ public:
FontManager();
void terminate();
void clearFonts();
bool importFont(std::string fontFile);

View File

@@ -120,7 +120,7 @@ void PainterOGL2::drawCoords(CoordsBuffer& coordsBuffer, DrawMode drawMode)
void PainterOGL2::drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture)
{
if(texture->isEmpty())
if(texture && texture->isEmpty())
return;
setDrawProgram(m_shaderProgram ? m_shaderProgram : m_drawTexturedProgram.get());

View File

@@ -34,6 +34,7 @@
#include <framework/core/module.h>
#include <framework/sound/soundmanager.h>
#include <framework/util/crypt.h>
#include <framework/core/resourcemanager.h>
void Application::registerLuaFunctions()
{
@@ -601,9 +602,11 @@ void Application::registerLuaFunctions()
g_lua.bindSingletonFunction("g_modules", "reloadModules", &ModuleManager::reloadModules, &g_modules);
g_lua.bindSingletonFunction("g_modules", "getModule", &ModuleManager::getModule, &g_modules);
g_lua.bindSingletonFunction("g_modules", "getModules", &ModuleManager::getModules, &g_modules);
g_lua.bindSingletonFunction("g_modules", "getModulesPath", &ModuleManager::getModulesPath, &g_modules);
// FontManager
g_lua.registerSingletonClass("g_fonts");
g_lua.bindSingletonFunction("g_fonts", "clearFonts", &FontManager::clearFonts, &g_fonts);
g_lua.bindSingletonFunction("g_fonts", "importFont", &FontManager::importFont, &g_fonts);
g_lua.bindSingletonFunction("g_fonts", "fontExists", &FontManager::fontExists, &g_fonts);
g_lua.bindSingletonFunction("g_fonts", "setDefaultFont", &FontManager::setDefaultFont, &g_fonts);
@@ -626,4 +629,15 @@ void Application::registerLuaFunctions()
g_lua.bindSingletonFunction("g_eventDispatcher", "addEvent", &EventDispatcher::addEvent, &g_eventDispatcher);
g_lua.bindSingletonFunction("g_eventDispatcher", "scheduleEvent", &EventDispatcher::scheduleEvent, &g_eventDispatcher);
g_lua.bindSingletonFunction("g_eventDispatcher", "cycleEvent", &EventDispatcher::cycleEvent, &g_eventDispatcher);
// ResourceManager
g_lua.registerSingletonClass("g_resources");
g_lua.bindSingletonFunction("g_resources", "addToSearchPath", &ResourceManager::addToSearchPath, &g_resources);
g_lua.bindSingletonFunction("g_resources", "removeFromSearchPath", &ResourceManager::removeFromSearchPath, &g_resources);
g_lua.bindSingletonFunction("g_resources", "fileExists", &ResourceManager::fileExists, &g_resources);
// LuaInterface
g_lua.registerSingletonClass("g_lua");
g_lua.bindSingletonFunction("g_lua", "getCurrentSourcePath", &LuaInterface::getCurrentSourcePath, &g_lua);
}

View File

@@ -112,8 +112,6 @@ public:
void draw(const Point& dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase);
void drawMask(const Point& dest, float scaleFactor, int w, int h, int xPattern, int yPattern, int zPattern, int layer, int animationPhase, SpriteMask mask);
TexturePtr& getSprite(int w, int h, int l, int x, int y, int z, int a);
TexturePtr& getSpriteMask(int w, int h, int l, int x, int y, int z, int a, SpriteMask mask);
TexturePtr& getTexture(int animationPhase);
bool getProperty(Property property) { return m_properties[property]; }