Back to Home

ESO Lua File v100033

libraries/zo_tile/claimtile.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
----
-- ZO_ClaimTile
----
------
-- For order of instantiation to happen in the intended order the base class must be inherited before it's platform counterpart
-- (IMPLEMENTS OF THESE FUNCTIONS IN THIS CLASS WILL BE COMPETELY OVERRIDDEN BY PLATFORM SPECIFIC IMPLEMENTATIONS)
-- SetActionAvailable
-- SetActionText
-- SetActionCallback
------
ZO_ClaimTile = ZO_ActionTile:Subclass()
ZO_CLAIM_TILE_STATE = {
    UNCLAIMED = 1,
    CLAIMED = 2
}
function ZO_ClaimTile:New(...)
    return ZO_ActionTile.New(self, ...)
end
function ZO_ClaimTile:Initialize(control)
    ZO_ActionTile.Initialize(self, control)
    -- Platform specific implementation
    self:SetActionCallback(function() self:RequestClaim() end)
end
function ZO_ClaimTile:PostInitialize()
    ZO_ActionTile.PostInitialize(self)
end
function ZO_ClaimTile:RefreshHeaderText()
    -- To be overridden
end
function ZO_ClaimTile:RefreshActionText()
    local locString
    if self.claimState == ZO_CLAIM_TILE_STATE.UNCLAIMED then
        locString = self:GetUnclaimedString()
    else
        locString = self:GetClaimedString()
    end
    -- Platform specific implementation
    self:SetActionText(locString)
end
function ZO_ClaimTile:GetUnclaimedString()
    return GetString(SI_CLAIM_TILE_CLAIM)
end
function ZO_ClaimTile:GetClaimedString()
    return GetString(SI_CLAIM_TILE_VIEW_ALL)
end
function ZO_ClaimTile:SetClaimState(claimState)
    self.claimState = claimState
end
function ZO_ClaimTile:RequestClaim()
    self:SetClaimState(ZO_CLAIM_TILE_STATE.CLAIMED)
    if self.onClaimCallback then
        self.onClaimCallback()
    end
    if self.animationTimeline then
        local animationTransitionCallback = function()
            self.animationTimeline:SetHandler("OnStop", nil)
    
            self:OnAnimationTransitionCompleted()
        end
        self.animationTimeline:SetHandler("OnStop", animationTransitionCallback)
    end
    self:PlayAnimation()
end
function ZO_ClaimTile:SetClaimCallback(onClaimCallback)
end
function ZO_ClaimTile:SetAnimation(animation)
    self.animationTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual(animation, self.container)
end
function ZO_ClaimTile:PlayAnimation()
    if self.animationTimeline then
        self.animationTimeline:PlayForward()
    else
    end
end
function ZO_ClaimTile:OnAnimationTransitionCompleted()
end
function ZO_ClaimTile:OnClaimCompleted()
    self:RefreshLayout()
    if self.animationTimeline then
        self.animationTimeline:PlayBackward()
    end
end