mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Fixed an issue with collection gamelists getting loaded in the wrong order on startup.
This commit is contained in:
parent
f22da24486
commit
397ad15de6
|
@ -33,16 +33,14 @@
|
|||
#include "utils/StringUtil.h"
|
||||
#include "utils/TimeUtil.h"
|
||||
#include "views/GamelistView.h"
|
||||
#include "views/ViewController.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <pugixml.hpp>
|
||||
#include <random>
|
||||
|
||||
#define LAST_PLAYED_MAX 50
|
||||
|
||||
CollectionSystemsManager::CollectionSystemsManager() noexcept
|
||||
: mWindow {Window::getInstance()}
|
||||
, mApplicationStartup {false}
|
||||
{
|
||||
// clang-format off
|
||||
CollectionSystemDecl systemDecls[] {
|
||||
|
@ -191,6 +189,7 @@ void CollectionSystemsManager::saveCustomCollection(SystemData* sys)
|
|||
|
||||
void CollectionSystemsManager::loadCollectionSystems()
|
||||
{
|
||||
mApplicationStartup = true;
|
||||
initAutoCollectionSystems();
|
||||
CollectionSystemDecl decl {mCollectionSystemDeclsIndex[myCollectionsName]};
|
||||
mCustomCollectionsBundle = createNewCollectionEntry(decl.name, decl, false);
|
||||
|
@ -205,6 +204,8 @@ void CollectionSystemsManager::loadCollectionSystems()
|
|||
// Add to the main System Vector, and create Views as needed.
|
||||
updateSystemsList();
|
||||
}
|
||||
|
||||
mApplicationStartup = false;
|
||||
}
|
||||
|
||||
void CollectionSystemsManager::loadEnabledListFromSettings()
|
||||
|
@ -259,6 +260,9 @@ void CollectionSystemsManager::updateSystemsList()
|
|||
// Add auto enabled collections.
|
||||
addEnabledCollectionsToDisplayedSystems(&mAutoCollectionSystemsData);
|
||||
|
||||
if (mApplicationStartup)
|
||||
return;
|
||||
|
||||
// Create views for collections, before reload.
|
||||
for (auto sysIt = SystemData::sSystemVector.cbegin(); // Line break.
|
||||
sysIt != SystemData::sSystemVector.cend(); ++sysIt) {
|
||||
|
@ -1196,13 +1200,14 @@ void CollectionSystemsManager::populateAutoCollection(CollectionSystemData* sysD
|
|||
rootFolder->sort(rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavoritesFirst"));
|
||||
|
||||
if (sysDecl.type == AUTO_LAST_PLAYED)
|
||||
if (!mApplicationStartup && sysDecl.type == AUTO_LAST_PLAYED)
|
||||
trimCollectionCount(rootFolder, LAST_PLAYED_MAX);
|
||||
|
||||
// For the 'recent' collection we need to populate the gamelist once more as the
|
||||
// collection was trimmed down to 50 items. If we don't do this, the game count will
|
||||
// not be correct as it would include all the games prior to trimming.
|
||||
if (rootFolder->getName() == "recent" && !rootFolder->getChildrenRecursive().empty()) {
|
||||
if (!mApplicationStartup && rootFolder->getName() == "recent" &&
|
||||
!rootFolder->getChildrenRecursive().empty()) {
|
||||
// The following is needed to avoid a crash when repopulating the system as the previous
|
||||
// cursor pointer may point to a random memory address.
|
||||
auto recentGamelist =
|
||||
|
@ -1348,10 +1353,13 @@ void CollectionSystemsManager::addEnabledCollectionsToDisplayedSystems(
|
|||
rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||
Settings::getInstance()->getBool("FavFirstCustom"));
|
||||
// Jump to the first row of the game list, assuming it's not empty.
|
||||
GamelistView* gameList {
|
||||
ViewController::getInstance()->getGamelistView((it->second.system)).get()};
|
||||
if (!gameList->getCursor()->isPlaceHolder()) {
|
||||
gameList->setCursor(gameList->getFirstEntry());
|
||||
if (!mApplicationStartup) {
|
||||
GamelistView* gameList {ViewController::getInstance()
|
||||
->getGamelistView((it->second.system))
|
||||
.get()};
|
||||
if (!gameList->getCursor()->isPlaceHolder()) {
|
||||
gameList->setCursor(gameList->getFirstEntry());
|
||||
}
|
||||
}
|
||||
it->second.system->setIsGroupedCustomCollection(false);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
#ifndef ES_APP_COLLECTION_SYSTEM_MANAGER_H
|
||||
#define ES_APP_COLLECTION_SYSTEM_MANAGER_H
|
||||
|
||||
#define LAST_PLAYED_MAX 50
|
||||
|
||||
#include "utils/StringUtil.h"
|
||||
#include "views/ViewController.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
@ -136,6 +139,11 @@ public:
|
|||
|
||||
static inline std::string myCollectionsName = "collections";
|
||||
|
||||
protected:
|
||||
void trimCollectionCount(FileData* rootFolder, int limit);
|
||||
|
||||
friend ViewController;
|
||||
|
||||
private:
|
||||
CollectionSystemsManager() noexcept;
|
||||
|
||||
|
@ -146,6 +154,7 @@ private:
|
|||
Window* mWindow;
|
||||
bool mIsEditingCustom;
|
||||
bool mHasEnabledCustomCollection;
|
||||
bool mApplicationStartup;
|
||||
std::string mEditingCollection;
|
||||
CollectionSystemData* mEditingCollectionSystemData;
|
||||
SystemData* mCustomCollectionsBundle;
|
||||
|
@ -180,7 +189,6 @@ private:
|
|||
std::vector<std::string> getCollectionThemeFolders(bool custom);
|
||||
// Return the theme folders in use for the user-defined custom collections.
|
||||
std::vector<std::string> getUserCollectionThemeFolders();
|
||||
void trimCollectionCount(FileData* rootFolder, int limit);
|
||||
// Return whether a specific folder exists in the theme.
|
||||
const bool themeFolderExists(const std::string& folder);
|
||||
const bool includeFileInAutoCollections(FileData* file);
|
||||
|
|
|
@ -1144,11 +1144,14 @@ void ViewController::preload()
|
|||
// Load navigation sounds, either from the theme if it supports it, or otherwise from
|
||||
// the bundled fallback sound files.
|
||||
bool themeSoundSupport {false};
|
||||
for (SystemData* system : SystemData::sSystemVector) {
|
||||
for (auto system : SystemData::sSystemVector) {
|
||||
if (system->getTheme()->hasView("all")) {
|
||||
NavigationSounds::getInstance().loadThemeNavigationSounds(system->getTheme().get());
|
||||
themeSoundSupport = true;
|
||||
break;
|
||||
}
|
||||
if (system->getRootFolder()->getName() == "recent") {
|
||||
CollectionSystemsManager::getInstance()->trimCollectionCount(system->getRootFolder(),
|
||||
LAST_PLAYED_MAX);
|
||||
}
|
||||
}
|
||||
if (!SystemData::sSystemVector.empty() && !themeSoundSupport)
|
||||
|
|
Loading…
Reference in a new issue