inventory bar: stack count always falls back to contained object count

Related to #1970 and 5fc07df757
This replaces the very hacky implementation just for the dynamite with a more general solution (and e.g. also works with the grenade launcher).
install-platforms
David Dormagen 2018-01-13 15:24:08 +01:00
parent 12da14d603
commit 6b797e300e
2 changed files with 5 additions and 17 deletions

View File

@ -218,12 +218,12 @@ private func UpdateInventory()
if (contents)
{
extra_symbol = contents;
// Stack count: Some contents may provide their own stack count function just for inventory display
extra_symbol_stack_count = contents->~GetContainedDisplayStackCount();
if (!GetType(extra_symbol_stack_count))
// Stack count: either actual stack count or stacked object count.
extra_symbol_stack_count = contents->~GetStackCount();
if (extra_symbol_stack_count == nil)
{
// Stack count fallback to actually stacked objects
extra_symbol_stack_count = contents->~GetStackCount();
extra_symbol_stack_count = item->ContentsCount(contents->GetID());
}
}
extra_slot_player = GetOwner();
@ -243,7 +243,7 @@ private func UpdateInventory()
var extra_text = nil, number_symbol = nil;
if (extra_symbol && extra_symbol_stack_count)
{
if (contents->IsInfiniteStackCount())
if (contents->~IsInfiniteStackCount())
number_symbol = Icon_Number;
else extra_text = Format("%dx", extra_symbol_stack_count);
}

View File

@ -84,18 +84,6 @@ public func OnFuseFinished(object fuse)
DoExplode();
}
// This will only when inside a dynamite box to display the remaining dynamite sticks in the HUD
public func GetContainedDisplayStackCount()
{
if (Contained())
{
if (Contained()->GetID() == DynamiteBox)
{
return Contained()->ContentsCount(GetID());
}
}
}
public func IsInfiniteStackCount()
{
return false;