add mosaic checkbox to overworld editor properties

This commit is contained in:
scawful
2024-07-21 19:34:09 -04:00
parent 25bd1abb24
commit 713196a9ef
2 changed files with 131 additions and 113 deletions

View File

@@ -30,13 +30,23 @@ namespace yaze {
namespace app { namespace app {
namespace editor { namespace editor {
using ImGui::BeginChild;
using ImGui::BeginTabBar; using ImGui::BeginTabBar;
using ImGui::BeginTabItem; using ImGui::BeginTabItem;
using ImGui::BeginTable; using ImGui::BeginTable;
using ImGui::BeginTooltip;
using ImGui::Button; using ImGui::Button;
using ImGui::Checkbox; using ImGui::Checkbox;
using ImGui::EndChild;
using ImGui::EndTabBar; using ImGui::EndTabBar;
using ImGui::EndTabItem; using ImGui::EndTabItem;
using ImGui::EndTable;
using ImGui::EndTooltip;
using ImGui::IsItemHovered;
using ImGui::NewLine;
using ImGui::PopStyleColor;
using ImGui::PushStyleColor;
using ImGui::SameLine;
using ImGui::Selectable; using ImGui::Selectable;
using ImGui::Separator; using ImGui::Separator;
using ImGui::TableHeadersRow; using ImGui::TableHeadersRow;
@@ -45,7 +55,8 @@ using ImGui::TableNextRow;
using ImGui::TableSetupColumn; using ImGui::TableSetupColumn;
using ImGui::Text; using ImGui::Text;
constexpr uint16_t kOverworldMapSize = 0x200; constexpr int kTile16Size = 0x10;
constexpr int kOverworldMapSize = 0x200;
void OverworldEditor::InitializeZeml() { void OverworldEditor::InitializeZeml() {
// Load zeml string from layouts/overworld.zeml // Load zeml string from layouts/overworld.zeml
@@ -345,7 +356,6 @@ void OverworldEditor::RefreshOverworldMap() {
} }
} }
// TODO: Palette throws out of bounds error unexpectedly.
absl::Status OverworldEditor::RefreshMapPalette() { absl::Status OverworldEditor::RefreshMapPalette() {
const auto current_map_palette = const auto current_map_palette =
overworld_.overworld_map(current_map_)->current_palette(); overworld_.overworld_map(current_map_)->current_palette();
@@ -387,11 +397,11 @@ void OverworldEditor::RefreshMapProperties() {
} }
} }
// TODO: Add @JaredBrian per map mosaic feature
void OverworldEditor::DrawOverworldMapSettings() { void OverworldEditor::DrawOverworldMapSettings() {
if (BeginTable(kOWMapTable.data(), 7, kOWMapFlags, ImVec2(0, 0), -1)) { if (BeginTable(kOWMapTable.data(), 8, kOWMapFlags, ImVec2(0, 0), -1)) {
for (const auto &name : {"##1stCol", "##gfxCol", "##palCol", "##sprgfxCol", for (const auto &name :
"##sprpalCol", "##msgidCol", "##2ndCol"}) {"##1stCol", "##gfxCol", "##palCol", "##sprgfxCol", "##sprpalCol",
"##msgidCol", "##2ndCol", "##mosaic"})
ImGui::TableSetupColumn(name); ImGui::TableSetupColumn(name);
TableNextColumn(); TableNextColumn();
@@ -449,12 +459,16 @@ void OverworldEditor::DrawOverworldMapSettings() {
ImGui::SetNextItemWidth(100.f); ImGui::SetNextItemWidth(100.f);
ImGui::Combo("##World", &game_state_, kGamePartComboString.data(), 3); ImGui::Combo("##World", &game_state_, kGamePartComboString.data(), 3);
TableNextColumn();
ImGui::Checkbox(
"##mosaic",
overworld_.mutable_overworld_map(current_map_)->mutable_mosaic());
HOVER_HINT("Enable Mosaic effect for the current map");
ImGui::EndTable(); ImGui::EndTable();
} }
} }
// ----------------------------------------------------------------------------
void OverworldEditor::DrawOverworldMaps() { void OverworldEditor::DrawOverworldMaps() {
int xx = 0; int xx = 0;
int yy = 0; int yy = 0;
@@ -474,10 +488,9 @@ void OverworldEditor::DrawOverworldMaps() {
void OverworldEditor::DrawOverworldEdits() { void OverworldEditor::DrawOverworldEdits() {
// Determine which overworld map the user is currently editing. // Determine which overworld map the user is currently editing.
constexpr int small_map_size = 512;
auto mouse_position = ow_map_canvas_.drawn_tile_position(); auto mouse_position = ow_map_canvas_.drawn_tile_position();
int map_x = mouse_position.x / small_map_size; int map_x = mouse_position.x / kOverworldMapSize;
int map_y = mouse_position.y / small_map_size; int map_y = mouse_position.y / kOverworldMapSize;
current_map_ = map_x + map_y * 8; current_map_ = map_x + map_y * 8;
if (current_world_ == 1) { if (current_world_ == 1) {
current_map_ += 0x40; current_map_ += 0x40;
@@ -495,8 +508,8 @@ void OverworldEditor::DrawOverworldEdits() {
int mouse_x = mouse_position.x; int mouse_x = mouse_position.x;
int mouse_y = mouse_position.y; int mouse_y = mouse_position.y;
// Calculate the correct tile16_x and tile16_y positions // Calculate the correct tile16_x and tile16_y positions
int tile16_x = (mouse_x % small_map_size) / (small_map_size / 32); int tile16_x = (mouse_x % kOverworldMapSize) / (kOverworldMapSize / 32);
int tile16_y = (mouse_y % small_map_size) / (small_map_size / 32); int tile16_y = (mouse_y % kOverworldMapSize) / (kOverworldMapSize / 32);
// Update the overworld_.map_tiles() based on tile16 ID and current world // Update the overworld_.map_tiles() based on tile16 ID and current world
auto &selected_world = auto &selected_world =
@@ -516,8 +529,10 @@ void OverworldEditor::RenderUpdatedMapBitmap(const ImVec2 &click_position,
constexpr int tile_size = 16; // Tile size is 16x16 pixels constexpr int tile_size = 16; // Tile size is 16x16 pixels
// Calculate the tile index for x and y based on the click_position // Calculate the tile index for x and y based on the click_position
int tile_index_x = (static_cast<int>(click_position.x) % 512) / tile_size; int tile_index_x =
int tile_index_y = (static_cast<int>(click_position.y) % 512) / tile_size; (static_cast<int>(click_position.x) % kOverworldMapSize) / tile_size;
int tile_index_y =
(static_cast<int>(click_position.y) % kOverworldMapSize) / tile_size;
// 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;
@@ -635,13 +650,12 @@ void OverworldEditor::CheckForSelectRectangle() {
absl::Status OverworldEditor::CheckForCurrentMap() { absl::Status OverworldEditor::CheckForCurrentMap() {
// 4096x4096, 512x512 maps and some are larges maps 1024x1024 // 4096x4096, 512x512 maps and some are larges maps 1024x1024
auto mouse_position = ImGui::GetIO().MousePos; auto mouse_position = ImGui::GetIO().MousePos;
constexpr int small_map_size = 512;
const auto large_map_size = 1024; const auto large_map_size = 1024;
const auto canvas_zero_point = ow_map_canvas_.zero_point(); const auto canvas_zero_point = ow_map_canvas_.zero_point();
// Calculate which small map the mouse is currently over // Calculate which small map the mouse is currently over
int map_x = (mouse_position.x - canvas_zero_point.x) / small_map_size; int map_x = (mouse_position.x - canvas_zero_point.x) / kOverworldMapSize;
int map_y = (mouse_position.y - canvas_zero_point.y) / small_map_size; int map_y = (mouse_position.y - canvas_zero_point.y) / kOverworldMapSize;
// Calculate the index of the map in the `maps_bmp_` vector // Calculate the index of the map in the `maps_bmp_` vector
current_map_ = map_x + map_y * 8; current_map_ = map_x + map_y * 8;
@@ -663,13 +677,13 @@ absl::Status OverworldEditor::CheckForCurrentMap() {
overworld_.overworld_map(current_highlighted_map)->parent(); overworld_.overworld_map(current_highlighted_map)->parent();
auto parent_map_x = highlight_parent % 8; auto parent_map_x = highlight_parent % 8;
auto parent_map_y = highlight_parent / 8; auto parent_map_y = highlight_parent / 8;
ow_map_canvas_.DrawOutline(parent_map_x * small_map_size, ow_map_canvas_.DrawOutline(parent_map_x * kOverworldMapSize,
parent_map_y * small_map_size, large_map_size, parent_map_y * kOverworldMapSize, large_map_size,
large_map_size); large_map_size);
} else { } else {
ow_map_canvas_.DrawOutline(current_map_x * small_map_size, ow_map_canvas_.DrawOutline(current_map_x * kOverworldMapSize,
current_map_y * small_map_size, small_map_size, current_map_y * kOverworldMapSize,
small_map_size); kOverworldMapSize, kOverworldMapSize);
} }
if (maps_bmp_[current_map_].modified() || if (maps_bmp_[current_map_].modified() ||
@@ -725,12 +739,12 @@ void OverworldEditor::DrawOverworldCanvas() {
DrawOverworldItems(); DrawOverworldItems();
DrawOverworldSprites(); DrawOverworldSprites();
CheckForOverworldEdits(); CheckForOverworldEdits();
if (ImGui::IsItemHovered()) status_ = CheckForCurrentMap(); if (IsItemHovered()) status_ = CheckForCurrentMap();
} }
ow_map_canvas_.DrawGrid(); ow_map_canvas_.DrawGrid();
ow_map_canvas_.DrawOverlay(); ow_map_canvas_.DrawOverlay();
ImGui::EndChild(); EndChild();
} }
absl::Status OverworldEditor::DrawTile16Selector() { absl::Status OverworldEditor::DrawTile16Selector() {
@@ -763,7 +777,7 @@ absl::Status OverworldEditor::DrawTile16Selector() {
blockset_canvas_.DrawGrid(); blockset_canvas_.DrawGrid();
blockset_canvas_.DrawOverlay(); blockset_canvas_.DrawOverlay();
} }
ImGui::EndChild(); EndChild();
ImGui::EndGroup(); ImGui::EndGroup();
return absl::OkStatus(); return absl::OkStatus();
} }
@@ -816,7 +830,7 @@ absl::Status OverworldEditor::DrawAreaGraphics() {
current_gfx_canvas_.DrawGrid(); current_gfx_canvas_.DrawGrid();
current_gfx_canvas_.DrawOverlay(); current_gfx_canvas_.DrawOverlay();
} }
ImGui::EndChild(); EndChild();
ImGui::EndGroup(); ImGui::EndGroup();
return absl::OkStatus(); return absl::OkStatus();
} }
@@ -832,7 +846,7 @@ absl::Status OverworldEditor::DrawTileSelector() {
gui::BeginPadding(3); gui::BeginPadding(3);
gui::BeginChildWithScrollbar("##Tile8SelectorScrollRegion"); gui::BeginChildWithScrollbar("##Tile8SelectorScrollRegion");
DrawTile8Selector(); DrawTile8Selector();
ImGui::EndChild(); EndChild();
gui::EndNoPadding(); gui::EndNoPadding();
EndTabItem(); EndTabItem();
} }
@@ -950,7 +964,7 @@ bool DrawEntranceInserterPopup() {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_CANCEL)) { if (Button(ICON_MD_CANCEL)) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
@@ -978,12 +992,12 @@ bool DrawOverworldEntrancePopup(
if (Button(ICON_MD_DONE)) { if (Button(ICON_MD_DONE)) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_CANCEL)) { if (Button(ICON_MD_CANCEL)) {
set_done = true; set_done = true;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_DELETE)) { if (Button(ICON_MD_DELETE)) {
entrance.deleted = true; entrance.deleted = true;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
@@ -1077,7 +1091,7 @@ void DrawExitInserterPopup() {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_CANCEL)) { if (Button(ICON_MD_CANCEL)) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
@@ -1118,22 +1132,22 @@ bool DrawExitEditorPopup(zelda3::overworld::OverworldExit &exit) {
static int leftEdgeOfMap = 0; static int leftEdgeOfMap = 0;
gui::InputHexWord("Room", &exit.room_id_); gui::InputHexWord("Room", &exit.room_id_);
ImGui::SameLine(); SameLine();
gui::InputHex("Entity ID", &exit.entity_id_, 4); gui::InputHex("Entity ID", &exit.entity_id_, 4);
gui::InputHex("Map", &exit.map_id_); gui::InputHex("Map", &exit.map_id_);
ImGui::SameLine(); SameLine();
Checkbox("Automatic", &exit.is_automatic_); Checkbox("Automatic", &exit.is_automatic_);
gui::InputHex("X Positon", &exit.x_); gui::InputHex("X Positon", &exit.x_);
ImGui::SameLine(); SameLine();
gui::InputHex("Y Position", &exit.y_); gui::InputHex("Y Position", &exit.y_);
gui::InputHexByte("X Camera", &exit.x_camera_); gui::InputHexByte("X Camera", &exit.x_camera_);
ImGui::SameLine(); SameLine();
gui::InputHexByte("Y Camera", &exit.y_camera_); gui::InputHexByte("Y Camera", &exit.y_camera_);
gui::InputHexWord("X Scroll", &exit.x_scroll_); gui::InputHexWord("X Scroll", &exit.x_scroll_);
ImGui::SameLine(); SameLine();
gui::InputHexWord("Y Scroll", &exit.y_scroll_); gui::InputHexWord("Y Scroll", &exit.y_scroll_);
ImGui::Separator(); ImGui::Separator();
@@ -1141,17 +1155,17 @@ bool DrawExitEditorPopup(zelda3::overworld::OverworldExit &exit) {
static bool show_properties = false; static bool show_properties = false;
Checkbox("Show properties", &show_properties); Checkbox("Show properties", &show_properties);
if (show_properties) { if (show_properties) {
ImGui::Text("Deleted? %s", exit.deleted_ ? "true" : "false"); Text("Deleted? %s", exit.deleted_ ? "true" : "false");
ImGui::Text("Hole? %s", exit.is_hole_ ? "true" : "false"); Text("Hole? %s", exit.is_hole_ ? "true" : "false");
ImGui::Text("Large Map? %s", exit.large_map_ ? "true" : "false"); Text("Large Map? %s", exit.large_map_ ? "true" : "false");
} }
gui::TextWithSeparators("Unimplemented below"); gui::TextWithSeparators("Unimplemented below");
ImGui::RadioButton("None", &doorType, 0); ImGui::RadioButton("None", &doorType, 0);
ImGui::SameLine(); SameLine();
ImGui::RadioButton("Wooden", &doorType, 1); ImGui::RadioButton("Wooden", &doorType, 1);
ImGui::SameLine(); SameLine();
ImGui::RadioButton("Bombable", &doorType, 2); ImGui::RadioButton("Bombable", &doorType, 2);
// If door type is not None, input positions // If door type is not None, input positions
if (doorType != 0) { if (doorType != 0) {
@@ -1160,9 +1174,9 @@ bool DrawExitEditorPopup(zelda3::overworld::OverworldExit &exit) {
} }
ImGui::RadioButton("None##Fancy", &fancyDoorType, 0); ImGui::RadioButton("None##Fancy", &fancyDoorType, 0);
ImGui::SameLine(); SameLine();
ImGui::RadioButton("Sanctuary", &fancyDoorType, 1); ImGui::RadioButton("Sanctuary", &fancyDoorType, 1);
ImGui::SameLine(); SameLine();
ImGui::RadioButton("Palace", &fancyDoorType, 2); ImGui::RadioButton("Palace", &fancyDoorType, 2);
// If fancy door type is not None, input positions // If fancy door type is not None, input positions
if (fancyDoorType != 0) { if (fancyDoorType != 0) {
@@ -1199,14 +1213,14 @@ bool DrawExitEditorPopup(zelda3::overworld::OverworldExit &exit) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_CANCEL)) { if (Button(ICON_MD_CANCEL)) {
set_done = true; set_done = true;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_DELETE)) { if (Button(ICON_MD_DELETE)) {
exit.deleted_ = true; exit.deleted_ = true;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
@@ -1279,23 +1293,23 @@ void DrawItemInsertPopup() {
// Contents of the Context Menu // Contents of the Context Menu
if (ImGui::BeginPopup("Item Inserter")) { if (ImGui::BeginPopup("Item Inserter")) {
static int new_item_id = 0; static int new_item_id = 0;
ImGui::Text("Add Item"); Text("Add Item");
ImGui::BeginChild("ScrollRegion", ImVec2(150, 150), true, BeginChild("ScrollRegion", ImVec2(150, 150), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGuiWindowFlags_AlwaysVerticalScrollbar);
for (int i = 0; i < zelda3::overworld::kSecretItemNames.size(); i++) { for (int i = 0; i < zelda3::overworld::kSecretItemNames.size(); i++) {
if (Selectable(zelda3::overworld::kSecretItemNames[i].c_str(), if (Selectable(zelda3::overworld::kSecretItemNames[i].c_str(),
i == new_item_id)) { i == new_item_id)) {
new_item_id = i; new_item_id = i;
} }
} }
ImGui::EndChild(); EndChild();
if (Button(ICON_MD_DONE)) { if (Button(ICON_MD_DONE)) {
// Add the new item to the overworld // Add the new item to the overworld
new_item_id = 0; new_item_id = 0;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_CANCEL)) { if (Button(ICON_MD_CANCEL)) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
@@ -1313,8 +1327,8 @@ bool DrawItemEditorPopup(zelda3::overworld::OverworldItem &item) {
} }
if (ImGui::BeginPopupModal("Item editor", NULL, if (ImGui::BeginPopupModal("Item editor", NULL,
ImGuiWindowFlags_AlwaysAutoResize)) { ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::BeginChild("ScrollRegion", ImVec2(150, 150), true, BeginChild("ScrollRegion", ImVec2(150, 150), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGuiWindowFlags_AlwaysVerticalScrollbar);
ImGui::BeginGroup(); ImGui::BeginGroup();
for (int i = 0; i < zelda3::overworld::kSecretItemNames.size(); i++) { for (int i = 0; i < zelda3::overworld::kSecretItemNames.size(); i++) {
if (Selectable(zelda3::overworld::kSecretItemNames[i].c_str(), if (Selectable(zelda3::overworld::kSecretItemNames[i].c_str(),
@@ -1323,15 +1337,15 @@ bool DrawItemEditorPopup(zelda3::overworld::OverworldItem &item) {
} }
} }
ImGui::EndGroup(); ImGui::EndGroup();
ImGui::EndChild(); EndChild();
if (Button(ICON_MD_DONE)) ImGui::CloseCurrentPopup(); if (Button(ICON_MD_DONE)) ImGui::CloseCurrentPopup();
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_CLOSE)) { if (Button(ICON_MD_CLOSE)) {
set_done = true; set_done = true;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_DELETE)) { if (Button(ICON_MD_DELETE)) {
item.deleted = true; item.deleted = true;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
@@ -1471,7 +1485,7 @@ void DrawSpriteTable(std::function<void(int)> onSpriteSelect) {
if (filter.PassFilter(item.name)) { if (filter.PassFilter(item.name)) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("%d", item.id); Text("%d", item.id);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
if (Selectable(item.name, selected_id == item.id, if (Selectable(item.name, selected_id == item.id,
@@ -1489,19 +1503,19 @@ void DrawSpriteTable(std::function<void(int)> onSpriteSelect) {
void DrawSpriteInserterPopup() { void DrawSpriteInserterPopup() {
if (ImGui::BeginPopup("Sprite Inserter")) { if (ImGui::BeginPopup("Sprite Inserter")) {
static int new_sprite_id = 0; static int new_sprite_id = 0;
ImGui::Text("Add Sprite"); Text("Add Sprite");
ImGui::BeginChild("ScrollRegion", ImVec2(250, 250), true, BeginChild("ScrollRegion", ImVec2(250, 250), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGuiWindowFlags_AlwaysVerticalScrollbar);
sprite_internal::DrawSpriteTable( sprite_internal::DrawSpriteTable(
[](int selected_id) { new_sprite_id = selected_id; }); [](int selected_id) { new_sprite_id = selected_id; });
ImGui::EndChild(); EndChild();
if (Button(ICON_MD_DONE)) { if (Button(ICON_MD_DONE)) {
// Add the new item to the overworld // Add the new item to the overworld
new_sprite_id = 0; new_sprite_id = 0;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_CANCEL)) { if (Button(ICON_MD_CANCEL)) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
@@ -1518,25 +1532,25 @@ bool DrawSpriteEditorPopup(zelda3::Sprite &sprite) {
} }
if (ImGui::BeginPopupModal("Sprite editor", NULL, if (ImGui::BeginPopupModal("Sprite editor", NULL,
ImGuiWindowFlags_AlwaysAutoResize)) { ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::BeginChild("ScrollRegion", ImVec2(350, 350), true, BeginChild("ScrollRegion", ImVec2(350, 350), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGuiWindowFlags_AlwaysVerticalScrollbar);
ImGui::BeginGroup(); ImGui::BeginGroup();
ImGui::Text("%s", sprite.Name().c_str()); Text("%s", sprite.Name().c_str());
sprite_internal::DrawSpriteTable([&sprite](int selected_id) { sprite_internal::DrawSpriteTable([&sprite](int selected_id) {
sprite.set_id(selected_id); sprite.set_id(selected_id);
sprite.UpdateMapProperties(sprite.map_id()); sprite.UpdateMapProperties(sprite.map_id());
}); });
ImGui::EndGroup(); ImGui::EndGroup();
ImGui::EndChild(); EndChild();
if (Button(ICON_MD_DONE)) ImGui::CloseCurrentPopup(); if (Button(ICON_MD_DONE)) ImGui::CloseCurrentPopup();
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_CLOSE)) { if (Button(ICON_MD_CLOSE)) {
set_done = true; set_done = true;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
ImGui::SameLine(); SameLine();
if (Button(ICON_MD_DELETE)) { if (Button(ICON_MD_DELETE)) {
sprite.set_deleted(true); sprite.set_deleted(true);
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
@@ -1782,12 +1796,12 @@ void OverworldEditor::DrawOverworldProperties() {
if (Checkbox("Dark World", &dark_world)) { if (Checkbox("Dark World", &dark_world)) {
properties_canvas_.set_current_labels(current + world); properties_canvas_.set_current_labels(current + world);
} }
ImGui::SameLine(); SameLine();
if (Button("Area Graphics")) { if (Button("Area Graphics")) {
current = 0; current = 0;
properties_canvas_.set_current_labels(current + world); properties_canvas_.set_current_labels(current + world);
} }
ImGui::SameLine(); SameLine();
if (Button("Area Palette")) { if (Button("Area Palette")) {
current = 1; current = 1;
properties_canvas_.set_current_labels(current + world); properties_canvas_.set_current_labels(current + world);
@@ -1799,7 +1813,7 @@ void OverworldEditor::DrawOverworldProperties() {
properties_canvas_.set_current_labels(6); properties_canvas_.set_current_labels(6);
} }
} }
ImGui::SameLine(); SameLine();
if (Button("Sprite Palette")) { if (Button("Sprite Palette")) {
current = 2; current = 2;
properties_canvas_.set_current_labels(current + world); properties_canvas_.set_current_labels(current + world);
@@ -1822,7 +1836,7 @@ absl::Status OverworldEditor::DrawExperimentalModal() {
"the tilemap into the editor"); "the tilemap into the editor");
ImGui::InputText("##TilemapFile", &ow_tilemap_filename_); ImGui::InputText("##TilemapFile", &ow_tilemap_filename_);
ImGui::SameLine(); SameLine();
gui::FileDialogPipeline( gui::FileDialogPipeline(
"ImportTilemapsKey", ".DAT,.dat\0", "Tilemap Hex File", [this]() { "ImportTilemapsKey", ".DAT,.dat\0", "Tilemap Hex File", [this]() {
ow_tilemap_filename_ = ImGuiFileDialog::Instance()->GetFilePathName(); ow_tilemap_filename_ = ImGuiFileDialog::Instance()->GetFilePathName();
@@ -1830,7 +1844,7 @@ absl::Status OverworldEditor::DrawExperimentalModal() {
ImGui::InputText("##Tile32ConfigurationFile", ImGui::InputText("##Tile32ConfigurationFile",
&tile32_configuration_filename_); &tile32_configuration_filename_);
ImGui::SameLine(); SameLine();
gui::FileDialogPipeline("ImportTile32Key", ".DAT,.dat\0", "Tile32 Hex File", gui::FileDialogPipeline("ImportTile32Key", ".DAT,.dat\0", "Tile32 Hex File",
[this]() { [this]() {
tile32_configuration_filename_ = tile32_configuration_filename_ =
@@ -1865,38 +1879,38 @@ absl::Status OverworldEditor::UpdateUsageStats() {
TableNextRow(); TableNextRow();
TableNextColumn(); TableNextColumn();
ImGui::BeginChild("UnusedSpritesetScroll", ImVec2(0, 0), true, if (BeginChild("UnusedSpritesetScroll", ImVec2(0, 0), true,
ImGuiWindowFlags_HorizontalScrollbar); ImGuiWindowFlags_HorizontalScrollbar)) {
for (int i = 0; i < 0x81; i++) { for (int i = 0; i < 0x81; i++) {
std::string str = absl::StrFormat("%#x", i); std::string str = absl::StrFormat("%#x", i);
if (Selectable(str.c_str(), selected_entrance_ == i, if (Selectable(str.c_str(), selected_entrance_ == i,
overworld_.entrances().at(i).deleted overworld_.entrances().at(i).deleted
? ImGuiSelectableFlags_Disabled ? ImGuiSelectableFlags_Disabled
: 0)) { : 0)) {
selected_entrance_ = i; selected_entrance_ = i;
selected_usage_map_ = overworld_.entrances().at(i).map_id_; selected_usage_map_ = overworld_.entrances().at(i).map_id_;
properties_canvas_.set_highlight_tile_id(selected_usage_map_); properties_canvas_.set_highlight_tile_id(selected_usage_map_);
} }
if (ImGui::IsItemHovered()) { if (IsItemHovered()) {
ImGui::BeginTooltip(); BeginTooltip();
ImGui::Text("Entrance ID: %d", i); Text("Entrance ID: %d", i);
ImGui::Text("Map ID: %d", overworld_.entrances().at(i).map_id_); Text("Map ID: %d", overworld_.entrances().at(i).map_id_);
ImGui::Text("Entrance ID: %d", Text("Entrance ID: %d", overworld_.entrances().at(i).entrance_id_);
overworld_.entrances().at(i).entrance_id_); Text("X: %d", overworld_.entrances().at(i).x_);
ImGui::Text("X: %d", overworld_.entrances().at(i).x_); Text("Y: %d", overworld_.entrances().at(i).y_);
ImGui::Text("Y: %d", overworld_.entrances().at(i).y_); Text("Deleted? %s",
ImGui::Text("Deleted? %s", overworld_.entrances().at(i).deleted ? "Yes" : "No");
overworld_.entrances().at(i).deleted ? "Yes" : "No"); EndTooltip();
ImGui::EndTooltip(); }
} }
EndChild();
} }
ImGui::EndChild();
TableNextColumn(); TableNextColumn();
DrawUsageGrid(); DrawUsageGrid();
TableNextColumn(); TableNextColumn();
DrawOverworldProperties(); DrawOverworldProperties();
ImGui::EndTable(); EndTable();
} }
return absl::OkStatus(); return absl::OkStatus();
} }
@@ -1920,7 +1934,7 @@ void OverworldEditor::DrawUsageGrid() {
// Loop through each row // Loop through each row
for (int row = 0; row < squaresTall; ++row) { for (int row = 0; row < squaresTall; ++row) {
ImGui::NewLine(); NewLine();
for (int col = 0; col < squaresWide; ++col) { for (int col = 0; col < squaresWide; ++col) {
if (row * squaresWide + col >= totalSquares) { if (row * squaresWide + col >= totalSquares) {
@@ -1931,7 +1945,7 @@ void OverworldEditor::DrawUsageGrid() {
// Set highlight color if needed // Set highlight color if needed
if (highlight) { if (highlight) {
ImGui::PushStyleColor( PushStyleColor(
ImGuiCol_Button, ImGuiCol_Button,
ImVec4(1.0f, 0.5f, 0.0f, 1.0f)); // Or any highlight color ImVec4(1.0f, 0.5f, 0.0f, 1.0f)); // Or any highlight color
} }
@@ -1945,16 +1959,16 @@ void OverworldEditor::DrawUsageGrid() {
// Reset style if it was highlighted // Reset style if it was highlighted
if (highlight) { if (highlight) {
ImGui::PopStyleColor(); PopStyleColor();
} }
// Check if the square is hovered // Check if the square is hovered
if (ImGui::IsItemHovered()) { if (IsItemHovered()) {
// Display a tooltip with all the room properties // Display a tooltip with all the room properties
} }
// Keep squares in the same line // Keep squares in the same line
ImGui::SameLine(); SameLine();
} }
} }
} }
@@ -1991,20 +2005,20 @@ absl::Status OverworldEditor::LoadAnimatedMaps() {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void OverworldEditor::DrawDebugWindow() { void OverworldEditor::DrawDebugWindow() {
ImGui::Text("Current Map: %d", current_map_); Text("Current Map: %d", current_map_);
ImGui::Text("Current Tile16: %d", current_tile16_); Text("Current Tile16: %d", current_tile16_);
int relative_x = (int)ow_map_canvas_.drawn_tile_position().x % 512; int relative_x = (int)ow_map_canvas_.drawn_tile_position().x % 512;
int relative_y = (int)ow_map_canvas_.drawn_tile_position().y % 512; int relative_y = (int)ow_map_canvas_.drawn_tile_position().y % 512;
ImGui::Text("Current Tile16 Drawn Position (Relative): %d, %d", relative_x, Text("Current Tile16 Drawn Position (Relative): %d, %d", relative_x,
relative_y); relative_y);
// Print the size of the overworld map_tiles per world // Print the size of the overworld map_tiles per world
ImGui::Text("Light World Map Tiles: %d", Text("Light World Map Tiles: %d",
(int)overworld_.mutable_map_tiles()->light_world.size()); (int)overworld_.mutable_map_tiles()->light_world.size());
ImGui::Text("Dark World Map Tiles: %d", Text("Dark World Map Tiles: %d",
(int)overworld_.mutable_map_tiles()->dark_world.size()); (int)overworld_.mutable_map_tiles()->dark_world.size());
ImGui::Text("Special World Map Tiles: %d", Text("Special World Map Tiles: %d",
(int)overworld_.mutable_map_tiles()->special_world.size()); (int)overworld_.mutable_map_tiles()->special_world.size());
static bool view_lw_map_tiles = false; static bool view_lw_map_tiles = false;
static MemoryEditor mem_edit; static MemoryEditor mem_edit;

View File

@@ -51,6 +51,8 @@ class OverworldMap : public editor::context::GfxContext {
auto is_initialized() const { return initialized_; } auto is_initialized() const { return initialized_; }
auto parent() const { return parent_; } auto parent() const { return parent_; }
auto mutable_mosaic() { return &mosaic_; }
auto mutable_current_palette() { return &current_palette_; } auto mutable_current_palette() { return &current_palette_; }
auto area_graphics() const { return area_graphics_; } auto area_graphics() const { return area_graphics_; }
@@ -118,6 +120,8 @@ class OverworldMap : public editor::context::GfxContext {
bool large_map_ = false; bool large_map_ = false;
bool initialized_ = false; bool initialized_ = false;
bool mosaic_ = false;
int index_ = 0; // Map index int index_ = 0; // Map index
int parent_ = 0; // Parent map index int parent_ = 0; // Parent map index
int large_index_ = 0; // Quadrant ID [0-3] int large_index_ = 0; // Quadrant ID [0-3]