Add Changes stack to ROM for saving
This commit is contained in:
@@ -306,12 +306,10 @@ void MasterEditor::DrawHelpMenu() {
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Text("File -> Open");
|
||||
ImGui::Text("Select a ROM file to open");
|
||||
ImGui::Text("Supported ROMs:");
|
||||
ImGui::Text("Supported ROMs (headered or unheadered):");
|
||||
ImGui::Text("The Legend of Zelda: A Link to the Past");
|
||||
ImGui::Text("US Version 1.0");
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Must remove header before opening");
|
||||
ImGui::Text("Header is 0x200 bytes of data at the beginning of the ROM");
|
||||
ImGui::Text("JP Version 1.0");
|
||||
|
||||
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
||||
open_rom_help = false;
|
||||
|
||||
@@ -245,13 +245,15 @@ void OverworldEditor::RenderUpdatedMapBitmap(const ImVec2 &click_position,
|
||||
|
||||
void OverworldEditor::QueueROMChanges(int index, ushort new_tile16) {
|
||||
// Store the changes made by the user to the ROM (or project file)
|
||||
overworld_.SaveOverworldMaps();
|
||||
if (!overworld_.CreateTile32Tilemap()) {
|
||||
// overworld_.SaveMap16Tiles();
|
||||
overworld_.SaveMap32Tiles();
|
||||
} else {
|
||||
std::cout << "Failed to create tile32 tilemap" << std::endl;
|
||||
}
|
||||
rom()->QueueChanges([&]() {
|
||||
overworld_.SaveOverworldMaps();
|
||||
if (!overworld_.CreateTile32Tilemap()) {
|
||||
// overworld_.SaveMap16Tiles();
|
||||
overworld_.SaveMap32Tiles();
|
||||
} else {
|
||||
std::cout << "Failed to create tile32 tilemap" << std::endl;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void OverworldEditor::DetermineActiveMap(const ImVec2 &mouse_position) {
|
||||
|
||||
@@ -3,16 +3,24 @@
|
||||
#include <SDL.h>
|
||||
#include <asar/src/asar/interface-lib.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
@@ -21,8 +29,9 @@
|
||||
#include "app/core/common.h"
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/compression.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/gfx/compression.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -324,6 +333,11 @@ absl::Status ROM::SaveToFile(bool backup, absl::string_view filename) {
|
||||
|
||||
// Run the other save functions
|
||||
// SaveAllPalettes();
|
||||
while (!changes_.empty()) {
|
||||
auto change = changes_.top();
|
||||
change();
|
||||
changes_.pop();
|
||||
}
|
||||
|
||||
// Open the file that we know exists for writing
|
||||
std::fstream file(filename.data(), std::ios::binary | std::ios::out);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -29,7 +30,9 @@
|
||||
#include "app/core/common.h"
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/compression.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -197,6 +200,8 @@ class ROM {
|
||||
WriteShort(address, bgr);
|
||||
}
|
||||
|
||||
void QueueChanges(std::function<void()> function) { changes_.push(function); }
|
||||
|
||||
VersionConstants GetVersionConstants() const {
|
||||
return kVersionConstantsMap.at(version_);
|
||||
}
|
||||
@@ -286,6 +291,7 @@ class ROM {
|
||||
Z3_Version version_ = Z3_Version::US;
|
||||
gfx::BitmapTable graphics_bin_;
|
||||
|
||||
std::stack<std::function<void()>> changes_;
|
||||
std::shared_ptr<SDL_Renderer> renderer_;
|
||||
std::unordered_map<std::string, gfx::PaletteGroup> palette_groups_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user