Export AniDir field for FrameTags in JSON meta attribute

This commit is contained in:
David Capello 2015-12-03 12:07:46 -03:00
parent 4dbee12789
commit 2d2434daea
4 changed files with 33 additions and 1 deletions

View File

@ -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 ]";

View File

@ -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

25
src/doc/anidir.cpp Normal file
View File

@ -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

View File

@ -8,6 +8,8 @@
#define DOC_ANIDIR_H_INCLUDED
#pragma once
#include <string>
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