Back to Home

ESO Lua File v101050

publicallingames/tooltip/rewardtooltips.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
do
    local NOT_EQUIPPED = false
    local NO_CREATOR_NAME = nil
    local FORCE_FULL_DURABILITY = true
    local NO_PREVIEW_VALUE = nil
    function ZO_Tooltip:LayoutReward(rewardId, amount, displayFlags)
        local rewardType = GetRewardType(rewardId)
        -- For some market product types we can just use other tooltip layouts
        if rewardType == REWARD_ENTRY_TYPE_COLLECTIBLE then
            local collectibleId = GetCollectibleRewardCollectibleId(rewardId)
            local params =
            {
                collectibleId = collectibleId,
                showIfPurchasable = true,
            }
            self:LayoutCollectibleWithParams(params)
            return
        elseif rewardType == REWARD_ENTRY_TYPE_ITEM then
            local stackCount = amount
            local itemLink = GetItemRewardItemLink(rewardId, amount, displayFlags)
            self:LayoutItemWithStackCount(itemLink, NOT_EQUIPPED, NO_CREATOR_NAME, FORCE_FULL_DURABILITY, NO_PREVIEW_VALUE, stackCount, EQUIP_SLOT_NONE)
            return
        elseif rewardType == REWARD_ENTRY_TYPE_LOOT_CRATE then
            local crateId = GetCrownCrateRewardCrateId(rewardId)
            local quantity = amount
            self:LayoutCrownCrate(crateId, quantity)
            return
        elseif rewardType == REWARD_ENTRY_TYPE_ADD_CURRENCY then
            local currencyType = GetAddCurrencyRewardInfo(rewardId)
            self:LayoutCurrency(currencyType, amount)
            return
        elseif rewardType == REWARD_ENTRY_TYPE_INSTANT_UNLOCK then
            local instantUnlockId = GetInstantUnlockRewardInstantUnlockId(rewardId)
            self:LayoutInstantUnlock(instantUnlockId)
            return
        elseif rewardType == REWARD_ENTRY_TYPE_REWARD_LIST then
            local rewardListId = GetRewardListIdFromReward(rewardId)
            self:LayoutRewardList(rewardListId)
            return
        elseif rewardType == REWARD_ENTRY_TYPE_CHOICE then
            local rewardListId = GetChoiceRewardListId(rewardId)
            local HAS_CHOICE = true
            self:LayoutRewardList(rewardListId, HAS_CHOICE)
            return
        elseif rewardType == REWARD_ENTRY_TYPE_ADD_TITLE then
            local rewardTitleName, isAcquired = GetAddTitleRewardTitleInfo(rewardId)
            self:LayoutRewardTitleTooltip(rewardTitleName, isAcquired)
            return
        end
    end
end
do
    local g_dailyLoginRewardtimerStatValuePair
    function ZO_Tooltip:LayoutDailyLoginReward(rewardIndex)
        local rewardId, quantity = GetDailyLoginRewardInfoForCurrentMonth(rewardIndex)
        if ShouldUseFallbackReward(rewardId) then
            rewardId, quantity = GetFallbackReward(rewardId)
        end
        self:LayoutReward(rewardId, quantity, REWARD_DISPLAY_FLAGS_NONE)
        g_dailyLoginRewardtimerStatValuePair = nil
        local claimableRewardIndex = GetDailyLoginClaimableRewardIndex()
        local nextPotentialRewardIndex = ZO_DAILYLOGINREWARDS_MANAGER:GetNextPotentialReward()
        if not claimableRewardIndex and nextPotentialRewardIndex == rewardIndex then
            local timeToNextClaim = GetTimeUntilNextDailyLoginRewardClaimS()
            local timeToNextMonth = GetTimeUntilNextDailyLoginMonthS()
            if timeToNextMonth == 0 or timeToNextClaim < timeToNextMonth then
                local timerSection = self:AcquireSection(self:GetStyle("dailyLoginRewardsTimerSection"))
                local statValuePair = timerSection:AcquireStatValuePair(self:GetStyle("statValuePair"))
                statValuePair:SetStat(GetString(SI_GAMEPAD_DAILY_LOGIN_REWARDS_TOOLTIP_AVAILABLE_TIMER), self:GetStyle("statValuePairStat"))
                local formattedTime = ZO_FormatTimeLargestTwo(timeToNextClaim, TIME_FORMAT_STYLE_DESCRIPTIVE_MINIMAL)
                statValuePair:SetValue(formattedTime, self:GetStyle("statValuePairValue"))
                timerSection:AddStatValuePair(statValuePair)
                self:AddSection(timerSection)
                g_dailyLoginRewardtimerStatValuePair = statValuePair
            end
        end
        if rewardIndex > GetNumClaimableDailyLoginRewardsInCurrentMonth() then
            local lockedSection = self:AcquireSection(self:GetStyle("dailyLoginRewardsLockedSection"))
            lockedSection:AddLine(GetString(SI_DAILY_LOGIN_REWARDS_NOT_CLAIMABLE_TOOLTIP))
            self:AddSection(lockedSection)
        end
    end
    function ZO_Tooltip:UpdateDailyLoginRewardTimer()
        if g_dailyLoginRewardtimerStatValuePair then
            local formattedTime = ZO_FormatTimeLargestTwo(GetTimeUntilNextDailyLoginRewardClaimS(), TIME_FORMAT_STYLE_DESCRIPTIVE_MINIMAL)
            g_dailyLoginRewardtimerStatValuePair:SetValue(formattedTime, self:GetStyle("statValuePairValue"))
        end
    end
