summaryrefslogtreecommitdiff
path: root/src/helpers/AnimatedVariable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/AnimatedVariable.cpp')
-rw-r--r--src/helpers/AnimatedVariable.cpp17
1 files changed, 10 insertions, 7 deletions
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::milliseconds>(std::chrono::system_clock::now() - animationBegin).count(), 0, INT_MAX);
+}