forked from taylor-meyer/Missing-Flight-Paths
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMFP_ScoutingMaps.lua
132 lines (116 loc) · 3.15 KB
/
MFP_ScoutingMaps.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
------------------------------------------------------------------------------------------
-- Scouting Maps --
--------------------
-- Author: Lypidius @ US-MoonGuard
------------------------------------------------------------------------------------------
-- Addon name & common namespace
local addon, ns = ...
ns.ButtonFrames = {}
-- Table of scouting maps within the toybox.
-- [instanceID] -> [toyName], [toyID]
ns["scoutingMaps"] = {
[0] = {
["toyName"] = "Scouting Map: Modern Provisioning of the Eastern Kingdoms",
["toyID"] = 150746
},
[1] = {
["toyName"] = "Scouting Map: Surviving Kalimdor",
["toyID"] = 150743
},
[2] = {
["toyName"] = "Scouting Map: The Eastern Kingdoms Campaign",
["toyID"] = 150745
},
[3] = {
["toyName"] = "Scouting Map: Walking Kalimdor with the Earthmother",
["toyID"] = 150744
},
[530] = {
["toyName"] = "Scouting Map: The Many Curiosities of Outland",
["toyID"] = 187899
},
[571] = {
["toyName"] = "Scouting Map: True Cost of the Northrend Campaign",
["toyID"] = 187898
},
[646] = {
["toyName"] = "Scouting Map: Cataclysm's Consequences",
["toyID"] = 187897
},
[870] = {
["toyName"] = "Scouting Map: A Stormstout's Guide to Pandaria",
["toyID"] = 187896
},
[1116] = {
["toyName"] = "Scouting Map: The Dangers of Draenor",
["toyID"] = 187895
},
[1220] = {
["toyName"] = "Scouting Map: United Fronts of the Broken Isles",
["toyID"] = 187875
},
[1642] = {
["toyName"] = "Scouting Map: The Wonders of Kul Tiras and Zandalar",
["toyID"] = 187900
},
[2222] = {
["toyName"] = "Scouting Map: Into the Shadowlands",
["toyID"] = 187869
}
}
function ns:CreateButtonFrames()
for k,v in pairs(ns["scoutingMaps"]) do
local f = CreateFrame("Button", "MFP_Button_" .. v["toyName"], UIParent, "SecureActionButtonTemplate")
f:RegisterForClicks("AnyUp", "AnyDown")
f:SetSize(50,50)
f.texture = f:CreateTexture()
f.texture:SetTexture(GetItemIcon(v["toyID"]))
f.texture:SetAllPoints(f)
f:HookScript("OnEnter", function()
if (C_ToyBox.GetToyLink(v["toyID"])) then
GameTooltip:SetOwner(f, "ANCHOR_TOP")
GameTooltip:SetHyperlink(C_ToyBox.GetToyLink(v["toyID"]))
GameTooltip:Show()
end
end)
f:HookScript("OnLeave", function()
GameTooltip:Hide()
end)
f:SetAttribute("type", "toy")
f:SetAttribute("toy", v["toyID"])
ns.ButtonFrames[k] = f
end
end
function ns:HideAllMaps()
for _,v in pairs(ns.ButtonFrames) do
v:Hide()
end
end
function ns:ShowScoutingMapButton()
local player_faction = UnitFactionGroup("player")
if player_faction == "Neutral" then
return
end
local _,_,instanceID = ns:GetInstanceID()
if ns.ButtonFrames[instanceID] == nil then return end
-- If player in E(0), Kalimdor(1), or Cata zone(646)
-- we show the Cataclysm button as well
-- button, cataclysmButton
local b, cb = nil, nil
if instanceID <= 1 then
if player_faction == "Horde" then
b = ns.ButtonFrames[instanceID + 2]
else
b = ns.ButtonFrames[instanceID]
end
cb = ns.ButtonFrames[646]
else
b = ns.ButtonFrames[instanceID]
end
b:SetPoint("BOTTOM", FlightMapFrame, "TOP", -15, 5)
b:Show()
if cb ~= nil then
cb:SetPoint("LEFT", b, "RIGHT", 5, 0)
cb:Show()
end
end