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