diff --git a/DatabaseDefaults.lua b/DatabaseDefaults.lua
index e938255..c8dd3d9 100644
--- a/DatabaseDefaults.lua
+++ b/DatabaseDefaults.lua
@@ -6,9 +6,11 @@ addon.defaults = {
profile = {
positions = {},
- corpseSource = true,
- questObjectivesSource = true,
- archaeologyDigSitesSource = true,
+ sources = {
+ corpse = true,
+ questobj = true,
+ archaeodig = true,
+ },
showMapIconsZone = false,
showMapIconsContinent = false,
diff --git a/TomTomLite.lua b/TomTomLite.lua
index f23f52a..7a66a06 100644
--- a/TomTomLite.lua
+++ b/TomTomLite.lua
@@ -69,6 +69,16 @@ function addon:Initialize()
self.PRI_ACTIVE = 15
self.PRI_NORMAL = 0
self.PRI_ALWAYS = math.huge
+
+ -- Set options for any pre-registered sources
+ for idx, source in ipairs(self.sources) do
+ local stype = source.stype
+ if addon.db.profile.sources[stype] == nil then
+ source.enabled = true
+ else
+ source.enabled = addon.db.profile.sources[stype]
+ end
+ end
end
function addon:CreateCrazyArrow(name, parent)
@@ -172,23 +182,32 @@ end
-- opt - A table containing any other options, for future-use
function addon:RegisterSource(stype, name, desc, opt)
- local sources = {
- type = stype,
+ local source = {
+ stype = stype,
name = name,
desc = desc,
}
if opt then
for k,v in pairs(opt) do
- if sources[k] then
+ if source[k] then
local err = string.format(L["Source '%s' registered with invalid option '%s'"], name, k)
error(err)
else
- sources[k] = v
+ source[k] = v
end
end
end
+ -- Check to see if the options table has been loaded, if so
+ if addon.db then
+ if addon.db.profile.sources[stype] == nil then
+ source.enabled = true
+ else
+ source.enabled = addon.db.profile.sources[style]
+ end
+ end
+
table.insert(self.sources, source)
end
@@ -216,6 +235,8 @@ end
-- 100, indicating something that should always be
-- displayed, for example the Corpse arrow.
--
+-- source - The source that produced the waypoint
+--
-- Returns:
-- waypoint - A table containing the information about the given waypoint and
-- serving as a unique identifier for the waypoint within TomTomLite.
@@ -289,16 +310,26 @@ function addon:UpdateArrow()
return bpri < apri
end)
- local highest = self.waypoints[1]
- if highest then
- local zone, floor, x, y = unpack(highest)
- local lzone = self:GetMapDisplayName(zone)
+ local active = false
+ for idx, waypoint in ipairs(self.waypoints) do
+ local source = waypoint.source
+ local disabled = source and self.db.profile.sources[source] == false
+
+ if disabled then
+ -- move on to the next waypoint
+ else
+ local zone, floor, x, y = unpack(waypoint)
+ local lzone = self:GetMapDisplayName(zone)
+
+ self.arrow.waypoint = waypoint
+ self.arrow.title:SetText(waypoint.title or L["Unknown waypoint"])
+ self.arrow.info:SetFormattedText("%.2f, %.2f - %s", x * 100, y * 100, lzone)
+ self.arrow:Show()
+ active = true
+ end
+ end
- self.arrow.waypoint = highest
- self.arrow.title:SetText(highest.title or L["Unknown waypoint"])
- self.arrow.info:SetFormattedText("%.2f, %.2f - %s", x * 100, y * 100, lzone)
- self.arrow:Show()
- else
+ if not active then
self.arrow.waypoint = nil
self.arrow:Hide()
end
@@ -405,6 +436,8 @@ SLASH_TOMTOMLITE3 = "/tt"
local wrongseparator = "(%d)" .. (tonumber("1.1") and "," or ".") .. "(%d)"
local rightseparator = "%1" .. (tonumber("1.1") and "." or ",") .. "%2"
+local enabled = L["|cFF11FF11%s|r"]:format(L["enabled"])
+local disabled = L["|cFFFF1111%s|r"]:format(L["disabled"])
SlashCmdList["TOMTOMLITE"] = function(msg, editbox)
-- Attempt to fix any pairs of coordinates in any form so they work. This
@@ -423,6 +456,7 @@ SlashCmdList["TOMTOMLITE"] = function(msg, editbox)
end
local verb = tokens[1] and tokens[1]:lower()
+ local showusage = false
if verb == "set" then
if not tonumber(tokens[2]) then
@@ -442,11 +476,43 @@ SlashCmdList["TOMTOMLITE"] = function(msg, editbox)
if desc then
desc = table.concat(tokens, " ", zoneEnd + 3)
end
-
+ else
-- TODO: Try to find a match for the zone/map name
- else
- self:Printf(L["Usage for /ttl:"])
- self:Printf(L[" * set [zone] <x> <y> [desc] - sets a waypoint"])
- end
+ end
+ elseif verb == "source" then
+ local found = false
+
+ if tokens[2] then
+ for idx, source in ipairs(addon.sources) do
+ if source.stype == tokens[2]:lower() then
+ found = true
+ source.enabled = not source.enabled
+ addon.db.profile.sources[source.stype] = source.enabled
+ local status = source.enabled and enabled or disabled
+ addon:FireMessage("TOMTOMLITE_WAYPOINTS_CHANGED")
+ addon:Printf(L["Waypoint source '%s' has been %s"], tokens[2], status)
+ break
+ end
+ end
+ end
+
+ if not found then
+ showusage = true
+ end
+ elseif verb == "sources" then
+ addon:Printf(L["Waypoint sources for TomTomLite"])
+ for idx, source in ipairs(addon.sources) do
+ local status = source.enabled and enabled or disabled
+ addon:Printf(L[" - %s - %s: %s"], source.stype, status, source.desc)
+ end
+ else
+ showusage = true
+ end
+
+ if showusage then
+ addon:Printf(L["Usage for /ttl:"])
+ addon:Printf(L[" * set [zone] <x> <y> [desc] - sets a waypoint"])
+ addon:Printf(L[" * source <sourceName> - toggles a waypoint source"])
+ addon:Printf(L[" * sources - lists available sources and states"])
end
end
diff --git a/sources/ArchaeologyDigSites.lua b/sources/ArchaeologyDigSites.lua
index 770c471..3a1a02e 100644
--- a/sources/ArchaeologyDigSites.lua
+++ b/sources/ArchaeologyDigSites.lua
@@ -20,7 +20,7 @@ eventFrame:RegisterEvent("ARTIFACT_DIG_SITE_UPDATED")
-- on the current continent
local waypoints = {}
local function UpdateDigSites()
- if not addon.db.profile.archaeologyDigSitesSource then
+ if not addon.db.profile.sources.archaeodig then
return
end
@@ -46,6 +46,7 @@ local function UpdateDigSites()
local waypoint = addon:AddWaypoint(continent, nil, px, py, {
title = string.format(L["Dig site: %s\n%s"], name, zoneName),
priority = 0,
+ source = "archaeodig",
})
sites[key] = waypoint
else
diff --git a/sources/Corpse.lua b/sources/Corpse.lua
index e26f832..74e9eba 100644
--- a/sources/Corpse.lua
+++ b/sources/Corpse.lua
@@ -22,7 +22,7 @@ local waypoint
local map, floor, x, y
local function GetCorpseLocation()
- if not addon.db.profile.corpseSource then
+ if not addon.db.profile.sources.corpse then
return
end
@@ -77,6 +77,7 @@ local function SetCorpseArrow()
waypoint = addon:AddWaypoint(map, floor, x, y, {
title = "Your corpse",
priority = addon.PRI_ALWAYS,
+ source = "corpse",
})
return waypoint
end
@@ -104,7 +105,7 @@ eventFrame:SetScript("OnUpdate", function(self, elapsed)
return
else
counter = 0
- if addon.db.profile.corpseSource then
+ if addon.db.profile.sources.corpse then
if GetCorpseLocation() then
if SetCorpseArrow() then
self:Hide()
diff --git a/sources/QuestObjectives.lua b/sources/QuestObjectives.lua
index b2f6cfd..543a602 100644
--- a/sources/QuestObjectives.lua
+++ b/sources/QuestObjectives.lua
@@ -12,7 +12,7 @@ local L = addon.L
-------------------------------------------------------------------]]--
do
- local desc = L["This source provides waypoints for each of the objectives listed in the Blizzard objectives tracker. To add a quest to the tracking list, just shift-click it in your quest log."],
+ local desc = L["This source provides waypoints for each of the objectives listed in the Blizzard objectives tracker. To add a quest to the tracking list, just shift-click it in your quest log."]
addon:RegisterSource("questobj", L["Quest Objectives (tracked)"], desc)
end
@@ -48,7 +48,7 @@ function addon:OBJECTIVES_CHANGED()
SetCVar("questPOI", 1)
-- Only do an objective scan if the option is enabled
- if not self.db.profile.questObjectivesSource then
+ if not self.db.profile.sources.questobj then
return
end
@@ -106,6 +106,7 @@ function addon:OBJECTIVES_CHANGED()
local waypoint = self:AddWaypoint(map, floor, x, y, {
title = title,
priority = key == first and addon.PRI_ACTIVE or addon.PRI_NORMAL,
+ source = "questobj",
})
newWaypoints[key] = waypoint