From 86dd3df1d09a0ea46a9500ecf76a684e4d634bdf Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 28 Oct 2023 09:12:05 -0700 Subject: [PATCH] Remove InputViewer position store It's redundant now as ImGui is storing the position, it wasn't before so I'm not sure what changed for it to suddenly work, however let's not store things redundantly. --- Runtime/CMain.cpp | 1 + Runtime/ConsoleVariables/CVarCommons.cpp | 9 ++++----- Runtime/ConsoleVariables/CVarCommons.hpp | 3 ++- Runtime/ImGuiConsole.cpp | 15 ++------------- Runtime/ImGuiConsole.hpp | 2 -- Runtime/ImGuiControllerConfig.hpp | 4 +++- 6 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Runtime/CMain.cpp b/Runtime/CMain.cpp index fcab14d4b..d4e7fa344 100644 --- a/Runtime/CMain.cpp +++ b/Runtime/CMain.cpp @@ -538,6 +538,7 @@ int main(int argc, char** argv) { .msaa = cvarCmns.getSamples(), .maxTextureAnisotropy = static_cast(cvarCmns.getAnisotropy()), .startFullscreen = cvarCmns.getFullscreen(), + .allowJoystickBackgroundEvents = cvarCmns.getAllowJoystickInBackground(), .windowPosX = cvarCmns.getWindowPos().x, .windowPosY = cvarCmns.getWindowPos().y, .windowWidth = static_cast(cvarCmns.getWindowSize().x < 0 ? 0 : cvarCmns.getWindowSize().x), diff --git a/Runtime/ConsoleVariables/CVarCommons.cpp b/Runtime/ConsoleVariables/CVarCommons.cpp index cbd631049..aadd27d5f 100644 --- a/Runtime/ConsoleVariables/CVarCommons.cpp +++ b/Runtime/ConsoleVariables/CVarCommons.cpp @@ -8,6 +8,9 @@ CVarCommons* m_instance = nullptr; CVarCommons::CVarCommons(CVarManager& manager) : m_mgr(manager) { m_fullscreen = m_mgr.findOrMakeCVar("fullscreen"sv, "Start in fullscreen"sv, false, CVar::EFlags::System | CVar::EFlags::Archive); + m_allowJoystickInBackground = + m_mgr.findOrMakeCVar("allowJoystickInBackground"sv, "Enable joystick input while window does not have focus"sv, + true, CVar::EFlags::System | CVar::EFlags::Archive); m_graphicsApi = m_mgr.findOrMakeCVar("graphicsApi"sv, "API to use for rendering graphics"sv, DEFAULT_GRAPHICS_API, CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::ModifyRestart); m_drawSamples = m_mgr.findOrMakeCVar("drawSamples"sv, "Number of MSAA samples to use for render targets"sv, 1, @@ -22,7 +25,7 @@ CVarCommons::CVarCommons(CVarManager& manager) : m_mgr(manager) { m_windowSize = m_mgr.findOrMakeCVar("windowSize", "Stores the last known window size", zeus::CVector2i(1280, 960), (CVar::EFlags::System | CVar::EFlags::Archive)); m_windowPos = m_mgr.findOrMakeCVar("windowPos", "Stores the last known window position", zeus::CVector2i(-1, -1), - (CVar::EFlags::System | CVar::EFlags::Archive)); + (CVar::EFlags::System | CVar::EFlags::Archive)); m_debugOverlayPlayerInfo = m_mgr.findOrMakeCVar( "debugOverlay.playerInfo"sv, "Displays information about the player, such as location and orientation"sv, false, @@ -72,10 +75,6 @@ CVarCommons::CVarCommons(CVarManager& manager) : m_mgr(manager) { m_debugInputOverlayCorner = m_mgr.findOrMakeCVar("debugOverlay.inputOverlayCorner"sv, "ImGui input overlay corner"sv, 3 /* bottom-right */, CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::Hidden); - m_debugInputOverlayPos = - m_mgr.findOrMakeCVar("debugOverlay.inputOverlayPosition"sv, "ImGui custom input overlay position"sv, - zeus::CVector2f{0.f, 0.f} /* uninitialized */, - CVar::EFlags::System | CVar::EFlags::Archive | CVar::EFlags::Hidden); m_debugToolDrawAiPath = m_mgr.findOrMakeCVar("debugTool.drawAiPath", "Draws the selected paths of any AI in the room"sv, false, diff --git a/Runtime/ConsoleVariables/CVarCommons.hpp b/Runtime/ConsoleVariables/CVarCommons.hpp index fa821d8b6..7da5d6548 100644 --- a/Runtime/ConsoleVariables/CVarCommons.hpp +++ b/Runtime/ConsoleVariables/CVarCommons.hpp @@ -22,6 +22,7 @@ using namespace std::literals; struct CVarCommons { CVarManager& m_mgr; CVar* m_fullscreen = nullptr; + CVar* m_allowJoystickInBackground = nullptr; CVar* m_graphicsApi = nullptr; CVar* m_drawSamples = nullptr; CVar* m_texAnisotropy = nullptr; @@ -46,7 +47,6 @@ struct CVarCommons { CVar* m_debugOverlayShowInput = nullptr; CVar* m_debugOverlayCorner = nullptr; CVar* m_debugInputOverlayCorner = nullptr; - CVar* m_debugInputOverlayPos = nullptr; CVar* m_debugToolDrawAiPath = nullptr; CVar* m_debugToolDrawLighting = nullptr; CVar* m_debugToolDrawCollisionActors = nullptr; @@ -58,6 +58,7 @@ struct CVarCommons { CVarCommons(CVarManager& manager); bool getFullscreen() const { return m_fullscreen->toBoolean(); } + bool getAllowJoystickInBackground() const { return m_allowJoystickInBackground->toBoolean(); } void setFullscreen(bool b) { m_fullscreen->fromBoolean(b); } diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index 7d20cadac..f74173cc7 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -1050,20 +1050,8 @@ void ImGuiConsole::ShowInputViewer() { windowFlags |= ImGuiWindowFlags_NoMove; } - if (m_initialInputOverlayDraw && m_inputOverlayCorner == -1) { - ImGui::SetNextWindowPos(m_inputOverlayPos); - m_initialInputOverlayDraw = false; - } - ImGui::SetNextWindowBgAlpha(0.65f); if (ImGui::Begin("Input Overlay", nullptr, windowFlags)) { - /* If the position has changed and we're not in a corner, grab it and store it */ - if (m_inputOverlayCorner == -1 && - (ImGui::GetWindowPos().x != m_inputOverlayPos.x() || ImGui::GetWindowPos().y != m_inputOverlayPos.y())) { - m_inputOverlayPos = ImGui::GetWindowPos(); - m_cvarCommons.m_debugInputOverlayPos->fromVec2f(m_inputOverlayPos); - } - float scale = GetScale(); if (!m_controllerName.empty()) { TextCenter(m_controllerName); @@ -1893,7 +1881,7 @@ void ImGuiConsole::ControllerRemoved(uint32_t idx) { } static void ImGuiCVarCheckbox(CVarManager& mgr, std::string_view cvarName, const char* label, bool* ptr = nullptr) { - auto* cvar = mgr.findOrMakeCVar(cvarName, ""sv, false, CVar::EFlags::Game | CVar::EFlags::Archive); + auto* cvar = mgr.findCVar(cvarName); if (cvar != nullptr) { bool value = cvar->toBoolean(); bool modified = false; @@ -1945,6 +1933,7 @@ void ImGuiConsole::ShowPreLaunchSettingsWindow() { ImGui::EndTabItem(); } if (ImGui::BeginTabItem("Game")) { + ImGuiCVarCheckbox(m_cvarMgr, "allowJoystickInBackground", "Enable Background Joystick Input"); ImGuiCVarCheckbox(m_cvarMgr, "tweak.game.SplashScreensDisabled", "Skip Splash Screens"); ImGuiCVarCheckbox(m_cvarMgr, "cheats", "Enable Cheats", &m_cheats); if (m_cheats) { diff --git a/Runtime/ImGuiConsole.hpp b/Runtime/ImGuiConsole.hpp index f8b8566d1..a87737c18 100644 --- a/Runtime/ImGuiConsole.hpp +++ b/Runtime/ImGuiConsole.hpp @@ -132,8 +132,6 @@ class ImGuiConsole { int m_debugOverlayCorner = m_cvarCommons.m_debugOverlayCorner->toSigned(); int m_inputOverlayCorner = m_cvarCommons.m_debugInputOverlayCorner->toSigned(); - zeus::CVector2f m_inputOverlayPos = m_cvarCommons.m_debugInputOverlayPos->toVec2f(); - bool m_initialInputOverlayDraw = true; const void* m_currentRoom = nullptr; double m_lastRoomTime = 0.f; double m_currentRoomStart = 0.f; diff --git a/Runtime/ImGuiControllerConfig.hpp b/Runtime/ImGuiControllerConfig.hpp index 8d04ab066..446abdc12 100644 --- a/Runtime/ImGuiControllerConfig.hpp +++ b/Runtime/ImGuiControllerConfig.hpp @@ -3,6 +3,8 @@ #include "Runtime/GCNTypes.hpp" #include "Runtime/Streams/CInputStream.hpp" #include "Runtime/Streams/COutputStream.hpp" + +#include "imgui.h" #include #include @@ -31,7 +33,7 @@ class ImGuiControllerConfig { std::vector> vidPids; std::string atlasFile; // Path to atlas relative to controller definition std::vector