Skip to content

Commit

Permalink
= fixed inventory cell items not updating progress bar
Browse files Browse the repository at this point in the history
= Corrected some issues with Axel's feature
  • Loading branch information
revolucas authored and Xottab-DUTY committed Dec 16, 2017
1 parent afc85df commit 218dacf
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/xrGame/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,9 +1075,12 @@ bool CInventory::Eat(PIItem pIItem)

if (pItemToEat->CanDelete())
{
pIItem->SetDropManual(TRUE);
return false;
if (!pItemToEat->CanDelete())
return false;

pIItem->SetDropManual(true);
}

return true;
}

Expand Down
8 changes: 7 additions & 1 deletion src/xrGame/alife_trader_abstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,14 @@ void add_online_impl(CSE_ALifeDynamicObject* object, const bool& update_registri
//-Alundaio

CSE_ALifeDynamicObject* l_tpALifeDynamicObject = ai().alife().objects().object(*I);
if (!l_tpALifeDynamicObject)
continue;

CSE_ALifeInventoryItem* l_tpALifeInventoryItem = smart_cast<CSE_ALifeInventoryItem*>(l_tpALifeDynamicObject);
R_ASSERT2(l_tpALifeInventoryItem, "Non inventory item object has parent?!");
if (!l_tpALifeInventoryItem)
continue;

//R_ASSERT2(l_tpALifeInventoryItem, "Non inventory item object has parent?!");
l_tpALifeInventoryItem->base()->s_flags.or (M_SPAWN_UPDATE);
CSE_Abstract* l_tpAbstract = smart_cast<CSE_Abstract*>(l_tpALifeInventoryItem);
object->alife().server().entity_Destroy(l_tpAbstract);
Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/eatable_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ bool CEatableItem::UseBy(CEntityAlive* entity_alive)
m_iRemainingUses = 0;

SetCondition((float)m_iRemainingUses / (float)m_iMaxUses);
CurrentGameUI()->HideActorMenu();
CurrentGameUI()->ShowActorMenu();

return true;
}
6 changes: 5 additions & 1 deletion src/xrGame/ui/UIActorMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ class CUIActorMenu : public CUIDialogWnd, public CUIWndCallback
void BindDragDropListEvents(CUIDragDropListEx* lst);

EDDListType GetListType(CUIDragDropListEx* l);
CUIDragDropListEx* GetListByType(EDDListType t);

public:
CUIDragDropListEx* GetListByType(EDDListType t); //Alundaio: Make public

protected:
CUIDragDropListEx* GetSlotList(u16 slot_idx);
bool CanSetItemToList(PIItem item, CUIDragDropListEx* l, u16& ret_slot);

Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/ui/UIActorMenuInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,9 @@ bool CUIActorMenu::TryUseItem(CUICellItem* cell_itm)
{
return false;
}

cell_itm->UpdateConditionProgressBar(); //Alundaio

u16 recipient = m_pActorInvOwner->object_id();
if (item->parent_id() != recipient)
{
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ui/UIActorMenu_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ bool CUIActorMenu::OnItemDrop(CUICellItem* itm)

OnItemDropped(CurrentIItem(), new_owner, old_owner);

UpdateItemsPlace();
UpdateConditionProgressBars();
UpdateItemsPlace();

return true;
}
Expand Down Expand Up @@ -232,8 +232,8 @@ bool CUIActorMenu::OnItemDbClick(CUICellItem* itm)

}; // switch

UpdateItemsPlace();
UpdateConditionProgressBars();
UpdateItemsPlace();

return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/ui/UICellCustomItems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void CUIInventoryCellItem::SetIsHelper(bool is_helper) { object()->set_is_helper
void CUIInventoryCellItem::Update()
{
inherited::Update();
inherited:UpdateConditionProgressBar(); //Alundaio
UpdateItemText();

u32 color = GetTextureColor();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ui/UICellItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void CUICellItem::UpdateConditionProgressBar()
m_pConditionState->ShowBackground(false);
}

m_pConditionState->m_bUseColor = false;
m_pConditionState->m_bNoLerp = true;
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/xrGame/ui/UIProgressBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CUIProgressBar::CUIProgressBar(void)

m_bBackgroundPresent = false;
m_bUseColor = false;
m_bNoLerp = false; //Alundaio

AttachChild(&m_UIBackgroundItem);
AttachChild(&m_UIProgressItem);
Expand Down Expand Up @@ -53,6 +54,12 @@ void CUIProgressBar::UpdateProgressBar()

if (m_bUseColor)
{
if (m_bNoLerp)
{
m_UIProgressItem.SetTextureColor(m_maxColor.get());
return;
}

Fcolor curr;
curr.lerp(m_minColor, m_middleColor, m_maxColor, fCurrentLength);
m_UIProgressItem.SetTextureColor(curr.get());
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/ui/UIProgressBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class CUIProgressBar : public CUIWindow

public:
bool m_bUseColor;
bool m_bNoLerp; //Alundaio: use only solid color with m_maxColor
Fcolor m_minColor;
Fcolor m_middleColor;
Fcolor m_maxColor;
float m_inertion; //

public:
CUIStatic m_UIProgressItem;
CUIStatic m_UIBackgroundItem;
Expand Down

0 comments on commit 218dacf

Please sign in to comment.