Skip to content

Commit

Permalink
Work on SOC PDA UI (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Mar 31, 2022
1 parent c580383 commit 5bd41bb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/xrGame/ui/UIMapWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool CUIMapWnd::Init(cpcstr xml_name, cpcstr start_from, bool critical /*= true*
AddCallback(m_UIMainScrollV, SCROLLBAR_VSCROLL, CUIWndCallback::void_function(this, &CUIMapWnd::OnScrollV));
}

init_xml_nav(uiXml);
init_xml_nav(uiXml, start_from, critical);

m_map_location_hint = xr_new<CUIMapLocationHint>();
m_map_location_hint->SetAutoDelete(false);
Expand Down Expand Up @@ -362,7 +362,8 @@ void CUIMapWnd::Draw()
m_dbg_info->Draw ();
#endif // DEBUG */

m_btn_nav_parent->Draw();
if (m_btn_nav_parent)
m_btn_nav_parent->Draw();
}

void CUIMapWnd::MapLocationRelcase(CMapLocation* ml)
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ui/UIMapWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CUIMapWnd : public CUIWindow, public CUIWndCallback
btn_zoom_reset = 8,
max_btn_nav = 9
};
CUI3tButton* m_btn_nav[max_btn_nav];
CUI3tButton* m_btn_nav[max_btn_nav]{};
CUIStatic* m_btn_nav_parent;
u32 m_nav_timing;

Expand Down Expand Up @@ -106,7 +106,7 @@ class CUIMapWnd : public CUIWindow, public CUIWndCallback
UIHint* hint_wnd;

protected:
void init_xml_nav(CUIXml& xml);
void init_xml_nav(CUIXml& xml, pcstr start_from, bool critical);
void ShowHint(bool extra = false);
void Activated();

Expand Down
40 changes: 27 additions & 13 deletions src/xrGame/ui/UIMapWnd2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@
#include "UIHelper.h"
#include "UITaskWnd.h"

void CUIMapWnd::init_xml_nav(CUIXml& xml)
void CUIMapWnd::init_xml_nav(CUIXml& xml, pcstr start_from, bool critical)
{
m_btn_nav_parent = UIHelper::CreateStatic(xml, "btn_nav_parent", this);
m_btn_nav_parent = UIHelper::CreateStatic(xml, "btn_nav_parent", this, critical);

VERIFY(hint_wnd);
if (m_btn_nav_parent)
{
VERIFY(hint_wnd);
for (u8 i = 0; i < max_btn_nav; ++i)
{
string64 buf;
xr_sprintf(buf, "btn_nav_parent:btn_nav_%d", i);

string64 buf;
for (u8 i = 0; i < max_btn_nav; ++i)
m_btn_nav[i] = UIHelper::Create3tButton(xml, buf, m_btn_nav_parent);
Register(m_btn_nav[i]);
//. m_btn_nav[i]->set_hint_wnd( hint_wnd );
}
}
else // Shadow of Chernobyl
{
xr_sprintf(buf, "btn_nav_parent:btn_nav_%d", i);
string512 pth;
strconcat(pth, start_from, ":main_wnd:map_header_frame_line:tool_bar");

m_btn_nav[i] = UIHelper::Create3tButton(xml, buf, m_btn_nav_parent);
Register(m_btn_nav[i]);
//. m_btn_nav[i]->set_hint_wnd( hint_wnd );
string512 temp;
m_btn_nav[btn_zoom_reset] = UIHelper::Create3tButton(xml, strconcat(temp, pth, ":global_map_btn"), m_UIMainMapHeader, false);
m_btn_nav[btn_actor] = UIHelper::Create3tButton(xml, strconcat(temp, pth, ":actor_btn" ), m_UIMainMapHeader, false);
m_btn_nav[btn_zoom_more] = UIHelper::Create3tButton(xml, strconcat(temp, pth, ":zoom_in_btn" ), m_UIMainMapHeader, false);
m_btn_nav[btn_zoom_less] = UIHelper::Create3tButton(xml, strconcat(temp, pth, ":zoom_out_btn" ), m_UIMainMapHeader, false);
}

AddCallback(m_btn_nav[btn_legend], BUTTON_DOWN, CUIWndCallback::void_function(this, &CUIMapWnd::OnBtnLegend_Push));
Expand Down Expand Up @@ -50,21 +63,22 @@ void CUIMapWnd::UpdateNav()
}
m_nav_timing = Device.dwTimeGlobal;

if (m_btn_nav[btn_up]->CursorOverWindow() && m_btn_nav[btn_up]->GetButtonState() == CUIButton::BUTTON_PUSHED)
if (m_btn_nav[btn_up] && m_btn_nav[btn_up]->CursorOverWindow() &&
m_btn_nav[btn_up]->GetButtonState() == CUIButton::BUTTON_PUSHED)
{
MoveMap(Fvector2().set(0.0f, m_map_move_step));
}
else if (m_btn_nav[btn_left]->CursorOverWindow() &&
else if (m_btn_nav[btn_left] && m_btn_nav[btn_left]->CursorOverWindow() &&
m_btn_nav[btn_left]->GetButtonState() == CUIButton::BUTTON_PUSHED)
{
MoveMap(Fvector2().set(m_map_move_step, 0.0f));
}
else if (m_btn_nav[btn_right]->CursorOverWindow() &&
else if (m_btn_nav[btn_right] && m_btn_nav[btn_right]->CursorOverWindow() &&
m_btn_nav[btn_right]->GetButtonState() == CUIButton::BUTTON_PUSHED)
{
MoveMap(Fvector2().set(-m_map_move_step, 0.0f));
}
else if (m_btn_nav[btn_down]->CursorOverWindow() &&
else if (m_btn_nav[btn_down] && m_btn_nav[btn_down]->CursorOverWindow() &&
m_btn_nav[btn_down]->GetButtonState() == CUIButton::BUTTON_PUSHED)
{
MoveMap(Fvector2().set(0.0f, -m_map_move_step));
Expand Down
9 changes: 6 additions & 3 deletions src/xrGame/ui/UIPdaWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ CUIPdaWnd::~CUIPdaWnd()
if (pUILogsWnd)
delete_data(pUILogsWnd);
delete_data(m_hint_wnd);
delete_data(UINoice);
if (UINoice)
delete_data(UINoice);
}

void CUIPdaWnd::Init()
Expand Down Expand Up @@ -126,7 +127,8 @@ void CUIPdaWnd::Init()

UINoice = xr_new<CUIStatic>();
UINoice->SetAutoDelete(true);
CUIXmlInit::InitStatic(uiXml, "noice_static", 0, UINoice);
if (!CUIXmlInit::InitStatic(uiXml, "noice_static", 0, UINoice, false))
xr_delete(UINoice);

// XXX: dynamically determine if we need to rearrange the tabs
if (ClearSkyMode)
Expand Down Expand Up @@ -298,7 +300,8 @@ void CUIPdaWnd::Draw()
inherited::Draw();
//. DrawUpdatedSections();
DrawHint();
UINoice->Draw(); // over all
if (UINoice)
UINoice->Draw(); // over all
}

void CUIPdaWnd::DrawHint()
Expand Down

0 comments on commit 5bd41bb

Please sign in to comment.