Refactor assembly and overworld editor code for improved readability and performance

- Updated namespace usage to yaze::editor for consistency.
- Replaced string search methods with contains and ranges::find for better clarity and performance.
- Simplified Load function in AssemblyEditor for conciseness.
- Enhanced OverworldEditor by consolidating GUI element bindings and improving input handling.
- Refactored toolset drawing logic to streamline the editor interface and improve user experience.
This commit is contained in:
scawful
2025-05-26 13:54:58 -04:00
parent 3c734207be
commit 006624c0d8
5 changed files with 200 additions and 214 deletions

View File

@@ -9,8 +9,7 @@
#include "app/gui/icons.h" #include "app/gui/icons.h"
#include "app/gui/modules/text_editor.h" #include "app/gui/modules/text_editor.h"
namespace yaze { namespace yaze::editor {
namespace editor {
using core::FileDialogWrapper; using core::FileDialogWrapper;
@@ -22,15 +21,14 @@ std::vector<std::string> RemoveIgnoredFiles(
std::vector<std::string> filtered_files; std::vector<std::string> filtered_files;
for (const auto& file : files) { for (const auto& file : files) {
// Remove subdirectory files // Remove subdirectory files
if (file.find('/') != std::string::npos) { if (file.contains('/')) {
continue; continue;
} }
// Make sure the file has an extension // Make sure the file has an extension
if (file.find('.') == std::string::npos) { if (!file.contains('.')) {
continue; continue;
} }
if (std::find(ignored_files.begin(), ignored_files.end(), file) == if (std::ranges::find(ignored_files, file) == ignored_files.end()) {
ignored_files.end()) {
filtered_files.push_back(file); filtered_files.push_back(file);
} }
} }
@@ -68,15 +66,14 @@ FolderItem LoadFolder(const std::string& folder) {
auto folder_files = FileDialogWrapper::GetFilesInFolder(full_folder); auto folder_files = FileDialogWrapper::GetFilesInFolder(full_folder);
for (const auto& files : folder_files) { for (const auto& files : folder_files) {
// Remove subdirectory files // Remove subdirectory files
if (files.find('/') != std::string::npos) { if (files.contains('/')) {
continue; continue;
} }
// Make sure the file has an extension // Make sure the file has an extension
if (files.find('.') == std::string::npos) { if (!files.contains('.')) {
continue; continue;
} }
if (std::find(ignored_files.begin(), ignored_files.end(), files) != if (std::ranges::find(ignored_files, files) != ignored_files.end()) {
ignored_files.end()) {
continue; continue;
} }
folder_item.files.push_back(files); folder_item.files.push_back(files);
@@ -101,9 +98,7 @@ void AssemblyEditor::Initialize() {
// Set the language definition // Set the language definition
} }
absl::Status AssemblyEditor::Load() { absl::Status AssemblyEditor::Load() { return absl::OkStatus(); }
return absl::OkStatus();
}
void AssemblyEditor::OpenFolder(const std::string& folder_path) { void AssemblyEditor::OpenFolder(const std::string& folder_path) {
current_folder_ = LoadFolder(folder_path); current_folder_ = LoadFolder(folder_path);
@@ -131,7 +126,6 @@ void AssemblyEditor::Update(bool& is_loaded) {
} }
void AssemblyEditor::InlineUpdate() { void AssemblyEditor::InlineUpdate() {
ChangeActiveFile("assets/asm/template_song.asm");
auto cpos = text_editor_.GetCursorPosition(); auto cpos = text_editor_.GetCursorPosition();
SetEditorText(); SetEditorText();
ImGui::Text("%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1, ImGui::Text("%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
@@ -237,8 +231,8 @@ void AssemblyEditor::DrawFileTabView() {
if (ImGui::BeginTabBar("AssemblyFileTabBar", ImGuiTabBarFlags_None)) { if (ImGui::BeginTabBar("AssemblyFileTabBar", ImGuiTabBarFlags_None)) {
if (ImGui::TabItemButton(ICON_MD_ADD, ImGuiTabItemFlags_None)) { if (ImGui::TabItemButton(ICON_MD_ADD, ImGuiTabItemFlags_None)) {
if (std::find(active_files_.begin(), active_files_.end(), if (std::ranges::find(active_files_, current_file_id_) !=
current_file_id_) != active_files_.end()) { active_files_.end()) {
// Room is already open // Room is already open
next_tab_id++; next_tab_id++;
} }
@@ -366,5 +360,4 @@ absl::Status AssemblyEditor::Redo() {
absl::Status AssemblyEditor::Update() { return absl::OkStatus(); } absl::Status AssemblyEditor::Update() { return absl::OkStatus(); }
} // namespace editor } // namespace yaze::editor
} // namespace yaze

View File

@@ -55,10 +55,7 @@ class AssemblyEditor : public Editor {
void OpenFolder(const std::string &folder_path); void OpenFolder(const std::string &folder_path);
// Set the ROM pointer
void set_rom(Rom* rom) { rom_ = rom; } void set_rom(Rom* rom) { rom_ = rom; }
// Get the ROM pointer
Rom* rom() const { return rom_; } Rom* rom() const { return rom_; }
private: private:

View File

@@ -30,87 +30,43 @@
#include "util/log.h" #include "util/log.h"
#include "util/macro.h" #include "util/macro.h"
namespace yaze { namespace yaze::editor {
namespace editor {
using core::Renderer; using core::Renderer;
using namespace ImGui; using namespace ImGui;
constexpr int kTile16Size = 0x10; constexpr int kTile16Size = 0x10;
constexpr float kInputFieldSize = 30.f;
void OverworldEditor::Initialize() { void OverworldEditor::Initialize() {
// Load zeml string from layouts/overworld.zeml layout_node_ = gui::zeml::Parse(gui::zeml::LoadFile("overworld.zeml"));
std::string layout = gui::zeml::LoadFile("overworld.zeml");
// Parse the zeml string into a Node object
layout_node_ = gui::zeml::Parse(layout);
gui::zeml::Bind(&*layout_node_.GetNode("OverworldCanvas"), gui::zeml::Bind(std::to_address(layout_node_.GetNode("OverworldCanvas")),
[this]() { DrawOverworldCanvas(); }); [this]() { DrawOverworldCanvas(); });
gui::zeml::Bind(&*layout_node_.GetNode("OverworldTileSelector"), gui::zeml::Bind(
std::to_address(layout_node_.GetNode("OverworldTileSelector")),
[this]() { status_ = DrawTileSelector(); }); [this]() { status_ = DrawTileSelector(); });
gui::zeml::Bind(&*layout_node_.GetNode("OwUsageStats"), [this]() { gui::zeml::Bind(std::to_address(layout_node_.GetNode("OwUsageStats")),
[this]() {
if (rom_->is_loaded()) { if (rom_->is_loaded()) {
status_ = UpdateUsageStats(); status_ = UpdateUsageStats();
} }
}); });
gui::zeml::Bind(&*layout_node_.GetNode("owToolset"), gui::zeml::Bind(std::to_address(layout_node_.GetNode("owToolset")),
[this]() { DrawToolset(); }); [this]() { DrawToolset(); });
gui::zeml::Bind(&*layout_node_.GetNode("OwTile16Editor"), [this]() { gui::zeml::Bind(std::to_address(layout_node_.GetNode("OwTile16Editor")),
[this]() {
if (rom_->is_loaded()) { if (rom_->is_loaded()) {
status_ = tile16_editor_.Update(); status_ = tile16_editor_.Update();
} }
}); });
gui::zeml::Bind(&*layout_node_.GetNode("OwGfxGroupEditor"), [this]() { gui::zeml::Bind(std::to_address(layout_node_.GetNode("OwGfxGroupEditor")),
[this]() {
if (rom_->is_loaded()) { if (rom_->is_loaded()) {
status_ = gfx_group_editor_.Update(); status_ = gfx_group_editor_.Update();
} }
}); });
}
absl::Status OverworldEditor::Load() {
RETURN_IF_ERROR(LoadGraphics());
RETURN_IF_ERROR(
tile16_editor_.Initialize(tile16_blockset_bmp_, current_gfx_bmp_,
*overworld_.mutable_all_tiles_types()));
ASSIGN_OR_RETURN(entrance_tiletypes_, zelda3::LoadEntranceTileTypes(rom_));
all_gfx_loaded_ = true;
return absl::OkStatus();
}
absl::Status OverworldEditor::Update() {
status_ = absl::OkStatus();
if (overworld_canvas_fullscreen_) {
DrawFullscreenCanvas();
}
// Draw the overworld editor layout from the ZEML file
gui::zeml::Render(layout_node_);
return status_;
}
void OverworldEditor::DrawFullscreenCanvas() {
static bool use_work_area = true;
static ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoSavedSettings;
const ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(use_work_area ? viewport->WorkPos : viewport->Pos);
ImGui::SetNextWindowSize(use_work_area ? viewport->WorkSize : viewport->Size);
if (ImGui::Begin("Fullscreen Overworld Editor", &overworld_canvas_fullscreen_,
flags)) {
// Draws the toolset for editing the Overworld.
DrawToolset();
DrawOverworldCanvas();
}
ImGui::End();
}
void OverworldEditor::DrawToolset() {
static bool show_gfx_group = false;
static bool show_properties = false;
if (toolset_table_.column_contents.empty()) {
gui::AddTableColumn(toolset_table_, "##Undo", [&]() { gui::AddTableColumn(toolset_table_, "##Undo", [&]() {
if (Button(ICON_MD_UNDO)) status_ = Undo(); if (Button(ICON_MD_UNDO)) status_ = Undo();
}); });
@@ -127,7 +83,7 @@ void OverworldEditor::DrawToolset() {
gui::AddTableColumn(toolset_table_, "##Fullscreen", [&]() { gui::AddTableColumn(toolset_table_, "##Fullscreen", [&]() {
if (Button(ICON_MD_OPEN_IN_FULL)) if (Button(ICON_MD_OPEN_IN_FULL))
overworld_canvas_fullscreen_ = !overworld_canvas_fullscreen_; overworld_canvas_fullscreen_ = !overworld_canvas_fullscreen_;
HOVER_HINT("Fullscreen Canvas") HOVER_HINT("Fullscreen Canvas");
}); });
gui::AddTableColumn(toolset_table_, "##Sep2", ICON_MD_MORE_VERT); gui::AddTableColumn(toolset_table_, "##Sep2", ICON_MD_MORE_VERT);
gui::AddTableColumn(toolset_table_, "##Pan", [&]() { gui::AddTableColumn(toolset_table_, "##Pan", [&]() {
@@ -144,8 +100,7 @@ void OverworldEditor::DrawToolset() {
HOVER_HINT("Draw Tile"); HOVER_HINT("Draw Tile");
}); });
gui::AddTableColumn(toolset_table_, "##Entrances", [&]() { gui::AddTableColumn(toolset_table_, "##Entrances", [&]() {
if (Selectable(ICON_MD_DOOR_FRONT, if (Selectable(ICON_MD_DOOR_FRONT, current_mode == EditingMode::ENTRANCES))
current_mode == EditingMode::ENTRANCES))
current_mode = EditingMode::ENTRANCES; current_mode = EditingMode::ENTRANCES;
HOVER_HINT("Entrances"); HOVER_HINT("Entrances");
}); });
@@ -181,7 +136,8 @@ void OverworldEditor::DrawToolset() {
HOVER_HINT("Tile16 Editor"); HOVER_HINT("Tile16 Editor");
}); });
gui::AddTableColumn(toolset_table_, "##GfxGroupEditor", [&]() { gui::AddTableColumn(toolset_table_, "##GfxGroupEditor", [&]() {
if (Button(ICON_MD_TABLE_CHART)) show_gfx_group = !show_gfx_group; if (Button(ICON_MD_TABLE_CHART))
show_gfx_group_editor_ = !show_gfx_group_editor_;
HOVER_HINT("Gfx Group Editor"); HOVER_HINT("Gfx Group Editor");
}); });
gui::AddTableColumn(toolset_table_, "##sep3", ICON_MD_MORE_VERT); gui::AddTableColumn(toolset_table_, "##sep3", ICON_MD_MORE_VERT);
@@ -202,12 +158,47 @@ void OverworldEditor::DrawToolset() {
status_ = DisplayPalette(palette_, overworld_.is_loaded()); status_ = DisplayPalette(palette_, overworld_.is_loaded());
}); });
gui::AddTableColumn(toolset_table_, "##Sep4", ICON_MD_MORE_VERT); gui::AddTableColumn(toolset_table_, "##Sep4", ICON_MD_MORE_VERT);
gui::AddTableColumn(toolset_table_, "##Properties", gui::AddTableColumn(toolset_table_, "##Properties", [&]() {
[&]() { Checkbox("Properties", &show_properties); }); Checkbox("Properties", &show_properties_editor_);
});
}
} else { absl::Status OverworldEditor::Load() {
gui::DrawTable(toolset_table_); RETURN_IF_ERROR(LoadGraphics());
RETURN_IF_ERROR(
tile16_editor_.Initialize(tile16_blockset_bmp_, current_gfx_bmp_,
*overworld_.mutable_all_tiles_types()));
ASSIGN_OR_RETURN(entrance_tiletypes_, zelda3::LoadEntranceTileTypes(rom_));
all_gfx_loaded_ = true;
return absl::OkStatus();
}
absl::Status OverworldEditor::Update() {
status_ = absl::OkStatus();
if (overworld_canvas_fullscreen_) DrawFullscreenCanvas();
gui::zeml::Render(layout_node_);
return status_;
}
void OverworldEditor::DrawFullscreenCanvas() {
static bool use_work_area = true;
static ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoSavedSettings;
const ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(use_work_area ? viewport->WorkPos : viewport->Pos);
ImGui::SetNextWindowSize(use_work_area ? viewport->WorkSize : viewport->Size);
if (ImGui::Begin("Fullscreen Overworld Editor", &overworld_canvas_fullscreen_,
flags)) {
// Draws the toolset for editing the Overworld.
DrawToolset();
DrawOverworldCanvas();
} }
ImGui::End();
}
void OverworldEditor::DrawToolset() {
gui::DrawTable(toolset_table_);
if (show_tile16_editor_) { if (show_tile16_editor_) {
ImGui::Begin("Tile16 Editor", &show_tile16_editor_, ImGui::Begin("Tile16 Editor", &show_tile16_editor_,
@@ -216,36 +207,38 @@ void OverworldEditor::DrawToolset() {
ImGui::End(); ImGui::End();
} }
if (show_gfx_group) { if (show_gfx_group_editor_) {
gui::BeginWindowWithDisplaySettings("Gfx Group Editor", &show_gfx_group); gui::BeginWindowWithDisplaySettings("Gfx Group Editor",
&show_gfx_group_editor_);
status_ = gfx_group_editor_.Update(); status_ = gfx_group_editor_.Update();
gui::EndWindowWithDisplaySettings(); gui::EndWindowWithDisplaySettings();
} }
if (show_properties) { if (show_properties_editor_) {
ImGui::Begin("Properties", &show_properties); ImGui::Begin("Properties", &show_properties_editor_);
DrawOverworldProperties(); DrawOverworldProperties();
ImGui::End(); ImGui::End();
} }
// TODO: Customizable shortcuts for the Overworld Editor // TODO: Customizable shortcuts for the Overworld Editor
if (!ImGui::IsAnyItemActive()) { if (!ImGui::IsAnyItemActive()) {
using enum EditingMode;
if (ImGui::IsKeyDown(ImGuiKey_1)) { if (ImGui::IsKeyDown(ImGuiKey_1)) {
current_mode = EditingMode::PAN; current_mode = PAN;
} else if (ImGui::IsKeyDown(ImGuiKey_2)) { } else if (ImGui::IsKeyDown(ImGuiKey_2)) {
current_mode = EditingMode::DRAW_TILE; current_mode = DRAW_TILE;
} else if (ImGui::IsKeyDown(ImGuiKey_3)) { } else if (ImGui::IsKeyDown(ImGuiKey_3)) {
current_mode = EditingMode::ENTRANCES; current_mode = ENTRANCES;
} else if (ImGui::IsKeyDown(ImGuiKey_4)) { } else if (ImGui::IsKeyDown(ImGuiKey_4)) {
current_mode = EditingMode::EXITS; current_mode = EXITS;
} else if (ImGui::IsKeyDown(ImGuiKey_5)) { } else if (ImGui::IsKeyDown(ImGuiKey_5)) {
current_mode = EditingMode::ITEMS; current_mode = ITEMS;
} else if (ImGui::IsKeyDown(ImGuiKey_6)) { } else if (ImGui::IsKeyDown(ImGuiKey_6)) {
current_mode = EditingMode::SPRITES; current_mode = SPRITES;
} else if (ImGui::IsKeyDown(ImGuiKey_7)) { } else if (ImGui::IsKeyDown(ImGuiKey_7)) {
current_mode = EditingMode::TRANSPORTS; current_mode = TRANSPORTS;
} else if (ImGui::IsKeyDown(ImGuiKey_8)) { } else if (ImGui::IsKeyDown(ImGuiKey_8)) {
current_mode = EditingMode::MUSIC; current_mode = MUSIC;
} }
} }
} }
@@ -325,7 +318,7 @@ void OverworldEditor::DrawOverworldMapSettings() {
} }
void OverworldEditor::DrawCustomOverworldMapSettings() { void OverworldEditor::DrawCustomOverworldMapSettings() {
if (BeginTable(kOWMapTable.data(), 15, kOWMapFlags, ImVec2(0, 0), -1)) { if (BeginTable(kOWMapTable.data(), 8, kOWMapFlags, ImVec2(0, 0), -1)) {
for (const auto &name : kMapSettingsColumnNames) for (const auto &name : kMapSettingsColumnNames)
ImGui::TableSetupColumn(name); ImGui::TableSetupColumn(name);
@@ -333,11 +326,16 @@ void OverworldEditor::DrawCustomOverworldMapSettings() {
ImGui::SetNextItemWidth(120.f); ImGui::SetNextItemWidth(120.f);
ImGui::Combo("##world", &current_world_, kWorldList.data(), 3); ImGui::Combo("##world", &current_world_, kWorldList.data(), 3);
TableNextColumn();
if (ImGui::Button("Tile Graphics", ImVec2(120, 0))) {
ImGui::OpenPopup("TileGraphicsPopup");
}
if (ImGui::BeginPopup("TileGraphicsPopup")) {
static const std::array<std::string, 8> kCustomMapSettingsColumnNames = { static const std::array<std::string, 8> kCustomMapSettingsColumnNames = {
"TileGfx0", "TileGfx1", "TileGfx2", "TileGfx3", "TileGfx0", "TileGfx1", "TileGfx2", "TileGfx3",
"TileGfx4", "TileGfx5", "TileGfx6", "TileGfx7"}; "TileGfx4", "TileGfx5", "TileGfx6", "TileGfx7"};
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {
TableNextColumn();
ImGui::BeginGroup(); ImGui::BeginGroup();
if (gui::InputHexByte(kCustomMapSettingsColumnNames[i].data(), if (gui::InputHexByte(kCustomMapSettingsColumnNames[i].data(),
overworld_.mutable_overworld_map(current_map_) overworld_.mutable_overworld_map(current_map_)
@@ -348,6 +346,8 @@ void OverworldEditor::DrawCustomOverworldMapSettings() {
} }
ImGui::EndGroup(); ImGui::EndGroup();
} }
ImGui::EndPopup();
}
TableNextColumn(); TableNextColumn();
ImGui::BeginGroup(); ImGui::BeginGroup();
@@ -404,8 +404,9 @@ void OverworldEditor::DrawOverworldMaps() {
int yy = 0; int yy = 0;
for (int i = 0; i < 0x40; i++) { for (int i = 0; i < 0x40; i++) {
int world_index = i + (current_world_ * 0x40); int world_index = i + (current_world_ * 0x40);
int map_x = (xx * kOverworldMapSize * ow_map_canvas_.global_scale()); int scale = static_cast<int>(ow_map_canvas_.global_scale());
int map_y = (yy * kOverworldMapSize * ow_map_canvas_.global_scale()); int map_x = (xx * kOverworldMapSize * scale);
int map_y = (yy * kOverworldMapSize * scale);
ow_map_canvas_.DrawBitmap(maps_bmp_[world_index], map_x, map_y, ow_map_canvas_.DrawBitmap(maps_bmp_[world_index], map_x, map_y,
ow_map_canvas_.global_scale()); ow_map_canvas_.global_scale());
xx++; xx++;
@@ -463,8 +464,8 @@ void OverworldEditor::RenderUpdatedMapBitmap(
// Calculate the pixel start position based on tile index and tile size // Calculate the pixel start position based on tile index and tile size
ImVec2 start_position; ImVec2 start_position;
start_position.x = tile_index_x * kTile16Size; start_position.x = static_cast<float>(tile_index_x * kTile16Size);
start_position.y = tile_index_y * kTile16Size; start_position.y = static_cast<float>(tile_index_y * kTile16Size);
// Update the bitmap's pixel data based on the start_position and tile_data // Update the bitmap's pixel data based on the start_position and tile_data
gfx::Bitmap &current_bitmap = maps_bmp_[current_map_]; gfx::Bitmap &current_bitmap = maps_bmp_[current_map_];
@@ -482,14 +483,13 @@ void OverworldEditor::RenderUpdatedMapBitmap(
void OverworldEditor::CheckForOverworldEdits() { void OverworldEditor::CheckForOverworldEdits() {
CheckForSelectRectangle(); CheckForSelectRectangle();
// User has selected a tile they want to draw from the blockset. // User has selected a tile they want to draw from the blockset
// and clicked on the canvas.
if (!blockset_canvas_.points().empty() && if (!blockset_canvas_.points().empty() &&
!ow_map_canvas_.select_rect_active()) { !ow_map_canvas_.select_rect_active() &&
// Left click is pressed ow_map_canvas_.DrawTilemapPainter(tile16_blockset_, current_tile16_)) {
if (ow_map_canvas_.DrawTilemapPainter(tile16_blockset_, current_tile16_)) {
DrawOverworldEdits(); DrawOverworldEdits();
} }
}
if (ow_map_canvas_.select_rect_active()) { if (ow_map_canvas_.select_rect_active()) {
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) || if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) ||
@@ -738,14 +738,13 @@ void OverworldEditor::DrawTile8Selector() {
} }
absl::Status OverworldEditor::DrawAreaGraphics() { absl::Status OverworldEditor::DrawAreaGraphics() {
if (overworld_.is_loaded() && if (overworld_.is_loaded() && current_graphics_set_.contains(current_map_)) {
current_graphics_set_.count(current_map_) == 0) {
overworld_.set_current_map(current_map_); overworld_.set_current_map(current_map_);
palette_ = overworld_.current_area_palette(); palette_ = overworld_.current_area_palette();
gfx::Bitmap bmp; gfx::Bitmap bmp;
Renderer::Get().CreateAndRenderBitmap(0x80, kOverworldMapSize, 0x08, Renderer::Get().CreateAndRenderBitmap(0x80, kOverworldMapSize, 0x08,
overworld_.current_graphics(), overworld_.current_graphics(), bmp,
bmp, palette_); palette_);
current_graphics_set_[current_map_] = bmp; current_graphics_set_[current_map_] = bmp;
} }
@@ -1044,8 +1043,8 @@ absl::Status OverworldEditor::LoadGraphics() {
util::logf("Loading overworld tileset."); util::logf("Loading overworld tileset.");
// Create the tile16 blockset image // Create the tile16 blockset image
Renderer::Get().CreateAndRenderBitmap( Renderer::Get().CreateAndRenderBitmap(0x80, 0x2000, 0x08,
0x80, 0x2000, 0x08, overworld_.tile16_blockset_data(), overworld_.tile16_blockset_data(),
tile16_blockset_bmp_, palette_); tile16_blockset_bmp_, palette_);
map_blockset_loaded_ = true; map_blockset_loaded_ = true;
@@ -1117,7 +1116,7 @@ void OverworldEditor::RefreshChildMap(int map_index) {
void OverworldEditor::RefreshOverworldMap() { void OverworldEditor::RefreshOverworldMap() {
std::vector<std::future<void>> futures; std::vector<std::future<void>> futures;
int indices[4]; std::array<int, 4> indices = {0, 0, 0, 0};
auto refresh_map_async = [this](int map_index) { auto refresh_map_async = [this](int map_index) {
RefreshChildMap(map_index); RefreshChildMap(map_index);
@@ -1172,7 +1171,7 @@ absl::Status OverworldEditor::RefreshMapPalette() {
} }
void OverworldEditor::RefreshMapProperties() { void OverworldEditor::RefreshMapProperties() {
auto &current_ow_map = *overworld_.mutable_overworld_map(current_map_); const auto &current_ow_map = *overworld_.mutable_overworld_map(current_map_);
if (current_ow_map.is_large_map()) { if (current_ow_map.is_large_map()) {
// We need to copy the properties from the parent map to the children // We need to copy the properties from the parent map to the children
for (int i = 1; i < 4; i++) { for (int i = 1; i < 4; i++) {
@@ -1277,32 +1276,32 @@ void OverworldEditor::DrawOverworldProperties() {
} }
Text("Area Gfx LW/DW"); Text("Area Gfx LW/DW");
properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 8, 2.0f, 32, properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 32,
OverworldProperty::LW_AREA_GFX); OverworldProperty::LW_AREA_GFX);
SameLine(); SameLine();
properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 8, 2.0f, 32, properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 32,
OverworldProperty::DW_AREA_GFX); OverworldProperty::DW_AREA_GFX);
ImGui::Separator(); ImGui::Separator();
Text("Sprite Gfx LW/DW"); Text("Sprite Gfx LW/DW");
properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 8, 2.0f, 32, properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 32,
OverworldProperty::LW_SPR_GFX_PART1); OverworldProperty::LW_SPR_GFX_PART1);
SameLine(); SameLine();
properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 8, 2.0f, 32, properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 32,
OverworldProperty::DW_SPR_GFX_PART1); OverworldProperty::DW_SPR_GFX_PART1);
SameLine(); SameLine();
properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 8, 2.0f, 32, properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 32,
OverworldProperty::LW_SPR_GFX_PART2); OverworldProperty::LW_SPR_GFX_PART2);
SameLine(); SameLine();
properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 8, 2.0f, 32, properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 32,
OverworldProperty::DW_SPR_GFX_PART2); OverworldProperty::DW_SPR_GFX_PART2);
ImGui::Separator(); ImGui::Separator();
Text("Area Pal LW/DW"); Text("Area Pal LW/DW");
properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 8, 2.0f, 32, properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 32,
OverworldProperty::LW_AREA_PAL); OverworldProperty::LW_AREA_PAL);
SameLine(); SameLine();
properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 8, 2.0f, 32, properties_canvas_.UpdateInfoGrid(ImVec2(256, 256), 32,
OverworldProperty::DW_AREA_PAL); OverworldProperty::DW_AREA_PAL);
static bool show_gfx_group = false; static bool show_gfx_group = false;
@@ -1451,5 +1450,4 @@ absl::Status OverworldEditor::Clear() {
return absl::OkStatus(); return absl::OkStatus();
} }
} // namespace editor } // namespace yaze::editor
} // namespace yaze

View File

@@ -23,9 +23,7 @@ constexpr unsigned int k4BPP = 4;
constexpr unsigned int kByteSize = 3; constexpr unsigned int kByteSize = 3;
constexpr unsigned int kMessageIdSize = 5; constexpr unsigned int kMessageIdSize = 5;
constexpr unsigned int kNumSheetsToLoad = 223; constexpr unsigned int kNumSheetsToLoad = 223;
constexpr unsigned int kTile8DisplayHeight = 64;
constexpr unsigned int kOverworldMapSize = 0x200; constexpr unsigned int kOverworldMapSize = 0x200;
constexpr float kInputFieldSize = 30.f;
constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize * 8, constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize * 8,
kOverworldMapSize * 8); kOverworldMapSize * 8);
constexpr ImVec2 kCurrentGfxCanvasSize(0x100 + 1, 0x10 * 0x40 + 1); constexpr ImVec2 kCurrentGfxCanvasSize(0x100 + 1, 0x10 * 0x40 + 1);
@@ -209,6 +207,8 @@ class OverworldEditor : public Editor, public gfx::GfxContext {
bool map_blockset_loaded_ = false; bool map_blockset_loaded_ = false;
bool selected_tile_loaded_ = false; bool selected_tile_loaded_ = false;
bool show_tile16_editor_ = false; bool show_tile16_editor_ = false;
bool show_gfx_group_editor_ = false;
bool show_properties_editor_ = false;
bool overworld_canvas_fullscreen_ = false; bool overworld_canvas_fullscreen_ = false;
bool middle_mouse_dragging_ = false; bool middle_mouse_dragging_ = false;
bool is_dragging_entity_ = false; bool is_dragging_entity_ = false;

View File

@@ -35,6 +35,8 @@ absl::Status Tile16Editor::Initialize(
tile16_blockset_bmp_.SetPalette(tile16_blockset_bmp.palette()); tile16_blockset_bmp_.SetPalette(tile16_blockset_bmp.palette());
core::Renderer::Get().RenderBitmap(&tile16_blockset_bmp_); core::Renderer::Get().RenderBitmap(&tile16_blockset_bmp_);
// RETURN_IF_ERROR(LoadTile8()); // RETURN_IF_ERROR(LoadTile8());
map_blockset_loaded_ = true;
ImVector<std::string> tile16_names; ImVector<std::string> tile16_names;
for (int i = 0; i < 0x200; ++i) { for (int i = 0; i < 0x200; ++i) {
std::string str = util::HexByte(all_tiles_types_[i]); std::string str = util::HexByte(all_tiles_types_[i]);
@@ -473,8 +475,6 @@ absl::Status Tile16Editor::LoadTile8() {
Renderer::Get().RenderBitmap(&tile_bitmap); Renderer::Get().RenderBitmap(&tile_bitmap);
} }
map_blockset_loaded_ = true;
return absl::OkStatus(); return absl::OkStatus();
} }
@@ -488,8 +488,6 @@ absl::Status Tile16Editor::SetCurrentTile(int id) {
return absl::OkStatus(); return absl::OkStatus();
} }
#pragma mark - Tile16Transfer
absl::Status Tile16Editor::UpdateTile16Transfer() { absl::Status Tile16Editor::UpdateTile16Transfer() {
if (BeginTabItem("Tile16 Transfer")) { if (BeginTabItem("Tile16 Transfer")) {
if (BeginTable("#Tile16TransferTable", 2, TABLE_BORDERS_RESIZABLE, if (BeginTable("#Tile16TransferTable", 2, TABLE_BORDERS_RESIZABLE,
@@ -527,7 +525,7 @@ absl::Status Tile16Editor::UpdateTransferTileCanvas() {
// TODO: Implement tile16 transfer // TODO: Implement tile16 transfer
if (transfer_started_ && !transfer_blockset_loaded_) { if (transfer_started_ && !transfer_blockset_loaded_) {
ASSIGN_OR_RETURN(transfer_gfx_, LoadAllGraphicsData(*transfer_rom_)) ASSIGN_OR_RETURN(transfer_gfx_, LoadAllGraphicsData(*transfer_rom_));
// Load the Link to the Past overworld. // Load the Link to the Past overworld.
PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_)) PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_))