add mosaic editor user interface
This commit is contained in:
@@ -102,6 +102,7 @@ void MasterEditor::DrawFileDialog() {
|
||||
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
status_ = rom_.LoadFromFile(filePathName);
|
||||
overworld_editor_.SetupROM(rom_);
|
||||
screen_editor_.SetupROM(rom_);
|
||||
}
|
||||
ImGuiFileDialog::Instance()->Close();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "app/asm/script.h"
|
||||
#include "app/core/common.h"
|
||||
@@ -16,6 +17,7 @@
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/input.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -35,17 +37,60 @@ void ScreenEditor::Update() {
|
||||
END_TAB_BAR()
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawWorldGrid(int world, int h, int w) {
|
||||
const float time = (float)ImGui::GetTime();
|
||||
|
||||
int i = 0;
|
||||
if (world == 1) {
|
||||
i = 64;
|
||||
} else if (world == 2) {
|
||||
i = 128;
|
||||
}
|
||||
for (int y = 0; y < h; y++)
|
||||
for (int x = 0; x < w; x++) {
|
||||
if (x > 0) ImGui::SameLine();
|
||||
ImGui::PushID(y * 4 + x);
|
||||
std::string label = absl::StrCat(" #", absl::StrFormat("%x", i));
|
||||
if (ImGui::Selectable(label.c_str(), mosaic_tiles_[i] != 0, 0,
|
||||
ImVec2(35, 25))) {
|
||||
mosaic_tiles_[i] ^= 1;
|
||||
}
|
||||
ImGui::PopID();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawMosaicEditor() {
|
||||
TAB_ITEM("Mosaic Transitions")
|
||||
if (ImGui::Button("GenerateMosaicChangeAssembly")) {
|
||||
auto mosaic = mosaic_script_.GenerateMosaicChangeAssembly(mosaic_tiles_);
|
||||
|
||||
if (ImGui::BeginTable("Worlds", 3, ImGuiTableFlags_Borders)) {
|
||||
ImGui::TableSetupColumn("Light World");
|
||||
ImGui::TableSetupColumn("Dark World");
|
||||
ImGui::TableSetupColumn("Special World");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
DrawWorldGrid(0);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
DrawWorldGrid(1);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
DrawWorldGrid(2, 4);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
gui::InputHex("Routine Location", &overworldCustomMosaicASM);
|
||||
|
||||
if (ImGui::Button("Generate Mosaic Assembly")) {
|
||||
auto mosaic = mosaic_script_.GenerateMosaicChangeAssembly(
|
||||
rom_, mosaic_tiles_, overworldCustomMosaicASM);
|
||||
if (!mosaic.ok()) {
|
||||
std::cout << "Failed to generate mosaic change assembly";
|
||||
} else {
|
||||
std::cout << "Successfully generated mosaic change assembly";
|
||||
std::cout << mosaic.value();
|
||||
std::cout << mosaic;
|
||||
}
|
||||
}
|
||||
|
||||
END_TAB_ITEM()
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "app/core/constants.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/screen.h"
|
||||
#include "gui/canvas.h"
|
||||
|
||||
@@ -17,9 +18,12 @@ namespace app {
|
||||
namespace editor {
|
||||
|
||||
using MosaicArray = std::array<int, core::kNumOverworldMaps>;
|
||||
static int overworldCustomMosaicASM = 0x1301D0;
|
||||
static int overworldCustomMosaicArray = 0x1301F0;
|
||||
|
||||
class ScreenEditor {
|
||||
public:
|
||||
void SetupROM(ROM &rom) { rom_ = rom; }
|
||||
ScreenEditor();
|
||||
void Update();
|
||||
|
||||
@@ -34,8 +38,11 @@ class ScreenEditor {
|
||||
|
||||
void DrawCanvas();
|
||||
void DrawToolset();
|
||||
void DrawWorldGrid(int world, int h = 8, int w = 8);
|
||||
|
||||
std::array<int, core::kNumOverworldMaps> mosaic_tiles_;
|
||||
char mosaic_tiles_[core::kNumOverworldMaps];
|
||||
|
||||
ROM rom_;
|
||||
snes_asm::Script mosaic_script_;
|
||||
zelda3::Screen current_screen_;
|
||||
gui::Canvas screen_canvas_;
|
||||
|
||||
Reference in New Issue
Block a user