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

29 lines
609 B
Plaintext
Raw Normal View History

2024-03-17 20:18:03 -04:00
-- 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