Add options to export layers and frameTags meta JSON data from the UI

This commit is contained in:
David Capello 2015-12-03 12:42:33 -03:00
parent 2d2434daea
commit fb387cb6c2
3 changed files with 35 additions and 2 deletions

View File

@ -249,6 +249,8 @@
<option id="open_generated" type="bool" default="false" />
<option id="layer" type="std::string" />
<option id="frame_tag" type="std::string" />
<option id="list_layers" type="bool" default="true" />
<option id="list_frame_tags" type="bool" default="true" />
</section>
<section id="import_sprite_sheet">
<option id="type" type="app::SpriteSheetType" default="app::SpriteSheetType::Rows" />

View File

@ -47,6 +47,13 @@
<check id="data_enabled" text="JSON Data" />
<button id="data_filename" cell_hspan="3" />
<hbox />
<hbox id="data_meta" cell_hspan="3">
<label text="Meta:" />
<check id="list_layers" text="Layers" />
<check id="list_tags" text="Frame Tags" />
</hbox>
<check id="open_generated" text="Open generated sprite sheet" cell_hspan="4" />
<hbox cell_hspan="4">

View File

@ -359,7 +359,9 @@ public:
m_dataFilename = m_docPref.spriteSheet.dataFilename();
dataEnabled()->setSelected(!m_dataFilename.empty());
dataFilename()->setVisible(dataEnabled()->isSelected());
listLayers()->setSelected(m_docPref.spriteSheet.listLayers());
listTags()->setSelected(m_docPref.spriteSheet.listFrameTags());
updateDataFields();
std::string base = doc->filename();
base = base::join_path(base::get_file_path(base), base::get_file_title(base));
@ -496,6 +498,14 @@ public:
return kAllFrames;
}
bool listLayersValue() const {
return listLayers()->isSelected();
}
bool listFrameTagsValue() const {
return listTags()->isSelected();
}
private:
void onExport() {
@ -599,7 +609,7 @@ private:
void onDataEnabledChange() {
m_dataFilenameAskOverwrite = true;
dataFilename()->setVisible(dataEnabled()->isSelected());
updateDataFields();
updateExportButton();
resize();
}
@ -669,6 +679,12 @@ private:
fitHeight()->getEntryWidget()->setTextf("%d", fit.height);
}
void updateDataFields() {
bool state = dataEnabled()->isSelected();
dataFilename()->setVisible(state);
dataMeta()->setVisible(state);
}
Sprite* m_sprite;
DocumentPreferences& m_docPref;
std::string m_filename;
@ -748,6 +764,8 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
docPref.spriteSheet.openGenerated(window.openGeneratedValue());
docPref.spriteSheet.layer(window.layerValue());
docPref.spriteSheet.frameTag(window.frameTagValue());
docPref.spriteSheet.listLayers(window.listLayersValue());
docPref.spriteSheet.listFrameTags(window.listFrameTagsValue());
// Default preferences for future sprites
DocumentPreferences& defPref(Preferences::instance().document(nullptr));
@ -777,6 +795,8 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
borderPadding = MID(0, borderPadding, 100);
shapePadding = MID(0, shapePadding, 100);
innerPadding = MID(0, innerPadding, 100);
bool listLayers = docPref.spriteSheet.listLayers();
bool listFrameTags = docPref.spriteSheet.listFrameTags();
if (context->isUIAvailable() && askOverwrite) {
if (!ask_overwrite(true, filename,
@ -865,6 +885,10 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
exporter.setBorderPadding(borderPadding);
exporter.setShapePadding(shapePadding);
exporter.setInnerPadding(innerPadding);
if (listLayers)
exporter.setListLayers(true);
if (listFrameTags)
exporter.setListFrameTags(true);
exporter.addDocument(document, layer, frameTag, isTemporalTag);
base::UniquePtr<Document> newDocument(exporter.exportSheet());