mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Core: Add ability to specify and launch a riivolution-modded game via a .json file.
This commit is contained in:
@ -57,6 +57,8 @@ namespace fs = std::filesystem;
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/GameModDescriptor.h"
|
||||
#include "DiscIO/RiivolutionParser.h"
|
||||
#include "DiscIO/RiivolutionPatcher.h"
|
||||
#include "DiscIO/VolumeDisc.h"
|
||||
#include "DiscIO/VolumeWad.h"
|
||||
@ -217,6 +219,40 @@ BootParameters::GenerateFromFile(std::vector<std::string> paths,
|
||||
return std::make_unique<BootParameters>(std::move(*wad), savestate_path);
|
||||
}
|
||||
|
||||
if (extension == ".json")
|
||||
{
|
||||
auto descriptor = DiscIO::ParseGameModDescriptorFile(path);
|
||||
if (descriptor)
|
||||
{
|
||||
auto boot_params = GenerateFromFile(descriptor->base_file, savestate_path);
|
||||
if (!boot_params)
|
||||
{
|
||||
PanicAlertFmtT("Could not recognize file {0}", descriptor->base_file);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (descriptor->riivolution && std::holds_alternative<Disc>(boot_params->parameters))
|
||||
{
|
||||
auto& disc = std::get<Disc>(boot_params->parameters);
|
||||
const auto& volume = *disc.volume;
|
||||
boot_params->riivolution_patches =
|
||||
DiscIO::Riivolution::GenerateRiivolutionPatchesFromGameModDescriptor(
|
||||
*descriptor->riivolution, volume.GetGameID(), volume.GetRevision(),
|
||||
volume.GetDiscNumber());
|
||||
if (!boot_params->riivolution_patches.empty())
|
||||
{
|
||||
disc.volume = DiscIO::CreateDisc(DiscIO::DirectoryBlobReader::Create(
|
||||
std::move(disc.volume),
|
||||
[&](std::vector<DiscIO::FSTBuilderNode>* fst, DiscIO::FSTBuilderNode* dol_node) {
|
||||
DiscIO::Riivolution::ApplyPatchesToFiles(boot_params->riivolution_patches, fst,
|
||||
dol_node);
|
||||
}));
|
||||
}
|
||||
}
|
||||
return boot_params;
|
||||
}
|
||||
}
|
||||
|
||||
PanicAlertFmtT("Could not recognize file {0}", path);
|
||||
return {};
|
||||
}
|
||||
|
Reference in New Issue
Block a user