From 944c00b89e0d5120974dfb29ed6422420af9616b Mon Sep 17 00:00:00 2001 From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com> Date: Mon, 17 Mar 2025 17:05:35 +0100 Subject: [PATCH] add hotkey (R) for rotation --- src/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 7cdc992..ee501b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1095,6 +1095,14 @@ int main(int argc, char **argv) { msaa_texture = NULL; } } + + if (selected_tile != -1 && ImGui::IsWindowFocused() && ImGui::IsKeyPressed(ImGuiKey_R, false)) { + if (ImGui::IsKeyDown(ImGuiKey_LeftShift)) { + selected_rotation = (selected_rotation - 1) & 3; + } else { + selected_rotation = (selected_rotation + 1) & 3; + } + } } ImGui::End(); @@ -1143,6 +1151,8 @@ int main(int argc, char **argv) { if (io.WantCaptureKeyboard) continue; + SDL_Keymod modifiers = SDL_GetModState(); + if (event.key.key == SDLK_UP || event.key.key == SDLK_W) { player.pos_y = clamp(0, player.pos_y + 1, map_height - 2); } @@ -1166,6 +1176,16 @@ int main(int argc, char **argv) { if (event.key.key == SDLK_F4) { load_map(); } + + if (event.key.key == SDLK_R) { + if (selected_tile != -1 && selected_rotation != -1) { + if (modifiers & SDL_KMOD_SHIFT) { + selected_rotation = (selected_rotation - 1) & 3; + } else { + selected_rotation = (selected_rotation + 1) & 3; + } + } + } } break; case SDL_EVENT_MOUSE_BUTTON_DOWN: {