Cleaning up some accessors/mutators

This commit is contained in:
Don Honerbrink 2015-06-19 17:24:25 -05:00
parent 297f3e2787
commit 3ea62b9c64
23 changed files with 139 additions and 340 deletions

View File

@ -45,35 +45,11 @@ CollectionInfo::~CollectionInfo()
} }
} }
std::string CollectionInfo::GetName() const
{
return Name;
}
std::string CollectionInfo::GetSettingsPath() const std::string CollectionInfo::GetSettingsPath() const
{ {
return Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", GetName()); return Utils::CombinePath(Configuration::AbsolutePath, "collections", Name);
} }
std::string CollectionInfo::GetListPath() const
{
return ListPath;
}
std::string CollectionInfo::GetMetadataType() const
{
return MetadataType;
}
std::string CollectionInfo::GetMetadataPath() const
{
return MetadataPath;
}
std::string CollectionInfo::GetExtensions() const
{
return Extensions;
}
void CollectionInfo::GetExtensions(std::vector<std::string> &extensions) void CollectionInfo::GetExtensions(std::vector<std::string> &extensions)
{ {
@ -85,14 +61,11 @@ void CollectionInfo::GetExtensions(std::vector<std::string> &extensions)
extensions.push_back(token); extensions.push_back(token);
} }
} }
std::vector<Item *> *CollectionInfo::GetItems()
{
return &Items;
}
bool CollectionInfo::ItemIsLess(Item const *lhs, Item const *rhs)
bool CollectionInfo::ItemIsLess(Item *lhs, Item *rhs)
{ {
return lhs->GetLCFullTitle() < rhs->GetLCFullTitle(); return lhs->LCFullTitle() < rhs->LCFullTitle();
} }
void CollectionInfo::SortItems() void CollectionInfo::SortItems()

View File

@ -25,23 +25,17 @@ class CollectionInfo
public: public:
CollectionInfo(std::string name, std::string listPath, std::string extensions, std::string metadataType, std::string metadataPath); CollectionInfo(std::string name, std::string listPath, std::string extensions, std::string metadataType, std::string metadataPath);
virtual ~CollectionInfo(); virtual ~CollectionInfo();
std::string GetName() const;
std::string GetSettingsPath() const; std::string GetSettingsPath() const;
std::string GetListPath() const;
std::string GetMetadataType() const;
std::string GetMetadataPath() const;
std::string GetExtensions() const;
std::vector<Item *> *GetItems();
void SortItems(); void SortItems();
void GetExtensions(std::vector<std::string> &extensions); void GetExtensions(std::vector<std::string> &extensions);
private:
static bool ItemIsLess(Item const *lhs, Item const *rhs);
std::string Name; std::string Name;
std::string ListPath; std::string ListPath;
std::string Extensions; std::string Extensions;
std::string MetadataType; std::string MetadataType;
std::string MetadataPath; std::string MetadataPath;
std::vector<Item *> Items; std::vector<Item *> Items;
private:
static bool ItemIsLess(Item *lhs, Item *rhs);
}; };

View File

@ -47,7 +47,7 @@ CollectionInfoBuilder::~CollectionInfoBuilder()
bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name) bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
{ {
std::string collectionPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", name); std::string collectionPath = Utils::CombinePath(Configuration::AbsolutePath, "collections", name);
std::vector<std::string> paths; std::vector<std::string> paths;
paths.push_back(collectionPath); paths.push_back(collectionPath);
@ -215,11 +215,10 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::stri
line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() ); line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() );
i->SetFullTitle(line); i->FullTitle = line;
i->SetName(line); i->Name = line;
i->SetFullTitle(line); i->Title = line;
i->SetTitle(line); i->Launcher = launcher;
i->SetLauncher(launcher);
list[line] = i; list[line] = i;
} }
@ -232,16 +231,16 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
{ {
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
std::string path = info->GetListPath(); std::string path = info->ListPath;
std::map<std::string, Item *> includeFilter; std::map<std::string, Item *> includeFilter;
std::map<std::string, Item *> excludeFilter; std::map<std::string, Item *> excludeFilter;
std::string includeFile = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", info->GetName(), "include.txt"); std::string includeFile = Utils::CombinePath(Configuration::AbsolutePath, "collections", info->Name, "include.txt");
std::string excludeFile = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", info->GetName(), "exclude.txt"); std::string excludeFile = Utils::CombinePath(Configuration::AbsolutePath, "collections", info->Name, "exclude.txt");
std::string launcher; std::string launcher;
bool showMissing = false; bool showMissing = false;
(void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher); (void)Conf.GetProperty("collections." + info->Name + ".launcher", launcher);
(void)Conf.GetProperty("collections." + info->GetName() + ".list.includeMissingItems", showMissing); (void)Conf.GetProperty("collections." + info->Name + ".list.includeMissingItems", showMissing);
ImportBasicList(info, includeFile, launcher, includeFilter); ImportBasicList(info, includeFile, launcher, includeFilter);
ImportBasicList(info, excludeFile, launcher, excludeFilter); ImportBasicList(info, excludeFile, launcher, excludeFilter);
@ -267,7 +266,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
{ {
if(excludeFilter.find(it->first) == excludeFilter.end()) if(excludeFilter.find(it->first) == excludeFilter.end())
{ {
info->GetItems()->push_back(it->second); info->Items.push_back(it->second);
} }
} }
} }
@ -295,11 +294,11 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
if(file.compare(start, comparator.length(), *extensionsIt) == 0) if(file.compare(start, comparator.length(), *extensionsIt) == 0)
{ {
Item *i = new Item(); Item *i = new Item();
i->SetName(basename); i->Name = basename;
i->SetFullTitle(basename); i->FullTitle = basename;
i->SetTitle(basename); i->Title = basename;
i->SetLauncher(launcher); i->Launcher = launcher;
info->GetItems()->push_back(i); info->Items.push_back(i);
} }
} }
} }

