/trunk/EasyDND/frames
--[[ |
Name: EasyDND - AntiParasites / LibDataBroker LibDBIcon-1.0 Dewdrop-2.0 |
Name: EasyDND - AntiParasites / LibDataBroker LibDBIcon-1.0 DewdropLib |
Description: This file handles Broker used for displaying a minimap icon with LibDBIcon-1.0 |
this add support to all bar mods and/or minimap with minimal spared codes |
Thanks Rabbit and Tekkub it saves so much! |
if not LibStub then return end |
local LDB, LDB_EV = LibStub:GetLibrary("LibDataBroker-1.1"), LibStub("AceEvent-3.0") |
local _, L, DEW, ICO = EasyDND, LibStub("AceLocale-3.0"):GetLocale("EasyDND"), LibStub("Dewdrop-2.0"), LibStub("LibDBIcon-1.0", true) |
if not ( LDB or _ or L or DEW ) then return end |
local _, L, DEW, ICO = EasyDND, LibStub("AceLocale-3.0"):GetLocale("EasyDND"), LibStub("Dewdrop-2.0", true), LibStub("LibDBIcon-1.0", true) |
if not ( LDB or _ or L ) then return end |
local ICONOFF = "Interface\\AddOns\\EasyDND\\icons\\dndoff" |
local ICONON = "Interface\\AddOns\\EasyDND\\icons\\dndon" |
local function ToggleMinimap() |
if _.db.profile.showminimap then |
if ICO then ICO:Show("EasyDND") else _:Print("Minimap icon OFF, install LibDBIcon-1.0 or disable the show minimap option.") end |
if ICO then ICO:Show("EasyDND") else _:Print("|cff7e7e7e".."Minimap icon disabled, install LibDBIcon-1.0 or disable the show minimap option to hide this warning.".."|r") end |
else |
if ICO then ICO:Hide("EasyDND") end |
end |
end |
local function ToggleDewdrop(a) |
if not DEW then _:Print("|cff7e7e7e".."Quick menu disabled, install DewdropLib to activate this feature.") return end |
DEW:Open(a, "children", function() |
local a = _.DEW.options.args.messages.args |
local b, save = _.DEW.options.args, nil |
local a = DEW.options.args.messages.args |
local b, save = DEW.options.args, nil |
a.msgcbt.type, a.msgmail.type, a.msgbank.type, a.msgah.type, a.msginst.type, a.msgbg.type = "text", "text", "text", "text", "text", "text" |
a.message_blockparty.type, a.message_blockduel.type, a.message_blocktrade.type = "text", "text", "text" |
a.message_blockguildinvite.type, a.message_blockguildpetition.type = "text", "text" |
b.aceConfig.order = 35 b.blizzConfig.order = 40 b.activated.order = 45 |
DEW:FeedAceOptionsTable(_.DEW.options) |
DEW:FeedAceOptionsTable(DEW.options) |
end) |
--fix the menu position to not obscurate bar icons |
AdjustDewdropPosition(a) |
LDB_EV:RegisterEvent("ZONE_CHANGED_NEW_AREA", UpdateLDB) |
end |
-- this function is used to clone the default table for Dewdrop-2.0 to apply changes on it without breaking the Ace3 table. |
-- http://lua-users.org/wiki/CopyTable |
-- Changes to the table are committed in the ToggleDewdrop function |
local function deepcopy(object) |
local lookup_table = {} |
local function _copy(object) |
if type(object) ~= "table" then |
return object |
elseif lookup_table[object] then |
return lookup_table[object] |
end |
local new_table = {} |
lookup_table[object] = new_table |
for index, value in pairs(object) do |
new_table[_copy(index)] = _copy(value) |
end |
return setmetatable(new_table, getmetatable(object)) |
end |
return _copy(object) |
end |
local function InitLDB() |
local ldb = LDB:NewDataObject("EasyDND", { |
type = "data source", |
end |
end |
_.LDB = ldb |
_.LDB.DEW = DEW |
if ICO then _.LDB.ICO = ICO end |
_.LDB.ICONON = ICONON |
_.LDB.ICONOFF = ICONOFF |
_.LDB = {} |
_.LDB.InitLDB = InitLDB |
if DEW then DEW.options = deepcopy(_.options) end |