From ff215dccbae348845727503a906dd485e7f3485e Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Tue, 9 May 2023 20:47:31 -0700 Subject: [PATCH 1/9] don't cycle playlist if on "street fighter and capcom fighters" or "street fighter" --- RetroFE/Source/Graphics/Page.cpp | 14 ++++----- RetroFE/Source/RetroFE.cpp | 52 ++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 4c9da3998..5941a9945 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -1513,13 +1513,13 @@ void Page::togglePlaylist() { if (!selectedItem_) return; -if(playlist_->first != "favorites") - { - if (selectedItem_->isFavorite) - removePlaylist(); - else - addPlaylist(); - } + if (playlist_->first != "favorites") + { + if (selectedItem_->isFavorite) + removePlaylist(); + else + addPlaylist(); + } } diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 599edec81..d04e3af2a 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -1596,24 +1596,33 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page ) else if ( input_.keystate(UserInput::KeyCodeCyclePlaylist) || input_.keystate(UserInput::KeyCodeNextCyclePlaylist) ) { - attract_.reset( ); - std::string cycleString; - config_.getProperty( "cyclePlaylist", cycleString ); - std::vector cycleVector; - Utils::listToVector( cycleString, cycleVector, ',' ); - page->nextCyclePlaylist( cycleVector ); - state = RETROFE_PLAYLIST_REQUEST; + if (currentPage_->getPlaylistName() != "street fighter and capcom fighters" && + currentPage_->getPlaylistName() != "street fighter") + { + attract_.reset(); + std::string cycleString; + config_.getProperty("cyclePlaylist", cycleString); + std::vector cycleVector; + Utils::listToVector(cycleString, cycleVector, ','); + page->nextCyclePlaylist(cycleVector); + state = RETROFE_PLAYLIST_REQUEST; + + } } else if ( input_.keystate(UserInput::KeyCodePrevCyclePlaylist) ) { - attract_.reset( ); - std::string cycleString; - config_.getProperty( "cyclePlaylist", cycleString ); - std::vector cycleVector; - Utils::listToVector( cycleString, cycleVector, ',' ); - page->prevCyclePlaylist( cycleVector ); - state = RETROFE_PLAYLIST_REQUEST; + if (currentPage_->getPlaylistName() != "street fighter and capcom fighters" && + currentPage_->getPlaylistName() != "street fighter") + { + attract_.reset(); + std::string cycleString; + config_.getProperty("cyclePlaylist", cycleString); + std::vector cycleVector; + Utils::listToVector(cycleString, cycleVector, ','); + page->prevCyclePlaylist(cycleVector); + state = RETROFE_PLAYLIST_REQUEST; + } } else if ( input_.keystate(UserInput::KeyCodeRemovePlaylist) ) @@ -1632,15 +1641,12 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page ) else if ( input_.keystate(UserInput::KeyCodeTogglePlaylist) ) { - if (currentPage_->getPlaylistName() == "favorites" ) -{ -} -else -{ - attract_.reset( ); - page->togglePlaylist( ); - state = RETROFE_PLAYLIST_REQUEST; -} + if (currentPage_->getPlaylistName() != "favorites" ) + { + attract_.reset( ); + page->togglePlaylist( ); + state = RETROFE_PLAYLIST_REQUEST; + } } else if ( input_.keystate(UserInput::KeyCodeSkipForward) ) From 62bf36c213cc441578fb200be295fd8528b35b45 Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Tue, 23 May 2023 21:37:24 -0700 Subject: [PATCH 2/9] lower errors to warnings in logs --- RetroFE/Source/Graphics/Font.cpp | 2 +- RetroFE/Source/RetroFE.cpp | 2 +- RetroFE/Source/Sound/Sound.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RetroFE/Source/Graphics/Font.cpp b/RetroFE/Source/Graphics/Font.cpp index b0781439e..7a1d2903c 100644 --- a/RetroFE/Source/Graphics/Font.cpp +++ b/RetroFE/Source/Graphics/Font.cpp @@ -72,7 +72,7 @@ bool Font::initialize() { std::stringstream ss; ss << "Could not open font: " << TTF_GetError(); - Logger::write(Logger::ZONE_ERROR, "FontCache", ss.str()); + Logger::write(Logger::ZONE_WARNING, "FontCache", ss.str()); return false; } diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index ab62eadb5..e78c8c4a0 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -314,7 +314,7 @@ bool RetroFE::run( ) // Define control configuration std::string controlsConfPath = Utils::combinePath( Configuration::absolutePath, "controls" ); for (int i = 9; i > 0; i--) - config_.import("controls", controlsConfPath + std::to_string(i) + ".conf"); + config_.import("controls", controlsConfPath + std::to_string(i) + ".conf", false); config_.import("controls", controlsConfPath + ".conf"); if (config_.propertiesEmpty()) diff --git a/RetroFE/Source/Sound/Sound.cpp b/RetroFE/Source/Sound/Sound.cpp index 8ff39b04a..8556b7cf2 100644 --- a/RetroFE/Source/Sound/Sound.cpp +++ b/RetroFE/Source/Sound/Sound.cpp @@ -28,7 +28,7 @@ Sound::Sound(std::string file, std::string altfile) file_ = altfile; if (!allocate()) { - Logger::write(Logger::ZONE_ERROR, "Sound", "Cannot load " + file_); + Logger::write(Logger::ZONE_WARNING, "Sound", "Cannot load " + file_); } } } From 167b0896ff1b72f987ff7adcad77c0d510214886 Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Tue, 23 May 2023 22:21:00 -0700 Subject: [PATCH 3/9] intital --- RetroFE/Build/CHANGELOG | 1 + .../Graphics/Component/ScrollingList.cpp | 22 +++++++++++++++++++ .../Source/Graphics/Component/ScrollingList.h | 1 + RetroFE/Source/Graphics/Page.h | 2 ++ RetroFE/Source/Graphics/PageBuilder.cpp | 2 ++ 5 files changed, 28 insertions(+) diff --git a/RetroFE/Build/CHANGELOG b/RetroFE/Build/CHANGELOG index 230bc8c98..e8433f5e0 100644 --- a/RetroFE/Build/CHANGELOG +++ b/RetroFE/Build/CHANGELOG @@ -33,3 +33,4 @@ v0.10.34.1 - added playlistNextEnter/Exit and playlistPrevEnter/Exit layout events upon playlist navigation changes (monkofthefunk) - fixed removed playlistNextEnter from fav toggle; ensured other RETROFE_PLAYLIST_REQUEST didn't trigger playlistNext/PrevExit events (monkofthefunk) - fixed showing playlist menu upon item fav toggle and letter jump/random (don't trigger on playlist enter events) (monkofthefunk) + - added \ No newline at end of file diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index a3caa8d0f..3e3ff974c 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -1074,6 +1074,17 @@ void ScrollingList::updateScrollPeriod( ) if ( scrollPeriod_ < minScrollTime_ ) { scrollPeriod_ = minScrollTime_; + + if (!menuFastScrollEntered_) { + menuFastScrollEntered_ = true; + triggerEventOnAll("menuFastScrollEnter", 0); + } + } + else { + if (menuFastScrollEntered_) { + menuFastScrollEntered_ = false; + triggerEventOnAll("menuFastScrollExit", 0); + } } } @@ -1090,6 +1101,17 @@ void ScrollingList::scroll( bool forward ) if ( scrollPeriod_ < minScrollTime_ ) { scrollPeriod_ = minScrollTime_; + + if (!menuFastScrollEntered_) { + menuFastScrollEntered_ = true; + triggerEventOnAll("menuFastScrollEnter", 0); + } + } + else { + if (menuFastScrollEntered_) { + menuFastScrollEntered_ = false; + triggerEventOnAll("menuFastScrollExit", 0); + } } // Replace the item that's scrolled out diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 5cfc83ddf..32d982312 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -119,6 +119,7 @@ class ScrollingList : public Component bool commonMode_; bool playlistType_; bool selectedImage_; + bool menuFastScrollEntered_ = false; std::vector *spriteList_; std::vector *scrollPoints_; diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index 70e3b5a10..f5ac6d236 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -108,6 +108,8 @@ class Page void setMinShowTime(float value); float getMinShowTime(); void menuScroll(); + void menuFastScrollEnter(); + void menuFastScrollExit(); void highlightEnter(); void highlightExit(); void playlistEnter(); diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 0272cb035..17256b282 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -877,6 +877,8 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) buildTweenSet(tweens, componentXml, "onIdle", "idle"); buildTweenSet(tweens, componentXml, "onMenuIdle", "menuIdle"); buildTweenSet(tweens, componentXml, "onMenuScroll", "menuScroll"); + buildTweenSet(tweens, componentXml, "onMenuFastScrollEnter", "menuFastScrollEnter"); + buildTweenSet(tweens, componentXml, "onMenuFastScrollExit", "menuFastScrollExit"); buildTweenSet(tweens, componentXml, "onHighlightEnter", "highlightEnter"); buildTweenSet(tweens, componentXml, "onHighlightExit", "highlightExit"); buildTweenSet(tweens, componentXml, "onMenuEnter", "menuEnter"); From 14728bed652eef206c032d3fed30f164f7d7a704 Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Wed, 24 May 2023 08:02:21 -0700 Subject: [PATCH 4/9] saving prgress --- .../Graphics/Component/ScrollingList.cpp | 20 +++++-------------- RetroFE/Source/RetroFE.cpp | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 3e3ff974c..3784a6893 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -1074,10 +1074,11 @@ void ScrollingList::updateScrollPeriod( ) if ( scrollPeriod_ < minScrollTime_ ) { scrollPeriod_ = minScrollTime_; - - if (!menuFastScrollEntered_) { - menuFastScrollEntered_ = true; - triggerEventOnAll("menuFastScrollEnter", 0); + if (scrollPeriod_ != 0) { + if (!menuFastScrollEntered_) { + menuFastScrollEntered_ = true; + triggerEventOnAll("menuFastScrollEnter", 0); + } } } else { @@ -1101,17 +1102,6 @@ void ScrollingList::scroll( bool forward ) if ( scrollPeriod_ < minScrollTime_ ) { scrollPeriod_ = minScrollTime_; - - if (!menuFastScrollEntered_) { - menuFastScrollEntered_ = true; - triggerEventOnAll("menuFastScrollEnter", 0); - } - } - else { - if (menuFastScrollEntered_) { - menuFastScrollEntered_ = false; - triggerEventOnAll("menuFastScrollExit", 0); - } } // Replace the item that's scrolled out diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index e78c8c4a0..ab62eadb5 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -314,7 +314,7 @@ bool RetroFE::run( ) // Define control configuration std::string controlsConfPath = Utils::combinePath( Configuration::absolutePath, "controls" ); for (int i = 9; i > 0; i--) - config_.import("controls", controlsConfPath + std::to_string(i) + ".conf", false); + config_.import("controls", controlsConfPath + std::to_string(i) + ".conf"); config_.import("controls", controlsConfPath + ".conf"); if (config_.propertiesEmpty()) From 6a29c9f765443a7f757ec8f63580e2fa4ffeef7c Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Wed, 24 May 2023 21:49:35 -0700 Subject: [PATCH 5/9] initial kinda working onMenuFastScroll --- .../Graphics/Component/ScrollingList.cpp | 17 ++++------ .../Source/Graphics/Component/ScrollingList.h | 3 +- RetroFE/Source/Graphics/Page.cpp | 34 +++++++++++++++++-- RetroFE/Source/Graphics/Page.h | 4 +-- RetroFE/Source/Graphics/PageBuilder.cpp | 3 +- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 3784a6893..263213fea 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -1074,21 +1074,18 @@ void ScrollingList::updateScrollPeriod( ) if ( scrollPeriod_ < minScrollTime_ ) { scrollPeriod_ = minScrollTime_; - if (scrollPeriod_ != 0) { - if (!menuFastScrollEntered_) { - menuFastScrollEntered_ = true; - triggerEventOnAll("menuFastScrollEnter", 0); - } - } + menuFastScroll_ = true; } else { - if (menuFastScrollEntered_) { - menuFastScrollEntered_ = false; - triggerEventOnAll("menuFastScrollExit", 0); - } + menuFastScroll_ = false; } } +bool ScrollingList::isMenuScrollingFast() +{ + return menuFastScroll_; +} + void ScrollingList::scroll( bool forward ) { diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 32d982312..ad2869d2c 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -107,6 +107,7 @@ class ScrollingList : public Component void allocateSpritePoints( ); void resetScrollPeriod( ); void updateScrollPeriod( ); + bool isMenuScrollingFast(); void scroll( bool forward ); bool isPlaylist(); private: @@ -119,7 +120,7 @@ class ScrollingList : public Component bool commonMode_; bool playlistType_; bool selectedImage_; - bool menuFastScrollEntered_ = false; + bool menuFastScroll_ = false; std::vector *spriteList_; std::vector *scrollPoints_; diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index d1a573e89..f0eb83360 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -45,6 +45,7 @@ Page::Page(Configuration &config, int layoutWidth, int layoutHeight) , anActiveMenu_(NULL) , fromPreviousPlaylist (false) , fromPlaylistNav(false) + , scrollFastActive_(false) { for (int i = 0; i < SDL::getNumScreens(); i++) { @@ -326,6 +327,9 @@ bool Page::isMenuIdle() } } } + if (idle) { + scrollFastActive_ = false; + } return idle; } @@ -603,7 +607,6 @@ void Page::menuJumpExit() triggerEventOnAllMenus("menuJumpExit"); } - void Page::attractEnter() { triggerEventOnAllMenus("attractEnter"); @@ -619,7 +622,6 @@ void Page::attractExit() triggerEventOnAllMenus("attractExit"); } - void Page::jukeboxJump() { triggerEventOnAllMenus("jukeboxJump"); @@ -1447,6 +1449,22 @@ bool Page::isMenuScrolling() return scrollActive_; } +bool Page::isMenuScrollingFast() +{ + bool retVal = false; + + for (std::vector::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++) + { + ScrollingList* menu = *it; + // if menu exists and is not a playlist or playlist menu is allowed to be updated + if (menu) + { + retVal |= menu->isMenuScrollingFast(); + } + } + + return retVal; +} bool Page::isPlaying() { @@ -1479,8 +1497,18 @@ void Page::updateScrollPeriod() for(std::vector::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++) { ScrollingList *menu = *it; - if(menu) menu->updateScrollPeriod(); + if (menu) { + menu->updateScrollPeriod(); + if (!scrollFastActive_ && menu->isMenuScrollingFast()) { + scrollFastActive_ = true; + for (std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) + { + (*it)->triggerEvent("menuFastScroll", menuDepth_ - 1); + } + } + } } + return; } diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index f5ac6d236..522e16de8 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -108,8 +108,6 @@ class Page void setMinShowTime(float value); float getMinShowTime(); void menuScroll(); - void menuFastScrollEnter(); - void menuFastScrollExit(); void highlightEnter(); void highlightExit(); void playlistEnter(); @@ -132,6 +130,7 @@ class Page void togglePlaylist(); void reallocateMenuSpritePoints(bool updatePlaylistMenu = true); bool isMenuScrolling(); + bool isMenuScrollingFast(); bool isPlaying(); void resetScrollPeriod(); void updateScrollPeriod(); @@ -191,6 +190,7 @@ class Page std::map lastPlaylistOffsets_; bool scrollActive_; + bool scrollFastActive_; Item *selectedItem_; Text *textStatusComponent_; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 17256b282..13a169b68 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -877,8 +877,6 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) buildTweenSet(tweens, componentXml, "onIdle", "idle"); buildTweenSet(tweens, componentXml, "onMenuIdle", "menuIdle"); buildTweenSet(tweens, componentXml, "onMenuScroll", "menuScroll"); - buildTweenSet(tweens, componentXml, "onMenuFastScrollEnter", "menuFastScrollEnter"); - buildTweenSet(tweens, componentXml, "onMenuFastScrollExit", "menuFastScrollExit"); buildTweenSet(tweens, componentXml, "onHighlightEnter", "highlightEnter"); buildTweenSet(tweens, componentXml, "onHighlightExit", "highlightExit"); buildTweenSet(tweens, componentXml, "onMenuEnter", "menuEnter"); @@ -898,6 +896,7 @@ AnimationEvents *PageBuilder::createTweenInstance(xml_node<> *componentXml) buildTweenSet(tweens, componentXml, "onAttractExit", "attractExit"); buildTweenSet(tweens, componentXml, "onJukeboxJump", "jukeboxJump"); + buildTweenSet(tweens, componentXml, "onMenuFastScroll", "menuFastScroll"); buildTweenSet(tweens, componentXml, "onMenuActionInputEnter", "menuActionInputEnter"); buildTweenSet(tweens, componentXml, "onMenuActionInputExit", "menuActionInputExit"); buildTweenSet(tweens, componentXml, "onMenuActionSelectEnter", "menuActionSelectEnter"); From 45f807855851cacaa7202501d591b7b43b711689 Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Wed, 24 May 2023 22:05:56 -0700 Subject: [PATCH 6/9] fix to trigger onmenus --- RetroFE/Source/Graphics/Page.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index f0eb83360..5ea065079 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -1501,10 +1501,7 @@ void Page::updateScrollPeriod() menu->updateScrollPeriod(); if (!scrollFastActive_ && menu->isMenuScrollingFast()) { scrollFastActive_ = true; - for (std::vector::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it) - { - (*it)->triggerEvent("menuFastScroll", menuDepth_ - 1); - } + triggerEventOnAllMenus("menuFastScroll"); } } } From cecfff456f5d0c0445d6b963cfc2df5b72cda70d Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Thu, 25 May 2023 21:04:21 -0700 Subject: [PATCH 7/9] fix idle animation loop --- .../Source/Graphics/Component/Component.cpp | 86 +++++++++---------- RetroFE/Source/Graphics/Page.cpp | 7 +- 2 files changed, 45 insertions(+), 48 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index cfeb2da6f..e86deac6a 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -154,56 +154,56 @@ void Component::update(float dt) { elapsedTweenTime_ += dt; - if ( animationRequested_ && animationRequestedType_ != "" ) - { - Animation *newTweens; - // Check if this component is part of an active scrolling list - if ( menuIndex_ >= MENU_INDEX_HIGH ) - { - // Check for animation at index i - newTweens = tweens_->getAnimation( animationRequestedType_, MENU_INDEX_HIGH ); - if ( !(newTweens && newTweens->size() > 0) ) - { - // Check for animation at the current menuIndex - newTweens = tweens_->getAnimation( animationRequestedType_, menuIndex_ - MENU_INDEX_HIGH); - } - } - else - { - // Check for animation at the current menuIndex - newTweens = tweens_->getAnimation( animationRequestedType_, menuIndex_ ); - } - if (newTweens && newTweens->size() > 0) - { - animationType_ = animationRequestedType_; - currentTweens_ = newTweens; - currentTweenIndex_ = 0; - elapsedTweenTime_ = 0; - storeViewInfo_ = baseViewInfo; - currentTweenComplete_ = false; - } - animationRequested_ = false; - } + if (animationRequested_) { + if (animationRequestedType_ != "") + { + Animation* newTweens; + // Check if this component is part of an active scrolling list + if (menuIndex_ >= MENU_INDEX_HIGH) + { + // Check for animation at index i + newTweens = tweens_->getAnimation(animationRequestedType_, MENU_INDEX_HIGH); + if (!(newTweens && newTweens->size() > 0)) + { + // Check for animation at the current menuIndex + newTweens = tweens_->getAnimation(animationRequestedType_, menuIndex_ - MENU_INDEX_HIGH); + } + } + else + { + // Check for animation at the current menuIndex + newTweens = tweens_->getAnimation(animationRequestedType_, menuIndex_); + } + if (newTweens && newTweens->size() > 0) + { + animationType_ = animationRequestedType_; + currentTweens_ = newTweens; + currentTweenIndex_ = 0; + elapsedTweenTime_ = 0; + storeViewInfo_ = baseViewInfo; + currentTweenComplete_ = false; + } + animationRequested_ = false; + } - if (tweens_ && currentTweenComplete_) - { - animationType_ = "idle"; - currentTweens_ = tweens_->getAnimation( "idle", menuIndex_ ); - if ( currentTweens_ && currentTweens_->size( ) == 0 && !page.isMenuScrolling( ) ) + // perform idle animation + if (tweens_ && currentTweenComplete_) { - currentTweens_ = tweens_->getAnimation( "menuIdle", menuIndex_ ); - if ( currentTweens_ && currentTweens_->size( ) > 0 ) + animationType_ = "idle"; + currentTweens_ = tweens_->getAnimation("idle", menuIndex_); + if (currentTweens_ && currentTweens_->size() == 0 && !page.isMenuScrolling()) { - currentTweens_ = currentTweens_; + currentTweens_ = tweens_->getAnimation("menuIdle", menuIndex_); } + currentTweenIndex_ = 0; + elapsedTweenTime_ = 0; + storeViewInfo_ = baseViewInfo; + currentTweenComplete_ = false; + animationRequested_ = false; } - currentTweenIndex_ = 0; - elapsedTweenTime_ = 0; - storeViewInfo_ = baseViewInfo; - currentTweenComplete_ = false; - animationRequested_ = false; } + // reset currentTweenComplete_ = animate(); if ( currentTweenComplete_ ) { diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 5ea065079..ef23ecea4 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -327,9 +327,8 @@ bool Page::isMenuIdle() } } } - if (idle) { - scrollFastActive_ = false; - } + scrollFastActive_ = !idle; + return idle; } @@ -1443,7 +1442,6 @@ void Page::reallocateMenuSpritePoints(bool updatePlaylistMenu) } } - bool Page::isMenuScrolling() { return scrollActive_; @@ -1456,7 +1454,6 @@ bool Page::isMenuScrollingFast() for (std::vector::iterator it = activeMenu_.begin(); it != activeMenu_.end(); it++) { ScrollingList* menu = *it; - // if menu exists and is not a playlist or playlist menu is allowed to be updated if (menu) { retVal |= menu->isMenuScrollingFast(); From 10abef4f64419e4274b34a5479c11444225053c1 Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Thu, 25 May 2023 21:12:49 -0700 Subject: [PATCH 8/9] changelog --- RetroFE/Build/CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RetroFE/Build/CHANGELOG b/RetroFE/Build/CHANGELOG index cda049630..6e74b3eda 100644 --- a/RetroFE/Build/CHANGELOG +++ b/RetroFE/Build/CHANGELOG @@ -41,3 +41,5 @@ v0.10.34.1 - added ability to specify SDL render driver to use, SDLRenderDriver in settings.conf. Acceptable values are direct3d11, opengl (inigomontoya) - added logging to report the SDL render driver being used (inigomontoya) - changed SDL screen config logic to iterate over number of screens preventing iterations beyond number of found displays (inigomontoya) + - defined as std:min(numScreens_, numDisplays_) and replaced all instances of that with screenCount_ (inigomontoya) + - added onMenuFastScroll layout event that triggers when menu starts scrolling fast. use onMenuIdle as exit event (monkofthefunk) From 0e504ef58e4509a30ed983554295346a14b1f076 Mon Sep 17 00:00:00 2001 From: Tobias Contreras Date: Thu, 25 May 2023 22:29:49 -0700 Subject: [PATCH 9/9] it compiles! but i don't think it works... grinds to a halt... maybe not best idea --- RetroFE/Source/Graphics/Component/Image.cpp | 5 +- RetroFE/Source/Graphics/PageBuilder.cpp | 3 + RetroFE/Source/Graphics/ViewInfo.h | 1 + RetroFE/Source/SDL.cpp | 71 ++++++++++++++++++++- RetroFE/Source/SDL.h | 2 +- 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/Image.cpp b/RetroFE/Source/Graphics/Component/Image.cpp index 0350692fb..b9319f202 100644 --- a/RetroFE/Source/Graphics/Component/Image.cpp +++ b/RetroFE/Source/Graphics/Component/Image.cpp @@ -58,7 +58,8 @@ void Image::allocateGraphicsMemory() texture_ = IMG_LoadTexture(SDL::getRenderer(baseViewInfo.Monitor), file_.c_str()); if (!texture_ && altFile_ != "") { - texture_ = IMG_LoadTexture(SDL::getRenderer(baseViewInfo.Monitor), altFile_.c_str()); + file_ = altFile_; + texture_ = IMG_LoadTexture(SDL::getRenderer(baseViewInfo.Monitor), file_.c_str()); } if (texture_ != NULL) @@ -90,6 +91,6 @@ void Image::draw() rect.h = static_cast(baseViewInfo.ScaledHeight()); rect.w = static_cast(baseViewInfo.ScaledWidth()); - SDL::renderCopy(texture_, baseViewInfo.Alpha, NULL, &rect, baseViewInfo, page.getLayoutWidth(baseViewInfo.Monitor), page.getLayoutHeight(baseViewInfo.Monitor)); + SDL::renderCopy(texture_, baseViewInfo.Alpha, NULL, &rect, baseViewInfo, page.getLayoutWidth(baseViewInfo.Monitor), page.getLayoutHeight(baseViewInfo.Monitor), file_.c_str()); } } diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 13a169b68..776879088 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -1317,6 +1317,8 @@ void PageBuilder::buildViewInfo(xml_node<> *componentXml, ViewInfo &info, xml_no xml_attribute<> *containerHeight = findAttribute(componentXml, "containerHeight", defaultXml); xml_attribute<> *monitor = findAttribute(componentXml, "monitor", defaultXml); xml_attribute<> *volume = findAttribute(componentXml, "volume", defaultXml); + xml_attribute<>* blur = findAttribute(componentXml, "blur", defaultXml); + info.X = getHorizontalAlignment(x, 0); info.Y = getVerticalAlignment(y, 0); @@ -1359,6 +1361,7 @@ void PageBuilder::buildViewInfo(xml_node<> *componentXml, ViewInfo &info, xml_no info.ContainerHeight = containerHeight ? Utils::convertFloat(containerHeight->value()) : -1.f; info.Monitor = monitor ? Utils::convertInt(monitor->value()) : 0; info.Volume = volume ? Utils::convertFloat(volume->value()) : 1.f; + info.Blur = blur ? Utils::convertInt(blur->value()) : 0; if(fontColor) { diff --git a/RetroFE/Source/Graphics/ViewInfo.h b/RetroFE/Source/Graphics/ViewInfo.h index e1ebbdfcd..c4bdde20e 100644 --- a/RetroFE/Source/Graphics/ViewInfo.h +++ b/RetroFE/Source/Graphics/ViewInfo.h @@ -73,6 +73,7 @@ class ViewInfo float ContainerHeight; int Monitor; float Volume; + int Blur; private: float AbsoluteHeight() const; diff --git a/RetroFE/Source/SDL.cpp b/RetroFE/Source/SDL.cpp index 0990b6d43..39551b54c 100644 --- a/RetroFE/Source/SDL.cpp +++ b/RetroFE/Source/SDL.cpp @@ -20,6 +20,7 @@ #include "Utility/Log.h" #include #include "Utility/Utils.h" +#include std::vector SDL::window_; std::vector SDL::renderer_; @@ -394,7 +395,7 @@ SDL_Window* SDL::getWindow( int index ) // Render a copy of a texture -bool SDL::renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo, int layoutWidth, int layoutHeight ) +bool SDL::renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo, int layoutWidth, int layoutHeight, const char* fileName) { // Skip rendering if the object is invisible anyway or if renderer does not exist @@ -528,6 +529,74 @@ bool SDL::renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect } + // Blur + if (viewInfo.Blur) { + SDL_Surface* imageSurface = IMG_Load(fileName); + int blur_extent = viewInfo.Blur; + for (int y = 0; y < imageSurface->h; y++) + { + for (int x = 0; x < (imageSurface->pitch / 4); x++) + { + Uint32 color = ((Uint32*)imageSurface->pixels)[(y * (imageSurface->pitch / 4)) + x]; + + //SDL_GetRGBA() is a method for getting color + //components from a 32 bit color + Uint8 r = 0, g = 0, b = 0, a = 0; + SDL_GetRGBA(color, imageSurface->format, &r, &g, &b, &a); + + Uint32 rb = 0, gb = 0, bb = 0, ab = 0; + + //Within the two for-loops below, colors of adjacent pixels are added up + + for (int yo = -blur_extent; yo <= blur_extent; yo++) + { + for (int xo = -blur_extent; xo <= blur_extent; xo++) { + if (y + yo >= 0 && x + xo >= 0 + && y + yo < imageSurface->h && x + xo < (imageSurface->pitch / 4) + ) + { + Uint32 colOth = ((Uint32*)imageSurface->pixels)[((y + yo) + * (imageSurface->pitch / 4)) + (x + xo)]; + + Uint8 ro = 0, go = 0, bo = 0, ao = 0; + SDL_GetRGBA(colOth, imageSurface->format, &ro, &go, &bo, &ao); + + rb += ro; + gb += go; + bb += bo; + ab += ao; + } + } + } + + //The sum is then, divided by the total number of + //pixels present in a block of blur radius + + //For blur_extent 1, it will be 9 + //For blur_extent 2, it will be 25 + //and so on... + + //In this way, we are getting the average of + //all the pixels in a block of blur radius + + //(((blur_extent * 2) + 1) * ((blur_extent * 2) + 1)) calculates + //the total number of pixels present in a block of blur radius + + r = (Uint8)(rb / (((blur_extent * 2) + 1) * ((blur_extent * 2) + 1))); + g = (Uint8)(gb / (((blur_extent * 2) + 1) * ((blur_extent * 2) + 1))); + b = (Uint8)(bb / (((blur_extent * 2) + 1) * ((blur_extent * 2) + 1))); + a = (Uint8)(ab / (((blur_extent * 2) + 1) * ((blur_extent * 2) + 1))); + + //Bit shifting color bits to form a 32 bit proper colour + color = (r) | (g << 8) | (b << 16) | (a << 24); + ((Uint32*)imageSurface->pixels)[(y * (imageSurface->pitch / 4)) + x] = color; + } + } + SDL_UpperBlit(imageSurface, &srcRect, NULL, &dstRect); + SDL_UpdateWindowSurface(getWindow(viewInfo.Monitor)); + } + + // Angle double angle = viewInfo.Angle; if ( !mirror_[viewInfo.Monitor] ) angle += rotation_[viewInfo.Monitor] * 90; diff --git a/RetroFE/Source/SDL.h b/RetroFE/Source/SDL.h index 2db0678d4..e0e56366d 100644 --- a/RetroFE/Source/SDL.h +++ b/RetroFE/Source/SDL.h @@ -33,7 +33,7 @@ class SDL static SDL_Renderer *getRenderer( int index ); static SDL_mutex *getMutex( ); static SDL_Window *getWindow( int index ); - static bool renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo, int layoutWidth, int layoutHeight ); + static bool renderCopy( SDL_Texture *texture, float alpha, SDL_Rect *src, SDL_Rect *dest, ViewInfo &viewInfo, int layoutWidth, int layoutHeight, const char* fileName = ""); static int getWindowWidth( int index ) { return (index < screenCount_ ? windowWidth_[index] : windowWidth_[0]);