From 0146d38405e3bdfe8495e5de8e5ff9be6e8c9d42 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 19 Jan 2025 18:18:52 -0600 Subject: [PATCH] [nostalgia/core/studio/tilesheeteditor] Manually merge in changes that were lost in conflict --- .../tilesheeteditor/tilesheeteditor-imgui.cpp | 24 ++++++------------- .../tilesheeteditor/tilesheeteditor-imgui.hpp | 2 +- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp index 8cc7c9ab..c9f9f6c1 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.cpp @@ -437,19 +437,17 @@ void TileSheetEditorImGui::drawTileSheet(ox::Vec2 const&fbSize) noexcept { } void TileSheetEditorImGui::drawPaletteMenu() noexcept { - auto const&files = m_sctx.project->fileList(core::FileExt_npal); auto const comboWidthSub = 62; ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - comboWidthSub); - if (ig::ComboBox("Palette", files, m_selectedPaletteIdx)) { - oxLogError(m_model.setPalette(files[m_selectedPaletteIdx])); + auto constexpr palTags = ImGuiInputTextFlags_ReadOnly; + if (ig::InputText("Palette", m_selectedPalette, palTags)) { + oxLogError(m_model.setPalette(m_selectedPalette)); } if (ig::DragDropTarget const dragDropTarget; dragDropTarget) { auto const [ref, err] = ig::getDragDropPayload("FileRef"); - if (!err && endsWith(ref.path, FileExt_npal)) { - auto const oldVal = m_selectedPaletteIdx; - std::ignore = ox::findIdx(files.begin(), files.end(), ref.path).moveTo(m_selectedPaletteIdx); - if (oldVal != m_selectedPaletteIdx) { - oxLogError(m_model.setPalette(files[m_selectedPaletteIdx])); + if (!err) { + if (ref.path != m_selectedPalette) { + oxLogError(m_model.setPalette(ref.path)); } } } @@ -523,15 +521,7 @@ ox::Error TileSheetEditorImGui::updateActiveSubsheet(ox::StringView const&name, } ox::Error TileSheetEditorImGui::setPaletteSelection() noexcept { - auto const&palPath = m_model.palPath(); - auto const&palList = m_sctx.project->fileList(core::FileExt_npal); - for (std::size_t i = 0; auto const&pal : palList) { - if (palPath == pal) { - m_selectedPaletteIdx = i; - break; - } - ++i; - } + m_selectedPalette = m_model.palPath(); return {}; } diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.hpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.hpp index 40acda3b..46797d09 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.hpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditor-imgui.hpp @@ -46,7 +46,7 @@ class TileSheetEditorImGui: public studio::Editor { constexpr bool isOpen() const noexcept { return m_show; } }; static constexpr float s_palViewWidth = 300; - std::size_t m_selectedPaletteIdx = 0; + ox::String m_selectedPalette; studio::StudioContext &m_sctx; turbine::Context &m_tctx; ox::Vector m_paletteList;