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.
This commit is contained in:
Phillip Stephens 2023-10-28 09:12:05 -07:00
parent a6392ab822
commit 86dd3df1d0
6 changed files with 12 additions and 22 deletions

View File

@ -538,6 +538,7 @@ int main(int argc, char** argv) {
.msaa = cvarCmns.getSamples(),
.maxTextureAnisotropy = static_cast<uint16_t>(cvarCmns.getAnisotropy()),
.startFullscreen = cvarCmns.getFullscreen(),
.allowJoystickBackgroundEvents = cvarCmns.getAllowJoystickInBackground(),
.windowPosX = cvarCmns.getWindowPos().x,
.windowPosY = cvarCmns.getWindowPos().y,
.windowWidth = static_cast<uint>(cvarCmns.getWindowSize().x < 0 ? 0 : cvarCmns.getWindowSize().x),

View File

@ -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,

View File

@ -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); }

View File

@ -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) {

View File

@ -132,8 +132,6 @@ private:
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;

View File

@ -3,6 +3,8 @@
#include "Runtime/GCNTypes.hpp"
#include "Runtime/Streams/CInputStream.hpp"
#include "Runtime/Streams/COutputStream.hpp"
#include "imgui.h"
#include <dolphin/pad.h>
#include <array>
@ -31,7 +33,7 @@ class ImGuiControllerConfig {
std::vector<std::pair<u16, u16>> vidPids;
std::string atlasFile; // Path to atlas relative to controller definition
std::vector<Button> buttons;
ImTextureID atlasId;
ControllerAtlas() = default;
explicit ControllerAtlas(CInputStream& in);
void PutTo(COutputStream& out) const;