SharedROM, Editor parent, housekeeping
This commit is contained in:
@@ -3,11 +3,37 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
|
class Editor {
|
||||||
|
public:
|
||||||
|
Editor() = default;
|
||||||
|
virtual ~Editor() = default;
|
||||||
|
|
||||||
|
virtual void Cut() = 0;
|
||||||
|
virtual void Copy() = 0;
|
||||||
|
virtual void Paste() = 0;
|
||||||
|
|
||||||
|
virtual void Undo() = 0;
|
||||||
|
virtual void Redo() = 0;
|
||||||
|
|
||||||
|
virtual void SelectAll() = 0;
|
||||||
|
|
||||||
|
virtual void Delete() = 0;
|
||||||
|
|
||||||
|
virtual void Find() = 0;
|
||||||
|
|
||||||
|
virtual void Replace() = 0;
|
||||||
|
|
||||||
|
virtual void Goto() = 0;
|
||||||
|
|
||||||
|
virtual void Indent() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
unsigned int SnesToPc(unsigned int addr);
|
unsigned int SnesToPc(unsigned int addr);
|
||||||
int AddressFromBytes(uint8_t addr1, uint8_t addr2, uint8_t addr3);
|
int AddressFromBytes(uint8_t addr1, uint8_t addr2, uint8_t addr3);
|
||||||
int HexToDec(char *input, int length);
|
int HexToDec(char *input, int length);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
#include "app/core/common.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "rom.h"
|
#include "rom.h"
|
||||||
@@ -11,7 +12,7 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
class DungeonEditor {
|
class DungeonEditor : public SharedROM {
|
||||||
public:
|
public:
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ constexpr ImGuiWindowFlags kMainEditorFlags =
|
|||||||
void NewMasterFrame() {
|
void NewMasterFrame() {
|
||||||
const ImGuiIO &io = ImGui::GetIO();
|
const ImGuiIO &io = ImGui::GetIO();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0));
|
ImGui::SetNextWindowPos(gui::kZeroPos);
|
||||||
ImVec2 dimensions(io.DisplaySize.x, io.DisplaySize.y);
|
ImVec2 dimensions(io.DisplaySize.x, io.DisplaySize.y);
|
||||||
ImGui::SetNextWindowSize(dimensions, ImGuiCond_Always);
|
ImGui::SetNextWindowSize(dimensions, ImGuiCond_Always);
|
||||||
|
|
||||||
@@ -104,20 +104,18 @@ void MasterEditor::DrawStatusPopup() {
|
|||||||
prev_status_ = status_;
|
prev_status_ = status_;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_status_) {
|
if (show_status_ && (BeginCentered("StatusWindow"))) {
|
||||||
if (BeginCentered("StatusWindow")) {
|
ImGui::Text("%s", prev_status_.ToString().c_str());
|
||||||
ImGui::Text("%s", prev_status_.ToString().c_str());
|
ImGui::Spacing();
|
||||||
ImGui::Spacing();
|
ImGui::NextColumn();
|
||||||
ImGui::NextColumn();
|
ImGui::Columns(1);
|
||||||
ImGui::Columns(1);
|
ImGui::Separator();
|
||||||
ImGui::Separator();
|
ImGui::NewLine();
|
||||||
ImGui::NewLine();
|
ImGui::SameLine(270);
|
||||||
ImGui::SameLine(270);
|
if (ImGui::Button("OK", gui::kDefaultModalSize)) {
|
||||||
if (ImGui::Button("OK", ImVec2(200, 0))) {
|
show_status_ = false;
|
||||||
show_status_ = false;
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +129,7 @@ void MasterEditor::DrawAboutPopup() {
|
|||||||
ImGui::Text("Special Thanks: Zarby89, JaredBrian");
|
ImGui::Text("Special Thanks: Zarby89, JaredBrian");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::Button("Close", ImVec2(200, 0))) {
|
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
||||||
about_ = false;
|
about_ = false;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
@@ -146,7 +144,7 @@ void MasterEditor::DrawInfoPopup() {
|
|||||||
ImGui::Text("Title: %s", rom_.GetTitle());
|
ImGui::Text("Title: %s", rom_.GetTitle());
|
||||||
ImGui::Text("ROM Size: %ld", rom_.size());
|
ImGui::Text("ROM Size: %ld", rom_.size());
|
||||||
|
|
||||||
if (ImGui::Button("Close", ImVec2(200, 0))) {
|
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
||||||
rom_info_ = false;
|
rom_info_ = false;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
@@ -188,10 +186,10 @@ void MasterEditor::DrawFileMenu() {
|
|||||||
static std::string save_as_filename = "";
|
static std::string save_as_filename = "";
|
||||||
ImGui::Begin("Save As..", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
ImGui::Begin("Save As..", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
ImGui::InputText("Filename", &save_as_filename);
|
ImGui::InputText("Filename", &save_as_filename);
|
||||||
if (ImGui::Button("Save", ImVec2(200, 0))) {
|
if (ImGui::Button("Save", gui::kDefaultModalSize)) {
|
||||||
status_ = rom_.SaveToFile(backup_rom_, save_as_filename);
|
status_ = rom_.SaveToFile(backup_rom_, save_as_filename);
|
||||||
}
|
}
|
||||||
if (ImGui::Button("Cancel", ImVec2(200, 0))) {
|
if (ImGui::Button("Cancel", gui::kDefaultModalSize)) {
|
||||||
save_as_menu = false;
|
save_as_menu = false;
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@@ -242,7 +240,7 @@ void MasterEditor::DrawViewMenu() {
|
|||||||
|
|
||||||
if (show_palette_editor) {
|
if (show_palette_editor) {
|
||||||
ImGui::Begin("Palette Editor", &show_palette_editor);
|
ImGui::Begin("Palette Editor", &show_palette_editor);
|
||||||
palette_editor_.Update();
|
status_ = palette_editor_.Update();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +311,7 @@ void MasterEditor::DrawDungeonEditor() {
|
|||||||
|
|
||||||
void MasterEditor::DrawGraphicsEditor() {
|
void MasterEditor::DrawGraphicsEditor() {
|
||||||
TAB_ITEM("Graphics")
|
TAB_ITEM("Graphics")
|
||||||
graphics_editor_.Update();
|
status_ = graphics_editor_.Update();
|
||||||
END_TAB_ITEM()
|
END_TAB_ITEM()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/overworld.h"
|
#include "app/zelda3/overworld.h"
|
||||||
|
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
@@ -41,7 +40,7 @@ static constexpr absl::string_view kOverworldSettingsColumnNames[] = {
|
|||||||
"##1stCol", "##gfxCol", "##palCol", "##sprgfxCol",
|
"##1stCol", "##gfxCol", "##palCol", "##sprgfxCol",
|
||||||
"##sprpalCol", "##msgidCol", "##2ndCol"};
|
"##sprpalCol", "##msgidCol", "##2ndCol"};
|
||||||
|
|
||||||
class OverworldEditor {
|
class OverworldEditor : public SharedROM {
|
||||||
public:
|
public:
|
||||||
absl::Status Update();
|
absl::Status Update();
|
||||||
absl::Status Undo() const { return absl::UnimplementedError("Undo"); }
|
absl::Status Undo() const { return absl::UnimplementedError("Undo"); }
|
||||||
@@ -49,7 +48,10 @@ class OverworldEditor {
|
|||||||
absl::Status Cut() const { return absl::UnimplementedError("Cut"); }
|
absl::Status Cut() const { return absl::UnimplementedError("Cut"); }
|
||||||
absl::Status Copy() const { return absl::UnimplementedError("Copy"); }
|
absl::Status Copy() const { return absl::UnimplementedError("Copy"); }
|
||||||
absl::Status Paste() const { return absl::UnimplementedError("Paste"); }
|
absl::Status Paste() const { return absl::UnimplementedError("Paste"); }
|
||||||
void SetupROM(ROM &rom) { rom_ = rom; }
|
void SetupROM(ROM &rom) {
|
||||||
|
rom_ = rom;
|
||||||
|
shared_rom_ = std::make_shared<ROM>(rom_);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
absl::Status DrawToolset();
|
absl::Status DrawToolset();
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
|
constexpr ImVec2 kDefaultModalSize = ImVec2(200, 0);
|
||||||
|
constexpr ImVec2 kZeroPos = ImVec2(0, 0);
|
||||||
|
|
||||||
IMGUI_API bool InputHex(const char* label, int* data);
|
IMGUI_API bool InputHex(const char* label, int* data);
|
||||||
IMGUI_API bool InputHexShort(const char* label, int* data);
|
IMGUI_API bool InputHexShort(const char* label, int* data);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "widgets.h"
|
#include "widgets.h"
|
||||||
|
|
||||||
#include <ImGuiColorTextEdit/TextEditor.h>
|
#include <ImGuiColorTextEdit/TextEditor.h>
|
||||||
|
#include <imgui_memory_editor.h>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
|
|||||||
@@ -89,9 +89,8 @@ const std::map<std::string, uint32_t> paletteGroupBaseAddresses = {
|
|||||||
{"sprites_aux2", core::spritePalettesAux2},
|
{"sprites_aux2", core::spritePalettesAux2},
|
||||||
{"sprites_aux3", core::spritePalettesAux3},
|
{"sprites_aux3", core::spritePalettesAux3},
|
||||||
{"dungeon_main", core::dungeonMainPalettes},
|
{"dungeon_main", core::dungeonMainPalettes},
|
||||||
{"grass", core::hardcodedGrassLW}, // Assuming LW is the first color
|
{"grass", core::hardcodedGrassLW},
|
||||||
{"3d_object",
|
{"3d_object", core::triforcePalette},
|
||||||
core::triforcePalette}, // Assuming triforcePalette is the first palette
|
|
||||||
{"ow_mini_map", core::overworldMiniMapPalettes},
|
{"ow_mini_map", core::overworldMiniMapPalettes},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -214,6 +213,15 @@ class ROM {
|
|||||||
std::unordered_map<std::string, gfx::PaletteGroup> palette_groups_;
|
std::unordered_map<std::string, gfx::PaletteGroup> palette_groups_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SharedROM {
|
||||||
|
public:
|
||||||
|
SharedROM() = default;
|
||||||
|
virtual ~SharedROM() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<ROM> shared_rom_;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class DungeonDestination {
|
|||||||
|
|
||||||
// int RealY() { return AssociatedObject ? AssociatedObject->RealY : 0; }
|
// int RealY() { return AssociatedObject ? AssociatedObject->RealY : 0; }
|
||||||
|
|
||||||
// void Reset() { AssociatedObject = nullptr; }
|
|
||||||
|
|
||||||
std::string ToString() {
|
std::string ToString() {
|
||||||
return std::to_string(Index) + ": To " + std::to_string(Target);
|
return std::to_string(Index) + ": To " + std::to_string(Target);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user