end
function ZO_Tooltip:LayoutRewardData(rewardData)
    local rewardId = rewardData:GetRewardId()
    local quantity = rewardData:GetQuantity()
    local displayFlags = rewardData:GetDisplayFlags()
    self:LayoutReward(rewardId, quantity, displayFlags)
end
function ZO_Tooltip:LayoutRewardList(rewardListId, hasChoice)
    local headerSection = self:AcquireSection(self:GetStyle("title"))
    local headerString = hasChoice and SI_PROMOTIONAL_EVENT_CHOICE_REWARD_TOOLTIP_HEADER or SI_GAMEPAD_TOOLTIPS_REWARD_LIST_HEADER
    headerSection:AddLine(GetString(headerString))
    self:AddSection(headerSection)
    -- TODO: Append reward type text in parenthetical?
    local rewardsSection = self:AcquireSection(self:GetStyle("bodySection"))
    local numRewardListEntries = GetNumRewardListEntries(rewardListId)
    for rewardIndex = 1, numRewardListEntries do
        local rewardId, rewardType, amount = GetRewardListEntryInfo(rewardListId, rewardIndex)
        if rewardType == REWARD_ENTRY_TYPE_COLLECTIBLE then
            local collectibleId = GetCollectibleRewardCollectibleId(rewardId)
            local formattedName = ZO_CachedStrFormat(SI_COLLECTIBLE_NAME_FORMATTER, GetCollectibleName(collectibleId))
            rewardsSection:AddLine(formattedName, self:GetStyle("bodyDescription"), self:GetStyle("whiteFontColor"))
        elseif rewardType == REWARD_ENTRY_TYPE_ITEM then
            local itemLink = GetItemRewardItemLink(rewardId, amount, displayFlags)
            local itemName = GetItemLinkName(itemLink)
            if amount and amount > 1 then
                itemName = zo_strformat(SI_TOOLTIP_ITEM_NAME_WITH_QUANTITY, itemName, amount)
            end
            local displayQuality = GetItemLinkDisplayQuality(itemLink)
            local qualityStyle = ZO_TooltipStyles_GetItemQualityStyle(displayQuality)
            rewardsSection:AddLine(zo_strformat(SI_TOOLTIP_ITEM_NAME, itemName), qualityStyle, self:GetStyle("bodyDescription"), self:GetStyle("whiteFontColor"))
        elseif rewardType == REWARD_ENTRY_TYPE_LOOT_CRATE then
            local crateId = GetCrownCrateRewardCrateId(rewardId)
            local displayName = GetCrownCrateName(crateId)
            if amount and amount > 1 then
                displayName = zo_strformat(SI_TOOLTIP_ITEM_NAME_WITH_QUANTITY, displayName, amount)
            else
                displayName = zo_strformat(SI_TOOLTIP_ITEM_NAME, displayName)
            end
            rewardsSection:AddLine(displayName, self:GetStyle("bodyDescription"), self:GetStyle("whiteFontColor"))
        elseif rewardType == REWARD_ENTRY_TYPE_ADD_CURRENCY then
            local currencyType = GetAddCurrencyRewardInfo(rewardId)
            local IS_UPPER = false
            local displayName
            if amount and amount > 1 then
                local currencyName = GetCurrencyName(currencyType, IS_PLURAL)
                displayName = zo_strformat(SI_TOOLTIP_ITEM_NAME_WITH_QUANTITY, currencyName, amount)
            else
                local IS_SINGULAR = true
                local currencyName = GetCurrencyName(currencyType, IS_SINGULAR)
                displayName = zo_strformat(SI_TOOLTIP_ITEM_NAME, currencyName)
            end
            rewardsSection:AddLine(displayName, self:GetStyle("bodyDescription"), self:GetStyle("whiteFontColor"))
        elseif rewardType == REWARD_ENTRY_TYPE_INSTANT_UNLOCK then
            local instantUnlockId = GetInstantUnlockRewardInstantUnlockId(rewardId)
            local displayName = GetInstantUnlockRewardDisplayName(instantUnlockId)
            displayName = zo_strformat(SI_TOOLTIP_ITEM_NAME, displayName)
            rewardsSection:AddLine(displayName, self:GetStyle("bodyDescription"), self:GetStyle("whiteFontColor"))
        end
    end
    self:AddSection(rewardsSection)
end
function ZO_Tooltip:LayoutRewardTitleTooltip(rewardTitleName, isAcquired)
    local headerSection = self:AcquireSection(self:GetStyle("bodyHeader"))
    local isAcquiredText = isAcquired and GetString(SI_REWARD_TITLE_TOOLTIP_ACQUIRED) or GetString(SI_REWARD_TITLE_TOOLTIP_NOT_ACQUIRED)
    headerSection:AddLine(isAcquiredText)
    headerSection:AddLine(GetString(SI_REWARD_TITLE_TOOLTIP_LABEL))
    self:AddSection(headerSection)
    local titleTextSection = self:AcquireSection(self:GetStyle("title"))
    titleTextSection:AddLine(rewardTitleName)
    self:AddSection(titleTextSection)
    local descriptionSection = self:AcquireSection(self:GetStyle("bodySection"))
    local colorizedTitle = ZO_SELECTED_TEXT:Colorize(rewardTitleName)
    descriptionSection:AddLine(zo_strformat(SI_REWARD_TITLE_TOOLTIP_DESCRIPTION_FORMATTER, colorizedTitle), self:GetStyle("bodyDescription"))
    self:AddSection(descriptionSection)
end