/*! to retrieve the both lists with groupFrames option = on and off. */ void TSystem::readDirectory(TFilePathSet &groupFpSet, TFilePathSet &allFpSet, const TFilePath &path) { if (!TFileStatus(path).isDirectory()) throw TSystemException(path, " is not a directory"); std::set<TFilePath, CaselessFilepathLess> fileSet_group; std::set<TFilePath, CaselessFilepathLess> fileSet_all; QStringList fil = QDir(toQString(path)) .entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::Readable); if (fil.size() == 0) return; for (int i = 0; i < fil.size(); i++) { QString fi = fil.at(i); TFilePath son = path + TFilePath(fi.toStdWString()); // store all file paths fileSet_all.insert(son); // in case of the sequencial files if (son.getDots() == "..") son = son.withFrame(); // store the group. insersion avoids duplication of the item fileSet_group.insert(son); } groupFpSet.insert(groupFpSet.end(), fileSet_group.begin(), fileSet_group.end()); allFpSet.insert(allFpSet.end(), fileSet_all.begin(), fileSet_all.end()); }
bool TSystem::doesExistFileOrLevel(const TFilePath &fp) { if (TFileStatus(fp).doesExist()) return true; if (fp.isLevelName()) { const TFilePath &parentDir = fp.getParentDir(); if (!TFileStatus(parentDir).doesExist()) return false; TFilePathSet files; try { files = TSystem::readDirectory(parentDir, false, true, true); } catch (...) { } TFilePathSet::iterator it, end = files.end(); for (it = files.begin(); it != end; ++it) { if (it->getLevelNameW() == fp.getLevelNameW()) return true; } } else if (fp.getType() == "psd") { QString name(QString::fromStdWString(fp.getWideName())); name.append(QString::fromStdString(fp.getDottedType())); int sepPos = name.indexOf("#"); int dotPos = name.indexOf(".", sepPos); int removeChars = dotPos - sepPos; int doubleUnderscorePos = name.indexOf("__", sepPos); if (doubleUnderscorePos > 0) removeChars = doubleUnderscorePos - sepPos; name.remove(sepPos, removeChars); TFilePath psdpath(fp.getParentDir() + TFilePath(name.toStdWString())); if (TFileStatus(psdpath).doesExist()) return true; } return false; }
void TSystem::readDirectory(TFilePathSet &dst, const TFilePathSet &pathSet, bool groupFrames, bool onlyFiles, bool getHiddenFiles) { for (TFilePathSet::const_iterator it = pathSet.begin(); it != pathSet.end(); it++) readDirectory(dst, *it, groupFrames, onlyFiles); }
void InsertFxPopup::loadMacro() { TFilePath fp = m_presetFolder + TFilePath("macroFx"); try { if (TFileStatus(fp).isDirectory()) { TFilePathSet macros = TSystem::readDirectory(fp); if (macros.empty()) return; QTreeWidgetItem *macroFolder = new QTreeWidgetItem((QTreeWidget *)0, QStringList(tr("Macro"))); macroFolder->setData(0, Qt::UserRole, QVariant(toQString(fp))); macroFolder->setIcon(0, m_folderIcon); m_fxTree->addTopLevelItem(macroFolder); for (TFilePathSet::iterator it = macros.begin(); it != macros.end(); ++it) { TFilePath macroPath = *it; QString name(macroPath.getName().c_str()); QTreeWidgetItem *macroItem = new QTreeWidgetItem((QTreeWidget *)0, QStringList(name)); macroItem->setData(0, Qt::UserRole, QVariant(toQString(macroPath))); macroItem->setIcon(0, m_fxIcon); macroFolder->addChild(macroItem); } } } catch (...) { } }
void ProjectPopup::updateChooseProjectCombo() { m_projectPaths.clear(); m_chooseProjectCombo->clear(); TFilePath sandboxFp = TProjectManager::instance()->getSandboxProjectFolder() + "sandbox_otprj.xml"; m_projectPaths.push_back(sandboxFp); m_chooseProjectCombo->addItem("sandbox"); std::vector<TFilePath> prjRoots; TProjectManager::instance()->getProjectRoots(prjRoots); for (int i = 0; i < prjRoots.size(); i++) { TFilePathSet fps; TSystem::readDirectory_Dir_ReadExe(fps, prjRoots[i]); TFilePathSet::iterator it; for (it = fps.begin(); it != fps.end(); ++it) { TFilePath fp(*it); if (TProjectManager::instance()->isProject(fp)) { m_projectPaths.push_back( TProjectManager::instance()->projectFolderToProjectPath(fp)); m_chooseProjectCombo->addItem(QString::fromStdString(fp.getName())); } } } for (int i = 0; i < m_projectPaths.size(); i++) { if (TProjectManager::instance()->getCurrentProjectPath() == m_projectPaths[i]) { m_chooseProjectCombo->setCurrentIndex(i); break; } } }
bool InsertFxPopup::loadPreset(QTreeWidgetItem *item) { QString str = item->data(0, Qt::UserRole).toString(); TFilePath presetsFilepath(m_presetFolder + str.toStdWString()); int i; for (i = item->childCount() - 1; i >= 0; i--) item->removeChild(item->child(i)); if (TFileStatus(presetsFilepath).isDirectory()) { TFilePathSet presets = TSystem::readDirectory(presetsFilepath); if (!presets.empty()) { for (TFilePathSet::iterator it2 = presets.begin(); it2 != presets.end(); ++it2) { TFilePath presetPath = *it2; QString name(presetPath.getName().c_str()); QTreeWidgetItem *presetItem = new QTreeWidgetItem((QTreeWidget *)0, QStringList(name)); presetItem->setData(0, Qt::UserRole, QVariant(toQString(presetPath))); item->addChild(presetItem); presetItem->setIcon(0, m_fxIcon); } } else return false; } else return false; return true; }
void TSystem::renameFileOrLevel_throw(const TFilePath &dst, const TFilePath &src, bool renamePalette) { if (renamePalette && ((src.getType() == "tlv") || (src.getType() == "tzp") || (src.getType() == "tzu"))) { // Special case: since renames cannot be 'grouped' in the UI, palettes are // automatically // renamed here if required const char *type = (src.getType() == "tlv") ? "tpl" : "plt"; TFilePath srcpltname(src.withNoFrame().withType(type)); TFilePath dstpltname(dst.withNoFrame().withType(type)); if (TSystem::doesExistFileOrLevel(src) && TSystem::doesExistFileOrLevel(srcpltname)) TSystem::renameFile(dstpltname, srcpltname, false); } if (src.isLevelName()) { TFilePathSet files; files = TSystem::readDirectory(src.getParentDir(), false); for (TFilePathSet::iterator it = files.begin(); it != files.end(); it++) { if (it->getLevelName() == src.getLevelName()) { TFilePath src1 = *it; TFilePath dst1 = dst.withFrame(it->getFrame()); TSystem::renameFile(dst1, src1); } } } else TSystem::renameFile(dst, src); }
void TSystem::hideFileOrLevel_throw(const TFilePath &fp) { if (fp.isLevelName()) { TFilePathSet files; files = TSystem::readDirectory(fp.getParentDir(), false); TFilePathSet::iterator it, end = files.end(); for (it = files.begin(); it != end; ++it) { if (it->getLevelNameW() == fp.getLevelNameW()) TSystem::hideFile(*it); } } else TSystem::hideFile(fp); }
TFilePathSet TSystem::packLevelNames(const TFilePathSet &fps) { std::set<TFilePath> tmpSet; TFilePathSet::const_iterator cit; for (cit = fps.begin(); cit != fps.end(); ++cit) tmpSet.insert(cit->getParentDir() + cit->getLevelName()); TFilePathSet fps2; for (std::set<TFilePath>::const_iterator c_sit = tmpSet.begin(); c_sit != tmpSet.end(); ++c_sit) { fps2.push_back(*c_sit); } return fps2; }
TLevelP TLevelReader::loadInfo() { TFilePath parentDir = m_path.getParentDir(); TFilePath levelName(m_path.getLevelName()); // cout << "Parent dir = '" << parentDir << "'" << endl; // cout << "Level name = '" << levelName << "'" << endl; TFilePathSet files; try { files = TSystem::readDirectory(parentDir, false, true, true); } catch (...) { throw TImageException(m_path, "unable to read directory content"); } TLevelP level; vector<TFilePath> data; for (TFilePathSet::iterator it = files.begin(); it != files.end(); it++) { TFilePath ln(it->getLevelName()); // cout << "try " << *it << " " << it->getLevelName() << endl; if (levelName == TFilePath(it->getLevelName())) { try { level->setFrame(it->getFrame(), TImageP()); data.push_back(*it); } catch (string msg) { throw msg; } } } if (!data.empty()) { std::vector<TFilePath>::iterator it = std::min_element(data.begin(), data.end(), myLess); TFilePath fr = (*it).withoutParentDir().withName("").withType(""); wstring ws = fr.getWideString(); if (ws.length() == 5) { if (ws.rfind(L'_') == (int)wstring::npos) m_frameFormat = TFrameId::FOUR_ZEROS; else m_frameFormat = TFrameId::UNDERSCORE_FOUR_ZEROS; } else { if (ws.rfind(L'_') == (int)wstring::npos) m_frameFormat = TFrameId::NO_PAD; else m_frameFormat = TFrameId::UNDERSCORE_NO_PAD; } } else m_frameFormat = TFrameId::FOUR_ZEROS; return level; }
void TSystem::copyFileOrLevel_throw(const TFilePath &dst, const TFilePath &src) { if (src.isLevelName()) { TFilePathSet files; files = TSystem::readDirectory(src.getParentDir(), false); TFilePathSet::iterator it, end = files.end(); for (it = files.begin(); it != end; ++it) { if (it->getLevelNameW() == src.getLevelNameW()) { TFilePath src1 = *it; TFilePath dst1 = dst.withFrame(it->getFrame()); TSystem::copyFile(dst1, src1); } } } else TSystem::copyFile(dst, src); }
void TPaperFormatManager::readPaperFormats() { TFilePathSet fps; TFilePath papDir = TEnv::getConfigDir() + "pap"; if (!TFileStatus(papDir).isDirectory()) { // TMessage::error("E_CanNotReadDirectory_%1", papDir); return; } try { fps = TSystem::readDirectory(papDir); } catch (TException &) { // TMessage::error("E_CanNotReadDirectory_%1", papDir); return; } TFilePathSet::const_iterator it = fps.begin(); for (; it != fps.end(); ++it) readPaperFormat(*it); }
void AddFxContextMenu::loadMacro() { TFilePath macroDir = m_presetPath + TFilePath("macroFx"); try { if (TFileStatus(macroDir).isDirectory()) { TFilePathSet macros = TSystem::readDirectory(macroDir); if (macros.empty()) return; QMenu *insertMacroMenu = new QMenu("Macro", m_insertMenu); QMenu *addMacroMenu = new QMenu("Macro", m_addMenu); QMenu *replaceMacroMenu = new QMenu("Macro", m_replaceMenu); m_insertMenu->addMenu(insertMacroMenu); m_addMenu->addMenu(addMacroMenu); m_replaceMenu->addMenu(replaceMacroMenu); for (TFilePathSet::iterator it = macros.begin(); it != macros.end(); ++it) { TFilePath macroPath = *it; QString name = QString::fromStdWString(macroPath.getWideName()); QAction *insertAction = new QAction(name, insertMacroMenu); QAction *addAction = new QAction(name, addMacroMenu); QAction *replaceAction = new QAction(name, replaceMacroMenu); insertAction->setData( QVariant(QString::fromStdWString(macroPath.getWideString()))); addAction->setData( QVariant(QString::fromStdWString(macroPath.getWideString()))); replaceAction->setData( QVariant(QString::fromStdWString(macroPath.getWideString()))); insertMacroMenu->addAction(insertAction); addMacroMenu->addAction(addAction); replaceMacroMenu->addAction(replaceAction); m_insertActionGroup->addAction(insertAction); m_addActionGroup->addAction(addAction); m_replaceActionGroup->addAction(replaceAction); } } } catch (...) { } }
TFilePath TMyPaintBrushStyle::decodePath(const TFilePath &path) const { if (path.isAbsolute()) return path; if (m_currentScene) { TFilePath p = m_currentScene->decodeFilePath(path); TFileStatus fs(p); if (fs.doesExist() && !fs.isDirectory()) return p; } TFilePathSet paths = getBrushesDirs(); for(TFilePathSet::iterator i = paths.begin(); i != paths.end(); ++i) { TFilePath p = *i + path; TFileStatus fs(p); if (fs.doesExist() && !fs.isDirectory()) return p; } return path; }
/*! return the file list which is readable and executable */ void TSystem::readDirectory_Dir_ReadExe(TFilePathSet &dst, const TFilePath &path) { if (!TFileStatus(path).isDirectory()) throw TSystemException(path, " is not a directory"); std::set<TFilePath, CaselessFilepathLess> fileSet; QStringList fil = QDir(toQString(path)) .entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable); int i; for (i = 0; i < fil.size(); i++) { QString fi = fil.at(i); TFilePath son = path + TFilePath(fi.toStdWString()); fileSet.insert(son); } dst.insert(dst.end(), fileSet.begin(), fileSet.end()); }
void TSystem::readDirectory(TFilePathSet &dst, const QDir &dir, bool groupFrames) { if (!(dir.exists() && QFileInfo(dir.path()).isDir())) throw TSystemException(TFilePath(dir.path().toStdWString()), " is not a directory"); QStringList entries(dir.entryList(dir.filter() | QDir::NoDotAndDotDot)); TFilePath dirPath(dir.path().toStdWString()); std::set<TFilePath, CaselessFilepathLess> fpSet; int e, eCount = entries.size(); for (e = 0; e != eCount; ++e) { TFilePath path(dirPath + TFilePath(entries.at(e).toStdWString())); if (groupFrames && path.getDots() == "..") path = path.withFrame(); fpSet.insert(path); } dst.insert(dst.end(), fpSet.begin(), fpSet.end()); }
bool AddFxContextMenu::loadPreset(const string &name, QMenu *insertFxGroup, QMenu *addFxGroup, QMenu *replaceFxGroup) { TFilePath presetsFilepath(m_presetPath + name); if (TFileStatus(presetsFilepath).isDirectory()) { TFilePathSet presets = TSystem::readDirectory(presetsFilepath, false); if (!presets.empty()) { QMenu *inserMenu = new QMenu(QString::fromStdWString(TStringTable::translate(name)), insertFxGroup); insertFxGroup->addMenu(inserMenu); QMenu *addMenu = new QMenu(QString::fromStdWString(TStringTable::translate(name)), addFxGroup); addFxGroup->addMenu(addMenu); QMenu *replaceMenu = new QMenu(QString::fromStdWString(TStringTable::translate(name)), replaceFxGroup); replaceFxGroup->addMenu(replaceMenu); //This is a workaround to set the bold style to the first element of this menu //Setting a font directly to a QAction is not enought; style sheet definitions //preval over QAction font settings. inserMenu->setObjectName("fxMenu"); addMenu->setObjectName("fxMenu"); replaceMenu->setObjectName("fxMenu"); QAction *insertAction = new QAction(QString::fromStdWString(TStringTable::translate(name)), inserMenu); QAction *addAction = new QAction(QString::fromStdWString(TStringTable::translate(name)), addMenu); QAction *replaceAction = new QAction(QString::fromStdWString(TStringTable::translate(name)), replaceMenu); insertAction->setCheckable(true); addAction->setCheckable(true); replaceAction->setCheckable(true); insertAction->setData(QVariant(QString::fromStdString(name))); addAction->setData(QVariant(QString::fromStdString(name))); replaceAction->setData(QVariant(QString::fromStdString(name))); inserMenu->addAction(insertAction); addMenu->addAction(addAction); replaceMenu->addAction(replaceAction); m_insertActionGroup->addAction(insertAction); m_addActionGroup->addAction(addAction); m_replaceActionGroup->addAction(replaceAction); for (TFilePathSet::iterator it2 = presets.begin(); it2 != presets.end(); ++it2) { TFilePath presetName = *it2; QString qPresetName = QString::fromStdWString(presetName.getWideName()); insertAction = new QAction(qPresetName, inserMenu); addAction = new QAction(qPresetName, addMenu); replaceAction = new QAction(qPresetName, replaceMenu); insertAction->setData(QVariant(QString::fromStdWString(presetName.getWideString()))); addAction->setData(QVariant(QString::fromStdWString(presetName.getWideString()))); replaceAction->setData(QVariant(QString::fromStdWString(presetName.getWideString()))); inserMenu->addAction(insertAction); addMenu->addAction(addAction); replaceMenu->addAction(replaceAction); m_insertActionGroup->addAction(insertAction); m_addActionGroup->addAction(addAction); m_replaceActionGroup->addAction(replaceAction); } return true; } else return false; } else return false; }
/*! In particolare imposta la projectRoot e la stuffDir, controlla se la directory di outputs esiste (e provvede a crearla in caso contrario) verifica inoltre che stuffDir esista. */ void initToonzEnv() { StudioPalette::enable(true); TEnv::setApplication(applicationName, applicationVersion, applicationRevision); TEnv::setRootVarName(rootVarName); TEnv::setSystemVarPrefix(systemVarPrefix); TEnv::setDllRelativeDir(TFilePath(dllRelativePath)); QCoreApplication::setOrganizationName("OpenToonz"); QCoreApplication::setOrganizationDomain(""); QString fullApplicationNameQStr = QString(applicationName) + " " + applicationVersion; QCoreApplication::setApplicationName(fullApplicationNameQStr); /*-- TOONZROOTのPathの確認 --*/ // controllo se la xxxroot e' definita e corrisponde ad un folder esistente TFilePath stuffDir = TEnv::getStuffDir(); if (stuffDir == TFilePath() || !TFileStatus(stuffDir).isDirectory()) { if (stuffDir == TFilePath()) fatalError("Undefined or empty: \"" + toQString(TEnv::getRootVarPath()) + "\""); else fatalError("Folder \"" + toQString(stuffDir) + "\" not found or not readable"); } Tiio::defineStd(); initImageIo(); initSoundIo(); initStdFx(); initColorFx(); // TPluginManager::instance()->loadStandardPlugins(); TFilePath library = ToonzFolder::getLibraryFolder(); TRasterImagePatternStrokeStyle::setRootDir(library); TVectorImagePatternStrokeStyle::setRootDir(library); TVectorBrushStyle::setRootDir(library); CustomStyleManager::setRootPath(library); // sembra indispensabile nella lettura dei .tab 2.2: TPalette::setRootDir(library); TImageStyle::setLibraryDir(library); //TProjectManager::instance()->enableTabMode(true); TProjectManager *projectManager = TProjectManager::instance(); /*-- TOONZPROJECTSのパスセットを取得する。(TOONZPROJECTSはセミコロンで区切って複数設定可能) --*/ TFilePathSet projectsRoots = ToonzFolder::getProjectsFolders(); TFilePathSet::iterator it; for (it = projectsRoots.begin(); it != projectsRoots.end(); ++it) projectManager->addProjectsRoot(*it); /*-- もしまだ無ければ、TOONZROOT/sandboxにsandboxプロジェクトを作る --*/ projectManager->createSandboxIfNeeded(); /* TProjectP project = projectManager->getCurrentProject(); Non dovrebbe servire per Tab: project->setFolder(TProject::Drawings, TFilePath("$scenepath")); project->setFolder(TProject::Extras, TFilePath("$scenepath")); project->setUseScenePath(TProject::Drawings, false); project->setUseScenePath(TProject::Extras, false); */ // Imposto la rootDir per ImageCache /*-- TOONZCACHEROOTの設定 --*/ TFilePath cacheDir = ToonzFolder::getCacheRootFolder(); if (cacheDir.isEmpty()) cacheDir = TEnv::getStuffDir() + "cache"; TImageCache::instance()->setRootDir(cacheDir); }
Preferences::Preferences() : m_units("mm"), m_cameraUnits("inch"), m_scanLevelType("tif"), m_defLevelWidth(0.0), m_defLevelHeight(0.0), m_defLevelDpi(0.0), m_iconSize(160, 120), m_blankColor(TPixel32::White), m_frontOnionColor(TPixel::Black), m_backOnionColor(TPixel::Black), m_transpCheckBg(TPixel::White), m_transpCheckInk(TPixel::Black), m_transpCheckPaint(TPixel(127, 127, 127)), m_autosavePeriod(15), m_chunkSize(10), m_rasterOptimizedMemory(0), m_shrink(1), m_step(1), m_blanksCount(0), m_keyframeType(3), m_animationStep(1), m_textureSize(0), m_xsheetStep(10), m_shmmax(-1), m_shmseg(-1), m_shmall(-1), m_shmmni(-1), m_onionPaperThickness(50), m_currentLanguage(0), m_currentStyleSheet(0), m_undoMemorySize(100), m_dragCellsBehaviour(0), m_lineTestFpsCapture(25), m_defLevelType(0), m_autocreationType(1), m_autoExposeEnabled(true), m_autoCreateEnabled(true), m_subsceneFolderEnabled(true), m_generatedMovieViewEnabled(true), m_xsheetAutopanEnabled(true), m_ignoreAlphaonColumn1Enabled(false), m_rewindAfterPlaybackEnabled(true), m_fitToFlipbookEnabled(false), m_previewAlwaysOpenNewFlipEnabled(false), m_autosaveEnabled(false), m_defaultViewerEnabled(false), m_saveUnpaintedInCleanup(true), m_askForOverrideRender(true), m_automaticSVNFolderRefreshEnabled(true), m_SVNEnabled(false), m_minimizeSaveboxAfterEditing(true), m_levelsBackupEnabled(false), m_sceneNumberingEnabled(false), m_animationSheetEnabled(false), m_inksOnly(false), m_fillOnlySavebox(false), m_show0ThickLines(true), m_regionAntialias(false), m_viewerBGColor(128, 128, 128, 255), m_previewBGColor(64, 64, 64, 255), m_chessboardColor1(180, 180, 180), m_chessboardColor2(230, 230, 230), m_showRasterImagesDarkenBlendedInViewer(false), m_actualPixelViewOnSceneEditingMode(false), m_viewerZoomCenter(0), m_initialLoadTlvCachingBehavior(0), m_removeSceneNumberFromLoadedLevelName(false), m_replaceAfterSaveLevelAs(true), m_showFrameNumberWithLetters(false), m_levelNameOnEachMarker(false), m_columnIconLoadingPolicy((int)LoadAtOnce), m_moveCurrentFrameByClickCellArea(true), m_onionSkinEnabled(false), m_multiLayerStylePickerEnabled(false), m_paletteTypeOnLoadRasterImageAsColorModel(0), m_showKeyframesOnXsheetCellArea(true) { TCamera camera; m_defLevelType = PLI_XSHLEVEL; m_defLevelWidth = camera.getSize().lx; m_defLevelHeight = camera.getSize().ly; m_defLevelDpi = camera.getDpi().x; TFilePath layoutDir = ToonzFolder::getMyModuleDir(); TFilePath savePath = layoutDir + TFilePath("preferences.ini"); m_settings.reset(new QSettings(QString::fromStdWString(savePath.getWideString()), QSettings::IniFormat)); getValue(*m_settings, "autoExposeEnabled", m_autoExposeEnabled); getValue(*m_settings, "autoCreateEnabled", m_autoCreateEnabled); getValue(*m_settings, "subsceneFolderEnabled", m_subsceneFolderEnabled); getValue(*m_settings, "generatedMovieViewEnabled", m_generatedMovieViewEnabled); getValue(*m_settings, "xsheetAutopanEnabled", m_xsheetAutopanEnabled); getValue(*m_settings, "ignoreAlphaonColumn1Enabled", m_ignoreAlphaonColumn1Enabled); getValue(*m_settings, "rewindAfterPlayback", m_rewindAfterPlaybackEnabled); getValue(*m_settings, "previewAlwaysOpenNewFlip", m_previewAlwaysOpenNewFlipEnabled); getValue(*m_settings, "fitToFlipbook", m_fitToFlipbookEnabled); getValue(*m_settings, "automaticSVNFolderRefreshEnabled", m_automaticSVNFolderRefreshEnabled); getValue(*m_settings, "SVNEnabled", m_SVNEnabled); getValue(*m_settings, "minimizeSaveboxAfterEditing", m_minimizeSaveboxAfterEditing); getValue(*m_settings, "levelsBackupEnabled", m_levelsBackupEnabled); getValue(*m_settings, "sceneNumberingEnabled", m_sceneNumberingEnabled); getValue(*m_settings, "animationSheetEnabled", m_animationSheetEnabled); getValue(*m_settings, "autosaveEnabled", m_autosaveEnabled); getValue(*m_settings, "defaultViewerEnabled", m_defaultViewerEnabled); getValue(*m_settings, "rasterOptimizedMemory", m_rasterOptimizedMemory); getValue(*m_settings, "saveUnpaintedInCleanup", m_saveUnpaintedInCleanup); getValue(*m_settings, "autosavePeriod", m_autosavePeriod); getValue(*m_settings, "taskchunksize", m_chunkSize); getValue(*m_settings, "xsheetStep", m_xsheetStep); int r = 0, g = 0, b = 0; getValue(*m_settings, "frontOnionColor.r", r); getValue(*m_settings, "frontOnionColor.g", g); getValue(*m_settings, "frontOnionColor.b", b); m_frontOnionColor = TPixel32(r, g, b); getValue(*m_settings, "onionPaperThickness", m_onionPaperThickness); r = 0, g = 0, b = 0; getValue(*m_settings, "backOnionColor.r", r); getValue(*m_settings, "backOnionColor.g", g); getValue(*m_settings, "backOnionColor.b", b); m_backOnionColor = TPixel32(r, g, b); r = m_transpCheckBg.r, g = m_transpCheckBg.g, b = m_transpCheckBg.b; getValue(*m_settings, "transpCheckInkOnBlack.r", r); getValue(*m_settings, "transpCheckInkOnBlack.g", g); getValue(*m_settings, "transpCheckInkOnBlack.b", b); m_transpCheckBg = TPixel32(r, g, b); r = m_transpCheckInk.r, g = m_transpCheckInk.g, b = m_transpCheckInk.b; getValue(*m_settings, "transpCheckInkOnWhite.r", r); getValue(*m_settings, "transpCheckInkOnWhite.g", g); getValue(*m_settings, "transpCheckInkOnWhite.b", b); m_transpCheckInk = TPixel32(r, g, b); r = m_transpCheckPaint.r, g = m_transpCheckPaint.g, b = m_transpCheckPaint.b; getValue(*m_settings, "transpCheckPaint.r", r); getValue(*m_settings, "transpCheckPaint.g", g); getValue(*m_settings, "transpCheckPaint.b", b); m_transpCheckPaint = TPixel32(r, g, b); getValue(*m_settings, "onionInksOnly", m_inksOnly); getValue(*m_settings, "iconSizeX", m_iconSize.lx); getValue(*m_settings, "iconSizeY", m_iconSize.ly); getValue(*m_settings, s_show0ThickLines, m_show0ThickLines); getValue(*m_settings, s_regionAntialias, m_regionAntialias); getValue(*m_settings, "viewShrink", m_shrink); getValue(*m_settings, "viewStep", m_step); getValue(*m_settings, "blanksCount", m_blanksCount); getValue(*m_settings, "askForOverrideRender", m_askForOverrideRender); r = 255, g = 255, b = 255; getValue(*m_settings, "blankColor.r", r); getValue(*m_settings, "blankColor.g", g); getValue(*m_settings, "blankColor.b", b); getValue(*m_settings, "undoMemorySize", m_undoMemorySize); setUndoMemorySize(m_undoMemorySize); m_blankColor = TPixel32(r, g, b); QString units; units = m_settings->value("linearUnits").toString(); if (units != "") m_units = units; setUnits(m_units.toStdString()); units = m_settings->value("cameraUnits").toString(); if (units != "") m_cameraUnits = units; setCameraUnits(m_cameraUnits.toStdString()); getValue(*m_settings, "keyframeType", m_keyframeType); getValue(*m_settings, "animationStep", m_animationStep); getValue(*m_settings, "textureSize", m_textureSize); QString scanLevelType; scanLevelType = m_settings->value("scanLevelType").toString(); if (scanLevelType != "") m_scanLevelType = scanLevelType; setScanLevelType(m_scanLevelType.toStdString()); getValue(*m_settings, "shmmax", m_shmmax); getValue(*m_settings, "shmseg", m_shmseg); getValue(*m_settings, "shmall", m_shmall); getValue(*m_settings, "shmmni", m_shmmni); // Load level formats getDefaultLevelFormats(m_levelFormats); getValue(*m_settings, m_levelFormats); std::sort(m_levelFormats.begin(), m_levelFormats.end(), // Format sorting must be formatLess); // enforced TFilePath lang_path = TEnv::getConfigDir() + "loc"; TFilePathSet lang_fpset; m_languageMaps[0] = "english"; //m_currentLanguage=0; try { TFileStatus langPathFs(lang_path); if (langPathFs.doesExist() && langPathFs.isDirectory()) { TSystem::readDirectory(lang_fpset, lang_path, true, false); } else { } TFilePathSet::iterator it = lang_fpset.begin(); int i = 1; for (it; it != lang_fpset.end(); it++, i++) { TFilePath newPath = *it; if (newPath == lang_path) continue; if (TFileStatus(newPath).isDirectory()) { QString string = QString::fromStdWString(newPath.getWideName()); m_languageMaps[i] = string; } } } catch (...) { } TFilePath path(TEnv::getConfigDir() + "qss"); TFilePathSet fpset; try { TSystem::readDirectory(fpset, path, true, false); TFilePathSet::iterator it = fpset.begin(); int i = 0; for (it; it != fpset.end(); it++, i++) { TFilePath newPath = *it; if (newPath == path) continue; QString fpName = QString::fromStdWString(newPath.getWideName()); #ifdef MACOSX QString string = fpName + QString("/") + fpName + QString("_mac.qss"); #else QString string = fpName + QString("/") + fpName + QString(".qss"); #endif if (fpName == QString("standard")) m_currentStyleSheet = i; m_styleSheetMaps[i] = "file:///" + path.getQString() + "/" + string; } } catch (...) { } getValue(*m_settings, "CurrentLanguage", m_currentLanguage); getValue(*m_settings, "CurrentStyleSheet", m_currentStyleSheet); getValue(*m_settings, "DragCellsBehaviour", m_dragCellsBehaviour); getValue(*m_settings, "LineTestFpsCapture", m_lineTestFpsCapture); getValue(*m_settings, "FillOnlysavebox", m_fillOnlySavebox); getValue(*m_settings, "AutocreationType", m_autocreationType); getValue(*m_settings, "DefLevelType", m_defLevelType); getValue(*m_settings, "DefLevelWidth", m_defLevelWidth); getValue(*m_settings, "DefLevelHeight", m_defLevelHeight); getValue(*m_settings, "DefLevelDpi", m_defLevelDpi); getValue(*m_settings, "viewerBGColor", m_viewerBGColor); getValue(*m_settings, "previewBGColor", m_previewBGColor); getValue(*m_settings, "chessboardColor1", m_chessboardColor1); getValue(*m_settings, "chessboardColor2", m_chessboardColor2); getValue(*m_settings, "showRasterImagesDarkenBlendedInViewer", m_showRasterImagesDarkenBlendedInViewer); getValue(*m_settings, "actualPixelViewOnSceneEditingMode", m_actualPixelViewOnSceneEditingMode); getValue(*m_settings, "viewerZoomCenter", m_viewerZoomCenter); getValue(*m_settings, "initialLoadTlvCachingBehavior", m_initialLoadTlvCachingBehavior); getValue(*m_settings, "removeSceneNumberFromLoadedLevelName", m_removeSceneNumberFromLoadedLevelName); getValue(*m_settings, "replaceAfterSaveLevelAs", m_replaceAfterSaveLevelAs); getValue(*m_settings, "showFrameNumberWithLetters", m_showFrameNumberWithLetters); getValue(*m_settings, "levelNameOnEachMarkerEnabled", m_levelNameOnEachMarker); getValue(*m_settings, "columnIconLoadingPolicy", m_columnIconLoadingPolicy); getValue(*m_settings, "moveCurrentFrameByClickCellArea", m_moveCurrentFrameByClickCellArea); getValue(*m_settings, "onionSkinEnabled", m_onionSkinEnabled); getValue(*m_settings, "multiLayerStylePickerEnabled", m_multiLayerStylePickerEnabled); getValue(*m_settings, "paletteTypeOnLoadRasterImageAsColorModel", m_paletteTypeOnLoadRasterImageAsColorModel); getValue(*m_settings, "showKeyframesOnXsheetCellArea", m_showKeyframesOnXsheetCellArea); }
void TLevelWriter::renumberFids(const std::map<TFrameId, TFrameId> &table) { typedef std::map<TFrameId, TFrameId> Table; struct locals { static inline QString qstring(const TFilePath &fp) { return QString::fromStdWString(fp.getWideString()); } static inline QString temp(const QString &str) { return str + QString("_"); } }; if (m_path.getDots() == "..") { try { // Extract all image file paths of the level QDir parentDir(QString::fromStdWString(m_path.getParentDir().getWideString())); parentDir.setFilter(QDir::Files); QStringList nameFilters( QString::fromStdWString(m_path.getWideName()) + ".*." + QString::fromStdString(m_path.getType())); parentDir.setNameFilters(nameFilters); TFilePathSet fpset; TSystem::readDirectory(fpset, parentDir, false); // Could throw // Traverse each file, trying to match it with a table entry std::vector<QString> storedDstPaths; TFilePathSet::iterator st, sEnd(fpset.end()); for (st = fpset.begin(); st != sEnd; ++st) { const QString &src = locals::qstring(*st); const TFrameId &fid = st->getFrame(); // Could throw ! (and I'm quite appalled of that o.o') Table::const_iterator dt(table.find(fid)); if (dt == table.end()) { // The frame must be removed QFile::remove(src); } else { if (fid == dt->second) continue; // The frame must be renumbered const QString &dst = locals::qstring(st->withFrame(dt->second)); if (!QFile::rename(src, dst)) { // Use a temporary file rename to ensure that other frames to be renumbered // are not overwritten. if (QFile::rename(locals::qstring(*st), locals::temp(dst))) storedDstPaths.push_back(dst); // If the second rename did not happen, the problem was not on dst, but on src. // Alas, it means that rename on source is not possible - skip. } } } // At this point, temporaries should be restored to originals. In case the // rename of one of those files cannot be finalized, leave the temporary - as // it may be impossible to roll back (another frame could have been renumbered // to the would-roll-back frame) ! std::vector<QString>::iterator dt, dEnd(storedDstPaths.end()); for (dt = storedDstPaths.begin(); dt != dEnd; ++dt) QFile::rename(locals::temp(*dt), *dt); } catch (...) { // Could not read the directory - skip silently } } }