yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
patch_manager.h
Go to the documentation of this file.
1#ifndef YAZE_CORE_PATCH_PATCH_MANAGER_H
2#define YAZE_CORE_PATCH_PATCH_MANAGER_H
3
4#include <memory>
5#include <string>
6#include <vector>
7
8#include "absl/status/status.h"
10#ifdef YAZE_WITH_Z3DK
11#include "core/z3dk_wrapper.h"
12#endif
13
14namespace yaze {
15class Rom;
16}
17
18namespace yaze::core {
19
40 public:
41 PatchManager() = default;
42
48 absl::Status LoadPatches(const std::string& patches_dir);
49
53 absl::Status ReloadPatches();
54
58 const std::vector<std::string>& folders() const { return folders_; }
59
65 std::vector<AsmPatch*> GetPatchesInFolder(const std::string& folder);
66
73 AsmPatch* GetPatch(const std::string& folder, const std::string& filename);
74
78 const std::vector<std::unique_ptr<AsmPatch>>& patches() const {
79 return patches_;
80 }
81
85 int GetEnabledPatchCount() const;
86
92 absl::Status ApplyEnabledPatches(Rom* rom);
93
94#ifdef YAZE_WITH_Z3DK
95 void SetZ3dkAssembleOptions(const Z3dkAssembleOptions& options) {
96 z3dk_options_ = options;
97 }
98#endif
99
108 absl::Status GenerateCombinedPatch(const std::string& output_path);
109
114 absl::Status SaveAllPatches();
115
121 absl::Status CreatePatchFolder(const std::string& folder_name);
122
128 absl::Status RemovePatchFolder(const std::string& folder_name);
129
136 absl::Status AddPatchFile(const std::string& source_path,
137 const std::string& target_folder);
138
145 absl::Status RemovePatchFile(const std::string& folder,
146 const std::string& filename);
147
151 const std::string& patches_directory() const { return patches_directory_; }
152
156 bool is_loaded() const { return is_loaded_; }
157
158 private:
164 void ScanDirectory(const std::string& dir_path,
165 const std::string& folder_name);
166
167 std::vector<std::string> folders_;
168 std::vector<std::unique_ptr<AsmPatch>> patches_;
170 bool is_loaded_ = false;
171#ifdef YAZE_WITH_Z3DK
172 Z3dkAssembleOptions z3dk_options_;
173#endif
174};
175
176} // namespace yaze::core
177
178#endif // YAZE_CORE_PATCH_PATCH_MANAGER_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Represents a ZScream-compatible ASM patch file.
Definition asm_patch.h:74
Manages a collection of ZScream-compatible ASM patches.
absl::Status ApplyEnabledPatches(Rom *rom)
Apply all enabled patches to a ROM.
absl::Status RemovePatchFile(const std::string &folder, const std::string &filename)
Remove a patch file.
std::vector< std::string > folders_
void ScanDirectory(const std::string &dir_path, const std::string &folder_name)
Scan a directory for .asm files.
absl::Status AddPatchFile(const std::string &source_path, const std::string &target_folder)
Add a patch file from an external source.
AsmPatch * GetPatch(const std::string &folder, const std::string &filename)
Get a specific patch by folder and filename.
absl::Status SaveAllPatches()
Save all patches to their files.
bool is_loaded() const
Check if patches have been loaded.
const std::vector< std::string > & folders() const
Get list of patch folder names.
int GetEnabledPatchCount() const
Get count of enabled patches.
std::vector< AsmPatch * > GetPatchesInFolder(const std::string &folder)
Get all patches in a specific folder.
absl::Status CreatePatchFolder(const std::string &folder_name)
Create a new patch folder.
absl::Status ReloadPatches()
Reload patches from the current directory.
const std::string & patches_directory() const
Get the patches directory path.
const std::vector< std::unique_ptr< AsmPatch > > & patches() const
Get all loaded patches.
std::vector< std::unique_ptr< AsmPatch > > patches_
absl::Status LoadPatches(const std::string &patches_dir)
Load all patches from a directory structure.
absl::Status RemovePatchFolder(const std::string &folder_name)
Remove a patch folder and all its contents.
absl::Status GenerateCombinedPatch(const std::string &output_path)
Generate a combined .asm file that includes all enabled patches.