Skip to content

Commit

Permalink
Implement move to and move all buttons
Browse files Browse the repository at this point in the history
For #58 pr
  • Loading branch information
Hozar2002 committed Aug 1, 2024
1 parent 5e9d529 commit 59a8726
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gamedata/configs/ui/actor_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
</text_color>
</takeall_button>

<putall_button x="699" y="695" width="312" height="24" stretch="1" hint="ui_st_put_all_hint">
<putall_button x="699" y="695" width="312" height="24" accel="klcontrol" stretch="1" hint="ui_st_put_all_hint">
<window_name>putall_button</window_name>
<texture>ui_inGame2_big_inventory_button</texture>
<text font="graffiti22" align="c">ui_st_put_all</text>
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/ui/actor_menu_16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
</text_color>
</takeall_button>

<putall_button x="662" y="694" width="248" height="24" stretch="1" hint="ui_st_put_all_hint">
<putall_button x="662" y="694" width="248" height="24" accel="klcontrol" stretch="1" hint="ui_st_put_all_hint">
<window_name>putall_button</window_name>
<texture>ui_inGame2_big_inventory_button</texture>
<text font="graffiti22" align="c">ui_st_put_all</text>
Expand Down
56 changes: 40 additions & 16 deletions src/xrGame/ui/UIActorMenuInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "../PDA.h"

#include "../actor_defs.h"
#include "../InventoryBox.h"


void move_item_from_to(u16 from_id, u16 to_id, u16 what_id);
Expand Down Expand Up @@ -854,8 +855,7 @@ void CUIActorMenu::ActivatePropertiesBox()
PropertiesBoxForAddon( item, b_show );
PropertiesBoxForUsing( item, b_show );
PropertiesBoxForPlaying(item, b_show);
if ( m_currMenuMode == mmInventory )
PropertiesBoxForDrop( cell_item, item, b_show );
PropertiesBoxForDrop(cell_item, item, b_show);
}
//else if ( m_currMenuMode == mmDeadBodySearch )
//{
Expand Down Expand Up @@ -995,7 +995,7 @@ void CUIActorMenu::PropertiesBoxForWeapon( CUICellItem* cell_item, PIItem item,
}
if ( b )
{
m_UIPropertiesBox->AddItem( "st_unload_magazine", nullptr, INVENTORY_UNLOAD_MAGAZINE );
m_UIPropertiesBox->AddItem("st_unload_magazine", nullptr, INVENTORY_UNLOAD_MAGAZINE);
b_show = true;
}
}
Expand Down Expand Up @@ -1116,16 +1116,27 @@ void CUIActorMenu::PropertiesBoxForPlaying(PIItem item, bool& b_show)
b_show = true;
}

void CUIActorMenu::PropertiesBoxForDrop( CUICellItem* cell_item, PIItem item, bool& b_show )
void CUIActorMenu::PropertiesBoxForDrop(CUICellItem* cell_item, PIItem item, bool& b_show)
{
if ( !item->IsQuestItem() )
if(!item->IsQuestItem())
{
m_UIPropertiesBox->AddItem( "st_drop", nullptr, INVENTORY_DROP_ACTION );
b_show = true;
if(m_currMenuMode != mmDeadBodySearch) {
m_UIPropertiesBox->AddItem("st_drop", nullptr, INVENTORY_DROP_ACTION);
b_show = true;

if ( cell_item->ChildsCount() )
{
m_UIPropertiesBox->AddItem( "st_drop_all", (void*)33, INVENTORY_DROP_ACTION );
if(cell_item->ChildsCount()) {
m_UIPropertiesBox->AddItem("st_drop_all", (void*)33, INVENTORY_DROP_ACTION);
}
}
else {
if(item->parent_id() == m_pActorInvOwner->object_id()) {
m_UIPropertiesBox->AddItem("st_move_to", nullptr, INVENTORY_DROP_ACTION);
b_show = true;

if(cell_item->ChildsCount()) {
m_UIPropertiesBox->AddItem("st_move_all", (void*)33, INVENTORY_DROP_ACTION);
}
}
}
}
}
Expand Down Expand Up @@ -1162,13 +1173,26 @@ void CUIActorMenu::ProcessPropertiesBoxClicked( CUIWindow* w, void* d )
case INVENTORY_DROP_ACTION:
{
void* d_ = m_UIPropertiesBox->GetClickedItem()->GetData();
if ( d_ == (void*)33 )
{
DropAllCurrentItem();
if(m_currMenuMode != mmDeadBodySearch) {
if(d_ == (void*)33) {
DropAllCurrentItem();
}
else {
SendEvent_Item_Drop(item, m_pActorInvOwner->object_id());
}
}
else
{
SendEvent_Item_Drop( item, m_pActorInvOwner->object_id() );
else {
auto ownerID = m_pPartnerInvOwner ? m_pPartnerInvOwner->object_id() : m_pInvBox->ID();

if(d_ == (void*)33) {
for(u32 i = 0; i < cell_item->ChildsCount(); ++i) {
CUICellItem* child_itm = cell_item->Child(i);
PIItem child_iitm = (PIItem)(child_itm->m_pData);
move_item_from_to(item->parent_id(), ownerID, child_iitm->object_id());
}
}

move_item_from_to(item->parent_id(), ownerID, item->object_id());
}
break;
}
Expand Down

0 comments on commit 59a8726

Please sign in to comment.