mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 15:15:37 +00:00
Change handling of screensaver to FileData only and respect UI Mode
This commit is contained in:
parent
70da690ca4
commit
55e4c47e4b
|
@ -14,10 +14,8 @@
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
#include <pugixml/src/pugixml.hpp>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define FADE_TIME 300
|
#define FADE_TIME 300
|
||||||
|
|
||||||
SystemScreenSaver::SystemScreenSaver(Window* window) :
|
SystemScreenSaver::SystemScreenSaver(Window* window) :
|
||||||
|
@ -262,27 +260,21 @@ unsigned long SystemScreenSaver::countGameListNodes(const char *nodeName)
|
||||||
std::vector<SystemData*>::const_iterator it;
|
std::vector<SystemData*>::const_iterator it;
|
||||||
for (it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); ++it)
|
for (it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); ++it)
|
||||||
{
|
{
|
||||||
// We only want images and videos from game systems that are not collections
|
// We only want nodes from game systems that are not collections
|
||||||
if (!(*it)->isCollection() && (*it)->isGameSystem())
|
if (!(*it)->isGameSystem() || (*it)->isCollection())
|
||||||
{
|
continue;
|
||||||
pugi::xml_document doc;
|
|
||||||
pugi::xml_node root;
|
|
||||||
std::string xmlReadPath = (*it)->getGamelistPath(false);
|
|
||||||
|
|
||||||
if(Utils::FileSystem::exists(xmlReadPath))
|
FileData* rootFileData = (*it)->getRootFolder();
|
||||||
|
|
||||||
|
FileType type = GAME;
|
||||||
|
std::vector<FileData*> allFiles = rootFileData->getFilesRecursive(type, true);
|
||||||
|
std::vector<FileData*>::const_iterator itf; // declare an iterator to a vector of strings
|
||||||
|
|
||||||
|
for(itf=allFiles.cbegin() ; itf < allFiles.cend(); itf++) {
|
||||||
|
if ((strcmp(nodeName, "video") == 0 && (*itf)->getVideoPath() != "") ||
|
||||||
|
(strcmp(nodeName, "image") == 0 && (*itf)->getImagePath() != ""))
|
||||||
{
|
{
|
||||||
pugi::xml_parse_result result = doc.load_file(xmlReadPath.c_str());
|
nodeCount++;
|
||||||
if (!result)
|
|
||||||
continue;
|
|
||||||
root = doc.child("gameList");
|
|
||||||
if (!root)
|
|
||||||
continue;
|
|
||||||
for(pugi::xml_node fileNode = root.child("game"); fileNode; fileNode = fileNode.next_sibling("game"))
|
|
||||||
{
|
|
||||||
pugi::xml_node node = fileNode.child(nodeName);
|
|
||||||
if (node)
|
|
||||||
++nodeCount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,70 +304,31 @@ void SystemScreenSaver::pickGameListNode(unsigned long index, const char *nodeNa
|
||||||
std::vector<SystemData*>::const_iterator it;
|
std::vector<SystemData*>::const_iterator it;
|
||||||
for (it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); ++it)
|
for (it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); ++it)
|
||||||
{
|
{
|
||||||
pugi::xml_document doc;
|
|
||||||
pugi::xml_node root;
|
|
||||||
|
|
||||||
// We only want nodes from game systems that are not collections
|
// We only want nodes from game systems that are not collections
|
||||||
if (!(*it)->isGameSystem() || (*it)->isCollection())
|
if (!(*it)->isGameSystem() || (*it)->isCollection())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string xmlReadPath = (*it)->getGamelistPath(false);
|
|
||||||
|
|
||||||
if(Utils::FileSystem::exists(xmlReadPath))
|
|
||||||
{
|
|
||||||
pugi::xml_parse_result result = doc.load_file(xmlReadPath.c_str());
|
|
||||||
if (!result)
|
|
||||||
continue;
|
|
||||||
root = doc.child("gameList");
|
|
||||||
if (!root)
|
|
||||||
continue;
|
|
||||||
for(pugi::xml_node fileNode = root.child("game"); fileNode; fileNode = fileNode.next_sibling("game"))
|
|
||||||
{
|
|
||||||
pugi::xml_node node = fileNode.child(nodeName);
|
|
||||||
if (node)
|
|
||||||
{
|
|
||||||
// See if this is the desired index
|
|
||||||
if (index-- == 0)
|
|
||||||
{
|
|
||||||
// Yes. Resolve to a full path
|
|
||||||
path = Utils::FileSystem::resolveRelativePath(node.text().get(), (*it)->getStartPath(), true);
|
|
||||||
mSystemName = (*it)->getFullName();
|
|
||||||
mGameName = fileNode.child("name").text().get();
|
|
||||||
|
|
||||||
// getting corresponding FileData
|
|
||||||
|
|
||||||
// try the easy way. Should work for the majority of cases, unless in subfolders
|
|
||||||
FileData* rootFileData = (*it)->getRootFolder();
|
FileData* rootFileData = (*it)->getRootFolder();
|
||||||
std::string gamePath = Utils::FileSystem::resolveRelativePath(fileNode.child("path").text().get(), (*it)->getStartPath(), false);
|
|
||||||
|
|
||||||
std::string shortPath = gamePath;
|
|
||||||
shortPath = shortPath.replace(0, (*it)->getStartPath().length()+1, "");
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, FileData*>& children = rootFileData->getChildrenByFilename();
|
|
||||||
std::unordered_map<std::string, FileData*>::const_iterator screenSaverGame = children.find(shortPath);
|
|
||||||
|
|
||||||
if (screenSaverGame != children.cend())
|
|
||||||
{
|
|
||||||
// Found the corresponding FileData
|
|
||||||
mCurrentGame = screenSaverGame->second;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Couldn't find FileData. Going for the full iteration.
|
|
||||||
// iterate on children
|
|
||||||
FileType type = GAME;
|
FileType type = GAME;
|
||||||
std::vector<FileData*> allFiles = rootFileData->getFilesRecursive(type);
|
std::vector<FileData*> allFiles = rootFileData->getFilesRecursive(type, true);
|
||||||
std::vector<FileData*>::const_iterator itf; // declare an iterator to a vector of strings
|
std::vector<FileData*>::const_iterator itf; // declare an iterator to a vector of strings
|
||||||
|
|
||||||
int i = 0;
|
for(itf=allFiles.cbegin() ; itf < allFiles.cend(); itf++) {
|
||||||
for(itf=allFiles.cbegin() ; itf < allFiles.cend(); itf++,i++ ) {
|
if ((strcmp(nodeName, "video") == 0 && (*itf)->getVideoPath() != "") ||
|
||||||
if ((*itf)->getPath() == gamePath)
|
(strcmp(nodeName, "image") == 0 && (*itf)->getImagePath() != ""))
|
||||||
{
|
{
|
||||||
|
if (index-- == 0)
|
||||||
|
{
|
||||||
|
// We have it
|
||||||
|
path = "";
|
||||||
|
if (strcmp(nodeName, "video") == 0)
|
||||||
|
path = (*itf)->getVideoPath();
|
||||||
|
else if (strcmp(nodeName, "image") == 0)
|
||||||
|
path = (*itf)->getImagePath();
|
||||||
|
mSystemName = (*it)->getFullName();
|
||||||
|
mGameName = (*itf)->getName();
|
||||||
mCurrentGame = (*itf);
|
mCurrentGame = (*itf);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// end of getting FileData
|
// end of getting FileData
|
||||||
if (Settings::getInstance()->getString("ScreenSaverGameInfo") != "never")
|
if (Settings::getInstance()->getString("ScreenSaverGameInfo") != "never")
|
||||||
|
@ -386,7 +339,6 @@ void SystemScreenSaver::pickGameListNode(unsigned long index, const char *nodeNa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemScreenSaver::pickRandomVideo(std::string& path)
|
void SystemScreenSaver::pickRandomVideo(std::string& path)
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
|
|
||||||
virtual FileData* getCurrentGame();
|
virtual FileData* getCurrentGame();
|
||||||
virtual void launchGame();
|
virtual void launchGame();
|
||||||
|
inline virtual void resetCounts() { mVideosCounted = false; mImagesCounted = false; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned long countGameListNodes(const char *nodeName);
|
unsigned long countGameListNodes(const char *nodeName);
|
||||||
|
|
|
@ -432,6 +432,7 @@ void Window::startScreenSaver()
|
||||||
{
|
{
|
||||||
mScreenSaver->stopScreenSaver();
|
mScreenSaver->stopScreenSaver();
|
||||||
mRenderScreenSaver = false;
|
mRenderScreenSaver = false;
|
||||||
|
mScreenSaver->resetCounts();
|
||||||
|
|
||||||
// Tell the GUI components the screensaver has stopped
|
// Tell the GUI components the screensaver has stopped
|
||||||
for(auto i = mGuiStack.cbegin(); i != mGuiStack.cend(); i++)
|
for(auto i = mGuiStack.cbegin(); i != mGuiStack.cend(); i++)
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
virtual bool isScreenSaverActive() = 0;
|
virtual bool isScreenSaverActive() = 0;
|
||||||
virtual FileData* getCurrentGame() = 0;
|
virtual FileData* getCurrentGame() = 0;
|
||||||
virtual void launchGame() = 0;
|
virtual void launchGame() = 0;
|
||||||
|
virtual void resetCounts() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InfoPopup {
|
class InfoPopup {
|
||||||
|
|
Loading…
Reference in a new issue