Skip to content

Commit

Permalink
Remove TODO for cl_charcreate.lua payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Winkarst authored and Winkarst committed Dec 25, 2024
1 parent 4e49199 commit 1a8b12a
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions gamemode/core/derma/cl_charcreate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 1a8b12a

Please sign in to comment.