[nostalgia/core/studio] Fix PaletteEditor to handle Palettes with 0 pages
All checks were successful
Build / build (push) Successful in 2m55s

This commit is contained in:
Gary Talent 2024-10-28 20:57:21 -05:00
parent 941bc71348
commit 3c7652efc2

View File

@ -154,22 +154,24 @@ void PaletteEditorImGui::drawColorsEditor() noexcept {
ImGui::TableSetupColumn("Blue", ImGuiTableColumnFlags_WidthFixed, 40); ImGui::TableSetupColumn("Blue", ImGuiTableColumnFlags_WidthFixed, 40);
ImGui::TableSetupColumn("Preview", ImGuiTableColumnFlags_NoHide); ImGui::TableSetupColumn("Preview", ImGuiTableColumnFlags_NoHide);
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
for (auto i = 0u; auto const&c : m_pal.pages[m_page].colors) { if (m_page < m_pal.pages.size()) {
ig::IDStackItem const idStackItem(static_cast<int>(i)); for (auto i = 0u; auto const &c: m_pal.pages[m_page].colors) {
ImGui::TableNextRow(); ig::IDStackItem const idStackItem(static_cast<int>(i));
drawColumn(i + 1); ImGui::TableNextRow();
drawColumnLeftAlign(m_pal.colorNames[i]); drawColumn(i + 1);
drawColumn(red16(c)); drawColumnLeftAlign(m_pal.colorNames[i]);
drawColumn(green16(c)); drawColumn(red16(c));
drawColumn(blue16(c)); drawColumn(green16(c));
ImGui::TableNextColumn(); drawColumn(blue16(c));
auto const ic = ImGui::GetColorU32({redf(c), greenf(c), bluef(c), 1}); ImGui::TableNextColumn();
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ic); auto const ic = ImGui::GetColorU32({redf(c), greenf(c), bluef(c), 1});
if (ImGui::Selectable( ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ic);
"##ColorRow", i == m_selectedColorRow, ImGuiSelectableFlags_SpanAllColumns)) { if (ImGui::Selectable(
m_selectedColorRow = i; "##ColorRow", i == m_selectedColorRow, ImGuiSelectableFlags_SpanAllColumns)) {
m_selectedColorRow = i;
}
++i;
} }
++i;
} }
} }
ImGui::EndTable(); ImGui::EndTable();