Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
fix bug when level changing
  • Loading branch information
Amx545 committed Jun 16, 2024
1 parent e14b5b7 commit ac865df
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 49 deletions.
118 changes: 69 additions & 49 deletions src/xrGame/ui/UIBoostStatesWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)
xml.SetLocalRoot(stored_root);
}

void CUIBoostStatesWnd::DrawBoosterIndicators()
void CUIBoostStatesWnd::DrawBoosterIndicators()
{
for (const auto& Iter : m_ind_boost_state)
if (m_ind_boost_pos.empty())
return;
for (const auto& [type, Item] : m_ind_boost_state)
{
if (Iter.second && Iter.second->IsShown())
if (Item && Item->IsShown())
{
Iter.second->Update();
Iter.second->Draw();
Item->Update();
Item->Draw();
}
}
}
Expand All @@ -66,90 +68,108 @@ void CUIBoostStatesWnd::UpdateBoosterIndicators(const CEntityCondition::BOOSTER_
flags |= LA_ONLYALPHA;
flags |= LA_TEXTURECOLOR;

for (const auto& [type, item] : m_ind_boost_state)
for (const auto& [type, Item] : m_ind_boost_state)
{
if (influences.empty())
{
item->Show(false);
Item->Show(false);
continue;
}
CEntityCondition::BOOSTER_MAP::const_iterator It = influences.find(type);
if (It != influences.end())
{
if (!item->IsShown())
if (!Item->IsShown())
{
m_ind_boost_pos.push_back(type);
item->Show(true);
Item->Show(true);
}
if (It->second.fBoostTime <= 3.0f)
{
item->SetColorAnimation(str_flag, flags);
Item->SetColorAnimation(str_flag, flags);
}
else
{
item->ResetColorAnimation();
Item->ResetColorAnimation();
}
}
else
{
item->Show(false);
Item->Show(false);
}
}
if(!influences.empty() || !m_ind_boost_pos.empty())
{
UpdateBoosterPosition(influences);
}
}

if (!m_ind_boost_pos.empty())
void CUIBoostStatesWnd::UpdateBoosterPosition(const CEntityCondition::BOOSTER_MAP& influences)
{
if (m_ind_boost_pos.empty() && !influences.empty())
{
for (const auto& [type, Item] : m_ind_boost_state)
{
if (Item && Item->IsShown())
{
Item->Show(false);
}
}
}
if (m_ind_boost_pos.empty())
return;
u8 i = 0, j = 0, max = max_item - 1;
if (bInverse)
{
u8 i = 0,j = 0,max = max_item - 1;
if (bInverse)
for (auto It = m_ind_boost_pos.end() - 1; It >= m_ind_boost_pos.begin(); It--)
{
for (auto It = m_ind_boost_pos.end() - 1; It >= m_ind_boost_pos.begin(); It--)
xr_map<EBoostParams, CUIStatic*>::const_iterator Item = m_ind_boost_state.find(*It);
if (Item->second->IsShown())
{
if (m_ind_boost_state[*It]->IsShown())
(bHorizontal ? Item->second->SetWndPos({dx * i, dy * j}) :
Item->second->SetWndPos({dx * j, dy * i}));
if (i >= max_item)
{
(bHorizontal ? m_ind_boost_state[*It]->SetWndPos({dx * i, dy * j}) :
m_ind_boost_state[*It]->SetWndPos({dx * j, dy * i}));
if (i >= max_item)
{
i = 0;
j++;
}
else
{
i++;
}
m_ind_boost_state[*It]->Update();
m_ind_boost_state[*It]->Draw();
i = 0;
j++;
}
else
{
m_ind_boost_pos.erase(It);
i++;
}
Item->second->Update();
Item->second->Draw();
}
else
{
m_ind_boost_pos.erase(It);
}
}
else
}
else
{
for (auto It = m_ind_boost_pos.begin(); It != m_ind_boost_pos.end(); It++)
{
for (auto It = m_ind_boost_pos.begin(); It != m_ind_boost_pos.end(); It++)
xr_map<EBoostParams, CUIStatic*>::const_iterator Item = m_ind_boost_state.find(*It);
if (Item->second->IsShown())
{
if (m_ind_boost_state[*It]->IsShown())
(bHorizontal ? Item->second->SetWndPos({dx * i, dy * j}) :
Item->second->SetWndPos({dx * j, dy * i}));
if (i >= max)
{
(bHorizontal ? m_ind_boost_state[*It]->SetWndPos({dx * i, dy * j}) :
m_ind_boost_state[*It]->SetWndPos({dx * j, dy * i}));
if (i >= max)
{
i = 0;
j++;
}
else
{
i++;
}
m_ind_boost_state[*It]->Update();
m_ind_boost_state[*It]->Draw();
i = 0;
j++;
}
else
{
m_ind_boost_pos.erase(It);
It--;
i++;
}
Item->second->Update();
Item->second->Draw();
}
else
{
m_ind_boost_pos.erase(It);
It--;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/ui/UIBoostStatesWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CUIBoostStatesWnd final : public CUIWindow
void InitFromXml(CUIXml& xml, LPCSTR path);
void DrawBoosterIndicators();
void UpdateBoosterIndicators(const CEntityCondition::BOOSTER_MAP& influences);
void UpdateBoosterPosition(const CEntityCondition::BOOSTER_MAP& influences);

private:
bool bHorizontal, bInverse;
Expand Down

0 comments on commit ac865df

Please sign in to comment.