Manages a collection of ZScream-compatible ASM patches. More...
#include <patch_manager.h>
Public Member Functions | |
| PatchManager ()=default | |
| absl::Status | LoadPatches (const std::string &patches_dir) |
| Load all patches from a directory structure. | |
| absl::Status | ReloadPatches () |
| Reload patches from the current directory. | |
| const std::vector< std::string > & | folders () const |
| Get list of patch folder names. | |
| std::vector< AsmPatch * > | GetPatchesInFolder (const std::string &folder) |
| Get all patches in a specific folder. | |
| AsmPatch * | GetPatch (const std::string &folder, const std::string &filename) |
| Get a specific patch by folder and filename. | |
| const std::vector< std::unique_ptr< AsmPatch > > & | patches () const |
| Get all loaded patches. | |
| int | GetEnabledPatchCount () const |
| Get count of enabled patches. | |
| absl::Status | ApplyEnabledPatches (Rom *rom) |
| Apply all enabled patches to a ROM. | |
| absl::Status | GenerateCombinedPatch (const std::string &output_path) |
| Generate a combined .asm file that includes all enabled patches. | |
| absl::Status | SaveAllPatches () |
| Save all patches to their files. | |
| absl::Status | CreatePatchFolder (const std::string &folder_name) |
| Create a new patch folder. | |
| absl::Status | RemovePatchFolder (const std::string &folder_name) |
| Remove a patch folder and all its contents. | |
| absl::Status | AddPatchFile (const std::string &source_path, const std::string &target_folder) |
| Add a patch file from an external source. | |
| absl::Status | RemovePatchFile (const std::string &folder, const std::string &filename) |
| Remove a patch file. | |
| const std::string & | patches_directory () const |
| Get the patches directory path. | |
| bool | is_loaded () const |
| Check if patches have been loaded. | |
Private Member Functions | |
| void | ScanDirectory (const std::string &dir_path, const std::string &folder_name) |
| Scan a directory for .asm files. | |
Private Attributes | |
| std::vector< std::string > | folders_ |
| std::vector< std::unique_ptr< AsmPatch > > | patches_ |
| std::string | patches_directory_ |
| bool | is_loaded_ = false |
Manages a collection of ZScream-compatible ASM patches.
PatchManager handles patch discovery, loading, organization, and application. It expects patches to be organized in a directory structure like:
Definition at line 36 of file patch_manager.h.
|
default |
| absl::Status yaze::core::PatchManager::LoadPatches | ( | const std::string & | patches_dir | ) |
Load all patches from a directory structure.
| patches_dir | Path to the patches root directory |
Definition at line 17 of file patch_manager.cc.
References folders_, is_loaded_, patches_, patches_directory_, and ScanDirectory().
Referenced by yaze::editor::SettingsPanel::DrawPatchSettings(), and ReloadPatches().

| absl::Status yaze::core::PatchManager::ReloadPatches | ( | ) |
Reload patches from the current directory.
Definition at line 65 of file patch_manager.cc.
References LoadPatches(), and patches_directory_.

