Some fixes to cicatrization handling

This commit is contained in:
ZioPao
2023-12-24 02:15:19 -05:00
parent 2c5c3885d1
commit 33140938c9
7 changed files with 44 additions and 24 deletions

View File

@@ -173,7 +173,7 @@ function ISHealthBodyPartListBox:doDrawItem(y, item, alt)
local fontHgt = getTextManager():getFontHeight(UIFont.Small)
-- TODO Get username of the correct player
local username = getPlayer():getUsername()
local username = self.parent.character:getUsername()
--local amputatedLimbs = CachedDataHandler.GetIndexedAmputatedLimbs(username)
---@type BodyPart
@@ -185,8 +185,13 @@ function ISHealthBodyPartListBox:doDrawItem(y, item, alt)
local modDataHandler = ModDataHandler.GetInstance(username)
if modDataHandler:getIsCut(limbName) and modDataHandler:getIsVisible(limbName) then
local cicaTime = modDataHandler:getCicatrizationTime(limbName)
self:drawText("- " .. "Cicatrization " .. tostring(cicaTime), x, y, 0.89, 0.28, 0.28, 1, UIFont.Small)
y = y + fontHgt;
-- Show it in percentage
local maxCicaTime = StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM[limbName]
local percentage = (1 - cicaTime/maxCicaTime) * 100
self:drawText("- " .. string.format("Cicatrization %.2f", percentage) .. "%", x, y, 0.89, 0.28, 0.28, 1, UIFont.Small)
y = y + fontHgt
end

View File

@@ -50,8 +50,8 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
local optionMain = context:addOption(getText("ContextMenu_Cauterize"), nil)
local subMenu = context:getNew(context)
context:addSubMenu(optionMain, subMenu)
for i=1, #amputatedLimbs do
local limbName = amputatedLimbs[i]
for k, _ in pairs(amputatedLimbs) do
local limbName = k
local option = subMenu:addOption(getText("ContextMenu_Limb_" .. limbName), limbName, Cauterize)
option.notAvailable = isTempLow
if isTempLow then