void IntroChapter::LoadResource() { ResourceGroupManager::getSingletonPtr()->addResourceLocation("Media/Texture", "FileSystem", "IntroChapter"); ResourceGroupManager::getSingletonPtr()->addResourceLocation("Media/Script", "FileSystem", "IntroChapter"); ResourceGroupManager::getSingletonPtr()->addResourceLocation("Media/Mesh", "FileSystem", "IntroChapter"); Loading loding; loding.start( m_pkWindow ); m_pkSceneManager->clearSpecialCaseRenderQueues(); m_pkSceneManager->addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); m_pkSceneManager->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); // Initialise the rest of the resource groups, parse scripts etc Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("IntroChapter"); ResourceGroupManager::getSingleton().loadResourceGroup( "IntroChapter", false, true); m_pkSceneManager->clearSpecialCaseRenderQueues(); m_pkSceneManager->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); loding.finish(); }
int MaxLoading(int w[],int c,int n,int bestx[]){//返回最右载重量 ofstream Outfile("/Users/CristinaSt/Documents/算法设计/test6/test2.txt"); Loading X; X.x = new int[n+1]; X.w = new int[n+1]; X.bestx = new int[n+1]; X.w = w; X.c = c; X.n = n; X.bestx = bestx; X.bestw = 0; X.cw = 0; X.r = 0; for (int i = 1; i <=n ; ++i) { X.r+=w[i]; } //计算最右载重量 X.Backtrack(1); for (int j = 1; j <=n ; ++j) { cout<<X.bestx[j]<<" "; Outfile<<X.bestx[j]; } delete[]X.w; delete[]X.bestx; delete[] X.x; return X.bestw; }
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; }
int main() { // int x[8]; // for (int i=0;i<8;i++) // x[i]=-1; // NQueens(8,x); int weight[] = {22,35,24,15,4}; Loading<int> *ld = new Loading<int>(5,60,40,weight); // ld->Backtrack(1); // ld->Show(); ld->Iteration(); ld->Show(); }
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; }
Scene * Loading::create() { Loading *ret = new Loading(); if (ret && ret->init()) { ret->autorelease(); return ret; } else { CC_SAFE_DELETE(ret); return NULL; } }
int MaxLoading(int w[],int c,int n,int bestx[]){ Loading X; X.x = new int[n + 1]; X.w = w; X.c = c; X.n = n; X.bestx = bestx; X.bestw = 0; X.cw = 0; X.r = 0; for(int i = 1;i <= n;i++){ X.r += w[i]; } X.Backtrack(1); return X.bestw; }
T MaxLoading(T w[], T c, int n) {// Return weight of best loading. Loading<T> X; // initialize X X.w = w; X.c = c; X.n = n; X.bestw = 0; X.cw = 0; // initial r is sum of all weights X.r = 0; for (int i = 1; i <= n; i++) X.r += w[i]; // compute weight of best loading X.maxLoading(1); return X.bestw; }
void CcdChapter::LoadResource() { Ogre::ResourceGroupManager::getSingleton().addResourceLocation("BaseBall", "FileSystem", ResourceGroup); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("TerrainChapter", "FileSystem", ResourceGroup); Loading loding; loding.start( m_pkWindow ); m_pkSceneManager->clearSpecialCaseRenderQueues(); m_pkSceneManager->addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); m_pkSceneManager->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup(ResourceGroup); m_pkSceneManager->clearSpecialCaseRenderQueues(); m_pkSceneManager->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); loding.finish(); }
/********************************************************************* ** 功能: 预加载上阵角色 ** 输入参数: int tag: 副本id ** 返回值: 无 ** 修改记录: *********************************************************************/ bool RolePrestrain::loading(int tag) { auto roles = RoleResInfo::roleInBattle(tag); for (unsigned index = 0;index < roles.size();index ++) /* 剔除重复的 */ { auto temp = roles; auto str = roles[index]; for (unsigned int i = 0;i < temp.size();i++) { auto str2 = temp[i]; if ((i != index) && (str.compare(str2) == 0)) { roles.erase(roles.begin() + index); break; } } } auto sz = roles.size(); unsigned int index = 0; for (index = 0;index < sz;index ++) { auto name = roles[index]; prestrainRoleArmatureRes(name, RoleResInfo::getRoleResNum(name)); } auto scene = Loading::scene(); Loading* pGameLoading = static_cast<Loading*>(scene->getChildByTag(2)); for (index = 0;index < _vecPath.size();index ++) { pGameLoading->addTextureCacheFromFileByName(_vecPath[index].c_str()); } pGameLoading->addTextureCacheFromFileByName("res/Sprite"); CCDirector::getInstance()->replaceScene(scene); pGameLoading->setChangeScene(Counterpart::scene); _vecPath.clear(); return true; }
Type MaxLoading(Type w[], Type c, int n, int bestx[]) //返回最优载重量 { Loading<Type> X; // 初始化 X X.x = new int[n+1]; X.w = w; X.c = c; X.n = n; X.bestx = bestx; X.bestw = 0; X.cw = 0; // 初始化 r X.r = 0; for(int i=1; i<=n; i++) { X.r += w[i]; } X.Backtrack(1); delete []X.x; return X.bestw; }
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(); } } }