GameList: Auto set cache/database path from user directory

This commit is contained in:
Connor McLaughlin
2020-01-24 14:51:09 +10:00
parent feb48899c3
commit b4c06fdcc6
9 changed files with 35 additions and 64 deletions

View File

@ -676,7 +676,7 @@ const GameListDatabaseEntry* GameList::GetDatabaseEntryForCode(const std::string
return (iter != m_database.end()) ? &iter->second : nullptr;
}
void GameList::SetPathsFromSettings(SettingsInterface& si)
void GameList::SetSearchDirectoriesFromSettings(SettingsInterface& si)
{
m_search_directories.clear();
@ -687,9 +687,6 @@ void GameList::SetPathsFromSettings(SettingsInterface& si)
dirs = si.GetStringList("GameList", "RecursivePaths");
for (std::string& dir : dirs)
m_search_directories.push_back({std::move(dir), true});
m_database_filename = si.GetStringValue("GameList", "RedumpDatabasePath");
m_cache_filename = si.GetStringValue("GameList", "CachePath");
}
void GameList::Refresh(bool invalidate_cache, bool invalidate_database)

View File

@ -63,7 +63,10 @@ public:
const GameListEntry* GetEntryForPath(const char* path) const;
const GameListDatabaseEntry* GetDatabaseEntryForCode(const std::string& code) const;
void SetPathsFromSettings(SettingsInterface& si);
void SetCacheFilename(std::string filename) { m_cache_filename = std::move(filename); }
void SetDatabaseFilename(std::string filename) { m_database_filename = std::move(filename); }
void SetSearchDirectoriesFromSettings(SettingsInterface& si);
void AddDirectory(std::string path, bool recursive);
void Refresh(bool invalidate_cache, bool invalidate_database);

View File

@ -54,6 +54,8 @@ HostInterface::HostInterface()
{
SetUserDirectory();
m_game_list = std::make_unique<GameList>();
m_game_list->SetCacheFilename(GetGameListCacheFileName());
m_game_list->SetDatabaseFilename(GetGameListDatabaseFileName());
m_settings.SetDefaults();
m_last_throttle_time = Common::Timer::GetValue();
}
@ -485,6 +487,16 @@ std::string HostInterface::GetSettingsFileName() const
return GetUserDirectoryRelativePath("settings.ini");
}
std::string HostInterface::GetGameListCacheFileName() const
{
return GetUserDirectoryRelativePath("cache/gamelist.cache");
}
std::string HostInterface::GetGameListDatabaseFileName() const
{
return GetUserDirectoryRelativePath("cache/redump.dat");
}
void HostInterface::RunFrame()
{
m_frame_timer.Reset();

View File

@ -93,6 +93,12 @@ protected:
/// Returns the path of the settings file.
std::string GetSettingsFileName() const;
/// Returns the path of the game list cache file.
std::string GetGameListCacheFileName() const;
/// Returns the path of the game database cache file.
std::string GetGameListDatabaseFileName() const;
void RunFrame();
/// Throttles the system, i.e. sleeps until it's time to execute the next frame.