Added genre type. Fixed invalid error where folders starting with _ were treated as actual collections.

This commit is contained in:
emb
2015-02-27 23:16:47 -06:00
parent c7dccd7109
commit a9dbc4e004
9 changed files with 68 additions and 28 deletions

View File

@@ -63,6 +63,16 @@ void Item::SetManufacturer(const std::string& manufacturer)
Manufacturer = 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 const std::string& Item::GetName() const
{ {
return Name; return Name;

View File

@@ -29,6 +29,8 @@ public:
void SetLauncher(const std::string& launcher); void SetLauncher(const std::string& launcher);
const std::string& GetManufacturer() const; const std::string& GetManufacturer() const;
void SetManufacturer(const std::string& manufacturer); void SetManufacturer(const std::string& manufacturer);
const std::string& GetGenre() const;
void SetGenre(const std::string& genre);
const std::string& GetName() const; const std::string& GetName() const;
void SetName(const std::string& name); void SetName(const std::string& name);
void SetNumberButtons(std::string numberbuttons); void SetNumberButtons(std::string numberbuttons);
@@ -56,6 +58,7 @@ private:
std::string FullTitle; std::string FullTitle;
std::string Year; std::string Year;
std::string Manufacturer; std::string Manufacturer;
std::string Genre;
std::string CloneOf; std::string CloneOf;
std::string NumberPlayers; std::string NumberPlayers;
std::string NumberButtons; std::string NumberButtons;

View File

@@ -81,6 +81,7 @@ bool MetadataDatabase::Initialize()
sql.append("title TEXT NOT NULL DEFAULT '',"); sql.append("title TEXT NOT NULL DEFAULT '',");
sql.append("year TEXT NOT NULL DEFAULT '',"); sql.append("year TEXT NOT NULL DEFAULT '',");
sql.append("manufacturer TEXT NOT NULL DEFAULT '',"); sql.append("manufacturer TEXT NOT NULL DEFAULT '',");
sql.append("genre TEXT NOT NULL DEFAULT '',");
sql.append("cloneOf TEXT NOT NULL DEFAULT '',"); sql.append("cloneOf TEXT NOT NULL DEFAULT '',");
sql.append("players TEXT NOT NULL DEFAULT '',"); sql.append("players TEXT NOT NULL DEFAULT '',");
sql.append("buttons TEXT NOT NULL DEFAULT '');"); sql.append("buttons TEXT NOT NULL DEFAULT '');");
@@ -110,7 +111,7 @@ bool MetadataDatabase::ImportDirectory()
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
std::string hyperListPath = Configuration::GetAbsolutePath() + "/meta/hyperlist"; std::string hyperListPath = Configuration::GetAbsolutePath() + "/meta/hyperlist";
std::string mameListPath = Configuration::GetAbsolutePath() + "/meta/Mamelist"; std::string mameListPath = Configuration::GetAbsolutePath() + "/meta/mamelist";
dp = opendir(hyperListPath.c_str()); dp = opendir(hyperListPath.c_str());
@@ -204,7 +205,7 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
//todo: program crashes if this query fails //todo: program crashes if this query fails
sqlite3_prepare_v2(handle, sqlite3_prepare_v2(handle,
"SELECT DISTINCT Meta.name, Meta.title, Meta.year, Meta.manufacturer, Meta.players, Meta.buttons, Meta.cloneOf " "SELECT DISTINCT Meta.name, Meta.title, Meta.year, Meta.manufacturer, Meta.genre, Meta.players, Meta.buttons, Meta.cloneOf "
"FROM Meta WHERE collectionName=? ORDER BY title ASC;", "FROM Meta WHERE collectionName=? ORDER BY title ASC;",
-1, &stmt, 0); -1, &stmt, 0);
@@ -218,9 +219,10 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
std::string fullTitle = (char *)sqlite3_column_text(stmt, 1); std::string fullTitle = (char *)sqlite3_column_text(stmt, 1);
std::string year = (char *)sqlite3_column_text(stmt, 2); std::string year = (char *)sqlite3_column_text(stmt, 2);
std::string manufacturer = (char *)sqlite3_column_text(stmt, 3); std::string manufacturer = (char *)sqlite3_column_text(stmt, 3);
std::string numberPlayers = (char *)sqlite3_column_text(stmt, 4); std::string genre = (char *)sqlite3_column_text(stmt, 4);
std::string numberButtons = (char *)sqlite3_column_text(stmt, 5); std::string numberPlayers = (char *)sqlite3_column_text(stmt, 5);
std::string cloneOf = (char *)sqlite3_column_text(stmt, 6); std::string numberButtons = (char *)sqlite3_column_text(stmt, 6);
std::string cloneOf = (char *)sqlite3_column_text(stmt, 7);
std::string launcher; std::string launcher;
std::string title = fullTitle; std::string title = fullTitle;
@@ -267,6 +269,7 @@ void MetadataDatabase::InjectMetadata(CollectionInfo *collection)
item->SetFullTitle(fullTitle); item->SetFullTitle(fullTitle);
item->SetYear(year); item->SetYear(year);
item->SetManufacturer(manufacturer); item->SetManufacturer(manufacturer);
item->SetGenre(genre);
item->SetNumberPlayers(numberPlayers); item->SetNumberPlayers(numberPlayers);
item->SetNumberButtons(numberButtons); item->SetNumberButtons(numberButtons);
item->SetCloneOf(cloneOf); item->SetCloneOf(cloneOf);
@@ -348,15 +351,16 @@ bool MetadataDatabase::ImportHyperList(std::string hyperlistFile, std::string co
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
sqlite3_prepare_v2(handle, sqlite3_prepare_v2(handle,
"INSERT OR REPLACE INTO Meta (name, title, year, manufacturer, cloneOf, collectionName) VALUES (?,?,?,?,?,?)", "INSERT OR REPLACE INTO Meta (name, title, year, manufacturer, genre, cloneOf, collectionName) VALUES (?,?,?,?,?,?,?)",
-1, &stmt, 0); -1, &stmt, 0);
sqlite3_bind_text(stmt, 1, name.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 1, name.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 2, description.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 2, description.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 3, year.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 3, year.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 4, manufacturer.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 4, manufacturer.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 5, cloneOf.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 5, genre.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 6, collectionName.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 6, cloneOf.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 7, collectionName.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_step(stmt); sqlite3_step(stmt);
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
@@ -424,11 +428,13 @@ bool MetadataDatabase::ImportMameList(std::string filename, std::string collecti
rapidxml::xml_node<> *descriptionNode = game->first_node("description"); rapidxml::xml_node<> *descriptionNode = game->first_node("description");
rapidxml::xml_node<> *yearNode = game->first_node("year"); rapidxml::xml_node<> *yearNode = game->first_node("year");
rapidxml::xml_node<> *manufacturerNode = game->first_node("manufacturer"); rapidxml::xml_node<> *manufacturerNode = game->first_node("manufacturer");
rapidxml::xml_node<> *genreNode = game->first_node("genre");
rapidxml::xml_node<> *inputNode = game->first_node("input"); rapidxml::xml_node<> *inputNode = game->first_node("input");
std::string description = (descriptionNode == NULL) ? nameNode->value() : descriptionNode->value(); std::string description = (descriptionNode == NULL) ? nameNode->value() : descriptionNode->value();
std::string year = (yearNode == NULL) ? "" : yearNode->value(); std::string year = (yearNode == NULL) ? "" : yearNode->value();
std::string manufacturer = (manufacturerNode == NULL) ? "" : manufacturerNode->value(); std::string manufacturer = (manufacturerNode == NULL) ? "" : manufacturerNode->value();
std::string genre = (genreNode == NULL) ? "" : genreNode->value();
std::string cloneOf = (cloneOfXml == NULL) ? "" : cloneOfXml->value(); std::string cloneOf = (cloneOfXml == NULL) ? "" : cloneOfXml->value();
std::string players; std::string players;
std::string buttons; std::string buttons;
@@ -453,7 +459,7 @@ bool MetadataDatabase::ImportMameList(std::string filename, std::string collecti
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
sqlite3_prepare_v2(handle, sqlite3_prepare_v2(handle,
"INSERT OR REPLACE INTO Meta (name, title, year, manufacturer, players, buttons, cloneOf, collectionName) VALUES (?,?,?,?,?,?,?,?)", "INSERT OR REPLACE INTO Meta (name, title, year, manufacturer, genre, players, buttons, cloneOf, collectionName) VALUES (?,?,?,?,?,?,?,?,?)",
-1, &stmt, 0); -1, &stmt, 0);
@@ -461,10 +467,11 @@ bool MetadataDatabase::ImportMameList(std::string filename, std::string collecti
sqlite3_bind_text(stmt, 2, description.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 2, description.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 3, year.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 3, year.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 4, manufacturer.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 4, manufacturer.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 5, players.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 5, genre.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 6, buttons.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 6, players.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 7, cloneOf.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 7, buttons.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 8, collectionName.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 8, cloneOf.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 9, collectionName.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_step(stmt); sqlite3_step(stmt);
sqlite3_finalize(stmt); sqlite3_finalize(stmt);

View File

@@ -215,6 +215,12 @@ void ReloadableMedia::ReloadTexture()
{ {
imageBasename = selectedItem->GetManufacturer(); imageBasename = selectedItem->GetManufacturer();
} }
else if(typeLC == "genre")
{
imageBasename = selectedItem->GetGenre();
}
Utils::ReplaceSlashesWithUnderscores(imageBasename);
if(!LoadedComponent) if(!LoadedComponent)
{ {

View File

@@ -55,6 +55,10 @@ ReloadableText::ReloadableText(std::string type, Font *font, std::string layoutK
{ {
Type = TextTypeManufacturer; Type = TextTypeManufacturer;
} }
else if(type == "genre")
{
Type = TextTypeGenre;
}
AllocateGraphicsMemory(); AllocateGraphicsMemory();
} }
@@ -147,6 +151,9 @@ void ReloadableText::ReloadTexture()
case TextTypeManufacturer: case TextTypeManufacturer:
ss << selectedItem->GetManufacturer(); ss << selectedItem->GetManufacturer();
break; break;
case TextTypeGenre:
ss << selectedItem->GetGenre();
break;
default: default:
break; break;
} }

View File

@@ -42,6 +42,7 @@ private:
TextTypeYear, TextTypeYear,
TextTypeTitle, TextTypeTitle,
TextTypeManufacturer, TextTypeManufacturer,
TextTypeGenre,
}; };
void ReloadTexture(); void ReloadTexture();

View File

@@ -89,23 +89,20 @@ bool ImportConfiguration(Configuration *c)
{ {
std::string basename = dirp->d_name; std::string basename = dirp->d_name;
// if(basename.length() > 0) std::string extension = basename.substr(basename.find_last_of("."), basename.size()-1);
basename = basename.substr(0, basename.find_last_of("."));
if(extension == ".conf")
{ {
std::string extension = basename.substr(basename.find_last_of("."), basename.size()-1); std::string prefix = "launchers." + basename;
basename = basename.substr(0, basename.find_last_of("."));
if(extension == ".conf") std::string importFile = launchersPath + "/" + std::string(dirp->d_name);
if(!c->Import(prefix, importFile))
{ {
std::string prefix = "launchers." + basename; Logger::Write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + importFile + "\"");
closedir(dp);
std::string importFile = launchersPath + "/" + std::string(dirp->d_name); return false;
if(!c->Import(prefix, importFile))
{
Logger::Write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + importFile + "\"");
closedir(dp);
return false;
}
} }
} }
} }
@@ -123,7 +120,8 @@ bool ImportConfiguration(Configuration *c)
while((dirp = readdir(dp)) != NULL) while((dirp = readdir(dp)) != NULL)
{ {
if (dirp->d_type == DT_DIR && std::string(dirp->d_name) != "." && std::string(dirp->d_name) != "..") std::string dirName = (dirp->d_name);
if (dirp->d_type == DT_DIR && dirName != "." && dirName != ".." && dirName.length() > 0 && dirName[0] != '_')
{ {
std::string prefix = "collections." + std::string(dirp->d_name); std::string prefix = "collections." + std::string(dirp->d_name);

View File

@@ -114,6 +114,13 @@ void Utils::NormalizeBackSlashes(std::string& content)
std::replace(content.begin(), content.end(), '\\', '/'); std::replace(content.begin(), content.end(), '\\', '/');
} }
void Utils::ReplaceSlashesWithUnderscores(std::string &content)
{
std::replace(content.begin(), content.end(), '\\', '_');
std::replace(content.begin(), content.end(), '/', '_');
}
std::string Utils::GetDirectory(std::string filePath) std::string Utils::GetDirectory(std::string filePath)
{ {

View File

@@ -27,6 +27,7 @@ public:
static float ConvertFloat(std::string content); static float ConvertFloat(std::string content);
static int ConvertInt(std::string content); static int ConvertInt(std::string content);
static void NormalizeBackSlashes(std::string &content); static void NormalizeBackSlashes(std::string &content);
static void ReplaceSlashesWithUnderscores(std::string &content);
static std::string GetDirectory(std::string filePath); static std::string GetDirectory(std::string filePath);
static std::string GetParentDirectory(std::string filePath); static std::string GetParentDirectory(std::string filePath);
static std::string GetFileName(std::string filePath); static std::string GetFileName(std::string filePath);