Thread Tools Display Modes
12-09-12, 12:14 AM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
[FeedTillers] Feed them their favourites!

FeedTillers very simply tells you the Tiller (Sho, Old Hillpaw, etc), their favourite dish for the daily quests A Dish For ..., and if you have fed them today. It plugs into any Broker display, and is so basic, there are no options!

Come look at the pretty picture!!

If you know other languages, please help with your Curse user name and password via the localization app.

There is more information on the project page, and can be downloaded on WoWInterface and Curse.

Last edited by myrroddin : 12-09-12 at 01:55 AM. Reason: Helps if I put the file link in, eh?
  Reply With Quote
12-09-12, 11:02 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by myrroddin View Post
If you know other languages, please help with your Curse user name and password via the localization app.
I'm pretty sure I'm not supposed to give you my Curse user name and password.

That said, I did give you a Spanish translation for the description. I didn't translate the addon name, as names are generally not translated.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-10-12, 03:21 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Silliness aside, I don't want your user name and password, only that people use theirs to log in and translate LOL.

And I saw the Spanish translations, Phanx, and thank you. You could, in this case, translate the addon name because I only use it for display purposes, and "Feed Tillers" looks better than "FeedTillers".
  Reply With Quote
12-10-12, 10:12 PM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I have Release 1.0.2 up, which fixes the log in error; public version works, not just developer build. I fail at string-fu!

Also, the Tillers changed their display order to match the order of faction ID. Cosmetic, but if Blizzard ever changes the list of Tillers, this makes it easier to keep track in the code.
  Reply With Quote
12-14-12, 12:35 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I made the mistake of looking at your code.

It's actually not that bad, but I rewrote it anyway. AceAddon seemed like overkill, so I removed it. I also removed all of the localization in the Lua file in favor of just pulling the translated name from the TOC via GetAddOnMetadata, and replaced all of the unnecessary upvalues with "GLOBALS: ..." comments which will keep FindGlobals from complaining, though personally I only use FindGlobals to check for set globals, not read ones.

I also moved to a table for storing NPC/item/quest IDs. Localized names are looked up on-demand and cached in the table. This allows easily sorting the display by any criteria, while retaining whatever order you find most convenient in the source code.

By default, all quests are shown, and tooltip lines are sorted by NPC name. Click the plugin to toggle between sorting by NPC name or item name. Shift-click to toggle between showing or hiding completed quests. You could easily save the sort and filter between sessions by changing the "currentSort" and "hideComplete" local variables to more distinctly-named global variables and listing them as SavedVariables in the TOC. I did not add any tooltip hints, since that would require localization, but it would be easy to add if you wanted.

I also aligned each column so my eyes can stop bleeding while looking at it, and highlighted each line green or red depending on quest completion status.

Feel free to make this the official version.

Code:
-- GLOBALS: sort, GetAddOnMetadata, GetFactionInfoByID, GetItemInfo, IsQuestFlaggedCompleted
-- GLOBALS: COMPLETE, ITEMS, NO, YES
-- GLOBALS: LibStub

local ADDON = ...
local ADDON_TITLE = GetAddOnMetadata(ADDON, "Title")
local TILLERS

local qtip = LibStub("LibQTip-1.0")

local npcs = {
	{ factionID = 1273, itemID = 74643, questID = 30439 }, -- Jogu the Drunk
	{ factionID = 1275, itemID = 74651, questID = 30386 }, -- Ella
	{ factionID = 1276, itemID = 74649, questID = 30396 }, -- Old Hillpaw
	{ factionID = 1277, itemID = 74647, questID = 30402 }, -- Chee Chee
	{ factionID = 1278, itemID = 74645, questID = 30408 }, -- Sho
	{ factionID = 1279, itemID = 74642, questID = 30414 }, -- Haohan Mudclaw
	{ factionID = 1280, itemID = 74652, questID = 30433 }, -- Tina Mudclaw
	{ factionID = 1281, itemID = 74644, questID = 30390 }, -- Gina Mudclaw
	{ factionID = 1282, itemID = 74655, questID = 30427 }, -- Fish Fellreed
	{ factionID = 1283, itemID = 74654, questID = 30421 }, -- Farmer Fung
}

local currentSort, hideComplete, tooltip = "NAME"
local sortByName = function(a, b)
	return a.name < b.name
end
local sortByItem = function(a, b)
	return a.item < b.item
end

