From b339f33305cf3bc8b0b384f3365f1aa005a98270 Mon Sep 17 00:00:00 2001 From: gugueU Date: Sun, 18 Sep 2022 21:54:43 +0200 Subject: [PATCH] feat(frontend): add systems remove management --- projects/frontend/es-app/src/MainRunner.cpp | 2 +- .../frontend/es-app/src/games/FolderData.cpp | 10 ++- .../es-app/src/games/GameRandomSelector.cpp | 11 +++- .../guis/menus/GuiMenuAdvancedSettings.cpp | 4 ++ .../src/guis/menus/GuiMenuAdvancedSettings.h | 1 + .../src/guis/menus/GuiMenuGameFilters.cpp | 23 +------ .../src/guis/menus/GuiMenuGameFilters.h | 5 -- .../src/guis/menus/GuiMenuGamelistOptions.cpp | 14 +--- .../src/guis/menus/GuiMenuGamelistOptions.h | 5 -- .../src/guis/menus/GuiMenuScreensavers.cpp | 4 +- .../es-app/src/guis/menus/GuiMenuSystems.cpp | 40 ++++++++++++ .../es-app/src/guis/menus/GuiMenuSystems.h | 23 +++++++ .../src/guis/menus/GuiMenuVirtualSystems.cpp | 6 -- .../src/guis/menus/GuiMenuVirtualSystems.h | 5 -- .../es-app/src/systems/SystemData.cpp | 7 +- .../frontend/es-app/src/systems/SystemData.h | 2 + .../es-app/src/systems/SystemManager.cpp | 27 +++----- .../frontend/es-app/src/views/SystemView.cpp | 45 +++++++++---- .../frontend/es-app/src/views/SystemView.h | 5 +- .../es-app/src/views/ViewController.cpp | 65 +++++++++++++------ .../es-app/src/views/ViewController.h | 12 +++- .../src/views/gamelist/BasicGameListView.cpp | 2 +- 22 files changed, 199 insertions(+), 119 deletions(-) create mode 100644 projects/frontend/es-app/src/guis/menus/GuiMenuSystems.cpp create mode 100644 projects/frontend/es-app/src/guis/menus/GuiMenuSystems.h diff --git a/projects/frontend/es-app/src/MainRunner.cpp b/projects/frontend/es-app/src/MainRunner.cpp index 2955a3e8bc..704ee0f177 100644 --- a/projects/frontend/es-app/src/MainRunner.cpp +++ b/projects/frontend/es-app/src/MainRunner.cpp @@ -376,7 +376,7 @@ void MainRunner::CheckAlert(WindowManager& window, SystemManager& systemManager) { int realSystemCount = 0; for(const SystemData* system : systemManager.GetVisibleSystemList()) - if (system->HasVisibleGame()) + if (system->HasGame()) realSystemCount++; if (realSystemCount > maxSystem) { diff --git a/projects/frontend/es-app/src/games/FolderData.cpp b/projects/frontend/es-app/src/games/FolderData.cpp index 39b7e84158..0d17db8a1e 100644 --- a/projects/frontend/es-app/src/games/FolderData.cpp +++ b/projects/frontend/es-app/src/games/FolderData.cpp @@ -471,15 +471,19 @@ int FolderData::countExcludesItemsRecursively(Filter includes, Filter excludes, else if (fd->IsGame()) { Filter currentIncludes = Filter::None; - if (fd->Metadata().Favorite()) currentIncludes |= Filter::Favorite; - if (currentIncludes == 0) currentIncludes = Filter::Normal; + if (fd->Metadata().Favorite()) + currentIncludes |= Filter::Favorite; + if (currentIncludes == 0) + currentIncludes = Filter::Normal; Filter currentExcludes = Filter::None; + if (!fd->Metadata().Favorite()) currentExcludes |= Filter::Normal; if (fd->Metadata().Hidden()) currentExcludes |= Filter::Hidden; if (!fd->Metadata().LatestVersion()) currentExcludes |= Filter::NotLatest; if (Strings::Contains(fd->RomPath().ToString(), "share_init")) currentExcludes |= Filter::PreInstalled; - if(!fd->System().IncludeAdultGames() && fd->Metadata().Adult()) currentExcludes |= Filter::Adult; + if(!fd->System().IncludeAdultGames() && fd->Metadata().Adult()) + currentExcludes |= Filter::Adult; if ((currentIncludes & includes) == 0 || (currentExcludes & excludes) != 0) result++; diff --git a/projects/frontend/es-app/src/games/GameRandomSelector.cpp b/projects/frontend/es-app/src/games/GameRandomSelector.cpp index ba0b740961..b5f7a63f86 100644 --- a/projects/frontend/es-app/src/games/GameRandomSelector.cpp +++ b/projects/frontend/es-app/src/games/GameRandomSelector.cpp @@ -28,9 +28,16 @@ void GameRandomSelector::InitializeSystems() mSystemArray.Clear(); for(const SystemData* system : mSystemManager.GetVisibleSystemList()) { + RecalboxConf& conf = RecalboxConf::Instance(); + + // is system ignored + if (conf.AsBool(system->Name() + ".ignore")) + continue; + // Demo system? - if (!RecalboxConf::Instance().isInList("global.demo.systemlist", system->Name()) && - !RecalboxConf::Instance().GetSystemDemoInclude(*system)) continue; + if (!conf.isInList("global.demo.systemlist", system->Name()) && + !conf.GetSystemDemoInclude(*system)) continue; + // Has game? int gameCount = SystemContent::GetSystemGameCount(system, mFilter); if (gameCount <= 0) continue; diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuAdvancedSettings.cpp b/projects/frontend/es-app/src/guis/menus/GuiMenuAdvancedSettings.cpp index de76f510b0..56a4304c39 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuAdvancedSettings.cpp +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuAdvancedSettings.cpp @@ -13,6 +13,7 @@ #include "GuiMenuCRT.h" #include "GuiMenuResolutionSettings.h" #include "ResolutionAdapter.h" +#include "GuiMenuSystems.h" #include #include //#include @@ -43,6 +44,7 @@ GuiMenuAdvancedSettings::GuiMenuAdvancedSettings(WindowManager& window, SystemMa AddSubMenu(_("BOOT SETTINGS"), (int)Components::BootSubMenu, _(MENUMESSAGE_ADVANCED_BOOT_HELP_MSG)); // Virtual systems + AddSubMenu(_("SYSTEMS"), (int)Components::Systems, ""); AddSubMenu(_("VIRTUAL SYSTEMS"), (int)Components::VirtualSubMenu, _(MENUMESSAGE_ADVANCED_VIRTUALSYSTEMS_HELP_MSG)); // CRT @@ -233,6 +235,7 @@ void GuiMenuAdvancedSettings::SwitchComponentChanged(int id, bool status) case Components::Manager: RecalboxConf::Instance().SetSystemManagerEnabled(status).Save(); break; case Components::OverclockList: case Components::BootSubMenu: + case Components::Systems: case Components::VirtualSubMenu: case Components::AdvancedSubMenu: case Components::KodiSubMenu: @@ -251,6 +254,7 @@ void GuiMenuAdvancedSettings::SubMenuSelected(int id) { case Components::BootSubMenu: mWindow.pushGui(new GuiMenuBootSettings(mWindow, mSystemManager)); break; case Components::CrtSubMenu: mWindow.pushGui(new GuiMenuCRT(mWindow)); break; + case Components::Systems: mWindow.pushGui(new GuiMenuSystems(mWindow, mSystemManager)); break; case Components::VirtualSubMenu: mWindow.pushGui(new GuiMenuVirtualSystems(mWindow, mSystemManager)); break; case Components::AdvancedSubMenu: mWindow.pushGui(new GuiMenuSystemList(mWindow, mSystemManager)); break; case Components::KodiSubMenu: mWindow.pushGui(new GuiMenuKodiSettings(mWindow)); break; diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuAdvancedSettings.h b/projects/frontend/es-app/src/guis/menus/GuiMenuAdvancedSettings.h index 2a17a88b13..68782294e9 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuAdvancedSettings.h +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuAdvancedSettings.h @@ -49,6 +49,7 @@ class GuiMenuAdvancedSettings : public GuiMenuBase DebugLogs, OverclockList, BootSubMenu, + Systems, VirtualSubMenu, ResolutionSubMenu, AdvancedSubMenu, diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuGameFilters.cpp b/projects/frontend/es-app/src/guis/menus/GuiMenuGameFilters.cpp index 90a7dd78ee..390e58bb31 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuGameFilters.cpp +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuGameFilters.cpp @@ -5,14 +5,12 @@ #include "GuiMenuGameFilters.h" #include -#include #include #include "views/ViewController.h" #include "components/SwitchComponent.h" #include "utils/locale/LocaleHelper.h" #include "guis/MenuMessages.h" #include "GuiMenu.h" -#include "guis/GuiMsgBox.h" GuiMenuGameFilters::GuiMenuGameFilters(WindowManager& window) : GuiMenuBase(window, _("GAME FILTERS"), nullptr) @@ -34,8 +32,7 @@ GuiMenuGameFilters::GuiMenuGameFilters(WindowManager& window) GuiMenuGameFilters::~GuiMenuGameFilters() { - if(!ViewController::Instance().CheckFilters()) - ManageSystems(); + ViewController::Instance().RefreshSystems(); } void GuiMenuGameFilters::SwitchComponentChanged(int id, bool status) @@ -44,39 +41,21 @@ void GuiMenuGameFilters::SwitchComponentChanged(int id, bool status) { case Components::ShowOnlyLatestVersion: RecalboxConf::Instance().SetShowOnlyLatestVersion(status).Save(); - ManageSystems(); break; case Components::FavoritesOnly: RecalboxConf::Instance().SetFavoritesOnly(status).Save(); - ManageSystems(); break; case Components::ShowHidden: RecalboxConf::Instance().SetShowHidden(status).Save(); - ManageSystems(); break; case Components::Adult: RecalboxConf::Instance().SetFilterAdultGames(status).Save(); - ManageSystems(); break; case Components::HidePreinstalled: RecalboxConf::Instance().SetGlobalHidePreinstalled(status).Save(); - ManageSystems(); break; case Components::NoGames: RecalboxConf::Instance().SetHideNoGames(status).Save(); - ManageSystems(); break; } } - -void GuiMenuGameFilters::ManageSystems() -{ - SystemData* systemData = ViewController::Instance().getState().getSystem(); - ViewController::Instance().getGameListView(systemData)->refreshList(); - - ViewController::Instance().setAllInvalidGamesList(nullptr); - ViewController::Instance().getSystemListView().manageSystemsList(); - - // for updating game counts on system view - ViewController::Instance().getSystemListView().onCursorChanged(CursorState::Stopped); -} diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuGameFilters.h b/projects/frontend/es-app/src/guis/menus/GuiMenuGameFilters.h index 8d90038f51..42931ca632 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuGameFilters.h +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuGameFilters.h @@ -38,9 +38,4 @@ class GuiMenuGameFilters : public GuiMenuBase */ void SwitchComponentChanged(int id, bool status) override; - - /*! - * @brief Manage all systems - */ - void ManageSystems(); }; \ No newline at end of file diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuGamelistOptions.cpp b/projects/frontend/es-app/src/guis/menus/GuiMenuGamelistOptions.cpp index c3bb5495d4..8d912ecef9 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuGamelistOptions.cpp +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuGamelistOptions.cpp @@ -286,7 +286,7 @@ void GuiMenuGamelistOptions::SwitchComponentChanged(int id, bool status) switch((Components)id) { case Components::FlatFolders: RecalboxConf::Instance().SetSystemFlatFolders(mSystem, status).Save(); break; - case Components::FavoritesOnly: RecalboxConf::Instance().SetFavoritesOnly(status).Save(); ManageSystems(); break; + case Components::FavoritesOnly: RecalboxConf::Instance().SetFavoritesOnly(status).Save(); ViewController::Instance().RefreshSystems(); break; case Components::Regions: case Components::Sorts: case Components::JumpToLetter: @@ -303,16 +303,4 @@ void GuiMenuGamelistOptions::SwitchComponentChanged(int id, bool status) mGamelist.refreshList(); mGamelist.setCursor(game); RefreshGameMenuContext(); -} - -void GuiMenuGamelistOptions::ManageSystems() -{ - SystemData* systemData = ViewController::Instance().getState().getSystem(); - ViewController::Instance().getGameListView(systemData)->refreshList(); - - ViewController::Instance().setAllInvalidGamesList(nullptr); - ViewController::Instance().getSystemListView().manageSystemsList(); - - // for updating game counts on system view - ViewController::Instance().getSystemListView().onCursorChanged(CursorState::Stopped); } \ No newline at end of file diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuGamelistOptions.h b/projects/frontend/es-app/src/guis/menus/GuiMenuGamelistOptions.h index 3aef289896..42a153ed1b 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuGamelistOptions.h +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuGamelistOptions.h @@ -68,11 +68,6 @@ class GuiMenuGamelistOptions : public GuiMenuBase //! Get available region List std::vector> GetRegionEntries(); - /*! - * @brief Refresh gamelist - */ - static void ManageSystems(); - /* * GuiMetaDataEd::IMetaDataAction implementation */ diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuScreensavers.cpp b/projects/frontend/es-app/src/guis/menus/GuiMenuScreensavers.cpp index d4f5731389..5152faec31 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuScreensavers.cpp +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuScreensavers.cpp @@ -40,8 +40,8 @@ std::vector> GuiMenuScreensavers::GetSystemE { std::vector> list; - for (const SystemData* system : mSystemManager.GetAllSystemList()) - if (system->HasVisibleGame()) + for (const SystemData* system : mSystemManager.GetVisibleSystemList()) + if (system->IsDisplayable()) list.push_back({ system->FullName(), system->Name(), RecalboxConf::Instance().IsInScreenSaverSystemList(system->Name()) }); return list; diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuSystems.cpp b/projects/frontend/es-app/src/guis/menus/GuiMenuSystems.cpp new file mode 100644 index 0000000000..a8f7204efc --- /dev/null +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuSystems.cpp @@ -0,0 +1,40 @@ +// +// Created by gugue_u on 24/09/22. +// + +#include "GuiMenuSystems.h" +#include "views/ViewController.h" + +GuiMenuSystems::GuiMenuSystems(WindowManager& window, SystemManager& systemManager) + : GuiMenuBase(window, _("SYSTEMS"), nullptr) + , mSystemManager(systemManager) + +{ + int id = 0; + for(const auto & system : mSystemManager.GetVisibleSystemList()) + { + AddSwitch(system->Descriptor().FullName(), !RecalboxConf::Instance().AsBool(system->Name() + ".ignore"), id, this, ""); + id++; + } +} + +GuiMenuSystems::~GuiMenuSystems() +{ + ViewController::Instance().RefreshSystems(); +} + +void GuiMenuSystems::SwitchComponentChanged(int id, bool status) +{ + SystemData* systemData; + int loop = 0; + + for(const auto & system : mSystemManager.GetVisibleSystemList()) + { + if (loop == id) { + systemData = system; + } + loop++; + } + RecalboxConf::Instance().SetBool(systemData->Name() + ".ignore", !status); + RecalboxConf::Instance().Save(); +} diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuSystems.h b/projects/frontend/es-app/src/guis/menus/GuiMenuSystems.h new file mode 100644 index 0000000000..de835b30ce --- /dev/null +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuSystems.h @@ -0,0 +1,23 @@ +// +// Created by gugue_u on 24/09/22. +// +#pragma once + +#include "GuiMenuBase.h" +#include "systems/SystemManager.h" + +class GuiMenuSystems : public GuiMenuBase, private ISwitchComponent + +{ + public: + explicit GuiMenuSystems(WindowManager& window, SystemManager& systemManager); + + ~GuiMenuSystems() override; + + private: + //! System manager + SystemManager& mSystemManager; + + void SwitchComponentChanged(int id, bool status) override; +}; + diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuVirtualSystems.cpp b/projects/frontend/es-app/src/guis/menus/GuiMenuVirtualSystems.cpp index 77eb58063f..0147dec487 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuVirtualSystems.cpp +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuVirtualSystems.cpp @@ -21,7 +21,6 @@ GuiMenuVirtualSystems::GuiMenuVirtualSystems(WindowManager& window, SystemManage , mMultiplayersOriginalValues(RecalboxConf::Instance().GetCollectionMultiplayer()) , mLastPlayedOriginalValues(RecalboxConf::Instance().GetCollectionLastPlayed()) , mLightGunOriginalValues(!RecalboxConf::Instance().GetCollectionHide("lightgun")) - , mPortsOriginalValues(!RecalboxConf::Instance().GetCollectionHide("ports")) { // All games mAllGames = AddSwitch(_("SHOW ALL-GAMES SYSTEM"), mAllGamesOriginalValues, (int)Components::AllGames, this, _(MENUMESSAGE_ADVANCED_ALLGAMES_HELP_MSG)); @@ -37,9 +36,6 @@ GuiMenuVirtualSystems::GuiMenuVirtualSystems(WindowManager& window, SystemManage if (board != BoardType::OdroidAdvanceGo && board != BoardType::OdroidAdvanceGoSuper) mLightGun = AddSwitch(_("SHOW LIGHTGUN SYSTEM"), mLightGunOriginalValues, (int)Components::LightGun, this, _(MENUMESSAGE_ADVANCED_LIGHTGUN_HELP_MSG)); - // Ports - mPorts = AddSwitch(_("SHOW PORTS SYSTEM"), mPortsOriginalValues, (int)Components::Ports, this, _(MENUMESSAGE_ADVANCED_PORTS_HELP_MSG)); - AddSubMenu(_("VIRTUAL SYSTEMS PER GENRE"), (int)Components::VirtualPerGenre, _(MENUMESSAGE_ADVANCED_VIRTUALGENRESYSTEMS_HELP_MSG)); AddSubMenu(_("ARCADE VIRTUAL SYSTEM"), (int)Components::VirtualArcade, _(MENUMESSAGE_ADVANCED_ARCADEVIRTUALSYSTEM_HELP_MSG)); } @@ -49,7 +45,6 @@ GuiMenuVirtualSystems::~GuiMenuVirtualSystems() if ((mLastPlayedOriginalValues != RecalboxConf::Instance().GetCollectionLastPlayed()) || (mMultiplayersOriginalValues != RecalboxConf::Instance().GetCollectionMultiplayer()) || (mLightGunOriginalValues == RecalboxConf::Instance().GetCollectionHide("lightgun")) || - (mPortsOriginalValues == RecalboxConf::Instance().GetCollectionHide("ports")) || (mAllGamesOriginalValues != RecalboxConf::Instance().GetCollectionAllGames())) RequestRelaunch(); } @@ -68,7 +63,6 @@ void GuiMenuVirtualSystems::SwitchComponentChanged(int id, bool status) case Components::Multiplayers: RecalboxConf::Instance().SetCollectionMultiplayer(status).Save(); break; case Components::LastPlayed: RecalboxConf::Instance().SetCollectionLastPlayed(status).Save(); break; case Components::LightGun: RecalboxConf::Instance().SetCollectionHide("lightgun", !status).Save(); break; - case Components::Ports: RecalboxConf::Instance().SetCollectionHide("ports", !status).Save(); break; case Components::VirtualPerGenre: case Components::VirtualArcade: break; } diff --git a/projects/frontend/es-app/src/guis/menus/GuiMenuVirtualSystems.h b/projects/frontend/es-app/src/guis/menus/GuiMenuVirtualSystems.h index 8fb36c0614..95232f58ce 100644 --- a/projects/frontend/es-app/src/guis/menus/GuiMenuVirtualSystems.h +++ b/projects/frontend/es-app/src/guis/menus/GuiMenuVirtualSystems.h @@ -36,7 +36,6 @@ class GuiMenuVirtualSystems : public GuiMenuBase VirtualPerGenre, VirtualArcade, LightGun, - Ports, }; //! System manager @@ -50,8 +49,6 @@ class GuiMenuVirtualSystems : public GuiMenuBase std::shared_ptr mLastPlayed; //! Lightgun switch component std::shared_ptr mLightGun; - //! Ports switch component - std::shared_ptr mPorts; //! All games original value bool mAllGamesOriginalValues; @@ -61,8 +58,6 @@ class GuiMenuVirtualSystems : public GuiMenuBase bool mLastPlayedOriginalValues; //! Lightgun original value bool mLightGunOriginalValues; - //! Ports original value - bool mPortsOriginalValues; /* * IGuiMenuBase implementation diff --git a/projects/frontend/es-app/src/systems/SystemData.cpp b/projects/frontend/es-app/src/systems/SystemData.cpp index 35bbdae33e..87018425c7 100644 --- a/projects/frontend/es-app/src/systems/SystemData.cpp +++ b/projects/frontend/es-app/src/systems/SystemData.cpp @@ -397,7 +397,7 @@ bool SystemData::IsAlwaysFlat() const bool SystemData::IsSearchable() const { - return (mProperties & Properties::Searchable) != 0; + return (mProperties & Properties::Searchable) != 0 && IsDisplayable(); } void SystemData::BuildDoppelgangerMap(FileData::StringMap& doppelganger, bool includefolder) const @@ -545,6 +545,8 @@ bool SystemData::HasVisibleGame() const return false; } + + bool SystemData::HasScrapableGame() const { for(const RootFolderData* root : mRootOfRoot.SubRoots()) @@ -590,6 +592,9 @@ FileData::Filter SystemData::Excludes() const // Default excludes filter FileData::Filter excludesFilter = FileData::Filter::None; + // ignore normal (aka non favorites games) ? + if (conf.GetFavoritesOnly()) + excludesFilter |= FileData::Filter::Normal; // ignore hidden? if (!conf.GetShowHidden()) excludesFilter |= FileData::Filter::Hidden; diff --git a/projects/frontend/es-app/src/systems/SystemData.h b/projects/frontend/es-app/src/systems/SystemData.h index 1fe4f36ddd..8dab4c4b0e 100644 --- a/projects/frontend/es-app/src/systems/SystemData.h +++ b/projects/frontend/es-app/src/systems/SystemData.h @@ -167,6 +167,8 @@ class SystemData : private INoCopy bool HasGame() const; bool HasVisibleGame() const; + bool IsDisplayable() const { return !RecalboxConf::Instance().AsBool(Name() + ".ignore") && HasVisibleGame(); } + /*! * @brief Check if system has no only RO games diff --git a/projects/frontend/es-app/src/systems/SystemManager.cpp b/projects/frontend/es-app/src/systems/SystemManager.cpp index ebb5a1ec66..3ee597eca5 100644 --- a/projects/frontend/es-app/src/systems/SystemManager.cpp +++ b/projects/frontend/es-app/src/systems/SystemManager.cpp @@ -522,18 +522,15 @@ bool SystemManager::AddPorts() mHiddenSystemVector.push_back(port); } - if ((!RecalboxConf::Instance().GetCollectionHide("ports")) || (mVisibleSystemVector.size() == 1)) - { - // Create meta-system - SystemData* portSystem = CreateMetaSystem("ports", "Ports", "ports", ports, SystemData::Properties::Virtual | SystemData::Properties::Searchable, doppelganger); - { LOG(LogInfo) << "[System] Creating Ports"; } - // Seek default position - int position = RecalboxConf::Instance().GetCollectionPosition("ports") % (int)mVisibleSystemVector.size(); - if (position == 0) - while((position < (int)mVisibleSystemVector.size()) && (portSystem->Name() > mVisibleSystemVector[position]->Name())) position++; - auto it = position >= 0 ? mVisibleSystemVector.begin() + position : mVisibleSystemVector.end() + (position + 1); - mVisibleSystemVector.insert(it, portSystem); - } + // Create meta-system + SystemData* portSystem = CreateMetaSystem("ports", "Ports", "ports", ports, SystemData::Properties::Virtual | SystemData::Properties::Searchable, doppelganger); + { LOG(LogInfo) << "[System] Creating Ports"; } + // Seek default position + int position = RecalboxConf::Instance().GetCollectionPosition("ports") % (int)mVisibleSystemVector.size(); + if (position == 0) + while((position < (int)mVisibleSystemVector.size()) && (portSystem->Name() > mVisibleSystemVector[position]->Name())) position++; + auto it = position >= 0 ? mVisibleSystemVector.begin() + position : mVisibleSystemVector.end() + (position + 1); + mVisibleSystemVector.insert(it, portSystem); } return !ports.empty(); @@ -766,8 +763,6 @@ bool SystemManager::LoadSystemConfigurations(FileNotifier& gamelistWatcher, bool SystemDescriptor descriptor; if (deserializer.Deserialize(index, descriptor)) { - if (!RecalboxConf::Instance().AsBool(descriptor.Name() + ".ignore")) - { // Get weight int weight = weights.GetInt(descriptor.FullName(), 0); // Add system name and raw rompath @@ -777,8 +772,6 @@ bool SystemManager::LoadSystemConfigurations(FileNotifier& gamelistWatcher, bool mAllDeclaredSystemExtensionSet.insert(ext); // Push weighted system threadPool.PushFeed(descriptor, weight); - } - else { LOG(LogInfo) << "[System] " << descriptor.FullName() << " ignored in configuration."; } } } @@ -953,7 +946,7 @@ int SystemManager::getVisibleSystemIndex(const std::string &name) SystemData* SystemManager::FirstNonEmptySystem() { for (auto &system : mVisibleSystemVector) - if (system->HasVisibleGame()) + if (system->IsDisplayable()) return system; return nullptr; diff --git a/projects/frontend/es-app/src/views/SystemView.cpp b/projects/frontend/es-app/src/views/SystemView.cpp index 2fcf2d4790..cb38691da7 100755 --- a/projects/frontend/es-app/src/views/SystemView.cpp +++ b/projects/frontend/es-app/src/views/SystemView.cpp @@ -153,13 +153,13 @@ void SystemView::addSystem(SystemData * it) // sort the extras by z-index e.data.backgroundExtras->sortExtrasByZIndex(); - this->add(e); + mCompleteList.push_back(e); } SystemData* SystemView::Prev() { SystemData* prev = mSystemManager.PreviousVisible(mCurrentSystem); - while(!prev->HasVisibleGame()) { + while(!prev->IsDisplayable()) { prev = mSystemManager.PreviousVisible(prev); } @@ -170,7 +170,7 @@ void SystemView::RemoveCurrentSystem() { std::vector newEntries; for(auto& systemView : mEntries) - if (systemView.object == mCurrentSystem && mCurrentSystem->HasVisibleGame()) + if (systemView.object == mCurrentSystem && mCurrentSystem->IsDisplayable()) { newEntries.push_back(systemView); break; @@ -195,10 +195,17 @@ void SystemView::Sort() void SystemView::populate() { mEntries.clear(); - - for (const auto it : mSystemManager.GetVisibleSystemList()) - if (it->HasVisibleGame()) + for (const auto it : mSystemManager.GetAllSystemList()) + { addSystem(it); + } + + for (const auto entry : mCompleteList) + { + for(const SystemData* systemData: mSystemManager.GetVisibleSystemList()) + if (systemData == entry.object && entry.object->IsDisplayable()) + this->add(entry); + } } void SystemView::goToSystem(SystemData* system, bool animate) @@ -213,6 +220,7 @@ void SystemView::goToSystem(SystemData* system, bool animate) if(!animate) finishAnimation(0); onCursorChanged(CursorState::Stopped); + onCursorChanged(CursorState::Stopped); } bool SystemView::ProcessInput(const InputCompactEvent& event) @@ -622,6 +630,7 @@ void SystemView::renderCarousel(const Transform4x4f& trans) while (index >= (int)mEntries.size()) index -= mEntries.size(); + Transform4x4f logoTrans = carouselTrans; logoTrans.translate(Vector3f((float)i * logoSpacing[0] + xOff, (float)i * logoSpacing[1] + yOff, 0)); @@ -831,26 +840,36 @@ void SystemView::manageFavorite() else if (!hasFavorite && favorite->FavoritesCount() > 0) addSystem(favorite); } -void SystemView::manageSystemsList() +void SystemView::RefreshSystemsList() { for (auto& system : mSystemManager.GetAllSystemList()) { if(system->Descriptor().IsPort()) continue; - bool hasGame = system->HasVisibleGame(); bool systemIsAlreadyVisible = false; - for (auto& mEntrie : mEntries) - if (mEntrie.object->Name() == system->Name()) + if (mEntrie.name == system->Name()) { systemIsAlreadyVisible = true; break; } - if(!systemIsAlreadyVisible && hasGame) - addSystem(system); - else if (systemIsAlreadyVisible && !hasGame) + bool isDisplayable = system->IsDisplayable(); + + if(!systemIsAlreadyVisible && isDisplayable) { + for( const auto s : mCompleteList) + if(system == s.object) + this->add(s); + } + + if (systemIsAlreadyVisible && !isDisplayable) removeSystem(system); } + if(mEntries.empty()) { + ViewController::Instance().CheckEmptySystemList(); + RefreshSystemsList(); + } + + Sort(); } diff --git a/projects/frontend/es-app/src/views/SystemView.h b/projects/frontend/es-app/src/views/SystemView.h index a7f0d72cd1..394ca00d15 100755 --- a/projects/frontend/es-app/src/views/SystemView.h +++ b/projects/frontend/es-app/src/views/SystemView.h @@ -65,7 +65,7 @@ public: /*! * @brief update view with only visible games systems */ - void manageSystemsList(); + void RefreshSystemsList(); /*! * @brief Add a system to system view @@ -112,4 +112,7 @@ private: bool mViewNeedsReload; bool mShowing; bool launchKodi; + + std::vector mCompleteList; + }; diff --git a/projects/frontend/es-app/src/views/ViewController.cpp b/projects/frontend/es-app/src/views/ViewController.cpp index a4fd993648..c4159f8229 100755 --- a/projects/frontend/es-app/src/views/ViewController.cpp +++ b/projects/frontend/es-app/src/views/ViewController.cpp @@ -54,22 +54,15 @@ ViewController::ViewController(WindowManager& window, SystemManager& systemManag void ViewController::goToStart() { - CheckFilters(); + CheckEmptySystemList(); std::string systemName = RecalboxConf::Instance().GetStartupSelectedSystem(); int index = systemName.empty() ? -1 : mSystemManager.getVisibleSystemIndex(systemName); SystemData* selectedSystem = index < 0 ? nullptr : mSystemManager.GetVisibleSystemList()[index]; - if ((selectedSystem == nullptr) || !selectedSystem->HasVisibleGame()) + if ((selectedSystem == nullptr) || !selectedSystem->IsDisplayable()) selectedSystem = mSystemManager.FirstNonEmptySystem(); - if (selectedSystem == nullptr) - { - - mWindow.pushGui(new GuiMsgBox(mWindow, "Your filters preferences hide all your games !\nThe filters will be reseted and recalbox will be reloaded.", _("OK"), [this] { ResetFilters();})); - return; - } - if (RecalboxConf::Instance().GetStartupHideSystemView()) goToGameList(selectedSystem); else @@ -81,13 +74,14 @@ void ViewController::goToStart() } } -bool ViewController::CheckFilters() +bool ViewController::CheckEmptySystemList() { if(mSystemManager.FirstNonEmptySystem() == nullptr) { ResetFilters(); - mWindow.pushGui(new GuiMsgBox(mWindow, "Your filters preferences hide all your games !\nAll filters have been reseted.", _("OK"), []{})); + EnabledAllSystems(); + mWindow.pushGui(new GuiMsgBox(mWindow, "Your filters preferences hide all your games !\nAll filters have been reseted.", _("OK") )); return false; } return true; @@ -103,8 +97,17 @@ void ViewController::ResetFilters() conf.SetHideNoGames(false); conf.SetFilterAdultGames(false); - conf.SetCollectionHide("ports",false); -// MainRunner::RequestQuit(MainRunner::ExitState::Relaunch, true); +} + +void ViewController::EnabledAllSystems() +{ + RecalboxConf& conf = RecalboxConf::Instance(); + + for(const auto & system : mSystemManager.GetVisibleSystemList()) + { + conf.SetBool(system->Name() + ".ignore", false); + } + RecalboxConf::Instance().Save(); } int ViewController::getSystemId(SystemData* system) @@ -122,10 +125,10 @@ void ViewController::goToQuitScreen() void ViewController::goToSystemView(SystemData* system) { - CheckFilters(); + CheckEmptySystemList(); mSystemListView.setPosition((float)getSystemId(system) * Renderer::Instance().DisplayWidthAsFloat(), mSystemListView.getPosition().y()); - if (!system->HasVisibleGame()) { + if (!system->IsDisplayable()) { system = mSystemManager.FirstNonEmptySystem(); } @@ -172,7 +175,7 @@ void ViewController::quitGameClipView() goToSystemView(mSystemListView.getSelected()); break; case ViewMode::GameList: - if(mState.getSystem()->HasVisibleGame()) + if(mState.getSystem()->IsDisplayable()) goToGameList(mState.getSystem()); else goToStart(); break; @@ -221,9 +224,9 @@ void ViewController::goToNextGameList() SystemData* system = getState().getSystem(); assert(system); - CheckFilters(); + CheckEmptySystemList(); SystemData* next = mSystemManager.NextVisible(system); - while(!next->HasVisibleGame()) { + while(!next->IsDisplayable()) { next = mSystemManager.NextVisible(next); } @@ -239,9 +242,9 @@ void ViewController::goToPrevGameList() SystemData* system = getState().getSystem(); assert(system); - CheckFilters(); + CheckEmptySystemList(); SystemData* prev = mSystemManager.PreviousVisible(system); - while(!prev->HasVisibleGame()) { + while(!prev->IsDisplayable()) { prev = mSystemManager.PreviousVisible(prev); } @@ -780,7 +783,7 @@ void ViewController::Render(const Transform4x4f& parentTrans) bool ViewController::reloadGameListView(IGameListView* view, bool reloadTheme) { - if (view->System().HasVisibleGame()) + if (view->System().IsDisplayable()) { for (auto it = mGameListViews.begin(); it != mGameListViews.end(); it++) { @@ -846,3 +849,23 @@ void ViewController::ApplyHelpStyle() return mCurrentView->ApplyHelpStyle(); } +void ViewController::RefreshSystems() +{ + CheckEmptySystemList(); + + // usefull when changing filters inside a system + // if system displayable refresh game list + // else redirect to system view pev system + SystemData* currentSystem = getState().getSystem(); + getGameListView(currentSystem)->refreshList(); + if(mState.viewing == ViewMode::GameList) + currentSystem->IsDisplayable()? getGameListView(currentSystem)->refreshList() :goToSystemView(getSystemListView().Prev()); + + + setAllInvalidGamesList(nullptr); + getSystemListView().RefreshSystemsList(); + + // for updating game counts on system view + getSystemListView().onCursorChanged(CursorState::Stopped); +} + diff --git a/projects/frontend/es-app/src/views/ViewController.h b/projects/frontend/es-app/src/views/ViewController.h index cf3ccad4be..877165780d 100644 --- a/projects/frontend/es-app/src/views/ViewController.h +++ b/projects/frontend/es-app/src/views/ViewController.h @@ -39,6 +39,11 @@ public: void setInvalidGamesList(SystemData* system); void setAllInvalidGamesList(SystemData* systemExclude); + /*! + * @brief Refresh all systems + */ + void RefreshSystems(); + // Navigation. void goToNextGameList(); void goToPrevGameList(); @@ -98,7 +103,7 @@ public: */ IProgressInterface& GetProgressInterface() { return mSplashView; } - bool CheckFilters(); + bool CheckEmptySystemList(); /* * Gui implementation @@ -163,4 +168,9 @@ public: * @brief Reset game filters */ void ResetFilters(); + + /*! + * @brief Reset game filters + */ + void EnabledAllSystems(); }; diff --git a/projects/frontend/es-app/src/views/gamelist/BasicGameListView.cpp b/projects/frontend/es-app/src/views/gamelist/BasicGameListView.cpp index bbed706f70..4ac5a17353 100644 --- a/projects/frontend/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/projects/frontend/es-app/src/views/gamelist/BasicGameListView.cpp @@ -251,7 +251,7 @@ void BasicGameListView::setCursor(FileData* cursor) void BasicGameListView::removeEntry(FileData* fileData) { - if (!mCursorStack.empty() && !fileData->Parent()->HasVisibleGame()) + if (!mCursorStack.empty() && !fileData->Parent()->IsDisplayable()) { //FolderData* selected = mCursorStack.top(); -- GitLab