Skip to content

Commit

Permalink
Ability to unload all weapons in inventory via context menu. (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dx74rghs authored and Xottab-DUTY committed Sep 5, 2019
1 parent c7d2e67 commit 455781b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions res/gamedata/configs/text/eng/openxray.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="windows-1251" ?>
<string_table>
<string id="st_unload_magazine_all">
<text>unload all weapons</text>
</string>
<string id="st_unequip">
<text>unequip</text>
</string>
Expand Down
3 changes: 3 additions & 0 deletions res/gamedata/configs/text/pol/openxray.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="windows-1251" ?>
<string_table>
<string id="st_unload_magazine_all">
<text>roz豉duj wszystkie bronie</text>
</string>
<string id="st_unequip">
<text>Zdejmij</text>
</string>
Expand Down
3 changes: 3 additions & 0 deletions res/gamedata/configs/text/rus/openxray.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="windows-1251" ?>
<string_table>
<string id="st_unload_magazine_all">
<text>ðàçðÿäèòü âñ¸ îðóæèå</text>
</string>
<string id="st_unequip">
<text>óáðàòü â ðþêçàê</text>
</string>
Expand Down
25 changes: 25 additions & 0 deletions src/xrGame/ui/UIActorMenuInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ void CUIActorMenu::PropertiesBoxForWeapon(CUICellItem* cell_item, PIItem item, b
if (b)
{
m_UIPropertiesBox->AddItem("st_unload_magazine", NULL, INVENTORY_UNLOAD_MAGAZINE);
m_UIPropertiesBox->AddItem("st_unload_magazine_all", NULL, INVENTORY_UNLOAD_MAGAZINE_ALL);
b_show = true;
}
}
Expand Down Expand Up @@ -1413,6 +1414,30 @@ void CUIActorMenu::ProcessPropertiesBoxClicked(CUIWindow* w, void* d)
}
break;
}
case INVENTORY_UNLOAD_MAGAZINE_ALL:
{
u32 const ci_count = m_pInventoryBagList->ItemsCount();
for (u32 i = 0; i < ci_count; ++i)
{
CUICellItem* ci = m_pInventoryBagList->GetItemIdx(i);
VERIFY(ci);
CWeaponMagazined* weap_mag = smart_cast<CWeaponMagazined*>((CWeapon*)ci->m_pData);
if (weap_mag)
{
weap_mag->UnloadMagazine();
for (u32 i = 0; i < ci->ChildsCount(); ++i)
{
CUICellItem* child_itm = ci->Child(i);
CWeaponMagazined* child_weap_mag = smart_cast<CWeaponMagazined*>((CWeapon*)child_itm->m_pData);
if (child_weap_mag)
{
child_weap_mag->UnloadMagazine();
}
}
}
}
break;
}
case INVENTORY_REPAIR:
{
TryRepairItem(this, 0);
Expand Down
1 change: 1 addition & 0 deletions src/xrUICore/UIMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ enum EUIMessages

INVENTORY_RELOAD_MAGAZINE,
INVENTORY_UNLOAD_MAGAZINE,
INVENTORY_UNLOAD_MAGAZINE_ALL,
INVENTORY_SELL_ITEM,

// CUIAnimationBase
Expand Down

0 comments on commit 455781b

Please sign in to comment.