Save and render (#20)

This commit is contained in:
Jeremy Bullock 2020-05-27 17:54:19 -06:00 committed by GitHub
parent 67c02220a5
commit 148badbee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 13 deletions

View file

@ -297,7 +297,7 @@ old save path.
If pointer to subXsheet is different from zero save only resources
used in subXsheet.
*/
void save(const TFilePath newScenePath);
bool save(const TFilePath newScenePath);
/*!
Update all resouces paths.

View file

@ -1660,13 +1660,18 @@ bool IoCmd::saveAll() {
ToonzScene *scene = app->getCurrentScene()->getScene();
bool untitled = scene->isUntitled();
SceneResources resources(scene, 0);
resources.save(scene->getScenePath());
result = result && resources.save(scene->getScenePath());
resources.updatePaths();
// for update title bar
app->getCurrentLevel()->notifyLevelTitleChange();
app->getCurrentPalette()->notifyPaletteTitleChanged();
if (untitled) scene->setUntitled();
if (!result) {
DVGui::warning(
QObject::tr("An error occured while saving. \n"
"Please check your work and try again."));
}
return result;
}

View file

@ -1668,7 +1668,7 @@ void MainWindow::defineActions() {
createMenuRenderAction(MI_OutputSettings, tr("&Output Settings..."),
"Ctrl+O");
createMenuRenderAction(MI_PreviewSettings, tr("&Preview Settings..."), "");
createMenuRenderAction(MI_Render, tr("&Render"), "Ctrl+Shift+R");
createMenuRenderAction(MI_Render, tr("&Save and Render"), "Ctrl+Shift+R");
createMenuRenderAction(MI_FastRender, tr("&Fast Render to MP4"), "Alt+R");
createMenuRenderAction(MI_Preview, tr("&Preview"), "Ctrl+R");
createMenuFileAction(MI_SoundTrack, tr("&Export Soundtrack"), "");

View file

@ -225,7 +225,7 @@ OutputSettingsPopup::OutputSettingsPopup(bool isPreview)
showOtherSettingsButton = new QPushButton("", this);
otherSettingsLabel = new QLabel(tr("Other Settings"), this);
otherSettingsFrame = new QFrame(this);
m_renderButton = new QPushButton(tr("Render"), this);
m_renderButton = new QPushButton(tr("Save and Render"), this);
// Board
m_addBoard = new DVGui::CheckBox(tr("Add Clapperboard"), this);
@ -935,8 +935,8 @@ void OutputSettingsPopup::onNameChanged() {
}
if (isReservedFileName_message(name)) {
TOutputProperties *prop = getProperties();
TFilePath fp = prop->getPath();
QString name = QString::fromStdString(fp.getName());
TFilePath fp = prop->getPath();
QString name = QString::fromStdString(fp.getName());
if (name.isEmpty())
name = QString::fromStdString(scene->getScenePath().getName());
m_fileNameFld->setText(name);

View file

@ -39,6 +39,7 @@
#include "tenv.h"
#include "trenderer.h"
#include "trasterfx.h"
#include "iocommand.h"
// TnzCore includes
#include "tsystem.h"
@ -735,7 +736,14 @@ void RenderCommand::multimediaRender() {
//===================================================================
void RenderCommand::onRender() { doRender(false); }
void RenderCommand::onRender() {
bool saved = false;
saved = IoCmd::saveAll();
if (!saved) {
return;
}
doRender(false);
}
void RenderCommand::onFastRender() {
TOutputProperties *prop = TApp::instance()

View file

@ -121,7 +121,7 @@ TFilePath ResourceImportStrategy::process(ToonzScene *scene,
if (srcPath.getWideString().find(L'+') == 0)
dstPath = srcPath;
else
dstPath = scene->getImportedLevelPath(srcPath);
dstPath = scene->getImportedLevelPath(srcPath);
TFilePath actualDstPath = scene->decodeFilePath(dstPath);
assert(actualDstPath != TFilePath());
@ -500,10 +500,10 @@ void SceneResources::getResources() {
//-----------------------------------------------------------------------------
void SceneResources::save(const TFilePath newScenePath) {
bool SceneResources::save(const TFilePath newScenePath) {
TFilePath oldScenePath = m_scene->getScenePath();
m_scene->setScenePath(newScenePath);
bool failedSave = false;
bool saved = false;
for (int i = 0; i < (int)m_resources.size(); i++) {
m_resources[i]->save();
}
@ -523,6 +523,8 @@ void SceneResources::save(const TFilePath newScenePath) {
" " + failedList.join("\n "));
}
m_scene->setScenePath(oldScenePath);
return failedList.isEmpty() ? true : false;
}
//-----------------------------------------------------------------------------
@ -576,7 +578,7 @@ ResourceImporter::ResourceImporter(ToonzScene *scene, TProject *dstProject,
scene->getScenePath() - scene->getProject()->getScenesPath();
if (relativeScenePath.isAbsolute())
relativeScenePath = scene->getScenePath().withoutParentDir();
TFilePath newFp = dstProject->getScenesPath() + relativeScenePath;
TFilePath newFp = dstProject->getScenesPath() + relativeScenePath;
makeUnique(newFp);
m_dstScene->setScenePath(newFp);
}
@ -694,7 +696,7 @@ void ResourceCollector::process(TXshSimpleLevel *sl) {
std::string suffix = ResourceImporter::extractPsdSuffix(path);
std::map<TFilePath, TFilePath>::iterator it = m_collectedFiles.find(path);
if (it != m_collectedFiles.end()) {
TFilePath destPath = it->second;
TFilePath destPath = it->second;
if (suffix != "") destPath = ResourceImporter::buildPsd(destPath, suffix);
sl->setPath(destPath);
} else {
@ -710,7 +712,7 @@ void ResourceCollector::process(TXshSimpleLevel *sl) {
}
}
++m_count;
TFilePath destPath = collectedPath;
TFilePath destPath = collectedPath;
if (suffix != "") destPath = ResourceImporter::buildPsd(destPath, suffix);
sl->setPath(destPath);
m_collectedFiles[path] = collectedPath;