From 5afefc7d47ab28c50b0c54b5a3505f2e520558d9 Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Tue, 23 Jun 2015 11:54:19 -0500 Subject: [PATCH] Cleanup configuration class (moved variables to properties). --- RetroFE/Source/Database/Configuration.cpp | 37 +------------------ RetroFE/Source/Database/Configuration.h | 9 ----- RetroFE/Source/Database/MetadataDatabase.cpp | 10 ++--- .../Graphics/Component/ReloadableMedia.cpp | 7 +++- RetroFE/Source/Graphics/Page.cpp | 4 +- RetroFE/Source/RetroFE.cpp | 7 ++-- 6 files changed, 18 insertions(+), 56 deletions(-) diff --git a/RetroFE/Source/Database/Configuration.cpp b/RetroFE/Source/Database/Configuration.cpp index fbf8c1c..2fbea0f 100644 --- a/RetroFE/Source/Database/Configuration.cpp +++ b/RetroFE/Source/Database/Configuration.cpp @@ -31,7 +31,6 @@ std::string Configuration::AbsolutePath; Configuration::Configuration() - : Verbose(false) { } @@ -70,16 +69,6 @@ void Configuration::Initialize() } } -void Configuration::SetCurrentCollection(std::string collection) -{ - CurrentCollection = collection; -} - -std::string Configuration::GetCurrentCollection() -{ - return CurrentCollection; -} - bool Configuration::Import(std::string keyPrefix, std::string file) { bool retVal = true; @@ -183,10 +172,6 @@ bool Configuration::GetRawProperty(std::string key, std::string &value) retVal = true; } - else if(Verbose) - { - Logger::Write(Logger::ZONE_DEBUG, "Configuration", "Missing property " + key); - } return retVal; } @@ -197,10 +182,10 @@ bool Configuration::GetProperty(std::string key, std::string &value) std::string baseMediaPath = AbsolutePath; std::string baseItemPath = AbsolutePath; std::string collectionName; + GetProperty("currentCollection", collectionName); GetRawProperty("baseMediaPath", baseMediaPath); GetRawProperty("baseItemPath", baseItemPath); - collectionName = GetCurrentCollection(); value = Utils::Replace(value, "%BASE_MEDIA_PATH%", baseMediaPath); value = Utils::Replace(value, "%BASE_ITEM_PATH%", baseItemPath); @@ -407,23 +392,3 @@ void Configuration::GetCollectionAbsolutePath(std::string collectionName, std::s value = Utils::CombinePath(AbsolutePath, "collections", collectionName, "roms"); } - -bool Configuration::IsVerbose() const -{ - return Verbose; -} - -void Configuration::SetVerbose(bool verbose) -{ - this->Verbose = verbose; -} - -void Configuration::SetStatus(std::string status) -{ - Status = status; -} - -std::string Configuration::GetStatus() -{ - return Status; -} diff --git a/RetroFE/Source/Database/Configuration.h b/RetroFE/Source/Database/Configuration.h index 729f346..98e863c 100644 --- a/RetroFE/Source/Database/Configuration.h +++ b/RetroFE/Source/Database/Configuration.h @@ -26,12 +26,8 @@ public: virtual ~Configuration(); static void Initialize(); static std::string ConvertToAbsolutePath(std::string prefix, std::string path); - void SetStatus(std::string status); - std::string GetStatus(); // gets the global configuration bool Import(std::string keyPrefix, std::string file); - void SetCurrentCollection(std::string collection); - std::string GetCurrentCollection(); bool GetProperty(std::string key, std::string &value); bool GetProperty(std::string key, int &value); bool GetProperty(std::string key, bool &value); @@ -43,8 +39,6 @@ public: void GetMediaPropertyAbsolutePath(std::string collectionName, std::string mediaType, std::string &value); void GetMediaPropertyAbsolutePath(std::string collectionName, std::string mediaType, bool system, std::string &value); void GetCollectionAbsolutePath(std::string collectionName, std::string &value); - bool IsVerbose() const; - void SetVerbose(bool verbose); static std::string AbsolutePath; private: @@ -53,10 +47,7 @@ private: std::string TrimEnds(std::string str); typedef std::map PropertiesType; typedef std::pair PropertiesPair; - bool Verbose; - std::string CurrentCollection; PropertiesType Properties; - std::string Status; }; diff --git a/RetroFE/Source/Database/MetadataDatabase.cpp b/RetroFE/Source/Database/MetadataDatabase.cpp index b0c3ab9..6be6dcf 100644 --- a/RetroFE/Source/Database/MetadataDatabase.cpp +++ b/RetroFE/Source/Database/MetadataDatabase.cpp @@ -169,7 +169,7 @@ bool MetadataDatabase::ImportDirectory() { std::string importFile = Utils::CombinePath(mameListPath, std::string(dirp->d_name)); Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing mamelist: " + importFile); - Config.SetStatus("Scraping data from " + importFile); + Config.SetProperty("status", "Scraping data from " + importFile); ImportMameList(importFile, collectionName); } } @@ -305,7 +305,7 @@ bool MetadataDatabase::ImportHyperList(std::string hyperlistFile, std::string co { char *error = NULL; - Config.SetStatus("Scraping data from \"" + hyperlistFile + "\""); + Config.SetProperty("status", "Scraping data from \"" + hyperlistFile + "\""); rapidxml::xml_document<> doc; std::ifstream file(hyperlistFile.c_str()); std::vector buffer((std::istreambuf_iterator(file)), std::istreambuf_iterator()); @@ -366,7 +366,7 @@ bool MetadataDatabase::ImportHyperList(std::string hyperlistFile, std::string co sqlite3_finalize(stmt); } } - Config.SetStatus("Saving data from \"" + hyperlistFile + "\" to database"); + Config.SetProperty("status", "Saving data from \"" + hyperlistFile + "\" to database"); sqlite3_exec(handle, "COMMIT TRANSACTION;", NULL, NULL, &error); return true; @@ -397,7 +397,7 @@ bool MetadataDatabase::ImportMameList(std::string filename, std::string collecti char *error = NULL; sqlite3 *handle = DBInstance.Handle; - Config.SetStatus("Scraping data from \"" + filename + "\" (this will take a while)"); + Config.SetProperty("status", "Scraping data from \"" + filename + "\" (this will take a while)"); Logger::Write(Logger::ZONE_INFO, "Mamelist", "Importing mamelist file \"" + filename + "\" (this will take a while)"); std::ifstream file(filename.c_str()); @@ -478,7 +478,7 @@ bool MetadataDatabase::ImportMameList(std::string filename, std::string collecti } } - Config.SetStatus("Saving data from \"" + filename + "\" to database"); + Config.SetProperty("status", "Saving data from \"" + filename + "\" to database"); sqlite3_exec(handle, "COMMIT TRANSACTION;", NULL, NULL, &error); return true; diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index ed2052f..96e9e3b 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -62,7 +62,10 @@ void ReloadableMedia::Update(float dt) { if(NewItemSelected) { - if(!SystemMode || (SystemMode && CurrentCollection != Config.GetCurrentCollection())) + std::string collection; + Config.GetProperty("currentCollection", collection); + + if(!SystemMode || (SystemMode && CurrentCollection != collection)) { ReloadRequested = true; } @@ -144,7 +147,7 @@ void ReloadableMedia::ReloadTexture() Item *selectedItem = GetSelectedItem(); - CurrentCollection = Config.GetCurrentCollection(); + Config.GetProperty("currentCollection", CurrentCollection); if (selectedItem != NULL) { diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 7279706..d016238 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -535,7 +535,9 @@ void Page::Update(float dt) if(TextStatusComponent) { - TextStatusComponent->SetText(Config.GetStatus()); + std::string status; + Config.SetProperty("status", status); + TextStatusComponent->SetText(status); } for(unsigned int i = 0; i < NUM_LAYERS; ++i) diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index d030467..b09b0ba 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -278,7 +278,7 @@ void RetroFE::Run() Config.GetProperty("firstCollection", firstCollection); CurrentPage->Start(); - Config.SetCurrentCollection(firstCollection); + Config.SetProperty("currentCollection", firstCollection); CollectionInfo *info = GetCollection(firstCollection); MenuParser mp; mp.GetMenuItems(info); @@ -307,9 +307,10 @@ void RetroFE::Run() break; case RETROFE_BACK_REQUEST: + LastMenuOffsets[CurrentPage->GetCollectionName()] = CurrentPage->GetScrollOffsetIndex(); CurrentPage->PopCollection(); - Config.SetCurrentCollection(CurrentPage->GetCollectionName()); + Config.SetProperty("currentCollection", CurrentPage->GetCollectionName()); state = RETROFE_NEW; @@ -458,7 +459,7 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page) } else { - Config.SetCurrentCollection(NextPageItem->Name); + Config.SetProperty("currentCollection", NextPageItem->Name); CollectionInfo *info = GetCollection(NextPageItem->Name); MenuParser mp;