Divergent/mods/Weapon Parts Overhaul/gamedata/scripts/utils_ui_custom.script

29 lines
609 B
Plaintext

-- standalone class to enable custom code on rclick props
class "UICellPropertiesCustom" (utils_ui.UICellProperties)
function UICellPropertiesCustom:__init(functor) super()
self.functor = functor
end
function UICellPropertiesCustom:OnListItemDbClicked()
if self.list_box:GetSize()==0 then return end
local item = self.list_box:GetSelectedItem()
if not (item) then
return
end
if item.func then
if item.params then
pcall(self.functor, unpack(item.params))
else
pcall(self.functor)
end
self.action_moment = time_continual()
end
if (self:IsShown()) then
self:OnHide()
end
end