diff --git a/RetroFE/Source/Graphics/Animate/Tween.cpp b/RetroFE/Source/Graphics/Animate/Tween.cpp index 3657892..e992148 100644 --- a/RetroFE/Source/Graphics/Animate/Tween.cpp +++ b/RetroFE/Source/Graphics/Animate/Tween.cpp @@ -29,6 +29,7 @@ Tween::Tween(TweenProperty property, TweenAlgorithm type, double start, double e , type(type) , start(start) , end(end) + , endOriginal(end) { } @@ -49,6 +50,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_["fontSize"] = TWEEN_PROPERTY_FONT_SIZE; tweenPropertyMap_["backgroundalpha"] = TWEEN_PROPERTY_BACKGROUND_ALPHA; tweenPropertyMap_["maxwidth"] = TWEEN_PROPERTY_MAX_WIDTH; @@ -113,6 +115,17 @@ TweenAlgorithm Tween::getTweenType(std::string name) } } +double Tween::getStart( ){ + return start; +} + +double Tween::getOriginalEnd( ){ + return endOriginal; +} + +void Tween::setEnd(double value){ + end = value; +} float Tween::animate(double elapsedTime) { @@ -124,6 +137,11 @@ float Tween::animate(double elapsedTime, double startValue) return animateSingle(type, startValue, end, duration, elapsedTime); } +float Tween::animate(double elapsedTime, double startValue, double endValue, double durationValue) +{ + return animateSingle(type, startValue, endValue, durationValue, elapsedTime); +} + //todo: SDL likes floats, consider having casting being performed elsewhere float Tween::animateSingle(TweenAlgorithm type, double start, double end, double duration, double elapsedTime) { diff --git a/RetroFE/Source/Graphics/Animate/Tween.h b/RetroFE/Source/Graphics/Animate/Tween.h index 3cf440e..7fbc1f1 100644 --- a/RetroFE/Source/Graphics/Animate/Tween.h +++ b/RetroFE/Source/Graphics/Animate/Tween.h @@ -28,12 +28,16 @@ public: Tween(TweenProperty name, TweenAlgorithm type, double start, double end, double duration); float animate(double elapsedTime); float animate(double elapsedTime, double startValue); + float animate(double elapsedTime, double startValue, double endValue, double durationValue); static float animateSingle(TweenAlgorithm type, double start, double end, double duration, double elapsedTime); static TweenAlgorithm getTweenType(std::string name); static bool getTweenProperty(std::string name, TweenProperty &property); TweenProperty property; double duration; bool startDefined; + void setEnd(double value); + double getStart( ); + double getOriginalEnd( ); private: static double easeInQuadratic(double elapsedTime, double duration, double b, double c); @@ -64,4 +68,5 @@ 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 6526099..baadbec 100644 --- a/RetroFE/Source/Graphics/Animate/TweenTypes.h +++ b/RetroFE/Source/Graphics/Animate/TweenTypes.h @@ -53,6 +53,7 @@ enum TweenProperty TWEEN_PROPERTY_Y_ORIGIN, TWEEN_PROPERTY_X_OFFSET, TWEEN_PROPERTY_Y_OFFSET, + TWEEN_PROPERTY_Y_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 8f08dd8..8f296cf 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -256,16 +256,22 @@ bool Component::animate() bool currentDone = true; TweenSet *tweens = currentTweens_->tweenSet(currentTweenIndex_); + for(unsigned int i = 0; i < tweens->size(); i++) { Tween *tween = tweens->tweens()->at(i); double elapsedTime = elapsedTweenTime_; + /* Special case get menu scroll duration if duration specified is 0 */ + double duration = tween->duration ? tween->duration : page.getScrollPeriod(); + //todo: too many levels of nesting - if ( elapsedTime < tween->duration ) + if ( elapsedTime < duration ){ currentDone = false; - else - elapsedTime = static_cast(tween->duration); + } + else{ + elapsedTime = static_cast(duration); + } switch(tween->property) { @@ -339,6 +345,38 @@ bool Component::animate() baseViewInfo.YOffset = tween->animate(elapsedTime, storeViewInfo_.YOffset); break; + case TWEEN_PROPERTY_Y_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(), + tween->getStart() + tween->getOriginalEnd()* (static_cast(page.isMenuScrollForward()?-1.0f:1.0f)) );*/ + /*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)), + duration); + } + else{ + /*printf("storeViewInfo_.YOffset = %f, page.isMenuScrollForward()=%d, tween->getEnd()=%f, newEnd=%f\n", + storeViewInfo_.YOffset, page.isMenuScrollForward(), tween->getOriginalEnd(), + 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)), + duration); + } + break; + case TWEEN_PROPERTY_FONT_SIZE: if (tween->startDefined) baseViewInfo.FontSize = tween->animate(elapsedTime); diff --git a/RetroFE/Source/Graphics/Component/ImageBuilder.cpp b/RetroFE/Source/Graphics/Component/ImageBuilder.cpp index 5008273..c0845aa 100644 --- a/RetroFE/Source/Graphics/Component/ImageBuilder.cpp +++ b/RetroFE/Source/Graphics/Component/ImageBuilder.cpp @@ -33,6 +33,7 @@ Image * ImageBuilder::CreateImage(std::string path, Page &p, std::string name, f std::string prefix = Utils::combinePath(path, name); std::string file; + //printf(" findMatchingFile, prefix = %s, file = %s\n", prefix.c_str(), file.c_str()); if(Utils::findMatchingFile(prefix, extensions, file)) { image = new Image(file, "", p, scaleX, scaleY); diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 8a3c8c2..68262b2 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -40,6 +40,9 @@ ReloadableMedia::ReloadableMedia(Configuration &config, bool systemMode, bool la , isVideo_(isVideo) , FfntInst_(font) , textFallback_(false) + , imageFallback_(false) + , imageAndTextPadding_(0) + , imageAndText_(false) , type_(type) , scaleX_(scaleX) , scaleY_(scaleY) @@ -57,17 +60,36 @@ ReloadableMedia::~ReloadableMedia() } } +void ReloadableMedia::enableImageAndText_(bool value) +{ + imageAndText_ = value; +} + +void ReloadableMedia::setImageAndTextPadding_(float value) +{ + imageAndTextPadding_ = value; +} + void ReloadableMedia::enableTextFallback_(bool value) { textFallback_ = value; } +void ReloadableMedia::enableImageFallback_(bool value) +{ + imageFallback_ = value; +} + void ReloadableMedia::update(float dt) { + + // needs to be ran at the end to prevent the NewItemSelected flag from being detected + Component::update(dt); + + // Reload media if (newItemSelected || (newScrollItemSelected && getMenuScrollReload())) { - reloadTexture(); newItemSelected = false; newScrollItemSelected = false; @@ -86,9 +108,6 @@ void ReloadableMedia::update(float dt) loadedComponent_->update(dt); } - // needs to be ran at the end to prevent the NewItemSelected flag from being detected - Component::update(dt); - } void ReloadableMedia::allocateGraphicsMemory() @@ -379,6 +398,20 @@ void ReloadableMedia::reloadTexture() } } + // if image and artwork was not specified, fall back to displaying text + if(!loadedComponent_ && imageFallback_) + { + //loadedComponent_ = new Text(selectedItem->fullTitle, page, FfntInst_, scaleX_, scaleY_); + /*baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth; + baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;*/ + + std::string imagePath; + ImageBuilder imageBuild; + imagePath = Utils::combinePath(Configuration::absolutePath, "collections", collectionName ); + imagePath = Utils::combinePath( imagePath, "system_artwork" ); + loadedComponent_ = imageBuild.CreateImage( imagePath, page, std::string("fallback"), scaleX_, scaleY_ ); + } + // if image and artwork was not specified, fall back to displaying text if(!loadedComponent_ && textFallback_) { @@ -386,6 +419,12 @@ void ReloadableMedia::reloadTexture() baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth; baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight; } + + /*if(imageAndText_){ + loadedComponent_ = new Text(selectedItem->fullTitle, page, FfntInst_, scaleX_, scaleY_); + baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth; + baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight; + }*/ } diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.h b/RetroFE/Source/Graphics/Component/ReloadableMedia.h index f8057fe..48540ba 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.h +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.h @@ -35,7 +35,10 @@ public: void allocateGraphicsMemory(); Component *findComponent(std::string collection, std::string type, std::string basename, std::string filepath, bool systemMode); + void enableImageAndText_(bool value); + void setImageAndTextPadding_(float value); void enableTextFallback_(bool value); + void enableImageFallback_(bool value); private: void reloadTexture(); @@ -48,7 +51,10 @@ private: IVideo *videoInst_; bool isVideo_; Font *FfntInst_; + bool imageAndText_; + float imageAndTextPadding_; bool textFallback_; + bool imageFallback_; std::string type_; float scaleX_; float scaleY_; diff --git a/RetroFE/Source/Graphics/Component/ReloadableText.cpp b/RetroFE/Source/Graphics/Component/ReloadableText.cpp index c6df57a..a96ce4e 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableText.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableText.cpp @@ -25,7 +25,7 @@ #include #include -ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, std::string singlePrefix, std::string singlePostfix, std::string pluralPrefix, std::string pluralPostfix, float scaleX, float scaleY) +ReloadableText::ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, std::string singlePrefix, std::string singlePostfix, std::string pluralPrefix, std::string pluralPostfix, int displayOffset, float scaleX, float scaleY) : Component(page) , config_(config) , imageInst_(NULL) @@ -38,6 +38,7 @@ ReloadableText::ReloadableText(std::string type, Page &page, Configuration &conf , singlePostfix_(singlePostfix) , pluralPrefix_(pluralPrefix) , pluralPostfix_(pluralPostfix) + , displayOffset_(displayOffset) , scaleX_(scaleX) , scaleY_(scaleY) { @@ -110,7 +111,7 @@ void ReloadableText::ReloadTexture() imageInst_ = NULL; } - Item *selectedItem = page.getSelectedItem(); + Item *selectedItem = page.getSelectedItem( displayOffset_ ); if (selectedItem != NULL) { diff --git a/RetroFE/Source/Graphics/Component/ReloadableText.h b/RetroFE/Source/Graphics/Component/ReloadableText.h index 70f6b0e..3a2fcfd 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableText.h +++ b/RetroFE/Source/Graphics/Component/ReloadableText.h @@ -25,7 +25,7 @@ class ReloadableText : public Component { public: - ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, std::string singlePrefix, std::string singlePostfix, std::string pluralPrefix, std::string pluralPostfix, float scaleX, float scaleY); + ReloadableText(std::string type, Page &page, Configuration &config, Font *font, std::string layoutKey, std::string timeFormat, std::string textFormat, std::string singlePrefix, std::string singlePostfix, std::string pluralPrefix, std::string pluralPostfix, int displayOffset, float scaleX, float scaleY); virtual ~ReloadableText(); void update(float dt); void draw(); @@ -48,6 +48,7 @@ private: std::string singlePostfix_; std::string pluralPrefix_; std::string pluralPostfix_; + int displayOffset_; float scaleX_; float scaleY_; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index c4d5c2a..b783c83 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -60,7 +60,9 @@ ScrollingList::ScrollingList( Configuration &c, , selectedOffsetIndex_( 0 ) , scrollAcceleration_( 0 ) , startScrollTime_( 0.500 ) + , scrollDirectionForward_( false ) , scrollPeriod_( 0 ) + , scrollAccelerationIdx_( 0 ) , config_( c ) , scaleX_( scaleX ) , scaleY_( scaleY ) @@ -125,7 +127,7 @@ unsigned int ScrollingList::loopIncrement( unsigned int offset, unsigned int i, unsigned int ScrollingList::loopDecrement( unsigned int offset, unsigned int i, unsigned int size ) { if ( size == 0 ) return 0; - return ((offset % size ) - (i % size ) + size ) % size; + return ((offset % size ) - (i % size ) + size ) % size; } @@ -247,7 +249,7 @@ Item *ScrollingList::getItemByOffset( int offset ) { index = loopDecrement( index, offset*-1, items_->size( ) ); } - + return items_->at( index ); } @@ -359,7 +361,7 @@ void ScrollingList::freeGraphicsMemory( ) { Component::freeGraphicsMemory( ); scrollPeriod_ = 0; - + deallocateSpritePoints( ); } @@ -620,6 +622,7 @@ bool ScrollingList::allocateTexture( unsigned int index, Item *item ) imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", "_common"); else imagePath = Utils::combinePath( Configuration::absolutePath, "layouts", layoutName, "collections", collectionName ); + imagePath = Utils::combinePath( imagePath, "medium_artwork", imageType_ ); } else @@ -633,6 +636,7 @@ bool ScrollingList::allocateTexture( unsigned int index, Item *item ) config_.getMediaPropertyAbsolutePath( collectionName, imageType_, false, imagePath ); } t = imageBuild.CreateImage( imagePath, page, names[n], scaleX_, scaleY_ ); + // check sub-collection path for art if ( !t && !commonMode_ ) { @@ -654,10 +658,12 @@ bool ScrollingList::allocateTexture( unsigned int index, Item *item ) { if ( layoutMode_ ) { - if ( commonMode_ ) + if ( commonMode_ ){ imagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", "_common"); - else + } + else{ imagePath = Utils::combinePath( Configuration::absolutePath, "layouts", layoutName, "collections", item->name ); + } imagePath = Utils::combinePath( imagePath, "system_artwork" ); } else @@ -667,15 +673,24 @@ bool ScrollingList::allocateTexture( unsigned int index, Item *item ) imagePath = Utils::combinePath(Configuration::absolutePath, "collections", "_common" ); imagePath = Utils::combinePath( imagePath, "system_artwork" ); } - else + else{ config_.getMediaPropertyAbsolutePath( item->name, imageType_, true, imagePath ); + } } t = imageBuild.CreateImage( imagePath, page, imageType_, scaleX_, scaleY_ ); } // check rom directory path for art - if ( !t ) + if ( !t ){ t = imageBuild.CreateImage( item->filepath, page, imageType_, scaleX_, scaleY_ ); + } + + // Image fallback + if ( !t && imageType_.compare(std::string("null"))){ + imagePath = Utils::combinePath(Configuration::absolutePath, "collections", collectionName ); + imagePath = Utils::combinePath( imagePath, "system_artwork" ); + t = imageBuild.CreateImage( imagePath, page, std::string("fallback"), scaleX_, scaleY_ ); + } if ( !t ) { @@ -712,7 +727,7 @@ void ScrollingList::draw( ) void ScrollingList::draw( unsigned int layer ) { - + if ( components_.size( ) == 0 ) return; for ( unsigned int i = 0; i < components_.size( ); ++i ) @@ -737,8 +752,21 @@ bool ScrollingList::isIdle( ) } +bool ScrollingList::getScrollDirectionForward( ) +{ + return scrollDirectionForward_; +} + + +float ScrollingList::getScrollPeriod( ) +{ + return scrollPeriod_; +} + + void ScrollingList::resetScrollPeriod( ) { + scrollAccelerationIdx_ = 0; scrollPeriod_ = startScrollTime_; return; } @@ -746,11 +774,40 @@ void ScrollingList::resetScrollPeriod( ) void ScrollingList::updateScrollPeriod( ) { + //printf("update Scroll Period: %d\n", scrollAccelerationIdx_); scrollPeriod_ -= scrollAcceleration_; if ( scrollPeriod_ < scrollAcceleration_ ) { + //printf(" Very fast scroll\n"); scrollPeriod_ = scrollAcceleration_; } + else{ + scrollAccelerationIdx_++; + } + +#if 0 + /* Send fast scroll event if long press detected */ + if(scrollAccelerationIdx_ >= 2){ + for ( unsigned int i = 0; i < scrollPoints_->size( ); i++ ) + { + unsigned int nextI; + if ( scrollDirectionForward_ ) + { + nextI = loopDecrement( i, 1, scrollPoints_->size( ) ); + } + else + { + nextI = loopIncrement( i, 1, scrollPoints_->size( ) ); + } + + Component *c = components_.at( i ); + + resetTweens( c, tweenPoints_->at( nextI ), scrollPoints_->at( i ), scrollPoints_->at( nextI ), scrollPeriod_ ); + c->baseViewInfo.font = scrollPoints_->at( nextI )->font; // Use the font settings of the next index + c->triggerEvent( "menuFastScroll" ); + } + } +#endif } @@ -763,6 +820,7 @@ void ScrollingList::scroll( bool forward ) // Replace the item that's scrolled out if ( forward ) { + scrollDirectionForward_ = true; Item *i = items_->at( loopIncrement( itemIndex_, scrollPoints_->size( ), items_->size( ) ) ); itemIndex_ = loopIncrement( itemIndex_, 1, items_->size( ) ); deallocateTexture( 0 ); @@ -770,6 +828,7 @@ void ScrollingList::scroll( bool forward ) } else { + scrollDirectionForward_ = false; Item *i = items_->at( loopDecrement( itemIndex_, 1, items_->size( ) ) ); itemIndex_ = loopDecrement( itemIndex_, 1, items_->size( ) ); deallocateTexture( loopDecrement( 0, 1, components_.size( ) ) ); @@ -806,7 +865,7 @@ void ScrollingList::scroll( bool forward ) Component *store = components_.at( prevI ); components_[prevI] = c; c = store; - + } } else @@ -817,7 +876,7 @@ void ScrollingList::scroll( bool forward ) Component *store = components_.at( nextI ); components_[nextI] = c; c = store; - + } } diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index b5a78ef..978aa13 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -73,6 +73,8 @@ public: void letterChange( bool increment ); void random( ); bool isIdle( ); + bool getScrollDirectionForward( ); + float getScrollPeriod( ); unsigned int getScrollOffsetIndex( ); void setScrollOffsetIndex( unsigned int index ); void setSelectedIndex( int selectedIndex ); @@ -110,6 +112,7 @@ private: float scrollAcceleration_; float startScrollTime_; float scrollPeriod_; + int scrollAccelerationIdx_; Configuration &config_; float scaleX_; @@ -121,4 +124,5 @@ private: std::vector *items_; std::vector components_; + bool scrollDirectionForward_; }; diff --git a/RetroFE/Source/Graphics/Component/Text.cpp b/RetroFE/Source/Graphics/Component/Text.cpp index 1b1fff3..afb7b69 100644 --- a/RetroFE/Source/Graphics/Component/Text.cpp +++ b/RetroFE/Source/Graphics/Component/Text.cpp @@ -107,18 +107,22 @@ void Text::draw( ) Font::GlyphInfo glyph; if ( font->getRect( textData_[i], glyph ) ) { + SDL_Rect charRect = glyph.rect; + //charRect.w = static_cast( glyph.advance ); + charRect.w = static_cast( glyph.rect.w?glyph.rect.w:glyph.advance ); + if ( glyph.minX < 0 ) { imageWidth += glyph.minX; } - if ( (imageWidth + glyph.advance)*scale > imageMaxWidth ) + if ( (imageWidth + charRect.w)*scale > imageMaxWidth ) { break; } textIndexMax = i; - imageWidth += glyph.advance; + imageWidth += charRect.w; /*printf("textData_[%d]=%c, glyph.advance= %f - %d\n", i, textData_[i], glyph.advance, glyph.advance); printf("imageWidth=%f \n", imageWidth);*/ @@ -163,7 +167,7 @@ void Text::draw( ) { SDL_Rect charRect = glyph.rect; float h = static_cast( charRect.h * scale ); - float w = static_cast( charRect.w * scale ); + float w = static_cast( (charRect.w?charRect.w:glyph.advance) * scale ); rect.h = static_cast( h ); rect.w = static_cast( w ); rect.y = static_cast( yOrigin ); @@ -182,8 +186,7 @@ void Text::draw( ) SDL::renderCopy( t, baseViewInfo.Alpha, &charRect, &rect, baseViewInfo ); - rect.x += static_cast( glyph.advance * scale ); - + rect.x += rect.w; } } } diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 66d51ec..93c8708 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -32,7 +32,9 @@ Page::Page(Configuration &config) : config_(config) , menuDepth_(0) , scrollActive_(false) + , scrollDirectionForward_(false) , selectedItem_(NULL) + , selectNextItemAfterScroll_(false) , textStatusComponent_(NULL) , loadSoundChunk_(NULL) , unloadSoundChunk_(NULL) @@ -166,14 +168,17 @@ void Page::onNewItemSelected() void Page::onNewScrollItemSelected() { - if(!(activeMenu_.size() > 0 && activeMenu_[0])) return; - selectedItem_ = activeMenu_[0]->getSelectedItem(); + if(selectNextItemAfterScroll_){ + if(!(activeMenu_.size() > 0 && activeMenu_[0])) return; + selectedItem_ = activeMenu_[0]->getSelectedItem(); - for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) - { - (*it)->setNewScrollItemSelected(); - } + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->setNewScrollItemSelected(); + } + selectNextItemAfterScroll_ = false; + } } @@ -434,6 +439,19 @@ void Page::menuScroll() } +void Page::menuFastScroll() +{ + Item *item = selectedItem_; + + if(!item) return; + + for(std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent( "menuFastScroll", menuDepth_ - 1 ); + } +} + + void Page::highlightEnter() { Item *item = selectedItem_; @@ -647,14 +665,22 @@ void Page::setScrolling(ScrollDirection direction) { menuScroll(); } + else{ + menuFastScroll(); + } scrollActive_ = true; + scrollDirectionForward_=true; break; case ScrollDirectionBack: if(!scrollActive_) { menuScroll(); } + else{ + menuFastScroll(); + } scrollActive_ = true; + scrollDirectionForward_=false; break; case ScrollDirectionIdle: default: @@ -1293,6 +1319,11 @@ bool Page::isMenuScrolling() return scrollActive_; } +bool Page::isMenuScrollForward() +{ + return scrollDirectionForward_; +} + bool Page::isPlaying() { @@ -1320,6 +1351,17 @@ void Page::resetScrollPeriod() } +float Page::getScrollPeriod() +{ + for(std::vector::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++) + { + ScrollingList *menu = *it; + if(menu) return menu->getScrollPeriod(); + } + return 0; +} + + void Page::updateScrollPeriod() { for(std::vector::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++) @@ -1333,6 +1375,14 @@ void Page::updateScrollPeriod() void Page::scroll(bool forward) { + + // Select next item + onNewScrollItemSelected(); + + // Set flag for notifying a new selected item after next update() + selectNextItemAfterScroll_ = true; + + // Change scroll index for(std::vector::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++) { ScrollingList *menu = *it; @@ -1341,7 +1391,7 @@ void Page::scroll(bool forward) menu->scroll(forward); } } - onNewScrollItemSelected(); + if(highlightSoundChunk_) { highlightSoundChunk_->play(); diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 21bff55..67de70e 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -97,6 +97,7 @@ public: void setMinShowTime(float value); float getMinShowTime(); void menuScroll(); + void menuFastScroll(); void highlightEnter(); void highlightExit(); void playlistEnter(); @@ -109,8 +110,10 @@ public: void removePlaylist(); void reallocateMenuSpritePoints(); bool isMenuScrolling(); + bool isMenuScrollForward(); bool isPlaying(); void resetScrollPeriod(); + float getScrollPeriod(); void updateScrollPeriod(); void scroll(bool forward); @@ -141,6 +144,8 @@ private: std::list deleteCollectionList_; bool scrollActive_; + bool scrollDirectionForward_; + bool selectNextItemAfterScroll_; Item *selectedItem_; Text *textStatusComponent_; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index d2660e7..e07d668 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -351,7 +351,9 @@ float PageBuilder::getVerticalAlignment(xml_attribute<> *attribute, float valueI } else { + //printf(" Utils::convertFloat(str)=%f, scaleY_=%f\n", Utils::convertFloat(str), scaleY_); value = Utils::convertFloat(str) * scaleY_; + //printf(" value=%f\n", value); } } return value; @@ -658,7 +660,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName, { pluralPostfix = pluralPostfixXml->value(); } - c = new ReloadableText(type->value(), *page, config_, font, layoutKey, timeFormat, textFormat, singlePrefix, singlePostfix, pluralPrefix, pluralPostfix, scaleX_, scaleY_); + c = new ReloadableText(type->value(), *page, config_, font, layoutKey, timeFormat, textFormat, singlePrefix, singlePostfix, pluralPrefix, pluralPostfix, selectedOffset, scaleX_, scaleY_); c->setId( id ); xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload"); if (menuScrollReload && @@ -739,7 +741,6 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName, { c->setMenuScrollReload(true); } - c->allocateGraphicsMemory( ); } } else @@ -754,6 +755,24 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName, { c->setMenuScrollReload(true); } + xml_attribute<> *imageAndText = componentXml->first_attribute("imageAndText"); + if(imageAndText && Utils::toLower(imageAndText->value()) == "true") + { + static_cast(c)->enableImageAndText_(true); + } + else + { + static_cast(c)->enableImageAndText_(false); + } + xml_attribute<> *imageAndTextPadding = componentXml->first_attribute("imageAndTextPadding"); + if(imageAndTextPadding) + { + static_cast(c)->setImageAndTextPadding_( Utils::convertFloat(imageAndTextPadding->value()) ); + } + else + { + static_cast(c)->enableImageAndText_(false); + } xml_attribute<> *textFallback = componentXml->first_attribute("textFallback"); if(textFallback && Utils::toLower(textFallback->value()) == "true") { @@ -763,6 +782,15 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName, { static_cast(c)->enableTextFallback_(false); } + xml_attribute<> *imageFallback = componentXml->first_attribute("imageFallback"); + if(imageFallback && Utils::toLower(imageFallback->value()) == "true") + { + static_cast(c)->enableImageFallback_(true); + } + else + { + static_cast(c)->enableImageFallback_(false); + } } if(c) @@ -852,6 +880,7 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) buildTweenSet(tweens, componentXml, "onIdle", "idle"); buildTweenSet(tweens, componentXml, "onMenuIdle", "menuIdle"); buildTweenSet(tweens, componentXml, "onMenuScroll", "menuScroll"); + buildTweenSet(tweens, componentXml, "onMenuFastScroll", "menuFastScroll"); buildTweenSet(tweens, componentXml, "onHighlightEnter", "highlightEnter"); buildTweenSet(tweens, componentXml, "onHighlightExit", "highlightExit"); buildTweenSet(tweens, componentXml, "onMenuEnter", "menuEnter"); @@ -1385,7 +1414,8 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens) { toValue = Utils::convertFloat(to->value()); } - float durationValue = Utils::convertFloat(durationXml->value()); + float durationValue = 0; + durationValue = Utils::convertFloat(durationXml->value()); TweenAlgorithm algorithm = LINEAR; TweenProperty property; @@ -1425,6 +1455,11 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens) toValue = getVerticalAlignment(to, 0); break; + case TWEEN_PROPERTY_Y_SHIFT_MENU_DIRECTION: + fromValue = getVerticalAlignment(from, 0); + toValue = getVerticalAlignment(to, 0); + break; + // y origin gets translated to a percent case TWEEN_PROPERTY_Y_ORIGIN: fromValue = getVerticalAlignment(from, 0) / screenHeight_; @@ -1433,8 +1468,9 @@ void PageBuilder::getAnimationEvents(xml_node<> *node, TweenSet &tweens) case TWEEN_PROPERTY_MAX_WIDTH: case TWEEN_PROPERTY_MAX_HEIGHT: - fromValue = getVerticalAlignment(from, FLT_MAX); - toValue = getVerticalAlignment(to, FLT_MAX); + fromValue = getVerticalAlignment(from, FLT_MAX); + toValue = getVerticalAlignment(to, FLT_MAX); + break; default: break; diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 5ce76a3..2c0e45f 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -625,6 +625,7 @@ void RetroFE::run( ) // Start onHighlightEnter animation case RETROFE_HIGHLIGHT_LOAD_ART: currentPage_->highlightEnter( ); + currentPage_->onNewScrollItemSelected( ); state = RETROFE_HIGHLIGHT_ENTER; break;