This commit is contained in:
ZioPao
2023-11-12 05:53:26 +01:00
parent 3443198edb
commit 3d963a2ad6
4 changed files with 27 additions and 11 deletions

View File

@@ -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

View File

@@ -28,7 +28,7 @@ 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)
@@ -39,7 +39,7 @@ 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
@@ -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,7 +110,8 @@ 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

View File

@@ -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

View File

@@ -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