Skip to content

Commit 92f1ee8

Browse files
committed
Port over checkbox images from pob2, show icons for spectre type for filtering
1 parent 58cf40d commit 92f1ee8

11 files changed

Lines changed: 458 additions & 11 deletions

File tree

1.82 KB
Loading
1.19 KB
Loading
1.66 KB
Loading
1.59 KB
Loading
1.38 KB
Loading
1.55 KB
Loading

src/Classes/CheckBoxControl.lua

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ local CheckBoxClass = newClass("CheckBoxControl", "Control", "TooltipHost", func
1111
self.labelWidth = DrawStringWidth(self.width - 4, "VAR", label or "") + 5
1212
self.changeFunc = changeFunc
1313
self.state = initialState
14+
self.checkImage = nil
1415
end)
1516

1617
function CheckBoxClass:IsMouseOver()
@@ -42,6 +43,8 @@ function CheckBoxClass:Draw(viewPort, noTooltip)
4243
elseif self.borderFunc then
4344
local r, g, b = self.borderFunc()
4445
SetDrawColor(r, g, b)
46+
elseif self.checkImage and self.state then
47+
SetDrawColor(0.75, 0.75, 0.75)
4548
else
4649
SetDrawColor(0.5, 0.5, 0.5)
4750
end
@@ -56,15 +59,30 @@ function CheckBoxClass:Draw(viewPort, noTooltip)
5659
SetDrawColor(0, 0, 0)
5760
end
5861
DrawImage(nil, x + 1, y + 1, size - 2, size - 2)
59-
if self.state then
60-
if not enabled then
61-
SetDrawColor(0.33, 0.33, 0.33)
62-
elseif mOver then
63-
SetDrawColor(1, 1, 1)
62+
if self.checkImage then
63+
if self.state then
64+
if not enabled then
65+
SetDrawColor(0.33, 0.33, 0.33)
66+
elseif mOver then
67+
SetDrawColor(2, 2, 2)
68+
else
69+
SetDrawColor(1, 1, 1)
70+
end
6471
else
65-
SetDrawColor(0.75, 0.75, 0.75)
72+
SetDrawColor(0.5, 0.5, 0.5)
73+
end
74+
DrawImage(self.checkImage.handle, x + 1, y + 1, size - 2, size - 2, self.checkImage[1])
75+
else
76+
if self.state then
77+
if not enabled then
78+
SetDrawColor(0.33, 0.33, 0.33)
79+
elseif mOver then
80+
SetDrawColor(1, 1, 1)
81+
else
82+
SetDrawColor(0.75, 0.75, 0.75)
83+
end
84+
main:DrawCheckMark(x + size/2, y + size/2, size * 0.8)
6685
end
67-
main:DrawCheckMark(x + size/2, y + size/2, size * 0.8)
6886
end
6987
if enabled then
7088
SetDrawColor(1, 1, 1)
@@ -106,3 +124,8 @@ function CheckBoxClass:OnKeyUp(key)
106124
end
107125
self.clicked = false
108126
end
127+
128+
---@param image table @The image to display instead of a check. Expects a `handle` field with an image handle, and the sprite position at index `1`. All other fields are ignored. Set to `nil` to draw a normal check.
129+
function CheckBoxClass:SetCheckImage(image)
130+
self.checkImage = image
131+
end

0 commit comments

Comments
 (0)