diff --git a/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor-imgui.cpp b/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor-imgui.cpp index b782709f..5355da47 100644 --- a/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor-imgui.cpp +++ b/src/nostalgia/modules/core/src/studio/paletteeditor/paletteeditor-imgui.cpp @@ -154,22 +154,24 @@ void PaletteEditorImGui::drawColorsEditor() noexcept { ImGui::TableSetupColumn("Blue", ImGuiTableColumnFlags_WidthFixed, 40); ImGui::TableSetupColumn("Preview", ImGuiTableColumnFlags_NoHide); ImGui::TableHeadersRow(); - for (auto i = 0u; auto const&c : m_pal.pages[m_page].colors) { - ig::IDStackItem const idStackItem(static_cast(i)); - ImGui::TableNextRow(); - drawColumn(i + 1); - drawColumnLeftAlign(m_pal.colorNames[i]); - drawColumn(red16(c)); - drawColumn(green16(c)); - drawColumn(blue16(c)); - ImGui::TableNextColumn(); - auto const ic = ImGui::GetColorU32({redf(c), greenf(c), bluef(c), 1}); - ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ic); - if (ImGui::Selectable( - "##ColorRow", i == m_selectedColorRow, ImGuiSelectableFlags_SpanAllColumns)) { - m_selectedColorRow = i; + if (m_page < m_pal.pages.size()) { + for (auto i = 0u; auto const &c: m_pal.pages[m_page].colors) { + ig::IDStackItem const idStackItem(static_cast(i)); + ImGui::TableNextRow(); + drawColumn(i + 1); + drawColumnLeftAlign(m_pal.colorNames[i]); + drawColumn(red16(c)); + drawColumn(green16(c)); + drawColumn(blue16(c)); + ImGui::TableNextColumn(); + auto const ic = ImGui::GetColorU32({redf(c), greenf(c), bluef(c), 1}); + ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ic); + if (ImGui::Selectable( + "##ColorRow", i == m_selectedColorRow, ImGuiSelectableFlags_SpanAllColumns)) { + m_selectedColorRow = i; + } + ++i; } - ++i; } } ImGui::EndTable();