[nostalgia/core/studio] Make TileSheetEditor palette keys behave like PaletteEditor

This commit is contained in:
Gary Talent 2024-10-01 22:37:36 -05:00
parent 36c4022b56
commit ba7e3929e9

View File

@ -158,21 +158,25 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key key, bool down) {
} else if (key >= turbine::Key::Num_1 && key <= turbine::Key::Num_9) { } else if (key >= turbine::Key::Num_1 && key <= turbine::Key::Num_9) {
if (turbine::buttonDown(m_tctx, turbine::Key::Mod_Alt)) { if (turbine::buttonDown(m_tctx, turbine::Key::Mod_Alt)) {
auto const idx = ox::min<std::size_t>( auto const idx = ox::min<std::size_t>(
static_cast<uint32_t>(key - turbine::Key::Num_1), m_model.pal().pages.size() - 1); static_cast<uint32_t>(key - turbine::Key::Num_1),
m_model.pal().pages.size() - 1);
m_model.setPalettePage(idx); m_model.setPalettePage(idx);
} else if (key <= turbine::Key::Num_0 + colorCnt) { } else if (key <= turbine::Key::Num_9) {
auto const idx = ox::min<std::size_t>( auto const idx = ox::min<std::size_t>(
static_cast<uint32_t>(key - turbine::Key::Num_1), colorCnt - 1); static_cast<uint32_t>(key - turbine::Key::Num_1),
colorCnt - 1);
m_view.setPalIdx(idx); m_view.setPalIdx(idx);
} }
} else if (key == turbine::Key::Num_0) { } else if (key == turbine::Key::Num_0) {
if (turbine::buttonDown(m_tctx, turbine::Key::Mod_Alt)) { if (turbine::buttonDown(m_tctx, turbine::Key::Mod_Alt)) {
auto const idx = ox::min<std::size_t>( auto const idx = ox::min<std::size_t>(
static_cast<uint32_t>(key - turbine::Key::Num_1 + 9), m_model.pal().pages.size() - 1); static_cast<uint32_t>(key - turbine::Key::Num_1 + 9),
m_model.pal().pages.size() - 1);
m_model.setPalettePage(idx); m_model.setPalettePage(idx);
} else if (colorCnt >= 10) { } else {
auto const idx = ox::min<std::size_t>( auto const idx = ox::min<std::size_t>(
static_cast<uint32_t>(key - turbine::Key::Num_1 + 9), colorCnt - 1); static_cast<uint32_t>(key - turbine::Key::Num_1 + 9),
colorCnt - 1);
m_view.setPalIdx(idx); m_view.setPalIdx(idx);
} }
} }