Skip to content

Commit

Permalink
Make Input Overlay position persistent when is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Antidote committed Oct 23, 2023
1 parent d5ed445 commit 70443dd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Runtime/ConsoleVariables/CVarCommons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ 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,
CVar::EFlags::Game | CVar::EFlags::Archive | CVar::EFlags::ReadOnly);
Expand Down
1 change: 1 addition & 0 deletions Runtime/ConsoleVariables/CVarCommons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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 Down
12 changes: 12 additions & 0 deletions Runtime/ImGuiConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,20 @@ void ImGuiConsole::ShowInputViewer() {
SetOverlayWindowLocation(m_inputOverlayCorner);
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
2 changes: 2 additions & 0 deletions Runtime/ImGuiConsole.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ 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

0 comments on commit 70443dd

Please sign in to comment.