RiivolutionParser: Add code to read and write the Riivolution config XMLs that remember the last selection.

This commit is contained in:
Admiral H. Curtiss
2021-10-19 23:30:02 +02:00
parent 2d3ed2c3ad
commit 2be62d94fc
2 changed files with 127 additions and 0 deletions

View File

@ -199,9 +199,33 @@ struct Disc
std::vector<Patch> GeneratePatches(const std::string& game_id) const;
};
// Config format that remembers which patches are enabled/disabled for the next run.
// Some patches ship with pre-made config XMLs instead of baking their defaults into the actual
// patch XMLs, so it makes sense to support this format directly.
struct ConfigOption
{
// The identifier for the referenced Option.
std::string m_id;
// The selected Choice index.
u32 m_default;
};
struct Config
{
// Config version. Riivolution itself only accepts '2' here.
int m_version = 2;
std::vector<ConfigOption> m_options;
};
std::optional<Disc> ParseFile(const std::string& filename);
std::optional<Disc> ParseString(std::string_view xml, std::string xml_path);
std::vector<Patch> GenerateRiivolutionPatchesFromGameModDescriptor(
const GameModDescriptorRiivolution& descriptor, const std::string& game_id,
std::optional<u16> revision, std::optional<u8> disc_number);
std::optional<Config> ParseConfigFile(const std::string& filename);
std::optional<Config> ParseConfigString(std::string_view xml);
std::string WriteConfigString(const Config& config);
bool WriteConfigFile(const std::string& filename, const Config& config);
void ApplyConfigDefaults(Disc* disc, const Config& config);
} // namespace DiscIO::Riivolution