From cf39f2d14c00af62f63ea3316364a39a7a6d4292 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sat, 9 Mar 2024 15:34:48 +0100 Subject: [PATCH] imgui scale --- src/solanaceae/doom_imgui.cpp | 22 +++++++++++++--------- src/solanaceae/doom_imgui.hpp | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/solanaceae/doom_imgui.cpp b/src/solanaceae/doom_imgui.cpp index e1ae270..0cd1dc8 100644 --- a/src/solanaceae/doom_imgui.cpp +++ b/src/solanaceae/doom_imgui.cpp @@ -90,19 +90,23 @@ const static std::vector> g_all_keys { float DoomIMGUI::render(float time_delta) { float doom_interval {1.f}; - if (ImGui::Begin("doom")) { - for (const auto& [imkey, dokey] : g_all_keys) { - // TODO: unpress all keys on focus loss - if (ImGui::IsKeyPressed(imkey, false)) { - _doom.doomKeyDown(dokey); - } - if (ImGui::IsKeyReleased(imkey)) { - _doom.doomKeyUp(dokey); + if (ImGui::Begin("doom", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { + ImGui::SliderFloat("scale", &_size_scaler, 1.f, 5.f); + + if (ImGui::IsWindowFocused()) { + for (const auto& [imkey, dokey] : g_all_keys) { + // TODO: unpress all keys on focus loss + if (ImGui::IsKeyPressed(imkey, false)) { + _doom.doomKeyDown(dokey); + } + if (ImGui::IsKeyReleased(imkey)) { + _doom.doomKeyUp(dokey); + } } } doom_interval = _doom.render(time_delta); - ImGui::Image(reinterpret_cast(_doom.getTexID()), {320, 200*1.2}); + ImGui::Image(reinterpret_cast(_doom.getTexID()), {_size_scaler * 320, _size_scaler * 200 * 1.2f}); } ImGui::End(); diff --git a/src/solanaceae/doom_imgui.hpp b/src/solanaceae/doom_imgui.hpp index be7f0bf..deccbb1 100644 --- a/src/solanaceae/doom_imgui.hpp +++ b/src/solanaceae/doom_imgui.hpp @@ -6,6 +6,8 @@ class DoomIMGUI { // inherit instead? Doom _doom; + float _size_scaler {2.f}; + public: DoomIMGUI( TextureUploaderI& tu