From 00a4da7a991497f92b2e4bd281c475c7476fafe5 Mon Sep 17 00:00:00 2001 From: lightmanLP <50497969+lightmanLP@users.noreply.github.com> Date: Wed, 18 Dec 2024 06:32:42 +0000 Subject: [PATCH] store main game window ID to reduce load --- src/controller/controldeck/ControlDeck.cpp | 3 --- src/window/gui/Gui.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/controller/controldeck/ControlDeck.cpp b/src/controller/controldeck/ControlDeck.cpp index d3d4ca24f..b2d7f6abe 100644 --- a/src/controller/controldeck/ControlDeck.cpp +++ b/src/controller/controldeck/ControlDeck.cpp @@ -10,8 +10,6 @@ #include #include "controller/deviceindex/ShipDeviceIndexMappingManager.h" -#include "spdlog/spdlog.h" - namespace Ship { ControlDeck::ControlDeck(std::vector additionalBitmasks) : mSinglePlayerMappingMode(false) { @@ -88,7 +86,6 @@ bool ControlDeck::KeyboardGameInputBlocked() { bool ControlDeck::MouseGameInputBlocked() { // block mouse input when user interacting with gui - // TODO: check perfomance ImGuiWindow* window = ImGui::GetCurrentContext()->HoveredWindow; if (window == NULL) { return true; diff --git a/src/window/gui/Gui.cpp b/src/window/gui/Gui.cpp index 2015c9ac4..2f3af046c 100644 --- a/src/window/gui/Gui.cpp +++ b/src/window/gui/Gui.cpp @@ -292,11 +292,16 @@ void Gui::UnblockGamepadNavigation() { } ImGuiID Gui::GetMainGameWindowID() { + static ImGuiID windowID = 0; + if (windowID != 0) { + return windowID; + } ImGuiWindow* window = ImGui::FindWindowByName("Main Game"); if (window == NULL) { return 0; } - return window->ID; + windowID = window->ID; + return windowID; } void Gui::ImGuiBackendNewFrame() {