Back to Home

ESO Lua File v100016

ingame/campaign/campaignavarank.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
local CAMPAIGN_AVA_RANK
CampaignAvARank = ZO_Object:Subclass()
function CampaignAvARank:New(control)
    local manager = ZO_Object.New(self)
    manager.name = GetControl(control, "Name")
    manager.icon = GetControl(control, "Icon")
    manager.rank = GetControl(control, "Rank")
    manager.statusBar = GetControl(control, "XPBar")
    ZO_StatusBar_SetGradientColor(manager.statusBar, ZO_AVA_RANK_GRADIENT_COLORS)
    control:RegisterForEvent(EVENT_RANK_POINT_UPDATE, function() manager:Refresh() end) 
    manager:Refresh()
    return manager
end
local function GetCurrentRankProgress()
    local rankPoints = GetUnitAvARankPoints("player")
    local _, _, rankStartsAt, nextRankAt = GetAvARankProgress(rankPoints)
    if(rankPoints >= nextRankAt) then
        local rank = GetUnitAvARank("player")
        local lastRankPoints = GetNumPointsNeededForAvARank(rank - 1)
        local maxRankPoints = GetNumPointsNeededForAvARank(rank)
        local fullRankPoints = maxRankPoints - lastRankPoints
        return fullRankPoints, fullRankPoints
    else
        return rankPoints - rankStartsAt, nextRankAt - rankStartsAt
    end
end
function CampaignAvARank:Refresh()
    local alliance = GetUnitAlliance("player")
    local rank = GetUnitAvARank("player")
    self.name:SetText(zo_strformat(SI_AVA_ALLIANCE_AND_RANK_NAME, GetAllianceName(alliance), GetAvARankName(GetUnitGender("player"), rank)))
    self.rank:SetText(rank)
    self.icon:SetTexture(GetLargeAvARankIcon(rank))
    local current, max = GetCurrentRankProgress()
    self.statusBar:SetMinMax(0,max)    
    self.statusBar:SetValue(current)
    if(InformationTooltip:GetOwner() == ZO_CampaignAvARankXPBar) then
        ZO_CampaignAvARankStatusBar_OnMouseEnter(ZO_CampaignAvARankXPBar)
    end
end
--Global XML
    InitializeTooltip(InformationTooltip, control, TOP, 0, 5)
    SetTooltipText(InformationTooltip, zo_strformat(SI_AVA_RANK_PROGRESS_TOOLTIP, GetCurrentRankProgress()))
end
    ClearTooltip(InformationTooltip)
end
    CAMPAIGN_AVA_RANK = CampaignAvARank:New(self)
end