From 1a8b12aed8bb3ffd97c1216285037bc46431b395 Mon Sep 17 00:00:00 2001 From: Winkarst <74284083+Winkarst-cpu@users.noreply.github.co> Date: Thu, 26 Dec 2024 01:31:50 +0300 Subject: [PATCH] Remove TODO for cl_charcreate.lua payload --- gamemode/core/derma/cl_charcreate.lua | 33 +++++++-------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/gamemode/core/derma/cl_charcreate.lua b/gamemode/core/derma/cl_charcreate.lua index 1dc6a505a..300b0a8ea 100644 --- a/gamemode/core/derma/cl_charcreate.lua +++ b/gamemode/core/derma/cl_charcreate.lua @@ -161,7 +161,7 @@ function PANEL:Init() self.progress:SetPos(0, parent:GetTall() - self.progress:GetTall()) -- setup payload hooks - self:AddPayloadHook("model", function(value) + self.payload:AddHook("model", function(value) local faction = ix.faction.indices[self.payload.faction] if (faction) then @@ -281,13 +281,17 @@ function PANEL:ResetPayload(bWithHooks) self.payload = {} - -- TODO: eh.. function self.payload.Set(payload, key, value) - self:SetPayload(key, value) + self.payload[key] = value + + for _, v in ipairs(self.hooks[key] or {}) do + v(value) + end end function self.payload.AddHook(payload, key, callback) - self:AddPayloadHook(key, callback) + self.hooks[key] = self.hooks[key] or {} + self.hooks[key][#self.hooks[key] + 1] = callback end function self.payload.Prepare(payload) @@ -297,27 +301,6 @@ function PANEL:ResetPayload(bWithHooks) end end -function PANEL:SetPayload(key, value) - self.payload[key] = value - self:RunPayloadHook(key, value) -end - -function PANEL:AddPayloadHook(key, callback) - if (!self.hooks[key]) then - self.hooks[key] = {} - end - - self.hooks[key][#self.hooks[key] + 1] = callback -end - -function PANEL:RunPayloadHook(key, value) - local hooks = self.hooks[key] or {} - - for _, v in ipairs(hooks) do - v(value) - end -end - function PANEL:GetContainerPanel(name) -- TODO: yuck if (name == "description") then