uitradepacklistitem.lua

main 51 lines · 1.4 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1-- @docclass
2UITradepackListItem = extends(UIWidget, "UITradepackListItem")
3
4function UITradepackListItem.create()
5 local btn = UITradepackListItem.internalCreate()
6 return btn
7end
8
9function UITradepackListItem:onStyleApply(styleName, styleNode)
10 for name,value in pairs(styleNode) do
11 if name == 'even-background-color' then
12 self.evenBackgroundColor = value
13 elseif name == 'odd-background-color' then
14 self.oddBackgroundColor = value
15 end
16 end
17end
18
19function UITradepackListItem:updateBackgroundColor()
20 self.backgroundColor = nil
21
22 local children = self:getParent():getChildren()
23 local isEven = self.isEven
24
25 if isEven and self.evenBackgroundColor then
26 self.backgroundColor = self.evenBackgroundColor
27 elseif not isEven and self.oddBackgroundColor then
28 self.backgroundColor = self.oddBackgroundColor
29 end
30
31 if self.backgroundColor then
32 self:mergeStyle({ ['background-color'] = self.backgroundColor })
33 end
34end
35
36function UITradepackListItem:setRowBackgroundColor(order)
37 self.backgroundColor = nil
38
39 local children = self:getParent():getChildren()
40
41 if order == 'even' and self.evenBackgroundColor then
42 self.backgroundColor = self.evenBackgroundColor
43 elseif order == 'odd' and self.oddBackgroundColor then
44 self.backgroundColor = self.oddBackgroundColor
45 end
46
47 if self.backgroundColor then
48 self:mergeStyle({ ['background-color'] = self.backgroundColor })
49 end
50end
51
Top