Skip to content

Commit

Permalink
xrGame/UIZoneMap.h|cpp: partial compatibility with CS (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed May 14, 2019
1 parent 402d6e2 commit 8904da0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
45 changes: 38 additions & 7 deletions src/xrGame/UIZoneMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
#include "ui/UIInventoryUtilities.h"
//////////////////////////////////////////////////////////////////////////

CUIZoneMap::CUIZoneMap() : m_current_map_idx(u8(-1)), visible(true) {}
CUIZoneMap::CUIZoneMap() : m_current_map_idx(u8(-1)), visible(true)
{
m_clock_wnd = nullptr;
m_pointerDistanceText = nullptr;
}

CUIZoneMap::~CUIZoneMap() {}

void CUIZoneMap::Init()
{
CUIXml uiXml;
Expand All @@ -29,7 +35,12 @@ void CUIZoneMap::Init()
CUIXmlInit::InitWindow(uiXml, "minimap:level_frame", 0, &m_clipFrame);
CUIXmlInit::InitStatic(uiXml, "minimap:center", 0, &m_center);

m_clock_wnd = UIHelper::CreateStatic(uiXml, "minimap:clock_wnd", &m_background);
m_clock_wnd = UIHelper::CreateStatic(uiXml, "minimap:clock_wnd", &m_background, false);

if (IsGameTypeSingle())
{
m_pointerDistanceText = UIHelper::CreateStatic(uiXml, "minimap:background:dist_text", &m_background, false);
}

m_activeMap = new CUIMiniMap();
m_clipFrame.AttachChild(m_activeMap);
Expand Down Expand Up @@ -75,9 +86,12 @@ void CUIZoneMap::Init()
rel_pos.mul(m_background.GetWndSize());
m_compass.SetWndPos(rel_pos);

rel_pos = m_clock_wnd->GetWndPos();
rel_pos.mul(m_background.GetWndSize());
m_clock_wnd->SetWndPos(rel_pos);
if (m_clock_wnd)
{
rel_pos = m_clock_wnd->GetWndPos();
rel_pos.mul(m_background.GetWndSize());
m_clock_wnd->SetWndPos(rel_pos);
}

if (IsGameTypeSingle())
{
Expand Down Expand Up @@ -129,8 +143,11 @@ void CUIZoneMap::Update()
Device.vCameraDirection.getHP(h, p);
SetHeading(-h);

m_clock_wnd->TextItemControl()->SetText(
InventoryUtilities::GetGameTimeAsString(InventoryUtilities::etpTimeToMinutes).c_str());
if (m_clock_wnd)
{
m_clock_wnd->TextItemControl()->SetText(
InventoryUtilities::GetGameTimeAsString(InventoryUtilities::etpTimeToMinutes).c_str());
}
}

void CUIZoneMap::SetHeading(float angle)
Expand All @@ -144,6 +161,20 @@ void CUIZoneMap::UpdateRadar(Fvector pos)
m_clipFrame.Update();
m_background.Update();
m_activeMap->SetActivePoint(pos);

if (m_pointerDistanceText)
{
if (m_activeMap->GetPointerDistance() > 0.5f)
{
string64 str;
xr_sprintf(str, "%.0f m", m_activeMap->GetPointerDistance());
m_pointerDistanceText->SetText(str);
}
else
{
m_pointerDistanceText->SetText("");
}
}
}

bool CUIZoneMap::ZoomIn() { return true; }
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/UIZoneMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CUIZoneMap
CUIStatic m_center;
CUIStatic m_compass;
CUIWindow m_clipFrame;
CUIStatic* m_pointerDistanceText;
CUIStatic m_Counter;
CUITextWnd m_Counter_text;
u8 m_current_map_idx;
Expand Down

0 comments on commit 8904da0

Please sign in to comment.