ESO Lua File v100011

ingame/tooltip/maptooltips.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
local QUEST_BULLET_ICON = "EsoUI/Art/Miscellaneous/Gamepad/gp_bullet.dds"
-- TODO: These icons may need to be shifted to gamepad icons.
local GROUP_LEADER_ICON = "EsoUI/Art/Compass/groupLeader.dds"
local CURRENT_PLAYER_ICON = "EsoUI/Art/MapPins/UI-WorldMapPlayerPip.dds"
local GROUP_MEMBER_ICON = "EsoUI/Art/MapPins/UI-WorldMapGroupPip.dds"
local TOOLTIP_MONEY_FORMAT
--Section Generators
ZO_MapInformationTooltip_Gamepad_Mixin = {}
function ZO_MapInformationTooltip_Gamepad_Mixin:LayoutIconStringLine(baseSection, icon, string, ...)
    local iconStyle
    if not icon then
        iconStyle = self.tooltip:GetStyle("mapLocationTooltipNoIcon")
    else
        iconStyle = self.tooltip:GetStyle("mapLocationTooltipIcon")
    end
    local lineSection = baseSection:AcquireSection(self.tooltip:GetStyle("mapLocationTooltipContentSection"))
    lineSection:AddTexture(icon, iconStyle, ...)
    lineSection:AddLine(string, ...)
    baseSection:AddSection(lineSection)
end
function ZO_MapInformationTooltip_Gamepad_Mixin:LayoutIconStringRightStringLine(baseSection, icon, string, rightString, ...)
    local iconStyle
    if not icon then
        iconStyle = self.tooltip:GetStyle("mapLocationTooltipNoIcon")
    else
        iconStyle = self.tooltip:GetStyle("mapLocationTooltipIcon")
    end
    local lineSection = baseSection:AcquireSection(self.tooltip:GetStyle("mapLocationTooltipContentSection"))
    lineSection:AddTexture(icon, iconStyle, ...)
    lineSection:AddLine(string, self.tooltip:GetStyle("mapLocationTooltipContentLeftLabel"), ...)
    lineSection:AddLine(rightString, self.tooltip:GetStyle("mapLocationTooltipContentRightLabel"), ...)
    baseSection:AddSection(lineSection)
end
function ZO_MapInformationTooltip_Gamepad_Mixin:LayoutGroupHeader(baseSection, icon, string, ...)
    local iconStyle
    if not icon then
        iconStyle = self.tooltip:GetStyle("mapLocationTooltipNoIcon")
    else
        iconStyle = self.tooltip:GetStyle("mapLocationTooltipIcon")
    end
    local lineSection = baseSection:AcquireSection(self.tooltip:GetStyle("mapLocationTooltipContentSection"))
    lineSection:AddTexture(icon, iconStyle)
    local textSection = lineSection:AcquireSection(self.tooltip:GetStyle("mapLocationHeaderTextSection"))
    textSection:AddLine(string, ...)
    lineSection:AddSection(textSection)
    baseSection:AddSection(lineSection)
end
function ZO_MapInformationTooltip_Gamepad_Mixin:AppendUnitName(unitTag)
    -- NOTE: This function currently only supports group members, which are the only
    -- pins currently shown on the map.
    local icon
    if IsUnitGroupLeader(unitTag) then
        icon = GROUP_LEADER_ICON
    elseif unitTag == "player" then
        icon = CURRENT_PLAYER_ICON
    else
        icon = GROUP_MEMBER_ICON
    end
    local text = GenerateUnitNameTooltipLine(unitTag)
    self:LayoutIconStringLine(self.tooltip, icon, text, self.tooltip:GetStyle("mapUnitName"), self.tooltip:GetStyle("keepBaseTooltipContent"))
end
function ZO_MapInformationTooltip_Gamepad_Mixin:AppendQuestEnding(questIndex)
    local isFocusedQuest = GetTrackedIsAssisted(TRACK_TYPE_QUEST, questIndex)
    local colorStyle = self.tooltip:GetStyle(isFocusedQuest and "mapQuestFocused" or "mapQuestNonFocused")
    local text = GenerateQuestEndingTooltipLine(questIndex)
    self:LayoutIconStringLine(self.tooltip, QUEST_BULLET_ICON, text, colorStyle, self.tooltip:GetStyle("keepBaseTooltipContent"))
end
function ZO_MapInformationTooltip_Gamepad_Mixin:AppendQuestCondition(questIndex, stepIndex, conditionIndex)
    local isFocusedQuest = GetTrackedIsAssisted(TRACK_TYPE_QUEST, questIndex)
    local colorStyle = self.tooltip:GetStyle(isFocusedQuest and "mapQuestFocused" or "mapQuestNonFocused")
    local text = GenerateQuestConditionTooltipLine(questIndex, stepIndex, conditionIndex)
    self:LayoutIconStringLine(self.tooltip, QUEST_BULLET_ICON, text, colorStyle, self.tooltip:GetStyle("keepBaseTooltipContent"))
