Back to Home

ESO Lua File v100035

ingame/leveluprewards/leveluprewardsclaim_base.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
ZO_LevelUpRewardsClaim_Base = ZO_Object:Subclass()
function ZO_LevelUpRewardsClaim_Base:New(...)
    local rewards = ZO_Object.New(self)
    rewards:Initialize(...)
    return rewards
end
function ZO_LevelUpRewardsClaim_Base:Initialize()
    self.rewardLevel = nil
    ZO_LEVEL_UP_REWARDS_MANAGER:RegisterCallback("OnLevelUpRewardsChoiceUpdated", function() if self:IsShowing() then self:RefreshSelectedChoices() end end)
end
function ZO_LevelUpRewardsClaim_Base:ShowLevelUpRewards()
    local rewardLevel = ZO_LEVEL_UP_REWARDS_MANAGER:GetPendingRewardLevel()
    if rewardLevel then
        self.rewardLevel = rewardLevel
        self:UpdateHeader()
        local rewardEntryInfo = ZO_LEVEL_UP_REWARDS_MANAGER:GetPendingLevelUpRewards()
        self:AddRewards(rewardEntryInfo)
    else
        --It's possible in high latency that they player could claim their last available reward and then make it back to the claim menu entry before the server acknowledges that we claimed it. This can lead
        --to the pending reward info being wiped out as we are changing scenes into claim. So if this happens, we just hide claim automatically.
        self.rewardLevel = nil
        self.rewardId = nil
        self:Hide()
    end
end
function ZO_LevelUpRewardsClaim_Base:GetRewardLevel()
    return self.rewardLevel
end
function ZO_LevelUpRewardsClaim_Base:UpdateHeader()
    --to be overridden
end
function ZO_LevelUpRewardsClaim_Base:AddRewards(rewards)
    --to be overridden
end
function ZO_LevelUpRewardsClaim_Base:Show()
    --to be overridden
end
function ZO_LevelUpRewardsClaim_Base:Hide()
    --to be overridden
end
function ZO_LevelUpRewardsClaim_Base:IsShowing()
    --to be overridden
end
function ZO_LevelUpRewardsClaim_Base:RefreshSelectedChoices()
    --to be overridden
end
function ZO_LevelUpRewardsClaim_Base:ClaimLevelUpRewards()
    local numFreeInventorySlotsNeeded = GetNumInventorySlotsNeededForLevelUpReward(self.rewardLevel)
    if CheckInventorySpaceAndWarn(numFreeInventorySlotsNeeded) then
        ClaimPendingLevelUpReward()
        PlaySound(SOUNDS.LEVEL_UP_REWARD_CLAIM)
    end
end