Represents a ZScream-compatible ASM patch file. More...
#include <asm_patch.h>
Public Member Functions | |
| AsmPatch (const std::string &file_path, const std::string &folder) | |
| Construct a patch from a file path. | |
| const std::string & | name () const |
| const std::string & | author () const |
| const std::string & | version () const |
| const std::string & | description () const |
| const std::string & | folder () const |
| const std::string & | filename () const |
| const std::string & | file_path () const |
| bool | enabled () const |
| void | set_enabled (bool enabled) |
| const std::vector< PatchParameter > & | parameters () const |
| std::vector< PatchParameter > & | mutable_parameters () |
| bool | SetParameterValue (const std::string &define_name, int value) |
| Set the value of a parameter by its define name. | |
| PatchParameter * | GetParameter (const std::string &define_name) |
| Get a parameter by its define name. | |
| const PatchParameter * | GetParameter (const std::string &define_name) const |
| std::string | GenerateContent () const |
| Generate the patch file content with current parameter values. | |
| absl::Status | Save () |
| Save the patch to its original file location. | |
| absl::Status | SaveToPath (const std::string &output_path) |
| Save the patch to a specific path. | |
| bool | is_valid () const |
| Check if the patch was loaded successfully. | |
Private Member Functions | |
| void | ParseMetadata (const std::string &content) |
| Parse metadata from the patch file content. | |
Static Private Member Functions | |
| static PatchParameterType | ParseType (const std::string &type_str) |
| Parse a parameter type from a string. | |
| static int | ParseValue (const std::string &value_str) |
| Parse an integer value from a string (handles $hex and decimal) | |
| static void | UpdateLine (std::string &content, const std::string &prefix, const std::string &new_value) |
| Update a line in the content that starts with a prefix. | |
| static void | UpdateDefineLine (std::string &content, const std::string &define_name, int value) |
| Update an Asar define line with a new value. | |
Private Attributes | |
| std::string | name_ |
| std::string | author_ |
| std::string | version_ |
| std::string | description_ |
| std::string | folder_ |
| std::string | filename_ |
| std::string | file_path_ |
| std::string | original_content_ |
| bool | enabled_ = true |
| bool | is_valid_ = false |
| std::vector< PatchParameter > | parameters_ |
Represents a ZScream-compatible ASM patch file.
ZScream uses comment-based metadata in ASM files to define patch properties and configurable parameters. This class parses that metadata and provides methods to modify parameter values and regenerate the file content.
Example patch file format:
Definition at line 74 of file asm_patch.h.
| yaze::core::AsmPatch::AsmPatch | ( | const std::string & | file_path, |
| const std::string & | folder ) |
Construct a patch from a file path.
| file_path | Full path to the .asm file |
| folder | Category folder name (e.g., "Sprites", "Misc") |
Definition at line 35 of file asm_patch.cc.
References file_path(), filename_, is_valid_, original_content_, and ParseMetadata().

|
inline |
Definition at line 84 of file asm_patch.h.
References name_.
Referenced by yaze::editor::SettingsPanel::DrawPatchDetails().
|
inline |
Definition at line 85 of file asm_patch.h.
References author_.
Referenced by yaze::editor::SettingsPanel::DrawPatchDetails().
|
inline |
Definition at line 86 of file asm_patch.h.
References version_.
Referenced by yaze::editor::SettingsPanel::DrawPatchDetails().
|
inline |
Definition at line 87 of file asm_patch.h.
References description_.
Referenced by yaze::editor::SettingsPanel::DrawPatchDetails().
|
inline |
Definition at line 88 of file asm_patch.h.
References folder_.
|
inline |
Definition at line 89 of file asm_patch.h.
References filename_.
|
inline |
|
inline |
|
inline |
Definition at line 94 of file asm_patch.h.
References enabled(), and enabled_.

