From 920fdd6bff0f78d6f7f5de6167a23af303e00e57 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 28 Jul 2022 13:28:43 +0200 Subject: Animation config rework --- src/helpers/AnimatedVariable.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/helpers/AnimatedVariable.cpp') diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp index 1e9dd74e..7860fb8f 100644 --- a/src/helpers/AnimatedVariable.cpp +++ b/src/helpers/AnimatedVariable.cpp @@ -1,25 +1,24 @@ #include "AnimatedVariable.hpp" #include "../managers/AnimationManager.hpp" +#include "../config/ConfigManager.hpp" CAnimatedVariable::CAnimatedVariable() { ; // dummy var } -void CAnimatedVariable::create(ANIMATEDVARTYPE type, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY policy) { +void CAnimatedVariable::create(ANIMATEDVARTYPE type, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) { m_eVarType = type; m_eDamagePolicy = policy; - m_pSpeed = speed; - m_pEnabled = enabled; + m_pConfig = pAnimConfig; 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, AVARDAMAGEPOLICY policy) { - create(type, speed, enabled, pBezier, pWindow, policy); +void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) { + create(type, pAnimConfig, pWindow, policy); try { switch (type) { @@ -57,4 +56,8 @@ CAnimatedVariable::~CAnimatedVariable() { void CAnimatedVariable::unregister() { g_pAnimationManager->m_lAnimatedVariables.remove(this); -} \ No newline at end of file +} + +int CAnimatedVariable::getDurationLeftMs() { + return std::clamp((int)(m_pConfig->pValues->internalSpeed * 100) - (int)std::chrono::duration_cast(std::chrono::system_clock::now() - animationBegin).count(), 0, INT_MAX); +} -- cgit v1.2.3