Skip to content

Commit 801239f

Browse files
AxelDominatoRXottab-DUTY
authored andcommitted
Various fixes plus progress bars are now green
Fixed various issues with the multiple item uses and now the progress bars are green. Also fixed a few issues with the hotbar and progressbar background
1 parent 218dacf commit 801239f

File tree

8 files changed

+61
-8
lines changed

8 files changed

+61
-8
lines changed

src/xrGame/Inventory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ bool CInventory::Eat(PIItem pIItem)
10731073
if (IsGameTypeSingle() && Actor()->m_inventory == this)
10741074
Actor()->callback(GameObject::eUseObject)((smart_cast<CGameObject*>(pIItem))->lua_game_object());
10751075

1076-
if (pItemToEat->CanDelete())
1076+
if (pItemToEat->Empty())
10771077
{
10781078
if (!pItemToEat->CanDelete())
10791079
return false;

src/xrGame/eatable_item.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "EntityCondition.h"
1616
#include "InventoryOwner.h"
1717
#include "UIGameCustom.h"
18+
#include "ui/UIActorMenu.h"
1819

1920
CEatableItem::CEatableItem()
2021
{
@@ -137,6 +138,7 @@ bool CEatableItem::UseBy(CEntityAlive* entity_alive)
137138
m_iRemainingUses = 0;
138139

139140
SetCondition((float)m_iRemainingUses / (float)m_iMaxUses);
141+
CurrentGameUI()->GetActorMenu().RefreshConsumableCells();
140142

141143
return true;
142144
}

src/xrGame/eatable_item.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CEatableItem : public CInventoryItem
3333
virtual void OnH_A_Independent();
3434
virtual bool UseBy(CEntityAlive* npc);
3535
virtual bool Empty() const { return m_iRemainingUses == 0; }
36-
bool CanDelete() const { return Empty() && m_bRemoveAfterUse == true; }
36+
bool CanDelete() const { return m_bRemoveAfterUse == true; }
3737
virtual u16 GetMaxUses() const { return m_iMaxUses; }
3838
virtual u16 GetRemainingUses() const { return m_iRemainingUses; }
3939
};

src/xrGame/ui/UIActorMenu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class CUIActorMenu : public CUIDialogWnd, public CUIWndCallback
8888
CUICellItem* m_InfoCellItem;
8989
u32 m_InfoCellItem_timer;
9090
CUICellItem* m_pCurrentCellItem;
91+
CUICellItem* m_pCurrentConsumable;
9192
CUICellItem* m_upgrade_selected;
9293
CUIPropertiesBox* m_UIPropertiesBox;
9394

@@ -354,4 +355,8 @@ class CUIActorMenu : public CUIDialogWnd, public CUIWndCallback
354355
void UpdateConditionProgressBars();
355356

356357
IC UIHint* get_hint_wnd() { return m_hint_wnd; }
358+
359+
CUICellItem* GetCurrentConsumable() { return m_pCurrentConsumable; };
360+
void SetCurrentConsumable(CUICellItem* ci) { m_pCurrentConsumable = ci; };
361+
void RefreshConsumableCells();
357362
}; // class CUIActorMenu

