From 5fc07df7574b22a3d956c22ae1bdfadd4f70fe0f Mon Sep 17 00:00:00 2001 From: Sven Eberhardt Date: Sun, 7 Jan 2018 20:55:10 -0800 Subject: [PATCH] Fix dynamite stick display count within dynamite box in interaction menu. --- .../ControllerInventoryBar.ocd/Script.c | 14 ++++++++++++-- .../Items.ocd/Tools.ocd/Dynamite.ocd/Script.c | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c b/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c index 2fdd84d66..9c5e86e56 100644 --- a/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c +++ b/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c @@ -208,6 +208,7 @@ private func UpdateInventory() // Hide or show extra-slot display? var extra_slot_player = NO_OWNER; var extra_symbol = nil; + var extra_symbol_stack_count = nil; var contents = nil; var extra_slot_background_symbol = nil; if (has_extra_slot) @@ -215,7 +216,16 @@ private func UpdateInventory() // Show! contents = item->Contents(0); 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 fallback to actually stacked objects + extra_symbol_stack_count = contents->~GetStackCount(); + } + } extra_slot_player = GetOwner(); extra_slot_background_symbol = Icon_Menu_Circle; // And attach tracker.. @@ -231,11 +241,11 @@ private func UpdateInventory() } // What to display in the extra slot? var extra_text = nil, number_symbol = nil; - if (extra_symbol && contents->~GetStackCount()) + if (extra_symbol && extra_symbol_stack_count) { if (contents->IsInfiniteStackCount()) 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. diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/Dynamite.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/Dynamite.ocd/Script.c index 282537966..db5fe2ab9 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/Dynamite.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/Dynamite.ocd/Script.c @@ -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 -public func GetStackCount() +public func GetContainedDisplayStackCount() { if (Contained()) + { if (Contained()->GetID() == DynamiteBox) { return Contained()->ContentsCount(GetID()); } + } } public func IsInfiniteStackCount()