mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-18 04:45:39 +00:00
Added functionality to show favorites on top of the gamelists (mostly ported from batocera-emulationstation)
This commit is contained in:
parent
37dd9874f2
commit
1007f19bdc
|
@ -258,6 +258,10 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
|
||||||
if (name == "favorites" && file->metadata.get("favorite") == "false") {
|
if (name == "favorites" && file->metadata.get("favorite") == "false") {
|
||||||
// need to check if still marked as favorite, if not remove
|
// need to check if still marked as favorite, if not remove
|
||||||
ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, false);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#define PROGRAM_VERSION_MAJOR 2
|
#define PROGRAM_VERSION_MAJOR 2
|
||||||
#define PROGRAM_VERSION_MINOR 10
|
#define PROGRAM_VERSION_MINOR 10
|
||||||
#define PROGRAM_VERSION_MAINTENANCE 0
|
#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__
|
#define PROGRAM_BUILT_STRING __DATE__ " - " __TIME__
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ const std::string FileData::getThumbnailPath() const
|
||||||
return thumbnail;
|
return thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::string& FileData::getName()
|
const std::string& FileData::getName()
|
||||||
{
|
{
|
||||||
return metadata.get("name");
|
return metadata.get("name");
|
||||||
|
@ -92,6 +93,14 @@ const std::string& FileData::getSortName()
|
||||||
return metadata.get("sortname");
|
return metadata.get("sortname");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool FileData::getFavorite()
|
||||||
|
{
|
||||||
|
if (metadata.get("favorite") == "true")
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
|
const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
|
||||||
|
|
||||||
FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex();
|
FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex();
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
|
|
||||||
virtual const std::string& getName();
|
virtual const std::string& getName();
|
||||||
virtual const std::string& getSortName();
|
virtual const std::string& getSortName();
|
||||||
|
virtual const bool getFavorite();
|
||||||
inline FileType getType() const { return mType; }
|
inline FileType getType() const { return mType; }
|
||||||
inline const std::string& getPath() const { return mPath; }
|
inline const std::string& getPath() const { return mPath; }
|
||||||
inline FileData* getParent() const { return mParent; }
|
inline FileData* getParent() const { return mParent; }
|
||||||
|
|
|
@ -372,6 +372,16 @@ void GuiMenu::openUISettings()
|
||||||
s->addWithLabel("DISABLE START MENU IN KID MODE", disable_start);
|
s->addWithLabel("DISABLE START MENU IN KID MODE", disable_start);
|
||||||
s->addSaveFunc([disable_start] { Settings::getInstance()->setBool("DisableKidStartMenu", disable_start->getState()); });
|
s->addSaveFunc([disable_start] { Settings::getInstance()->setBool("DisableKidStartMenu", disable_start->getState()); });
|
||||||
|
|
||||||
|
// Show favorites first in gamelists
|
||||||
|
auto favoritesFirstSwitch = std::make_shared<SwitchComponent>(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);
|
mWindow->pushGui(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -487,6 +497,7 @@ void GuiMenu::openQuitMenu()
|
||||||
ComponentListRow row;
|
ComponentListRow row;
|
||||||
if (UIModeController::getInstance()->isUIModeFull())
|
if (UIModeController::getInstance()->isUIModeFull())
|
||||||
{
|
{
|
||||||
|
|
||||||
row.makeAcceptInputHandler([window] {
|
row.makeAcceptInputHandler([window] {
|
||||||
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES",
|
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES",
|
||||||
[] {
|
[] {
|
||||||
|
@ -514,6 +525,7 @@ void GuiMenu::openQuitMenu()
|
||||||
s->addRow(row);
|
s->addRow(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
row.elements.clear();
|
row.elements.clear();
|
||||||
row.makeAcceptInputHandler([window] {
|
row.makeAcceptInputHandler([window] {
|
||||||
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES",
|
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES",
|
||||||
|
@ -527,6 +539,8 @@ void GuiMenu::openQuitMenu()
|
||||||
row.addElement(std::make_shared<TextComponent>(window, "RESTART SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
row.addElement(std::make_shared<TextComponent>(window, "RESTART SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||||
s->addRow(row);
|
s->addRow(row);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
row.elements.clear();
|
row.elements.clear();
|
||||||
row.makeAcceptInputHandler([window] {
|
row.makeAcceptInputHandler([window] {
|
||||||
window->pushGui(new GuiMsgBox(window, "REALLY SHUTDOWN?", "YES",
|
window->pushGui(new GuiMsgBox(window, "REALLY SHUTDOWN?", "YES",
|
||||||
|
|
|
@ -45,9 +45,57 @@ void BasicGameListView::populateList(const std::vector<FileData*>& files)
|
||||||
mHeaderText.setText(mRoot->getSystem()->getFullName());
|
mHeaderText.setText(mRoot->getSystem()->getFullName());
|
||||||
if (files.size() > 0)
|
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
|
else
|
||||||
|
|
|
@ -38,6 +38,7 @@ std::vector<const char*> settings_dont_save {
|
||||||
|
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
{
|
{
|
||||||
|
mWasChanged = false;
|
||||||
setDefaults();
|
setDefaults();
|
||||||
loadFile();
|
loadFile();
|
||||||
}
|
}
|
||||||
|
@ -139,6 +140,8 @@ void Settings::setDefaults()
|
||||||
mBoolMap["SortAllSystems"] = false;
|
mBoolMap["SortAllSystems"] = false;
|
||||||
mBoolMap["UseCustomCollectionsSystem"] = true;
|
mBoolMap["UseCustomCollectionsSystem"] = true;
|
||||||
|
|
||||||
|
mBoolMap["FavoritesFirst"] = true;
|
||||||
|
|
||||||
mBoolMap["LocalArt"] = false;
|
mBoolMap["LocalArt"] = false;
|
||||||
|
|
||||||
// Audio out device for volume control
|
// Audio out device for volume control
|
||||||
|
@ -251,9 +254,17 @@ void Settings::processBackwardCompatibility()
|
||||||
} \
|
} \
|
||||||
return mapName[name]; \
|
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);
|
SETTINGS_GETSET(bool, mBoolMap, getBool, setBool);
|
||||||
|
|
|
@ -19,10 +19,10 @@ public:
|
||||||
float getFloat(const std::string& name);
|
float getFloat(const std::string& name);
|
||||||
const std::string& getString(const std::string& name);
|
const std::string& getString(const std::string& name);
|
||||||
|
|
||||||
void setBool(const std::string& name, bool value);
|
bool setBool(const std::string& name, bool value);
|
||||||
void setInt(const std::string& name, int value);
|
bool setInt(const std::string& name, int value);
|
||||||
void setFloat(const std::string& name, float value);
|
bool setFloat(const std::string& name, float value);
|
||||||
void setString(const std::string& name, const std::string& value);
|
bool setString(const std::string& name, const std::string& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Settings* sInstance;
|
static Settings* sInstance;
|
||||||
|
@ -33,6 +33,8 @@ private:
|
||||||
void setDefaults();
|
void setDefaults();
|
||||||
void processBackwardCompatibility();
|
void processBackwardCompatibility();
|
||||||
|
|
||||||
|
bool mWasChanged;
|
||||||
|
|
||||||
std::map<std::string, bool> mBoolMap;
|
std::map<std::string, bool> mBoolMap;
|
||||||
std::map<std::string, int> mIntMap;
|
std::map<std::string, int> mIntMap;
|
||||||
std::map<std::string, float> mFloatMap;
|
std::map<std::string, float> mFloatMap;
|
||||||
|
|
Loading…
Reference in a new issue