Zerotorescue@203: local addon = select(2, ...); Zerotorescue@203: local mod = addon:NewModule("MinimapIcon"); Zerotorescue@203: Zerotorescue@210: local icon; Zerotorescue@210: Zerotorescue@203: function mod:OnEnable() Zerotorescue@210: if addon.db.profile.defaults.minimapIcon then Zerotorescue@210: self:MakeIcon(); Zerotorescue@210: end Zerotorescue@203: end Zerotorescue@203: Zerotorescue@210: function mod:MakeIcon() Zerotorescue@210: icon = LibStub("LibDBIcon-1.0"); Zerotorescue@210: Zerotorescue@203: local ldb = LibStub("LibDataBroker-1.1"); Zerotorescue@203: Zerotorescue@203: local dataobject = ldb:GetDataObjectByName("Inventorium") or ldb:NewDataObject("Inventorium", { Zerotorescue@203: ["type"] = "launcher", Zerotorescue@203: ["label"] = "Inventorium", Zerotorescue@203: ["icon"] = [[Interface\Icons\INV_Misc_Bag_15]], Zerotorescue@203: ["OnClick"] = function(frame, button) Zerotorescue@203: if button == "RightButton" then Zerotorescue@203: -- Open up the config Zerotorescue@203: InventoriumCommandHandler("config"); Zerotorescue@203: elseif button == "LeftButton" then Zerotorescue@208: if IsControlKeyDown() then Zerotorescue@208: -- Queue Zerotorescue@208: InventoriumCommandHandler("queue"); Zerotorescue@208: else Zerotorescue@208: -- Open the summary Zerotorescue@208: InventoriumCommandHandler("summary"); Zerotorescue@208: end Zerotorescue@203: elseif button == "MiddleButton" then Zerotorescue@203: -- Check stock and provide the alert if needed Zerotorescue@203: InventoriumCommandHandler("alert"); Zerotorescue@203: end Zerotorescue@203: end, Zerotorescue@203: ["OnTooltipShow"] = function(tooltip) Zerotorescue@203: tooltip:AddLine("Inventorium"); Zerotorescue@203: tooltip:AddLine(" "); Zerotorescue@203: tooltip:AddLine("|cfffed000Left-click|r to open the summary window.", 0, 1, 0); Zerotorescue@203: tooltip:AddLine("|cfffed000Middle-click|r to generate a stock alert.", 0, 1, 0); Zerotorescue@203: tooltip:AddLine("|cfffed000Right-click|r to open the config window.", 0, 1, 0); Zerotorescue@208: tooltip:AddLine("|cfffed000Control left-click|r to try to queue tracked items.", 0, 1, 0); Zerotorescue@203: end, Zerotorescue@203: }); Zerotorescue@203: Zerotorescue@208: if icon and not icon:IsRegistered("Inventorium") then Zerotorescue@203: icon:Register("Inventorium", dataobject); Zerotorescue@203: end Zerotorescue@203: end Zerotorescue@210: Zerotorescue@210: function mod:ShowIcon() Zerotorescue@210: if not icon then Zerotorescue@210: self:MakeIcon(); Zerotorescue@210: else Zerotorescue@210: icon:Show("Inventorium"); Zerotorescue@210: end Zerotorescue@210: end Zerotorescue@210: Zerotorescue@210: function mod:HideIcon() Zerotorescue@210: if icon then Zerotorescue@210: icon:Hide("Inventorium"); Zerotorescue@210: end Zerotorescue@210: end