src/xrGame/ui/UIActorMenuInventory.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,12 @@ void CUIActorMenu::ProcessPropertiesBoxClicked(CUIWindow* w, void* d)
11291129
case INVENTORY_TO_SLOT_ACTION: ToSlot(cell_item, true, item->BaseSlot()); break;
11301130
case INVENTORY_TO_BELT_ACTION: ToBelt(cell_item, false); break;
11311131
case INVENTORY_TO_BAG_ACTION: ToBag(cell_item, false); break;
1132-
case INVENTORY_EAT_ACTION: TryUseItem(cell_item); break;
1132+
1133+
case INVENTORY_EAT_ACTION:
1134+
CurrentGameUI()->GetActorMenu().SetCurrentConsumable(cell_item);
1135+
TryUseItem(cell_item);
1136+
break;
1137+
11331138
case INVENTORY_DROP_ACTION:
11341139
{
11351140
void* d = m_UIPropertiesBox->GetClickedItem()->GetData();
@@ -1291,3 +1296,33 @@ void CUIActorMenu::MoveArtefactsToBag()
12911296
} // for i
12921297
m_pInventoryBeltList->ClearAll(true);
12931298
}
1299+
1300+
void CUIActorMenu::RefreshConsumableCells()
1301+
{
1302+
CUICellItem* ci = GetCurrentConsumable();
1303+
if (ci)
1304+
{
1305+
CEatableItem* eitm = smart_cast<CEatableItem*>((CEatableItem*)ci->m_pData);
1306+
if (eitm)
1307+
{
1308+
Fvector2 cp = GetUICursor().GetCursorPosition(); // XXX: This is unused
1309+
CUIDragDropListEx* invlist = GetListByType(iActorBag);
1310+
1311+
CUICellItem* parent = invlist->RemoveItem(ci, true);
1312+
const u32 c = parent->ChildsCount();
1313+
if (c > 0)
1314+
{
1315+
while (parent->ChildsCount())
1316+
{
1317+
CUICellItem* child = parent->PopChild(nullptr);
1318+
invlist->SetItem(child);
1319+
}
1320+
1321+
invlist->SetItem(parent);
1322+
}
1323+
else
1324+
invlist->SetItem(parent);
1325+
}
1326+
SetCurrentConsumable(nullptr);
1327+
}
1328+
}

src/xrGame/ui/UICellItem.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "Weapon.h"
1414
#include "CustomOutfit.h"
1515
#include "ActorHelmet.h"
16+
#include "UIGameCustom.h"
17+
#include "UIActorMenu.h"
1618

1719
CUICellItem* CUICellItem::m_mouse_selected_item = NULL;
1820

@@ -145,6 +147,7 @@ bool CUICellItem::OnMouseAction(float x, float y, EUIMessages mouse_action)
145147
else if (mouse_action == WINDOW_LBUTTON_DB_CLICK)
146148
{
147149
GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_DB_CLICK, NULL);
150+
CurrentGameUI()->GetActorMenu().SetCurrentConsumable(this);
148151
return true;
149152
}
150153
else if (mouse_action == WINDOW_RBUTTON_DOWN)
@@ -222,12 +225,13 @@ void CUICellItem::UpdateConditionProgressBar()
222225
else if (max_uses > 8)
223226
cond = (float)remaining_uses / (float)max_uses;
224227
else
225-
{
226228
cond = (float)remaining_uses * 0.125f - 0.0625f;
229+
230+
if (max_uses < 8)
227231
m_pConditionState->ShowBackground(false);
228-
}
229232

230233
m_pConditionState->m_bNoLerp = true;
234+
m_pConditionState->m_bUseGradient = false;
231235
}
232236
}
233237

src/xrGame/ui/UIProgressBar.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CUIProgressBar::CUIProgressBar(void)
1010

1111
m_bBackgroundPresent = false;
1212
m_bUseColor = false;
13+
m_bUseGradient = true;
1314
m_bNoLerp = false; //Alundaio
1415

1516
AttachChild(&m_UIBackgroundItem);
@@ -60,9 +61,14 @@ void CUIProgressBar::UpdateProgressBar()
6061
return;
6162
}
6263

63-
Fcolor curr;
64-
curr.lerp(m_minColor, m_middleColor, m_maxColor, fCurrentLength);
65-
m_UIProgressItem.SetTextureColor(curr.get());
64+
if ( m_bUseGradient )
65+
{
66+
Fcolor curr;
67+
curr.lerp(m_minColor, m_middleColor, m_maxColor, fCurrentLength);
68+
m_UIProgressItem.SetTextureColor(curr.get());
69+
}
70+
else
71+
m_UIProgressItem.SetTextureColor( m_maxColor.get());
6672
}
6773
}
6874

src/xrGame/ui/UIProgressBar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class CUIProgressBar : public CUIWindow
3232

3333
public:
3434
bool m_bUseColor;
35+
bool m_bUseGradient;
3536
bool m_bNoLerp; //Alundaio: use only solid color with m_maxColor
3637
Fcolor m_minColor;
3738
Fcolor m_middleColor;

0 commit comments

Comments
 (0)