Skip to content

Commit

Permalink
Fix icon update
Browse files Browse the repository at this point in the history
  • Loading branch information
Shtrecker committed Sep 28, 2024
1 parent 865c3d2 commit 9adbcce
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/xrGame/inventory_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ CInventoryItem::CInventoryItem()
m_custom_mark_offset.set (0.f ,0.f);
m_custom_mark_size.set (0.f ,0.f);
m_custom_mark_clr = 0;
bNeedUpdateIcon = false;
}

CInventoryItem::~CInventoryItem()
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/inventory_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class CInventoryItem :
Fvector2 m_custom_mark_size;
u32 m_custom_mark_clr;
LPCSTR m_custom_mark_lanim;
bool bNeedUpdateIcon;

SInvItemPlace m_ItemCurrPlace;

Expand Down
5 changes: 5 additions & 0 deletions src/xrGame/inventory_item_upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,13 @@ bool CInventoryItem::install_upgrade_impl( LPCSTR section, bool test )
temp_width += m_IconRect.x2;
temp_height += m_IconRect.y2;

Irect old_rect = m_IconRect;

m_IconRect.set(temp_x, temp_y, temp_width, temp_height);

if (!m_IconRect.cmp(old_rect))
bNeedUpdateIcon = true;

LPCSTR str;
result2 = process_if_exists_set( section, "immunities_sect", &CInifile::r_string, str, test );
if ( result2 && !test )
Expand Down
16 changes: 16 additions & 0 deletions src/xrGame/ui/UICellCustomItems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ void CUIInventoryCellItem::Update()
}

SetTextureColor(color);

PIItem itm = smart_cast<PIItem>((PIItem)m_pData);
if (itm != nullptr && itm->bNeedUpdateIcon)
{
itm->bNeedUpdateIcon = false;

m_grid_size.set(itm->GetInvGridRect().rb);
Frect rect;
rect.lt.set(INV_GRID_WIDTHF(EngineExternal()[EEngineExternalUI::HQIcons]) * itm->GetInvGridRect().x1,
INV_GRID_HEIGHTF(EngineExternal()[EEngineExternalUI::HQIcons]) * itm->GetInvGridRect().y1);

rect.rb.set(rect.lt.x + INV_GRID_WIDTHF(EngineExternal()[EEngineExternalUI::HQIcons]) * m_grid_size.x,
rect.lt.y + INV_GRID_HEIGHTF(EngineExternal()[EEngineExternalUI::HQIcons]) * m_grid_size.y);

inherited::SetTextureRect(rect);
}
}

void CUIInventoryCellItem::UpdateItemText()
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/ui/UIMainIngameWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,11 @@ void CUIMainIngameWnd::UpdatePickUpItem ()
shared_str sect_name = m_pPickUpItem->object().cNameSect();

//properties used by inventory menu
int m_iGridWidth = pSettings->r_u32(sect_name, "inv_grid_width");
int m_iGridHeight = pSettings->r_u32(sect_name, "inv_grid_height");
int m_iGridWidth = m_pPickUpItem->GetInvGridRect().x2;
int m_iGridHeight = m_pPickUpItem->GetInvGridRect().y2;

int m_iXPos = pSettings->r_u32(sect_name, "inv_grid_x");
int m_iYPos = pSettings->r_u32(sect_name, "inv_grid_y");
int m_iXPos = m_pPickUpItem->GetInvGridRect().x1;
int m_iYPos = m_pPickUpItem->GetInvGridRect().y1;

float scale_x = m_iPickUpItemIconWidth /
float(m_iGridWidth * INV_GRID_WIDTH(EngineExternal()[EEngineExternalUI::HQIcons]));
Expand Down

0 comments on commit 9adbcce

Please sign in to comment.