end
function ZO_MapInformationTooltip_Gamepad_Mixin:AppendMapPing(pinType, unitTag)
    local text = GenerateMapPingTooltipLine(pinType, unitTag)
    self:LayoutIconStringLine(self.tooltip, nil, text, self.tooltip:GetStyle("keepBaseTooltipContent"))
end
function ZO_MapInformationTooltip_Gamepad_Mixin:AppendAvAObjective(queryType, keepId, objectiveId, isSpawnLocation)
    local text = GenerateAvAObjectiveConditionTooltipLine(queryType, keepId, objectiveId, isSpawnLocation)
    self:LayoutIconStringLine(self.tooltip, nil, text, self.tooltip:GetStyle("keepBaseTooltipContent"))
end
function ZO_MapInformationTooltip_Gamepad_Mixin:AddMoney(baseSection, amount, reason, notEnough, ...)
    -- Lazy setup of the local money format as the global one is not available at the time this file is loaded.
    if not TOOLTIP_MONEY_FORMAT then
        TOOLTIP_MONEY_FORMAT = ZO_ShallowTableCopy(GAMEPAD_INVENTORY_CURRENCY_OPTIONS_LONG_FORMAT)
        TOOLTIP_MONEY_FORMAT.font = nil
    end
    local lineSection = baseSection:AcquireSection(self.tooltip:GetStyle("mapLocationTooltipDoubleContentSection"))
    lineSection:AddTexture(nil, iconStyle, self.tooltip:GetStyle("mapLocationTooltipNoIcon"))
    if reason then
        lineSection:AddLine(reason, ...)
    end
    if amount > 0 then
        lineSection:AddSimpleCurrency(CURRENCY_TYPE_MONEY, amount, TOOLTIP_MONEY_FORMAT, CURRENCY_DONT_SHOW_ALL, notEnough, ...)
    end
    baseSection:AddSection(lineSection)
end
function ZO_MapInformationTooltip_Gamepad_Mixin:AppendWayshrineTooltip(pin)
    local wayshrineSection = self.tooltip:AcquireSection(self.tooltip:GetStyle("mapLocationTooltipSection"))
    local nodeIndex = pin:GetFastTravelNodeIndex()
    local known, name, _, _, icon, glowIcon, poiType, isShown = GetFastTravelNodeInfo(nodeIndex)
    local currentLoc = (ZO_Map_GetFastTravelNode() == nodeIndex)
    self:LayoutIconStringLine(wayshrineSection, icon, zo_strformat(SI_WORLD_MAP_LOCATION_NAME, name), self.tooltip:GetStyle("mapLocationTooltipWayshrineHeader"))
    if currentLoc then
        self:LayoutIconStringLine(wayshrineSection, nil, zo_strformat(SI_TOOLTIP_WAYSHRINE_CURRENT_LOC, name), self.tooltip:GetStyle("mapKeepAt"), self.tooltip:GetStyle("keepBaseTooltipContent"))
    elseif ZO_Map_GetFastTravelNode() == nil then --recall
        if IsInCampaign() then
            self:LayoutIconStringLine(wayshrineSection, nil, zo_strformat(SI_TOOLTIP_WAYSHRINE_CANT_RECALL_AVA, name), self.tooltip:GetStyle("mapKeepInaccessible"), self.tooltip:GetStyle("keepBaseTooltipContent"))
        else
            local _, premiumTimeLeft = GetRecallCooldown()
            if premiumTimeLeft == 0 then
                local cost = GetRecallCost()
                local hasEnoughMoney = (cost <= GetCurrentMoney())
                if cost > 0 then
                    self:AddMoney(wayshrineSection, cost, GetString(SI_GAMEPAD_WORLD_MAP_TOOLTIP_RECALL_COST), not hasEnoughMoney, self.tooltip:GetStyle("mapLocationTooltipContentLeftLabel"), self.tooltip:GetStyle("mapRecallCost"))
                end
            else
                local cooldownText = zo_strformat(SI_TOOLTIP_WAYSHRINE_RECALL_COOLDOWN, ZO_FormatTimeMilliseconds(premiumTimeLeft, TIME_FORMAT_STYLE_DESCRIPTIVE, TIME_FORMAT_PRECISION_SECONDS))
                self:LayoutIconStringLine(wayshrineSection, nil, cooldownText, self.tooltip:GetStyle("mapKeepInaccessible"), self.tooltip:GetStyle("keepBaseTooltipContent"))
            end
        end
    else --interaction
        local keyText = ZO_Keybindings_GetKeyText(KEY_GAMEPAD_BUTTON_1)
        local travelText = zo_strformat(SI_GAMEPAD_TOOLTIP_WAYSHRINE_FAST_TRAVEL_INTERACT, keyText)
        self:LayoutIconStringLine(wayshrineSection, nil, travelText, self.tooltip:GetStyle("mapKeepAccessible"), self.tooltip:GetStyle("keepBaseTooltipContent"))
    end
    self.tooltip:AddSection(wayshrineSection)
end