Back to Home

ESO Lua File v101043

ingame/map/keyboard/worldmapantiquities_keyboard.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
ZO_MAP_ANTIQUITY_KEYBOARD_ENTRY_HEIGHT = 60
ZO_MAP_ANTIQUITY_KEYBOARD_CATEGORY_HEIGHT = 32
local ANTIQUITY_ENTRY = 1
local ANTIQUITY_HEADER = 2
ZO_MapAntiquities_Keyboard = ZO_MapAntiquities_Shared:Subclass()
function ZO_MapAntiquities_Keyboard:New(...)
    return ZO_MapAntiquities_Shared.New(self,...)
end
function ZO_MapAntiquities_Keyboard:Initialize(control)
    ZO_MapAntiquities_Shared.Initialize(self, control, ZO_FadeSceneFragment)
end
function ZO_MapAntiquities_Keyboard:InitializeList(control)
    self.list = control:GetNamedChild("List")
    local function SetupAntiquity(entryControl, entryData)
        local antiquityData = entryData.antiquityData
        entryControl.antiquityData = antiquityData
        if not entryControl.progressIconMetaPool then
            entryControl.progressIconMetaPool = ZO_MetaPool:New(self.progressIconControlPool)
        end
        entryControl.nameLabel:SetText(antiquityData:GetColorizedFormattedName())
        entryControl.trackedIcon:SetHidden(not entryData.isTracked)
        local numGoalsAchieved = antiquityData:GetNumGoalsAchieved()
        local previousIcon
        local totalNumGoals = antiquityData:GetTotalNumGoals()
        for goalIndex = 1, totalNumGoals do
            local iconControl = entryControl.progressIconMetaPool:AcquireObject()
            iconControl:SetParent(entryControl)
            if numGoalsAchieved >= goalIndex then
                iconControl:SetTexture("EsoUI/Art/Antiquities/digsite_complete.dds")
            else
                iconControl:SetTexture("EsoUI/Art/Antiquities/digsite_unknown.dds")
            end
            if previousIcon then
                iconControl:SetAnchor(TOPLEFT, previousIcon, TOPRIGHT, 2)
            else
                iconControl:SetAnchor(TOPLEFT, entryControl.nameLabel, BOTTOMLEFT, 0, 2)
            end
            previousIcon = iconControl
        end
    end
    local function ResetAntiquity(entryControl)
        ZO_ObjectPool_DefaultResetControl(entryControl)
        entryControl.antiquityData = nil
        entryControl.progressIconMetaPool:ReleaseAllObjects()
    end
    local NO_HIDE_CALLBACK = nil
    local NO_SELECT_SOUND = nil
    ZO_ScrollList_AddDataType(self.list, ANTIQUITY_ENTRY, "ZO_AntiquityMapEntry_Keyboard", ZO_MAP_ANTIQUITY_KEYBOARD_ENTRY_HEIGHT, SetupAntiquity, NO_HIDE_CALLBACK, NO_SELECT_SOUND, ResetAntiquity)
    local function SetupHeader(headerControl, data)
        headerControl.label:SetText(data.text)
    end
    ZO_ScrollList_AddDataType(self.list, ANTIQUITY_HEADER, "ZO_AntiquityMapHeader_Keyboard", ZO_MAP_ANTIQUITY_KEYBOARD_CATEGORY_HEIGHT, SetupHeader)
    ZO_ScrollList_EnableHighlight(self.list, "ZO_TallListHighlight")
end
function ZO_MapAntiquities_Keyboard:SetListEnabled(enabled)
    ZO_MapAntiquities_Shared.SetListEnabled(self, enabled)
end
function ZO_MapAntiquities_Keyboard:RefreshList()
    ZO_MapAntiquities_Shared.RefreshList(self)
    local scrollData = ZO_ScrollList_GetDataList(self.list)
    local antiquityEntries = self:GetSortedAntiquityEntries()
    local lastAntiquityCategory
    for i, antiquityEntry in ipairs(antiquityEntries) do
        if lastAntiquityCategory ~= antiquityEntry.antiquityCategory then
            local dataEntry = ZO_ScrollList_CreateDataEntry(ANTIQUITY_HEADER, { text = GetString(ZO_MAP_ANTIQUITY_CATEGORY_TO_HEADER_STRING[antiquityEntry.antiquityCategory]) })
            table.insert(scrollData, dataEntry)
            lastAntiquityCategory = antiquityEntry.antiquityCategory
        end
        local dataEntry = ZO_ScrollList_CreateDataEntry(ANTIQUITY_ENTRY, antiquityEntry)
        table.insert(scrollData, dataEntry)
    end
end
function ZO_MapAntiquities_Keyboard:AntiquityMapEntryClicked(control, button)
    if WORLD_MAP_MANAGER:IsInMode(MAP_MODE_DIG_SITES) then
        return
    end
    -- primary action is to track the selected antiquity and secondry is to scry
    -- If you left-click on an antiquity that isn't in progress, show the right-click
    -- context menu so it's easy to see what options there are
    local antiquityData = control.antiquityData
    local antiquityIsInProgress = antiquityData:IsInProgress()
    local antiquityIsTracked = antiquityData:IsTracked()
    if button == MOUSE_BUTTON_INDEX_LEFT and antiquityIsInProgress then
        local antiquityId = antiquityData:GetId()
        if not antiquityIsTracked then
            SetTrackedAntiquityId(antiquityId)
        end
        WORLD_MAP_MANAGER:ShowAntiquityOnMap(antiquityId)
    elseif button == MOUSE_BUTTON_INDEX_RIGHT or (button == MOUSE_BUTTON_INDEX_LEFT and not antiquityIsInProgress) then
        ClearMenu()
        local canTrackAntiquity = antiquityIsInProgress and not antiquityIsTracked
        if canTrackAntiquity then
            AddMenuItem(GetString(SI_WORLD_MAP_ANTIQUITIES_TRACK), function()
                local antiquityId = antiquityData:GetId()
                SetTrackedAntiquityId(antiquityId)
                WORLD_MAP_MANAGER:ShowAntiquityOnMap(antiquityId)
            end)
        end
        if antiquityData:CanScry() then
            AddMenuItem(GetString(SI_ANTIQUITY_SCRY), function()
                SCENE_MANAGER:ShowBaseScene()
                ScryForAntiquity(antiquityData:GetId())
            end)
        end
        if antiquityIsInProgress then
            AddMenuItem(GetString(SI_ANTIQUITY_ABANDON), function()
                ZO_Dialogs_ShowDialog("CONFIRM_ABANDON_ANTIQUITY_SCRYING_PROGRESS", { antiquityId = antiquityData:GetId(), })
            end)
        end
        ShowMenu(control)
    end
end
function ZO_MapAntiquities_Keyboard:AntiquityMapEntryMouseEnter(control)
end
function ZO_MapAntiquities_Keyboard:AntiquityMapEntryMouseExit(control)
end
-- Global XML functions
    if upInside then
        WORLD_MAP_ANTIQUITIES_KEYBOARD:AntiquityMapEntryClicked(control, button)
    end
end
    WORLD_MAP_ANTIQUITIES_KEYBOARD:AntiquityMapEntryMouseEnter(control)
end
    WORLD_MAP_ANTIQUITIES_KEYBOARD:AntiquityMapEntryMouseExit(control)
end
    WORLD_MAP_ANTIQUITIES_KEYBOARD = ZO_MapAntiquities_Keyboard:New(self)
end