Back to Home

ESO Lua File v100029

ingame/campaign/campaignoverview.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
local ZO_CampaignOverviewManager = ZO_Object:Subclass()
function ZO_CampaignOverviewManager:New(control)
    local manager = ZO_Object.New(self)
    manager.control = control
    CAMPAIGN_OVERVIEW_SCENE = ZO_Scene:New("campaignOverview", SCENE_MANAGER)
    CAMPAIGN_OVERVIEW_SCENE:RegisterCallback("StateChange", function(oldState, newState)
                                                                if newState == SCENE_SHOWING then
                                                                    manager:ChangeCategory(manager.overviewType)
                                                                end
                                                            end)
    manager.campaignName = GetControl(control, "CampaignName")
    manager:InitializeCategories()
    return manager
end
function ZO_CampaignOverviewManager:UpdateCampaignName(campaignId)
    local campaignName = GetCampaignName(campaignId)
    self.campaignName:SetText(campaignName)
end
function ZO_CampaignOverviewManager:SetCampaignAndQueryType(campaignId, queryType)
    self:UpdateCampaignName(campaignId)
end
local CAMPAIGN_OVERVIEW_TYPE_SCORING = 1
local CAMPAIGN_OVERVIEW_TYPE_BONUSES = 2
local CAMPAIGN_OVERVIEW_TYPE_EMPEROR = 3
local CAMPAIGN_OVERVIEW_TYPE_INFO =
{
    [CAMPAIGN_OVERVIEW_TYPE_SCORING] = 
    {
        name = GetString(SI_CAMPAIGN_OVERVIEW_CATEGORY_SCORING),
        up = "EsoUI/Art/Campaign/overview_indexIcon_scoring_up.dds",
        down = "EsoUI/Art/Campaign/overview_indexIcon_scoring_down.dds",
        over = "EsoUI/Art/Campaign/overview_indexIcon_scoring_over.dds",
    },
    [CAMPAIGN_OVERVIEW_TYPE_BONUSES] = 
    {
        name = GetString(SI_CAMPAIGN_OVERVIEW_CATEGORY_BONUSES),
        up = "EsoUI/Art/Campaign/overview_indexIcon_bonus_up.dds",
        down = "EsoUI/Art/Campaign/overview_indexIcon_bonus_down.dds",
        over = "EsoUI/Art/Campaign/overview_indexIcon_bonus_over.dds",
        visible = function() return GetAssignedCampaignId() ~= 0 end,
    },
    [CAMPAIGN_OVERVIEW_TYPE_EMPEROR] = 
    {
        name = GetString(SI_CAMPAIGN_OVERVIEW_CATEGORY_EMPERORSHIP),
        up = "EsoUI/Art/Campaign/overview_indexIcon_emperor_up.dds",
        down = "EsoUI/Art/Campaign/overview_indexIcon_emperor_down.dds",
        over = "EsoUI/Art/Campaign/overview_indexIcon_emperor_over.dds",
    },
}
function ZO_CampaignOverviewManager:InitializeCategories()
    self.tree = ZO_Tree:New(GetControl(self.control, "Categories"), 60, -10, 280)
    local function CategorySetup(node, control, overviewType, down)
        local info = CAMPAIGN_OVERVIEW_TYPE_INFO[overviewType]
        control.text:SetModifyTextType(MODIFY_TEXT_TYPE_UPPERCASE)
        control.text:SetText(info.name)
        control.overviewType = overviewType
        control.icon:SetTexture(down and info.down or info.up)
        control.iconHighlight:SetTexture(info.over)
        ZO_IconHeader_Setup(control, down)
    end
    local function CategorySelected(control, overviewType, selected, reselectingDuringRebuild)
        if selected then
            self:ChangeCategory(overviewType)
        end
        CategorySetup(nil, control, overviewType, selected)
    end
    self.tree:AddTemplate("ZO_CampaignOverviewType", CategorySetup, CategorySelected, nil)
    self.tree:SetExclusive(true)
    self.control:RegisterForEvent(EVENT_ASSIGNED_CAMPAIGN_CHANGED, function() self:RefreshCategories() end)
end
function ZO_CampaignOverviewManager:RefreshCategories()
    self.tree:Reset()
    for categoryType, categoryInfo in ipairs(CAMPAIGN_OVERVIEW_TYPE_INFO) do
        if not categoryInfo.visible or categoryInfo.visible() then
            self.tree:AddNode("ZO_CampaignOverviewType", categoryType)
        end
    end
    self.tree:Commit()
end
function ZO_CampaignOverviewManager:ChangeCategory(overviewType)
    self.overviewType = overviewType
    if not CAMPAIGN_BONUSES_FRAGMENT or not CAMPAIGN_EMPEROR_FRAGMENT or not CAMPAIGN_SCORING_FRAGMENT then
        return
    end
    if overviewType == CAMPAIGN_OVERVIEW_TYPE_SCORING then
        CAMPAIGN_OVERVIEW_SCENE:RemoveFragment(CAMPAIGN_BONUSES_FRAGMENT)
        CAMPAIGN_OVERVIEW_SCENE:RemoveFragment(CAMPAIGN_EMPEROR_FRAGMENT)
        CAMPAIGN_OVERVIEW_SCENE:AddFragment(CAMPAIGN_SCORING_FRAGMENT)
    elseif overviewType == CAMPAIGN_OVERVIEW_TYPE_BONUSES then
        CAMPAIGN_OVERVIEW_SCENE:RemoveFragment(CAMPAIGN_SCORING_FRAGMENT)
        CAMPAIGN_OVERVIEW_SCENE:RemoveFragment(CAMPAIGN_EMPEROR_FRAGMENT)
        CAMPAIGN_OVERVIEW_SCENE:AddFragment(CAMPAIGN_BONUSES_FRAGMENT)
    else
        CAMPAIGN_OVERVIEW_SCENE:RemoveFragment(CAMPAIGN_SCORING_FRAGMENT)
        CAMPAIGN_OVERVIEW_SCENE:RemoveFragment(CAMPAIGN_BONUSES_FRAGMENT)
        CAMPAIGN_OVERVIEW_SCENE:AddFragment(CAMPAIGN_EMPEROR_FRAGMENT)
    end
end
    CAMPAIGN_OVERVIEW = ZO_CampaignOverviewManager:New(self)
end