Merge pull request #230 from shun-iwasawa/add_save_all_command
"Save All" menu which saves current scene and all the levels. (modified from pr#153)
This commit is contained in:
commit
43167d966f
11 changed files with 56 additions and 4 deletions
|
@ -4,6 +4,7 @@
|
|||
<command>MI_LoadScene</command>
|
||||
<command>MI_SaveScene</command>
|
||||
<command>MI_SaveSceneAs</command>
|
||||
<command>MI_SaveAll</command>
|
||||
<command>MI_OpenRecentScene</command>
|
||||
<command>MI_RevertScene</command>
|
||||
<separator/>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<command>MI_LoadScene</command>
|
||||
<command>MI_SaveScene</command>
|
||||
<command>MI_SaveSceneAs</command>
|
||||
<command>MI_SaveAll</command>
|
||||
<command>MI_OpenRecentScene</command>
|
||||
<command>MI_RevertScene</command>
|
||||
<separator/>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<command>MI_LoadScene</command>
|
||||
<command>MI_SaveScene</command>
|
||||
<command>MI_SaveSceneAs</command>
|
||||
<command>MI_SaveAll</command>
|
||||
<command>MI_OpenRecentScene</command>
|
||||
<command>MI_RevertScene</command>
|
||||
<separator/>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<command>MI_LoadFolder</command>
|
||||
<command>MI_SaveLevel</command>
|
||||
<command>MI_SaveLevelAs</command>
|
||||
<command>MI_SaveAll</command>
|
||||
<command>MI_OpenRecentLevel</command>
|
||||
<command>MI_ExportLevel</command>
|
||||
<command>MI_LevelSettings</command>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<command>MI_LoadScene</command>
|
||||
<command>MI_SaveScene</command>
|
||||
<command>MI_SaveSceneAs</command>
|
||||
<command>MI_SaveAll</command>
|
||||
<command>MI_OpenRecentScene</command>
|
||||
<command>MI_RevertScene</command>
|
||||
<separator/>
|
||||
|
|
|
@ -1661,6 +1661,30 @@ bool IoCmd::saveLevel(TXshSimpleLevel *sl)
|
|||
#endif
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// IoCmd::saveAll() save current scene and all of its levels
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool IoCmd::saveAll()
|
||||
{
|
||||
// try to save as much as possible
|
||||
// if anything is wrong, return false
|
||||
bool result = saveScene();
|
||||
|
||||
TApp *app = TApp::instance();
|
||||
ToonzScene* scene = app->getCurrentScene()->getScene();
|
||||
|
||||
SceneResources resources(scene, 0);
|
||||
resources.save(scene->getScenePath());
|
||||
resources.updatePaths();
|
||||
|
||||
// for update title bar
|
||||
app->getCurrentLevel()->notifyLevelTitleChange();
|
||||
app->getCurrentPalette()->notifyPaletteTitleChanged();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// IoCmd::saveSound(soundPath, soundColumn, overwrite)
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -2829,3 +2853,17 @@ public:
|
|||
TApp::instance()->getPaletteController()->getCurrentLevelPalette()->notifyPaletteDirtyFlagChanged();
|
||||
}
|
||||
} overwritePaletteCommandHandler;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// Save scene and levels
|
||||
//-----------------------------------------------------------------------------
|
||||
class SaveAllCommandHandler : public MenuItemHandler
|
||||
{
|
||||
public:
|
||||
SaveAllCommandHandler() : MenuItemHandler(MI_SaveAll) {}
|
||||
void execute()
|
||||
{
|
||||
IoCmd::saveAll();
|
||||
}
|
||||
} saveAllCommandHandler;
|
||||
|
|
|
@ -173,6 +173,8 @@ bool saveLevel();
|
|||
bool saveLevel(const TFilePath &fp, TXshSimpleLevel *sl, bool overwrite);
|
||||
bool saveLevel(TXshSimpleLevel *sl);
|
||||
|
||||
bool saveAll();
|
||||
|
||||
bool saveSound(const TFilePath &fp, TXshSoundLevel *sc, bool overwrite);
|
||||
bool saveSound(TXshSoundLevel *sc);
|
||||
|
||||
|
|
|
@ -1579,6 +1579,7 @@ void MainWindow::defineActions()
|
|||
createMenuFileAction(MI_LoadScene, tr("&Load Scene..."), "Ctrl+L");
|
||||
createMenuFileAction(MI_SaveScene, tr("&Save Scene"), "Ctrl+S");
|
||||
createMenuFileAction(MI_SaveSceneAs, tr("&Save Scene As..."), "Ctrl+Shift+S");
|
||||
createMenuFileAction(MI_SaveAll, tr("&Save All"), "");
|
||||
createMenuFileAction(MI_RevertScene, tr("&Revert Scene"), "");
|
||||
|
||||
QAction *act = CommandManager::instance()->getAction(MI_RevertScene);
|
||||
|
|
|
@ -403,6 +403,7 @@ QMenuBar* StackedMenuBar::createCleanupMenuBar()
|
|||
addMenuItem(filesMenu, MI_LoadScene);
|
||||
addMenuItem(filesMenu, MI_SaveScene);
|
||||
addMenuItem(filesMenu, MI_SaveSceneAs);
|
||||
addMenuItem(filesMenu, MI_SaveAll);
|
||||
addMenuItem(filesMenu, MI_OpenRecentScene);
|
||||
addMenuItem(filesMenu, MI_RevertScene);
|
||||
filesMenu->addSeparator();
|
||||
|
@ -535,6 +536,7 @@ QMenuBar* StackedMenuBar::createPltEditMenuBar()
|
|||
addMenuItem(filesMenu, MI_LoadScene);
|
||||
addMenuItem(filesMenu, MI_SaveScene);
|
||||
addMenuItem(filesMenu, MI_SaveSceneAs);
|
||||
addMenuItem(filesMenu, MI_SaveAll);
|
||||
addMenuItem(filesMenu, MI_OpenRecentScene);
|
||||
addMenuItem(filesMenu, MI_RevertScene);
|
||||
filesMenu->addSeparator();
|
||||
|
@ -707,6 +709,7 @@ QMenuBar* StackedMenuBar::createInknPaintMenuBar()
|
|||
addMenuItem(filesMenu, MI_LoadScene);
|
||||
addMenuItem(filesMenu, MI_SaveScene);
|
||||
addMenuItem(filesMenu, MI_SaveSceneAs);
|
||||
addMenuItem(filesMenu, MI_SaveAll);
|
||||
addMenuItem(filesMenu, MI_OpenRecentScene);
|
||||
filesMenu->addSeparator();
|
||||
addMenuItem(filesMenu, MI_NewScene);
|
||||
|
@ -857,6 +860,7 @@ QMenuBar* StackedMenuBar::createXsheetMenuBar()
|
|||
addMenuItem(xsheetMenu, MI_LoadScene);
|
||||
addMenuItem(xsheetMenu, MI_SaveScene);
|
||||
addMenuItem(xsheetMenu, MI_SaveSceneAs);
|
||||
addMenuItem(xsheetMenu, MI_SaveAll);
|
||||
addMenuItem(xsheetMenu, MI_OpenRecentScene);
|
||||
addMenuItem(xsheetMenu, MI_RevertScene);
|
||||
xsheetMenu->addSeparator();
|
||||
|
@ -1109,6 +1113,7 @@ QMenuBar* StackedMenuBar::createFullMenuBar()
|
|||
addMenuItem(fileMenu, MI_NewScene);
|
||||
addMenuItem(fileMenu, MI_LoadScene);
|
||||
addMenuItem(fileMenu, MI_SaveScene);
|
||||
addMenuItem(fileMenu, MI_SaveAll);
|
||||
addMenuItem(fileMenu, MI_SaveSceneAs);
|
||||
addMenuItem(fileMenu, MI_OpenRecentScene);
|
||||
addMenuItem(fileMenu, MI_RevertScene);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define MI_LoadScene "MI_LoadScene"
|
||||
#define MI_SaveScene "MI_SaveScene"
|
||||
#define MI_SaveSceneAs "MI_SaveSceneAs"
|
||||
#define MI_SaveAll "MI_SaveAll"
|
||||
#define MI_RevertScene "MI_RevertScene"
|
||||
#define MI_LoadSubSceneFile "MI_LoadSubSceneFile"
|
||||
|
||||
|
|
|
@ -256,13 +256,13 @@ void SceneLevel::save()
|
|||
//Questo controllo viene fatto qui e non nella copia o nel salvataggio del livello perche' in generale
|
||||
//non si vuole che il livello unpainted venga copiato con il livello.
|
||||
if (actualFp.getType() == "tlv") {
|
||||
TFilePath oldUnpaintedLevelPath = oldActualPath.getParentDir() + TFilePath(oldActualPath.getName() + "-unpainted." + oldActualPath.getType());
|
||||
TFilePath unpaintedLevelPath = actualFp.getParentDir() + TFilePath(actualFp.getName() + "-unpainted." + actualFp.getType());
|
||||
if (TSystem::doesExistFileOrLevel(oldUnpaintedLevelPath) && !TSystem::doesExistFileOrLevel(unpaintedLevelPath))
|
||||
TFilePath oldUnpaintedLevelPath = oldActualPath.getParentDir() + "nopaint\\" + TFilePath(oldActualPath.getName() + "_np." + oldActualPath.getType());
|
||||
TFilePath unpaintedLevelPath = actualFp.getParentDir() + "nopaint\\" + TFilePath(actualFp.getName() + "_np." + actualFp.getType());
|
||||
if (TSystem::doesExistFileOrLevel(oldUnpaintedLevelPath) && !TSystem::doesExistFileOrLevel(unpaintedLevelPath) && TSystem::touchParentDir(unpaintedLevelPath))
|
||||
TSystem::copyFile(unpaintedLevelPath, oldUnpaintedLevelPath);
|
||||
TFilePath oldUnpaintedPalettePath = oldUnpaintedLevelPath.withType("tpl");
|
||||
TFilePath unpaintedPalettePath = unpaintedLevelPath.withType("tpl");
|
||||
if (TSystem::doesExistFileOrLevel(oldUnpaintedPalettePath) && !TSystem::doesExistFileOrLevel(unpaintedPalettePath))
|
||||
if (TSystem::doesExistFileOrLevel(oldUnpaintedPalettePath) && !TSystem::doesExistFileOrLevel(unpaintedPalettePath) && TSystem::touchParentDir(unpaintedPalettePath))
|
||||
TSystem::copyFile(unpaintedPalettePath, oldUnpaintedPalettePath);
|
||||
}
|
||||
} catch (...) {
|
||||
|
|
Loading…
Reference in a new issue