--[[
-- file and project errata --
Project Author: @project-author@
Project Date: @project-date-iso@
Project Version: @project-version@
Project Revision: @project-revision@
File Author: @file-author@
File Date: @file-date-iso@
File Revision: @file-revision@
]]--
local ADDON, _ = ...
local ADDON_TITLE = GetAddOnMetadata(ADDON, "Title")
local TILLERS = GetFactionInfoByID(1272)
local LOCALE = GetLocale()
local event_frame = CreateFrame("frame")
local TomTom = TomTom
local L = setmetatable({}, {__index = function(t, k)
local v = tostring(k)
rawset(t, k, v)
return v
end})
-- translate the tooltips
--[[
-- don't actually need enUS as that's the default. using this as a reminder
if LOCALE == "enUS" then
L["Click a Tiller's line to set a waypoint in TomTom"] = true
L["Click the plugin to sort by Tiller name or item name"] = true
L["Hold the <Control> key and click to hide Best Friend Tillers"] = true
L["Hold the <Shift> key and click to hide already fed Tillers"] = true
return end
]]--
if LOCALE == "deDE" then
--@localization(locale="deDE", format="lua_additive_table")@
return end
if LOCALE == "esES" or LOCALE == "esMX" then
--@localization(locale="esES", format="lua_additive_table")@
return end
if LOCALE == "frFR" then
--@localization(locale="frFR", format="lua_additive_table")@
return end
if LOCALE == "itIT" then
--@localization(locale="itIT", format="lua_additive_table")@
return end
if LOCALE == "koKR" then
--@localization(locale="koKR", format="lua_additive_table")@
return end
if LOCALE == "ptBR" then
--@localization(locale="ptBR", format="lua_additive_table")@
return end
if LOCALE == "ruRU" then
--@localization(locale="ruRU", format="lua_additive_table")@
return end
if LOCALE == "zhCN" then
--@localization(locale="zhCN", format="lua_additive_table")@
return end
if LOCALE == "zhTW" then
--@localization(locale="zhTW", format="lua_additive_table")@
return end
local qtip = LibStub("LibQTip-1.0")
local npcs = {
{ factionID = 1273, itemID = 74643, questID = 30439, x = 52.6, y = 49.2 }, -- Jogu the Drunk
{ factionID = 1275, itemID = 74651, questID = 30386, x = 31.6, y = 58.0 }, -- Ella
{ factionID = 1276, itemID = 74649, questID = 30396, x = 31.0, y = 53.0 }, -- Old Hillpaw
{ factionID = 1277, itemID = 74647, questID = 30402, x = 34.4, y = 46.8 }, -- Chee Chee
{ factionID = 1278, itemID = 74645, questID = 30408, x = 29.6, y = 30.6 }, -- Sho
{ factionID = 1279, itemID = 74642, questID = 30414, x = 44.6, y = 34.0 }, -- Haohan Mudclaw
{ factionID = 1280, itemID = 74652, questID = 30433, x = 45.0, y = 33.8 }, -- Tina Mudclaw
{ factionID = 1281, itemID = 74644, questID = 30390, x = 53.2, y = 51.6 }, -- Gina Mudclaw
{ factionID = 1282, itemID = 74655, questID = 30427, x = 41.6, y = 30.0 }, -- Fish Fellreed
{ factionID = 1283, itemID = 74654, questID = 30421, x = 48.2, y = 33.8 }, -- Farmer Fung
}
local tooltip = "NAME"
local sortByName = function(a, b)
return a.name < b.name
end
local sortByItem = function(a, b)
return a.item < b.item
end
local function UseTomTom(npc)
local x, y = npc.x, npc.y
local opts = {title = GetFactionInfoByID(npc.factionID), persistant = true, minimap = true, world = true, crazy = true}
TomTom:AddWaypoint(376, x, y, opts) -- 376 is the uiMapID for Valley of the Four Winds
end
local function CreateBroker()
LibStub("LibDataBroker-1.1"):NewDataObject(ADDON, {
type = "data source",
text = ADDON_TITLE,
icon = [[Interface/ICONS/Achievement_Profession_ChefHat]],
OnClick = function(self)
if IsShiftKeyDown() then
FeedTillersDB.hideComplete = not FeedTillersDB.hideComplete
elseif IsControlKeyDown() then
FeedTillersDB.hideBestFriends = not FeedTillersDB.hideBestFriends
else
FeedTillersDB.currentSort = FeedTillersDB.currentSort == "NAME" and "ITEM" or "NAME"
sort(npcs, FeedTillersDB.currentSort == "NAME" and sortByName or sortByItem)
end
self:GetScript("OnLeave")(self)
self:GetScript("OnEnter")(self)
end,
OnEnter = function(self)
TILLERS = TILLERS or GetFactionInfoByID(1272)
tooltip = qtip:Acquire("FeedTillersTT", 3, "LEFT", "LEFT", "RIGHT")
tooltip:AddHeader(TILLERS, ITEMS, COMPLETE)
local line
local hideComplete = FeedTillersDB.hideComplete
local hideBestFriends = FeedTillersDB.hideBestFriends
for i = 1, #npcs do
local npc = npcs[i]
npc.name, npc.noop, npc.standingID = GetFactionInfoByID(npc.factionID) -- npc.noop is not used by FeedTillers
npc.item = npc.item or GetItemInfo(npc.itemID)
hideBestFriends = hideBestFriends == true and npc.standingID == 8
if not npc.item then
print("cFFFF0000" .. L["FeedTillers error:"] .. "|r " .. L["the food item is being cached. Please wait and try viewing the display a few times until it is updated."])
end
if not hideBestFriends then
if not IsQuestFlaggedCompleted(npc.questID) then
-- note "line" is no longer local to this scope!
local count = GetItemCount(npc.itemID)
line = tooltip:AddLine(npc.name, npc.item, format("%d/%d", count, 5))
if TomTom then
tooltip:SetScript(line, "OnMouseUp", UseTomTom, npc)
tooltip:SetHighlightTexture(1, 1, 1, 0.7)
end
if count < 5 then
tooltip:SetLineColor(line, 1, 0.1, 0.1, 0.3)
end
elseif not hideComplete then
line = tooltip:AddLine(npc.name, npc.item, YES)
tooltip:SetLineColor(line, 0.1, 1, 0.1, 0.3)
end
end
end
sort(npcs, sortByName)
if not line then
hideComplete = nil
hideBestFriends = nil
self:GetScript("OnLeave")(self)
return self:GetScript("OnEnter")(self)
end
line = tooltip:AddLine(" ") -- blank line
line = tooltip:AddLine(" ")
tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Click the plugin to sort by Tiller name or item name"], "LEFT", 3)
line = tooltip:AddLine(" ")
tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Shift> key and click to hide already fed Tillers"], "LEFT", 3)
line = tooltip:AddLine(" ")
tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Control> key and click to hide Best Friend Tillers"], "LEFT", 3)
if TomTom then
line = tooltip:AddLine(" ")
tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Click a Tiller's line to set a waypoint in TomTom"], "LEFT", 3)
end
tooltip:SmartAnchorTo(self)
tooltip:Show()
end,
OnLeave = function(self)
if qtip:IsAcquired("FeedTillersTT") then
qtip:Release(tooltip)
end
tooltip = nil
end
})
end
event_frame:RegisterEvent("PLAYER_LOGIN")
event_frame:SetScript("OnEvent", function(self, ...)
if ... == "PLAYER_LOGIN" then
FeedTillersDB = FeedTillersDB or {}
FeedTillersDB.hideComplete = FeedTillersDB.hideComplete or false
FeedTillersDB.currentSort = FeedTillersDB.currentSort or "NAME"
FeedTillersDB.hideBestFriends = FeedTillersDB.hideBestFriends or false
-- clean up old saved variables
FeedTillers_hideComplete = nil
FeedTillers_currentSort = nil
CreateBroker()
end
end)