add hotkey (R) for rotation

This commit is contained in:
Sven Balzer 2025-03-17 17:05:35 +01:00
parent 5ac98b6203
commit 944c00b89e

View File

@ -1095,6 +1095,14 @@ int main(int argc, char **argv) {
msaa_texture = NULL; 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(); ImGui::End();
@ -1143,6 +1151,8 @@ int main(int argc, char **argv) {
if (io.WantCaptureKeyboard) if (io.WantCaptureKeyboard)
continue; continue;
SDL_Keymod modifiers = SDL_GetModState();
if (event.key.key == SDLK_UP || event.key.key == SDLK_W) { if (event.key.key == SDLK_UP || event.key.key == SDLK_W) {
player.pos_y = clamp(0, player.pos_y + 1, map_height - 2); 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) { if (event.key.key == SDLK_F4) {
load_map(); 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; } break;
case SDL_EVENT_MOUSE_BUTTON_DOWN: { case SDL_EVENT_MOUSE_BUTTON_DOWN: {