Disable sleep mode while scraping.

Fix to actually update metadata.
Write changes to gamelist.xml after each game is done.
This commit is contained in:
Aloshi 2013-10-13 16:40:36 -05:00
parent 69852af751
commit 12dd8b028d
7 changed files with 53 additions and 16 deletions

View file

@ -326,18 +326,12 @@ std::string SystemData::getGamelistPath()
filePath = getHomePath(); filePath = getHomePath();
filePath += "/.emulationstation/"+ getName() + "/gamelist.xml"; filePath += "/.emulationstation/"+ getName() + "/gamelist.xml";
if(fs::exists(filePath))
return filePath; return filePath;
return "";
} }
bool SystemData::hasGamelist() bool SystemData::hasGamelist()
{ {
if(getGamelistPath().empty()) return (fs::exists(getGamelistPath()));
return false;
else
return true;
} }
std::vector<MetaDataDecl> SystemData::getGameMDD() std::vector<MetaDataDecl> SystemData::getGameMDD()

View file

@ -8,7 +8,7 @@
#include <iomanip> #include <iomanip>
Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10), Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10),
mZoomFactor(1.0f), mCenterPoint(0, 0), mMatrix(Eigen::Affine3f::Identity()), mFadePercent(0.0f) mZoomFactor(1.0f), mCenterPoint(0, 0), mMatrix(Eigen::Affine3f::Identity()), mFadePercent(0.0f), mAllowSleep(true)
{ {
mInputManager = new InputManager(this); mInputManager = new InputManager(this);
setCenterPoint(Eigen::Vector2f(Renderer::getScreenWidth() / 2, Renderer::getScreenHeight() / 2)); setCenterPoint(Eigen::Vector2f(Renderer::getScreenWidth() / 2, Renderer::getScreenHeight() / 2));
@ -188,3 +188,13 @@ void Window::postProcess()
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | ((unsigned char)(mFadePercent * 255))); Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | ((unsigned char)(mFadePercent * 255)));
} }
} }
bool Window::getAllowSleep()
{
return mAllowSleep;
}
void Window::setAllowSleep(bool sleep)
{
mAllowSleep = sleep;
}

View file

@ -34,6 +34,9 @@ public:
void setFadePercent(const float& perc); void setFadePercent(const float& perc);
bool getAllowSleep();
void setAllowSleep(bool sleep);
private: private:
InputManager* mInputManager; InputManager* mInputManager;
std::vector<GuiComponent*> mGuiStack; std::vector<GuiComponent*> mGuiStack;
@ -55,6 +58,8 @@ private:
void postProcess(); void postProcess();
float mFadePercent; float mFadePercent;
bool mAllowSleep;
}; };
#endif #endif

View file

