Fixed update when Health Panel is open for remote pl

This commit is contained in:
ZioPao
2024-03-22 15:52:34 +01:00
parent feab41ac5c
commit 00b1b78cb3
4 changed files with 29 additions and 7 deletions

View File

@@ -1,3 +1,5 @@
if isServer() then return end
local CommandsData = require("TOC/CommandsData") local CommandsData = require("TOC/CommandsData")
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
---------------- ----------------
@@ -346,6 +348,7 @@ function DataController:apply()
ModData.transmit(CommandsData.GetKey(self.username)) ModData.transmit(CommandsData.GetKey(self.username))
end end
---Online only, Global Mod Data doesn't trigger this in SP ---Online only, Global Mod Data doesn't trigger this in SP
---@param key any ---@param key any
---@param data any ---@param data any

View File

@@ -1,4 +1,5 @@
local StaticData = require("TOC/StaticData") local StaticData = require("TOC/StaticData")
local CommandsData = require("TOC/CommandsData")
local DataController = require("TOC/Controllers/DataController") local DataController = require("TOC/Controllers/DataController")
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
@@ -7,7 +8,6 @@ local WoundCleaningInteractionHandler = require("TOC/UI/Interactions/WoundCleani
------------------------ ------------------------
local isReady = false local isReady = false
function SetHealthPanelTOC() function SetHealthPanelTOC()
@@ -125,14 +125,27 @@ function ISHealthPanel:render()
self:tryDrawAmputation(highestAmputations, "R", username) self:tryDrawAmputation(highestAmputations, "R", username)
self:tryDrawProsthesis(highestAmputations, "R", username) self:tryDrawProsthesis(highestAmputations, "R", username)
end end
end 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
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
-- We need to override this to force the alpha to 1 -- We need to override this to force the alpha to 1
local og_ISCharacterInfoWindow_render = ISCharacterInfoWindow.prerender local og_ISCharacterInfoWindow_render = ISCharacterInfoWindow.prerender
function ISCharacterInfoWindow:prerender() function ISCharacterInfoWindow:prerender()
@@ -192,6 +205,9 @@ function ISHealthBodyPartListBox:doDrawItem(y, item, alt)
local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType()) local bodyPartTypeStr = BodyPartType.ToString(bodyPart:getType())
local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr] local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr]
-- We should cache a lot of other stuff to have this working with CacheDataHandler :(
if limbName then if limbName then
local dcInst = DataController.GetInstance(username) local dcInst = DataController.GetInstance(username)
if dcInst:getIsCut(limbName) and dcInst:getIsVisible(limbName) then if dcInst:getIsCut(limbName) and dcInst:getIsVisible(limbName) then

View File

@@ -29,3 +29,4 @@ local function OnClientDebugCommand(module, command, playerObj, args)
end end
Events.OnClientCommand.Add(OnClientDebugCommand) Events.OnClientCommand.Add(OnClientDebugCommand)

View File

@@ -21,6 +21,8 @@ function ServerDataHandler.AddTable(key, table)
if not luautils.stringStarts(key, StaticData.MOD_NAME .. "_") then return end if not luautils.stringStarts(key, StaticData.MOD_NAME .. "_") then return end
TOC_DEBUG.print("Received TOC ModData: " .. tostring(key)) TOC_DEBUG.print("Received TOC ModData: " .. tostring(key))
TOC_DEBUG.printTable(table)
ModData.add(key, table) -- Add it to the server mod data ModData.add(key, table) -- Add it to the server mod data
ServerDataHandler.modData[key] = table ServerDataHandler.modData[key] = table
end end