From 716b3d60222661749e9387575d3f04cf8bffeee8 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 17 Dec 2022 14:05:35 -0600 Subject: [PATCH] [nostalgia/core/studio] Cleanup --- .../core/studio/paletteeditor-imgui.cpp | 12 ++++++------ .../core/studio/tilesheeteditor-imgui.cpp | 17 ++++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/nostalgia/core/studio/paletteeditor-imgui.cpp b/src/nostalgia/core/studio/paletteeditor-imgui.cpp index 27b050f9..3d50b4c3 100644 --- a/src/nostalgia/core/studio/paletteeditor-imgui.cpp +++ b/src/nostalgia/core/studio/paletteeditor-imgui.cpp @@ -20,7 +20,7 @@ ox::Result PaletteEditorImGui::make(Context *ctx, const ox: const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset(); out->m_itemName = out->m_itemPath.substr(lastSlash + 1); oxRequire(pal, core::readObj(out->m_ctx, out->m_itemPath)); - out->m_pal = *pal.get(); + out->m_pal = *pal; return out.release(); } @@ -45,20 +45,20 @@ void PaletteEditorImGui::draw(core::Context*) noexcept { { const auto sz = ImVec2(70, 24); if (ImGui::Button("Add", sz)) { - undoStack()->push(new AddColorCommand(&m_pal, 0, m_pal.colors.size())); + undoStack()->push(ox::make(&m_pal, 0, m_pal.colors.size())); } ImGui::SameLine(); ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size()); { if (ImGui::Button("Remove", sz)) { - undoStack()->push(new RemoveColorCommand(&m_pal, m_pal.colors[static_cast(m_selectedRow)], m_selectedRow)); + undoStack()->push(ox::make(&m_pal, m_pal.colors[static_cast(m_selectedRow)], m_selectedRow)); m_selectedRow = ox::min(m_pal.colors.size() - 1, m_selectedRow); } ImGui::SameLine(); ImGui::BeginDisabled(m_selectedRow <= 0); { if (ImGui::Button("Move Up", sz)) { - undoStack()->push(new MoveColorCommand(&m_pal, m_selectedRow, -1)); + undoStack()->push(ox::make(&m_pal, m_selectedRow, -1)); --m_selectedRow; } } @@ -67,7 +67,7 @@ void PaletteEditorImGui::draw(core::Context*) noexcept { ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size() - 1); { if (ImGui::Button("Move Down", sz)) { - undoStack()->push(new MoveColorCommand(&m_pal, m_selectedRow, 1)); + undoStack()->push(ox::make(&m_pal, m_selectedRow, 1)); ++m_selectedRow; } } @@ -127,7 +127,7 @@ void PaletteEditorImGui::draw(core::Context*) noexcept { ImGui::InputInt("Blue", &b, 1, 5); const auto newColor = color16(r, g, b, a); if (c != newColor) { - undoStack()->push(new UpdateColorCommand(&m_pal, m_selectedRow, c, newColor)); + undoStack()->push(ox::make(&m_pal, m_selectedRow, c, newColor)); } } ImGui::EndChild(); diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp index 5b9753f7..b7d2d9bd 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp @@ -197,11 +197,10 @@ void TileSheetEditorImGui::drawSubsheetSelector(TileSheet::SubSheet *subsheet, T const auto flags = ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_DefaultOpen - | (subsheet->subsheets.size() ? 0 : ImGuiTreeNodeFlags_Leaf) + | (subsheet->subsheets.empty() ? ImGuiTreeNodeFlags_Leaf : 0) | (rowSelected ? ImGuiTreeNodeFlags_Selected : 0); ImGui::TableNextColumn(); const auto open = ImGui::TreeNodeEx(lbl.c_str(), flags); - Str newName = subsheet->name.c_str(); ImGui::SameLine(); if (ImGui::IsItemClicked()) { model()->setActiveSubsheet(*path); @@ -209,16 +208,16 @@ void TileSheetEditorImGui::drawSubsheetSelector(TileSheet::SubSheet *subsheet, T if (ImGui::IsMouseDoubleClicked(0) && ImGui::IsItemHovered()) { showSubsheetEditor(); } - if (subsheet->subsheets.size()) { - ImGui::TableNextColumn(); - ImGui::Text("--"); - ImGui::TableNextColumn(); - ImGui::Text("--"); - } else { + if (subsheet->subsheets.empty()) { ImGui::TableNextColumn(); ImGui::Text("%d", subsheet->columns); ImGui::TableNextColumn(); ImGui::Text("%d", subsheet->rows); + } else { + ImGui::TableNextColumn(); + ImGui::Text("--"); + ImGui::TableNextColumn(); + ImGui::Text("--"); } if (open) { for (auto i = 0ul; auto &child : subsheet->subsheets) { @@ -287,7 +286,7 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept { glViewport(0, 0, fbSizei.width, fbSizei.height); m_tileSheetEditor.draw(); glBindFramebuffer(GL_FRAMEBUFFER, 0); - uintptr_t buffId = m_framebuffer.color.id; + const uintptr_t buffId = m_framebuffer.color.id; ImGui::Image( reinterpret_cast(buffId), static_cast(fbSize),