Refactor ROM save functionality to use structured settings
- Introduced a new SaveSettings struct to encapsulate parameters for the SaveToFile method, improving clarity and maintainability. - Updated SaveToFile method signature to accept SaveSettings instead of individual parameters. - Adjusted SaveRom method in EditorManager to utilize the new SaveSettings struct for better parameter management. - Removed redundant label loading from LoadFromFile when z3_load is true, streamlining the loading process.
This commit is contained in:
@@ -261,10 +261,9 @@ absl::Status Rom::LoadFromFile(const std::string &filename, bool z3_load) {
|
||||
|
||||
if (z3_load) {
|
||||
RETURN_IF_ERROR(LoadZelda3());
|
||||
resource_label_manager_.LoadLabels(absl::StrFormat("%s.labels", filename));
|
||||
}
|
||||
|
||||
// Set up the resource labels
|
||||
resource_label_manager_.LoadLabels(absl::StrFormat("%s.labels", filename));
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
@@ -383,12 +382,16 @@ absl::Status Rom::SaveGfxGroups() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Rom::SaveToFile(bool backup, bool save_new, std::string filename) {
|
||||
absl::Status Rom::SaveToFile(const SaveSettings &settings) {
|
||||
absl::Status non_firing_status;
|
||||
if (rom_data_.empty()) {
|
||||
return absl::InternalError("ROM data is empty.");
|
||||
}
|
||||
|
||||
std::string filename = settings.filename;
|
||||
auto backup = settings.backup;
|
||||
auto save_new = settings.save_new;
|
||||
|
||||
// Check if filename is empty
|
||||
if (filename == "") {
|
||||
filename = filename_;
|
||||
@@ -421,10 +424,12 @@ absl::Status Rom::SaveToFile(bool backup, bool save_new, std::string filename) {
|
||||
}
|
||||
|
||||
// Run the other save functions
|
||||
if (core::FeatureFlags::get().kSaveAllPalettes)
|
||||
RETURN_IF_ERROR(SaveAllPalettes());
|
||||
if (core::FeatureFlags::get().kSaveGfxGroups)
|
||||
RETURN_IF_ERROR(SaveGfxGroups());
|
||||
if (settings.z3_save) {
|
||||
if (core::FeatureFlags::get().kSaveAllPalettes)
|
||||
RETURN_IF_ERROR(SaveAllPalettes());
|
||||
if (core::FeatureFlags::get().kSaveGfxGroups)
|
||||
RETURN_IF_ERROR(SaveGfxGroups());
|
||||
}
|
||||
|
||||
if (save_new) {
|
||||
// Create a file of the same name and append the date between the filename
|
||||
|
||||
Reference in New Issue
Block a user