From 05f26e9d0608a74950dea0be0290a0dbd5f5f67c Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Wed, 21 Jun 2017 15:52:48 +0200 Subject: [PATCH] Added onMenuIdle animation type, which will continuously be activated while the menu isn't scrolling. --- .../Source/Graphics/Component/Component.cpp | 36 +++++++++++-------- RetroFE/Source/Graphics/PageBuilder.cpp | 19 +++++----- RetroFE/Source/Version.cpp | 2 +- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index 45373f7..7520188 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -36,7 +36,7 @@ Component::Component(const Component ©) backgroundTexture_ = NULL; freeGraphicsMemory(); - if(copy.tweens_) + if ( copy.tweens_ ) { AnimationEvents *tweens = new AnimationEvents(*copy.tweens_); setTweens(tweens); @@ -63,7 +63,7 @@ void Component::freeGraphicsMemory() currentTweenComplete_ = true; elapsedTweenTime_ = 0; - if(backgroundTexture_) + if ( backgroundTexture_ ) { SDL_LockMutex(SDL::getMutex()); SDL_DestroyTexture(backgroundTexture_); @@ -74,7 +74,7 @@ void Component::freeGraphicsMemory() } void Component::allocateGraphicsMemory() { - if(!backgroundTexture_) + if ( !backgroundTexture_ ) { // make a 4x4 pixel wide surface to be stretched during rendering, make it a white background so we can use // color later @@ -109,7 +109,7 @@ void Component::setNewItemSelected() bool Component::isIdle() { - return (currentTweenComplete_ || animationType_ == "idle"); + return (currentTweenComplete_ || animationType_ == "idle" || animationType_ == "menuIdle"); } bool Component::isMenuScrolling() @@ -126,15 +126,15 @@ void Component::update(float dt) { elapsedTweenTime_ += dt; - if(animationRequested_ && animationRequestedType_ != "") + if ( animationRequested_ && animationRequestedType_ != "" ) { Animation *newTweens; // Check if this component is part of an active scrolling list - if(menuIndex_ >= MENU_INDEX_HIGH) + if ( menuIndex_ >= MENU_INDEX_HIGH ) { // Check for animation at index i newTweens = tweens_->getAnimation( animationRequestedType_, MENU_INDEX_HIGH ); - if(!(newTweens && newTweens->size() > 0)) + if ( !(newTweens && newTweens->size() > 0) ) { // Check for animation at the current menuIndex newTweens = tweens_->getAnimation( animationRequestedType_, menuIndex_ - MENU_INDEX_HIGH); @@ -160,6 +160,14 @@ void Component::update(float dt) { animationType_ = "idle"; currentTweens_ = tweens_->getAnimation( "idle", menuIndex_ ); + if ( currentTweens_ && currentTweens_->size( ) == 0 && !page.isMenuScrolling( ) ) + { + currentTweens_ = tweens_->getAnimation( "menuIdle", menuIndex_ ); + if ( currentTweens_ && currentTweens_->size( ) > 0 ) + { + currentTweens_ = currentTweens_; + } + } currentTweenIndex_ = 0; elapsedTweenTime_ = 0; storeViewInfo_ = baseViewInfo; @@ -168,7 +176,7 @@ void Component::update(float dt) } currentTweenComplete_ = animate(); - if(currentTweenComplete_) + if ( currentTweenComplete_ ) { currentTweens_ = NULL; currentTweenIndex_ = 0; @@ -178,7 +186,7 @@ void Component::update(float dt) void Component::draw() { - if(backgroundTexture_) + if ( backgroundTexture_ ) { SDL_Rect rect; rect.h = static_cast(baseViewInfo.ScaledHeight()); @@ -199,11 +207,11 @@ void Component::draw() bool Component::animate() { bool completeDone = false; - if(!currentTweens_ || currentTweenIndex_ >= currentTweens_->size()) + if ( !currentTweens_ || currentTweenIndex_ >= currentTweens_->size() ) { completeDone = true; } - else if(currentTweens_) + else if ( currentTweens_ ) { bool currentDone = true; TweenSet *tweens = currentTweens_->tweenSet(currentTweenIndex_); @@ -214,7 +222,7 @@ bool Component::animate() double elapsedTime = elapsedTweenTime_; //todo: too many levels of nesting - if(elapsedTime < tween->duration) + if ( elapsedTime < tween->duration ) currentDone = false; else elapsedTime = static_cast(tween->duration); @@ -359,7 +367,7 @@ bool Component::animate() } } - if(currentDone) + if ( currentDone ) { currentTweenIndex_++; elapsedTweenTime_ = 0; @@ -367,7 +375,7 @@ bool Component::animate() } } - if(!currentTweens_ || currentTweenIndex_ >= currentTweens_->tweenSets()->size()) + if ( !currentTweens_ || currentTweenIndex_ >= currentTweens_->tweenSets()->size() ) { completeDone = true; } diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 95a7754..e024a1f 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -723,16 +723,17 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) { AnimationEvents *tweens = new AnimationEvents(); - buildTweenSet(tweens, componentXml, "onEnter", "enter"); - buildTweenSet(tweens, componentXml, "onExit", "exit"); - buildTweenSet(tweens, componentXml, "onIdle", "idle"); - buildTweenSet(tweens, componentXml, "onMenuScroll", "menuScroll"); + buildTweenSet(tweens, componentXml, "onEnter", "enter"); + buildTweenSet(tweens, componentXml, "onExit", "exit"); + buildTweenSet(tweens, componentXml, "onIdle", "idle"); + buildTweenSet(tweens, componentXml, "onMenuIdle", "menuIdle"); + buildTweenSet(tweens, componentXml, "onMenuScroll", "menuScroll"); buildTweenSet(tweens, componentXml, "onHighlightEnter", "highlightEnter"); - buildTweenSet(tweens, componentXml, "onHighlightExit", "highlightExit"); - buildTweenSet(tweens, componentXml, "onMenuEnter", "menuEnter"); - buildTweenSet(tweens, componentXml, "onMenuExit", "menuExit"); - buildTweenSet(tweens, componentXml, "onGameEnter", "gameEnter"); - buildTweenSet(tweens, componentXml, "onGameExit", "gameExit"); + buildTweenSet(tweens, componentXml, "onHighlightExit", "highlightExit"); + buildTweenSet(tweens, componentXml, "onMenuEnter", "menuEnter"); + buildTweenSet(tweens, componentXml, "onMenuExit", "menuExit"); + buildTweenSet(tweens, componentXml, "onGameEnter", "gameEnter"); + buildTweenSet(tweens, componentXml, "onGameExit", "gameExit"); return tweens; } diff --git a/RetroFE/Source/Version.cpp b/RetroFE/Source/Version.cpp index 4b17a6e..9ea280d 100644 --- a/RetroFE/Source/Version.cpp +++ b/RetroFE/Source/Version.cpp @@ -21,7 +21,7 @@ std::string retrofe_version_major = "0"; std::string retrofe_version_minor = "8"; -std::string retrofe_version_build = "8"; +std::string retrofe_version_build = "9"; std::string Version::getString( )