diff --git a/src/app/editor/dungeon_editor.cc b/src/app/editor/dungeon_editor.cc index 09ae5c65..0560297e 100644 --- a/src/app/editor/dungeon_editor.cc +++ b/src/app/editor/dungeon_editor.cc @@ -110,47 +110,47 @@ void DungeonEditor::DrawToolset() { TableSetupColumn("#doorTool"); TableSetupColumn("#blockTool"); - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::Button(ICON_MD_UNDO)) { PRINT_IF_ERROR(Undo()); } - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::Button(ICON_MD_REDO)) { PRINT_IF_ERROR(Redo()); } - ImGui::TableNextColumn(); + TableNextColumn(); ImGui::Text(ICON_MD_MORE_VERT); - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::RadioButton(ICON_MD_FILTER_NONE, background_type_ == kBackgroundAny)) { background_type_ = kBackgroundAny; } - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::RadioButton(ICON_MD_FILTER_1, background_type_ == kBackground1)) { background_type_ = kBackground1; } - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::RadioButton(ICON_MD_FILTER_2, background_type_ == kBackground2)) { background_type_ = kBackground2; } - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::RadioButton(ICON_MD_FILTER_3, background_type_ == kBackground3)) { background_type_ = kBackground3; } - ImGui::TableNextColumn(); + TableNextColumn(); ImGui::Text(ICON_MD_MORE_VERT); - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::RadioButton(ICON_MD_PEST_CONTROL, placement_type_ == kSprite)) { placement_type_ = kSprite; } @@ -158,7 +158,7 @@ void DungeonEditor::DrawToolset() { ImGui::SetTooltip("Sprites"); } - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::RadioButton(ICON_MD_GRASS, placement_type_ == kItem)) { placement_type_ = kItem; } @@ -166,7 +166,7 @@ void DungeonEditor::DrawToolset() { ImGui::SetTooltip("Items"); } - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::RadioButton(ICON_MD_SENSOR_DOOR, placement_type_ == kDoor)) { placement_type_ = kDoor; } @@ -174,7 +174,7 @@ void DungeonEditor::DrawToolset() { ImGui::SetTooltip("Doors"); } - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::RadioButton(ICON_MD_SQUARE, placement_type_ == kBlock)) { placement_type_ = kBlock; } @@ -182,7 +182,7 @@ void DungeonEditor::DrawToolset() { ImGui::SetTooltip("Blocks"); } - ImGui::TableNextColumn(); + TableNextColumn(); if (ImGui::Button(ICON_MD_PALETTE)) { palette_showing_ = !palette_showing_; } @@ -219,6 +219,12 @@ void DungeonEditor::DrawDungeonTabView() { if (ImGui::BeginTabBar("MyTabBar", kDungeonTabBarFlags)) { // TODO: Manage the room that is being added to the tab bar. if (ImGui::TabItemButton("+", kDungeonTabFlags)) { + if (std::find(active_rooms_.begin(), active_rooms_.end(), + current_room_id_) != active_rooms_.end()) { + // Room is already open + next_tab_id++; + } + active_rooms_.push_back(next_tab_id++); // Add new tab } @@ -269,8 +275,11 @@ void DungeonEditor::DrawDungeonCanvas(int room_id) { ImGui::EndGroup(); - canvas_.DrawBackground(); + canvas_.DrawBackground(ImVec2(0x200, 0x200)); canvas_.DrawContextMenu(); + if (is_loaded_) { + canvas_.DrawBitmap(rooms_[room_id].layer1(), 0, 0); + } canvas_.DrawGrid(); canvas_.DrawOverlay(); } @@ -328,7 +337,7 @@ void DungeonEditor::DrawObjectRenderer() { ImGui::GetContentRegionAvail().x); TableSetupColumn("Canvas"); - ImGui::TableNextColumn(); + TableNextColumn(); ImGui::BeginChild("DungeonObjectButtons", ImVec2(250, 0), true); int selected_object = 0; @@ -348,7 +357,7 @@ void DungeonEditor::DrawObjectRenderer() { ImGui::EndChild(); // Right side of the table - Canvas - ImGui::TableNextColumn(); + TableNextColumn(); ImGui::BeginChild("DungeonObjectCanvas", ImVec2(276, 0x10 * 0x40 + 1), true); diff --git a/src/app/editor/graphics_editor.cc b/src/app/editor/graphics_editor.cc index c4dcf494..a6bdbad5 100644 --- a/src/app/editor/graphics_editor.cc +++ b/src/app/editor/graphics_editor.cc @@ -28,6 +28,7 @@ using ImGui::Button; using ImGui::InputInt; using ImGui::InputText; using ImGui::SameLine; +using ImGui::TableNextColumn; constexpr ImGuiTableFlags kGfxEditTableFlags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | @@ -87,38 +88,41 @@ void GraphicsEditor::DrawGfxEditToolset() { "Zoom In", "Current Color", "Tile Size"}) ImGui::TableSetupColumn(name); - ImGui::TableNextColumn(); + TableNextColumn(); if (Button(ICON_MD_SELECT_ALL)) { gfx_edit_mode_ = GfxEditMode::kSelect; } - ImGui::TableNextColumn(); + TableNextColumn(); if (Button(ICON_MD_DRAW)) { gfx_edit_mode_ = GfxEditMode::kPencil; } + HOVER_HINT("Draw with current color"); - ImGui::TableNextColumn(); + TableNextColumn(); if (Button(ICON_MD_FORMAT_COLOR_FILL)) { gfx_edit_mode_ = GfxEditMode::kFill; } + HOVER_HINT("Fill with current color"); - ImGui::TableNextColumn(); + TableNextColumn(); if (Button(ICON_MD_CONTENT_COPY)) { std::vector png_data = - rom()->bitmap_manager().GetBitmap(current_sheet_)->GetPngData(); + rom()->bitmap_manager().shared_bitmap(current_sheet_)->GetPngData(); CopyImageToClipboard(png_data); } + HOVER_HINT("Copy to Clipboard"); - ImGui::TableNextColumn(); + TableNextColumn(); if (Button(ICON_MD_CONTENT_PASTE)) { std::vector png_data; int width, height; GetImageFromClipboard(png_data, width, height); if (png_data.size() > 0) { rom() - ->bitmap_manager() - .GetBitmap(current_sheet_) - ->LoadFromPngData(png_data, width, height); + ->mutable_bitmap_manager() + ->mutable_bitmap(current_sheet_) + ->Create(width, height, 8, png_data); rom()->UpdateBitmap(rom() ->mutable_bitmap_manager() ->mutable_bitmap(current_sheet_) @@ -127,21 +131,21 @@ void GraphicsEditor::DrawGfxEditToolset() { } HOVER_HINT("Paste from Clipboard"); - ImGui::TableNextColumn(); + TableNextColumn(); if (Button(ICON_MD_ZOOM_OUT)) { if (current_scale_ >= 0.0f) { current_scale_ -= 1.0f; } } - ImGui::TableNextColumn(); + TableNextColumn(); if (Button(ICON_MD_ZOOM_IN)) { if (current_scale_ <= 16.0f) { current_scale_ += 1.0f; } } - ImGui::TableNextColumn(); + TableNextColumn(); auto bitmap = rom()->bitmap_manager()[current_sheet_]; auto palette = bitmap->palette(); for (int i = 0; i < 8; i++) { @@ -155,7 +159,7 @@ void GraphicsEditor::DrawGfxEditToolset() { } } - ImGui::TableNextColumn(); + TableNextColumn(); gui::InputHexByte("Tile Size", &tile_size_, 0x01); ImGui::EndTable(); @@ -174,7 +178,7 @@ absl::Status GraphicsEditor::UpdateGfxSheetList() { ImGui::PopStyleVar(); gui::Canvas graphics_bin_canvas_; auto select_tile_event = [&]() { - if (value.get()->IsActive()) { + if (value.get()->is_active()) { auto texture = value.get()->texture(); graphics_bin_canvas_.GetDrawList()->AddImage( (void*)texture, @@ -424,7 +428,7 @@ absl::Status GraphicsEditor::DrawToolset() { for (const auto& name : kGfxToolsetColumnNames) ImGui::TableSetupColumn(name.data()); - ImGui::TableNextColumn(); + TableNextColumn(); if (Button(ICON_MD_MEMORY)) { if (!open_memory_editor_) { open_memory_editor_ = true;