Back to Home

ESO Lua File v101044

ingame/collections/keyboard/collectibleimitationtile_keyboard.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
-- Primary logic class must be subclassed after the platform class so that platform specific functions will have priority over the logic class functionality
ZO_CollectibleImitationTile_Keyboard = ZO_Object.MultiSubclass(ZO_ContextualActionsTile_Keyboard, ZO_ContextualActionsTile)
function ZO_CollectibleImitationTile_Keyboard:New(...)
    return ZO_ContextualActionsTile.New(self, ...)
end
-- Begin ZO_ContextualActionsTile_Keyboard Overrides --
function ZO_CollectibleImitationTile_Keyboard:InitializePlatform()
    ZO_ContextualActionsTile_Keyboard.InitializePlatform(self)
    self.statusMultiIcon = self.control:GetNamedChild("Status")
end
function ZO_CollectibleImitationTile_Keyboard:PostInitializePlatform()
    -- keybindStripDescriptor and canFocus need to be set after initialize, because ZO_ContextualActionsTile
    -- won't have finished initializing those until after InitializePlatform is called
    ZO_ContextualActionsTile_Keyboard.PostInitializePlatform(self)
    table.insert(self.keybindStripDescriptor,
    {
        keybind = "UI_SHORTCUT_PRIMARY",
        name = function()
            return GetString(self:GetPrimaryInteractionStringId())
        end,
        callback = function()
            self:Use()
        end,
        visible = function()
            return self:IsUsable() and self:GetPrimaryInteractionStringId() ~= nil
        end,
    })
    self:SetCanFocus(false)
end
-- End ZO_ContextualActionsTile_Keyboard Overrides --
-- Begin ZO_Tile Overrides --
function ZO_CollectibleImitationTile_Keyboard:Reset()
    self.imitationCollectibleData = nil
    self:SetCanFocus(false)
    local INSTANT = true
    self:SetHighlightHidden(true, INSTANT)
    self:SetTitle("")
    self.statusMultiIcon:ClearIcons()
end
-- End ZO_Tile Overrides --
-- Begin ZO_ContextualActionsTile Overrides --
function ZO_CollectibleImitationTile_Keyboard:OnControlHidden()
    self:OnMouseExit()
    ZO_ContextualActionsTile.OnControlHidden(self)
end
function ZO_CollectibleImitationTile_Keyboard:OnFocusChanged(isFocused)
    ZO_ContextualActionsTile.OnFocusChanged(self, isFocused)
    if not isFocused then
        ClearTooltip(InformationTooltip)
    end
end
function ZO_CollectibleImitationTile_Keyboard:SetHighlightHidden(hidden, instant)
    ZO_ContextualActionsTile.SetHighlightHidden(self, hidden, instant)
    if hidden then
        ZO_CollectibleTile_Keyboard_MouseOverIconAnimationProvider:PlayBackward(self:GetIconTexture(), instant)
    else
        ZO_CollectibleTile_Keyboard_MouseOverIconAnimationProvider:PlayForward(self:GetIconTexture(), instant)
    end
end
-- End ZO_ContextualActionsTile Overrides --
-- Begin ZO_ContextualActionsTile_Keyboard Overrides --
function ZO_CollectibleImitationTile_Keyboard:LayoutPlatform(imitationCollectibleData)
    self.imitationCollectibleData = imitationCollectibleData
    self:SetCanFocus(true)
    -- Title
    self:SetTitle(imitationCollectibleData:GetName())
    -- Icon/Highlight
    local iconTexture = self:GetIconTexture()
    iconTexture:SetTexture(imitationCollectibleData:GetIcon())
    local desaturation = imitationCollectibleData:IsBlocked(self:GetActorCategory()) and 1 or 0
    self:GetHighlightControl():SetDesaturation(desaturation)
    iconTexture:SetDesaturation(desaturation)
    self:Refresh()
