Back to Home

ESO Lua File v101043

publicallingames/tribute/tributepatrontile_shared.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
-------------------------
-- Tribute Patron Tile --
-------------------------
ZO_TributePatronTile_Shared = ZO_ContextualActionsTile:Subclass()
function ZO_TributePatronTile_Shared:New(...)
    return ZO_ContextualActionsTile.New(self, ...)
end
function ZO_TributePatronTile_Shared:Initialize(...)
    ZO_ContextualActionsTile.Initialize(self, ...)
    self.iconTexture = self.control:GetNamedChild("Icon")
end
-- Begin ZO_Tile Overrides --
function ZO_TributePatronTile_Shared:Layout(patronData)
    self.patronData = patronData
    self.iconTexture:SetTexture(patronData:GetPatronLargeIcon())
    ZO_ContextualActionsTile.Layout(self, patronData)
end
-- End ZO_Tile Overrides --
-----------------------------------
-- Tribute Patron Selection Tile --
-----------------------------------
ZO_TributePatronSelectionTile_Shared = ZO_TributePatronTile_Shared:Subclass()
function ZO_TributePatronSelectionTile_Shared:Initialize(...)
    ZO_TributePatronTile_Shared.Initialize(self, ...)
    self.keybindStripDescriptor =
    {
        {
            keybind = "UI_SHORTCUT_PRIMARY",
            name = GetString(SI_TRIBUTE_DECK_SELECTION_SELECT_PATRON),
            order = 1,
            callback = function()
                if self.patronData and ZO_TRIBUTE_PATRON_SELECTION_MANAGER then
                    ZO_TRIBUTE_PATRON_SELECTION_MANAGER:SelectPatron(self.patronData:GetId())
                    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
                end
            end,
            visible = function()
                return self:CanSelect()
            end,
        }
    }
end
function ZO_TributePatronSelectionTile_Shared:CanSelect()
    if self.patronData and ZO_TRIBUTE_PATRON_SELECTION_MANAGER then
        local patronId = self.patronData:GetId()
        if self.patronData:IsPatronLocked() then
            return false
        elseif ZO_TRIBUTE_PATRON_SELECTION_MANAGER:IsPatronDrafted(patronId) then
            return false
        elseif patronId == ZO_TRIBUTE_PATRON_SELECTION_MANAGER:GetSelectedPatron() then
            return false
        elseif ZO_TRIBUTE_PATRON_SELECTION_MANAGER:IsDraftAnimating() then
            return false
        else
            return GetActiveTributePlayerPerspective() == TRIBUTE_PLAYER_PERSPECTIVE_SELF
        end
    end
    return false
end