diff --git a/src/xrGame/UIDialogHolder.cpp b/src/xrGame/UIDialogHolder.cpp index 4838bef9be1..f877c4c03e1 100644 --- a/src/xrGame/UIDialogHolder.cpp +++ b/src/xrGame/UIDialogHolder.cpp @@ -58,9 +58,6 @@ void CDialogHolder::StartMenu(CUIDialogWnd* pDialog, bool bDoHideIndicators) SetFocused(nullptr); pDialog->SetHolder(this); - if (pDialog->NeedCursor()) - GetUICursor().Show(); - if (g_pGameLevel) { CActor* A = smart_cast(Level().CurrentViewEntity()); @@ -97,9 +94,6 @@ void CDialogHolder::StopMenu(CUIDialogWnd* pDialog) RemoveDialogToRender(pDialog); pDialog->SetHolder(NULL); - - if (!TopInputReceiver() || !TopInputReceiver()->NeedCursor()) - GetUICursor().Hide(); } void CDialogHolder::AddDialogToRender(CUIWindow* pDialog) @@ -230,8 +224,26 @@ void CDialogHolder::OnFrame() m_b_in_update = true; - if (!GEnv.isDedicatedServer && GetUICursor().IsVisible() && pInput->IsCurrentInputTypeController()) - GetUICursor().UpdateAutohideTiming(); + if (!GEnv.isDedicatedServer) + { + auto& cursor = GetUICursor(); + const bool need_cursor = TopInputReceiver() && TopInputReceiver()->NeedCursor(); + + const u32 cur_time = Device.dwTimeContinual; + + if (need_cursor) + { + if (!cursor.IsVisible()) + { + cursor.Show(); + m_become_visible_time = cur_time; + } + } + else if (float(cur_time - m_become_visible_time) > (psControllerCursorAutohideTime * 1000.f)) + { + cursor.Hide(); + } + } CUIDialogWnd* wnd = TopInputReceiver(); if (wnd && wnd->IsEnabled()) diff --git a/src/xrGame/UIDialogHolder.h b/src/xrGame/UIDialogHolder.h index f4a46eca148..0c1a588064d 100644 --- a/src/xrGame/UIDialogHolder.h +++ b/src/xrGame/UIDialogHolder.h @@ -39,6 +39,7 @@ class CDialogHolder : public pureFrame, public CUIDebuggable, public CUIFocusSys xr_vector m_input_receivers; xr_vector m_dialogsToRender; xr_vector m_dialogsToRender_new; + u32 m_become_visible_time{}; bool m_b_in_update; void StartMenu(CUIDialogWnd* pDialog, bool bDoHideIndicators); diff --git a/src/xrGame/ui/UIChatWnd.h b/src/xrGame/ui/UIChatWnd.h index a89a025c262..b8a38287ea2 100644 --- a/src/xrGame/ui/UIChatWnd.h +++ b/src/xrGame/ui/UIChatWnd.h @@ -18,7 +18,7 @@ class CUIChatWnd final : public CUIDialogWnd, public CUIWndCallback void SetEditBoxPrefix(LPCSTR prefix); void ChatToAll(bool b) { sendNextMessageToAll = b; } void PendingMode(bool const is_pending_mode); - virtual bool NeedCursor() const { return false; } + bool NeedCursor() const override { return false; } virtual void SendMessage(CUIWindow* pWnd, s16 msg, void* pData = NULL); pcstr GetDebugType() override { return "CUIChatWnd"; } diff --git a/src/xrGame/ui/UIMapFilters.cpp b/src/xrGame/ui/UIMapFilters.cpp index cb8ca579a8a..a58f631dd60 100644 --- a/src/xrGame/ui/UIMapFilters.cpp +++ b/src/xrGame/ui/UIMapFilters.cpp @@ -154,7 +154,6 @@ void CUIMapFilters::SelectFilter(bool select, bool next /*= true*/) m_selected_filter = int(m_filters.size() - 1); } cursor.WarpToWindow(m_filters[m_selected_filter]); - cursor.PauseAutohiding(true); } } diff --git a/src/xrUICore/Cursor/UICursor.cpp b/src/xrUICore/Cursor/UICursor.cpp index bd3d42b42b7..3836a44790c 100644 --- a/src/xrUICore/Cursor/UICursor.cpp +++ b/src/xrUICore/Cursor/UICursor.cpp @@ -57,19 +57,6 @@ CUICursor::~CUICursor() Device.seqRender.Remove(this); } -void CUICursor::Show() -{ - bVisible = true; - m_become_visible_time = Device.dwTimeContinual; -} - -void CUICursor::Hide() -{ - bVisible = false; - m_become_visible_time = 0; - m_pause_autohide = false; -} - //-------------------------------------------------------------------- u32 last_render_frame = 0; void CUICursor::OnRender() @@ -100,29 +87,6 @@ void CUICursor::OnRender() m_static->Draw(); } -void CUICursor::UpdateAutohideTiming() -{ - if (m_pause_autohide) - return; - - const u32 cur_time = Device.dwTimeContinual; - - if (float(cur_time - m_become_visible_time) > (psControllerCursorAutohideTime * 1000.f)) - { - Hide(); - } -} - -void CUICursor::PauseAutohiding(bool pause) -{ - if (m_pause_autohide == pause) - return; - - m_pause_autohide = pause; - if (!m_pause_autohide) - m_become_visible_time = Device.dwTimeContinual; -} - void CUICursor::SetUICursorPosition(Fvector2 pos) { vPos = pos; diff --git a/src/xrUICore/Cursor/UICursor.h b/src/xrUICore/Cursor/UICursor.h index e18d6665a7d..5793f0315f6 100644 --- a/src/xrUICore/Cursor/UICursor.h +++ b/src/xrUICore/Cursor/UICursor.h @@ -11,8 +11,6 @@ class XRUICORE_API CUICursor : public pureRender, public CDeviceResetNotifier, p Fvector2 correction; bool bVisible{}; bool m_bound_to_system_cursor{}; - bool m_pause_autohide{}; - u32 m_become_visible_time{}; void InitInternal(); @@ -20,8 +18,8 @@ class XRUICORE_API CUICursor : public pureRender, public CDeviceResetNotifier, p CUICursor(); ~CUICursor() override; - void Show(); - void Hide(); + void Show() { bVisible = true; } + void Hide() { bVisible = false; } [[nodiscard]] bool IsVisible() const { return bVisible; } @@ -30,9 +28,6 @@ class XRUICORE_API CUICursor : public pureRender, public CDeviceResetNotifier, p void OnDeviceReset() override; void OnUIReset() override; - void UpdateAutohideTiming(); - void PauseAutohiding(bool pause); - void WarpToWindow(CUIWindow* wnd, bool change_visibility = true); void UpdateCursorPosition(int _dx, int _dy);