Back to Home

ESO Lua File v100036

ingame/campaign/campaignbonuses.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
local BONUSES_HEADER_DATA = 1
local BONUSES_DATA = 2
local ZO_CampaignBonusesManager = ZO_SortFilterList:Subclass()
function ZO_CampaignBonusesManager:New(control)
    local manager = ZO_SortFilterList.New(self, control)
    manager.shown = false
    self.campaignBonuses = ZO_CampaignBonuses_Shared:New(control)
    ZO_ScrollList_AddDataType(manager.list, BONUSES_HEADER_DATA, "ZO_CampaignBonusesHeaderRow", 50, function(control, data) manager:SetupBonusesHeaderEntry(control, data) end)
    ZO_ScrollList_AddDataType(manager.list, BONUSES_DATA, "ZO_CampaignBonusesBonusRow", 80, function(control, data) manager:SetupBonusesEntry(control, data) end)
    CAMPAIGN_BONUSES_FRAGMENT = ZO_FadeSceneFragment:New(control)
    CAMPAIGN_BONUSES_FRAGMENT:RegisterCallback("StateChange", function(oldState, newState)
                                                                    if newState == SCENE_FRAGMENT_SHOWN then
                                                                        manager.shown = true
                                                                        manager:RefreshData()
                                                                    elseif newState == SCENE_FRAGMENT_HIDDEN then
                                                                        manager.shown = false
                                                                    end
                                                                end)
    control:RegisterForEvent(EVENT_KEEP_ALLIANCE_OWNER_CHANGED, function() if manager.shown then manager:RefreshData() end end)
    control:RegisterForEvent(EVENT_OBJECTIVES_UPDATED, function() if manager.shown then manager:RefreshData() end end)
    return manager
end
function ZO_CampaignBonusesManager:SetCampaignAndQueryType(campaignId, queryType)
    ZO_CampaignBonuses_Shared.SetCampaignAndQueryType(self.campaignBonuses, campaignId, queryType)
    self:RefreshData()
end
function ZO_CampaignBonusesManager:SetupBonusesHeaderEntry(control, data)
    ZO_SortFilterList.SetupRow(self, control, data)
    control.headerLabel = GetControl(control, "Header")
    control.countInfoLabel = GetControl(control, "CountInfo")
    control.countInfoLabel.bonusType = data.bonusType
    control.headerLabel:SetText(data.headerString)
    control.countInfoLabel:SetText(data.infoString)
end
function ZO_CampaignBonusesManager:SetupBonusesEntry(control, data)
    ZO_SortFilterList.SetupRow(self, control, data)
    control.typeIcon = GetControl(control, "TypeIcon")
    control.count = GetControl(control, "Count")
    control.ability = GetControl(control, "Ability")
    control.icon = GetControl(control.ability, "Icon")
    control.nameLabel = GetControl(control, "Name")
    control.ability.index = data.index
    control.ability.bonusType = data.bonusType
    control.ability:SetEnabled(data.active)
    ZO_ActionSlot_SetUnusable(control.icon, not data.active)
    control.typeIcon:SetTexture(data.typeIcon)
    if data.countText then
        control.count:SetText(zo_strformat(SI_CAMPAIGN_SCORING_HOLDING, data.countText))
        control.count:SetHidden(false)
    else
        control.count:SetHidden(true)
    end
    control.nameLabel:SetText(data.name)
    control.icon:SetTexture(data.icon)
end
function ZO_CampaignBonusesManager:SortScrollList()
    -- No sorting
end
function ZO_CampaignBonusesManager:FilterScrollList()
    local scrollData = ZO_ScrollList_GetDataList(self.list)
    ZO_ClearNumericallyIndexedTable(scrollData)
    for i = 1, #self.campaignBonuses.masterList do
        local data = self.campaignBonuses.masterList[i]
        if data.isHeader then
            table.insert(scrollData, ZO_ScrollList_CreateDataEntry(BONUSES_HEADER_DATA, data))
        else
            table.insert(scrollData, ZO_ScrollList_CreateDataEntry(BONUSES_DATA, data))
        end
    end
end
function ZO_CampaignBonusesManager:BuildMasterList()
    self.campaignBonuses:BuildMasterList()
end
function ZO_CampaignBonusesManager:GetRowColors(data, mouseIsOver)
    if data.isHeader then
        return ZO_CONTRAST_TEXT
    else
        if data.active then
            return ZO_CONTRAST_TEXT
        else
            return ZO_DISABLED_TEXT
        end
    end
end
function ZO_CampaignBonusesManager:ColorRow(control, data, mouseIsOver)
    local textColor = self:GetRowColors(data, mouseIsOver)
    if data.isHeader then
        GetControl(control, "CountInfo"):SetColor(textColor:UnpackRGBA())
    else
        GetControl(control, "Name"):SetColor(textColor:UnpackRGBA())
    end
end
--Global XML
    InitializeTooltip(SkillTooltip, control, TOPLEFT, 5, -5, TOPRIGHT)
    if control.bonusType == ZO_CAMPAIGN_BONUS_TYPE_DEFENSIVE_SCROLLS then
        SkillTooltip:SetScrollBonusAbility(GetUnitAlliance("player"), OBJECTIVE_ARTIFACT_DEFENSIVE, control.index)
    elseif control.bonusType == ZO_CAMPAIGN_BONUS_TYPE_OFFENSIVE_SCROLLS then
        SkillTooltip:SetScrollBonusAbility(GetUnitAlliance("player"), OBJECTIVE_ARTIFACT_OFFENSIVE, control.index)
    elseif control.bonusType == ZO_CAMPAIGN_BONUS_TYPE_EMPEROR then
        SkillTooltip:SetEmperorBonusAbility(CAMPAIGN_BONUSES.campaignBonuses:GetCurrentCampaignId(), GetUnitAlliance("player"))
    elseif control.bonusType== ZO_CAMPAIGN_BONUS_TYPE_EDGE_KEEPS then
        SkillTooltip:SetEdgeKeepBonusAbility(control.index)
    else
        SkillTooltip:SetKeepBonusAbility(control.index)
    end
end
    ClearTooltip(SkillTooltip)
end
    if control.bonusType == ZO_CAMPAIGN_BONUS_TYPE_ENEMY_KEEPS then
        InitializeTooltip(InformationTooltip, control, TOPRIGHT, 0, 5, BOTTOMRIGHT)
        SetTooltipText(InformationTooltip, GetString(SI_CAMPAIGN_BONUSES_ENEMY_KEEP_INFO_TOOLTIP))
    elseif control.bonusType == ZO_CAMPAIGN_BONUS_TYPE_DEFENSIVE_SCROLLS then
        InitializeTooltip(InformationTooltip, control, TOPRIGHT, 0, 5, BOTTOMRIGHT)
        SetTooltipText(InformationTooltip, GetString(SI_CAMPAIGN_BONUSES_ENEMY_SCROLL_INFO_TOOLTIP))
    elseif control.bonusType == ZO_CAMPAIGN_BONUS_TYPE_OFFENSIVE_SCROLLS then
        InitializeTooltip(InformationTooltip, control, TOPRIGHT, 0, 5, BOTTOMRIGHT)
        SetTooltipText(InformationTooltip, GetString(SI_CAMPAIGN_BONUSES_ENEMY_SCROLL_INFO_TOOLTIP))
    end
end
    ClearTooltip(InformationTooltip)
end
    CAMPAIGN_BONUSES = ZO_CampaignBonusesManager:New(self)
end