Merge pull request #853 from Gemba/fb_custom_coll_during_scrsaver

Minor suggestions for "Collection use during Screensaver"
This commit is contained in:
pjft 2024-02-06 21:59:51 +00:00 committed by GitHub
commit 6c7dc88ffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 20 deletions

View file

@ -147,7 +147,7 @@ void SystemScreenSaver::setVideoScreensaver(std::string& path)
mVideoScreensaver->setScreensaverMode(true);
mVideoScreensaver->onShow();
setupScreenSaverEditingCollection();
handleScreenSaverEditingCollection();
PowerSaver::runningScreenSaver(true);
mTimer = 0;
}
@ -172,7 +172,7 @@ void SystemScreenSaver::setImageScreensaver(std::string& path)
mImageScreensaver->setMaxSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
}
setupScreenSaverEditingCollection();
handleScreenSaverEditingCollection();
PowerSaver::runningScreenSaver(true);
mTimer = 0;
}
@ -187,7 +187,7 @@ bool SystemScreenSaver::isFileVideo(std::string& path)
return pathFilter.find(pathExtension) != std::string::npos;
}
void SystemScreenSaver::setupScreenSaverEditingCollection()
void SystemScreenSaver::handleScreenSaverEditingCollection()
{
std::string screensaverCollection = Settings::getInstance()->getString("DefaultScreenSaverCollection");
std::string currentEditingCollection = CollectionSystemManager::get()->getEditingCollection();
@ -339,7 +339,7 @@ void SystemScreenSaver::stopScreenSaver(bool toResume)
// we need this to loop through different videos
mState = STATE_INACTIVE;
setupScreenSaverEditingCollection();
handleScreenSaverEditingCollection();
PowerSaver::runningScreenSaver(false);
}

View file

@ -42,7 +42,7 @@ private:
void getAllGamelistNodesForSystem(SystemData* system);
void backgroundIndexing();
void setBackground();
void setupScreenSaverEditingCollection();
void handleScreenSaverEditingCollection();
void input(InputConfig* config, Input input);
enum STATE {

View file

@ -88,21 +88,21 @@ void GuiCollectionSystemsOptions::initializeMenu()
// Add option to select default collection for screensaver
defaultScreenSaverCollection = std::make_shared< OptionListComponent<std::string> >(mWindow, "DEFAULT COLLECTION TO ADD SCREENSAVER GAMES TO", false);
defaultScreenSaverCollection = std::make_shared< OptionListComponent<std::string> >(mWindow, "ADD/REMOVE GAMES WHILE SCREENSAVER TO", false);
// Add default option
defaultScreenSaverCollection->add("<DEFAULT>", "", Settings::getInstance()->getString("DefaultScreenSaverCollection") == "");
std::string defaultScreenSaverCollectionName = Settings::getInstance()->getString("DefaultScreenSaverCollection");
defaultScreenSaverCollection->add("<DEFAULT>", "", defaultScreenSaverCollectionName == "");
std::map<std::string, CollectionSystemData> customSystems = CollectionSystemManager::get()->getCustomCollectionSystems();
// add all enabled Custom Systems
for(std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin() ; it != customSystems.cend() ; it++ )
{
if (it->second.isEnabled)
defaultScreenSaverCollection->add(it->second.decl.longName, it->second.decl.name, Settings::getInstance()->getString("DefaultScreenSaverCollection") == it->second.decl.name);
defaultScreenSaverCollection->add(it->second.decl.longName, it->second.decl.name, defaultScreenSaverCollectionName == it->second.decl.name);
}
mMenu.addWithLabel("DEFAULT COLLECTION TO ADD SCREENSAVER GAMES TO", defaultScreenSaverCollection);
mMenu.addWithLabel("ADD/REMOVE GAMES WHILE SCREENSAVER TO", defaultScreenSaverCollection);
if(CollectionSystemManager::get()->isEditing())
{
row.elements.clear();
@ -206,15 +206,21 @@ void GuiCollectionSystemsOptions::applySettings()
bool prevBundle = Settings::getInstance()->getBool("UseCustomCollectionsSystem");
bool prevShow = Settings::getInstance()->getBool("CollectionShowSystemInfo");
bool outShow = toggleSystemNameInCollections->getState();
// need to check if collection is enabled
// check if custom collection is still enabled for 'collection during screensaver'.
// if not set 'collection during screensaver' to "" which renders as <DEFAULT>
std::string enabledCollectionName = "";
if (defaultScreenSaverCollection->getSelectedObjects().size() != 0)
std::vector<std::string> selection = defaultScreenSaverCollection->getSelectedObjects();
if (selection.size() > 0)
{
std::string selectedCollection = defaultScreenSaverCollection->getSelectedObjects().at(0);
if (selectedCollection != "") {
std::string selectedCollection = selection.at(0);
if (selectedCollection != "")
{
std::vector<std::string> enabledCollections = customOptionList->getSelectedObjects();
for(auto nameIt = enabledCollections.begin(); nameIt != enabledCollections.end(); nameIt++) {
if(*nameIt == selectedCollection) {
for(auto nameIt = enabledCollections.begin(); nameIt != enabledCollections.end(); nameIt++)
{
if(*nameIt == selectedCollection)
{
enabledCollectionName = selectedCollection;
break;
}
@ -224,9 +230,10 @@ void GuiCollectionSystemsOptions::applySettings()
Settings::getInstance()->setString("DefaultScreenSaverCollection", enabledCollectionName);
Settings::getInstance()->setBool("DoublePressRemovesFromFavs", doublePressToRemoveFavs->getState());
bool needRefreshCollectionSettings = prevAuto != outAuto || prevCustom != outCustom || outSort != prevSort || outBundle != prevBundle
|| prevShow != outShow;
if (needRefreshCollectionSettings)
{
updateSettings(outAuto, outCustom);
@ -235,8 +242,6 @@ void GuiCollectionSystemsOptions::applySettings()
{
Settings::getInstance()->saveFile();
}
Settings::getInstance()->saveFile();
delete this;
}
@ -247,7 +252,9 @@ void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings, st
Settings::getInstance()->setBool("SortAllSystems", sortAllSystemsSwitch->getState());
Settings::getInstance()->setBool("UseCustomCollectionsSystem", bundleCustomCollections->getState());
Settings::getInstance()->setBool("CollectionShowSystemInfo", toggleSystemNameInCollections->getState());
Settings::getInstance()->saveFile();
CollectionSystemManager::get()->loadEnabledListFromSettings();
CollectionSystemManager::get()->updateSystemsList();
ViewController::get()->goToStart();