mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-26 17:54:46 +01:00
clean up the code and add onNewItemSelected when exiting game
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
785449ec2a
commit
69e0a51dd2
@ -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)
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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<double>(page.isMenuScrollForward()?-1.0f:1.0f)) );
|
||||
baseViewInfo.YOffset = tween->animate(elapsedTime);*/
|
||||
|
||||
baseViewInfo.YOffset = tween->animate(elapsedTime,
|
||||
tween->getStart(),
|
||||
tween->getStart() + tween->getOriginalEnd()* (static_cast<double>(page.isMenuScrollForward()?-1.0f:1.0f)),
|
||||
tween->getStart() + tween->getEnd()* (static_cast<double>(page.isMenuScrollForward()?-1.0f:1.0f)),
|
||||
duration);
|
||||
}
|
||||
else{
|
||||
@ -367,12 +364,9 @@ bool Component::animate()
|
||||
static_cast<double>(storeViewInfo_.YOffset) + tween->getOriginalEnd()* (static_cast<double>(page.isMenuScrollForward()?-1.0f:1.0f)) );
|
||||
*/
|
||||
|
||||
/*tween->setEnd( static_cast<double>(storeViewInfo_.YOffset) + tween->getOriginalEnd()* (static_cast<double>(page.isMenuScrollForward()?-1.0f:1.0f)) );
|
||||
baseViewInfo.YOffset = tween->animate(elapsedTime, storeViewInfo_.YOffset);*/
|
||||
|
||||
baseViewInfo.YOffset = tween->animate(elapsedTime,
|
||||
static_cast<double>(storeViewInfo_.YOffset),
|
||||
static_cast<double>(storeViewInfo_.YOffset) + tween->getOriginalEnd()* (static_cast<double>(page.isMenuScrollForward()?-1.0f:1.0f)),
|
||||
static_cast<double>(storeViewInfo_.YOffset) + tween->getEnd()* (static_cast<double>(page.isMenuScrollForward()?-1.0f:1.0f)),
|
||||
duration);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user