end
function ZO_CollectibleImitationTile_Keyboard:Refresh()
    -- Status
    local statusMultiIcon = self.statusMultiIcon
    statusMultiIcon:ClearIcons()
    if self:IsActive() and not self.imitationCollectibleData:ShouldSuppressActiveState(self:GetActorCategory()) then
        statusMultiIcon:AddIcon(ZO_CHECK_ICON)
    end
    statusMultiIcon:Show()
    self:UpdateKeybinds()
    -- Mouseover
end
function ZO_CollectibleImitationTile_Keyboard:OnMouseUp(button, upInside)
    if upInside and button == MOUSE_BUTTON_INDEX_RIGHT then
        self:ShowMenu()
    end
end
function ZO_CollectibleImitationTile_Keyboard:OnMouseDoubleClick(button)
    if button == MOUSE_BUTTON_INDEX_LEFT and self:IsUsable() then
        self:Use()
    end
end
-- End ZO_ContextualActionsTile_Keyboard Overrides --
function ZO_CollectibleImitationTile_Keyboard:GetActorCategory()
    return self.imitationCollectibleData.actorCategory or GAMEPLAY_ACTOR_CATEGORY_PLAYER
end
function ZO_CollectibleImitationTile_Keyboard:RefreshTitleLabelColor()
    local labelColor = self:IsMousedOver() and ZO_HIGHLIGHT_TEXT or ZO_NORMAL_TEXT
end
function ZO_CollectibleImitationTile_Keyboard:RefreshMouseoverVisuals()
    if self:IsMousedOver() then
        local description = self.imitationCollectibleData:GetDescription(self:GetActorCategory())
        if description then
            -- Tooltip
            ClearTooltip(InformationTooltip)
            local offsetX = self.control:GetParent():GetLeft() - self.control:GetLeft() - 5
            InitializeTooltip(InformationTooltip, self.control, RIGHT, offsetX, 0, LEFT)
            local DEFAULT_FONT = ""
            local r, g, b = ZO_NORMAL_TEXT:UnpackRGB()
            InformationTooltip:AddLine(self.imitationCollectibleData:GetName(), DEFAULT_FONT, r, g, b)
            InformationTooltip:AddLine(description, DEFAULT_FONT, r, g, b)
            if self:IsActive() and self.imitationCollectibleData.GetActiveCollectibleText then
                local activeCollectibleText = self.imitationCollectibleData:GetActiveCollectibleText(self:GetActorCategory())
                if activeCollectibleText ~= nil and activeCollectibleText ~= "" then
                    InformationTooltip:AddLine(activeCollectibleText, DEFAULT_FONT, r, g, b)
                end
            end
            if self.imitationCollectibleData:IsBlocked(self:GetActorCategory()) then
                local errorR, errorG, errorB = ZO_ERROR_COLOR:UnpackRGB()
                InformationTooltip:AddLine(self.imitationCollectibleData:GetBlockReason(self:GetActorCategory()), DEFAULT_FONT, errorR, errorG, errorB)
            end
        end
    end
end
function ZO_CollectibleImitationTile_Keyboard:GetPrimaryInteractionStringId()
    if not self.imitationCollectibleData:IsBlocked(self:GetActorCategory()) then
        return self.imitationCollectibleData:GetPrimaryInteractionStringId(self:GetActorCategory())
    end
    return nil
end
function ZO_CollectibleImitationTile_Keyboard:ShowMenu()
    ClearMenu()
    --Use
    local stringId = self:GetPrimaryInteractionStringId()
    if stringId and self:IsUsable() then
        AddMenuItem(GetString(stringId), function() self:Use() end)
    end
end
function ZO_CollectibleImitationTile_Keyboard:IsActive()
    return self.imitationCollectibleData:IsActive(self:GetActorCategory())
end
function ZO_CollectibleImitationTile_Keyboard:IsUsable()
    return self.imitationCollectibleData:IsUsable(self:GetActorCategory())
end
function ZO_CollectibleImitationTile_Keyboard:Use()
    self.imitationCollectibleData:Use(self:GetActorCategory())
end
-- Begin Global XML Functions --
    ZO_CollectibleImitationTile_Keyboard:New(control)
end
-- End Global XML Functions --