|
inline |
Get list of patch folder names.
Definition at line 55 of file patch_manager.h.
References folders_.
Referenced by yaze::editor::SettingsPanel::DrawPatchSettings().
| std::vector< AsmPatch * > yaze::core::PatchManager::GetPatchesInFolder | ( | const std::string & | folder | ) |
Get all patches in a specific folder.
| folder | The folder name (e.g., "Sprites") |
Definition at line 85 of file patch_manager.cc.
References patches_.
Referenced by yaze::editor::SettingsPanel::DrawPatchList().
| AsmPatch * yaze::core::PatchManager::GetPatch | ( | const std::string & | folder, |
| const std::string & | filename ) |
Get a specific patch by folder and filename.
| folder | The folder name |
| filename | The filename (e.g., "Spike Damage.asm") |
Definition at line 99 of file patch_manager.cc.
References patches_.
|
inline |
Get all loaded patches.
Definition at line 75 of file patch_manager.h.
References patches_.
Referenced by yaze::editor::SettingsPanel::DrawPatchSettings().
| int yaze::core::PatchManager::GetEnabledPatchCount | ( | ) | const |
Get count of enabled patches.
Definition at line 109 of file patch_manager.cc.
References patches_.
Referenced by ApplyEnabledPatches(), and yaze::editor::SettingsPanel::DrawPatchSettings().
| absl::Status yaze::core::PatchManager::ApplyEnabledPatches | ( | Rom * | rom | ) |
Apply all enabled patches to a ROM.
| rom | The ROM to patch |
Definition at line 119 of file patch_manager.cc.
References yaze::core::AsarWrapper::ApplyPatch(), GenerateCombinedPatch(), GetEnabledPatchCount(), yaze::core::AsarWrapper::Initialize(), yaze::Rom::is_loaded(), yaze::Rom::mutable_vector(), and patches_directory_.
Referenced by yaze::editor::SettingsPanel::DrawPatchSettings().
| absl::Status yaze::core::PatchManager::GenerateCombinedPatch | ( | const std::string & | output_path | ) |
Generate a combined .asm file that includes all enabled patches.
| output_path | Path to write the combined patch file |
The generated file can be applied using Asar directly. It uses incsrc directives to include each enabled patch file.
Definition at line 176 of file patch_manager.cc.
References patches_.
Referenced by ApplyEnabledPatches().
| absl::Status yaze::core::PatchManager::SaveAllPatches | ( | ) |
Save all patches to their files.
Definition at line 225 of file patch_manager.cc.
References patches_.
Referenced by yaze::editor::SettingsPanel::DrawPatchSettings().
| absl::Status yaze::core::PatchManager::CreatePatchFolder | ( | const std::string & | folder_name | ) |
Create a new patch folder.
| folder_name | The name of the new folder |
Definition at line 245 of file patch_manager.cc.
References folders_, and patches_directory_.
| absl::Status yaze::core::PatchManager::RemovePatchFolder | ( | const std::string & | folder_name | ) |
Remove a patch folder and all its contents.
| folder_name | The folder to remove |
Definition at line 273 of file patch_manager.cc.
References folders_, patches_, and patches_directory_.
| absl::Status yaze::core::PatchManager::AddPatchFile | ( | const std::string & | source_path, |
| const std::string & | target_folder ) |
Add a patch file from an external source.
| source_path | Path to the source .asm file |
| target_folder | Folder to add the patch to |
Definition at line 313 of file patch_manager.cc.
References folders_, patches_, and patches_directory_.
| absl::Status yaze::core::PatchManager::RemovePatchFile | ( | const std::string & | folder, |
| const std::string & | filename ) |
Remove a patch file.
| folder | The folder containing the patch |
| filename | The patch filename |
Definition at line 354 of file patch_manager.cc.
References patches_, and patches_directory_.
|
inline |
Get the patches directory path.
Definition at line 142 of file patch_manager.h.
References patches_directory_.
|
inline |
Check if patches have been loaded.
Definition at line 147 of file patch_manager.h.
References is_loaded_.
|
private |
Scan a directory for .asm files.
| dir_path | Path to the directory |
| folder_name | Name to assign to patches found |
Definition at line 72 of file patch_manager.cc.
References patches_.
Referenced by LoadPatches().
|
private |
Definition at line 157 of file patch_manager.h.
Referenced by AddPatchFile(), CreatePatchFolder(), folders(), LoadPatches(), and RemovePatchFolder().
|
private |
Definition at line 158 of file patch_manager.h.
Referenced by AddPatchFile(), GenerateCombinedPatch(), GetEnabledPatchCount(), GetPatch(), GetPatchesInFolder(), LoadPatches(), patches(), RemovePatchFile(), RemovePatchFolder(), SaveAllPatches(), and ScanDirectory().
|
private |
Definition at line 159 of file patch_manager.h.
Referenced by AddPatchFile(), ApplyEnabledPatches(), CreatePatchFolder(), LoadPatches(), patches_directory(), ReloadPatches(), RemovePatchFile(), and RemovePatchFolder().
|
private |
Definition at line 160 of file patch_manager.h.
Referenced by is_loaded(), and LoadPatches().