From 5a5ae4f9a5c029c41652d7c5198b9218b0329399 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 29 Jan 2015 01:32:35 +0100 Subject: [PATCH] (Database) List entries by name instead of description --- database_info.c | 6 ++++ database_info.h | 1 + menu/menu_database.c | 61 ----------------------------------------- menu/menu_database.h | 3 -- menu/menu_entries.c | 2 +- menu/menu_entries_cbs.c | 8 +++++- 6 files changed, 15 insertions(+), 66 deletions(-) diff --git a/database_info.c b/database_info.c index 2a2be4df2f..b0c3816460 100644 --- a/database_info.c +++ b/database_info.c @@ -74,6 +74,7 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q db_info = (database_info_t*)&database_info[i]; + db_info->name = NULL; db_info->description = NULL; db_info->publisher = NULL; db_info->developer = NULL; @@ -99,6 +100,9 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q struct rmsgpack_dom_value *key = &item.map.items[j].key; struct rmsgpack_dom_value *val = &item.map.items[j].value; + if (!strcmp(key->string.buff, "name")) + db_info->name = strdup(val->string.buff); + if (!strcmp(key->string.buff, "description")) db_info->description = strdup(val->string.buff); @@ -185,6 +189,8 @@ void database_info_list_free(database_info_list_t *database_info_list) if (!info) continue; + if (info->name) + free(info->name); if (info->description) free(info->description); if (info->publisher) diff --git a/database_info.h b/database_info.h index 306ce6efb1..5f3ab1ebc1 100644 --- a/database_info.h +++ b/database_info.h @@ -27,6 +27,7 @@ extern "C" { typedef struct { + char *name; char *description; char *publisher; char *developer; diff --git a/menu/menu_database.c b/menu/menu_database.c index 2e59dd1ed0..f4e8582cfa 100644 --- a/menu/menu_database.c +++ b/menu/menu_database.c @@ -40,64 +40,3 @@ int menu_database_populate_query(file_list_t *list, const char *path, return 0; } - -int menu_database_print_info(const char *path, - const char *query) -{ -#ifdef HAVE_LIBRETRODB - size_t i; - database_info_list_t *db_info = NULL; - - if (!(db_info = database_info_list_new(path, query))) - return -1; - - for (i = 0; i < db_info->count; i++) - { - database_info_t *db_info_entry = (database_info_t*)&db_info->list[i]; - - if (!db_info_entry) - continue; - - if (db_info_entry->description) - RARCH_LOG("Description: %s\n", db_info_entry->description); - if (db_info_entry->publisher) - RARCH_LOG("Publisher: %s\n", db_info_entry->publisher); - if (db_info_entry->developer) - RARCH_LOG("Developer: %s\n", db_info_entry->developer); - if (db_info_entry->origin) - RARCH_LOG("Origin: %s\n", db_info_entry->origin); - if (db_info_entry->franchise) - RARCH_LOG("Franchise: %s\n", db_info_entry->franchise); - if (db_info_entry->max_users) - RARCH_LOG("Max Users: %d\n", db_info_entry->max_users); - if (db_info_entry->edge_magazine_rating) - RARCH_LOG("Edge Magazine Rating: %d/10\n", db_info_entry->edge_magazine_rating); - if (db_info_entry->edge_magazine_issue) - RARCH_LOG("Edge Magazine Issue: %d\n", db_info_entry->edge_magazine_issue); - if (db_info_entry->edge_magazine_review) - RARCH_LOG("Edge Magazine Review: %s\n", db_info_entry->edge_magazine_review); - if (db_info_entry->releasemonth) - RARCH_LOG("Releasedate Month: %d\n", db_info_entry->releasemonth); - if (db_info_entry->releaseyear) - RARCH_LOG("Releasedate Year: %d\n", db_info_entry->releaseyear); - if (db_info_entry->bbfc_rating) - RARCH_LOG("BBFC Rating: %s\n", db_info_entry->bbfc_rating); - if (db_info_entry->esrb_rating) - RARCH_LOG("ESRB Rating: %s\n", db_info_entry->esrb_rating); - if (db_info_entry->elspa_rating) - RARCH_LOG("ELSPA Rating: %s\n", db_info_entry->elspa_rating); - if (db_info_entry->pegi_rating) - RARCH_LOG("PEGI Rating: %s\n", db_info_entry->pegi_rating); - if (db_info_entry->cero_rating) - RARCH_LOG("CERO Rating: %s\n", db_info_entry->cero_rating); - RARCH_LOG("Analog supported: %s\n", db_info_entry->analog_supported ? "true" : "false"); - RARCH_LOG("Rumble supported: %s\n", db_info_entry->rumble_supported ? "true" : "false"); - RARCH_LOG("\n\n"); - } - - if (db_info) - database_info_list_free(db_info); - db_info = NULL; -#endif - return 0; -} diff --git a/menu/menu_database.h b/menu/menu_database.h index b2bf9ec4bb..bbb802b6b0 100644 --- a/menu/menu_database.h +++ b/menu/menu_database.h @@ -29,9 +29,6 @@ extern "C" { int menu_database_populate_query(file_list_t *list, const char *path, const char *query); -int menu_database_print_info(const char *path, - const char *query); - #ifdef __cplusplus } #endif diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 86526a3fb6..dcf0edd1fc 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -64,7 +64,7 @@ int menu_entries_push_query(libretrodb_t *db, struct rmsgpack_dom_value *key = &item.map.items[i].key; struct rmsgpack_dom_value *val = &item.map.items[i].value; - if (!strcmp(key->string.buff, "description")) + if (!strcmp(key->string.buff, "name")) { menu_list_push(list, val->string.buff, db->path, MENU_FILE_RDB_ENTRY, 0); diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 6cf83e5d1e..fa7aaca706 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -841,7 +841,7 @@ static int deferred_push_rdb_entry_detail(void *data, void *userdata, goto done; } - strlcpy(query, "{'description':\"", sizeof(query)); + strlcpy(query, "{'name':\"", sizeof(query)); strlcat(query, str_list->elems[1].data, sizeof(query)); strlcat(query, "\"}", sizeof(query)); @@ -861,6 +861,12 @@ static int deferred_push_rdb_entry_detail(void *data, void *userdata, if (!db_info_entry) continue; + if (db_info_entry->name) + { + snprintf(tmp, sizeof(tmp), "Description: %s", db_info_entry->name); + menu_list_push(list, tmp, "rdb_entry_name", + 0, 0); + } if (db_info_entry->description) { snprintf(tmp, sizeof(tmp), "Description: %s", db_info_entry->description);