ESO Lua File v100012

ingame/map/maplocationtooltip.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
178
local function HasMapLocationTooltip(self, locationIndex)
    local headerText = GetMapLocationTooltipHeader(locationIndex)
    if(headerText == "") then
        return false
    end
    local numTooltipLines = GetNumMapLocationTooltipLines(locationIndex)
    if(numTooltipLines == 0) then
        return false
    end
    return true
end
local MIN_HEADER_WIDTH = 150
local function SortGroupings(a, b)
    return a.id < b.id
end
local function SortGrouping(a, b)
    return a.name < b.name
end
local function GetMapLocationLines(locationIndex)
    local groupings = {}
    local numTooltipLines = GetNumMapLocationTooltipLines(locationIndex)
    for lineIndex = 1, numTooltipLines do
        if(IsMapLocationTooltipLineVisible(locationIndex, lineIndex)) then
            --Create labels for the lines. The size of the header depends on the lines.
            local icon, name, groupingId, categoryName = GetMapLocationTooltipLineInfo(locationIndex, lineIndex)
            --Search for an existing grouping
            local grouping
            for groupingIndex = 1, #groupings do
                if(groupings[groupingIndex].id == groupingId) then
                    grouping = groupings[groupingIndex]
                end
            end
            --if there isn't an existing one, make it
            if(grouping == nil) then
                grouping = {}
                grouping.id = groupingId
                table.insert(groupings, grouping)
            end
            table.insert(grouping, {name = name, categoryName = categoryName, icon = icon})
        end
    end
    table.sort(groupings, SortGroupings)
    for groupingIndex = 1, #groupings do
        local grouping = groupings[groupingIndex]
        table.sort(grouping, SortGrouping)
    end
    return groupings
end
local function SetMapLocation(self, locationIndex)
    self:ClearLines()
    local maxWidth = MIN_HEADER_WIDTH
    --add header
    local headerText = GetMapLocationTooltipHeader(locationIndex)
    if(headerText ~= "") then
        self.header:SetText(headerText)
        self:AddControl(self.header)
        self.header:SetAnchor(CENTER)
        self:AddVerticalPadding(-5)
        self:AddControl(self.divider)
        self.divider:SetAnchor(CENTER)
    end
    --add lines
    local groupings = GetMapLocationLines(locationIndex)
    for groupingIndex = 1, #groupings do
        if(groupingIndex > 1) then
            self:AddVerticalPadding(15)
        end
        local grouping = groupings[groupingIndex]
        for textIndex = 1, #grouping do
            local name = grouping[textIndex].name
            local icon = grouping[textIndex].icon
            local text = string.format("|t32:32:%s|t%s", icon, name)
            local label = self.labelPool:AcquireObject()
            label:SetDimensions(0,0)
            label:SetText(text)
            local labelWidth = label:GetTextDimensions()
            maxWidth = zo_max(labelWidth, maxWidth)
            self:AddControl(label)
            label:SetAnchor(CENTER)
            self:AddVerticalPadding(-8)
        end
    end
    self.header:SetWidth(maxWidth)
    self.divider:SetWidth(maxWidth)
    local labels = self.labelPool:GetActiveObjects()
    for _, label in pairs(labels) do
        label:SetWidth(maxWidth)
    end
end
local function SetMapLocation_Gamepad(self, locationIndex)
    local mainSection = self.tooltip:AcquireSection(self.tooltip:GetStyle("mapLocationSection"))
    --add header
    local headerText = GetMapLocationTooltipHeader(locationIndex)
    if headerText ~= "" then
        self:LayoutGroupHeader(mainSection, nil, headerText, self.tooltip:GetStyle("mapTitle"))
    end
    local groupsSection = self.tooltip:AcquireSection(self.tooltip:GetStyle("mapGroupsSection"))
    local groupSectionStyle = self.tooltip:GetStyle("mapLocationGroupSection")
    local entryStyle = self.tooltip:GetStyle("mapLocationTooltipContent")
    --add lines
    local groupings = GetMapLocationLines(locationIndex)
    for _, grouping in ipairs(groupings) do
        local groupSection = groupsSection:AcquireSection(groupSectionStyle)
        for _, entry in ipairs(grouping) do
            local name = zo_strformat(SI_TOOLTIP_UNIT_NAME, entry.name)
            local icon = entry.icon
            icon = icon:gsub("servicetooltipicons/", "servicetooltipicons/gamepad/gp_")
            self:LayoutLargeIconStringLine(groupSection, icon, name, entryStyle)
        end
        groupsSection:AddSection(groupSection)
    end
    mainSection:AddSection(groupsSection)
    self.tooltip:AddSection(mainSection)
end
--Global XML
    self.labelPool:ReleaseAllObjects()
end
    self.labelPool = ZO_ControlPool:New("ZO_MapLocationTooltipLabel", self, "Label")
    self.header = self:GetNamedChild("Header")
    self.divider = self:GetNamedChild("Divider")
end
    ZO_ScrollTooltip_Gamepad:Initialize(self, ZO_TOOLTIP_STYLES, "worldMapTooltip")
    zo_mixin(self, ZO_MapInformationTooltip_Gamepad_Mixin)
    local ALWAYS_ANIMATE = true
    GAMEPAD_WORLD_MAP_TOOLTIP_FRAGMENT = ZO_FadeSceneFragment:New(self:GetParent(), ALWAYS_ANIMATE)
    ZO_Scroll_Gamepad_SetScrollIndicatorSide(self.scrollIndicator, self:GetParent(), LEFT)
end