From 3d963a2ad6249934d851f7b50cb60bcf17935286 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sun, 12 Nov 2023 05:53:26 +0100 Subject: [PATCH] fixes --- media/lua/client/TOC/CommonMethods.lua | 6 ++++++ .../lua/client/TOC/UI/CutLimbInteractions.lua | 21 +++++++++++-------- media/lua/client/TOC/UI/HealthPanel.lua | 5 ++++- .../client/TOC/UI/HealthPanelBaseHandler.lua | 6 +++++- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/media/lua/client/TOC/CommonMethods.lua b/media/lua/client/TOC/CommonMethods.lua index 860e410..22f626e 100644 --- a/media/lua/client/TOC/CommonMethods.lua +++ b/media/lua/client/TOC/CommonMethods.lua @@ -7,4 +7,10 @@ function CommonMethods.GetSide(name) if string.find(name, "_L") then return "L" else return "R" end end +---comment +---@param bodyPart BodyPart +function CommonMethods.GetLimbNameFromBodyPart(bodyPart) + local bodyPartType = bodyPart:getType() + +end return CommonMethods \ No newline at end of file diff --git a/media/lua/client/TOC/UI/CutLimbInteractions.lua b/media/lua/client/TOC/UI/CutLimbInteractions.lua index 8dfbc03..9003e0e 100644 --- a/media/lua/client/TOC/UI/CutLimbInteractions.lua +++ b/media/lua/client/TOC/UI/CutLimbInteractions.lua @@ -28,21 +28,21 @@ local function AddInventoryAmputationOptions(surgeonNum, context) local option = context:addOption(getText("ContextMenu_Amputate"), nil) local subMenu = context:getNew(context) context:addSubMenu(option, subMenu) - for i=1, #StaticData.LIMBS_STRINGS do + for i = 1, #StaticData.LIMBS_STRINGS do local limbName = StaticData.LIMBS_STRINGS[i] if not ModDataHandler.GetInstance():getIsCut(limbName) then local limbTranslatedName = getText("ContextMenu_Limb_" .. limbName) - subMenu:addOption(limbTranslatedName, limbName, PerformAction, surgeonObj, surgeonObj) -- TODO Should be patient, not surgeon + subMenu:addOption(limbTranslatedName, limbName, PerformAction, surgeonObj, surgeonObj) -- TODO Should be patient, not surgeon end end end ---Handler for OnFillInventoryObjectContextMenu ---@param player number ----@param context ISUIElement +---@param context ISContextMenu ---@param items table local function AddInventoryAmputationMenu(player, context, items) - local item = items[1] -- Selected item + local item = items[1] -- Selected item if CheckIfSaw(item.name) then AddInventoryAmputationOptions(player, context) end @@ -58,8 +58,8 @@ local CutLimbHandler = BaseHandler:derive("CutLimbHandler") ---Creates new CutLimbHandler ----@param panel any ----@param bodyPart any +---@param panel ISUIElement +---@param bodyPart BodyPart ---@return CutLimbHandler function CutLimbHandler:new(panel, bodyPart) local o = BaseHandler.new(self, panel, bodyPart) @@ -67,6 +67,7 @@ function CutLimbHandler:new(panel, bodyPart) return o end +---@param item InventoryItem function CutLimbHandler:checkItem(item) local itemType = item:getType() if CheckIfSaw(itemType) then @@ -74,13 +75,14 @@ function CutLimbHandler:checkItem(item) end end +---@param context ISContextMenu function CutLimbHandler:addToMenu(context) --local types = self:getAllItemTypes(self.items.ITEMS) --if #types > 0 then local option = context:addOption(getText("ContextMenu_Amputate"), nil) local subMenu = context:getNew(context) context:addSubMenu(option, subMenu) - for i=1, #StaticData.LIMBS_STRINGS do + for i = 1, #StaticData.LIMBS_STRINGS do local limbName = StaticData.LIMBS_STRINGS[i] if not ModDataHandler.GetInstance():getIsCut(limbName) then local limbTranslatedName = getText("ContextMenu_Limb_" .. limbName) @@ -108,8 +110,9 @@ function CutLimbHandler:perform(previousAction, itemType) local item = self:getItemOfType(self.items.ITEMS, itemType) previousAction = self:toPlayerInventory(item, previousAction) - local action = CutLimbAction:new(self:getPatient(), self:getDoctor(), self.bodyPart) + local limbName = BodyPartType.getDisplayName(self.bodyPart:getType()) -- TODO Test this + local action = CutLimbAction:new(self:getPatient(), self:getDoctor(), limbName) ISTimedActionQueue.addAfter(previousAction, action) end -return CutLimbHandler \ No newline at end of file +return CutLimbHandler diff --git a/media/lua/client/TOC/UI/HealthPanel.lua b/media/lua/client/TOC/UI/HealthPanel.lua index 81e7c37..c5a81a7 100644 --- a/media/lua/client/TOC/UI/HealthPanel.lua +++ b/media/lua/client/TOC/UI/HealthPanel.lua @@ -79,10 +79,13 @@ function ISHealthPanel:initialise() end local og_ISHealthPanel_setOtherPlayer = ISHealthPanel.setOtherPlayer ----comment + + ---@param playerObj IsoPlayer function ISHealthPanel:setOtherPlayer(playerObj) og_ISHealthPanel_setOtherPlayer(self, playerObj) + + -- Since setOtherPlayer may be run after initialise (or always), we need to recheck it after. self:setHighestAmputation() end diff --git a/media/lua/client/TOC/UI/HealthPanelBaseHandler.lua b/media/lua/client/TOC/UI/HealthPanelBaseHandler.lua index d5a4c04..4578371 100644 --- a/media/lua/client/TOC/UI/HealthPanelBaseHandler.lua +++ b/media/lua/client/TOC/UI/HealthPanelBaseHandler.lua @@ -6,6 +6,9 @@ ---@field items table local BaseHandler = ISBaseObject:derive("BaseHandler") +---@param panel ISUIElement +---@param bodyPart BodyPart +---@return table function BaseHandler:new(panel, bodyPart) local o = {} setmetatable(o, self) @@ -52,7 +55,8 @@ function BaseHandler:checkContainerItems(container, childContainers) table.insert(childContainers, item:getInventory()) end else - self:checkItem(item) + ---@diagnostic disable-next-line: undefined-field + self:checkItem(item) -- This is in inherited classes, we never use this class by itself end end end