From 2d2434daea092310a5e8c2d29201430db183c7c5 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 3 Dec 2015 12:07:46 -0300 Subject: [PATCH] Export AniDir field for FrameTags in JSON meta attribute --- src/app/document_exporter.cpp | 4 +++- src/doc/CMakeLists.txt | 1 + src/doc/anidir.cpp | 25 +++++++++++++++++++++++++ src/doc/anidir.h | 4 ++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/doc/anidir.cpp diff --git a/src/app/document_exporter.cpp b/src/app/document_exporter.cpp index 1aaf4eb28..ee5d4bbbe 100644 --- a/src/app/document_exporter.cpp +++ b/src/app/document_exporter.cpp @@ -697,9 +697,11 @@ void DocumentExporter::createDataFile(const Samples& samples, std::ostream& os, firstTag = false; else os << ","; + os << "\n { \"name\": \"" << escape_for_json(tag->name()) << "\"," << " \"from\": " << tag->fromFrame() << "," - << " \"to\": " << tag->toFrame() << " }"; + << " \"to\": " << tag->toFrame() << "," + << " \"direction\": \"" << escape_for_json(convert_to_string(tag->aniDir())) << "\" }"; } } os << "\n ]"; diff --git a/src/doc/CMakeLists.txt b/src/doc/CMakeLists.txt index 1c8c56a62..0d3bf8e2c 100644 --- a/src/doc/CMakeLists.txt +++ b/src/doc/CMakeLists.txt @@ -11,6 +11,7 @@ add_library(doc-lib algorithm/rotsprite.cpp algorithm/shift_image.cpp algorithm/shrink_bounds.cpp + anidir.cpp blend_funcs.cpp brush.cpp cel.cpp diff --git a/src/doc/anidir.cpp b/src/doc/anidir.cpp new file mode 100644 index 000000000..ecf898904 --- /dev/null +++ b/src/doc/anidir.cpp @@ -0,0 +1,25 @@ +// Aseprite Document Library +// Copyright (c) 2001-2015 David Capello +// +// This file is released under the terms of the MIT license. +// Read LICENSE.txt for more information. + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "doc/anidir.h" + +namespace doc { + +std::string convert_to_string(AniDir anidir) +{ + switch (anidir) { + case AniDir::FORWARD: return "forward"; + case AniDir::REVERSE: return "reverse"; + case AniDir::PING_PONG: return "pingpong"; + } + return ""; +} + +} // namespace doc diff --git a/src/doc/anidir.h b/src/doc/anidir.h index e459f4aea..208e8ed9a 100644 --- a/src/doc/anidir.h +++ b/src/doc/anidir.h @@ -8,6 +8,8 @@ #define DOC_ANIDIR_H_INCLUDED #pragma once +#include + namespace doc { enum class AniDir { @@ -16,6 +18,8 @@ namespace doc { PING_PONG = 2, }; + std::string convert_to_string(AniDir anidir); + } // namespace doc #endif // DOC_ANIDIR_H_INCLUDED