From 1d543628850404ca0e73fb74d185387c8a5780fb Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Sun, 24 Mar 2019 21:48:05 +0100 Subject: [PATCH] Added volume animation. --- RetroFE/Source/Graphics/Animate/Tween.cpp | 1 + RetroFE/Source/Graphics/Animate/TweenTypes.h | 1 + RetroFE/Source/Graphics/Component/Component.cpp | 8 ++++++++ RetroFE/Source/Graphics/Component/Component.h | 1 + RetroFE/Source/Graphics/PageBuilder.cpp | 1 + 5 files changed, 12 insertions(+) diff --git a/RetroFE/Source/Graphics/Animate/Tween.cpp b/RetroFE/Source/Graphics/Animate/Tween.cpp index 3657892..42d23ad 100644 --- a/RetroFE/Source/Graphics/Animate/Tween.cpp +++ b/RetroFE/Source/Graphics/Animate/Tween.cpp @@ -58,6 +58,7 @@ bool Tween::getTweenProperty(std::string name, TweenProperty &property) tweenPropertyMap_["containery"] = TWEEN_PROPERTY_CONTAINER_Y; tweenPropertyMap_["containerwidth"] = TWEEN_PROPERTY_CONTAINER_WIDTH; tweenPropertyMap_["containerheight"] = TWEEN_PROPERTY_CONTAINER_HEIGHT; + tweenPropertyMap_["volume"] = TWEEN_PROPERTY_VOLUME; tweenPropertyMap_["nop"] = TWEEN_PROPERTY_NOP; } diff --git a/RetroFE/Source/Graphics/Animate/TweenTypes.h b/RetroFE/Source/Graphics/Animate/TweenTypes.h index 6526099..764d599 100644 --- a/RetroFE/Source/Graphics/Animate/TweenTypes.h +++ b/RetroFE/Source/Graphics/Animate/TweenTypes.h @@ -62,5 +62,6 @@ enum TweenProperty TWEEN_PROPERTY_CONTAINER_Y, TWEEN_PROPERTY_CONTAINER_WIDTH, TWEEN_PROPERTY_CONTAINER_HEIGHT, + TWEEN_PROPERTY_VOLUME, TWEEN_PROPERTY_NOP, }; diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index de70612..28865c6 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -175,6 +175,7 @@ void Component::update(float dt) currentTweenIndex_ = 0; elapsedTweenTime_ = 0; storeViewInfo_ = baseViewInfo; + storeVolume_ = getVolume(); currentTweenComplete_ = false; } animationRequested_ = false; @@ -194,6 +195,7 @@ void Component::update(float dt) currentTweenIndex_ = 0; elapsedTweenTime_ = 0; storeViewInfo_ = baseViewInfo; + storeVolume_ = getVolume(); currentTweenComplete_ = false; animationRequested_ = false; } @@ -385,6 +387,12 @@ bool Component::animate() baseViewInfo.ContainerHeight = tween->animate(elapsedTime, storeViewInfo_.ContainerHeight); break; + case TWEEN_PROPERTY_VOLUME: + if (tween->startDefined) + setVolume(tween->animate(elapsedTime)); + else + setVolume(tween->animate(elapsedTime, storeVolume_)); + case TWEEN_PROPERTY_NOP: break; } diff --git a/RetroFE/Source/Graphics/Component/Component.h b/RetroFE/Source/Graphics/Component/Component.h index d68a5c2..ab0fd7a 100644 --- a/RetroFE/Source/Graphics/Component/Component.h +++ b/RetroFE/Source/Graphics/Component/Component.h @@ -72,6 +72,7 @@ private: SDL_Texture *backgroundTexture_; ViewInfo storeViewInfo_; + double storeVolume_; unsigned int currentTweenIndex_; bool currentTweenComplete_; float elapsedTweenTime_; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 934455d..92cdc04 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -1428,6 +1428,7 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens) case TWEEN_PROPERTY_FONT_SIZE: case TWEEN_PROPERTY_CONTAINER_Y: case TWEEN_PROPERTY_CONTAINER_HEIGHT: + case TWEEN_PROPERTY_VOLUME: fromValue = getVerticalAlignment(from, 0); toValue = getVerticalAlignment(to, 0); break;