diff --git a/src/xrGame/ui/UIDialogWnd.h b/src/xrGame/ui/UIDialogWnd.h index 6568b21f0a0..cb448b7ce6a 100644 --- a/src/xrGame/ui/UIDialogWnd.h +++ b/src/xrGame/ui/UIDialogWnd.h @@ -33,7 +33,7 @@ class CUIDialogWnd : public CUIWindow CUIFocusSystem* GetCurrentFocusSystem() const override { return GetHolder(); } virtual bool StopAnyMove() { return true; } - virtual bool NeedCursor() const { return true; } + virtual bool NeedCursor() const { return pInput->IsCurrentInputTypeKeyboardMouse(); } virtual bool NeedCenterCursor() const { return true; } virtual bool WorkInPause() const { return m_bWorkInPause; } virtual bool Dispatch(int cmd, int param) { return true; } diff --git a/src/xrGame/ui/UIPdaWnd.cpp b/src/xrGame/ui/UIPdaWnd.cpp index 269edbc0955..976e2d6d54d 100644 --- a/src/xrGame/ui/UIPdaWnd.cpp +++ b/src/xrGame/ui/UIPdaWnd.cpp @@ -362,6 +362,14 @@ void CUIPdaWnd::DrawHint() m_hint_wnd->Draw(); } +bool CUIPdaWnd::NeedCursor() const +{ + if (m_pActiveDialog && m_pActiveDialog->IsUsingCursorRightNow()) + return true; + + return CUIDialogWnd::NeedCursor(); +} + void CUIPdaWnd::UpdatePda() { if (pUILogsWnd) diff --git a/src/xrGame/ui/UIPdaWnd.h b/src/xrGame/ui/UIPdaWnd.h index 367fc56862d..3f980551e04 100644 --- a/src/xrGame/ui/UIPdaWnd.h +++ b/src/xrGame/ui/UIPdaWnd.h @@ -84,7 +84,8 @@ class CUIPdaWnd final : public CUIDialogWnd void SetActiveSubdialog(const shared_str& section); CUITabControl* GetTabControl() const { return UITabControl; } - virtual bool StopAnyMove() { return false; } + bool StopAnyMove() override { return false; } + bool NeedCursor() const override; void UpdatePda(); void UpdateRankingWnd(); diff --git a/src/xrGame/ui/UIScriptWnd_script.cpp b/src/xrGame/ui/UIScriptWnd_script.cpp index 3b6ee495705..3aaabbc9ecf 100644 --- a/src/xrGame/ui/UIScriptWnd_script.cpp +++ b/src/xrGame/ui/UIScriptWnd_script.cpp @@ -73,6 +73,18 @@ struct CUIDialogWndExWrapperBase final : public CUIDialogWndEx, public luabind:: return ptr->self_type::inherited::Dispatch(cmd, param); } + bool NeedCursor() const override + { + if (luabind::call_member(this, "NeedCursor")) + return true; + return inherited::NeedCursor(); + } + + static bool NeedCursor_static(inherited* ptr) + { + return ptr->self_type::inherited::NeedCursor(); + } + pcstr GetDebugType() override { return "CUIScriptWnd"; } bool FillDebugTree(const CUIDebugState& debugState) override @@ -222,6 +234,8 @@ SCRIPT_EXPORT(CUIDialogWndEx, (CUIDialogWnd, IFactoryObject), .def("Dispatch", &BaseType::Dispatch, &WrapType::Dispatch_static) .def("Load", &BaseType::Load) + .def("NeedCursor", &BaseType::NeedCursor, &WrapType::NeedCursor_static) + .def("GetButton", &BaseType::GetControl) .def("GetMessageBox", &BaseType::GetControl) .def("GetPropertiesBox",&BaseType::GetControl) diff --git a/src/xrGame/ui/UITaskWnd.cpp b/src/xrGame/ui/UITaskWnd.cpp index 6d89b428390..6aa01331622 100644 --- a/src/xrGame/ui/UITaskWnd.cpp +++ b/src/xrGame/ui/UITaskWnd.cpp @@ -321,6 +321,11 @@ void CUITaskWnd::Show_TaskListWnd(bool status) const m_task_wnd->Show(status); } +bool CUITaskWnd::IsUsingCursorRightNow() const +{ + return m_pKeyboardCapturer == &m_filters; +} + void CUITaskWnd::TaskSetTargetMap(CGameTask* task) const { if (!task || !IsSecondaryTasksEnabled()) diff --git a/src/xrGame/ui/UITaskWnd.h b/src/xrGame/ui/UITaskWnd.h index 8fbcca1fd1a..ca42a222fbd 100644 --- a/src/xrGame/ui/UITaskWnd.h +++ b/src/xrGame/ui/UITaskWnd.h @@ -77,6 +77,8 @@ class CUITaskWnd final : public CUIWindow, public CUIWndCallback void SecondaryTasksEnabled(bool enable) { m_filters.SetFilterEnabled(CUIMapFilters::SecondaryTasks, enable); } void PrimaryObjectsEnabled(bool enable) { m_filters.SetFilterEnabled(CUIMapFilters::PrimaryObjects, enable); } + bool IsUsingCursorRightNow() const override; + private: void TaskSetTargetMap(CGameTask* task) const; void TaskShowMapSpot(CGameTask* task, bool show) const; diff --git a/src/xrUICore/Cursor/UICursor.cpp b/src/xrUICore/Cursor/UICursor.cpp index 3836a44790c..f55cacdcb12 100644 --- a/src/xrUICore/Cursor/UICursor.cpp +++ b/src/xrUICore/Cursor/UICursor.cpp @@ -130,6 +130,9 @@ void CUICursor::WarpToWindow(CUIWindow* wnd, bool change_visibility /*= true*/) if (change_visibility) Show(); + if (!IsVisible()) + return; + Fvector2 pos; wnd->GetAbsolutePos(pos); Fvector2 size = wnd->GetWndSize(); diff --git a/src/xrUICore/Windows/UIWindow.h b/src/xrUICore/Windows/UIWindow.h index f6516f4423a..6b8aab22f50 100644 --- a/src/xrUICore/Windows/UIWindow.h +++ b/src/xrUICore/Windows/UIWindow.h @@ -169,6 +169,9 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable CUIWindow* FindChild(const shared_str name); + [[nodiscard]] + virtual bool IsUsingCursorRightNow() const { return false; } + [[nodiscard]] IC bool CursorOverWindow() const { return m_bCursorOverWindow; } diff --git a/src/xrUICore/Windows/UIWindow_script.cpp b/src/xrUICore/Windows/UIWindow_script.cpp index ea6bf6e6d07..4dbc2407b24 100644 --- a/src/xrUICore/Windows/UIWindow_script.cpp +++ b/src/xrUICore/Windows/UIWindow_script.cpp @@ -165,6 +165,7 @@ SCRIPT_EXPORT(CUIWindow, (), .def("IsAutoDelete", &CUIWindow::IsAutoDelete) .def("IsCursorOverWindow", &CUIWindow::CursorOverWindow) + .def("IsUsingCursorRightNow", &CUIWindow::IsUsingCursorRightNow) .def("FocusReceiveTime", &CUIWindow::FocusReceiveTime) .def("GetAbsoluteRect", &CUIWindow::GetAbsoluteRect)