示例#1
0
XBool XSliderSkin::initEx(const char *filename,XResPos resPos)
{
	if(m_isInited ||
		filename == NULL) return XFalse;
	//先打开配置文件
	if(resPos == RES_SYS_DEF) resPos = getDefResPos();
	switch(resPos)
	{
	case RES_LOCAL_PACK:
		if(!loadFromPacker(filename,resPos)) return false;
		break;
	case RES_LOCAL_FOLDER:
		if(!loadFromFolder(filename,resPos)) return false;
		break;
	case RES_WEB:
		if(!loadFromWeb(filename,resPos)) return false;
		break;
	case RES_AUTO:
		if(!loadFromPacker(filename,resPos) && !loadFromFolder(filename,resPos) &&
			!loadFromWeb(filename,resPos)) return false;
		break;
	}
	m_isInited = XTrue;
	return XTrue;
}
QByteArray ResourceFileManager::loadFrom(const QString& resourceFileName, const QString& fileName)
{
    QString resourcePath = _resourceFolderPath + "/" + resourceFileName;
    QFileInfo path(resourcePath);
    qDebug() << "Resources: " + path.filePath();

    if (path.isFile()) {
        qDebug() << "Loading file \"" + fileName + "\" form resource file \"" + resourceFileName + "\"";
        return loadFromResourceFile(path.filePath(), fileName);
    }
    else if (path.isDir()) {
        qDebug() << "Loading file \"" + fileName + "\" from resource folder \"" + resourceFileName +"\"";
        return loadFromFolder(path.filePath(), fileName);
    }
    else {
        return nullptr;
    }
}