From e0b2f37925d61dfe0a154a21a22666e8c3c8fdff Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 5 Mar 2022 18:29:50 -0600 Subject: [PATCH] [nostalgia/core/studio] Adjust size of SubSheet Editor in cases without size input --- src/nostalgia/core/studio/tilesheeteditor-imgui.cpp | 6 ++++-- src/nostalgia/core/studio/tilesheeteditormodel.hpp | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp index 89aed650..89f59bd9 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp @@ -248,10 +248,12 @@ void TileSheetEditorImGui::SubSheetEditor::draw() noexcept { return; } ImGui::OpenPopup(popupName); - ImGui::SetNextWindowSize(ImVec2(235, 125)); + const auto modSize = m_cols > 0; + const auto popupHeight = modSize ? 125.f : 80.f; + ImGui::SetNextWindowSize(ImVec2(235, popupHeight)); if (ImGui::BeginPopupModal(popupName, &m_show, modalFlags)) { ImGui::InputText("Name", m_name.data(), m_name.cap()); - if (m_cols != -1) { + if (modSize) { ImGui::InputInt("Columns", &m_cols); ImGui::InputInt("Rows", &m_rows); } diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.hpp b/src/nostalgia/core/studio/tilesheeteditormodel.hpp index cc0365ce..c4d35d68 100644 --- a/src/nostalgia/core/studio/tilesheeteditormodel.hpp +++ b/src/nostalgia/core/studio/tilesheeteditormodel.hpp @@ -206,7 +206,12 @@ struct UpdateSubSheetCommand: public studio::UndoCommand { sheet.name = m_newName; sheet.columns = m_newCols; sheet.rows = m_newRows; - oxLogError(sheet.setPixelCount(m_img->bpp, static_cast(m_newCols * m_newRows))); + oxDebugf("old cols: {}, old rows: {}", sheet.columns, sheet.rows); + oxDebugf("new cols: {}, new rows: {}", m_newCols, m_newRows); + oxDebugf("bpp: {}", m_img->bpp); + oxDebugf("pixel count before: {}", sheet.pixels.size()); + oxLogError(sheet.setPixelCount(m_img->bpp, static_cast(PixelsPerTile * m_newCols * m_newRows))); + oxDebugf("pixel count after: {}", sheet.pixels.size()); } void undo() noexcept final {