Reply
 
Thread Tools Display Modes
Old 12-08-12, 11:14 PM   #1
myrroddin
A Rage Talon Dragon Guard
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 346
[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 12:55 AM. Reason: Helps if I put the file link in, eh?
myrroddin is offline   Reply With Quote
Old 12-09-12, 10:02 PM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 3,675
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.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Old 12-10-12, 02:21 AM   #3
myrroddin
A Rage Talon Dragon Guard
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 346
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".
myrroddin is offline   Reply With Quote
Old 12-10-12, 09:12 PM   #4
myrroddin
A Rage Talon Dragon Guard
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 346
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.
myrroddin is offline   Reply With Quote
Old 12-13-12, 11:35 PM   #5
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 3,675
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
})
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!

Last edited by Phanx : 12-14-12 at 01:13 AM.
Phanx is offline   Reply With Quote
Old 12-14-12, 04:42 AM   #6
myrroddin
A Rage Talon Dragon Guard
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 346
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
myrroddin is offline   Reply With Quote
Reply

Go BackWoWInterface » 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