From 69e0a51dd2280b0df687eda601118e65c6c8ce1a Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Tue, 25 Feb 2020 10:17:15 +0100 Subject: [PATCH] clean up the code and add onNewItemSelected when exiting game Signed-off-by: Vincent-FK --- RetroFE/Source/Graphics/Animate/Tween.cpp | 11 ++-- RetroFE/Source/Graphics/Animate/Tween.h | 4 +- RetroFE/Source/Graphics/Animate/TweenTypes.h | 2 +- .../Source/Graphics/Component/Component.cpp | 12 ++--- RetroFE/Source/Graphics/PageBuilder.cpp | 2 +- RetroFE/Source/RetroFE.cpp | 10 ++-- RetroFE/Source/SDL.cpp | 53 ------------------- 7 files changed, 13 insertions(+), 81 deletions(-) diff --git a/RetroFE/Source/Graphics/Animate/Tween.cpp b/RetroFE/Source/Graphics/Animate/Tween.cpp index e992148..73f73a8 100644 --- a/RetroFE/Source/Graphics/Animate/Tween.cpp +++ b/RetroFE/Source/Graphics/Animate/Tween.cpp @@ -29,7 +29,6 @@ Tween::Tween(TweenProperty property, TweenAlgorithm type, double start, double e , type(type) , start(start) , end(end) - , endOriginal(end) { } @@ -50,7 +49,7 @@ bool Tween::getTweenProperty(std::string name, TweenProperty &property) tweenPropertyMap_["yorigin"] = TWEEN_PROPERTY_Y_ORIGIN; tweenPropertyMap_["xoffset"] = TWEEN_PROPERTY_X_OFFSET; tweenPropertyMap_["yoffset"] = TWEEN_PROPERTY_Y_OFFSET; - tweenPropertyMap_["yshiftmenudirection"] = TWEEN_PROPERTY_Y_SHIFT_MENU_DIRECTION; + tweenPropertyMap_["yoffsetshiftmenudirection"] = TWEEN_PROPERTY_Y_OFFSET_SHIFT_MENU_DIRECTION; tweenPropertyMap_["fontSize"] = TWEEN_PROPERTY_FONT_SIZE; tweenPropertyMap_["backgroundalpha"] = TWEEN_PROPERTY_BACKGROUND_ALPHA; tweenPropertyMap_["maxwidth"] = TWEEN_PROPERTY_MAX_WIDTH; @@ -119,12 +118,8 @@ double Tween::getStart( ){ return start; } -double Tween::getOriginalEnd( ){ - return endOriginal; -} - -void Tween::setEnd(double value){ - end = value; +double Tween::getEnd( ){ + return end; } float Tween::animate(double elapsedTime) diff --git a/RetroFE/Source/Graphics/Animate/Tween.h b/RetroFE/Source/Graphics/Animate/Tween.h index 7fbc1f1..a252621 100644 --- a/RetroFE/Source/Graphics/Animate/Tween.h +++ b/RetroFE/Source/Graphics/Animate/Tween.h @@ -35,9 +35,8 @@ public: TweenProperty property; double duration; bool startDefined; - void setEnd(double value); double getStart( ); - double getOriginalEnd( ); + double getEnd( ); private: static double easeInQuadratic(double elapsedTime, double duration, double b, double c); @@ -68,5 +67,4 @@ private: TweenAlgorithm type; double start; double end; - double endOriginal; }; diff --git a/RetroFE/Source/Graphics/Animate/TweenTypes.h b/RetroFE/Source/Graphics/Animate/TweenTypes.h index baadbec..e370d2c 100644 --- a/RetroFE/Source/Graphics/Animate/TweenTypes.h +++ b/RetroFE/Source/Graphics/Animate/TweenTypes.h @@ -53,7 +53,7 @@ enum TweenProperty TWEEN_PROPERTY_Y_ORIGIN, TWEEN_PROPERTY_X_OFFSET, TWEEN_PROPERTY_Y_OFFSET, - TWEEN_PROPERTY_Y_SHIFT_MENU_DIRECTION, + TWEEN_PROPERTY_Y_OFFSET_SHIFT_MENU_DIRECTION, TWEEN_PROPERTY_FONT_SIZE, TWEEN_PROPERTY_BACKGROUND_ALPHA, TWEEN_PROPERTY_MAX_WIDTH, diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index 8f296cf..edbe2af 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -345,7 +345,7 @@ bool Component::animate() baseViewInfo.YOffset = tween->animate(elapsedTime, storeViewInfo_.YOffset); break; - case TWEEN_PROPERTY_Y_SHIFT_MENU_DIRECTION: + case TWEEN_PROPERTY_Y_OFFSET_SHIFT_MENU_DIRECTION: if (tween->startDefined){ /*printf("storeViewInfo_.YOffset = %f, tween->start() = %f, page.isMenuScrollForward()=%d, tween->getEnd()=%f, newEnd=%f\n", storeViewInfo_.YOffset, tween->getStart(), page.isMenuScrollForward(), tween->getOriginalEnd(), @@ -353,12 +353,9 @@ bool Component::animate() /*printf("y_shift_animation, elapsedTime = %f\n", elapsedTime); printf("page.getScrollPeriod() = %f\n", page.getScrollPeriod());*/ - /*tween->setEnd( tween->getStart() + tween->getOriginalEnd()* (static_cast(page.isMenuScrollForward()?-1.0f:1.0f)) ); - baseViewInfo.YOffset = tween->animate(elapsedTime);*/ - baseViewInfo.YOffset = tween->animate(elapsedTime, tween->getStart(), - tween->getStart() + tween->getOriginalEnd()* (static_cast(page.isMenuScrollForward()?-1.0f:1.0f)), + tween->getStart() + tween->getEnd()* (static_cast(page.isMenuScrollForward()?-1.0f:1.0f)), duration); } else{ @@ -367,12 +364,9 @@ bool Component::animate() static_cast(storeViewInfo_.YOffset) + tween->getOriginalEnd()* (static_cast(page.isMenuScrollForward()?-1.0f:1.0f)) ); */ - /*tween->setEnd( static_cast(storeViewInfo_.YOffset) + tween->getOriginalEnd()* (static_cast(page.isMenuScrollForward()?-1.0f:1.0f)) ); - baseViewInfo.YOffset = tween->animate(elapsedTime, storeViewInfo_.YOffset);*/ - baseViewInfo.YOffset = tween->animate(elapsedTime, static_cast(storeViewInfo_.YOffset), - static_cast(storeViewInfo_.YOffset) + tween->getOriginalEnd()* (static_cast(page.isMenuScrollForward()?-1.0f:1.0f)), + static_cast(storeViewInfo_.YOffset) + tween->getEnd()* (static_cast(page.isMenuScrollForward()?-1.0f:1.0f)), duration); } break; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index ead0335..19c5103 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -1492,7 +1492,7 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens) toValue = getVerticalAlignment(to, 0); break; - case TWEEN_PROPERTY_Y_SHIFT_MENU_DIRECTION: + case TWEEN_PROPERTY_Y_OFFSET_SHIFT_MENU_DIRECTION: fromValue = getVerticalAlignment(from, 0); toValue = getVerticalAlignment(to, 0); break; diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index d7d971a..8549525 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -779,6 +779,10 @@ void RetroFE::run( ) launchExit( ); currentPage_->exitGame( ); + // Warning test this + currentPage_->onNewItemSelected( ); + currentPage_->reallocateMenuSpritePoints( ); + state = RETROFE_LAUNCH_EXIT; } break; @@ -787,12 +791,6 @@ void RetroFE::run( ) case RETROFE_LAUNCH_EXIT: if ( currentPage_->isIdle( ) ) { - /********************************/ - /*#warning to remove - //bypass - state = RETROFE_QUIT_REQUEST; - break;*/ - /********************************/ state = RETROFE_IDLE; } break; diff --git a/RetroFE/Source/SDL.cpp b/RetroFE/Source/SDL.cpp index 226c9ae..478faa2 100644 --- a/RetroFE/Source/SDL.cpp +++ b/RetroFE/Source/SDL.cpp @@ -449,58 +449,6 @@ SDL_Surface * SDL::flip_surface( SDL_Surface *surface, int flags ) return flipped; } - - -#if 0 -/// Nearest neighboor optimized with possible out of screen coordinates (for cropping) -void NNOptimized(SDL_Surface *src_surface, SDL_Surface *dst_surface, int new_w, int new_h){ - - /* Declare vars */ - int x_ratio = (int)((src_surface->w <<16)/ new_w); - int y_ratio = (int)((src_surface->h <<16)/ new_h); - int new_w = - int x2, y2; - int i, j; - int rat; - - /* Columns iterations */ - for (i = 0; i < new_h; i++) - { - - /* Out of bounds: h */ - if(i >= dst_surface->h){ - continue; - } - - /* Get current lines in src and dst surfaces */ - uint16_t* t = ( (uint16_t*)dst_surface->pixels + i* ((new_w > dst_surface->w)? dst_surface->w : new_w) ); - y2 = ((i*y_ratio)>>16); - uint16_t* p = ( (uint16_t*)src_surface->pixels + y2*src_surface->w ); - rat = 0; - - /* Lines iterations */ - for (j = 0; j < new_w; j++) - { - /* Out of bounds: w */ - if(j>=dst_surface->w){ - continue; - } - - /* Get current pixel in src surface */ - x2 = (rat>>16); - - /* Copy src pixel in dst surface */ - *t++ = p[x2]; - - /* Update x position in source surface */ - rat += x_ratio; - } - } -} -#endif - - -#if 1 /// Nearest neighboor optimized with possible out of screen coordinates (for cropping) SDL_Surface * SDL::zoomSurface(SDL_Surface *src_surface, SDL_Rect *src_rect_origin, SDL_Rect *dst_rect){ @@ -594,7 +542,6 @@ SDL_Surface * SDL::zoomSurface(SDL_Surface *src_surface, SDL_Rect *src_rect_orig /* Return new zoomed surface */ return dst_surface; } -#endif // Render a copy of a texture