Add JSON game database to replace dat parsing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "core/types.h"
|
||||
#include "game_settings.h"
|
||||
#include "game_database.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -34,24 +35,31 @@ enum class GameListCompatibilityRating
|
||||
Count,
|
||||
};
|
||||
|
||||
struct GameListDatabaseEntry
|
||||
{
|
||||
std::string code;
|
||||
std::string title;
|
||||
DiscRegion region;
|
||||
};
|
||||
|
||||
struct GameListEntry
|
||||
{
|
||||
GameListEntryType type;
|
||||
DiscRegion region;
|
||||
|
||||
std::string path;
|
||||
std::string code;
|
||||
std::string title;
|
||||
std::string genre;
|
||||
std::string publisher;
|
||||
std::string developer;
|
||||
u64 total_size;
|
||||
u64 last_modified_time;
|
||||
DiscRegion region;
|
||||
GameListEntryType type;
|
||||
|
||||
u64 release_date;
|
||||
u32 supported_controllers;
|
||||
u8 min_players;
|
||||
u8 max_players;
|
||||
u8 min_blocks;
|
||||
u8 max_blocks;
|
||||
|
||||
GameListCompatibilityRating compatibility_rating;
|
||||
GameSettings::Entry settings;
|
||||
|
||||
size_t GetReleaseDateString(char* buffer, size_t buffer_size) const;
|
||||
};
|
||||
|
||||
struct GameListCompatibilityEntry
|
||||
@@ -93,11 +101,11 @@ public:
|
||||
const u32 GetSearchDirectoryCount() const { return static_cast<u32>(m_search_directories.size()); }
|
||||
|
||||
const GameListEntry* GetEntryForPath(const char* path) const;
|
||||
const GameListDatabaseEntry* GetDatabaseEntryForCode(const std::string& code) const;
|
||||
const GameListCompatibilityEntry* GetCompatibilityEntryForCode(const std::string& code) const;
|
||||
|
||||
bool GetGameCodeAndTitleFromDatabase(const char* path, std::string* code, std::string* title);
|
||||
|
||||
void SetCacheFilename(std::string filename) { m_cache_filename = std::move(filename); }
|
||||
void SetUserDatabaseFilename(std::string filename) { m_user_database_filename = std::move(filename); }
|
||||
void SetUserCompatibilityListFilename(std::string filename)
|
||||
{
|
||||
m_user_compatibility_list_filename = std::move(filename);
|
||||
@@ -123,10 +131,9 @@ private:
|
||||
enum : u32
|
||||
{
|
||||
GAME_LIST_CACHE_SIGNATURE = 0x45434C47,
|
||||
GAME_LIST_CACHE_VERSION = 25
|
||||
GAME_LIST_CACHE_VERSION = 26
|
||||
};
|
||||
|
||||
using DatabaseMap = std::unordered_map<std::string, GameListDatabaseEntry>;
|
||||
using CacheMap = std::unordered_map<std::string, GameListEntry>;
|
||||
using CompatibilityMap = std::unordered_map<std::string, GameListCompatibilityEntry>;
|
||||
|
||||
@@ -160,16 +167,15 @@ private:
|
||||
|
||||
void LoadGameSettings();
|
||||
|
||||
DatabaseMap m_database;
|
||||
EntryList m_entries;
|
||||
CacheMap m_cache_map;
|
||||
GameDatabase m_database;
|
||||
CompatibilityMap m_compatibility_list;
|
||||
GameSettings::Database m_game_settings;
|
||||
std::unique_ptr<ByteStream> m_cache_write_stream;
|
||||
|
||||
std::vector<DirectoryEntry> m_search_directories;
|
||||
std::string m_cache_filename;
|
||||
std::string m_user_database_filename;
|
||||
std::string m_user_compatibility_list_filename;
|
||||
std::string m_user_game_settings_filename;
|
||||
bool m_database_load_tried = false;
|
||||
|
||||
Reference in New Issue
Block a user