-
Notifications
You must be signed in to change notification settings - Fork 2
/
TomTomHandler.lua
76 lines (70 loc) · 2.67 KB
/
TomTomHandler.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
-- ----------------------------------------------------------------------------
-- AddOn namespace.
-- ----------------------------------------------------------------------------
local FOLDER_NAME, private = ...
local LibStub = _G.LibStub
local Dialog = LibStub("LibDialog-1.0")
-- ----------------------------------------------------------------------------
-- Handler.
-- ----------------------------------------------------------------------------
local TomTomHandler = {
-- ----------------------------------------------------------------------------
-- Data.
-- ----------------------------------------------------------------------------
currentDigsite = nil,
hasDisplayedConflictError = false,
hasPOIIntegration = false,
hasTomTom = false,
isActive = false,
waypoint = nil,
-- ----------------------------------------------------------------------------
-- Methods.
-- ----------------------------------------------------------------------------
CheckForConflict = function(self)
if not self.hasDisplayedConflictError and private.ProfileSettings.tomtom.enabled and self.hasPOIIntegration and _G.TomTom.profile.poi.setClosest then
self.hasDisplayedConflictError = true
Dialog:Spawn("ArchyTomTomError")
end
end,
ClearWaypoint = function(self)
if self.waypoint then
_G.TomTom:RemoveWaypoint(self.waypoint)
self.waypoint = nil
self.currentDigsite = nil
end
end,
Refresh = function(self, digsite)
self:ClearWaypoint()
if not digsite or digsite == self.currentDigsite or not self.hasTomTom or not self.isActive or not private.ProfileSettings.tomtom.enabled or not private.ProfileSettings.general.show or _G.CanScanResearchSite() then
return
end
self.currentDigsite = digsite
self.waypoint = _G.TomTom:AddWaypoint(digsite.UIMapID, digsite.coordX, digsite.coordY, {
crazy = private.ProfileSettings.tomtom.crazyArrowEnabled,
title = ("%s %s\n%s"):format(digsite.name, _G.PARENS_TEMPLATE:format(digsite.race.name), digsite.zoneName),
})
end
}
private.TomTomHandler = TomTomHandler
Dialog:Register("ArchyTomTomError", {
text = "",
on_show = function(self, data)
self.text:SetFormattedText("An incompatible TomTom setting was detected.\n\nThe \"%s%s|r\" setting will cause %s to lose control of TomTom when approaching quest POIs.\n\nDo you want to reset it?",
"|cFFFFCC00", _G.TomTomLocals and _G.TomTomLocals["Enable automatic quest objective waypoints"] or "", FOLDER_NAME)
end,
buttons = {
{
text = _G.YES,
on_click = function(self, data)
_G.TomTom.profile.poi.setClosest = false
_G.TomTom:EnableDisablePOIIntegration()
end,
},
{
text = _G.NO,
},
},
hide_on_escape = true,
show_while_dead = true,
width = 450,
})