Get an Epic Experience with Premium

LibDBIcon-1.0

Libraries Login to Add Favorites
  • 1 Like
  • World of Warcraft
  • 1,556 Monthly Downloads
  • Supports: 5.4.0
  • 638,929 Total Downloads
  • Updated 09/09/2013
  • Created 10/17/2008
  • 42 Favorites
  • Project Site
  • Release Type: Release
  • License: GNU General Public License version 2 (GPLv2)
  • Newest File: r38-release
or
Support development! **
Donate

About LibDBIcon-1.0

LibDBIcon-1.0 is a small library you can throw in your LDB addon that will create a small minimap icon for you and nothing more.

Simply get a reference to the library in your addon like so;

local icon = LibStub("LibDBIcon-1.0")

Then after you've registered your LDB object called "MyLDB", you can do:

icon:Register("MyLDB", myLDB, savedVarTable)

Where myLDB is a object reference to your LDB display and savedVarTable is a table where the library can store data like minimap position, radius and the like.

When you create the display, the library will automatically hide or show the icon based on the "hide = true/false" key in savedVarTable. If you want to add an option to hide or show the display, you can hide or show the icon manually during play with:

icon:Hide("MyLDB")
icon:Show("MyLDB")

So in conclusion, here is a complete Ace3 example of how to use this library

local addon = LibStub("AceAddon-3.0"):NewAddon("Bunnies", "AceConsole-3.0")
local bunnyLDB = LibStub("LibDataBroker-1.1"):NewDataObject("Bunnies!", {
	type = "data source",
	text = "Bunnies!",
	icon = "Interface\\Icons\\INV_Chest_Cloth_17",
	OnClick = function() print("BUNNIES ARE TAKING OVER THE WORLD") end,
})
local icon = LibStub("LibDBIcon-1.0")

function addon:OnInitialize()
	-- Obviously you'll need a ## SavedVariables: BunniesDB line in your TOC, duh!
	self.db = LibStub("AceDB-3.0"):New("BunniesDB", {
		profile = {
			minimap = {
				hide = false,
			},
		},
	})
	icon:Register("Bunnies!", bunnyLDB, self.db.profile.minimap)
	self:RegisterChatCommand("bunnies", "CommandTheBunnies")
end

function addon:CommandTheBunnies()
	self.db.profile.minimap.hide = not self.db.profile.minimap.hide
	if self.db.profile.minimap.hide then
		icon:Hide("Bunnies!")
	else
		icon:Show("Bunnies!")
	end
end

------------------------------------------------------------------------
r38 | funkydude | 2013-09-09 23:35:36 +0000 (Mon, 09 Sep 2013) | 1 line
Changed paths:
   A /tags/r38-release (from /trunk:37)

Tagging as r38-release
------------------------------------------------------------------------
r37 | funkydude | 2013-09-09 23:18:43 +0000 (Mon, 09 Sep 2013) | 1 line
Changed paths:
   M /trunk/LibDBIcon-1.0.toc

bump toc
------------------------------------------------------------------------

Login to Curse

Don't have an account? Create One.

Get an epic experience with Curse Premium
  • Faster addon downloads
  • Premium-Only Beta Giveaways
  • Ad-Free Curse experience
  • Premium Curse Client
  • and many More Features
  • Learn More »

Leaguepedia PAX Skin Giveaway