LibStub("LibDataBroker-1.1"):NewDataObject(ADDON, {
	type = "data source",
	text = ADDON_TITLE,
	icon = [[Interface/ICONS/Achievement_Profession_ChefHat]],
	OnClick = function(self)
		if IsShiftKeyDown() then
			hideComplete = not hideComplete
		else
			currentSort = currentSort == "NAME" and "ITEM" or "NAME"
			sort(npcs, currentSort == "NAME" and sortByName or sortByItem)
		end
		self:GetScript("OnLeave")(self)
		self:GetScript("OnEnter")(self)
	end,
	OnEnter = function(self)
		if not TILLERS then
			TILLERS = GetFactionInfoByID(1272)
			for i = 1, #npcs do
				local npc = npcs[i]
				npc.name = GetFactionInfoByID(npc.factionID)
			end
			sort(npcs, sortByName)
		end

		tooltip = qtip:Acquire("FeedTillersTT", 3, "LEFT", "LEFT", "RIGHT")
		tooltip:AddHeader(TILLERS, ITEMS, COMPLETE)
		for i = 1, #npcs do
			local npc = npcs[i]
			if not npc.item then
				npc.item = GetItemInfo(npc.itemID)
			end
			if not IsQuestFlaggedCompleted(npc.questID) then
				local line = tooltip:AddLine(npc.name, npc.item, NO)
				tooltip:SetLineColor(line, 1, 0.1, 0.1, 0.3)
			elseif not hideComplete then
				local line = tooltip:AddLine(npc.name, npc.item, YES)
				tooltip:SetLineColor(line, 0.1, 1, 0.1, 0.3)
			end
		end
		tooltip:SmartAnchorTo(self)
		tooltip:Show()
	end,
	OnLeave = function(self)
		if qtip:IsAcquired("FeedTillersTT") then
			qtip:Release(tooltip)
		end
		tooltip = nil
	end
})
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 12-14-12 at 02:13 AM.
  Reply With Quote
12-14-12, 05:42 AM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Good thing the dailies just reset. Bad thing is I need sleep. But I'll give it a whirl. If my tired eyes are reading correctly, I can reduce the pkgmeta and toc to just LibStub, LibDataBroker-1.1, and FeedTillers.lua.

And sorry for making you curious enough to look at my code
  Reply With Quote
12-14-12, 06:36 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, you also need LibQTip, though I suppose you could actually do away with that, since you could just do two columns with "<npc> / <item>" for incomplete quests and "<npc> / Complete" for complete ones:

Code:
	OnTooltipShow = function(tooltip)
		if not TILLERS then
			TILLERS = GetFactionInfoByID(1272)
			for i = 1, #npcs do
				local npc = npcs[i]
				npc.name = GetFactionInfoByID(npc.factionID)
			end
			sort(npcs, sortByName)
		end

		tooltip:AddDoubleLine(TILLERS, ITEMS)
		for i = 1, #npcs do
			local npc = npcs[i]
			if not npc.item then
				npc.item = GetItemInfo(npc.itemID)
			end
			if not IsQuestFlaggedCompleted(npc.questID) then
				tooltip:AddDoubleLine(npc.name, npc.item, 1, 0.8, 0.8, 1, 0.8, 0.8)
			elseif not hideComplete then
				tooltip:AddDoubleLine(npc.name, COMPLETE, 0.6, 0.8, 0.6, 0.6, 0.8, 0.6)
			end
		end
		tooltip:Show()
	end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-14-12, 03:37 PM   #8
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by Phanx View Post
Well, you also need LibQTip
I just forgot to mention it. But either case, it will have to wait until later tonight until I can poke at it. Work beckons. I will try both and see which I prefer.
  Reply With Quote
12-15-12, 08:16 AM   #9
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I just uploaded an alpha to the WoWAce project site, using Phanx's first version, because it looks the most similar to what I had visually. Therefore, no end user shock, or very little.

It might be good of me to cave in and add saved variables to maintain the sort through logging sessions, and put in a mouse over script to indicate that things can be sorted. That can come later.
  Reply With Quote
12-17-12, 01:29 AM   #10
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Saved variables are in, which save the column sort by name or item, and holding <shift> + click to hide completed Tillers. Also added is localization for the tooltip help. But it looks terrible, and I have tried a few variants of formatting. Any suggestions on how to adjust the placement of the hints, starting line 97, is welcome.

