-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lore.lua
347 lines (322 loc) · 14.4 KB
/
Lore.lua
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
---------------------------------------------------------
-- Addon declaration
HandyNotes_Lorewalkers = LibStub("AceAddon-3.0"):NewAddon("HandyNotes_Lorewalkers","AceEvent-3.0","AceConsole-3.0")
local HL = HandyNotes_Lorewalkers
local HandyNotes = LibStub("AceAddon-3.0"):GetAddon("HandyNotes")
-- local L = LibStub("AceLocale-3.0"):GetLocale("HandyNotes_Lorewalkers", true)
local debugf = tekDebug and tekDebug:GetFrame("Lorewalkers")
local function Debug(...) if debugf then debugf:AddMessage(string.join(", ", tostringall(...))) end end
if C_AddOns.IsAddOnLoaded("HandyNotes_MistsOfPandariaTreasures") then
HL:Print("has been replaced by HandyNotes_MistsOfPandariaTreasures and can be removed")
do return end
else
HL:Print("has been replaced by HandyNotes_MistsOfPandariaTreasures, which you should go download instead")
end
---------------------------------------------------------
-- Our db upvalue and db defaults
local db
local defaults = {
profile = {
completed = false,
icon_scale = 1.4,
icon_alpha = 0.8,
},
}
---------------------------------------------------------
-- Localize some globals
local next = next
local GameTooltip = GameTooltip
local HandyNotes = HandyNotes
local GetAchievementInfo = GetAchievementInfo
local GetAchievementCriteriaInfo = GetAchievementCriteriaInfo
---------------------------------------------------------
-- Constants
local get_icon
do
local icons, backup_icon
local GetPOITextureCoords = _G.GetPOITextureCoords or C_Minimap.GetPOITextureCoords
get_icon = function(achievement)
if not icons then
local function setupLandmarkIcon(left, right, top, bottom)
return {
icon = [[Interface\Minimap\POIIcons]],
tCoordLeft = left,
tCoordRight = right,
tCoordTop = top,
tCoordBottom = bottom,
}
end
icons = {
[6856] = setupLandmarkIcon(GetPOITextureCoords(111)), -- Ballad of Liu Lang
[6716] = setupLandmarkIcon(GetPOITextureCoords(112)), -- Between a Saurok and a Hard Place
[6846] = setupLandmarkIcon(GetPOITextureCoords(113)), -- Fish Tails
[6857] = setupLandmarkIcon(GetPOITextureCoords(114)), -- Heart of the Mantid Swarm
[6850] = setupLandmarkIcon(GetPOITextureCoords(115)), -- Hozen in the Mist
[7230] = setupLandmarkIcon(GetPOITextureCoords(116)), -- Legend of the Brewfathers
[6754] = setupLandmarkIcon(GetPOITextureCoords(117)), -- The Dark Heart of the Mogu
[6855] = setupLandmarkIcon(GetPOITextureCoords(118)), -- The Seven Burdens of Shaohao
[6847] = setupLandmarkIcon(GetPOITextureCoords(119)), -- The Song of the Yaungol
[6858] = setupLandmarkIcon(GetPOITextureCoords(120)), -- What is Worth Fighting For
[8049] = setupLandmarkIcon(GetPOITextureCoords(112)), -- Zandalari Prophecy
[8050] = setupLandmarkIcon(GetPOITextureCoords(113)), -- Rumbles of Thunder
[8051] = setupLandmarkIcon(GetPOITextureCoords(114)), -- Gods and Monsters
}
backup_icon = setupLandmarkIcon(GetPOITextureCoords(111)) -- fallback
end
return icons[achievement] or backup_icon
end
end
local points = {
-- [mapfile] = { [coord] = { [achievement_id], [criteria_index] } }
[379] = { -- Kun Lai Summit
[71726302] = {6847, 3}, -- The Song of the Yaungol, Yaungoil
[40904250] = {6855, 7}, -- The Seven Burdens of Shaohao, The Emperor's Burden - Part 7
[77559533] = {6716, 2}, -- Between a Saurok and a Hard Place, The Defiant
[67764833] = {6855, 6}, -- The Seven Burdens of Shaohao, The Emperor's Burden - Part 6
[74488355] = {6846, 4}, -- Fish Tails, Role Call
[44705237] = {7230, 3}, -- Legend of the Brewfathers, Ren Yun the Blind
[50307930] = {6847, 1}, -- The Song of the Yaungol, Yaungol Tactics
[50604805] = {6754, 1}, -- The Dark Heart of the Mogu, Valley of the Emperors
[63044082] = {6858, 5}, -- What is Worth Fighting For, Victory in Kun-Lai
[43825119] = {6855, 2}, -- The Seven Burdens of Shaohao, The Emperor's Burden - Part 2
[45766190] = {6850, 4}, -- Hozen in the Mist, The Hozen Ravage
-- [53004650] = {6754, 1, "Entrance"}, -- The Dark Heart of the Mogu, Valley of the Emperors
},
[388] = { -- Townlong Steppes
[84087286] = {6847, 4}, -- The Song of the Yaungol, Trapped in a Strange Land
[37746291] = {6855, 5}, -- The Seven Burdens of Shaohao, The Emperor's Burden - Part 5
[65505010] = {6847, 2}, -- The Song of the Yaungol, Dominance
},
[376] = { -- Valley of the Four Winds
[34576387] = {6856, 3}, -- Ballad of Liu Lang, The Wandering Widow
[20255586] = {6856, 1}, -- Ballad of Liu Lang, The Birthplace of Liu Lang
[83192118] = {6850, 3}, -- Hozen in the Mist, Embracing the Passions
[18843170] = {6858, 1}, -- What is Worth Fighting For, Pandaren Fighting Tactics
[61223469] = {6846, 2}, -- Fish Tails, Waterspeakers
[55094713] = {6856, 2}, -- Ballad of Liu Lang, A Most Famous Bill of Sale
},
[422] = { -- Dread Wastes
[67506090] = {6716, 3}, -- Between a Saurok and a Hard Place, The Deserters
[35533261] = {6857, 4}, -- Heart of the Mantid Swarm, The Empress
-- [53611548] = {6857, 3, "Entrance"}, -- Heart of the Mantid Swarm, Amber
[52521006] = {6857, 3}, -- Heart of the Mantid Swarm, Amber
[48383285] = {6857, 1}, -- Heart of the Mantid Swarm, Cycle of the Mantid
[59905470] = {6857, 2}, -- Heart of the Mantid Swarm, Mantid Society
},
[418] = { -- Krasarang Wilds
[52962742] = {6754, 2}, -- The Dark Heart of the Mogu, The Lost Dynasty
[33402500] = {6716, 4}, -- Between a Saurok and a Hard Place, The Last Stand
[41705420] = {6855, 4}, -- The Seven Burdens of Shaohao, The Emperor's Burden - Part 4
[54508770] = {6850, 2}, -- Hozen in the Mist, Hozen Maturiy
[31003480] = {6846, 3}, -- Fish Tails, Origins
[75812668] = {6856, 4}, -- Ballad of Liu Lang, Waiting for the Turtle
[85600560] = {7230, 1}, -- Legend of the Brewfathers, Quan Tou Kou the Two Fisted
},
[390] = { -- Vale of Eternal Blossoms
[26622149] = {6858, 4}, -- What is Worth Fighting For, Together, We Are Strong
[40247748] = {6754, 4}, -- The Dark Heart of the Mogu, The Thunder King
[52936865] = {6858, 2}, -- What is Worth Fighting For, Always Remember
[68804422] = {6855, 8}, -- The Seven Burdens of Shaohao, The Emperor's Burden - Part 8
},
[371] = { -- The Jade Forest
[35743046] = {6858, 3}, -- What is Worth Fighting For, The First Monks
[47084514] = {6855, 1}, -- The Seven Burdens of Shaohao, The Emperor's Burden - Part 1
[26382833] = {6850, 1}, -- Hozen in the Mist, Hozen Speech
[67722935] = {6716, 1}, -- Between a Saurok and a Hard Place, The Saurok
[42261747] = {6754, 3}, -- The Dark Heart of the Mogu, Spirit Binders
[37303012] = {7230, 2}, -- Legend of the Brewfathers, Xin Wo Yin the Broken Hearted
[66018756] = {6846, 1}, -- Fish Tails, Watersmithing
[55885685] = {6855, 3}, -- The Seven Burdens of Shaohao, The Emperor's Burden - Part 3
},
[504] = { -- Isle of the Thunder King
[35107010] = {8049, 1}, -- Zandalari Prophecy, Coming of Age
[68704580] = {8049, 2}, -- Zandalari Prophecy, For Council and King
[36307040] = {8049, 3}, -- Zandalari Prophecy, Shadows of the Loa
[52604140] = {8049, 4}, -- Zandalari Prophecy, The Dark Prophet Zul
[40204060] = {8050, 1}, -- Rumbles of Thunder, Lei Shen
[47005990] = {8050, 2}, -- Rumbles of Thunder, The Sacred Mount
[34906560] = {8050, 3}, -- Rumbles of Thunder, Unity at a Price
[60706880] = {8050, 4}, -- Rumbles of Thunder, The Pandaren Problem
[35805470] = {8051, 1}, -- Gods and Monsters, Agents of Order
[59202630] = {8051, 2}, -- Gods and Monsters, Shadow, Storm, and Stone
[49902040] = {8051, 3}, -- Gods and Monsters, The Curse and the Silence
[62503770] = {8051, 4}, -- Gods and Monsters, Age of a Hundred Kings
},
}
local info_from_coord = function(uiMapId, coord)
local point = points[uiMapId] and points[uiMapId][coord]
if point then
local _, achievement = GetAchievementInfo(point[1])
local criteria = GetAchievementCriteriaInfo(point[1], point[2])
return achievement, criteria
end
end
---------------------------------------------------------
-- Plugin Handlers to HandyNotes
local HLHandler = {}
local info = {}
function HLHandler:OnEnter(uiMapId, coord)
local tooltip = GameTooltip
if ( self:GetCenter() > UIParent:GetCenter() ) then -- compare X coordinate
tooltip:SetOwner(self, "ANCHOR_LEFT")
else
tooltip:SetOwner(self, "ANCHOR_RIGHT")
end
local achievement, criteria = info_from_coord(uiMapId, coord)
if achievement then
tooltip:SetText(("%s (%s)"):format(achievement, criteria))
tooltip:Show()
end
end
local function createWaypoint(button, uiMapId, coord)
local x, y = HandyNotes:getXY(coord)
local achievement, criteria = info_from_coord(uiMapId, coord)
if TomTom then
local persistent, minimap, world
if temporary then
persistent = true
minimap = false
world = false
end
TomTom:AddWaypoint(uiMapId, x, y, {
title=achievement,
persistent=persistent,
minimap=minimap,
world=world
})
end
end
do
local currentZone, currentCoord
local function generateMenu(button, level)
if (not level) then return end
for k in pairs(info) do info[k] = nil end
if (level == 1) then
-- Create the title of the menu
info.isTitle = 1
info.text = "HandyNotes - Lorewalkers"
info.notCheckable = 1
UIDropDownMenu_AddButton(info, level)
if TomTom then
-- Waypoint menu item
info.disabled = nil
info.isTitle = nil
info.notCheckable = nil
info.text = "Create waypoint"
info.icon = nil
info.func = createWaypoint
info.arg1 = currentZone
info.arg2 = currentCoord
UIDropDownMenu_AddButton(info, level);
end
-- Close menu item
info.text = "Close"
info.icon = nil
info.func = function() CloseDropDownMenus() end
info.arg1 = nil
info.notCheckable = 1
UIDropDownMenu_AddButton(info, level);
end
end
local HL_Dropdown = CreateFrame("Frame", "HandyNotes_LorewalkersDropdownMenu")
HL_Dropdown.displayMode = "MENU"
HL_Dropdown.initialize = generateMenu
function HLHandler:OnClick(button, down, uiMapId, coord)
if button == "RightButton" and not down then
currentZone = uiMapId
currentCoord = coord
ToggleDropDownMenu(1, nil, HL_Dropdown, self, 0, 0)
end
end
end
function HLHandler:OnLeave(uiMapId, coord)
GameTooltip:Hide()
end
do
local function should_show(achievement, criteria)
if db.completed then return true end
if GetAchievementNumCriteria(achievement) >= criteria then
return not select(3, GetAchievementCriteriaInfo(achievement, criteria))
end
-- this implies that we didn't load the data from the server completely... so default to showing it,
-- and later updates will hopefully fix it
return true
end
-- This is a custom iterator we use to iterate over every node in a given zone
local function iter(t, prestate)
if not t then return nil end
local state, value = next(t, prestate)
while state do -- Have we reached the end of this zone?
if value and should_show(value[1], value[2]) then
local icon = get_icon(value[1])
Debug("iter step", state, icon, db.icon_scale, db.icon_alpha)
return state, nil, icon, db.icon_scale, db.icon_alpha
end
state, value = next(t, state) -- Get next data
end
return nil, nil, nil, nil
end
function HLHandler:GetNodes2(uiMapId, minimap)
return iter, points[uiMapId], nil
end
end
---------------------------------------------------------
-- Options table
local options = {
type = "group",
name = "Lorewalkers",
desc = "Lorewalkers",
get = function(info) return db[info[#info]] end,
set = function(info, v)
db[info[#info]] = v
HL:SendMessage("HandyNotes_NotifyUpdate", "Lorewalkers")
end,
args = {
desc = {
name = "These settings control the look and feel of the icon.",
type = "description",
order = 0,
},
completed = {
name = "Show completed",
desc = "Show waypoints for lore you've already found?",
type = "toggle",
arg = "completed",
order = 10,
},
icon_scale = {
type = "range",
name = "Icon Scale",
desc = "The scale of the icons",
min = 0.25, max = 2, step = 0.01,
arg = "icon_scale",
order = 20,
},
icon_alpha = {
type = "range",
name = "Icon Alpha",
desc = "The alpha transparency of the icons",
min = 0, max = 1, step = 0.01,
arg = "icon_alpha",
order = 30,
},
},
}
---------------------------------------------------------
-- Addon initialization, enabling and disabling
function HL:OnInitialize()
-- Set up our database
self.db = LibStub("AceDB-3.0"):New("HandyNotes_LorewalkersDB", defaults)
db = self.db.profile
-- Initialize our database with HandyNotes
HandyNotes:RegisterPluginDB("Lorewalkers", HLHandler, options)
end
function HL:OnEnable()
self:RegisterEvent("CRITERIA_UPDATE", "Refresh")
self:RegisterEvent("CRITERIA_EARNED", "Refresh")
self:RegisterEvent("CRITERIA_COMPLETE", "Refresh")
self:RegisterEvent("ACHIEVEMENT_EARNED", "Refresh")
end
function HL:Refresh()
self:SendMessage("HandyNotes_NotifyUpdate", "Lorewalkers")
end