View File

@ -28,142 +28,24 @@ Item::~Item()
{ {
} }
const std::string Item::GetFileName() const std::string Item::FileName()
{ {
return Utils::GetFileName(FilePath); return Utils::GetFileName(FilePath);
} }
const std::string& Item::GetFilePath() const
{
return FilePath;
}
void Item::SetFilePath(const std::string& filepath)
{
FilePath = filepath;
}
const std::string& Item::GetLauncher() const
{
return Launcher;
}
void Item::SetLauncher(const std::string& launcher)
{
Launcher = launcher;
}
const std::string& Item::GetManufacturer() const
{
return Manufacturer;
}
void Item::SetManufacturer(const std::string& manufacturer)
{
Manufacturer = manufacturer;
}
const std::string& Item::GetGenre() const
{
return Genre;
}
void Item::SetGenre(const std::string& genre)
{
Genre = genre;
}
const std::string& Item::GetName() const
{
return Name;
}
void Item::SetName(const std::string& name)
{
Name = name;
}
std::string Item::GetNumberButtons() const
{
return NumberButtons;
}
void Item::SetNumberButtons(std::string numberbuttons) std::string Item::LCTitle()
{ {
NumberButtons = numberbuttons; std::string lcstr = Title;
std::transform(lcstr.begin(), lcstr.end(), lcstr.begin(), ::tolower);
return lcstr;
} }
std::string Item::GetNumberPlayers() const std::string Item::LCFullTitle()
{ {
return NumberPlayers; std::string lcstr = FullTitle;
std::transform(lcstr.begin(), lcstr.end(), lcstr.begin(), ::tolower);
return lcstr;
} }
void Item::SetNumberPlayers(std::string numberplayers)
{
NumberPlayers = numberplayers;
}
const std::string& Item::GetTitle() const
{
return Title;
}
const std::string& Item::GetLCTitle() const
{
return LCTitle;
}
const std::string& Item::GetLCFullTitle() const
{
return LCFullTitle;
}
void Item::SetTitle(const std::string& title)
{
Title = title;
LCTitle = Title;
std::transform(LCTitle.begin(), LCTitle.end(), LCTitle.begin(), ::tolower);
}
const std::string& Item::GetYear() const
{
return Year;
}
void Item::SetYear(const std::string& year)
{
Year = year;
}
bool Item::IsLeaf() const
{
return Leaf;
}
void Item::SetIsLeaf(bool leaf)
{
Leaf = leaf;
}
const std::string& Item::GetFullTitle() const
{
return FullTitle;
}
void Item::SetFullTitle(const std::string& fulltitle)
{
FullTitle = fulltitle;
LCFullTitle = fulltitle;
std::transform(LCFullTitle.begin(), LCFullTitle.end(), LCFullTitle.begin(), ::tolower);
}
const std::string& Item::GetCloneOf() const
{
return CloneOf;
}
void Item::SetCloneOf(const std::string& cloneOf)
{
CloneOf = cloneOf;
}

View File

@ -22,42 +22,14 @@ class Item
public: public:
Item(); Item();
virtual ~Item(); virtual ~Item();
const std::string GetFileName() const; std::string FileName();
const std::string& GetFilePath() const; std::string LCTitle() ;
void SetFilePath(const std::string& filepath); std::string LCFullTitle();
const std::string& GetLauncher() const; std::string Name;
void SetLauncher(const std::string& launcher);
const std::string& GetManufacturer() const;
void SetManufacturer(const std::string& manufacturer);
const std::string& GetGenre() const;
void SetGenre(const std::string& genre);
const std::string& GetName() const;
void SetName(const std::string& name);
void SetNumberButtons(std::string numberbuttons);
std::string GetNumberButtons() const;
void SetNumberPlayers(std::string numberplayers);
std::string GetNumberPlayers() const;
const std::string& GetTitle() const;
const std::string& GetLCTitle() const;
void SetTitle(const std::string& title);
const std::string& GetYear() const;
void SetYear(const std::string& year);
bool IsLeaf() const;
void SetIsLeaf(bool leaf);
const std::string& GetFullTitle() const;
const std::string& GetLCFullTitle() const;
void SetFullTitle(const std::string& fulltitle);
const std::string& GetCloneOf() const;
void SetCloneOf(const std::string& cloneOf);
private:
std::string Launcher; std::string Launcher;
std::string FilePath; std::string FilePath;
std::string Name;
std::string Title; std::string Title;
std::string LCTitle;
std::string FullTitle; std::string FullTitle;
std::string LCFullTitle;
std::string Year; std::string Year;
std::string Manufacturer; std::string Manufacturer;
std::string Genre; std::string Genre;

View File

