Fixed skins path

This commit is contained in:
Henrique Santiago 2012-08-23 04:17:19 -03:00
parent 621b1402c5
commit a306027cec
2 changed files with 21 additions and 7 deletions

View File

@ -16,8 +16,7 @@ local function onSkinComboBoxOptionChange(self, optionText, optionData)
end end
local function getSkinPath(name) local function getSkinPath(name)
local current = getfsrcpath() return getfsrcpath() .. '/skins/' .. string.lower(name)
return g_resources.getRealDir(current) .. current .. '/skins/' .. string.lower(name)
end end
-- public functions -- public functions
@ -27,7 +26,7 @@ function Skins.init()
Skins.installSkins('skins') Skins.installSkins('skins')
if installedSkins[defaultSkinName] then if installedSkins[defaultSkinName] then
g_resources.addSearchPath(getSkinPath(defaultSkinName), 0) g_resources.addSearchPath(getSkinPath(defaultSkinName), true)
end end
local userSkinName = g_settings.get('skin', 'false') local userSkinName = g_settings.get('skin', 'false')

View File

@ -100,12 +100,27 @@ bool ResourceManager::setWriteDir(const std::string& writeDir, bool create)
bool ResourceManager::addSearchPath(const std::string& path, bool pushFront) bool ResourceManager::addSearchPath(const std::string& path, bool pushFront)
{ {
if(!PHYSFS_addToSearchPath(path.c_str(), pushFront ? 0 : 1)) std::string savePath = path;
if(!PHYSFS_addToSearchPath(path.c_str(), pushFront ? 0 : 1)) {
bool found = false;
for(std::string searchPath : m_searchPaths) {
std::string newPath = searchPath + path;
if(PHYSFS_addToSearchPath(newPath.c_str(), pushFront ? 0 : 1)) {
savePath = newPath;
found = true;
break;
}
}
if(!found) {
g_logger.error(stdext::format("Could not add '%s' to directory search path. Reason %s", path, PHYSFS_getLastError()));
return false; return false;
}
}
if(pushFront) if(pushFront)
m_searchPaths.push_front(path); m_searchPaths.push_front(savePath);
else else
m_searchPaths.push_back(path); m_searchPaths.push_back(savePath);
m_hasSearchPath = true; m_hasSearchPath = true;
return true; return true;
} }