diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5ff3b30..db7cb67 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -59,6 +59,15 @@ "problemMatcher": [ "$eslint-stylish" ] + }, + { + "label": "Run Zomboid Test Server 3", + "options": {"statusbar": {"label": "$(run) Zomboid Server (TOC+FH+BH+iMedsFixed)"}}, + "type": "shell", + "command":"\"${config:zomboid_server_folder}\\StartServer64_nosteam_custom.bat\" TOC_FH_BH_imeds", + "problemMatcher": [ + "$eslint-stylish" + ] } ] } \ No newline at end of file diff --git a/media/lua/client/TOC/Compat.lua b/media/lua/client/TOC/Compat.lua index 8258cb0..fd99938 100644 --- a/media/lua/client/TOC/Compat.lua +++ b/media/lua/client/TOC/Compat.lua @@ -1,39 +1,74 @@ +---@class Compat +---@field handlers table +local Compat = { + handlers = {} +} -local function HandleModCompatibility() +--- Brutal hands has a TOC_COMPAT but its check is wrong and uses an old API. +function Compat.BrutalHandwork() + BrutalHands = BrutalHands or {} + BrutalHands.TOC = require("TOC/API") +end - - local activatedMods = getActivatedMods() - TOC_DEBUG.print("Checking for mods compatibility") - - --[[ - Brutal hands has a TOC_COMPAT but its check is wrong and uses an old API. - ]] - if activatedMods:contains('BrutalHandwork') then - TOC_DEBUG.print("found BrutalHandwork, activating compat module") - BrutalHands = BrutalHands or {} - BrutalHands.TOC = require("TOC/API") - end - - --[[ - Was handled inside old TOC - ]] - if activatedMods:contains('FancyHandwork') then - TOC_DEBUG.print("found FancyHandwork, activating compat module") - - require("TimedActions/FHSwapHandsAction") - local og_FHSwapHandsAction_isValid = FHSwapHandsAction.isValid - function FHSwapHandsAction:isValid() - local tocApi = require("TOC/API") - if tocApi.hasBothHands(self.character) then - return og_FHSwapHandsAction_isValid(self) - else - return false - end +--- Was handled inside old TOC +function Compat.FancyHandwork() + require("TimedActions/FHSwapHandsAction") + local og_FHSwapHandsAction_isValid = FHSwapHandsAction.isValid + function FHSwapHandsAction:isValid() + local tocApi = require("TOC/API") + if tocApi.hasBothHands(self.character) then + return og_FHSwapHandsAction_isValid(self) + else + return false end end end -Events.OnGameStart.Add(HandleModCompatibility) +function Compat.iMeds() + +end + + +------------------------------ + +Compat.handlers = { + ["BrutalHandwork"] = { + fun = Compat.BrutalHandwork, + isActive = false}, + ["FancyHandwork"] = { + fun = Compat.FancyHandwork, + isActive = false}, + + -- either or + ['iMeds'] = { + fun = Compat.iMeds, + isActive = false}, + ['iMedsFixed'] = { + fun = Compat.iMeds, + isActive = false} +} + + +function Compat.RunModCompatibility() + local activatedMods = getActivatedMods() + TOC_DEBUG.print("Checking for mods compatibility") + + for k, modCompatHandler in pairs(Compat.handlers) do + if activatedMods:contains(k) then + TOC_DEBUG.print("Found " .. k .. ", running compatibility handler") + modCompatHandler.fun() + modCompatHandler.isActive = true + end + end + + + +end + + +Events.OnGameStart.Add(Compat.RunModCompatibility) + +return Compat \ No newline at end of file diff --git a/media/lua/client/TOC/UI/HealthPanel.lua b/media/lua/client/TOC/UI/HealthPanel.lua index 895cfa9..4c519de 100644 --- a/media/lua/client/TOC/UI/HealthPanel.lua +++ b/media/lua/client/TOC/UI/HealthPanel.lua @@ -1,7 +1,7 @@ local StaticData = require("TOC/StaticData") -local CommandsData = require("TOC/CommandsData") local DataController = require("TOC/Controllers/DataController") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") +local Compat = require("TOC/Compat") local CutLimbInteractionHandler = require("TOC/UI/Interactions/CutLimbInteractionHandler") local WoundCleaningInteractionHandler = require("TOC/UI/Interactions/WoundCleaningInteractionHandler") @@ -11,6 +11,9 @@ local WoundCleaningInteractionHandler = require("TOC/UI/Interactions/WoundCleani local isReady = false function SetHealthPanelTOC() + + -- depending on compatibility + isReady = true end @@ -128,23 +131,23 @@ function ISHealthPanel:render() end -local og_ISHealthPanel_update = ISHealthPanel.update -function ISHealthPanel:update() - og_ISHealthPanel_update(self) - -- TODO Listen for changes on other player side instead of looping this +-- local og_ISHealthPanel_update = ISHealthPanel.update +-- function ISHealthPanel:update() +-- og_ISHealthPanel_update(self) +-- -- TODO Listen for changes on other player side instead of looping this - -- FIX Re-enable it, just for test - if self.character then - local locPlUsername = getPlayer():getUsername() - local remPlUsername = self.character:getUsername() - if locPlUsername ~= remPlUsername and self:isReallyVisible() then - -- Request update for TOC DATA - local key = CommandsData.GetKey(remPlUsername) - --ModData.request(key) - end - end -end +-- -- FIX Re-enable it, just for test +-- if self.character then +-- local locPlUsername = getPlayer():getUsername() +-- local remPlUsername = self.character:getUsername() +-- if locPlUsername ~= remPlUsername and self:isReallyVisible() then +-- -- Request update for TOC DATA +-- local key = CommandsData.GetKey(remPlUsername) +-- --ModData.request(key) +-- end +-- end +-- end @@ -252,10 +255,10 @@ end local og_ISHealthPanel_getDamagedParts = ISHealthPanel.getDamagedParts function ISHealthPanel:getDamagedParts() - -- TODO Overriding it is a lot easier, but ew - - if isReady then - + -- check for imeds or if TOC is ready to display its stuff on the health panel + if isReady == false or Compat.handlers['iMeds'].isActive or Compat.handlers['iMedsFixed'].isActive then + return og_ISHealthPanel_getDamagedParts(self) + elseif isReady then local result = {} local bodyParts = self:getPatient():getBodyDamage():getBodyParts() if isClient() and not self:getPatient():isLocalPlayer() then @@ -274,8 +277,5 @@ function ISHealthPanel:getDamagedParts() end end return result - - else - return og_ISHealthPanel_getDamagedParts(self) end end \ No newline at end of file