Exemplo n.º 1
0
void MagicTowerLoader::loadResource(const QString& resourcePath)
{
    QDir resourceDir(resourcePath);
    QFileInfoList resourceList = resourceDir.entryInfoList();
    for(int i=0;i<resourceList.size();i++)
    {
        if(resourceList[i].isFile() && resourceList[i].suffix()=="png")
        {
			if(!SLGCResourceManager::getInstance()->addPixmap(resourceList[i].baseName(),resourceList[i].filePath()))
            {
                QMessageBox::critical(NULL,QString("警告"),
                                         QString("警告:存在未加载的资源文件。\n"
                                                 "试图加载%1时失败。\n"
                                                 "应用程序将继续,但如果这些资源在稍后被引用,可能造成其它错误信息。").arg(resourceList[i].filePath()));
            }
        }
		else if(resourceList[i].isFile() && resourceList[i].suffix()=="wav")
		{
			if(!SLGCResourceManager::getInstance()->addAudio(resourceList[i].baseName(),resourceList[i].filePath()))
			{
				QMessageBox::critical(NULL,QString("警告"),
										 QString("Audio Load Fail %1").arg(resourceList[i].filePath()));
			}
		}
    }
}
Exemplo n.º 2
0
bool ResourceDirWrapper::wrap()
{
    clear();
    if (this->topEntryID == TOP_ENTRY_ROOT && this->album != NULL) {
        this->album->clear();
    }
    IMAGE_RESOURCE_DIRECTORY* dir = resourceDir();
    if (dir == NULL) return false;
    size_t namesNum = dir->NumberOfNamedEntries;
    size_t idsNum = dir->NumberOfIdEntries;

    size_t totalEntries = namesNum + idsNum;
    for (size_t i = 0; i < totalEntries && i < MAX_ENTRIES; i++ ) {

        long topDirId = (this->topEntryID != TOP_ENTRY_ROOT) ? this->topEntryID : long(i) ;

        //ResourceEntryWrapper(PEFile *pe, ResourceDirWrapper *parentDir, size_t entryNumber, long topEntryId, ResourcesAlbum *resAlbum)
        ResourceEntryWrapper* entry = new ResourceEntryWrapper(this->m_PE, this, i, topDirId, this->album);

        if (entry->getPtr() == NULL) {
            delete entry;
            break;
        }
        if (this->topEntryID == TOP_ENTRY_ROOT && this->album != NULL) {
            pe::resource_type typeId = static_cast<pe::resource_type>(entry->getID());
            this->album->mapIdToLeafType(i, typeId);
        }
        //this->parsedSize += val;
        this->entries.push_back(entry);
    }
    //printf("Entries: %d\n", getEntriesCount());
    return true;
}
Exemplo n.º 3
0
void Configurator::exportThemes() const
{
    // copy default themes from resources to user hard disk
    QDir resourceDir(THEMES_FOLDER_IN_RESOURCES);
    QDir themesDir = getThemesDir();
    qDebug() << "Exporting themes from " << resourceDir.absolutePath() << " to " << themesDir.absolutePath();
    QStringList themesInResources = resourceDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
    for (const QString &themeDir : themesInResources) {
        QDir themeFolderInResources(resourceDir.absoluteFilePath(themeDir));
        themesDir.mkdir(themeDir);
        QDir destinationDir(themesDir.absoluteFilePath(themeDir));
        qDebug() << "Exporting theme " << themeDir << " from " << themeFolderInResources.absolutePath() << " to " << destinationDir.absolutePath();
        QString fullPath = themeFolderInResources.absolutePath() + "/css/themes/" + themeDir;
        QDir pathInResources(fullPath);
        QStringList themeFiles = pathInResources.entryList(QDir::Files); // css files
        for (const QString &themeCSSFile : themeFiles) {
            QString sourcePath = pathInResources.absoluteFilePath(themeCSSFile);
            QString destinationPath = destinationDir.absoluteFilePath(themeCSSFile);
            if (QFile::copy(sourcePath, destinationPath))
                QFile(destinationPath).setPermissions(QFile::ReadOwner | QFile::WriteOwner);
            else
                qDebug(jtConfigurator) << "Can't copy " << sourcePath << " to " << destinationPath;

        }
    }
}
Exemplo n.º 4
0
void* ResourceDirWrapper::getFieldPtr(size_t fId, size_t subField)
{
    IMAGE_RESOURCE_DIRECTORY* d = resourceDir();
    if (d == NULL) return NULL;

    switch (fId) {
        case CHARACTERISTIC: return &d->Characteristics;
        case TIMESTAMP: return &d->TimeDateStamp;
        case MAJOR_VER: return &d->MajorVersion;
        case MINOR_VER: return &d->MinorVersion;
        case NAMED_ENTRIES_NUM : return &d->NumberOfNamedEntries;
        case ID_ENTRIES_NUM : return &d->NumberOfIdEntries;
        case CHILDREN : return (&d->NumberOfIdEntries) + 1;
    }
    return this->getPtr();
}
const File LinuxBundleAppSelf::resource(String rsc) {
    return resourceDir() / rsc;
}
Exemplo n.º 6
0
QString Paths::webClientPath()
{
  QString webName = QString("web-client-%1").arg(Version::GetWebVersion());
  return resourceDir(webName + "/index.html");
}