diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp index 13ba7a14..cbbbb990 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp @@ -55,6 +55,20 @@ void TileSheetEditorImGui::paste() { model()->paste(); } +void TileSheetEditorImGui::keyStateChanged(core::Key key, bool down) { + if (!down) { + return; + } + const auto colorCnt = model()->pal().colors.size(); + if (key >= core::Key::Num_1 && key <= core::Key::Num_0 + colorCnt) { + auto idx = ox::min(key - core::Key::Num_1, colorCnt - 1); + m_tileSheetEditor.setPalIdx(idx); + } else if (key == core::Key::Num_0 && colorCnt >= 10) { + auto idx = ox::min(key - core::Key::Num_1 + 9, colorCnt - 1); + m_tileSheetEditor.setPalIdx(idx); + } +} + void TileSheetEditorImGui::draw(core::Context*) noexcept { const auto paneSize = ImGui::GetContentRegionAvail(); const auto tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y); diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp index 7d3f6562..83e5834d 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.hpp @@ -70,6 +70,8 @@ class TileSheetEditorImGui: public studio::BaseEditor { void paste() override; + void keyStateChanged(core::Key key, bool down) override; + void draw(core::Context*) noexcept override; void drawSubsheetSelector(TileSheet::SubSheet*, TileSheet::SubSheetIdx *path) noexcept;