Bunch of stuff for the UI
BIN
dev_stuff/healthPanelHide.psd
Normal file
@@ -39,8 +39,6 @@ end
|
|||||||
function Main.Start()
|
function Main.Start()
|
||||||
Main.SetupTraits()
|
Main.SetupTraits()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Starts initialization for local client
|
-- Starts initialization for local client
|
||||||
Events.OnCreatePlayer.Add(PlayerHandler.InitializePlayer)
|
Events.OnCreatePlayer.Add(PlayerHandler.InitializePlayer)
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
local StaticData = require("TOC_StaticData")
|
local StaticData = require("TOC_StaticData")
|
||||||
|
|
||||||
----------------
|
----------------
|
||||||
---@alias amputationTable { isCut : boolean?, isInfected : boolean?, isOperated : boolean?, isCicatrized : boolean?, isCauterized : boolean?, isDependant : boolean? }
|
---@alias partData { isCut : boolean?, isInfected : boolean?, isOperated : boolean?, isCicatrized : boolean?, isCauterized : boolean?, isDependant : 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
|
-- TODO This class should handle all the stuff related to the mod data
|
||||||
|
|
||||||
---@class ModDataHandler
|
---@class ModDataHandler
|
||||||
---@field playerObj IsoPlayer
|
---@field playerObj IsoPlayer
|
||||||
|
---@field tocData tocModData
|
||||||
local ModDataHandler = {}
|
local ModDataHandler = {}
|
||||||
|
|
||||||
---@param playerObj IsoPlayer
|
---@param playerObj IsoPlayer
|
||||||
@@ -18,6 +19,7 @@ function ModDataHandler:new(playerObj)
|
|||||||
self.__index = self
|
self.__index = self
|
||||||
|
|
||||||
o.playerObj = playerObj
|
o.playerObj = playerObj
|
||||||
|
o.tocData = playerObj:getModData()[StaticData.MOD_NAME]
|
||||||
|
|
||||||
ModDataHandler.instance = o
|
ModDataHandler.instance = o
|
||||||
|
|
||||||
@@ -25,9 +27,10 @@ function ModDataHandler:new(playerObj)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Setup a newly instanced ModDataHandler
|
---Setup a newly instanced ModDataHandler
|
||||||
function ModDataHandler:setup()
|
---@param force boolean?
|
||||||
local modData = self.playerObj:getModData()[StaticData.MOD_NAME]
|
function ModDataHandler:setup(force)
|
||||||
if modData == nil or modData.Hand_L == nil or modData.Hand_L.isCut == nil then
|
local tocData = self.playerObj:getModData()[StaticData.MOD_NAME]
|
||||||
|
if force or tocData == nil or tocData.Hand_L == nil or tocData.Hand_L.isCut == nil then
|
||||||
self:createData()
|
self:createData()
|
||||||
end
|
end
|
||||||
-- TODO Check compatibility or do we just skip it at this point?
|
-- TODO Check compatibility or do we just skip it at this point?
|
||||||
@@ -44,7 +47,7 @@ function ModDataHandler:createData()
|
|||||||
isIgnoredPartInfected = false
|
isIgnoredPartInfected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type amputationTable
|
---@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, isDependant = false}
|
||||||
|
|
||||||
|
|
||||||
@@ -54,6 +57,8 @@ function ModDataHandler:createData()
|
|||||||
modData[StaticData.MOD_NAME][limbName] = {}
|
modData[StaticData.MOD_NAME][limbName] = {}
|
||||||
self:setLimbParams(StaticData.LIMBS_STRINGS[i], defaultParams, 0)
|
self:setLimbParams(StaticData.LIMBS_STRINGS[i], defaultParams, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.tocData = self.playerObj:getModData()[StaticData.MOD_NAME]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -64,20 +69,20 @@ end
|
|||||||
---@param limbName string
|
---@param limbName string
|
||||||
---@param isCut boolean
|
---@param isCut boolean
|
||||||
function ModDataHandler:setIsCut(limbName, isCut)
|
function ModDataHandler:setIsCut(limbName, isCut)
|
||||||
self.playerObj:getModData()[StaticData.MOD_NAME][limbName].isCut = isCut
|
self.tocData[limbName].isCut = isCut
|
||||||
end
|
end
|
||||||
|
|
||||||
---Set isInfected
|
---Set isInfected
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
---@param isInfected boolean
|
---@param isInfected boolean
|
||||||
function ModDataHandler:setIsInfected(limbName, isInfected)
|
function ModDataHandler:setIsInfected(limbName, isInfected)
|
||||||
self.playerObj:getModData()[StaticData.MOD_NAME][limbName].isInfected = isInfected
|
self.tocData[limbName].isInfected = isInfected
|
||||||
end
|
end
|
||||||
|
|
||||||
---Set isInfected
|
---Set isIgnoredPartInfected
|
||||||
---@param isIgnoredPartInfected boolean
|
---@param isIgnoredPartInfected boolean
|
||||||
function ModDataHandler:setIsIgnoredPartInfected(isIgnoredPartInfected)
|
function ModDataHandler:setIsIgnoredPartInfected(isIgnoredPartInfected)
|
||||||
self.playerObj:getModData()[StaticData.MOD_NAME].setIsIgnoredPartInfected = isIgnoredPartInfected
|
self.tocData.isIgnoredPartInfected = isIgnoredPartInfected
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
@@ -86,13 +91,13 @@ end
|
|||||||
---@param limbName string
|
---@param limbName string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function ModDataHandler:getIsCut(limbName)
|
function ModDataHandler:getIsCut(limbName)
|
||||||
return self.playerObj:getModData()[StaticData.MOD_NAME][limbName].isCut
|
return self.tocData[limbName].isCut
|
||||||
end
|
end
|
||||||
|
|
||||||
---Get isIgnoredPartInfected
|
---Get isIgnoredPartInfected
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function ModDataHandler:getIsIgnoredPartInfected()
|
function ModDataHandler:getIsIgnoredPartInfected()
|
||||||
return self.playerObj:getModData()[StaticData.MOD_NAME].isIgnoredPartInfected
|
return self.tocData.isIgnoredPartInfected
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -112,12 +117,10 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri
|
|||||||
cicatrizationTime = StaticData.LIMBS_CICATRIZATION_TIME[limbName] - surgeonFactor
|
cicatrizationTime = StaticData.LIMBS_CICATRIZATION_TIME[limbName] - surgeonFactor
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type amputationTable
|
---@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, isDependant = false}
|
||||||
self:setLimbParams(limbName, params, cicatrizationTime)
|
self:setLimbParams(limbName, params, cicatrizationTime)
|
||||||
|
|
||||||
local t = StaticData.LIMBS_DEPENDENCIES
|
|
||||||
print(t)
|
|
||||||
for i=1, #StaticData.LIMBS_DEPENDENCIES[limbName] do
|
for i=1, #StaticData.LIMBS_DEPENDENCIES[limbName] do
|
||||||
local dependedLimbName = StaticData.LIMBS_DEPENDENCIES[limbName][i]
|
local dependedLimbName = StaticData.LIMBS_DEPENDENCIES[limbName][i]
|
||||||
|
|
||||||
@@ -125,16 +128,19 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri
|
|||||||
-- Same story for cicatrizationTime, which will be 0
|
-- 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, isDependant = true}, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set the highest amputation and caches them.
|
||||||
|
ISHealthPanel.GetHighestAmputation()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Internal use only, set a limb data
|
---Internal use only, set a limb data
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
---@param ampStatus amputationTable {isCut, isInfected, isOperated, isCicatrized, isCauterized, isDependant}
|
---@param ampStatus partData {isCut, isInfected, isOperated, isCicatrized, isCauterized, isDependant}
|
||||||
---@param cicatrizationTime integer?
|
---@param cicatrizationTime integer?
|
||||||
---@private
|
---@private
|
||||||
function ModDataHandler:setLimbParams(limbName, ampStatus, cicatrizationTime)
|
function ModDataHandler:setLimbParams(limbName, ampStatus, cicatrizationTime)
|
||||||
local limbData = self.playerObj:getModData()[StaticData.MOD_NAME][limbName]
|
local limbData = self.tocData[limbName]
|
||||||
if ampStatus.isCut ~= nil then limbData.isCut = ampStatus.isCut end
|
if ampStatus.isCut ~= nil then limbData.isCut = ampStatus.isCut end
|
||||||
if ampStatus.isInfected ~= nil then limbData.isInfected = ampStatus.isInfected end
|
if ampStatus.isInfected ~= nil then limbData.isInfected = ampStatus.isInfected end
|
||||||
if ampStatus.isOperated ~= nil then limbData.isOperated = ampStatus.isOperated end
|
if ampStatus.isOperated ~= nil then limbData.isOperated = ampStatus.isOperated end
|
||||||
|
|||||||
@@ -9,9 +9,15 @@ local PlayerHandler = {}
|
|||||||
---Setup player modData
|
---Setup player modData
|
||||||
---@param _ nil
|
---@param _ nil
|
||||||
---@param playerObj IsoPlayer
|
---@param playerObj IsoPlayer
|
||||||
function PlayerHandler.InitializePlayer(_, playerObj)
|
---@param isForced boolean?
|
||||||
|
function PlayerHandler.InitializePlayer(_, playerObj, isForced)
|
||||||
PlayerHandler.modDataHandler = ModDataHandler:new(playerObj)
|
PlayerHandler.modDataHandler = ModDataHandler:new(playerObj)
|
||||||
PlayerHandler.modDataHandler:setup()
|
PlayerHandler.modDataHandler:setup(isForced)
|
||||||
|
|
||||||
|
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
|
||||||
|
if isForced then
|
||||||
|
ISHealthPanel.highestAmputations = {}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Cut a limb for a trait
|
---Cut a limb for a trait
|
||||||
|
|||||||
@@ -78,7 +78,11 @@ end
|
|||||||
StaticData.HEALTH_PANEL_TEXTURES = {
|
StaticData.HEALTH_PANEL_TEXTURES = {
|
||||||
Hand_L = getTexture("media/ui/Hand_L.png"),
|
Hand_L = getTexture("media/ui/Hand_L.png"),
|
||||||
ForeArm_L = getTexture("media/ui/ForeArm_L.png"),
|
ForeArm_L = getTexture("media/ui/ForeArm_L.png"),
|
||||||
UpeerArm_L = getTexture("media/ui/UpperArm_L.png")
|
UpeerArm_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")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ TestFramework.registerTestModule("Functionality", "Amputation", function()
|
|||||||
local Tests = {}
|
local Tests = {}
|
||||||
|
|
||||||
function Tests.InitializePlayer()
|
function Tests.InitializePlayer()
|
||||||
return true
|
|
||||||
|
|
||||||
-- TODO This breaks the Test Framework mod for some reason.
|
-- TODO This breaks the Test Framework mod for some reason.
|
||||||
-- local pl = getPlayer()
|
local pl = getPlayer()
|
||||||
-- PlayerHandler.InitializePlayer(nil, pl)
|
PlayerHandler.InitializePlayer(_, pl, true)
|
||||||
-- return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function Tests.CutLeftHand()
|
function Tests.CutLeftHand()
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ end
|
|||||||
-- TODO We need male variations
|
-- TODO We need male variations
|
||||||
|
|
||||||
|
|
||||||
---@return {partL : string?, partR : string?}
|
|
||||||
local function GetHighestAmputation()
|
function ISHealthPanel.GetHighestAmputation()
|
||||||
-- TODO Cache this instead of doing it here!
|
-- TODO Cache this instead of doing it here!
|
||||||
|
|
||||||
local tab = {}
|
ISHealthPanel.highestAmputations = {}
|
||||||
local prevDepSize = {}
|
local prevDepSize = {}
|
||||||
for i=1, #StaticData.LIMBS_STRINGS do
|
for i=1, #StaticData.LIMBS_STRINGS do
|
||||||
local limbName = StaticData.LIMBS_STRINGS[i]
|
local limbName = StaticData.LIMBS_STRINGS[i]
|
||||||
@@ -51,20 +51,19 @@ local function GetHighestAmputation()
|
|||||||
if string.find(limbName, "_L") then index = "L" else index = "R" end
|
if string.find(limbName, "_L") then index = "L" else index = "R" end
|
||||||
if PlayerHandler.modDataHandler:getIsCut(limbName) then
|
if PlayerHandler.modDataHandler:getIsCut(limbName) then
|
||||||
|
|
||||||
if tab[index] ~= nil then
|
if ISHealthPanel.highestAmputations[index] ~= nil then
|
||||||
local cDependencySize = #StaticData.LIMBS_DEPENDENCIES[limbName]
|
local cDependencySize = #StaticData.LIMBS_DEPENDENCIES[limbName]
|
||||||
if cDependencySize > prevDepSize[index] then
|
if cDependencySize > prevDepSize[index] then
|
||||||
tab[index] = limbName
|
ISHealthPanel.highestAmputations[index] = limbName
|
||||||
prevDepSize[index] = StaticData.LIMBS_DEPENDENCIES[limbName]
|
prevDepSize[index] = StaticData.LIMBS_DEPENDENCIES[limbName]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
tab[index] = limbName
|
ISHealthPanel.highestAmputations[index] = limbName
|
||||||
prevDepSize[index] = #StaticData.LIMBS_DEPENDENCIES[limbName]
|
prevDepSize[index] = #StaticData.LIMBS_DEPENDENCIES[limbName]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
return tab
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -74,21 +73,25 @@ function ISHealthPanel:render()
|
|||||||
|
|
||||||
-- TODO Handle another player health panel
|
-- TODO Handle another player health panel
|
||||||
|
|
||||||
local highestAmputations = GetHighestAmputation()
|
if ISHealthPanel.highestAmputations then
|
||||||
|
-- Left Texture
|
||||||
-- Left Texture
|
if ISHealthPanel.highestAmputations["L"] then
|
||||||
if highestAmputations["L"] then
|
local textureL = StaticData.HEALTH_PANEL_TEXTURES[ISHealthPanel.highestAmputations["L"]]
|
||||||
local textureL = StaticData.HEALTH_PANEL_TEXTURES[highestAmputations["L"]]
|
self:drawTextureScaled(textureL, self.healthPanel.x/2 - 2, self.healthPanel.y/2, 123, 302, 1, 1, 0, 0)
|
||||||
self:drawTextureScaled(textureL, self.healthPanel.x/2 - 2, self.healthPanel.y/2, 123, 302, 1, 1, 0, 0)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if highestAmputations["R"] then
|
|
||||||
|
|
||||||
|
-- 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)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ISHealthPanel.GetHighestAmputation()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Right Texture
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
BIN
media/ui/ForeArm_R.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.8 KiB |
BIN
media/ui/Hand_R.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
media/ui/UpperArm_R.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |