Back to Home

ESO Lua File v101041

libraries/zo_tile/contextualactionstile.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
103
104
105
106
107
108
109
110
111
112
113
114
115
------
-- For order of instantiation to happen in the intended order the base class must be inherited after it's platform counterpart
-- "Focus" will be determined by the nature of "selection" per platform
------
ZO_ContextualActionsTile = ZO_Tile:Subclass()
function ZO_ContextualActionsTile:New(...)
    return ZO_Tile.New(self, ...)
end
function ZO_ContextualActionsTile:Initialize(control)
    ZO_Tile.Initialize(self, control)
    self.titleLabel = self.control:GetNamedChild("Title")
    self.iconTexture = self.control:GetNamedChild("Icon")
    self.highlightControl = self.control:GetNamedChild("Highlight")
    self.keybindStripDescriptor = {}
    self.isFocused = false
    self.canFocus = true
end
function ZO_ContextualActionsTile:GetTitleLabel()
    return self.titleLabel
end
function ZO_ContextualActionsTile:SetTitle(titleText)
    self.titleLabel:SetText(titleText)
end
function ZO_ContextualActionsTile:GetIconTexture()
    return self.iconTexture
end
function ZO_ContextualActionsTile:SetIcon(iconFile)
    self.iconTexture:SetTexture(iconFile)
end
function ZO_ContextualActionsTile:GetHighlightControl()
    return self.highlightControl
end
function ZO_ContextualActionsTile:SetHighlightAnimationProvider(provider)
    self.highlightAnimationProvider = provider
end
function ZO_ContextualActionsTile:GetKeybindStripDescriptor()
    return self.keybindStripDescriptor
end
function ZO_ContextualActionsTile:CanFocus()
    return self.canFocus
end
function ZO_ContextualActionsTile:SetCanFocus(canFocus)
    if self:CanFocus() ~= canFocus then
        if not canFocus then
            self:Defocus()
        end
        self.canFocus = canFocus
    end
end
function ZO_ContextualActionsTile:IsFocused()
    return self.isFocused
end
function ZO_ContextualActionsTile:Focus()
    if self:CanFocus() and not self:IsFocused() then
        self.isFocused = true
        self:OnFocusChanged(self.isFocused)
    end
end
function ZO_ContextualActionsTile:Defocus()
    if self:CanFocus() and self:IsFocused() then
        self.isFocused = false
        self:OnFocusChanged(self.isFocused)
    end
end
function ZO_ContextualActionsTile:OnFocusChanged(isFocused)
    if isFocused then
        KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
        self:SetHighlightHidden(false)
    else
        KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
        self:SetHighlightHidden(true)
    end
end
function ZO_ContextualActionsTile:SetHighlightHidden(hidden, instant)
    if self.highlightAnimationProvider then
        if hidden then
            self.highlightAnimationProvider:PlayBackward(self.highlightControl, instant)
        else
            self.highlightAnimationProvider:PlayForward(self.highlightControl, instant)
        end
    end
end
function ZO_ContextualActionsTile:UpdateKeybinds()
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
-- Begin ZO_Tile Overrides --
function ZO_ContextualActionsTile:OnControlHidden()
    ZO_Tile.OnControlHidden(self)
    self:Defocus()
end
-- End ZO_Tile Overrides --