Cauterized status in health panel
This commit is contained in:
@@ -15,7 +15,6 @@ end
|
|||||||
|
|
||||||
--* Amputated Limbs caching *--
|
--* Amputated Limbs caching *--
|
||||||
CachedDataHandler.amputatedLimbs = {}
|
CachedDataHandler.amputatedLimbs = {}
|
||||||
-- TODO Add an indexable table too!
|
|
||||||
|
|
||||||
---Calculate the currently amputated limbs for a certain player
|
---Calculate the currently amputated limbs for a certain player
|
||||||
---@param username string
|
---@param username string
|
||||||
@@ -37,10 +36,7 @@ function CachedDataHandler.AddAmputatedLimb(username, limbName)
|
|||||||
TOC_DEBUG.print("added " .. limbName .. " to known amputated limbs for " .. username)
|
TOC_DEBUG.print("added " .. limbName .. " to known amputated limbs for " .. username)
|
||||||
|
|
||||||
-- Add it to the generic list
|
-- Add it to the generic list
|
||||||
-- TODO this is wrong
|
|
||||||
|
|
||||||
CachedDataHandler.amputatedLimbs[username][limbName] = limbName
|
CachedDataHandler.amputatedLimbs[username][limbName] = limbName
|
||||||
--table.insert(CachedDataHandler.amputatedLimbs[username], limbName)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Returns a table containing the cached amputated limbs
|
---Returns a table containing the cached amputated limbs
|
||||||
|
|||||||
@@ -178,7 +178,11 @@ end
|
|||||||
---@param limbName string
|
---@param limbName string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function ModDataHandler:getIsCut(limbName)
|
function ModDataHandler:getIsCut(limbName)
|
||||||
return self.tocData.limbs[limbName].isCut
|
if self.tocData.limbs[limbName] then
|
||||||
|
return self.tocData.limbs[limbName].isCut
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Get isVisible
|
---Get isVisible
|
||||||
@@ -246,14 +250,14 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri
|
|||||||
|
|
||||||
-- We don't care about isOperated, isCicatrized, isCauterized since this is depending on another limb
|
-- We don't care about isOperated, isCicatrized, isCauterized since this is depending on another limb
|
||||||
-- Same story for cicatrizationTime, which will be 0
|
-- Same story for cicatrizationTime, which will be 0
|
||||||
-- isCicatized is to true to prevent it from doing the cicatrization process
|
-- isCicatrized is to true to prevent it from doing the cicatrization process
|
||||||
self:setLimbParams(dependedLimbName, {isCut = true, isInfected = false, isVisible = false, isCicatrized = true}, 0)
|
self:setLimbParams(dependedLimbName, {isCut = true, isInfected = false, isVisible = false, isCicatrized = true}, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set that a limb has been cut, to activate some functions without having to loop through the parts
|
-- Set that a limb has been cut, to activate some functions without having to loop through the parts
|
||||||
self:setIsAnyLimbCut(true)
|
self:setIsAnyLimbCut(true)
|
||||||
|
|
||||||
-- TODO IN theory we should cache data from here, not AMputationHandler
|
-- TODO In theory we should cache data from here, not AmputationHandler
|
||||||
end
|
end
|
||||||
|
|
||||||
---Set a limb data
|
---Set a limb data
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ function ISHealthBodyPartListBox:doDrawItem(y, item, alt)
|
|||||||
local x = 15
|
local x = 15
|
||||||
local fontHgt = getTextManager():getFontHeight(UIFont.Small)
|
local fontHgt = getTextManager():getFontHeight(UIFont.Small)
|
||||||
|
|
||||||
-- TODO Get username of the correct player
|
|
||||||
local username = self.parent.character:getUsername()
|
local username = self.parent.character:getUsername()
|
||||||
--local amputatedLimbs = CachedDataHandler.GetIndexedAmputatedLimbs(username)
|
--local amputatedLimbs = CachedDataHandler.GetIndexedAmputatedLimbs(username)
|
||||||
|
|
||||||
@@ -184,13 +183,22 @@ function ISHealthBodyPartListBox:doDrawItem(y, item, alt)
|
|||||||
if limbName then
|
if limbName then
|
||||||
local modDataHandler = ModDataHandler.GetInstance(username)
|
local modDataHandler = ModDataHandler.GetInstance(username)
|
||||||
if modDataHandler:getIsCut(limbName) and modDataHandler:getIsVisible(limbName) then
|
if modDataHandler:getIsCut(limbName) and modDataHandler:getIsVisible(limbName) then
|
||||||
local cicaTime = modDataHandler:getCicatrizationTime(limbName)
|
|
||||||
|
|
||||||
-- Show it in percentage
|
if modDataHandler:getIsCicatrized(limbName) then
|
||||||
local maxCicaTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName]
|
if modDataHandler:getIsCauterized(limbName) then
|
||||||
local percentage = (1 - cicaTime/maxCicaTime) * 100
|
self:drawText("- " .. getText("IGUI_HealthPanel_Cauterized"), x, y, 0.58, 0.75, 0.28, 1, UIFont.Small)
|
||||||
|
else
|
||||||
|
self:drawText("- " .. getText("IGUI_HealthPanel_Cicatrized"), x, y, 0.28, 0.89, 0.28, 1, UIFont.Small)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
local cicaTime = modDataHandler:getCicatrizationTime(limbName)
|
||||||
|
|
||||||
self:drawText("- " .. string.format("Cicatrization %.2f", percentage) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small)
|
-- Show it in percentage
|
||||||
|
local maxCicaTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName]
|
||||||
|
local percentage = (1 - cicaTime/maxCicaTime) * 100
|
||||||
|
self:drawText("- " .. getText("IGUI_HealthPanel_Cicatrization") .. string.format(" %.2f", percentage) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small)
|
||||||
|
end
|
||||||
y = y + fontHgt
|
y = y + fontHgt
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -199,4 +207,39 @@ function ISHealthBodyPartListBox:doDrawItem(y, item, alt)
|
|||||||
|
|
||||||
y = y + 5
|
y = y + 5
|
||||||
return y
|
return y
|
||||||
|
end
|
||||||
|
|
||||||
|
local og_ISHealthPanel_getDamagedParts = ISHealthPanel.getDamagedParts
|
||||||
|
function ISHealthPanel:getDamagedParts()
|
||||||
|
|
||||||
|
-- TODO Overriding it is a lot easier, but ew
|
||||||
|
-- local result = og_ISHealthPanel_getDamagedParts(self)
|
||||||
|
-- local bodyParts = self:getPatient():getBodyDamage():getBodyParts()
|
||||||
|
-- if isClient() and not self:getPatient():isLocalPlayer() then
|
||||||
|
-- bodyParts = self:getPatient():getBodyDamageRemote():getBodyParts()
|
||||||
|
-- end
|
||||||
|
-- for i=1,bodyParts:size() do
|
||||||
|
-- local bodyPart = bodyParts:get(i-1)
|
||||||
|
-- table.insert(result, bodyPart)
|
||||||
|
|
||||||
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
-- return result
|
||||||
|
local result = {}
|
||||||
|
local bodyParts = self:getPatient():getBodyDamage():getBodyParts()
|
||||||
|
if isClient() and not self:getPatient():isLocalPlayer() then
|
||||||
|
bodyParts = self:getPatient():getBodyDamageRemote():getBodyParts()
|
||||||
|
end
|
||||||
|
for i=1,bodyParts:size() do
|
||||||
|
local bodyPart = bodyParts:get(i-1)
|
||||||
|
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())
|
||||||
|
local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr]
|
||||||
|
|
||||||
|
local bodyPartAction = self.bodyPartAction and self.bodyPartAction[bodyPart]
|
||||||
|
if ISHealthPanel.cheat or bodyPart:HasInjury() or bodyPart:bandaged() or bodyPart:stitched() or bodyPart:getSplintFactor() > 0 or bodyPart:getAdditionalPain() > 10 or bodyPart:getStiffness() > 5 or ModDataHandler.GetInstance(self:getPatient():getUsername()):getIsCut(limbName) then
|
||||||
|
table.insert(result, bodyPart)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||||
|
local StaticData = require("TOC/StaticData")
|
||||||
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
@@ -15,11 +16,17 @@ Events.OnFillInventoryObjectContextMenu.Add(AddInventorySurgeryMenu)
|
|||||||
|
|
||||||
-- TODO We need a class to handle operations, this is just a placeholder
|
-- TODO We need a class to handle operations, this is just a placeholder
|
||||||
local function Cauterize(limbName)
|
local function Cauterize(limbName)
|
||||||
|
local modDataHandler = ModDataHandler.GetInstance()
|
||||||
|
modDataHandler:setCicatrizationTime(limbName, 0)
|
||||||
|
modDataHandler:setIsCicatrized(limbName, true)
|
||||||
|
modDataHandler:setIsCauterized(limbName, true)
|
||||||
|
|
||||||
|
-- we don't care bout the depended limbs, since they're alread "cicatrized"
|
||||||
|
|
||||||
|
modDataHandler:apply()
|
||||||
end
|
end
|
||||||
|
|
||||||
---comment
|
---@param playerNum number
|
||||||
---@param playerNum any
|
|
||||||
---@param context ISContextMenu
|
---@param context ISContextMenu
|
||||||
---@param worldObjects any
|
---@param worldObjects any
|
||||||
---@param test any
|
---@param test any
|
||||||
@@ -28,7 +35,8 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
|||||||
|
|
||||||
local pl = getSpecificPlayer(playerNum)
|
local pl = getSpecificPlayer(playerNum)
|
||||||
|
|
||||||
if not ModDataHandler.GetInstance():getIsAnyLimbCut() then return end
|
local modDataHandler = ModDataHandler.GetInstance()
|
||||||
|
if not modDataHandler:getIsAnyLimbCut() then return end
|
||||||
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
|
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
|
||||||
|
|
||||||
local stoveObj = nil
|
local stoveObj = nil
|
||||||
@@ -51,12 +59,17 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
|
|||||||
local subMenu = context:getNew(context)
|
local subMenu = context:getNew(context)
|
||||||
context:addSubMenu(optionMain, subMenu)
|
context:addSubMenu(optionMain, subMenu)
|
||||||
for k, _ in pairs(amputatedLimbs) do
|
for k, _ in pairs(amputatedLimbs) do
|
||||||
|
|
||||||
|
-- We need to let the player cauterize ONLY the visible one!
|
||||||
local limbName = k
|
local limbName = k
|
||||||
local option = subMenu:addOption(getText("ContextMenu_Limb_" .. limbName), limbName, Cauterize)
|
if modDataHandler:getIsVisible(limbName) then
|
||||||
option.notAvailable = isTempLow
|
local option = subMenu:addOption(getText("ContextMenu_Limb_" .. limbName), limbName, Cauterize)
|
||||||
if isTempLow then
|
option.notAvailable = isTempLow
|
||||||
option.toolTip = tempTooltip
|
if isTempLow then
|
||||||
|
option.toolTip = tempTooltip
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ ContextMenu_EN = {
|
|||||||
ContextMenu_Cauterize_TempTooLow_tooltip = "Temperature too low",
|
ContextMenu_Cauterize_TempTooLow_tooltip = "Temperature too low",
|
||||||
|
|
||||||
ContextMenu_Limb_Hand_L = "Left Hand",
|
ContextMenu_Limb_Hand_L = "Left Hand",
|
||||||
ContextMenu_Limb_ForeArm_L = "Left forearm",
|
ContextMenu_Limb_ForeArm_L = "Left Forearm",
|
||||||
ContextMenu_Limb_UpperArm_L = "Left UpperArm"
|
ContextMenu_Limb_UpperArm_L = "Left UpperArm"
|
||||||
ContextMenu_Limb_Hand_R = "Right Hand",
|
ContextMenu_Limb_Hand_R = "Right Hand",
|
||||||
ContextMenu_Limb_ForeArm_R = "Right forearm",
|
ContextMenu_Limb_ForeArm_R = "Right Forearm",
|
||||||
ContextMenu_Limb_UpperArm_R = "Right UpperArm"
|
ContextMenu_Limb_UpperArm_R = "Right UpperArm"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,9 @@ IG_UI_EN = {
|
|||||||
|
|
||||||
IGUI_ItemCat_Prosthesis = "Prosthesis",
|
IGUI_ItemCat_Prosthesis = "Prosthesis",
|
||||||
IGUI_ItemCat_Amputation = "Amputation"
|
IGUI_ItemCat_Amputation = "Amputation"
|
||||||
|
|
||||||
|
IGUI_HealthPanel_Cicatrization = "Cicatrization",
|
||||||
|
IGUI_HealthPanel_Cicatrized = "Cicatrized",
|
||||||
|
IGUI_HealthPanel_Cauterized = "Cauterized",
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user