summaryrefslogtreecommitdiff
path: root/src/helpers/AnimatedVariable.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-28 13:28:43 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-28 13:28:43 +0200
commit920fdd6bff0f78d6f7f5de6167a23af303e00e57 (patch)
treeff28eaba4ee9c6647e0a3b8ac1fab1cb8e14fbf3 /src/helpers/AnimatedVariable.cpp
parent9dd17a4be6a719ab0cc501f63cf07cfd066f3ef8 (diff)
Animation config rework
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);
+}