@ -100,7 +100,7 @@ void parseGamelist(SystemData* system)
{ {
std::string xmlpath = system->getGamelistPath(); std::string xmlpath = system->getGamelistPath();
if(xmlpath.empty()) if(!boost::filesystem::exists(xmlpath))
return; return;
LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"...";
@ -198,7 +198,7 @@ void updateGamelist(SystemData* system)
return; return;
std::string xmlpath = system->getGamelistPath(); std::string xmlpath = system->getGamelistPath();
if(xmlpath.empty()) if(!boost::filesystem::exists(xmlpath))
return; return;
LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\" before writing..."; LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\" before writing...";

View file

@ -3,13 +3,15 @@
#include "GuiGameScraper.h" #include "GuiGameScraper.h"
#include "../Renderer.h" #include "../Renderer.h"
#include "../Log.h" #include "../Log.h"
#include "../XMLReader.h"
GuiScraperLog::GuiScraperLog(Window* window, const std::queue<ScraperSearchParams>& searches, bool manualMode) : GuiComponent(window), GuiScraperLog::GuiScraperLog(Window* window, const std::queue<ScraperSearchParams>& searches, bool manualMode) : GuiComponent(window),
mManualMode(manualMode), mManualMode(manualMode),
mBox(window, ":/frame.png"), mBox(window, ":/frame.png"),
mSearches(searches), mSearches(searches),
mStatus(window), mStatus(window),
mTextLines(40) mTextLines(40),
mSuccessCount(0), mSkippedCount(0)
{ {
addChild(&mBox); addChild(&mBox);
addChild(&mStatus); addChild(&mStatus);
@ -25,6 +27,13 @@ GuiScraperLog::GuiScraperLog(Window* window, const std::queue<ScraperSearchParam
mBox.setEdgeColor(0x111111FF); mBox.setEdgeColor(0x111111FF);
mBox.setCenterColor(0xDFDFDFFF); mBox.setCenterColor(0xDFDFDFFF);
mBox.fitTo(mSize, Eigen::Vector3f::Zero(), Eigen::Vector2f(8, 0)); mBox.fitTo(mSize, Eigen::Vector3f::Zero(), Eigen::Vector2f(8, 0));
mWindow->setAllowSleep(false);
}
GuiScraperLog::~GuiScraperLog()
{
mWindow->setAllowSleep(true);
} }
void GuiScraperLog::start() void GuiScraperLog::start()
@ -77,8 +86,16 @@ void GuiScraperLog::resultFetched(ScraperSearchParams params, MetaDataList mdl)
void GuiScraperLog::resultResolved(ScraperSearchParams params, MetaDataList mdl) void GuiScraperLog::resultResolved(ScraperSearchParams params, MetaDataList mdl)
{ {
//apply new metadata
*params.game->metadata() = mdl;
writeLine(" Success!", 0x00FF00FF); writeLine(" Success!", 0x00FF00FF);
//write changes to gamelist.xml
updateGamelist(params.system);
mSuccessCount++;
next(); next();
} }
@ -91,14 +108,21 @@ void GuiScraperLog::resultEmpty(ScraperSearchParams search)
LOG(LogInfo) << "Scraper skipping [" << search.game->getCleanName() << "]"; LOG(LogInfo) << "Scraper skipping [" << search.game->getCleanName() << "]";
mSkippedCount++;
next(); next();
} }
void GuiScraperLog::done() void GuiScraperLog::done()
{ {
writeLine("====================", 0x000000FF); writeLine("===================================", 0x000000FF);
writeLine("DONE!!", 0x00FF00FF);
writeLine("====================", 0x000000FF); std::stringstream ss;
ss << mSuccessCount << " successful, " << mSkippedCount << " skipped";
writeLine(ss.str(), 0x000000FF);
writeLine("DONE!! Press anything to continue.", 0x00FF00FF);
writeLine("===================================", 0x000000FF);
//done with everything! //done with everything!
} }

View file

@ -11,6 +11,7 @@ class GuiScraperLog : public GuiComponent
{ {
public: public:
GuiScraperLog(Window* window, const std::queue<ScraperSearchParams>& params, bool manualMode); GuiScraperLog(Window* window, const std::queue<ScraperSearchParams>& params, bool manualMode);
~GuiScraperLog();
void start(); void start();
@ -36,4 +37,7 @@ private:
TextComponent mStatus; TextComponent mStatus;
boost::circular_buffer< std::shared_ptr<TextComponent> > mTextLines; boost::circular_buffer< std::shared_ptr<TextComponent> > mTextLines;
unsigned int mSuccessCount;
unsigned int mSkippedCount;
}; };

View file

@ -228,7 +228,7 @@ int main(int argc, char* argv[])
//sleeping entails setting a flag to start skipping frames //sleeping entails setting a flag to start skipping frames
//and initially drawing a black semi-transparent rect to dim the screen //and initially drawing a black semi-transparent rect to dim the screen
timeSinceLastEvent += deltaTime; timeSinceLastEvent += deltaTime;
if(timeSinceLastEvent >= (unsigned int)Settings::getInstance()->getInt("DIMTIME") && Settings::getInstance()->getInt("DIMTIME") != 0) if(timeSinceLastEvent >= (unsigned int)Settings::getInstance()->getInt("DIMTIME") && Settings::getInstance()->getInt("DIMTIME") != 0 && window.getAllowSleep())
{ {
sleeping = true; sleeping = true;
timeSinceLastEvent = 0; timeSinceLastEvent = 0;