mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 18:00:26 +00:00
Fix opening image sequences more times from CLI
We've also fixed the Agree/Skip dialog to show a checkbox and repeat the same action for all image sequences. Fixes: https://github.com/aseprite/aseprite/issues/2128 https://github.com/aseprite/aseprite/issues/1936#issuecomment-451565903
This commit is contained in:
parent
4cc2c6188d
commit
1255b17738
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 5fbae081190139140d3b22794f83b8dccef8a4a1
|
||||
Subproject commit 1f266c766b0afb6834c7fbefd919c20ce1723ccc
|
@ -347,6 +347,7 @@ int App::initialize(const AppOptions& options)
|
||||
return code;
|
||||
}
|
||||
|
||||
LOG("APP: Finish launching...\n");
|
||||
system->finishLaunching();
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "doc/slice.h"
|
||||
#include "doc/tag.h"
|
||||
#include "doc/tags.h"
|
||||
#include "os/system.h"
|
||||
#include "render/dithering_algorithm.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -576,8 +577,14 @@ int CliProcessor::process(Context* ctx)
|
||||
else {
|
||||
cof.document = nullptr;
|
||||
cof.filename = base::normalize_path(value.value());
|
||||
if (openFile(ctx, cof))
|
||||
|
||||
if (// Check that the filename wasn't used loading a sequence
|
||||
// of images as one sprite
|
||||
m_usedFiles.find(cof.filename) == m_usedFiles.end() &&
|
||||
// Open sprite
|
||||
openFile(ctx, cof)) {
|
||||
lastDoc = cof.document;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -610,13 +617,40 @@ bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
|
||||
m_delegate->beforeOpenFile(cof);
|
||||
|
||||
Doc* oldDoc = ctx->activeDocument();
|
||||
Command* openCommand = Commands::instance()->byId(CommandId::OpenFile());
|
||||
auto openCommand = static_cast<OpenFileCommand*>(Commands::instance()->byId(CommandId::OpenFile()));
|
||||
Params params;
|
||||
params.set("filename", cof.filename.c_str());
|
||||
if (cof.oneFrame)
|
||||
params.set("oneframe", "true");
|
||||
else {
|
||||
switch (m_lastDecision) {
|
||||
case OpenFileCommand::SequenceDecision::Ask:
|
||||
params.set("sequence", "ask");
|
||||
params.set("repeat_checkbox", "true");
|
||||
break;
|
||||
case OpenFileCommand::SequenceDecision::Skip:
|
||||
params.set("sequence", "skip");
|
||||
break;
|
||||
case OpenFileCommand::SequenceDecision::Agree:
|
||||
params.set("sequence", "agree");
|
||||
break;
|
||||
}
|
||||
}
|
||||
ctx->executeCommand(openCommand, params);
|
||||
|
||||
// Mark used file names as "already processed" so we don't try to
|
||||
// open then again
|
||||
for (const auto& usedFn : openCommand->usedFiles()) {
|
||||
auto fn = base::normalize_path(usedFn);
|
||||
m_usedFiles.insert(fn);
|
||||
|
||||
os::instance()->markCliFileAsProcessed(fn);
|
||||
}
|
||||
|
||||
// Future decision for other files in the CLI
|
||||
if (openCommand->seqDecision() != OpenFileCommand::SequenceDecision::Ask)
|
||||
m_lastDecision = openCommand->seqDecision();
|
||||
|
||||
Doc* doc = ctx->activeDocument();
|
||||
// If the active document is equal to the previous one, it
|
||||
// means that we couldn't open this specific document.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -11,10 +11,12 @@
|
||||
|
||||
#include "app/cli/cli_delegate.h"
|
||||
#include "app/cli/cli_open_file.h"
|
||||
#include "app/commands/cmd_open_file.h"
|
||||
#include "app/doc_exporter.h"
|
||||
#include "doc/selected_layers.h"
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -58,6 +60,11 @@ namespace app {
|
||||
CliDelegate* m_delegate;
|
||||
const AppOptions& m_options;
|
||||
std::unique_ptr<DocExporter> m_exporter;
|
||||
|
||||
// Files already used in the CLI processing (e.g. when used to
|
||||
// load a sequence of files) so we don't ask for them again.
|
||||
std::set<std::string> m_usedFiles;
|
||||
OpenFileCommand::SequenceDecision m_lastDecision = OpenFileCommand::SequenceDecision::Ask;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -169,14 +169,12 @@ void OpenFileCommand::onExecute(Context* context)
|
||||
}
|
||||
else {
|
||||
if (fop->isSequence()) {
|
||||
|
||||
if (fop->sequenceFlags() & FILE_LOAD_SEQUENCE_YES) {
|
||||
m_seqDecision = SequenceDecision::Agree;
|
||||
}
|
||||
else if (fop->sequenceFlags() & FILE_LOAD_SEQUENCE_NONE) {
|
||||
m_seqDecision = SequenceDecision::Skip;
|
||||
}
|
||||
|
||||
m_usedFiles = fop->filenames();
|
||||
}
|
||||
else {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -27,6 +28,10 @@ namespace app {
|
||||
return m_usedFiles;
|
||||
}
|
||||
|
||||
SequenceDecision seqDecision() const {
|
||||
return m_seqDecision;
|
||||
}
|
||||
|
||||
protected:
|
||||
void onLoadParams(const Params& params) override;
|
||||
void onExecute(Context* context) override;
|
||||
|
Loading…
Reference in New Issue
Block a user