forked from gi2k15/Caravana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaravana.lua
75 lines (63 loc) · 2.25 KB
/
caravana.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
-- Make Campfire = 312370
-- Return to Camp = 312372
if select(2, UnitRace("player")) ~= "Vulpera" then return end
local db
local events = {}
local iconCamp = "poi-islands-table" -- change this to change the icons.
local atlasCamp = CreateAtlasMarkup(iconCamp, 20, 20)
local HBD = LibStub("HereBeDragons-2.0")
local Pins = LibStub("HereBeDragons-Pins-2.0")
local iconRef = true
local icon = CreateFrame("Frame")
icon:SetSize(20, 20)
icon.texture = icon:CreateTexture()
icon.texture:SetAtlas(iconCamp)
icon.texture:SetAllPoints()
icon:Hide()
icon:SetScript("OnEnter", function(self)
local camp = GetSpellInfo(312372)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT", 5, 0)
GameTooltip:SetText(format("%s\n|cFFFFFFFF%s", camp, db.place), _, _, _, _, true)
GameTooltip:Show()
end)
icon:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)
function events:PLAYER_LOGIN(...)
db = CaravanaDB or {}
if db.x and db.y and db.instance and db.place then
Pins:AddWorldMapIconWorld(iconRef, icon, db.instance, db.x, db.y, HBD_PINS_WORLDMAP_SHOW_WORLD)
end
end
function events:PLAYER_LOGOUT(...)
CaravanaDB = db
end
function events:UNIT_SPELLCAST_SUCCEEDED(...)
local _, _, spellID = ...
if spellID == 312370 then
local subzone, zone = GetSubZoneText(), GetZoneText()
db.place = subzone == "" and zone or format("%s, %s", subzone, zone)
Pins:RemoveAllWorldMapIcons(iconRef)
db.x, db.y, db.instance = HBD:GetPlayerWorldPosition()
Pins:AddWorldMapIconWorld(iconRef, icon, db.instance, db.x, db.y, HBD_PINS_WORLDMAP_SHOW_WORLD)
end
end
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(self, event, ...)
events[event](self, ...)
end)
for k, v in pairs(events) do
f:RegisterEvent(k)
end
local function AddTooltipText(tooltip, spellID)
if spellID == 312372 and db.place then
tooltip:AddLine(atlasCamp .. " " .. db.place, 0.94, 0.9, 0.55, true)
end
end
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Spell, function(self, data)
local _, SpellID = self:GetSpell()
AddTooltipText(self, SpellID)
end)
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Macro, function(self, data)
AddTooltipText(self, data.lines[1].tooltipID)
end)