Коммит 4b1d5920 создал по автору xottab-duty's avatar xottab-duty
Просмотр файлов

Revised CUIMotionIcon and CUIMiniMap SOC/CS compatibility (#382, #392)

WndPosIsProbablyRelative is a bad function :)
владелец 1a838794
......@@ -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());
......
......@@ -3,7 +3,7 @@
#include "xrUICore/Static/UIStatic.h"
class CActor;
class CUIMiniMap;
class CUICustomMap;
class CUIZoneMap
{
......@@ -11,7 +11,7 @@ public:
bool visible{ true };
private:
CUIMiniMap* m_activeMap{};
CUICustomMap* m_activeMap{};
CUIStatic m_background{ "Background" };
CUIStatic m_center{ "Center" };
......@@ -27,7 +27,7 @@ private:
public:
virtual ~CUIZoneMap() = default;
void Init();
void Init(bool motionIconAttached);
void Render();
void Update();
......
......@@ -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);
......
......@@ -142,7 +142,7 @@ public:
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 @@ public:
}
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 @@ public:
return m_blocker_spacing;
}
void SetConditionIndicator(CUIProgressBar* indicator);
void SetConditionIndicator(CUIProgressBar* indicator, bool convertPosToOurs = true);
CUIProgressBar* GetConditionIndicator() const
{
return m_condition_indicator;
......
......@@ -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 });
......
......@@ -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<CUIMotionIcon>();
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);
......
......@@ -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();
......
......@@ -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)
......
......@@ -38,13 +38,15 @@ private:
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);
......
......@@ -54,22 +54,6 @@ public:
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; }
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать