timeline refactor, bit broken rn
This commit is contained in:
@@ -105,10 +105,7 @@ namespace anm2ed::anm2
|
||||
return element;
|
||||
}
|
||||
|
||||
void Animation::serialize(XMLDocument& document, XMLElement* parent)
|
||||
{
|
||||
parent->InsertEndChild(to_element(document));
|
||||
}
|
||||
void Animation::serialize(XMLDocument& document, XMLElement* parent) { parent->InsertEndChild(to_element(document)); }
|
||||
|
||||
std::string Animation::to_string()
|
||||
{
|
||||
@@ -153,13 +150,13 @@ namespace anm2ed::anm2
|
||||
|
||||
if (isRootTransform)
|
||||
{
|
||||
auto root = rootAnimation.frame_generate(t, anm2::ROOT);
|
||||
auto root = rootAnimation.frame_generate(t, ROOT);
|
||||
transform *= math::quad_model_parent_get(root.position, {}, math::percent_to_unit(root.scale), root.rotation);
|
||||
}
|
||||
|
||||
for (auto& [id, layerAnimation] : layerAnimations)
|
||||
{
|
||||
auto frame = layerAnimation.frame_generate(t, anm2::LAYER);
|
||||
auto frame = layerAnimation.frame_generate(t, LAYER);
|
||||
|
||||
if (frame.size == vec2() || !frame.isVisible) continue;
|
||||
|
||||
|
||||
@@ -131,6 +131,8 @@ namespace anm2ed::anm2
|
||||
finalIndex -= numDeletedBefore;
|
||||
}
|
||||
|
||||
animation.frameNum = animation.length();
|
||||
|
||||
return finalIndex;
|
||||
}
|
||||
|
||||
|
||||
84
src/anm2/anm2_type.h
Normal file
84
src/anm2/anm2_type.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include "icon.h"
|
||||
|
||||
#include <glm/glm/vec2.hpp>
|
||||
#include <glm/glm/vec3.hpp>
|
||||
#include <glm/glm/vec4.hpp>
|
||||
|
||||
namespace anm2ed::anm2
|
||||
{
|
||||
constexpr auto ROOT_COLOR = glm::vec4(0.140f, 0.310f, 0.560f, 1.000f);
|
||||
constexpr auto ROOT_COLOR_ACTIVE = glm::vec4(0.240f, 0.520f, 0.880f, 1.000f);
|
||||
constexpr auto ROOT_COLOR_HOVERED = glm::vec4(0.320f, 0.640f, 1.000f, 1.000f);
|
||||
|
||||
constexpr auto LAYER_COLOR = glm::vec4(0.640f, 0.320f, 0.110f, 1.000f);
|
||||
constexpr auto LAYER_COLOR_ACTIVE = glm::vec4(0.840f, 0.450f, 0.170f, 1.000f);
|
||||
constexpr auto LAYER_COLOR_HOVERED = glm::vec4(0.960f, 0.560f, 0.240f, 1.000f);
|
||||
|
||||
constexpr auto NULL_COLOR = glm::vec4(0.140f, 0.430f, 0.200f, 1.000f);
|
||||
constexpr auto NULL_COLOR_ACTIVE = glm::vec4(0.250f, 0.650f, 0.350f, 1.000f);
|
||||
constexpr auto NULL_COLOR_HOVERED = glm::vec4(0.350f, 0.800f, 0.480f, 1.000f);
|
||||
|
||||
constexpr auto TRIGGER_COLOR = glm::vec4(0.620f, 0.150f, 0.260f, 1.000f);
|
||||
constexpr auto TRIGGER_COLOR_ACTIVE = glm::vec4(0.820f, 0.250f, 0.380f, 1.000f);
|
||||
constexpr auto TRIGGER_COLOR_HOVERED = glm::vec4(0.950f, 0.330f, 0.490f, 1.000f);
|
||||
|
||||
#define TYPE_LIST \
|
||||
X(NONE, "", "", resource::icon::NONE, glm::vec4(), glm::vec4(), glm::vec4()) \
|
||||
X(ROOT, "Root", "RootAnimation", resource::icon::ROOT, ROOT_COLOR, ROOT_COLOR_ACTIVE, ROOT_COLOR_HOVERED) \
|
||||
X(LAYER, "Layer", "LayerAnimation", resource::icon::LAYER, LAYER_COLOR, LAYER_COLOR_ACTIVE, LAYER_COLOR_HOVERED) \
|
||||
X(NULL_, "Null", "NullAnimation", resource::icon::NULL_, NULL_COLOR, NULL_COLOR_ACTIVE, NULL_COLOR_HOVERED) \
|
||||
X(TRIGGER, "Triggers", "Triggers", resource::icon::TRIGGERS, TRIGGER_COLOR, TRIGGER_COLOR_ACTIVE, \
|
||||
TRIGGER_COLOR_HOVERED)
|
||||
|
||||
enum Type
|
||||
{
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) symbol,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr const char* TYPE_STRINGS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) string,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr const char* TYPE_ITEM_STRINGS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) itemString,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr resource::icon::Type TYPE_ICONS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) icon,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr glm::vec4 TYPE_COLOR[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) color,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr glm::vec4 TYPE_COLOR_ACTIVE[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) colorActive,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr glm::vec4 TYPE_COLOR_HOVERED[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) colorHovered,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
enum ChangeType
|
||||
{
|
||||
ADD,
|
||||
SUBTRACT,
|
||||
ADJUST
|
||||
};
|
||||
}
|
||||
@@ -114,19 +114,13 @@ namespace anm2ed::anm2
|
||||
return xml::document_to_string(document);
|
||||
}
|
||||
|
||||
void Frame::shorten()
|
||||
{
|
||||
delay = glm::clamp(--delay, FRAME_DELAY_MIN, FRAME_DELAY_MAX);
|
||||
}
|
||||
void Frame::shorten() { delay = glm::clamp(--delay, FRAME_DELAY_MIN, FRAME_DELAY_MAX); }
|
||||
|
||||
void Frame::extend()
|
||||
{
|
||||
delay = glm::clamp(++delay, FRAME_DELAY_MIN, FRAME_DELAY_MAX);
|
||||
}
|
||||
void Frame::extend() { delay = glm::clamp(++delay, FRAME_DELAY_MIN, FRAME_DELAY_MAX); }
|
||||
|
||||
bool Frame::is_visible(Type type)
|
||||
{
|
||||
if (type == anm2::TRIGGER)
|
||||
if (type == TRIGGER)
|
||||
return isVisible && eventID > -1;
|
||||
else
|
||||
return isVisible;
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
#include <string>
|
||||
#include <tinyxml2/tinyxml2.h>
|
||||
|
||||
#include <glm/glm/vec2.hpp>
|
||||
#include <glm/glm/vec3.hpp>
|
||||
#include <glm/glm/vec4.hpp>
|
||||
|
||||
#include "anm2_type.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace anm2ed::anm2
|
||||
@@ -15,39 +12,6 @@ namespace anm2ed::anm2
|
||||
constexpr auto FRAME_DELAY_MIN = 1;
|
||||
constexpr auto FRAME_DELAY_MAX = 100000;
|
||||
|
||||
#define TYPE_LIST \
|
||||
X(NONE, "None", "None") \
|
||||
X(ROOT, "Root", "RootAnimation") \
|
||||
X(LAYER, "Layer", "LayerAnimation") \
|
||||
X(NULL_, "Null", "NullAnimation") \
|
||||
X(TRIGGER, "Trigger", "Triggers")
|
||||
|
||||
enum Type
|
||||
{
|
||||
#define X(symbol, string, animationString) symbol,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr const char* TYPE_STRINGS[] = {
|
||||
#define X(symbol, string, animationString) string,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr const char* TYPE_ANIMATION_STRINGS[] = {
|
||||
#define X(symbol, string, animationString) animationString,
|
||||
TYPE_LIST
|
||||
#undef X
|
||||
};
|
||||
|
||||
enum ChangeType
|
||||
{
|
||||
ADD,
|
||||
SUBTRACT,
|
||||
ADJUST
|
||||
};
|
||||
|
||||
#define MEMBERS \
|
||||
X(isVisible, bool, true) \
|
||||
X(isInterpolated, bool, false) \
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace anm2ed::anm2
|
||||
|
||||
XMLElement* Item::to_element(XMLDocument& document, Type type, int id)
|
||||
{
|
||||
auto element = document.NewElement(TYPE_ANIMATION_STRINGS[type]);
|
||||
auto element = document.NewElement(TYPE_ITEM_STRINGS[type]);
|
||||
|
||||
if (type == LAYER) element->SetAttribute("LayerId", id);
|
||||
if (type == NULL_) element->SetAttribute("NullId", id);
|
||||
|
||||
Reference in New Issue
Block a user