void MusicBrowser::setupBrowser() { QTreeWidgetItem *item; Loading *loading = new Loading; loading->show(); item = new QTreeWidgetItem; item->setText(0, "(OFF)"); item->setText(1, "null"); item->setText(2, ""); item->setIcon(0, QIcon(":/icons/music.png")); item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable); twMusicFiles->addTopLevelItem(item); twMusicFiles->setCurrentItem(item); item->setSelected(true); item = new QTreeWidgetItem; item->setText(0, "Global Data"); item->setText(1, "dir"); item->setText(2, ProjectData::datadir + "/music"); item->setIcon(0, QIcon(":/icons/folder.png")); item->setFlags(Qt::ItemIsEnabled); twMusicFiles->addTopLevelItem(item); QCoreApplication::processEvents(); setupDirectoryTree(item); QCoreApplication::processEvents(); item = new QTreeWidgetItem; item->setText(0, "Project Data"); item->setText(1, "dir"); item->setText(2, ProjectData::projectLocation + "/music"); item->setIcon(0, QIcon(":/icons/folder.png")); item->setFlags(Qt::ItemIsEnabled); twMusicFiles->addTopLevelItem(item); QCoreApplication::processEvents(); setupDirectoryTree(item); QCoreApplication::processEvents(); if (AudioManager::isMusicPlaying()) { unsigned int length, position, minutes, seconds, deciSeconds; musicPlaySpeed = AudioManager::getMusicPlaySpeed(); length = (unsigned int)(AudioManager::getMusicLength() / musicPlaySpeed); minutes = length / 60000; seconds = (length / 1000) % 60; deciSeconds = (length / 100) % 10; lblTotalLength->setText(QString("%1:%2.%3").arg(minutes).arg(seconds, 2, 10, QChar('0')).arg(deciSeconds)); position = (unsigned int)(AudioManager::getMusicPosition() / musicPlaySpeed); minutes = ((unsigned int)(position / musicPlaySpeed)) / 60000; seconds = (((unsigned int)(position / musicPlaySpeed)) / 1000) % 60; deciSeconds = (((unsigned int)(position / musicPlaySpeed)) / 100) % 10; lblCurrentPosition->setText(QString("%1:%2.%3").arg(minutes).arg(seconds, 2, 10, QChar('0')).arg(deciSeconds)); bStop->setEnabled(true); } else bStop->setEnabled(false); loading->doneLoading(); delete loading; }
void ImageBrowser::setupBrowser(QString startSubFolder, unsigned short blockFilters, QList<QSize> sizeRestrictions) { QTreeWidgetItem *item; Loading *loading = new Loading; loading->show(); blockedFilters = blockFilters; if ((blockedFilters & BlockBMP) == 0) cboxFilter->addItem("BMP"); if ((blockedFilters & BlockGIF) == 0) cboxFilter->addItem("GIF"); if ((blockedFilters & BlockJPEG) == 0) cboxFilter->addItem("JPEG"); if ((blockedFilters & BlockPBM) == 0) cboxFilter->addItem("PBM"); if ((blockedFilters & BlockPGM) == 0) cboxFilter->addItem("PGM"); if ((blockedFilters & BlockPNG) == 0) cboxFilter->addItem("PNG"); if ((blockedFilters & BlockPNM) == 0) cboxFilter->addItem("PNM"); if ((blockedFilters & BlockPPM) == 0) cboxFilter->addItem("PPM"); if ((blockedFilters & BlockXPM) == 0) cboxFilter->addItem("XPM"); if ((blockedFilters & BlockTIFF) == 0) cboxFilter->addItem("TIFF"); item = twFiles->topLevelItem(0); item->setFlags(Qt::ItemIsEnabled); item->setText(1, "dir"); if (item->text(0) == "Global Data") item->setText(2, ProjectData::datadir + "/images" + startSubFolder); else item->setText(2, ProjectData::projectLocation + "/images" + startSubFolder); item->setIcon(0, QIcon(":/icons/folder.png")); QCoreApplication::processEvents(); setupDirectoryTree(item, sizeRestrictions); QCoreApplication::processEvents(); item = twFiles->topLevelItem(1); item->setFlags(Qt::ItemIsEnabled); item->setText(1, "dir"); if (item->text(0) == "Global Data") item->setText(2, ProjectData::datadir + "/images" + startSubFolder); else item->setText(2, ProjectData::projectLocation + "/images" + startSubFolder); item->setIcon(0, QIcon(":/icons/folder.png")); QCoreApplication::processEvents(); setupDirectoryTree(item, sizeRestrictions); loading->doneLoading(); delete loading; }
void ResourceManager::on_bExport_clicked() { QString fileLocation = QFileDialog::getSaveFileName(0, "Save Location", QDir::homePath(), "Open RPG Maker Resources (*.orpgmresource)"); if (!fileLocation.isEmpty()) { Loading *loading = new Loading("Importing Resources", this); XMLNode ResourceNode = XMLNode::createXMLTopNode("openrpgmaker-resource"); XMLNode FilesNode = ResourceNode.addChild("files"); XMLNode FileNode; QStringList resourceFiles; QString xmlData; loading->show(); if (!fileLocation.endsWith(".orpgmresource")) fileLocation += ".orpgmresource"; for (int i = 0; i < attributeItems.size(); ++i) { QCoreApplication::processEvents(); if (attributeItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Attribute> *dataRef = new ProjectData::DataReference<Attribute>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getAttributeNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < battleAnimationItems.size(); ++i) { QCoreApplication::processEvents(); if (battleAnimationItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<BattleAnimation> *dataRef = new ProjectData::DataReference<BattleAnimation>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getAnimationNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < characterItems.size(); ++i) { QCoreApplication::processEvents(); if (characterItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Character> *dataRef = new ProjectData::DataReference<Character>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getCharacterNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < characterSpriteItems.size(); ++i) { QCoreApplication::processEvents(); if (characterSpriteItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<CharacterSprite> *dataRef = new ProjectData::DataReference<CharacterSprite>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getCharacterSpriteNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < classItems.size(); ++i) { QCoreApplication::processEvents(); if (classItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Class> *dataRef = new ProjectData::DataReference<Class>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getClassNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < commonEventItems.size(); ++i) { QCoreApplication::processEvents(); if (commonEventItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<CommonEvent> *dataRef = new ProjectData::DataReference<CommonEvent>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getCommonEventNode()); //resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < conditionItems.size(); ++i) { QCoreApplication::processEvents(); if (conditionItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Condition> *dataRef = new ProjectData::DataReference<Condition>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getConditionNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < fontItems.size(); ++i) { QCoreApplication::processEvents(); if (fontItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Font> *dataRef = new ProjectData::DataReference<Font>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getFontNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < globalAnimationItems.size(); ++i) { QCoreApplication::processEvents(); if (globalAnimationItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<GlobalAnimation> *dataRef = new ProjectData::DataReference<GlobalAnimation>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getAnimationNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < itemItems.size(); ++i) { QCoreApplication::processEvents(); if (itemItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Item> *dataRef = new ProjectData::DataReference<Item>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getItemNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < mainMenuItems.size(); ++i) { QCoreApplication::processEvents(); if (mainMenuItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<MainMenuLayout> *dataRef = new ProjectData::DataReference<MainMenuLayout>(mainMenuIDs[i], __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getMenuNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < monsterAnimationItems.size(); ++i) { QCoreApplication::processEvents(); if (monsterAnimationItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<MonsterAnimation> *dataRef = new ProjectData::DataReference<MonsterAnimation>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getMonsterAnimationNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < monsterItems.size(); ++i) { QCoreApplication::processEvents(); if (monsterItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Monster> *dataRef = new ProjectData::DataReference<Monster>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getMonsterNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < monsterGroupItems.size(); ++i) { QCoreApplication::processEvents(); if (monsterGroupItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<MonsterGroup> *dataRef = new ProjectData::DataReference<MonsterGroup>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getMonsterGroupNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < popupMenuItems.size(); ++i) { QCoreApplication::processEvents(); if (popupMenuItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<PopupMenuLayout> *dataRef = new ProjectData::DataReference<PopupMenuLayout>(popupMenuIDs[i], __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getMenuNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < skillItems.size(); ++i) { QCoreApplication::processEvents(); if (skillItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Skill> *dataRef = new ProjectData::DataReference<Skill>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getSkillNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < terrainItems.size(); ++i) { QCoreApplication::processEvents(); if (terrainItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Terrain> *dataRef = new ProjectData::DataReference<Terrain>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getTerrainNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < tilesetItems.size(); ++i) { QCoreApplication::processEvents(); if (tilesetItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Tileset> *dataRef = new ProjectData::DataReference<Tileset>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getTilesetNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < vehicleItems.size(); ++i) { QCoreApplication::processEvents(); if (vehicleItems[i]->checkState(0) == Qt::Checked) { ProjectData::DataReference<Vehicle> *dataRef = new ProjectData::DataReference<Vehicle>(i, __FILE__, __LINE__); ResourceNode.addChild((*dataRef)->getVehicleNode()); resourceFiles += (*dataRef)->getResources(); delete dataRef; } } for (int i = 0; i < fileItems.size(); ++i) { QCoreApplication::processEvents(); if (fileItems[i]->checkState(0) == Qt::Checked) resourceFiles += fileLocations[i]; } QCoreApplication::processEvents(); resourceFiles.removeDuplicates(); resourceFiles.removeAll(QString()); resourceFiles.removeAll(QString("")); for (int i = 0; i < resourceFiles.size(); ++i) { QCoreApplication::processEvents(); if (!resourceFiles[i].isEmpty()) { FileNode = FilesNode.addChild("file"); FileNode.addAttribute("location", ProjectData::getRelativeResourcePath(resourceFiles[i], true).toUtf8().data()); XMLTools::embedResource(FileNode, resourceFiles[i]); } } QCoreApplication::processEvents(); xmlData = ResourceNode.createXMLString(1); xmlData.replace("global::", "local::"); writeXMLData(xmlData, fileLocation); loading->doneLoading(); QCoreApplication::processEvents(); } }
void ResourceManager::on_bImportORPGM_clicked() { QString fileLocation = QFileDialog::getOpenFileName(0, "File Location", QDir::homePath(), "Open RPG Maker Resources (*.orpgmresource)"); if (!fileLocation.isEmpty()) { XMLNode ResourceNode, TempNode, FilesNode, FileNode; XMLResults results; QString xmlData = getXMLData(fileLocation); QString resourceType; ResourceNode = XMLNode::parseString(xmlData.toUtf8().data(), "openrpgmaker-resource", &results); if (ResourceNode.isEmpty() == TRUE) QMessageBox::critical(0, "XML Error", QString("Error parsing resource file \"%1\"\nXML Error Message: %2").arg(fileLocation).arg(XMLNode::getError(results.error))); else { Loading *loading = new Loading("Importing Resources", this); loading->show(); FilesNode = ResourceNode.getChildNode("files"); for (int i = 0; i < FilesNode.nChildNode("file"); ++i) { QCoreApplication::processEvents(); FileNode = FilesNode.getChildNode("file", i); XMLTools::extractResource(FileNode, ProjectData::getAbsoluteResourcePath(FileNode.getAttribute("location"))); } for (int i = 1; i < ResourceNode.nChildNode(); ++i) { QCoreApplication::processEvents(); TempNode = ResourceNode.getChildNode(i); resourceType = TempNode.getName(); if (resourceType == "attribute") { Attribute *data = new Attribute(TempNode); ProjectData::addAttribute(data); delete data; } else if (resourceType == "battleanimation") { BattleAnimation *data = new BattleAnimation(TempNode); ProjectData::addBattleAnimation(data); delete data; } else if (resourceType == "character") { Character *data = new Character(TempNode); ProjectData::addCharacter(data); delete data; } else if (resourceType == "charactersprite") { CharacterSprite *data = new CharacterSprite(TempNode); ProjectData::addCharacterSprite(data); delete data; } else if (resourceType == "class") { Class *data = new Class(TempNode); ProjectData::addClass(data); delete data; } else if (resourceType == "commonevent") { CommonEvent *data = new CommonEvent(TempNode); ProjectData::addCommonEvent(data); delete data; } else if (resourceType == "condition") { Condition *data = new Condition(TempNode); ProjectData::addCondition(data); delete data; } else if (resourceType == "font") { Font *data = new Font(TempNode); ProjectData::addFont(data); delete data; } else if (resourceType == "globalanimation") { GlobalAnimation *data = new GlobalAnimation(TempNode); ProjectData::addGlobalAnimation(data); delete data; } else if (resourceType == "item") { Item *data = new Item(TempNode); ProjectData::addItem(data); delete data; } else if (resourceType == "mainmenulayout") { MainMenuLayout *data = new MainMenuLayout(TempNode); ProjectData::addMainMenuLayout(data); delete data; } else if (resourceType == "monsteranimation") { MonsterAnimation *data = new MonsterAnimation(TempNode); ProjectData::addMonsterAnimation(data); delete data; } else if (resourceType == "monster") { Monster *data = new Monster(TempNode); ProjectData::addMonster(data); delete data; } else if (resourceType == "monstergroup") { MonsterGroup *data = new MonsterGroup(TempNode); ProjectData::addMonsterGroup(data); delete data; } else if (resourceType == "popupmenulayout") { PopupMenuLayout *data = new PopupMenuLayout(TempNode); ProjectData::addPopupMenuLayout(data); delete data; } else if (resourceType == "skill") { Skill *data = new Skill(TempNode); ProjectData::addSkill(data); delete data; } else if (resourceType == "terrain") { Terrain *data = new Terrain(TempNode); ProjectData::addTerrain(data); delete data; } else if (resourceType == "tileset") { Tileset *data = new Tileset(TempNode); ProjectData::addTileset(data); delete data; } else if (resourceType == "vehicle") { Vehicle *data = new Vehicle(TempNode); ProjectData::addVehicle(data); delete data; } } QCoreApplication::processEvents(); buildResourceTree(); loading->doneLoading(); } } }