diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index 364160fff..fcd74b050 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -258,6 +258,10 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS if (name == "favorites" && file->metadata.get("favorite") == "false") { // need to check if still marked as favorite, if not remove ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, false); + + // Send an event when removing from favorites + ViewController::get()->onFileChanged(file, FILE_METADATA_CHANGED); + ViewController::get()->getGameListView(curSys)->onFileChanged(collectionEntry, FILE_METADATA_CHANGED); } else { diff --git a/es-app/src/EmulationStation.h b/es-app/src/EmulationStation.h index 3af2071aa..1cd346ca5 100644 --- a/es-app/src/EmulationStation.h +++ b/es-app/src/EmulationStation.h @@ -7,7 +7,7 @@ #define PROGRAM_VERSION_MAJOR 2 #define PROGRAM_VERSION_MINOR 10 #define PROGRAM_VERSION_MAINTENANCE 0 -#define PROGRAM_VERSION_STRING "2.10.0rp-dev" +#define PROGRAM_VERSION_STRING "2.10.0DE-dev" #define PROGRAM_BUILT_STRING __DATE__ " - " __TIME__ diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 31b9848b8..dc5bb3c9c 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -79,6 +79,7 @@ const std::string FileData::getThumbnailPath() const return thumbnail; } + const std::string& FileData::getName() { return metadata.get("name"); @@ -92,6 +93,14 @@ const std::string& FileData::getSortName() return metadata.get("sortname"); } +const bool FileData::getFavorite() +{ + if (metadata.get("favorite") == "true") + return true; + else + return false; +} + const std::vector& FileData::getChildrenListToDisplay() { FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex(); diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 63a9ce16e..80b376008 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -38,6 +38,7 @@ public: virtual const std::string& getName(); virtual const std::string& getSortName(); + virtual const bool getFavorite(); inline FileType getType() const { return mType; } inline const std::string& getPath() const { return mPath; } inline FileData* getParent() const { return mParent; } diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 0f34628f9..6c47b4eb6 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -372,6 +372,16 @@ void GuiMenu::openUISettings() s->addWithLabel("DISABLE START MENU IN KID MODE", disable_start); s->addSaveFunc([disable_start] { Settings::getInstance()->setBool("DisableKidStartMenu", disable_start->getState()); }); + // Show favorites first in gamelists + auto favoritesFirstSwitch = std::make_shared(mWindow); + favoritesFirstSwitch->setState(Settings::getInstance()->getBool("FavoritesFirst")); + s->addWithLabel("SHOW FAVORITES ON TOP OF GAMELIST", favoritesFirstSwitch); + s->addSaveFunc([favoritesFirstSwitch] + { + if (Settings::getInstance()->setBool("FavoritesFirst", favoritesFirstSwitch->getState())) + ViewController::get()->reloadAll(); + }); + mWindow->pushGui(s); } @@ -487,6 +497,7 @@ void GuiMenu::openQuitMenu() ComponentListRow row; if (UIModeController::getInstance()->isUIModeFull()) { + row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES", [] { @@ -514,6 +525,7 @@ void GuiMenu::openQuitMenu() s->addRow(row); } } + row.elements.clear(); row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES", @@ -527,6 +539,8 @@ void GuiMenu::openQuitMenu() row.addElement(std::make_shared(window, "RESTART SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); s->addRow(row); + + row.elements.clear(); row.makeAcceptInputHandler([window] { window->pushGui(new GuiMsgBox(window, "REALLY SHUTDOWN?", "YES", diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index 899f12578..a5811b532 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -45,9 +45,57 @@ void BasicGameListView::populateList(const std::vector& files) mHeaderText.setText(mRoot->getSystem()->getFullName()); if (files.size() > 0) { - for(auto it = files.cbegin(); it != files.cend(); it++) + + std::string systemName = mRoot->getSystem()->getName(); + + bool favoritesFirst = Settings::getInstance()->getBool("FavoritesFirst"); + +// auto fav = Settings::getInstance()->getString(mRoot->getSystem()->getName() + ".FavoritesFirst"); +// if (fav == "1") favoritesFirst = true; +// else if (fav == "0") favoritesFirst = false; + + bool showFavoriteIcon = (systemName != "favorites" && systemName != "recent"); + if (!showFavoriteIcon) + favoritesFirst = false; + + if (favoritesFirst) { - mList.add((*it)->getName(), *it, ((*it)->getType() == FOLDER)); + for (auto file : files) + { + if (!file->getFavorite()) + continue; + + if (showFavoriteIcon) +// mList.add(("\uF006 ") + file->getName(), file, file->getType() == FOLDER); +// Quick fix for now until I've fixed the issue with Unicode rendering (Leon) + mList.add("** " + file->getName(), file, file->getType() == FOLDER); + else if (file->getType() == FOLDER) + mList.add(("\uF07C ") + file->getName(), file, true); + else + mList.add(file->getName(), file, false); + } + } + + for (auto file : files) + { + if (file->getFavorite()) + { + if (favoritesFirst) + continue; + + if (showFavoriteIcon) + { +// mList.add(("\uF006 ") + file->getName(), file, file->getType() == FOLDER); +// Quick fix for now until I've fixed the issue with Unicode rendering (Leon) + mList.add(("** ") + file->getName(), file, file->getType() == FOLDER); + continue; + } + } + + if (file->getType() == FOLDER) + mList.add(("\uF07C ") + file->getName(), file, true); + else + mList.add(file->getName(), file, false); } } else diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index c4d28b653..ec046a7a5 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -38,6 +38,7 @@ std::vector settings_dont_save { Settings::Settings() { + mWasChanged = false; setDefaults(); loadFile(); } @@ -139,6 +140,8 @@ void Settings::setDefaults() mBoolMap["SortAllSystems"] = false; mBoolMap["UseCustomCollectionsSystem"] = true; + mBoolMap["FavoritesFirst"] = true; + mBoolMap["LocalArt"] = false; // Audio out device for volume control @@ -251,9 +254,17 @@ void Settings::processBackwardCompatibility() } \ return mapName[name]; \ } \ -void Settings::setMethodName(const std::string& name, type value) \ +bool Settings::setMethodName(const std::string& name, type value) \ { \ - mapName[name] = value; \ + if (mapName.count(name) == 0 || mapName[name] != value) { \ + mapName[name] = value; \ +\ + if (std::find(settings_dont_save.cbegin(), settings_dont_save.cend(), name) == settings_dont_save.cend()) \ + mWasChanged = true; \ +\ + return true; \ + } \ + return false; \ } SETTINGS_GETSET(bool, mBoolMap, getBool, setBool); diff --git a/es-core/src/Settings.h b/es-core/src/Settings.h index e9b9f7f03..0a21e85cf 100644 --- a/es-core/src/Settings.h +++ b/es-core/src/Settings.h @@ -19,10 +19,10 @@ public: float getFloat(const std::string& name); const std::string& getString(const std::string& name); - void setBool(const std::string& name, bool value); - void setInt(const std::string& name, int value); - void setFloat(const std::string& name, float value); - void setString(const std::string& name, const std::string& value); + bool setBool(const std::string& name, bool value); + bool setInt(const std::string& name, int value); + bool setFloat(const std::string& name, float value); + bool setString(const std::string& name, const std::string& value); private: static Settings* sInstance; @@ -33,6 +33,8 @@ private: void setDefaults(); void processBackwardCompatibility(); + bool mWasChanged; + std::map mBoolMap; std::map mIntMap; std::map mFloatMap;