@ -26,9 +26,9 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
bool VectorSort(const Item *d1, const Item *d2) bool VectorSort(Item *d1, Item *d2)
{ {
return d1->GetLCTitle() < d2->GetLCTitle(); return d1->LCTitle() < d2->LCTitle();
} }
MenuParser::MenuParser() MenuParser::MenuParser()
@ -44,7 +44,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
{ {
bool retVal = false; bool retVal = false;
//todo: magic string //todo: magic string
std::string menuFilename = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", collection->GetName(), "menu.xml"); std::string menuFilename = Utils::CombinePath(Configuration::AbsolutePath, "collections", collection->Name, "menu.xml");
rapidxml::xml_document<> doc; rapidxml::xml_document<> doc;
rapidxml::xml_node<> * rootNode; rapidxml::xml_node<> * rootNode;
@ -88,11 +88,11 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
//todo, check for empty string //todo, check for empty string
std::string title = collectionAttribute->value(); std::string title = collectionAttribute->value();
Item *item = new Item(); Item *item = new Item();
item->SetTitle(title); item->Title = title;
item->SetFullTitle(title); item->FullTitle = title;
item->SetName(collectionAttribute->value()); item->Name = collectionAttribute->value();
item->SetIsLeaf(false); item->Leaf = false;
collection->GetItems()->push_back(item); collection->Items.push_back(item);
} }
else else
@ -106,7 +106,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
} }
// todo: sorting should occur within the collection itself, not externally // todo: sorting should occur within the collection itself, not externally
std::vector<Item *> *items = collection->GetItems(); std::vector<Item *> *items = &collection->Items;
std::sort( items->begin(), items->end(), VectorSort); std::sort( items->begin(), items->end(), VectorSort);
retVal = true; retVal = true;

View File

@ -46,7 +46,7 @@ void Configuration::Initialize()
if (environment != NULL) if (environment != NULL)
{ {
environmentStr = environment; environmentStr = environment;
Configuration::SetAbsolutePath(environment); AbsolutePath = environment;
} }
else else
{ {
@ -66,7 +66,7 @@ void Configuration::Initialize()
#endif #endif
Configuration::SetAbsolutePath(sPath); AbsolutePath = sPath;
} }
} }
@ -194,8 +194,8 @@ bool Configuration::GetProperty(std::string key, std::string &value)
{ {
bool retVal = GetRawProperty(key, value); bool retVal = GetRawProperty(key, value);
std::string baseMediaPath = GetAbsolutePath(); std::string baseMediaPath = AbsolutePath;
std::string baseItemPath = GetAbsolutePath(); std::string baseItemPath = AbsolutePath;
std::string collectionName; std::string collectionName;
GetRawProperty("baseMediaPath", baseMediaPath); GetRawProperty("baseMediaPath", baseMediaPath);
@ -328,7 +328,7 @@ bool Configuration::GetPropertyAbsolutePath(std::string key, std::string &value)
if(retVal) if(retVal)
{ {
value = ConvertToAbsolutePath(GetAbsolutePath(), value); value = ConvertToAbsolutePath(AbsolutePath, value);
} }
return retVal; return retVal;
@ -355,7 +355,7 @@ void Configuration::GetMediaPropertyAbsolutePath(std::string collectionName, std
if(!GetPropertyAbsolutePath("baseMediaPath", baseMediaPath)) if(!GetPropertyAbsolutePath("baseMediaPath", baseMediaPath))
{ {
// base media path was not specified, assume media files are in the collection // base media path was not specified, assume media files are in the collection
baseMediaPath = Utils::CombinePath(GetAbsolutePath(), "collections"); baseMediaPath = Utils::CombinePath(AbsolutePath, "collections");
} }
if(mediaType == "manufacturer") if(mediaType == "manufacturer")
@ -404,20 +404,10 @@ void Configuration::GetCollectionAbsolutePath(std::string collectionName, std::s
return; return;
} }
value = Utils::CombinePath(GetAbsolutePath(), "collections", collectionName, "roms"); value = Utils::CombinePath(AbsolutePath, "collections", collectionName, "roms");
} }
void Configuration::SetAbsolutePath(std::string absolutePath)
{
AbsolutePath = absolutePath;
}
std::string Configuration::GetAbsolutePath()
{
return AbsolutePath;
}
bool Configuration::IsVerbose() const bool Configuration::IsVerbose() const
{ {
return Verbose; return Verbose;

View File

@ -25,8 +25,6 @@ public:
Configuration(); Configuration();
virtual ~Configuration(); virtual ~Configuration();
static void Initialize(); static void Initialize();
static void SetAbsolutePath(std::string absolutePath);
static std::string GetAbsolutePath();
static std::string ConvertToAbsolutePath(std::string prefix, std::string path); static std::string ConvertToAbsolutePath(std::string prefix, std::string path);
void SetStatus(std::string status); void SetStatus(std::string status);
std::string GetStatus(); std::string GetStatus();
@ -47,6 +45,7 @@ public:
void GetCollectionAbsolutePath(std::string collectionName, std::string &value); void GetCollectionAbsolutePath(std::string collectionName, std::string &value);
bool IsVerbose() const; bool IsVerbose() const;
void SetVerbose(bool verbose); void SetVerbose(bool verbose);
static std::string AbsolutePath;
private: private:
bool GetRawProperty(std::string key, std::string &value); bool GetRawProperty(std::string key, std::string &value);
@ -56,7 +55,6 @@ private:
typedef std::pair<std::string, std::string> PropertiesPair; typedef std::pair<std::string, std::string> PropertiesPair;
bool Verbose; bool Verbose;
static std::string AbsolutePath;
std::string CurrentCollection; std::string CurrentCollection;
PropertiesType Properties; PropertiesType Properties;
std::string Status; std::string Status;

View File

@ -20,8 +20,8 @@
#include <fstream> #include <fstream>
DB::DB(std::string dbFile) DB::DB(std::string dbFile)
: Path(dbFile) : Handle(NULL)
, Handle(NULL) , Path(dbFile)
{ {
} }

View File

@ -24,13 +24,9 @@ public:
bool Initialize(); bool Initialize();
void DeInitialize(); void DeInitialize();
virtual ~DB(); virtual ~DB();
sqlite3 *GetHandle() sqlite3 *Handle;
{
return Handle;
}
private: private:
std::string Path; std::string Path;
sqlite3 *Handle;
}; };

