Back to Home

ESO Lua File v101044

libraries/zo_tile/gamepad/checkboxtile_gamepad.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---------------------------
-- Checkbox Tile Gamepad --
---------------------------
ZO_CHECKBOX_TILE_GAMEPAD_WIDTH = 350
ZO_CHECKBOX_TILE_GAMEPAD_HEIGHT = 45
-- Primary logic class must be subclassed after the platform class so that platform specific functions will have priority over the logic class functionality
ZO_CheckboxTile_Gamepad = ZO_Object.MultiSubclass(ZO_Tile_Gamepad, ZO_Tile)
function ZO_CheckboxTile_Gamepad:New(...)
    return ZO_Tile.New(self, ...)
end
function ZO_CheckboxTile_Gamepad:PostInitializePlatform()
    ZO_Tile_Gamepad.PostInitializePlatform(self)
    self.textLabel = self.control:GetNamedChild("Text")
    self.iconControl = self.control:GetNamedChild("Icon")
    self.selectorControl = self.control:GetNamedChild("SelectorBox")
end
function ZO_CheckboxTile_Gamepad:OnSelectionChanged()
    ZO_Tile_Gamepad.OnSelectionChanged(self)
end
function ZO_CheckboxTile_Gamepad:Layout(data)
    ZO_Tile.Layout(self, data)
    self.data = data
    self.textLabel:SetText(data.text)
end
function ZO_CheckboxTile_Gamepad:GetIsChecked()
    if type(self.data.isChecked) == "function" then
        return self.data.isChecked()
    end
    return self.data.isChecked
end
function ZO_CheckboxTile_Gamepad:GetIsDisabled()
    if type(self.data.isDisabled) == "function" then
        return self.data.isDisabled()
    end
    return self.data.isDisabled
end
function ZO_CheckboxTile_Gamepad:OnCheckboxToggle()
    local isDisabled = self:GetIsDisabled()
    if not isDisabled then
        PlaySound(self.data.clickSound)
        if self.data.onToggleFunction then
            self.data.onToggleFunction(self.data.value, not self:GetIsChecked())
        end
        self:UpdateVisualDisplay()
    end
end
function ZO_CheckboxTile_Gamepad:UpdateVisualDisplay()
    local color
    local isChecked = self:GetIsChecked()
    local isDisabled = self:GetIsDisabled()
    if self:IsSelected() then
        if isChecked then
            if isDisabled then
                color = ZO_GAMEPAD_COMPONENT_COLORS.SELECTED_ACTIVE_DISABLED
            else
                color = ZO_GAMEPAD_COMPONENT_COLORS.SELECTED_ACTIVE
            end
        else
            color = ZO_GAMEPAD_COMPONENT_COLORS.SELECTED_INACTIVE
        end
    else
        if isChecked then
            if isDisabled then
                color = ZO_GAMEPAD_COMPONENT_COLORS.UNSELECTED_ACTIVE_DISABLED
            else
                color = ZO_GAMEPAD_COMPONENT_COLORS.UNSELECTED_ACTIVE
            end
        else
            color = ZO_GAMEPAD_COMPONENT_COLORS.UNSELECTED_INACTIVE
        end
    end
    self.textLabel:SetColor(color:UnpackRGB())
    self.selectorControl:SetHidden(not self:IsSelected())
    self.iconControl:SetHidden(not isChecked)
end
-- XML functions
----------------
    ZO_CheckboxTile_Gamepad:New(control)
end