diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-04-24 11:22:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-24 11:22:44 +0200 |
| commit | 6679a4786b593cbe5050931261566fab9aa77f1f (patch) | |
| tree | a090b5c34cb75d4328c79f587018457a5e589c0a /src/helpers/AnimatedVariable.cpp | |
| parent | fc14157d765ce44e634525b2c437808e20ec93d6 (diff) | |
| parent | 1afc8329bc4438c3e2f8c3dda9a6743ce5ef7a3a (diff) | |
Merge pull request #55 from vaxerski/animation-system-rework
Animation system rework
Diffstat (limited to 'src/helpers/AnimatedVariable.cpp')
| -rw-r--r-- | src/helpers/AnimatedVariable.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp new file mode 100644 index 00000000..798e96e5 --- /dev/null +++ b/src/helpers/AnimatedVariable.cpp @@ -0,0 +1,55 @@ +#include "AnimatedVariable.hpp" +#include "../managers/AnimationManager.hpp" + +CAnimatedVariable::CAnimatedVariable() { + ; // dummy var +} + +void CAnimatedVariable::create(ANIMATEDVARTYPE type, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow) { + m_eVarType = type; + m_pSpeed = speed; + m_pEnabled = enabled; + m_pWindow = pWindow; + m_pBezier = pBezier; + + g_pAnimationManager->m_lAnimatedVariables.push_back(this); + + m_bDummy = false; +} + +void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow) { + create(type, speed, enabled, pBezier, pWindow); + + try { + switch (type) { + case AVARTYPE_FLOAT: { + const auto V = std::any_cast<float>(val); + m_fValue = V; + m_fGoal = V; + break; + } + case AVARTYPE_VECTOR: { + const auto V = std::any_cast<Vector2D>(val); + m_vValue = V; + m_vGoal = V; + break; + } + case AVARTYPE_COLOR: { + const auto V = std::any_cast<CColor>(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 |
