From 0147975faf939db389bebaa95e3a12e5e5a8753f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 23 Apr 2022 14:16:02 +0200 Subject: New animation system --- src/helpers/AnimatedVariable.cpp | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/helpers/AnimatedVariable.cpp (limited to 'src/helpers/AnimatedVariable.cpp') diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp new file mode 100644 index 00000000..581ea1c8 --- /dev/null +++ b/src/helpers/AnimatedVariable.cpp @@ -0,0 +1,54 @@ +#include "AnimatedVariable.hpp" +#include "../managers/AnimationManager.hpp" + +CAnimatedVariable::CAnimatedVariable() { + ; // dummy var +} + +void CAnimatedVariable::create(ANIMATEDVARTYPE type, float* speed, int64_t* enabled, void* pWindow) { + m_eVarType = type; + m_pSpeed = speed; + m_pEnabled = enabled; + m_pWindow = pWindow; + + g_pAnimationManager->m_lAnimatedVariables.push_back(this); + + m_bDummy = false; +} + +void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, float* speed, int64_t* enabled, void* pWindow) { + create(type, speed, enabled, pWindow); + + try { + switch (type) { + case AVARTYPE_FLOAT: { + const auto V = std::any_cast(val); + m_fValue = V; + m_fGoal = V; + break; + } + case AVARTYPE_VECTOR: { + const auto V = std::any_cast(val); + m_vValue = V; + m_vGoal = V; + break; + } + case AVARTYPE_COLOR: { + const auto V = std::any_cast(val); + m_cValue = V; + m_cGoal = V; + break; + } + default: + ASSERT(false); + break; + } + } catch (std::exception& e) { + Debug::log(ERR, "CAnimatedVariable create error: %s", e.what()); + RASSERT(false, "CAnimatedVariable create error: %s", e.what()); + } +} + +CAnimatedVariable::~CAnimatedVariable() { + g_pAnimationManager->m_lAnimatedVariables.remove(this); +} \ No newline at end of file -- cgit v1.2.3