Refactor OverworldEditor
This commit is contained in:
@@ -6,11 +6,13 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "absl/container/flat_hash_map.h"
|
#include "absl/container/flat_hash_map.h"
|
||||||
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/zelda3/overworld.h"
|
#include "app/zelda3/overworld.h"
|
||||||
|
#include "gui/canvas.h"
|
||||||
#include "gui/icons.h"
|
#include "gui/icons.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,13 +36,15 @@ namespace editor {
|
|||||||
|
|
||||||
void OverworldEditor::SetupROM(ROM &rom) { rom_ = rom; }
|
void OverworldEditor::SetupROM(ROM &rom) { rom_ = rom; }
|
||||||
|
|
||||||
void OverworldEditor::Update() {
|
absl::Status OverworldEditor::Update() {
|
||||||
if (rom_.isLoaded() && !all_gfx_loaded_) {
|
if (rom_.isLoaded() && !all_gfx_loaded_) {
|
||||||
LoadGraphics();
|
LoadGraphics();
|
||||||
all_gfx_loaded_ = true;
|
all_gfx_loaded_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawToolset();
|
auto toolset_status = DrawToolset();
|
||||||
|
if (!toolset_status.ok()) return toolset_status;
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::BeginTable("#owEditTable", 2, ow_edit_flags, ImVec2(0, 0))) {
|
if (ImGui::BeginTable("#owEditTable", 2, ow_edit_flags, ImVec2(0, 0))) {
|
||||||
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
|
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
|
||||||
@@ -54,72 +58,56 @@ void OverworldEditor::Update() {
|
|||||||
DrawTileSelector();
|
DrawTileSelector();
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldEditor::DrawToolset() {
|
absl::Status OverworldEditor::DrawToolset() {
|
||||||
if (ImGui::BeginTable("Toolset", 17, toolset_table_flags, ImVec2(0, 0))) {
|
if (ImGui::BeginTable("OWToolset", 17, toolset_table_flags, ImVec2(0, 0))) {
|
||||||
ImGui::TableSetupColumn("#undoTool");
|
for (const auto &name : kToolsetColumnNames)
|
||||||
ImGui::TableSetupColumn("#redoTool");
|
ImGui::TableSetupColumn(name.data());
|
||||||
ImGui::TableSetupColumn("#drawTool");
|
|
||||||
ImGui::TableSetupColumn("#separator2");
|
|
||||||
ImGui::TableSetupColumn("#zoomOutTool");
|
|
||||||
ImGui::TableSetupColumn("#zoomInTool");
|
|
||||||
ImGui::TableSetupColumn("#separator");
|
|
||||||
ImGui::TableSetupColumn("#history");
|
|
||||||
ImGui::TableSetupColumn("#entranceTool");
|
|
||||||
ImGui::TableSetupColumn("#exitTool");
|
|
||||||
ImGui::TableSetupColumn("#itemTool");
|
|
||||||
ImGui::TableSetupColumn("#spriteTool");
|
|
||||||
ImGui::TableSetupColumn("#transportTool");
|
|
||||||
ImGui::TableSetupColumn("#musicTool");
|
|
||||||
ImGui::TableSetupColumn("#separator3");
|
|
||||||
ImGui::TableSetupColumn("#reloadTool");
|
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_UNDO);
|
ImGui::Button(ICON_MD_UNDO);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_REDO);
|
ImGui::Button(ICON_MD_REDO);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text(ICON_MD_MORE_VERT);
|
ImGui::Text(ICON_MD_MORE_VERT);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_ZOOM_OUT);
|
ImGui::Button(ICON_MD_ZOOM_OUT);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_ZOOM_IN);
|
ImGui::Button(ICON_MD_ZOOM_IN);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text(ICON_MD_MORE_VERT);
|
ImGui::Text(ICON_MD_MORE_VERT);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_DRAW);
|
ImGui::Button(ICON_MD_DRAW);
|
||||||
|
// Entrances
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_DOOR_FRONT);
|
ImGui::Button(ICON_MD_DOOR_FRONT);
|
||||||
|
// Exits
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_DOOR_BACK);
|
ImGui::Button(ICON_MD_DOOR_BACK);
|
||||||
|
// Items
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_GRASS);
|
ImGui::Button(ICON_MD_GRASS);
|
||||||
|
// Sprites
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_PEST_CONTROL_RODENT);
|
ImGui::Button(ICON_MD_PEST_CONTROL_RODENT);
|
||||||
|
// Transports
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_ADD_LOCATION);
|
ImGui::Button(ICON_MD_ADD_LOCATION);
|
||||||
|
// Music
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Button(ICON_MD_MUSIC_NOTE);
|
ImGui::Button(ICON_MD_MUSIC_NOTE);
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text(ICON_MD_MORE_VERT);
|
ImGui::Text(ICON_MD_MORE_VERT);
|
||||||
|
// Load Overworld
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (ImGui::Button(ICON_MD_UPDATE)) {
|
if (ImGui::Button(ICON_MD_UPDATE)) {
|
||||||
overworld_.Load(rom_, tile16_blockset_bmp_.GetData());
|
auto ow_status = overworld_.Load(rom_, tile16_blockset_bmp_.GetData());
|
||||||
|
if (!ow_status.ok()) return ow_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
@@ -138,6 +126,7 @@ void OverworldEditor::DrawToolset() {
|
|||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldEditor::DrawOverworldMapSettings() {
|
void OverworldEditor::DrawOverworldMapSettings() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "absl/container/flat_hash_map.h"
|
#include "absl/container/flat_hash_map.h"
|
||||||
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
@@ -26,13 +27,19 @@ static constexpr unsigned int kNumSheetsToLoad = 223;
|
|||||||
static constexpr unsigned int kTile8DisplayHeight = 64;
|
static constexpr unsigned int kTile8DisplayHeight = 64;
|
||||||
static constexpr float kInputFieldSize = 30.f;
|
static constexpr float kInputFieldSize = 30.f;
|
||||||
|
|
||||||
|
static constexpr absl::string_view kToolsetColumnNames[] = {
|
||||||
|
"#undoTool", "#redoTool", "#drawTool", "#separator2",
|
||||||
|
"#zoomOutTool", "#zoomInTool", "#separator", "#history",
|
||||||
|
"#entranceTool", "#exitTool", "#itemTool", "#spriteTool",
|
||||||
|
"#transportTool", "#musicTool", "#separator3", "#reloadTool"};
|
||||||
|
|
||||||
class OverworldEditor {
|
class OverworldEditor {
|
||||||
public:
|
public:
|
||||||
void SetupROM(ROM &rom);
|
void SetupROM(ROM &rom);
|
||||||
void Update();
|
absl::Status Update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DrawToolset();
|
absl::Status DrawToolset();
|
||||||
void DrawOverworldMapSettings();
|
void DrawOverworldMapSettings();
|
||||||
void DrawOverworldCanvas();
|
void DrawOverworldCanvas();
|
||||||
void DrawTileSelector();
|
void DrawTileSelector();
|
||||||
|
|||||||
Reference in New Issue
Block a user