diff --git a/.gitignore b/.gitignore index c6f9a44..6937180 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -.vscode/settings.json +.vscode/settings.json \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 9d3a1e4..b8b2ea0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,7 @@ "todo-tree.tree.scanMode": "workspace", "zomboid_user_folder": "C:/Users/picch/Zomboid", "zomboid_folder": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\ProjectZomboid", - "zomboid_server_folder": "E:\\Steam\\steamapps\\common\\Project Zomboid Dedicated Server", + "zomboid_server_folder": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Project Zomboid Dedicated Server", "Lua.diagnostics.globals": [ "ModOptions", "zombie", diff --git a/media/lua/client/TOC/Handlers/CachedDataHandler.lua b/media/lua/client/TOC/Handlers/CachedDataHandler.lua index 9d9bec0..26e6dcb 100644 --- a/media/lua/client/TOC/Handlers/CachedDataHandler.lua +++ b/media/lua/client/TOC/Handlers/CachedDataHandler.lua @@ -10,11 +10,14 @@ local CachedDataHandler = {} ---@param username string function CachedDataHandler.Reset(username) CachedDataHandler.amputatedLimbs[username] = {} + CachedDataHandler.indexedAmputatedLimbs[username] = {} + CachedDataHandler.highestAmputatedLimbs[username] = {} end --* Amputated Limbs caching *-- CachedDataHandler.amputatedLimbs = {} +CachedDataHandler.indexedAmputatedLimbs = {} -- TODO Add an indexable table too! ---Calculate the currently amputated limbs for a certain player @@ -35,7 +38,12 @@ end ---@param limbName string function CachedDataHandler.AddAmputatedLimb(username, limbName) TOC_DEBUG.print("added " .. limbName .. " to known amputated limbs for " .. username) + + -- Add it to the generic list table.insert(CachedDataHandler.amputatedLimbs[username], limbName) + + -- Add it to the indexable list + CachedDataHandler.indexedAmputatedLimbs[username][limbName] = limbName end ---Returns a table containing the cached amputated limbs @@ -45,6 +53,12 @@ function CachedDataHandler.GetAmputatedLimbs(username) return CachedDataHandler.amputatedLimbs[username] end +---@param username string +---@return table +function CachedDataHandler.GetIndexedAmputatedLimbs(username) + return CachedDataHandler.indexedAmputatedLimbs[username] +end + --* Highest amputated limb per side caching *-- CachedDataHandler.highestAmputatedLimbs = {} diff --git a/media/lua/client/TOC/Main.lua b/media/lua/client/TOC/Main.lua index 30a95de..7b14334 100644 --- a/media/lua/client/TOC/Main.lua +++ b/media/lua/client/TOC/Main.lua @@ -11,17 +11,15 @@ local Main = {} function Main.SetupTraits() -- Perks.Left_Hand is defined in perks.txt - local traitsTable = {} - local trait1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8, getText("UI_trait_Amputee_Hand_desc"), false, false) - traitsTable[1] = trait1 - - local trait2 = TraitFactory.addTrait("Amputee_LowerArm", getText("UI_trait_Amputee_LowerArm"), -10, getText("UI_trait_Amputee_LowerArm_desc"), false, false) - traitsTable[2] = trait2 - - local trait3 = TraitFactory.addTrait("Amputee_UpperArm", getText("UI_trait_Amputee_UpperArm"), -20, getText("UI_trait_Amputee_UpperArm_desc"), false, false) - traitsTable[2] = trait3 + local traitsTable = { + [1] = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8, getText("UI_trait_Amputee_Hand_desc"), false, false), + [2] = TraitFactory.addTrait("Amputee_LowerArm", getText("UI_trait_Amputee_LowerArm"), -10, getText("UI_trait_Amputee_LowerArm_desc"), false, false), + [3] = TraitFactory.addTrait("Amputee_UpperArm", getText("UI_trait_Amputee_UpperArm"), -20, getText("UI_trait_Amputee_UpperArm_desc"), false, false) + } for i=1, #traitsTable do + + ---@type Trait local t = traitsTable[i] ---@diagnostic disable-next-line: undefined-field t:addXPBoost(Perks.Left_Hand, 4) diff --git a/media/lua/client/TOC/UI/HealthPanel.lua b/media/lua/client/TOC/UI/HealthPanel.lua index 77d4c9f..d6de9d6 100644 --- a/media/lua/client/TOC/UI/HealthPanel.lua +++ b/media/lua/client/TOC/UI/HealthPanel.lua @@ -10,7 +10,7 @@ local CutLimbHandler = require("TOC/UI/CutLimbInteractions") -- We also manage the drag'n drop of items on the body to let the players use the saw this way too ---@diagnostic disable: duplicate-set-field -ISHealthBodyPartPanel = ISBodyPartPanel:derive("ISHealthBodyPartPanel") +--ISHealthBodyPartPanel = ISBodyPartPanel:derive("ISHealthBodyPartPanel") --* Handling drag n drop of the saw *-- @@ -163,4 +163,35 @@ function ISMedicalCheckAction:perform() -- We need to recalculate them here before we can create the highest amputations point CachedDataHandler.CalculateAmputatedLimbs(username) og_ISMedicalCheckAction_perform(self) +end + +local og_ISHealthBodyPartListBox_doDrawItem = ISHealthBodyPartListBox.doDrawItem +function ISHealthBodyPartListBox:doDrawItem(y, item, alt) + y = og_ISHealthBodyPartListBox_doDrawItem(self, y, item, alt) + y = y - 5 + local x = 15 + local fontHgt = getTextManager():getFontHeight(UIFont.Small) + + -- TODO Get username of the correct player + local username = getPlayer():getUsername() + --local amputatedLimbs = CachedDataHandler.GetIndexedAmputatedLimbs(username) + + ---@type BodyPart + local bodyPart = item.item.bodyPart + + local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType()) + local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr] + if limbName then + 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; + + end + + end + + y = y + 5 + return y end \ No newline at end of file diff --git a/media/lua/shared/TOC/StaticData.lua b/media/lua/shared/TOC/StaticData.lua index 01b148c..741ee8e 100644 --- a/media/lua/shared/TOC/StaticData.lua +++ b/media/lua/shared/TOC/StaticData.lua @@ -40,8 +40,8 @@ StaticData.MOD_BODYLOCS_BASE_IND_STR = { -- No "MAX" here. StaticData.IGNORED_BODYLOCS_BPT = { - BodyPartType.Foot_L, BodyPartType.Foot_R, BodyPartType.Groin, BodyPartType.Head, - BodyPartType.LowerLeg_L, BodyPartType.LowerLeg_R, BodyPartType.Neck, BodyPartType.Torso_Lower, + BodyPartType.Foot_L, BodyPartType.Foot_R, BodyPartType.Groin, BodyPartType.Head, + BodyPartType.LowerLeg_L, BodyPartType.LowerLeg_R, BodyPartType.Neck, BodyPartType.Torso_Lower, BodyPartType.Torso_Upper, BodyPartType.UpperLeg_L, BodyPartType.UpperLeg_R } diff --git a/media/textures/metal_base.png b/media/textures/metal_base.png deleted file mode 100644 index e1346bc..0000000 Binary files a/media/textures/metal_base.png and /dev/null differ