Export Sprite Sheet: Fixed exporting selected layers when Split Layers is not checked

Bug reported here: https://community.aseprite.org/t/4248/6
This commit is contained in:
David Capello 2019-11-29 11:50:33 -03:00
parent 48c4e49d67
commit ea0e51e82d

View File

@ -166,10 +166,13 @@ ConstraintType constraint_type_from_params(const ExportSpriteSheetParams& params
#endif // ENABLE_UI #endif // ENABLE_UI
void update_doc_exporter_from_params(DocExporter& exporter, Doc* generate_sprite_sheet_from_params(
const Site& site, DocExporter& exporter,
const ExportSpriteSheetParams& params, Context* ctx,
const bool saveData) const Site& site,
const ExportSpriteSheetParams& params,
const bool saveData,
base::task_token& token)
{ {
const app::SpriteSheetType type = params.type(); const app::SpriteSheetType type = params.type();
const int columns = params.columns(); const int columns = params.columns();
@ -260,6 +263,11 @@ void update_doc_exporter_from_params(DocExporter& exporter,
if (listLayers) exporter.setListLayers(true); if (listLayers) exporter.setListLayers(true);
if (listTags) exporter.setListTags(true); if (listTags) exporter.setListTags(true);
if (listSlices) exporter.setListSlices(true); if (listSlices) exporter.setListSlices(true);
// We have to call exportSheet() while RestoreVisibleLayers is still
// alive. In this way we can export selected layers correctly if
// that option (kSelectedLayers) is selected.
return exporter.exportSheet(ctx, token);
} }
std::unique_ptr<Doc> generate_sprite_sheet( std::unique_ptr<Doc> generate_sprite_sheet(
@ -270,22 +278,22 @@ std::unique_ptr<Doc> generate_sprite_sheet(
bool saveData, bool saveData,
base::task_token& token) base::task_token& token)
{ {
update_doc_exporter_from_params(exporter, site, params, saveData);
std::unique_ptr<Doc> newDocument( std::unique_ptr<Doc> newDocument(
exporter.exportSheet(ctx, token)); generate_sprite_sheet_from_params(exporter, ctx, site, params, saveData, token));
if (newDocument) { if (!newDocument)
// Setup a filename for the new document in case that user didn't return nullptr;
// save the file/specified one output filename.
if (params.textureFilename().empty()) {
std::string fn = site.document()->filename();
std::string ext = base::get_file_extension(fn);
if (!ext.empty())
ext.insert(0, 1, '.');
newDocument->setFilename( // Setup a filename for the new document in case that user didn't
base::join_path(base::get_file_path(fn), // save the file/specified one output filename.
base::get_file_title(fn) + "-Sheet") + ext); if (params.textureFilename().empty()) {
} std::string fn = site.document()->filename();
std::string ext = base::get_file_extension(fn);
if (!ext.empty())
ext.insert(0, 1, '.');
newDocument->setFilename(
base::join_path(base::get_file_path(fn),
base::get_file_title(fn) + "-Sheet") + ext);
} }
return newDocument; return newDocument;
} }