View File

@ -48,7 +48,7 @@ bool MetadataDatabase::ResetDatabase()
{ {
int rc; int rc;
char *error = NULL; char *error = NULL;
sqlite3 *handle = DBInstance.GetHandle(); sqlite3 *handle = DBInstance.Handle;
Logger::Write(Logger::ZONE_INFO, "Metadata", "Erasing"); Logger::Write(Logger::ZONE_INFO, "Metadata", "Erasing");
@ -72,7 +72,7 @@ bool MetadataDatabase::Initialize()
{ {
int rc; int rc;
char *error = NULL; char *error = NULL;
sqlite3 *handle = DBInstance.GetHandle(); sqlite3 *handle = DBInstance.Handle;
std::string sql; std::string sql;
sql.append("CREATE TABLE IF NOT EXISTS Meta("); sql.append("CREATE TABLE IF NOT EXISTS Meta(");
@ -110,8 +110,8 @@ bool MetadataDatabase::ImportDirectory()
{ {
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
std::string hyperListPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "meta", "hyperlist"); std::string hyperListPath = Utils::CombinePath(Configuration::AbsolutePath, "meta", "hyperlist");
std::string mameListPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "meta", "mamelist"); std::string mameListPath = Utils::CombinePath(Configuration::AbsolutePath, "meta", "mamelist");
dp = opendir(hyperListPath.c_str()); dp = opendir(hyperListPath.c_str());
@ -183,7 +183,7 @@ bool MetadataDatabase::ImportDirectory()
void MetadataDatabase::InjectMetadata(CollectionInfo *collection) void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
{ {
sqlite3 *handle = DBInstance.GetHandle(); sqlite3 *handle = DBInstance.Handle;
int rc; int rc;
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
@ -195,12 +195,12 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
// items into a hash to make it easily searchable // items into a hash to make it easily searchable
std::vector<Item *> *items = collection->GetItems(); std::vector<Item *> *items = &collection->Items;
std::map<std::string, Item *> itemMap; std::map<std::string, Item *> itemMap;
for(std::vector<Item *>::iterator it = items->begin(); it != items->end(); it++) for(std::vector<Item *>::iterator it = items->begin(); it != items->end(); it++)
{ {
itemMap[(*it)->GetName()] = *it; itemMap[(*it)->Name] = *it;
} }
//todo: program crashes if this query fails //todo: program crashes if this query fails
@ -209,7 +209,7 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
"FROM Meta WHERE collectionName=? ORDER BY title ASC;", "FROM Meta WHERE collectionName=? ORDER BY title ASC;",
-1, &stmt, 0); -1, &stmt, 0);
sqlite3_bind_text(stmt, 1, collection->GetMetadataType().c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 1, collection->MetadataType.c_str(), -1, SQLITE_TRANSIENT);
rc = sqlite3_step(stmt); rc = sqlite3_step(stmt);
@ -265,14 +265,14 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
if(it != itemMap.end()) if(it != itemMap.end())
{ {
Item *item = it->second; Item *item = it->second;
item->SetTitle(title); item->Title = title;
item->SetFullTitle(fullTitle); item->FullTitle = fullTitle;
item->SetYear(year); item->Year = year;
item->SetManufacturer(manufacturer); item->Manufacturer = manufacturer;
item->SetGenre(genre); item->Genre = genre;
item->SetNumberPlayers(numberPlayers); item->NumberPlayers = numberPlayers;
item->SetNumberButtons(numberButtons); item->NumberButtons = numberButtons;
item->SetCloneOf(cloneOf); item->CloneOf = cloneOf;
} }
rc = sqlite3_step(stmt); rc = sqlite3_step(stmt);
} }
@ -280,7 +280,7 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
bool MetadataDatabase::NeedsRefresh() bool MetadataDatabase::NeedsRefresh()
{ {
sqlite3 *handle = DBInstance.GetHandle(); sqlite3 *handle = DBInstance.Handle;
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
sqlite3_prepare_v2(handle, sqlite3_prepare_v2(handle,
@ -323,7 +323,7 @@ bool MetadataDatabase::ImportHyperList(std::string hyperlistFile, std::string co
Logger::Write(Logger::ZONE_ERROR, "Metadata", "Does not appear to be a HyperList file (missing <menu> tag)"); Logger::Write(Logger::ZONE_ERROR, "Metadata", "Does not appear to be a HyperList file (missing <menu> tag)");
return false; return false;
} }
sqlite3 *handle = DBInstance.GetHandle(); sqlite3 *handle = DBInstance.Handle;
sqlite3_exec(handle, "BEGIN IMMEDIATE TRANSACTION;", NULL, NULL, &error); sqlite3_exec(handle, "BEGIN IMMEDIATE TRANSACTION;", NULL, NULL, &error);
for(rapidxml::xml_node<> *game = root->first_node("game"); game; game = game->next_sibling("game")) for(rapidxml::xml_node<> *game = root->first_node("game"); game; game = game->next_sibling("game"))
{ {
@ -395,7 +395,7 @@ bool MetadataDatabase::ImportMameList(std::string filename, std::string collecti
rapidxml::xml_document<> doc; rapidxml::xml_document<> doc;
rapidxml::xml_node<> * rootNode; rapidxml::xml_node<> * rootNode;
char *error = NULL; char *error = NULL;
sqlite3 *handle = DBInstance.GetHandle(); sqlite3 *handle = DBInstance.Handle;
Config.SetStatus("Scraping data from \"" + filename + "\" (this will take a while)"); Config.SetStatus("Scraping data from \"" + filename + "\" (this will take a while)");

View File

@ -19,17 +19,13 @@
#include <cstdlib> #include <cstdlib>
AttractMode::AttractMode() AttractMode::AttractMode()
: IsActive(false) : IdleTime(0)
, IsActive(false)
, ElapsedTime(0) , ElapsedTime(0)
, ActiveTime(0) , ActiveTime(0)
, IdleTime(0)
{ {
} }
void AttractMode::SetIdleTime(float time)
{
IdleTime = time;
}
void AttractMode::Reset() void AttractMode::Reset()
{ {
ElapsedTime = 0; ElapsedTime = 0;
@ -60,4 +56,4 @@ void AttractMode::Update(float dt, Page &page)
page.SetScrolling(Page::ScrollDirectionIdle); page.SetScrolling(Page::ScrollDirectionIdle);
} }
} }
} }

View File

@ -21,14 +21,13 @@ class AttractMode
{ {
public: public:
AttractMode(); AttractMode();
void SetIdleTime(float time);
void Reset(); void Reset();
void Update(float dt, Page &page); void Update(float dt, Page &page);
float IdleTime;
private: private:
bool IsActive; bool IsActive;
float ElapsedTime; float ElapsedTime;
float ActiveTime; float ActiveTime;
float IdleTime;
}; };

View File

@ -38,7 +38,7 @@ Launcher::Launcher(RetroFE &p, Configuration &c)
bool Launcher::Run(std::string collection, Item *collectionItem) bool Launcher::Run(std::string collection, Item *collectionItem)
{ {
std::string launcherName = collectionItem->GetLauncher(); std::string launcherName = collectionItem->Launcher;
std::string executablePath; std::string executablePath;
std::string selectedItemsDirectory; std::string selectedItemsDirectory;
std::string selectedItemsPath; std::string selectedItemsPath;
@ -67,29 +67,29 @@ bool Launcher::Run(std::string collection, Item *collectionItem)
Logger::Write(Logger::ZONE_ERROR, "Launcher", "No launcher arguments specified for launcher " + launcherName); Logger::Write(Logger::ZONE_ERROR, "Launcher", "No launcher arguments specified for launcher " + launcherName);
return false; return false;
} }
if(!FindFile(selectedItemsPath, matchedExtension, selectedItemsDirectory, collectionItem->GetName(), extensions)) if(!FindFile(selectedItemsPath, matchedExtension, selectedItemsDirectory, collectionItem->Name, extensions))
{ {
// FindFile() prints out diagnostic messages for us, no need to print anything here // FindFile() prints out diagnostic messages for us, no need to print anything here
return false; return false;
} }
args = ReplaceVariables(args, args = ReplaceVariables(args,
selectedItemsPath, selectedItemsPath,
collectionItem->GetName(), collectionItem->Name,
collectionItem->GetFileName(), collectionItem->FileName(),
selectedItemsDirectory, selectedItemsDirectory,
collection); collection);
executablePath = ReplaceVariables(executablePath, executablePath = ReplaceVariables(executablePath,
selectedItemsPath, selectedItemsPath,
collectionItem->GetName(), collectionItem->Name,
collectionItem->GetFileName(), collectionItem->FileName(),
selectedItemsDirectory, selectedItemsDirectory,
collection); collection);
currentDirectory = ReplaceVariables(currentDirectory, currentDirectory = ReplaceVariables(currentDirectory,
selectedItemsPath, selectedItemsPath,
collectionItem->GetName(), collectionItem->Name,
collectionItem->GetFileName(), collectionItem->FileName(),
selectedItemsDirectory, selectedItemsDirectory,
collection); collection);
@ -114,11 +114,11 @@ std::string Launcher::ReplaceVariables(std::string str,
str = Utils::Replace(str, "%ITEM_FILENAME%", itemFilename); str = Utils::Replace(str, "%ITEM_FILENAME%", itemFilename);
str = Utils::Replace(str, "%ITEM_DIRECTORY%", itemDirectory); str = Utils::Replace(str, "%ITEM_DIRECTORY%", itemDirectory);
str = Utils::Replace(str, "%ITEM_COLLECTION_NAME%", itemCollectionName); str = Utils::Replace(str, "%ITEM_COLLECTION_NAME%", itemCollectionName);
str = Utils::Replace(str, "%RETROFE_PATH%", Configuration::GetAbsolutePath()); str = Utils::Replace(str, "%RETROFE_PATH%", Configuration::AbsolutePath);
#ifdef WIN32 #ifdef WIN32
str = Utils::Replace(str, "%RETROFE_EXEC_PATH%", Utils::CombinePath(Configuration::GetAbsolutePath(), "RetroFE.exe")); str = Utils::Replace(str, "%RETROFE_EXEC_PATH%", Utils::CombinePath(Configuration::AbsolutePath, "RetroFE.exe"));
#else #else
str = Utils::Replace(str, "%RETROFE_EXEC_PATH%", Utils::CombinePath(Configuration::GetAbsolutePath(), "RetroFE")); str = Utils::Replace(str, "%RETROFE_EXEC_PATH%", Utils::CombinePath(Configuration::AbsolutePath, "RetroFE"));
#endif #endif
return str; return str;

View File

@ -150,12 +150,12 @@ void ReloadableMedia::ReloadTexture()
{ {
std::vector<std::string> names; std::vector<std::string> names;
names.push_back(selectedItem->GetName()); names.push_back(selectedItem->Name);
names.push_back(selectedItem->GetFullTitle()); names.push_back(selectedItem->FullTitle);
if(selectedItem->GetCloneOf().length() > 0) if(selectedItem->CloneOf.length() > 0)
{ {
names.push_back(selectedItem->GetCloneOf()); names.push_back(selectedItem->CloneOf);
} }
for(unsigned int n = 0; n < names.size() && !found; ++n) for(unsigned int n = 0; n < names.size() && !found; ++n)
@ -197,27 +197,27 @@ void ReloadableMedia::ReloadTexture()
if(typeLC == "numberButtons") if(typeLC == "numberButtons")
{ {
imageBasename = selectedItem->GetNumberButtons(); imageBasename = selectedItem->NumberButtons;
} }
else if(typeLC == "numberPlayers") else if(typeLC == "numberPlayers")
{ {
imageBasename = selectedItem->GetNumberPlayers(); imageBasename = selectedItem->NumberPlayers;
} }
else if(typeLC == "year") else if(typeLC == "year")
{ {
imageBasename = selectedItem->GetYear(); imageBasename = selectedItem->Year;
} }
else if(typeLC == "title") else if(typeLC == "title")
{ {
imageBasename = selectedItem->GetTitle(); imageBasename = selectedItem->Title;
} }
else if(typeLC == "manufacturer") else if(typeLC == "manufacturer")
{ {
imageBasename = selectedItem->GetManufacturer(); imageBasename = selectedItem->Manufacturer;
} }
else if(typeLC == "genre") else if(typeLC == "genre")
{ {
imageBasename = selectedItem->GetGenre(); imageBasename = selectedItem->Genre;
} }
Utils::ReplaceSlashesWithUnderscores(imageBasename); Utils::ReplaceSlashesWithUnderscores(imageBasename);

View File

@ -137,22 +137,22 @@ void ReloadableText::ReloadTexture()
switch(Type) switch(Type)
{ {
case TextTypeNumberButtons: case TextTypeNumberButtons:
ss << selectedItem->GetNumberButtons(); ss << selectedItem->NumberButtons;
break; break;
case TextTypeNumberPlayers: case TextTypeNumberPlayers:
ss << selectedItem->GetNumberPlayers(); ss << selectedItem->NumberPlayers;
break; break;
case TextTypeYear: case TextTypeYear:
ss << selectedItem->GetYear(); ss << selectedItem->Year;
break; break;
case TextTypeTitle: case TextTypeTitle:
ss << selectedItem->GetTitle(); ss << selectedItem->Title;
break; break;
case TextTypeManufacturer: case TextTypeManufacturer:
ss << selectedItem->GetManufacturer(); ss << selectedItem->Manufacturer;
break; break;
case TextTypeGenre: case TextTypeGenre:
ss << selectedItem->GetGenre(); ss << selectedItem->Genre;
break; break;
default: default:
break; break;

View File

@ -409,7 +409,7 @@ void ScrollingList::LetterUp()
// Select the previous item in the list in case we are at the top of all the items // Select the previous item in the list in case we are at the top of all the items
// for the currently selected letter. // for the currently selected letter.
CircularDecrement(FirstSpriteIndex, SpriteList); CircularDecrement(FirstSpriteIndex, SpriteList);
std::string startname = GetSelectedCollectionItemSprite()->GetCollectionItem()->GetLCFullTitle(); std::string startname = GetSelectedCollectionItemSprite()->GetCollectionItem()->LCFullTitle();
++i; ++i;
bool done = false; bool done = false;
@ -418,7 +418,7 @@ void ScrollingList::LetterUp()
while(!done && i < SpriteList->size()) while(!done && i < SpriteList->size())
{ {
CircularDecrement(FirstSpriteIndex, SpriteList); CircularDecrement(FirstSpriteIndex, SpriteList);
std::string endname = GetSelectedCollectionItemSprite()->GetCollectionItem()->GetLCFullTitle(); std::string endname = GetSelectedCollectionItemSprite()->GetCollectionItem()->LCFullTitle();
++i; ++i;
// check if we are changing characters from a-z, or changing from alpha character to non-alpha character // check if we are changing characters from a-z, or changing from alpha character to non-alpha character
@ -450,7 +450,7 @@ void ScrollingList::LetterDown()
if(SpriteList && ScrollPoints) if(SpriteList && ScrollPoints)
{ {
std::string startname = GetSelectedCollectionItemSprite()->GetCollectionItem()->GetLCFullTitle(); std::string startname = GetSelectedCollectionItemSprite()->GetCollectionItem()->LCFullTitle();
std::string endname = startname; std::string endname = startname;
unsigned int i = 0; unsigned int i = 0;
@ -458,7 +458,7 @@ void ScrollingList::LetterDown()
while(!done && i < SpriteList->size()) while(!done && i < SpriteList->size())
{ {
CircularIncrement(FirstSpriteIndex, SpriteList); CircularIncrement(FirstSpriteIndex, SpriteList);
endname = GetSelectedCollectionItemSprite()->GetCollectionItem()->GetLCFullTitle(); endname = GetSelectedCollectionItemSprite()->GetCollectionItem()->LCFullTitle();
++i; ++i;
// check if we are changing characters from a-z, or changing from alpha character to non-alpha character // check if we are changing characters from a-z, or changing from alpha character to non-alpha character
@ -792,21 +792,21 @@ bool ScrollingList::AllocateTexture(ComponentItemBinding *s)
ImageBuilder imageBuild; ImageBuilder imageBuild;
Config.GetMediaPropertyAbsolutePath(GetCollectionName(), ImageType, false, imagePath); Config.GetMediaPropertyAbsolutePath(GetCollectionName(), ImageType, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->GetName(), ScaleX, ScaleY); t = imageBuild.CreateImage(imagePath, item->Name, ScaleX, ScaleY);
if(!t) if(!t)
{ {
Config.GetMediaPropertyAbsolutePath(item->GetName(), ImageType, true, imagePath); Config.GetMediaPropertyAbsolutePath(item->Name, ImageType, true, imagePath);
t = imageBuild.CreateImage(imagePath, ImageType, ScaleX, ScaleY); t = imageBuild.CreateImage(imagePath, ImageType, ScaleX, ScaleY);
} }
if(!t && item->GetTitle() != item->GetFullTitle()) if(!t && item->Title != item->FullTitle)
{ {
t = imageBuild.CreateImage(imagePath, item->GetFullTitle(), ScaleX, ScaleY); t = imageBuild.CreateImage(imagePath, item->FullTitle, ScaleX, ScaleY);
} }
if (!t) if (!t)
{ {
t = new Text(item->GetTitle(), FontInst, ScaleX, ScaleY); t = new Text(item->Title, FontInst, ScaleX, ScaleY);
} }
if(t) if(t)

View File

@ -411,7 +411,7 @@ void Page::LetterScroll(ScrollDirection direction)
bool Page::PushCollection(CollectionInfo *collection) bool Page::PushCollection(CollectionInfo *collection)
{ {
Collections.push_back(collection); Collections.push_back(collection);
std::vector<ComponentItemBinding *> *sprites = ComponentItemBindingBuilder::BuildCollectionItems(collection->GetItems()); std::vector<ComponentItemBinding *> *sprites = ComponentItemBindingBuilder::BuildCollectionItems(&collection->Items);
int menuExitIndex = -1; int menuExitIndex = -1;
int menuEnterIndex = -1; int menuEnterIndex = -1;
@ -434,7 +434,7 @@ bool Page::PushCollection(CollectionInfo *collection)
} }
ActiveMenu = Menus[MenuDepth]; ActiveMenu = Menus[MenuDepth];
ActiveMenu->SetCollectionName(collection->GetName()); ActiveMenu->SetCollectionName(collection->Name);
ActiveMenu->DestroyItems(); ActiveMenu->DestroyItems();
ActiveMenu->SetItems(sprites); ActiveMenu->SetItems(sprites);
ActiveMenu->TriggerMenuEnterEvent(); ActiveMenu->TriggerMenuEnterEvent();
@ -449,7 +449,7 @@ bool Page::PushCollection(CollectionInfo *collection)
{ {
for(std::vector<Component *>::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it) for(std::vector<Component *>::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it)
{ {
(*it)->SetCollectionName(collection->GetName()); (*it)->SetCollectionName(collection->Name);
if(menuEnterIndex >= 0) if(menuEnterIndex >= 0)
{ {
(*it)->TriggerMenuEnterEvent(menuEnterIndex); (*it)->TriggerMenuEnterEvent(menuEnterIndex);
@ -500,7 +500,7 @@ bool Page::PopCollection()
{ {
for(std::vector<Component *>::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it) for(std::vector<Component *>::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it)
{ {
(*it)->SetCollectionName(collection->GetName()); (*it)->SetCollectionName(collection->Name);
if(menuEnterIndex >= 0) if(menuEnterIndex >= 0)
{ {
@ -571,7 +571,7 @@ std::string Page::GetCollectionName()
if(info) if(info)
{ {
return info->GetName(); return info->Name;
} }
return ""; return "";

View File

@ -77,7 +77,7 @@ Page *PageBuilder::BuildPage()
std::string layoutFile; std::string layoutFile;
std::string layoutName = LayoutKey; std::string layoutName = LayoutKey;
LayoutPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "layouts", layoutName); LayoutPath = Utils::CombinePath(Configuration::AbsolutePath, "layouts", layoutName);
layoutFile = Utils::CombinePath(LayoutPath, LayoutPage + ".xml"); layoutFile = Utils::CombinePath(LayoutPath, LayoutPage + ".xml");
Logger::Write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile); Logger::Write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile);
@ -125,7 +125,7 @@ Page *PageBuilder::BuildPage()
if(fontXml) if(fontXml)
{ {
FontName = Config.ConvertToAbsolutePath( FontName = Config.ConvertToAbsolutePath(
Utils::CombinePath(Config.GetAbsolutePath(), "layouts", LayoutKey, ""), Utils::CombinePath(Config.AbsolutePath, "layouts", LayoutKey, ""),
fontXml->value()); fontXml->value());
} }
@ -503,7 +503,7 @@ Font *PageBuilder::AddFont(xml_node<> *component, xml_node<> *defaults)
if(fontXml) if(fontXml)
{ {
fontName = Config.ConvertToAbsolutePath( fontName = Config.ConvertToAbsolutePath(
Utils::CombinePath(Config.GetAbsolutePath(), "layouts", LayoutKey,""), Utils::CombinePath(Config.AbsolutePath, "layouts", LayoutKey,""),
fontXml->value()); fontXml->value());
Logger::Write(Logger::ZONE_DEBUG, "Layout", "loading font " + fontName ); Logger::Write(Logger::ZONE_DEBUG, "Layout", "loading font " + fontName );

View File

@ -72,9 +72,9 @@ int main(int argc, char **argv)
bool ImportConfiguration(Configuration *c) bool ImportConfiguration(Configuration *c)
{ {
std::string configPath = Configuration::GetAbsolutePath(); std::string configPath = Configuration::AbsolutePath;
std::string launchersPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "launchers"); std::string launchersPath = Utils::CombinePath(Configuration::AbsolutePath, "launchers");
std::string collectionsPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections"); std::string collectionsPath = Utils::CombinePath(Configuration::AbsolutePath, "collections");
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
@ -162,7 +162,7 @@ bool ImportConfiguration(Configuration *c)
bool StartLogging() bool StartLogging()
{ {
std::string logFile = Utils::CombinePath(Configuration::GetAbsolutePath(), "log.txt"); std::string logFile = Utils::CombinePath(Configuration::AbsolutePath, "log.txt");
if(!Logger::Initialize(logFile)) if(!Logger::Initialize(logFile))
{ {
@ -178,7 +178,7 @@ bool StartLogging()
Logger::Write(Logger::ZONE_INFO, "RetroFE", "OS: Linux"); Logger::Write(Logger::ZONE_INFO, "RetroFE", "OS: Linux");
#endif #endif
Logger::Write(Logger::ZONE_INFO, "RetroFE", "Absolute path: " + Configuration::GetAbsolutePath()); Logger::Write(Logger::ZONE_INFO, "RetroFE", "Absolute path: " + Configuration::AbsolutePath);
return true; return true;
} }

View File

@ -85,7 +85,7 @@ int RetroFE::Initialize(void *context)
return -1; return -1;
} }
instance->Db = new DB(Utils::CombinePath(Configuration::GetAbsolutePath(), "meta.db")); instance->Db = new DB(Utils::CombinePath(Configuration::AbsolutePath, "meta.db"));
if(!instance->Db->Initialize()) if(!instance->Db->Initialize())
{ {
@ -220,7 +220,7 @@ void RetroFE::Run()
Config.GetProperty("attractModeTime", attractModeTime); Config.GetProperty("attractModeTime", attractModeTime);
Config.GetProperty("firstCollection", firstCollection); Config.GetProperty("firstCollection", firstCollection);
Attract.SetIdleTime(static_cast<float>(attractModeTime)); Attract.IdleTime = static_cast<float>(attractModeTime);
int initializeStatus = 0; int initializeStatus = 0;
@ -452,22 +452,22 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
if(NextPageItem) if(NextPageItem)
{ {
if(NextPageItem->IsLeaf()) if(NextPageItem->Leaf)
{ {
state = RETROFE_LAUNCH_REQUEST; state = RETROFE_LAUNCH_REQUEST;
} }
else else
{ {
Config.SetCurrentCollection(NextPageItem->GetName()); Config.SetCurrentCollection(NextPageItem->Name);
CollectionInfo *info = GetCollection(NextPageItem->GetName()); CollectionInfo *info = GetCollection(NextPageItem->Name);
MenuParser mp; MenuParser mp;
mp.GetMenuItems(info); mp.GetMenuItems(info);
page->PushCollection(info); page->PushCollection(info);
if(rememberMenu && LastMenuOffsets.find(NextPageItem->GetName()) != LastMenuOffsets.end()) if(rememberMenu && LastMenuOffsets.find(NextPageItem->Name) != LastMenuOffsets.end())
{ {
page->SetScrollOffsetIndex(LastMenuOffsets[NextPageItem->GetName()]); page->SetScrollOffsetIndex(LastMenuOffsets[NextPageItem->Name]);
} }
state = RETROFE_NEXT_PAGE_REQUEST; state = RETROFE_NEXT_PAGE_REQUEST;

View File

@ -134,7 +134,7 @@ bool Utils::FindMatchingFile(std::string prefix, std::vector<std::string> &exten
for(unsigned int i = 0; i < extensions.size(); ++i) for(unsigned int i = 0; i < extensions.size(); ++i)
{ {
std::string temp = prefix + "." + extensions[i]; std::string temp = prefix + "." + extensions[i];
temp = Configuration::ConvertToAbsolutePath(Configuration::GetAbsolutePath(), temp); temp = Configuration::ConvertToAbsolutePath(Configuration::AbsolutePath, temp);
std::ifstream f(temp.c_str()); std::ifstream f(temp.c_str());

View File

@ -135,7 +135,7 @@ bool GStreamerVideo::Initialize()
return true; return true;
} }
std::string path = Utils::CombinePath(Configuration::GetAbsolutePath(), "Core"); std::string path = Utils::CombinePath(Configuration::AbsolutePath, "Core");
gst_init(NULL, NULL); gst_init(NULL, NULL);
#ifdef WIN32 #ifdef WIN32
@ -208,7 +208,7 @@ bool GStreamerVideo::Play(std::string file)
} }
else else
{ {
Configuration::ConvertToAbsolutePath(Configuration::GetAbsolutePath(), file); Configuration::ConvertToAbsolutePath(Configuration::AbsolutePath, file);
file = uriFile; file = uriFile;
if(!Playbin) if(!Playbin)