[aseprite] 35/308: Add options to export layers and frameTags meta JSON data from the UI

Tobias Hansen thansen at moszumanska.debian.org
Tue Mar 8 02:44:49 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit fb387cb6c21cb5e6265c17eb2f3d5defac87feb8
Author: David Capello <davidcapello at gmail.com>
Date:   Thu Dec 3 12:42:33 2015 -0300

    Add options to export layers and frameTags meta JSON data from the UI
---
 data/pref.xml                                |  2 ++
 data/widgets/export_sprite_sheet.xml         |  7 +++++++
 src/app/commands/cmd_export_sprite_sheet.cpp | 28 ++++++++++++++++++++++++++--
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/data/pref.xml b/data/pref.xml
index c15dade..9924412 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -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" />
diff --git a/data/widgets/export_sprite_sheet.xml b/data/widgets/export_sprite_sheet.xml
index a3a4ffb..1b9a427 100644
--- a/data/widgets/export_sprite_sheet.xml
+++ b/data/widgets/export_sprite_sheet.xml
@@ -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">
diff --git a/src/app/commands/cmd_export_sprite_sheet.cpp b/src/app/commands/cmd_export_sprite_sheet.cpp
index 580e686..801efc9 100644
--- a/src/app/commands/cmd_export_sprite_sheet.cpp
+++ b/src/app/commands/cmd_export_sprite_sheet.cpp
@@ -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());

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list