Fix dynamite stick display count within dynamite box in interaction menu.

install-platforms
Sven Eberhardt 2018-01-07 20:55:10 -08:00
parent ebd2eeae4b
commit 5fc07df757
2 changed files with 15 additions and 3 deletions

View File

@ -208,6 +208,7 @@ private func UpdateInventory()
// Hide or show extra-slot display? // Hide or show extra-slot display?
var extra_slot_player = NO_OWNER; var extra_slot_player = NO_OWNER;
var extra_symbol = nil; var extra_symbol = nil;
var extra_symbol_stack_count = nil;
var contents = nil; var contents = nil;
var extra_slot_background_symbol = nil; var extra_slot_background_symbol = nil;
if (has_extra_slot) if (has_extra_slot)
@ -215,7 +216,16 @@ private func UpdateInventory()
// Show! // Show!
contents = item->Contents(0); contents = item->Contents(0);
if (contents) if (contents)
{
extra_symbol = 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 fallback to actually stacked objects
extra_symbol_stack_count = contents->~GetStackCount();
}
}
extra_slot_player = GetOwner(); extra_slot_player = GetOwner();
extra_slot_background_symbol = Icon_Menu_Circle; extra_slot_background_symbol = Icon_Menu_Circle;
// And attach tracker.. // And attach tracker..
@ -231,11 +241,11 @@ private func UpdateInventory()
} }
// What to display in the extra slot? // What to display in the extra slot?
var extra_text = nil, number_symbol = nil; var extra_text = nil, number_symbol = nil;
if (extra_symbol && contents->~GetStackCount()) if (extra_symbol && extra_symbol_stack_count)
{ {
if (contents->IsInfiniteStackCount()) if (contents->IsInfiniteStackCount())
number_symbol = Icon_Number; number_symbol = Icon_Number;
else extra_text = Format("%dx", contents->GetStackCount()); else extra_text = Format("%dx", extra_symbol_stack_count);
} }
// Close a possible lingering custom overlay for that slot. // Close a possible lingering custom overlay for that slot.

View File

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