On a side note, there are now four strings that need localizing, up from two. Still a tiny addon.
Lua Code:
  1. --[[
  2.     - file and project errata -
  3.     Project Author:     @project-author@
  4.     Project Date:       @project-date-iso@
  5.     Project Version:    @project-version@
  6.     Project Revision:   @project-revision@
  7.    
  8.     File Author:        @file-author@
  9.     File Date:          @file-date-iso@
  10.     File Revision:      @file-revision@
  11. ]]--
  12.  
  13. -- GLOBALS: sort, GetAddOnMetadata, GetFactionInfoByID, GetItemInfo, IsQuestFlaggedCompleted, GetLocale
  14. -- GLOBALS: COMPLETE, ITEMS, NO, YES, GameTooltip
  15. -- GLOBALS: LibStub
  16. -- GLOBALS: FeedTillers_hideComplete, FeedTillers_currentSort
  17.  
  18. local ADDON, L = ...
  19. local ADDON_TITLE = GetAddOnMetadata(ADDON, "Title")
  20. local TILLERS
  21. local LOCALE = GetLocale()
  22. local event_frame = CreateFrame("frame")
  23.  
  24. -- translate the tooltips
  25. if LOCALE == "esES" then
  26. --@localization(locale="esES", format="lua_additive_table", namespace="Normal")@
  27. elseif LOCALE == "esMX" then
  28. --@localization(locale="esMX", format="lua_additive_table", namespace="Normal")@
  29. elseif LOCALE == "itIT" then
  30. --@localization(locale="itIT", format="lua_additive_table", namespace="Normal")@
  31. elseif LOCALE == "ptBR" then
  32. --@localization(locale="ptBR", format="lua_additive_table", namespace="Normal")@
  33. elseif LOCALE == "frFR" then
  34. --@localization(locale="frFR", format="lua_additive_table", namespace="Normal")@
  35. elseif LOCALE == "deDE" then
  36. --@localization(locale="deDE", format="lua_additive_table", namespace="Normal")@
  37. elseif LOCALE == "ruRU" then
  38. --@localization(locale="ruRU", format="lua_additive_table", namespace="Normal")@
  39. elseif LOCALE == "zhCN" then
  40. --@localization(locale="zhCN", format="lua_additive_table", namespace="Normal")@
  41. elseif LOCALE == "zhTW" then
  42. --@localization(locale="zhTW", format="lua_additive_table", namespace="Normal")@
  43. else
  44. L["CLICK_SORT"] = "Click the plugin to sort by Tiller name or item name"
  45. L["SHIFT_DOWN"] = "Hold the <Shift> key and click to hide already fed Tillers"
  46. end
  47.  
  48. local qtip = LibStub("LibQTip-1.0")
  49.  
  50. local npcs = {
  51.     { factionID = 1273, itemID = 74643, questID = 30439 }, -- Jogu the Drunk
  52.     { factionID = 1275, itemID = 74651, questID = 30386 }, -- Ella
  53.     { factionID = 1276, itemID = 74649, questID = 30396 }, -- Old Hillpaw
  54.     { factionID = 1277, itemID = 74647, questID = 30402 }, -- Chee Chee
  55.     { factionID = 1278, itemID = 74645, questID = 30408 }, -- Sho
  56.     { factionID = 1279, itemID = 74642, questID = 30414 }, -- Haohan Mudclaw
  57.     { factionID = 1280, itemID = 74652, questID = 30433 }, -- Tina Mudclaw
  58.     { factionID = 1281, itemID = 74644, questID = 30390 }, -- Gina Mudclaw
  59.     { factionID = 1282, itemID = 74655, questID = 30427 }, -- Fish Fellreed
  60.     { factionID = 1283, itemID = 74654, questID = 30421 }, -- Farmer Fung
  61. }
  62.  
  63. local tooltip = "NAME"
  64. local sortByName = function(a, b)
  65.     return a.name < b.name
  66. end
  67. local sortByItem = function(a, b)
  68.     return a.item < b.item
  69. end
  70.  
  71. local function CreateBroker()
  72.     LibStub("LibDataBroker-1.1"):NewDataObject(ADDON, {
  73.         type = "data source",
  74.         text = ADDON_TITLE,
  75.         icon = [[Interface/ICONS/Achievement_Profession_ChefHat]],
  76.         OnClick = function(self)
  77.             if IsShiftKeyDown() then
  78.                 FeedTillers_hideComplete = not FeedTillers_hideComplete
  79.             else
  80.                 FeedTillers_currentSort = FeedTillers_currentSort == "NAME" and "ITEM" or "NAME"
  81.                 sort(npcs, FeedTillers_currentSort == "NAME" and sortByName or sortByItem)
  82.             end
  83.             self:GetScript("OnLeave")(self)
  84.             self:GetScript("OnEnter")(self)
  85.         end,
  86.         OnEnter = function(self)
  87.             if not TILLERS then
  88.                 TILLERS = GetFactionInfoByID(1272)
  89.                 for i = 1, #npcs do
  90.                     local npc = npcs[i]
  91.                     npc.name = GetFactionInfoByID(npc.factionID)
  92.                 end
  93.                 sort(npcs, sortByName)
  94.             end
  95.            
  96.             tooltip = qtip:Acquire("FeedTillersTT", 3, "LEFT", "LEFT", "RIGHT")
  97.             tooltip:AddLine(nil, nil, L.CLICK_SORT)
  98.             tooltip:AddLine(nil, nil, L.SHIFT_DOWN)
  99.             tooltip:AddLine("", "", "")
  100.             tooltip:AddHeader(TILLERS, ITEMS, COMPLETE)
  101.             for i = 1, #npcs do
  102.                 local npc = npcs[i]
  103.                 if not npc.item then
  104.                     npc.item = GetItemInfo(npc.itemID)
  105.                 end
  106.                 if not IsQuestFlaggedCompleted(npc.questID) then
  107.                     local line = tooltip:AddLine(npc.name, npc.item, NO)
  108.                     tooltip:SetLineColor(line, 1, 0.1, 0.1, 0.3)
  109.                 elseif not FeedTillers_hideComplete then
  110.                     local line = tooltip:AddLine(npc.name, npc.item, YES)
  111.                     tooltip:SetLineColor(line, 0.1, 1, 0.1, 0.3)
  112.                 end
  113.             end
  114.             tooltip:SmartAnchorTo(self)
  115.             tooltip:Show()
  116.         end,
  117.         OnLeave = function(self)
  118.             if qtip:IsAcquired("FeedTillersTT") then
  119.                 qtip:Release(tooltip)
  120.             end
  121.             tooltip = nil
  122.         end
  123.     })
  124. end
  125.  
  126. event_frame:RegisterEvent("ADDON_LOADED")
  127. event_frame:SetScript("OnEvent", function(self, event, ...)
  128.     if event == "ADDON_LOADED" and ... == ADDON then   
  129.         if not FeedTillers_hideComplete then
  130.             FeedTillers_hideComplete = false
  131.         end
  132.         if not FeedTillers_currentSort then
  133.             FeedTillers_currentSort = "NAME"
  134.         end
  135.     end
  136.     CreateBroker()
  137.     self:UnregisterEvent("ADDON_LOADED")
  138. end)
