Make Input Overlay position persistent when is selected

This commit is contained in:
Phillip Stephens 2023-10-22 17:38:48 -07:00
parent d5ed445c4b
commit 70443ddff5
4 changed files with 19 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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