annotate Modules/MinimapIcon.lua @ 225:2e4e52a589e5

Added onQueueStart and onQueueEnd events to crafting addon registering. GnomeWorks queue frame should automatically be closed before adding items to the queue and opened afterwards to speed this process up.
author Zerotorescue
date Mon, 07 Feb 2011 15:06:41 +0100
parents 1959e2b3dfe1
children
rev   line source
Zerotorescue@203 1 local addon = select(2, ...);
Zerotorescue@203 2 local mod = addon:NewModule("MinimapIcon");
Zerotorescue@203 3
Zerotorescue@210 4 local icon;
Zerotorescue@210 5
Zerotorescue@203 6 function mod:OnEnable()
Zerotorescue@210 7 if addon.db.profile.defaults.minimapIcon then
Zerotorescue@210 8 self:MakeIcon();
Zerotorescue@210 9 end
Zerotorescue@203 10 end
Zerotorescue@203 11
Zerotorescue@210 12 function mod:MakeIcon()
Zerotorescue@210 13 icon = LibStub("LibDBIcon-1.0");
Zerotorescue@210 14
Zerotorescue@203 15 local ldb = LibStub("LibDataBroker-1.1");
Zerotorescue@203 16
Zerotorescue@203 17 local dataobject = ldb:GetDataObjectByName("Inventorium") or ldb:NewDataObject("Inventorium", {
Zerotorescue@203 18 ["type"] = "launcher",
Zerotorescue@203 19 ["label"] = "Inventorium",
Zerotorescue@203 20 ["icon"] = [[Interface\Icons\INV_Misc_Bag_15]],
Zerotorescue@203 21 ["OnClick"] = function(frame, button)
Zerotorescue@203 22 if button == "RightButton" then
Zerotorescue@203 23 -- Open up the config
Zerotorescue@203 24 InventoriumCommandHandler("config");
Zerotorescue@203 25 elseif button == "LeftButton" then
Zerotorescue@208 26 if IsControlKeyDown() then
Zerotorescue@208 27 -- Queue
Zerotorescue@208 28 InventoriumCommandHandler("queue");
Zerotorescue@208 29 else
Zerotorescue@208 30 -- Open the summary
Zerotorescue@208 31 InventoriumCommandHandler("summary");
Zerotorescue@208 32 end
Zerotorescue@203 33 elseif button == "MiddleButton" then
Zerotorescue@203 34 -- Check stock and provide the alert if needed
Zerotorescue@203 35 InventoriumCommandHandler("alert");
Zerotorescue@203 36 end
Zerotorescue@203 37 end,
Zerotorescue@203 38 ["OnTooltipShow"] = function(tooltip)
Zerotorescue@203 39 tooltip:AddLine("Inventorium");
Zerotorescue@203 40 tooltip:AddLine(" ");
Zerotorescue@203 41 tooltip:AddLine("|cfffed000Left-click|r to open the summary window.", 0, 1, 0);
Zerotorescue@203 42 tooltip:AddLine("|cfffed000Middle-click|r to generate a stock alert.", 0, 1, 0);
Zerotorescue@203 43 tooltip:AddLine("|cfffed000Right-click|r to open the config window.", 0, 1, 0);
Zerotorescue@208 44 tooltip:AddLine("|cfffed000Control left-click|r to try to queue tracked items.", 0, 1, 0);
Zerotorescue@203 45 end,
Zerotorescue@203 46 });
Zerotorescue@203 47
Zerotorescue@208 48 if icon and not icon:IsRegistered("Inventorium") then
Zerotorescue@203 49 icon:Register("Inventorium", dataobject);
Zerotorescue@203 50 end
Zerotorescue@203 51 end
Zerotorescue@210 52
Zerotorescue@210 53 function mod:ShowIcon()
Zerotorescue@210 54 if not icon then
Zerotorescue@210 55 self:MakeIcon();
Zerotorescue@210 56 else
Zerotorescue@210 57 icon:Show("Inventorium");
Zerotorescue@210 58 end
Zerotorescue@210 59 end
Zerotorescue@210 60
Zerotorescue@210 61 function mod:HideIcon()
Zerotorescue@210 62 if icon then
Zerotorescue@210 63 icon:Hide("Inventorium");
Zerotorescue@210 64 end
Zerotorescue@210 65 end