Skip to content

Commit

Permalink
Remove InputViewer position store
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Antidote committed Oct 28, 2023
1 parent a6392ab commit 86dd3df
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 22 deletions.
1 change: 1 addition & 0 deletions Runtime/CMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
9 changes: 4 additions & 5 deletions Runtime/ConsoleVariables/CVarCommons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion Runtime/ConsoleVariables/CVarCommons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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); }

Expand Down
15 changes: 2 additions & 13 deletions Runtime/ImGuiConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions Runtime/ImGuiConsole.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion Runtime/ImGuiControllerConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 86dd3df

Please sign in to comment.