diff --git a/src/xrGame/UIZoneMap.cpp b/src/xrGame/UIZoneMap.cpp index a3ba7187baa..f7043a887da 100644 --- a/src/xrGame/UIZoneMap.cpp +++ b/src/xrGame/UIZoneMap.cpp @@ -18,7 +18,7 @@ #include "ui/UIInventoryUtilities.h" ////////////////////////////////////////////////////////////////////////// -void CUIZoneMap::Init() +void CUIZoneMap::Init(bool motionIconAttached) { CUIXml uiXml; uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, "zone_map.xml"); @@ -39,10 +39,7 @@ void CUIZoneMap::Init() m_activeMap->SetAutoDelete(true); m_activeMap->EnableHeading(true); - // Clear Sky and Shadow of Chernobyl compatibility - // Check for m_pointerDistanceText reduces flexibility - // But it's all we can, probably. - m_activeMap->SetRounded(!m_pointerDistanceText); + m_activeMap->SetRounded(motionIconAttached); CUIXmlInit::InitStatic(uiXml, "minimap:compass", 0, &m_compass); m_background.AttachChild(&m_compass); @@ -55,7 +52,7 @@ void CUIZoneMap::Init() Fvector2 temp; const float k = UI().get_current_kx(); - if (m_clipFrame.WndRectIsProbablyRelative()) + if (motionIconAttached) { temp = m_clipFrame.GetWndSize(); temp.y *= UI_BASE_HEIGHT * k; @@ -66,7 +63,7 @@ void CUIZoneMap::Init() m_clipFrame.SetWndPos(temp.mul(UI_BASE_HEIGHT)); } - if (m_background.WndSizeIsProbablyRelative()) + if (motionIconAttached) { m_background.SetHeight(m_background.GetHeight() * UI_BASE_HEIGHT); m_background.SetWidth(m_background.GetHeight() * k); @@ -78,14 +75,14 @@ void CUIZoneMap::Init() temp = m_clipFrame.GetWndSize(); m_center.SetWndPos(temp.div(2.0f)); - if (m_compass.WndPosIsProbablyRelative()) + if (motionIconAttached) { temp = m_compass.GetWndPos(); temp.mul(m_background.GetWndSize()); m_compass.SetWndPos(temp); } - if (m_clock_wnd && m_clock_wnd->WndPosIsProbablyRelative()) + if (m_clock_wnd && motionIconAttached) { temp = m_clock_wnd->GetWndPos(); temp.mul(m_background.GetWndSize()); @@ -99,7 +96,7 @@ void CUIZoneMap::Init() CUIXmlInit::InitTextWnd(uiXml, "minimap:static_counter:text_static", 0, &m_Counter_text); m_Counter.AttachChild(&m_Counter_text); - if (m_Counter.WndPosIsProbablyRelative()) + if (motionIconAttached) { temp = m_Counter.GetWndPos(); temp.mul(m_background.GetWndSize()); diff --git a/src/xrGame/UIZoneMap.h b/src/xrGame/UIZoneMap.h index e0e20b432d4..7b64fcd6cff 100644 --- a/src/xrGame/UIZoneMap.h +++ b/src/xrGame/UIZoneMap.h @@ -3,7 +3,7 @@ #include "xrUICore/Static/UIStatic.h" class CActor; -class CUIMiniMap; +class CUICustomMap; class CUIZoneMap { @@ -11,7 +11,7 @@ class CUIZoneMap bool visible{ true }; private: - CUIMiniMap* m_activeMap{}; + CUICustomMap* m_activeMap{}; CUIStatic m_background{ "Background" }; CUIStatic m_center{ "Center" }; @@ -27,7 +27,7 @@ class CUIZoneMap public: virtual ~CUIZoneMap() = default; - void Init(); + void Init(bool motionIconAttached); void Render(); void Update(); diff --git a/src/xrGame/ui/UIDragDropListEx.cpp b/src/xrGame/ui/UIDragDropListEx.cpp index 2cf8691cfc6..ae8f760dd46 100644 --- a/src/xrGame/ui/UIDragDropListEx.cpp +++ b/src/xrGame/ui/UIDragDropListEx.cpp @@ -90,7 +90,7 @@ void CUIDragDropListEx::InitDragDropList(Fvector2 pos, Fvector2 size) Fvector2().set(m_vScrollBar->GetWndPos().x - m_vScrollBar->GetWidth(), m_vScrollBar->GetWndPos().y)); } -void CUIDragDropListEx::SetHighlighter(CUIStatic* highlighter, Fvector2 spacing) +void CUIDragDropListEx::SetHighlighter(CUIStatic* highlighter, Fvector2 spacing, bool convertPosToOurs /*= true*/) { if (m_highlighter) { @@ -113,7 +113,7 @@ void CUIDragDropListEx::SetHighlighter(CUIStatic* highlighter, Fvector2 spacing) AttachChild(m_highlighter); // Convert absolute position to relative // Without this, UI Frustum will cull our highlighter - if (!m_highlighter->WndPosIsProbablyRelative()) + if (convertPosToOurs) { Fvector2 ourAbsPos; GetAbsolutePos(ourAbsPos); @@ -130,7 +130,7 @@ void CUIDragDropListEx::Highlight(bool highlight) m_highlighter->Show(highlight); } -void CUIDragDropListEx::SetBlocker(CUIStatic* blocker, Fvector2 spacing) +void CUIDragDropListEx::SetBlocker(CUIStatic* blocker, Fvector2 spacing, bool convertPosToOurs /*= true*/) { if (m_blocker) { @@ -152,7 +152,7 @@ void CUIDragDropListEx::SetBlocker(CUIStatic* blocker, Fvector2 spacing) AttachChild(m_blocker); // Convert absolute position to relative // Without this, UI Frustum will cull our blocker - if (!m_blocker->WndPosIsProbablyRelative()) + if (convertPosToOurs) { Fvector2 ourAbsPos; GetAbsolutePos(ourAbsPos); @@ -163,7 +163,7 @@ void CUIDragDropListEx::SetBlocker(CUIStatic* blocker, Fvector2 spacing) } } -void CUIDragDropListEx::SetConditionIndicator(CUIProgressBar* indicator) +void CUIDragDropListEx::SetConditionIndicator(CUIProgressBar* indicator, bool convertPosToOurs /*= true*/) { if (m_condition_indicator && m_condition_indicator->GetParent() == this) { @@ -178,7 +178,7 @@ void CUIDragDropListEx::SetConditionIndicator(CUIProgressBar* indicator) AttachChild(m_condition_indicator); // Convert absolute position to relative // Without this, UI Frustum will cull our indicator - if (!m_condition_indicator->WndPosIsProbablyRelative()) + if (convertPosToOurs) { Fvector2 ourAbsPos; GetAbsolutePos(ourAbsPos); diff --git a/src/xrGame/ui/UIDragDropListEx.h b/src/xrGame/ui/UIDragDropListEx.h index bf7296ac4df..d97166b1a1d 100644 --- a/src/xrGame/ui/UIDragDropListEx.h +++ b/src/xrGame/ui/UIDragDropListEx.h @@ -142,7 +142,7 @@ class CUIDragDropListEx : public CUIWindow, public CUIWndCallback bool GetVirtualCells(); void SetVirtualCells(bool b); - void SetHighlighter(CUIStatic* highlighter, Fvector2 spacing); + void SetHighlighter(CUIStatic* highlighter, Fvector2 spacing, bool convertPosToOurs = true); CUIStatic* GetHighlighter() const { return m_highlighter; @@ -153,7 +153,7 @@ class CUIDragDropListEx : public CUIWindow, public CUIWndCallback } void Highlight(bool highlight); - void SetBlocker(CUIStatic* blocker, Fvector2 spacing); + void SetBlocker(CUIStatic* blocker, Fvector2 spacing, bool convertPosToOurs = true); CUIStatic* GetBlocker() const { return m_blocker; @@ -163,7 +163,7 @@ class CUIDragDropListEx : public CUIWindow, public CUIWndCallback return m_blocker_spacing; } - void SetConditionIndicator(CUIProgressBar* indicator); + void SetConditionIndicator(CUIProgressBar* indicator, bool convertPosToOurs = true); CUIProgressBar* GetConditionIndicator() const { return m_condition_indicator; diff --git a/src/xrGame/ui/UIDragDropReferenceList.cpp b/src/xrGame/ui/UIDragDropReferenceList.cpp index 120c142578e..a6df3b8bfdf 100644 --- a/src/xrGame/ui/UIDragDropReferenceList.cpp +++ b/src/xrGame/ui/UIDragDropReferenceList.cpp @@ -54,7 +54,7 @@ void CUIDragDropReferenceList::Initialize(pcstr labelSection /*= nullptr*/, pcst CUITextWnd* label = UIHelper::CreateTextWnd(*uiXml, temp, this, false); if (label) { - if (!label->WndPosIsProbablyRelative()) // Without this, UI Frustum will cull our label + if (true /*!label->WndPosIsProbablyRelative()*/) // Without this, UI Frustum will cull our label { const Fvector2& lblPos = label->GetWndPos(); label->SetWndPos({ lblPos.x - listAbsPos.x, lblPos.y - listAbsPos.y }); diff --git a/src/xrGame/ui/UIMainIngameWnd.cpp b/src/xrGame/ui/UIMainIngameWnd.cpp index d331c9a914a..6cc70b09a01 100644 --- a/src/xrGame/ui/UIMainIngameWnd.cpp +++ b/src/xrGame/ui/UIMainIngameWnd.cpp @@ -103,9 +103,6 @@ void CUIMainIngameWnd::Init() m_iPickUpItemIconY = UIPickUpItemIcon->GetWndRect().top; //--------------------------------------------------------- - //индикаторы - UIZoneMap->Init(); - // Подсказки, которые возникают при наведении прицела на объект UIStaticQuickHelp = UIHelper::CreateTextWnd(uiXml, "quick_info", this); @@ -207,11 +204,20 @@ void CUIMainIngameWnd::Init() UIMotionIcon = xr_new(); UIMotionIcon->SetAutoDelete(true); - const bool independent = UIMotionIcon->Init(UIZoneMap->MapFrame().GetWndRect()); - if (!independent) + const bool attachedToMinimap = UIMotionIcon->Init(); + + //индикаторы + UIZoneMap->Init(attachedToMinimap); + + if (attachedToMinimap) + { UIZoneMap->MapFrame().AttachChild(UIMotionIcon); + UIMotionIcon->AttachToMinimap(UIZoneMap->MapFrame().GetWndRect()); + } else + { AttachChild(UIMotionIcon); + } UIStaticDiskIO = UIHelper::CreateStatic(uiXml, "disk_io", this); diff --git a/src/xrGame/ui/UIMap.cpp b/src/xrGame/ui/UIMap.cpp index 69e7a7c4322..c46ed8bad00 100644 --- a/src/xrGame/ui/UIMap.cpp +++ b/src/xrGame/ui/UIMap.cpp @@ -578,8 +578,6 @@ void CUIMiniMap::Init_internal(const shared_str& name, const CInifile& pLtx, con CUIStatic::SetTextureColor(0x7fffffff); } -// XXX: examine the difference with CUILevelMap::UpdateSpots() -// maybe we need to use inherited::UpdateSpots() here when minimap is not rounded.. void CUIMiniMap::UpdateSpots() { DetachAll(); diff --git a/src/xrGame/ui/UIMotionIcon.cpp b/src/xrGame/ui/UIMotionIcon.cpp index 409d2f67929..592b1d4974a 100644 --- a/src/xrGame/ui/UIMotionIcon.cpp +++ b/src/xrGame/ui/UIMotionIcon.cpp @@ -32,32 +32,17 @@ void CUIMotionIcon::ResetVisibility() m_bchanged = true; } -bool CUIMotionIcon::Init(Frect const& zonemap_rect) +bool CUIMotionIcon::Init() { CUIXml uiXml; uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, MOTION_ICON_XML); - bool independent = false; // Not bound to minimap - if (!CUIXmlInit::InitWindow(uiXml, "window", 0, this, false)) - { - independent = CUIXmlInit::InitStatic(uiXml, "background", 0, this, false); - } - - Fvector2 sz{}; - Fvector2 pos{}; - - if (!independent) + const bool attachedToMinimap = CUIXmlInit::InitWindow(uiXml, "window", 0, this, false); + if (attachedToMinimap) + m_relative_size = uiXml.ReadAttribFlt("window", 0, "rel_size", 1.0f); + else { - const float rel_sz = uiXml.ReadAttribFlt("window", 0, "rel_size", 1.0f); - - zonemap_rect.getsize(sz); - pos.set(sz.x / 2.0f, sz.y / 2.0f); - - SetWndSize(sz); - SetWndPos(pos); - - const float k = UICore::get_current_kx(); - sz.mul(rel_sz * k); + CUIXmlInit::InitStatic(uiXml, "background", 0, this, false); } m_power_progress = UIHelper::CreateProgressBar(uiXml, "power_progress", this, false); @@ -68,29 +53,14 @@ bool CUIMotionIcon::Init(Frect const& zonemap_rect) // Allow only shape or bar, not both if (!m_luminosity_progress_bar) - { m_luminosity_progress_shape = UIHelper::CreateProgressShape(uiXml, "luminosity_progress", this, false); - if (m_luminosity_progress_shape && !independent) - { - m_luminosity_progress_shape->SetWndSize(sz); - m_luminosity_progress_shape->SetWndPos(pos); - } - } if (!m_noise_progress_bar) - { m_noise_progress_shape = UIHelper::CreateProgressShape(uiXml, "noise_progress", this, false); - if (m_noise_progress_shape && !independent) - { - m_noise_progress_shape->SetWndSize(sz); - m_noise_progress_shape->SetWndPos(pos); - } - } const auto create_static = [&uiXml, this](pcstr ui_path, EState state) { - auto ui_static = UIHelper::CreateStatic(uiXml, ui_path, this, false); - if (ui_static) + if (const auto ui_static = UIHelper::CreateStatic(uiXml, ui_path, this, false)) { m_states[state] = ui_static; ui_static->Show(false); @@ -106,7 +76,32 @@ bool CUIMotionIcon::Init(Frect const& zonemap_rect) ShowState(stNormal); - return independent; + return attachedToMinimap; +} + +void CUIMotionIcon::AttachToMinimap(const Frect& rect) +{ + Fvector2 sz{}, pos{}; + + rect.getsize(sz); + pos.set(sz.x / 2.0f, sz.y / 2.0f); + + SetWndSize(sz); + SetWndPos(pos); + + const float k = UICore::get_current_kx(); + sz.mul(m_relative_size * k); + + if (m_luminosity_progress_shape) + { + m_luminosity_progress_shape->SetWndSize(sz); + m_luminosity_progress_shape->SetWndPos(pos); + } + if (m_noise_progress_shape) + { + m_noise_progress_shape->SetWndSize(sz); + m_noise_progress_shape->SetWndPos(pos); + } } void CUIMotionIcon::ShowState(EState state) diff --git a/src/xrGame/ui/UIMotionIcon.h b/src/xrGame/ui/UIMotionIcon.h index 3ef2646c602..aec87dd46ab 100644 --- a/src/xrGame/ui/UIMotionIcon.h +++ b/src/xrGame/ui/UIMotionIcon.h @@ -38,13 +38,15 @@ class CUIMotionIcon final : public CUIStatic bool m_bchanged; float m_luminosity; float m_cur_pos; + float m_relative_size{ 1.0f }; public: CUIMotionIcon(); ~CUIMotionIcon() override; virtual void Update(); virtual void Draw(); - bool Init(Frect const& rect); + bool Init(); + void AttachToMinimap(const Frect& rect); void ShowState(EState state); void SetPower(float Pos); void SetNoise(float Pos); diff --git a/src/xrUICore/uiabstract.h b/src/xrUICore/uiabstract.h index 5ed3b17038a..0bbfd6f757a 100644 --- a/src/xrUICore/uiabstract.h +++ b/src/xrUICore/uiabstract.h @@ -54,22 +54,6 @@ class CUISimpleWindow : public Noncopyable m_wndPos.set(rect.lt); rect.getsize(m_wndSize); } - - virtual bool WndPosIsProbablyRelative() - { - return m_wndPos.x <= 1.0f && m_wndPos.y <= 1.0f; - } - - virtual bool WndSizeIsProbablyRelative() - { - return m_wndSize.x <= 1.0f && m_wndSize.y <= 1.0f; - } - - virtual bool WndRectIsProbablyRelative() - { - return WndPosIsProbablyRelative() && WndSizeIsProbablyRelative(); - } - virtual void SetHeight(float height) { m_wndSize.y = height; } IC float GetHeight() const { return m_wndSize.y; } virtual void SetWidth(float width) { m_wndSize.x = width; }