|
inline |
Definition at line 97 of file asm_patch.h.
References parameters_.
|
inline |
Definition at line 98 of file asm_patch.h.
References parameters_.
Referenced by yaze::editor::SettingsPanel::DrawPatchDetails().
| bool yaze::core::AsmPatch::SetParameterValue | ( | const std::string & | define_name, |
| int | value ) |
Set the value of a parameter by its define name.
| define_name | The Asar define name (e.g., "!MY_DEFINE") |
| value | The new value to set |
Definition at line 300 of file asm_patch.cc.
References parameters_.
| PatchParameter * yaze::core::AsmPatch::GetParameter | ( | const std::string & | define_name | ) |
Get a parameter by its define name.
| define_name | The Asar define name |
Definition at line 310 of file asm_patch.cc.
References parameters_.
| const PatchParameter * yaze::core::AsmPatch::GetParameter | ( | const std::string & | define_name | ) | const |
Definition at line 319 of file asm_patch.cc.
References parameters_.
| std::string yaze::core::AsmPatch::GenerateContent | ( | ) | const |
Generate the patch file content with current parameter values.
Definition at line 329 of file asm_patch.cc.
References enabled_, original_content_, parameters_, UpdateDefineLine(), and UpdateLine().
Referenced by SaveToPath().

| absl::Status yaze::core::AsmPatch::Save | ( | ) |
Save the patch to its original file location.
Definition at line 375 of file asm_patch.cc.
References file_path_, and SaveToPath().

| absl::Status yaze::core::AsmPatch::SaveToPath | ( | const std::string & | output_path | ) |
Save the patch to a specific path.
| output_path | The path to save to |
Definition at line 379 of file asm_patch.cc.
References GenerateContent().
Referenced by Save().

|
inline |
Check if the patch was loaded successfully.
Definition at line 138 of file asm_patch.h.
References is_valid_.
|
private |
Parse metadata from the patch file content.
| content | The full file content |
Definition at line 60 of file asm_patch.cc.
References author_, yaze::core::PatchParameter::checked_value, yaze::core::PatchParameter::choices, yaze::core::PatchParameter::define_name, description_, yaze::core::PatchParameter::display_name, enabled_, filename_, yaze::core::kLong, yaze::core::kWord, yaze::core::PatchParameter::max_value, yaze::core::PatchParameter::min_value, name_, parameters_, ParseType(), ParseValue(), yaze::core::PatchParameter::type, yaze::core::PatchParameter::unchecked_value, yaze::core::PatchParameter::use_decimal, yaze::core::PatchParameter::value, and version_.
Referenced by AsmPatch().

|
staticprivate |
Parse a parameter type from a string.
| type_str | The type string (e.g., "byte", "bool", "choice") |
Definition at line 247 of file asm_patch.cc.
References yaze::core::kBitfield, yaze::core::kBool, yaze::core::kByte, yaze::core::kChoice, yaze::core::kItem, yaze::core::kLong, and yaze::core::kWord.
Referenced by ParseMetadata().
|
staticprivate |
Parse an integer value from a string (handles $hex and decimal)
| value_str | The value string (e.g., "$10" or "16") |
Definition at line 269 of file asm_patch.cc.
Referenced by ParseMetadata().
|
staticprivate |
Update a line in the content that starts with a prefix.
| content | The content to modify |
| prefix | The line prefix to find |
| new_value | The new value to set after the '=' |
Definition at line 343 of file asm_patch.cc.
Referenced by GenerateContent().
|
staticprivate |
Update an Asar define line with a new value.
| content | The content to modify |
| define_name | The define name to find |
| value | The new value |
Definition at line 358 of file asm_patch.cc.
Referenced by GenerateContent().
|
private |
Definition at line 180 of file asm_patch.h.
Referenced by name(), and ParseMetadata().
|
private |
Definition at line 181 of file asm_patch.h.
Referenced by author(), and ParseMetadata().
|
private |
Definition at line 182 of file asm_patch.h.
Referenced by ParseMetadata(), and version().
|
private |
Definition at line 183 of file asm_patch.h.
Referenced by description(), and ParseMetadata().
|
private |
Definition at line 184 of file asm_patch.h.
Referenced by folder().
|
private |
Definition at line 185 of file asm_patch.h.
Referenced by AsmPatch(), filename(), and ParseMetadata().
|
private |
Definition at line 186 of file asm_patch.h.
Referenced by file_path(), and Save().
|
private |
Definition at line 187 of file asm_patch.h.
Referenced by AsmPatch(), and GenerateContent().
|
private |
Definition at line 188 of file asm_patch.h.
Referenced by enabled(), GenerateContent(), ParseMetadata(), and set_enabled().
|
private |
Definition at line 189 of file asm_patch.h.
Referenced by AsmPatch(), and is_valid().
|
private |
Definition at line 192 of file asm_patch.h.
Referenced by GenerateContent(), GetParameter(), GetParameter(), mutable_parameters(), parameters(), ParseMetadata(), and SetParameterValue().