Attached Thumbnails
Click image for larger version

Name:	FeedTillers3.jpg
Views:	718
Size:	66.1 KB
ID:	7452  
  Reply With Quote
12-17-12, 02:28 AM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Added:
  • in yellow: hints at the bottom of the tooltip that span all 3 cells,
  • in pink: item counts instead of just "No" for not-yet-completed quests, with quests that are ready to turn in no longer highlighted in red,
  • in green: auto-switching back to showing completed quests once all quests have been completed (you might want to use a second variable for this so as not to mess with the saved variable, or just take it out).

Code:
tooltip:AddHeader(TILLERS, ITEMS, COMPLETE)
local line
for i = 1, #npcs do
	local npc = npcs[i]
	if not npc.item then
		npc.item = GetItemInfo(npc.itemID)
	end
	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 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

if not line then
	hideComplete = 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_SORT, "LEFT", 3)

line = tooltip:AddLine(" ")
tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L.SHIFT_DOWN, "LEFT", 3)

tooltip:SmartAnchorTo(self)
tooltip:Show()
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-20-12, 04:30 AM   #12
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Release 1.0.3 is out with Phanx's changes and improvements. It is already available on Curse, and will be available here as soon as the moderators have a chance.

There are two shiny new screenshots, with the outdated ones removed, as while Feed Tillers looks similar to previous versions, there are a some marked differences.
Attached Thumbnails
Click image for larger version

Name:	sortname.jpg
Views:	720
Size:	55.9 KB
ID:	7459  Click image for larger version

Name:	sortitem.jpg
Views:	721
Size:	51.7 KB
ID:	7460  
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Released AddOns » [FeedTillers] Feed them their favourites!

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off