More tests and cleaning UI
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
local StaticData = require("TOC_StaticData")
|
||||
|
||||
----------------
|
||||
---@alias partData { isCut : boolean?, isInfected : boolean?, isOperated : boolean?, isCicatrized : boolean?, isCauterized : boolean?, isDependant : boolean?, cicatrizationTime : number }
|
||||
---@alias partData { isCut : boolean?, isInfected : boolean?, isOperated : boolean?, isCicatrized : boolean?, isCauterized : boolean?, isVisible : boolean?, cicatrizationTime : number }
|
||||
---@alias tocModData {Hand_L : partData, ForeArm_L : partData, UpperArm_L : partData, Hand_R : partData, ForeArm_R : partData, UpperArm_R : partData, isIgnoredPartInfected : boolean}
|
||||
----------------
|
||||
-- TODO This class should handle all the stuff related to the mod data
|
||||
@@ -48,7 +48,7 @@ function ModDataHandler:createData()
|
||||
}
|
||||
|
||||
---@type partData
|
||||
local defaultParams = {isCut = false, isInfected = false, isOperated = false, isCicatrized = false, isCauterized = false, isDependant = false}
|
||||
local defaultParams = {isCut = false, isInfected = false, isOperated = false, isCicatrized = false, isCauterized = false, isVisible = false}
|
||||
|
||||
|
||||
-- Initialize limbs
|
||||
@@ -100,6 +100,11 @@ function ModDataHandler:getIsIgnoredPartInfected()
|
||||
return self.tocData.isIgnoredPartInfected
|
||||
end
|
||||
|
||||
---Get isVisible
|
||||
---@return boolean
|
||||
function ModDataHandler:getIsVisible(limbName)
|
||||
return self.tocData[limbName].isVisible
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -118,7 +123,7 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri
|
||||
end
|
||||
|
||||
---@type partData
|
||||
local params = {isCut = true, isInfected = false, isOperated = isOperated, isCicatrized = isCicatrized, isCauterized = isCauterized, isDependant = false}
|
||||
local params = {isCut = true, isInfected = false, isOperated = isOperated, isCicatrized = isCicatrized, isCauterized = isCauterized, isVisible = true}
|
||||
self:setLimbParams(limbName, params, cicatrizationTime)
|
||||
|
||||
for i=1, #StaticData.LIMBS_DEPENDENCIES[limbName] do
|
||||
@@ -126,7 +131,7 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri
|
||||
|
||||
-- We don't care about isOperated, isCicatrized, isCauterized since this is depending on another limb
|
||||
-- Same story for cicatrizationTime, which will be 0
|
||||
self:setLimbParams(dependedLimbName, {isCut = true, isInfected = false, isDependant = true}, 0)
|
||||
self:setLimbParams(dependedLimbName, {isCut = true, isInfected = false, isVisible = false}, 0)
|
||||
end
|
||||
|
||||
-- Set the highest amputation and caches them.
|
||||
@@ -136,7 +141,7 @@ end
|
||||
|
||||
---Internal use only, set a limb data
|
||||
---@param limbName string
|
||||
---@param ampStatus partData {isCut, isInfected, isOperated, isCicatrized, isCauterized, isDependant}
|
||||
---@param ampStatus partData {isCut, isInfected, isOperated, isCicatrized, isCauterized, isVisible}
|
||||
---@param cicatrizationTime integer?
|
||||
---@private
|
||||
function ModDataHandler:setLimbParams(limbName, ampStatus, cicatrizationTime)
|
||||
@@ -146,7 +151,7 @@ function ModDataHandler:setLimbParams(limbName, ampStatus, cicatrizationTime)
|
||||
if ampStatus.isOperated ~= nil then limbData.isOperated = ampStatus.isOperated end
|
||||
if ampStatus.isCicatrized ~= nil then limbData.isCicatrized = ampStatus.isCicatrized end
|
||||
if ampStatus.isCauterized ~= nil then limbData.isCauterized = ampStatus.isCauterized end
|
||||
if ampStatus.isDependant ~= nil then limbData.isDependant = ampStatus.isDependant end
|
||||
if ampStatus.isVisible ~= nil then limbData.isVisible = ampStatus.isVisible end
|
||||
|
||||
if cicatrizationTime ~= nil then limbData.cicatrizationTime = cicatrizationTime end
|
||||
end
|
||||
|
||||
@@ -75,14 +75,15 @@ end
|
||||
|
||||
|
||||
--- Textures
|
||||
-- TODO We need male variations
|
||||
StaticData.HEALTH_PANEL_TEXTURES = {
|
||||
Hand_L = getTexture("media/ui/Hand_L.png"),
|
||||
ForeArm_L = getTexture("media/ui/ForeArm_L.png"),
|
||||
UpeerArm_L = getTexture("media/ui/UpperArm_L.png"),
|
||||
UpperArm_L = getTexture("media/ui/UpperArm_L.png"),
|
||||
|
||||
Hand_R = getTexture("media/ui/Hand_R.png"),
|
||||
ForeArm_R = getTexture("media/ui/ForeArm_R.png"),
|
||||
UpeerArm_R = getTexture("media/ui/UpperArm_R.png")
|
||||
UpperArm_R = getTexture("media/ui/UpperArm_R.png")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,26 @@ TestFramework.registerTestModule("Functionality", "Amputation", function()
|
||||
return PlayerHandler.modDataHandler:getIsCut("ForeArm_L") and PlayerHandler.modDataHandler:getIsCut("Hand_L")
|
||||
end
|
||||
|
||||
function Tests.CutLeftUpperarm()
|
||||
PlayerHandler.ForceCutLimb("UpperArm_L")
|
||||
return PlayerHandler.modDataHandler:getIsCut("UpperArm_L") and PlayerHandler.modDataHandler:getIsCut("ForeArm_L") and PlayerHandler.modDataHandler:getIsCut("Hand_L")
|
||||
end
|
||||
|
||||
function Tests.CutRightHand()
|
||||
PlayerHandler.ForceCutLimb("Hand_R")
|
||||
return PlayerHandler.modDataHandler:getIsCut("Hand_R")
|
||||
end
|
||||
|
||||
function Tests.CutRightForearm()
|
||||
PlayerHandler.ForceCutLimb("ForeArm_R")
|
||||
return PlayerHandler.modDataHandler:getIsCut("ForeArm_R") and PlayerHandler.modDataHandler:getIsCut("Hand_R")
|
||||
end
|
||||
|
||||
function Tests.CutRightUpperarm()
|
||||
PlayerHandler.ForceCutLimb("UpperArm_R")
|
||||
return PlayerHandler.modDataHandler:getIsCut("UpperArm_R") and PlayerHandler.modDataHandler:getIsCut("ForeArm_R") and PlayerHandler.modDataHandler:getIsCut("Hand_R")
|
||||
end
|
||||
|
||||
return Tests
|
||||
|
||||
end)
|
||||
@@ -36,33 +36,17 @@ end
|
||||
|
||||
--* Modification to handle visible amputation on the health menu *--
|
||||
|
||||
-- TODO We need male variations
|
||||
|
||||
|
||||
|
||||
function ISHealthPanel.GetHighestAmputation()
|
||||
-- TODO Cache this instead of doing it here!
|
||||
|
||||
ISHealthPanel.highestAmputations = {}
|
||||
local prevDepSize = {}
|
||||
for i=1, #StaticData.LIMBS_STRINGS do
|
||||
local limbName = StaticData.LIMBS_STRINGS[i]
|
||||
local index
|
||||
if string.find(limbName, "_L") then index = "L" else index = "R" end
|
||||
if PlayerHandler.modDataHandler:getIsCut(limbName) then
|
||||
|
||||
if ISHealthPanel.highestAmputations[index] ~= nil then
|
||||
local cDependencySize = #StaticData.LIMBS_DEPENDENCIES[limbName]
|
||||
if cDependencySize > prevDepSize[index] then
|
||||
if PlayerHandler.modDataHandler:getIsCut(limbName) and PlayerHandler.modDataHandler:getIsVisible(limbName) then
|
||||
ISHealthPanel.highestAmputations[index] = limbName
|
||||
prevDepSize[index] = StaticData.LIMBS_DEPENDENCIES[limbName]
|
||||
end
|
||||
else
|
||||
ISHealthPanel.highestAmputations[index] = limbName
|
||||
prevDepSize[index] = #StaticData.LIMBS_DEPENDENCIES[limbName]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,22 +61,17 @@ function ISHealthPanel:render()
|
||||
-- Left Texture
|
||||
if ISHealthPanel.highestAmputations["L"] then
|
||||
local textureL = StaticData.HEALTH_PANEL_TEXTURES[ISHealthPanel.highestAmputations["L"]]
|
||||
self:drawTextureScaled(textureL, self.healthPanel.x/2 - 2, self.healthPanel.y/2, 123, 302, 1, 1, 0, 0)
|
||||
self:drawTexture(textureL, self.healthPanel.x/2 - 2, self.healthPanel.y/2, 1, 1, 0, 0)
|
||||
end
|
||||
|
||||
-- Right Texture
|
||||
if ISHealthPanel.highestAmputations["R"] then
|
||||
local textureR = StaticData.HEALTH_PANEL_TEXTURES[ISHealthPanel.highestAmputations["R"]]
|
||||
self:drawTextureScaled(textureR, self.healthPanel.x/2 - 2, self.healthPanel.y/2, 123, 302, 1, 1, 0, 0)
|
||||
self:drawTexture(textureR, self.healthPanel.x/2 + 2, self.healthPanel.y/2, 1, 1, 0, 0)
|
||||
end
|
||||
else
|
||||
ISHealthPanel.GetHighestAmputation()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- We need to override this to force the alpha to 1
|
||||
|
||||
Reference in New Issue
Block a user