| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <map> |
| 7 |
#include <memory> |
| 8 |
#include <optional> |
| 9 |
#include <string> |
| 10 |
#include <string_view> |
| 11 |
#include <vector> |
| 12 |
|
| 13 |
#include "Common/CommonTypes.h" |
| 14 |
|
| 15 |
namespace DiscIO |
| 16 |
{ |
| 17 |
struct GameModDescriptorRiivolution; |
| 18 |
} |
| 19 |
|
| 20 |
namespace DiscIO::Riivolution |
| 21 |
{ |
| 22 |
class FileDataLoader; |
| 23 |
|
| 24 |
|
| 25 |
struct GameFilter |
| 26 |
{ |
| 27 |
std::optional<std::string> m_game; |
| 28 |
std::optional<std::string> m_developer; |
| 29 |
std::optional<int> m_disc; |
| 30 |
std::optional<int> m_version; |
| 31 |
std::optional<std::vector<std::string>> m_regions; |
| 32 |
}; |
| 33 |
|
| 34 |
|
| 35 |
struct PatchReference |
| 36 |
{ |
| 37 |
std::string m_id; |
| 38 |
std::map<std::string, std::string> m_params; |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
struct Choice |
| 43 |
{ |
| 44 |
std::string m_name; |
| 45 |
std::vector<PatchReference> m_patch_references; |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
struct Option |
| 50 |
{ |
| 51 |
std::string m_name; |
| 52 |
std::string m_id; |
| 53 |
std::vector<Choice> m_choices; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
u32 m_selected_choice = 0; |
| 58 |
}; |
| 59 |
|
| 60 |
|
| 61 |
struct Section |
| 62 |
{ |
| 63 |
std::string m_name; |
| 64 |
std::vector<Option> m_options; |
| 65 |
}; |
| 66 |
|
| 67 |
|
| 68 |
struct File |
| 69 |
{ |
| 70 |
|
| 71 |
std::string m_disc; |
| 72 |
|
| 73 |
|
| 74 |
std::string m_external; |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
bool m_resize = true; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
bool m_create = false; |
| 83 |
|
| 84 |
|
| 85 |
u32 m_offset = 0; |
| 86 |
|
| 87 |
|
| 88 |
u32 m_fileoffset = 0; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
u32 m_length = 0; |
| 93 |
}; |
| 94 |
|
| 95 |
|
| 96 |
struct Folder |
| 97 |
{ |
| 98 |
|
| 99 |
|
| 100 |
std::string m_disc; |
| 101 |
|
| 102 |
|
| 103 |
std::string m_external; |
| 104 |
|
| 105 |
|
| 106 |
bool m_resize = true; |
| 107 |
|
| 108 |
|
| 109 |
bool m_create = false; |
| 110 |
|
| 111 |
|
| 112 |
bool m_recursive = true; |
| 113 |
|
| 114 |
|
| 115 |
u32 m_length = 0; |
| 116 |
}; |
| 117 |
|
| 118 |
|
| 119 |
struct Savegame |
| 120 |
{ |
| 121 |
|
| 122 |
std::string m_external; |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
bool m_clone = true; |
| 127 |
}; |
| 128 |
|
| 129 |
|
| 130 |
struct Memory |
| 131 |
{ |
| 132 |
|
| 133 |
u32 m_offset = 0; |
| 134 |
|
| 135 |
|
| 136 |
std::vector<u8> m_value; |
| 137 |
|
| 138 |
|
| 139 |
std::string m_valuefile; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
std::vector<u8> m_original; |
| 144 |
|
| 145 |
|
| 146 |
bool m_ocarina = false; |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
bool m_search = false; |
| 151 |
|
| 152 |
|
| 153 |
u32 m_align = 1; |
| 154 |
}; |
| 155 |
|
| 156 |
struct Patch |
| 157 |
{ |
| 158 |
|
| 159 |
std::string m_id; |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
std::string m_root; |
| 164 |
|
| 165 |
std::shared_ptr<FileDataLoader> m_file_data_loader; |
| 166 |
|
| 167 |
std::vector<File> m_file_patches; |
| 168 |
std::vector<Folder> m_folder_patches; |
| 169 |
std::vector<File> m_sys_file_patches; |
| 170 |
std::vector<Folder> m_sys_folder_patches; |
| 171 |
std::vector<Savegame> m_savegame_patches; |
| 172 |
std::vector<Memory> m_memory_patches; |
| 173 |
|
| 174 |
~Patch(); |
| 175 |
}; |
| 176 |
|
| 177 |
struct Disc |
| 178 |
{ |
| 179 |
|
| 180 |
int m_version = 0; |
| 181 |
|
| 182 |
|
| 183 |
GameFilter m_game_filter; |
| 184 |
|
| 185 |
|
| 186 |
std::vector<Section> m_sections; |
| 187 |
|
| 188 |
|
| 189 |
std::vector<Patch> m_patches; |
| 190 |
|
| 191 |
|
| 192 |
std::string m_xml_path; |
| 193 |
|
| 194 |
|
| 195 |
bool IsValidForGame(const std::string& game_id, std::optional<u16> revision, |
| 196 |
std::optional<u8> disc_number) const; |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
std::vector<Patch> GeneratePatches(const std::string& game_id) const; |
| 201 |
}; |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
struct ConfigOption |
| 207 |
{ |
| 208 |
|
| 209 |
std::string m_id; |
| 210 |
|
| 211 |
|
| 212 |
u32 m_default = 0; |
| 213 |
}; |
| 214 |
|
| 215 |
struct Config |
| 216 |
{ |
| 217 |
|
| 218 |
int m_version = 2; |
| 219 |
std::vector<ConfigOption> m_options; |
| 220 |
}; |
| 221 |
|
| 222 |
std::optional<Disc> ParseFile(const std::string& filename); |
| 223 |
std::optional<Disc> ParseString(std::string_view xml, std::string xml_path); |
| 224 |
std::vector<Patch> GenerateRiivolutionPatchesFromGameModDescriptor( |
| 225 |
const GameModDescriptorRiivolution& descriptor, const std::string& game_id, |
| 226 |
std::optional<u16> revision, std::optional<u8> disc_number); |
| 227 |
std::vector<Patch> GenerateRiivolutionPatchesFromConfig(const std::string& root_directory, |
| 228 |
const std::string& game_id, |
| 229 |
std::optional<u16> revision, |
| 230 |
std::optional<u8> disc_number); |
| 231 |
std::optional<Config> ParseConfigFile(const std::string& filename); |
| 232 |
std::optional<Config> ParseConfigString(std::string_view xml); |
| 233 |
std::string WriteConfigString(const Config& config); |
| 234 |
bool WriteConfigFile(const std::string& filename, const Config& config); |
| 235 |
void ApplyConfigDefaults(Disc* disc, const Config& config); |
| 236 |
} |