Quantcast WoWInterface: SVN - Plink - Path Comparison - / Rev 6 and / Rev 7

WoWInterface SVN Plink

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 6 to Rev 7
    Reverse comparison

Rev 6 → Rev 7

trunk/Plink!/plink.lua
1,3 → 1,14
--REGISTER OUR SOUNDS WITH LIBSHAREDMEDIA-3.0--
local LSM = LibStub("LibSharedMedia-3.0")
LSM:Register("sound", "Zelda: AOL_Deflect", "Interface\\AddOns\\Plink!\\sounds\\AOL_Deflect.wav")
LSM:Register("sound", "Zelda: LOZ_Shield", "Interface\\AddOns\\Plink!\\sounds\\LOZ_Shield.wav")
LSM:Register("sound", "Zelda: LTTP_Rupee1", "Interface\\AddOns\\Plink!\\sounds\\LTTP_Rupee1.wav")
LSM:Register("sound", "Zelda: MC_Rupee", "Interface\\AddOns\\Plink!\\sounds\\MC_Rupee.wav")
LSM:Register("sound", "Zelda: MC_Rupee_Bounce", "Interface\\AddOns\\Plink!\\sounds\\MC_Rupee_Bounce.wav")
LSM:Register("sound", "Zelda: OOT_Arrow_Hit_Ice", "Interface\\AddOns\\Plink!\\sounds\\OOT_Arrow_Hit_Ice.wav")
LSM:Register("sound", "Zelda: Oracle_Secret", "Interface\\AddOns\\Plink!\\sounds\\Oracle_Secret.wav")
LSM:Register("sound", "Zelda: WW_Map_Close_Tingle", "Interface\\AddOns\\Plink!\\sounds\\WW_Map_Close_Tingle.wav")
 
--ARE YOU A WARRIOR?--
if select(2, UnitClass("player")) ~= "WARRIOR" then
return
9,7 → 20,6
local player = UnitName("player")
local timerFrame = CreateFrame("Frame")
local chan = {"RAID", "PARTY", "Self", "None"}
local LSM = LibStub("LibSharedMedia-3.0")
local widgetLists = AceGUIWidgetLSMlists
 
local defaults = {
143,13 → 153,3
 
timerFrame:SetScript("OnUpdate", OnUpdate)
timerFrame:Hide()
 
--REGISTER OUR SOUNDS WITH LIBSHAREDMEDIA-3.0--
LSM:Register("sound", "Zelda: AOL_Deflect", "Interface\\AddOns\\Plink!\\sounds\\AOL_Deflect.wav")
LSM:Register("sound", "Zelda: LOZ_Shield", "Interface\\AddOns\\Plink!\\sounds\\LOZ_Shield.wav")
LSM:Register("sound", "Zelda: LTTP_Rupee1", "Interface\\AddOns\\Plink!\\sounds\\LTTP_Rupee1.wav")
LSM:Register("sound", "Zelda: MC_Rupee", "Interface\\AddOns\\Plink!\\sounds\\MC_Rupee.wav")
LSM:Register("sound", "Zelda: MC_Rupee_Bounce", "Interface\\AddOns\\Plink!\\sounds\\MC_Rupee_Bounce.wav")
LSM:Register("sound", "Zelda: OOT_Arrow_Hit_Ice", "Interface\\AddOns\\Plink!\\sounds\\OOT_Arrow_Hit_Ice.wav")
LSM:Register("sound", "Zelda: Oracle_Secret", "Interface\\AddOns\\Plink!\\sounds\\Oracle_Secret.wav")
LSM:Register("sound", "Zelda: WW_Map_Close_Tingle", "Interface\\AddOns\\Plink!\\sounds\\WW_Map_Close_Tingle.wav")
\ No newline at end of file
trunk/Plink!/Plink!.toc
1,6 → 1,6
## Interface: 30100
## Interface: 30300
## Title: Plink!
## Version: 1.1.1
## Version: 1.1.2
## Author: Seerah
## Notes: Plays a sound when your Spell Reflect buff gets used
## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets
trunk/Plink!/Libs/AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua
8,11 → 8,11
local min, max, floor = math.min, math.max, math.floor
local fixlevels = AceGUISharedMediaWidgets.fixlevels
local OnItemValueChanged = AceGUISharedMediaWidgets.OnItemValueChanged
 
 
do
local widgetType = "LSM30_Border_Item_Select"
local widgetVersion = 1
 
 
local function Frame_OnEnter(this)
local self = this.obj
 
21,7 → 21,7
self.border:Show()
end
self:Fire("OnEnter")
 
 
if self.specialOnEnter then
self.specialOnEnter(self)
end
32,7 → 32,7
self.border:Hide()
self.highlight:Hide()
self:Fire("OnLeave")
 
 
if self.specialOnLeave then
self.specialOnLeave(self)
end
46,7 → 46,7
end
self.text:SetText(text or "")
end
 
 
local function Constructor()
local self = AceGUI:Create("Dropdown-Item-Toggle")
self.type = widgetType
68,23 → 68,23
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
 
do
do
local widgetType = "LSM30_Border"
local widgetVersion = 2
 
local widgetVersion = 3
 
local function Frame_OnEnter(this)
local self = this.obj
local text = self.text:GetText()
if text ~= nil and text ~= '' then
if text ~= nil and text ~= '' then
self.borderframe:Show()
end
end
 
 
local function Frame_OnLeave(this)
local self = this.obj
self.borderframe:Hide()
end
 
 
local function AddListItem(self, value, text)
local item = AceGUI:Create("LSM30_Border_Item_Select")
item:SetText(text)
93,11 → 93,17
item:SetCallback("OnValueChanged", OnItemValueChanged)
self.pullout:AddItem(item)
end
 
local sortlist = {}
 
local function SetList(self, list)
self.list = list or Media:HashTable("border")
self.pullout:Clear()
if self.multiselect then
AddCloseButton()
end
end
 
local sortlist = {}
local function ParseListItems(self)
for v in pairs(self.list) do
sortlist[#sortlist + 1] = v
end
106,11 → 112,8
AddListItem(self, value, value)
sortlist[i] = nil
end
if self.multiselect then
AddCloseButton()
end
end
 
 
local function SetText(self, text)
if text and text ~= '' then
local backdropTable = self.borderframe:GetBackdrop()
119,18 → 122,18
end
self.text:SetText(text or "")
end
 
 
local function Constructor()
local self = AceGUI:Create("Dropdown")
self.type = widgetType
self.SetList = SetList
self.SetText = SetText
self.SetValue = AceGUISharedMediaWidgets.SetValue
 
 
local left = _G[self.dropdown:GetName() .. "Left"]
local middle = _G[self.dropdown:GetName() .. "Middle"]
local right = _G[self.dropdown:GetName() .. "Right"]
 
 
local borderframe = CreateFrame('Frame')
borderframe:SetFrameStrata("TOOLTIP")
borderframe:SetWidth(64)
141,11 → 144,18
insets = { left = 4, right = 4, top = 4, bottom = 4 }})
self.borderframe = borderframe
borderframe:Hide()
 
 
self.dropdown:EnableMouse(true)
self.dropdown:SetScript("OnEnter", Frame_OnEnter)
self.dropdown:SetScript("OnLeave", Frame_OnLeave)
 
 
local clickscript = self.button:GetScript("OnClick")
self.button:SetScript("OnClick", function(...)
self.pullout:Clear()
ParseListItems(self)
clickscript(...)
end)
 
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
trunk/Plink!/Libs/AceGUI-3.0-SharedMediaWidgets/BackgroundWidget.lua
8,11 → 8,11
local min, max, floor = math.min, math.max, math.floor
local fixlevels = AceGUISharedMediaWidgets.fixlevels
local OnItemValueChanged = AceGUISharedMediaWidgets.OnItemValueChanged
 
 
do
local widgetType = "LSM30_Background_Item_Select"
local widgetVersion = 1
 
 
local function Frame_OnEnter(this)
local self = this.obj
 
21,7 → 21,7
self.texture:Show()
end
self:Fire("OnEnter")
 
 
if self.specialOnEnter then
self.specialOnEnter(self)
end
32,7 → 32,7
self.texture:Hide()
self.highlight:Hide()
self:Fire("OnLeave")
 
 
if self.specialOnLeave then
self.specialOnLeave(self)
end
44,7 → 44,7
end
self.text:SetText(text or "")
end
 
 
local function Constructor()
local self = AceGUI:Create("Dropdown-Item-Toggle")
self.type = widgetType
67,30 → 67,30
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
 
do
do
local widgetType = "LSM30_Background"
local widgetVersion = 2
 
local widgetVersion = 3
 
local function Frame_OnEnter(this)
local self = this.obj
local text = self.text:GetText()
if text ~= nil and text ~= '' then
if text ~= nil and text ~= '' then
self.textureframe:Show()
end
end
 
 
local function Frame_OnLeave(this)
local self = this.obj
self.textureframe:Hide()
end
 
 
local function SetText(self, text)
if text and text ~= '' then
self.texture:SetTexture(Media:Fetch('background',text))
end
self.text:SetText(text or "")
end
 
 
local function AddListItem(self, value, text)
local item = AceGUI:Create("LSM30_Background_Item_Select")
item:SetText(text)
99,11 → 99,18
item:SetCallback("OnValueChanged", OnItemValueChanged)
self.pullout:AddItem(item)
end
 
local sortlist = {}
 
local function SetList(self, list)
self.list = list or Media:HashTable("background")
self.pullout:Clear()
 
if self.multiselect then
AddCloseButton()
end
end
 
local sortlist = {}
local function ParseListItems(self)
for v in pairs(self.list) do
sortlist[#sortlist + 1] = v
end
112,22 → 119,19
AddListItem(self, value, value)
sortlist[i] = nil
end
if self.multiselect then
AddCloseButton()
end
end
 
 
local function Constructor()
local self = AceGUI:Create("Dropdown")
self.type = widgetType
self.SetText = SetText
self.SetList = SetList
self.SetValue = AceGUISharedMediaWidgets.SetValue
 
 
local left = _G[self.dropdown:GetName() .. "Left"]
local middle = _G[self.dropdown:GetName() .. "Middle"]
local right = _G[self.dropdown:GetName() .. "Right"]
 
 
local textureframe = CreateFrame('Frame')
textureframe:SetFrameStrata("TOOLTIP")
textureframe:SetWidth(128)
139,11 → 143,18
texture:SetAllPoints(textureframe)
textureframe:Hide()
self.texture = texture
 
 
self.dropdown:EnableMouse(true)
self.dropdown:SetScript("OnEnter", Frame_OnEnter)
self.dropdown:SetScript("OnLeave", Frame_OnLeave)
 
 
local clickscript = self.button:GetScript("OnClick")
self.button:SetScript("OnClick", function(...)
self.pullout:Clear()
ParseListItems(self)
clickscript(...)
end)
 
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
trunk/Plink!/Libs/AceGUI-3.0-SharedMediaWidgets/FontWidget.lua
8,7 → 8,7
local min, max, floor = math.min, math.max, math.floor
local fixlevels = AceGUISharedMediaWidgets.fixlevels
local OnItemValueChanged = AceGUISharedMediaWidgets.OnItemValueChanged
 
 
do
local widgetType = "LSM30_Font_Item_Select"
local widgetVersion = 1
20,29 → 20,29
end
self.text:SetText(text or "")
end
 
 
local function Constructor()
local self = AceGUI:Create("Dropdown-Item-Toggle")
self.type = widgetType
self.SetText = SetText
return self
end
 
 
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
 
do
local widgetType = "LSM30_Font"
local widgetVersion = 2
 
local function SetText(self, text)
local widgetVersion = 3
 
local function SetText(self, text)
if text and text ~= '' then
local _, size, outline= self.text:GetFont()
self.text:SetFont(Media:Fetch('font',text),size,outline)
end
self.text:SetText(text or "")
end
 
 
local function AddListItem(self, value, text)
local item = AceGUI:Create("LSM30_Font_Item_Select")
item:SetText(text)
51,11 → 51,17
item:SetCallback("OnValueChanged", OnItemValueChanged)
self.pullout:AddItem(item)
end
 
local sortlist = {}
 
local function SetList(self, list)
self.list = list or Media:HashTable("font")
self.pullout:Clear()
if self.multiselect then
AddCloseButton()
end
end
 
local sortlist = {}
local function ParseListItems(self)
for v in pairs(self.list) do
sortlist[#sortlist + 1] = v
end
64,20 → 70,25
AddListItem(self, value, value)
sortlist[i] = nil
end
if self.multiselect then
AddCloseButton()
end
end
 
 
local function Constructor()
local self = AceGUI:Create("Dropdown")
self.type = widgetType
self.SetText = SetText
self.SetValue = AceGUISharedMediaWidgets.SetValue
self.SetList = SetList
 
local clickscript = self.button:GetScript("OnClick")
self.button:SetScript("OnClick", function(...)
self.pullout:Clear()
ParseListItems(self)
clickscript(...)
end)
 
return self
end
 
 
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
end
trunk/Plink!/Libs/AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua
8,11 → 8,11
local min, max, floor = math.min, math.max, math.floor
local fixlevels = AceGUISharedMediaWidgets.fixlevels
local OnItemValueChanged = AceGUISharedMediaWidgets.OnItemValueChanged
 
 
do
local widgetType = "LSM30_Sound_Item_Select"
local widgetVersion = 1
 
 
local function Frame_OnEnter(this)
local self = this.obj
 
20,7 → 20,7
self.highlight:Show()
end
self:Fire("OnEnter")
 
 
if self.specialOnEnter then
self.specialOnEnter(self)
end
28,10 → 28,10
 
local function Frame_OnLeave(this)
local self = this.obj
 
 
self.highlight:Hide()
self:Fire("OnLeave")
 
 
if self.specialOnLeave then
self.specialOnLeave(self)
end
51,7 → 51,7
 
local function SetPullout(self, pullout)
self.pullout = pullout
 
 
self.frame:SetParent(nil)
self.frame:SetParent(pullout.itemFrame)
self.parent = pullout.itemFrame
78,7 → 78,7
local function Hide(self)
self.frame:Hide()
end
 
 
local function SetDisabled(self, disabled)
self.disabled = disabled
if disabled then
89,7 → 89,7
self.text:SetTextColor(1, 1, 1)
end
end
 
 
local function SetOnLeave(self, func)
self.specialOnLeave = func
end
105,24 → 105,24
self.check:Hide()
end
end
 
 
local function Frame_OnClick(this, button)
local self = this.obj
self.value = not self.value
UpdateToggle(self)
self:Fire("OnValueChanged", self.value)
end
 
 
local function Speaker_OnClick(this, button)
local self = this.obj
PlaySoundFile(Media:Fetch('sound',self.sound))
end
 
 
local function SetValue(self, value)
self.value = value
UpdateToggle(self)
end
 
 
local function Constructor()
local count = AceGUI:GetNextWidgetNum(type)
local frame = CreateFrame("Frame", "LSM30_Sound_DropDownItem"..count)
130,35 → 130,35
self.frame = frame
frame.obj = self
self.type = type
 
 
self.useHighlight = true
 
 
frame:SetHeight(17)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
 
 
local button = CreateFrame("Button", nil, frame)
button:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-22,0)
button:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
self.button = button
button.obj = self
 
 
local speakerbutton = CreateFrame("Button", nil, frame)
speakerbutton:SetWidth(16)
speakerbutton:SetHeight(16)
speakerbutton:SetPoint("RIGHT",frame,"RIGHT",-6,0)
self.speakerbutton = speakerbutton
speakerbutton.obj = self
 
 
local speaker = frame:CreateTexture(nil, "BACKGROUND")
speaker:SetTexture("Interface\\Common\\VoiceChat-Speaker")
speaker:SetAllPoints(speakerbutton)
self.speaker = speaker
 
 
local speakeron = speakerbutton:CreateTexture(nil, "HIGHLIGHT")
speakeron:SetTexture("Interface\\Common\\VoiceChat-On")
speakeron:SetAllPoints(speakerbutton)
self.speakeron = speakeron
 
 
local text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
text:SetTextColor(1,1,1)
text:SetJustifyH("LEFT")
175,8 → 175,8
highlight:SetPoint("LEFT",frame,"LEFT",5,0)
highlight:Hide()
self.highlight = highlight
 
local check = frame:CreateTexture("OVERLAY")
 
local check = frame:CreateTexture("OVERLAY")
check:SetWidth(16)
check:SetHeight(16)
check:SetPoint("LEFT",frame,"LEFT",3,-1)
190,41 → 190,41
sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1)
sub:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
sub:Hide()
self.sub = sub
 
self.sub = sub
 
button:SetScript("OnEnter", Frame_OnEnter)
button:SetScript("OnLeave", Frame_OnLeave)
 
 
self.OnAcquire = OnAcquire
self.OnRelease = OnRelease
 
 
self.SetPullout = SetPullout
self.GetText = GetText
self.SetText = SetText
self.SetDisabled = SetDisabled
 
 
self.SetPoint = SetPoint
self.Show = Show
self.Hide = Hide
 
 
self.SetOnLeave = SetOnLeave
self.SetOnEnter = SetOnEnter
 
 
self.button:SetScript("OnClick", Frame_OnClick)
self.speakerbutton:SetScript("OnClick", Speaker_OnClick)
 
 
self.SetValue = SetValue
 
 
AceGUI:RegisterAsWidget(self)
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
 
do
do
local widgetType = "LSM30_Sound"
local widgetVersion = 2
 
local widgetVersion = 3
 
local function AddListItem(self, value, text)
local item = AceGUI:Create("LSM30_Sound_Item_Select")
item:SetText(text)
233,11 → 233,17
item:SetCallback("OnValueChanged", OnItemValueChanged)
self.pullout:AddItem(item)
end
 
local sortlist = {}
 
local function SetList(self, list)
self.list = list or Media:HashTable("sound")
self.pullout:Clear()
if self.multiselect then
AddCloseButton()
end
end
 
local sortlist = {}
local function ParseListItems(self)
for v in pairs(self.list) do
sortlist[#sortlist + 1] = v
end
246,16 → 252,21
AddListItem(self, value, value)
sortlist[i] = nil
end
if self.multiselect then
AddCloseButton()
end
end
 
 
local function Constructor()
local self = AceGUI:Create("Dropdown")
self.type = widgetType
self.SetList = SetList
self.SetValue = AceGUISharedMediaWidgets.SetValue
 
local clickscript = self.button:GetScript("OnClick")
self.button:SetScript("OnClick", function(...)
self.pullout:Clear()
ParseListItems(self)
clickscript(...)
end)
 
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
trunk/Plink!/Libs/AceGUI-3.0-SharedMediaWidgets/StatusbarWidget.lua
8,7 → 8,7
local min, max, floor = math.min, math.max, math.floor
local fixlevels = AceGUISharedMediaWidgets.fixlevels
local OnItemValueChanged = AceGUISharedMediaWidgets.OnItemValueChanged
 
 
do
local widgetType = "LSM30_Statusbar_Item_Select"
local widgetVersion = 1
35,10 → 35,10
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
 
do
do
local widgetType = "LSM30_Statusbar"
local widgetVersion = 2
 
local widgetVersion = 3
 
local function SetText(self, text)
if text and text ~= '' then
self.texture:SetTexture(Media:Fetch('statusbar',text))
46,7 → 46,7
end
self.text:SetText(text or "")
end
 
 
local function AddListItem(self, value, text)
local item = AceGUI:Create("LSM30_Statusbar_Item_Select")
item:SetText(text)
55,11 → 55,17
item:SetCallback("OnValueChanged", OnItemValueChanged)
self.pullout:AddItem(item)
end
 
local sortlist = {}
 
local function SetList(self, list)
self.list = list or Media:HashTable("statusbar")
self.pullout:Clear()
if self.multiselect then
AddCloseButton()
end
end
 
local sortlist = {}
local function ParseListItems(self)
for v in pairs(self.list) do
sortlist[#sortlist + 1] = v
end
68,26 → 74,31
AddListItem(self, value, value)
sortlist[i] = nil
end
if self.multiselect then
AddCloseButton()
end
end
 
 
local function Constructor()
local self = AceGUI:Create("Dropdown")
self.type = widgetType
self.SetText = SetText
self.SetList = SetList
self.SetValue = AceGUISharedMediaWidgets.SetValue
 
 
local left = _G[self.dropdown:GetName() .. "Left"]
local middle = _G[self.dropdown:GetName() .. "Middle"]
local right = _G[self.dropdown:GetName() .. "Right"]
 
 
local texture = self.dropdown:CreateTexture(nil, "ARTWORK")
texture:SetPoint("BOTTOMRIGHT", right, "BOTTOMRIGHT" ,-39, 26)
texture:SetPoint("TOPLEFT", left, "TOPLEFT", 24, -24)
self.texture = texture
 
local clickscript = self.button:GetScript("OnClick")
self.button:SetScript("OnClick", function(...)
self.pullout:Clear()
ParseListItems(self)
clickscript(...)
end)
 
return self
end
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
trunk/Plink!/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua
1,20 → 1,21
--[[ $Id: CallbackHandler-1.0.lua 504 2008-02-07 11:04:06Z nevcairiel $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 3
--[[ $Id: CallbackHandler-1.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 5
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
 
if not CallbackHandler then return end -- No upgrade needed
 
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
 
local type = type
local pcall = pcall
local pairs = pairs
local assert = assert
local concat = table.concat
local loadstring = loadstring
local next = next
local select = select
local type = type
-- Lua APIs
local tconcat = table.concat
local assert, error, loadstring = assert, error, loadstring
local setmetatable, rawset, rawget = setmetatable, rawset, rawget
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: geterrorhandler
 
local xpcall = xpcall
 
local function errorhandler(err)
46,7 → 47,7
 
local ARGS, OLD_ARGS = {}, {}
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
code = code:gsub("OLD_ARGS", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(ARGS, ", "))
code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
end
 
trunk/Plink!/Libs/AceEvent-3.0/AceEvent-3.0.lua
1,19 → 1,28
--- AceEvent-3.0 provides event registration and secure dispatching.
-- All dispatching is done using **CallbackHandler-1.0**. AceEvent is a simple wrapper around
-- CallbackHandler, and dispatches all game events or addon message to the registrees.
--
-- **AceEvent-3.0** can be embeded into your addon, either explicitly by calling AceEvent:Embed(MyAddon) or by
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
-- and can be accessed directly, without having to explicitly call AceEvent itself.\\
-- It is recommended to embed AceEvent, otherwise you'll have to specify a custom `self` on all calls you
-- make into AceEvent.
-- @class file
-- @name AceEvent-3.0
-- @release $Id: AceEvent-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $
-- @release $Id: AceEvent-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $
local MAJOR, MINOR = "AceEvent-3.0", 3
local AceEvent = LibStub:NewLibrary(MAJOR, MINOR)
 
if not AceEvent then return end
 
-- Lua APIs
local pairs = pairs
 
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
 
 
AceEvent.frame = AceEvent.frame or CreateFrame("Frame", "AceEvent30Frame") -- our event frame
AceEvent.embeds = AceEvent.embeds or {} -- what objects embed this lib
 
 
-- APIs and registry for blizzard events, using CallbackHandler lib
if not AceEvent.events then
AceEvent.events = CallbackHandler:New(AceEvent,
43,12 → 52,50
"RegisterMessage", "UnregisterMessage",
"SendMessage",
"UnregisterAllEvents", "UnregisterAllMessages",
}
}
 
-- AceEvent:Embed( target )
-- target (object) - target object to embed AceEvent in
--
--- Register for a Blizzard Event.
-- The callback will always be called with the event as the first argument, and if supplied, the `arg` as second argument.
-- Any arguments to the event will be passed on after that.
-- @name AceEvent:RegisterEvent
-- @class function
-- @paramsig event[, callback [, arg]]
-- @param event The event to register for
-- @param callback The callback function to call when the event is triggered (funcref or method, defaults to a method with the event name)
-- @param arg An optional argument to pass to the callback function
 
--- Unregister an event.
-- @name AceEvent:UnregisterEvent
-- @class function
-- @paramsig event
-- @param event The event to unregister
 
--- Register for a custom AceEvent-internal message.
-- The callback will always be called with the event as the first argument, and if supplied, the `arg` as second argument.
-- Any arguments to the event will be passed on after that.
-- @name AceEvent:RegisterMessage
-- @class function
-- @paramsig message[, callback [, arg]]
-- @param message The message to register for
-- @param callback The callback function to call when the message is triggered (funcref or method, defaults to a method with the event name)
-- @param arg An optional argument to pass to the callback function
 
--- Unregister a message
-- @name AceEvent:UnregisterMessage
-- @class function
-- @paramsig message
-- @param message The message to unregister
 
--- Send a message over the AceEvent-3.0 internal message system to other addons registered for this message.
-- @name AceEvent:SendMessage
-- @class function
-- @paramsig message, ...
-- @param message The message to send
-- @param ... Any arguments to the message
 
 
-- Embeds AceEvent into the target object making the functions from the mixins list available on target:..
-- @param target target object to embed AceEvent in
function AceEvent:Embed(target)
for k, v in pairs(mixins) do
target[v] = self[v]
trunk/Plink!/Libs/AceConsole-3.0/AceConsole-3.0.lua
1,8 → 1,16
--- AceConsole-3.0 provides registration facilities for slash commands.
--- **AceConsole-3.0** provides registration facilities for slash commands.
-- You can register slash commands to your custom functions and use the `GetArgs` function to parse them
-- to your addons individual needs.
--
-- **AceConsole-3.0** can be embeded into your addon, either explicitly by calling AceConsole:Embed(MyAddon) or by
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
-- and can be accessed directly, without having to explicitly call AceConsole itself.\\
-- It is recommended to embed AceConsole, otherwise you'll have to specify a custom `self` on all calls you
-- make into AceConsole.
-- @class file
-- @name AceConsole-3.0
-- @release $Id: AceConsole-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $
local MAJOR,MINOR = "AceConsole-3.0", 6
-- @release $Id: AceConsole-3.0.lua 878 2009-11-02 18:51:58Z nevcairiel $
local MAJOR,MINOR = "AceConsole-3.0", 7
 
local AceConsole, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
12,44 → 20,68
AceConsole.commands = AceConsole.commands or {} -- table containing commands registered
AceConsole.weakcommands = AceConsole.weakcommands or {} -- table containing self, command => func references for weak commands that don't persist through enable/disable
 
-- local upvalues
local _G = _G
local pairs = pairs
local select = select
local type = type
local tostring = tostring
local strfind = string.find
local strsub = string.sub
-- Lua APIs
local tconcat, tostring, select = table.concat, tostring, select
local type, pairs, error = type, pairs, error
local format, strfind, strsub = string.format, string.find, string.sub
local max = math.max
 
-- AceConsole:Print( [chatframe,] ... )
--
-- Print to DEFAULT_CHAT_FRAME or given chatframe (anything with an .AddMessage member)
function AceConsole:Print(...)
local text = ""
-- WoW APIs
local _G = _G
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: DEFAULT_CHAT_FRAME, SlashCmdList, hash_SlashCmdList
 
local tmp={}
local function Print(self,frame,...)
local n=0
if self ~= AceConsole then
text = "|cff33ff99"..tostring( self ).."|r: "
n=n+1
tmp[n] = "|cff33ff99"..tostring( self ).."|r:"
end
for i=1, select("#", ...) do
n=n+1
tmp[n] = tostring(select(i, ...))
end
frame:AddMessage( tconcat(tmp," ",1,n) )
end
 
local frame = select(1, ...)
if not ( type(frame) == "table" and frame.AddMessage ) then -- Is first argument something with an .AddMessage member?
frame=nil
--- Print to DEFAULT_CHAT_FRAME or given ChatFrame (anything with an .AddMessage function)
-- @paramsig [chatframe ,] ...
-- @param chatframe Custom ChatFrame to print to (or any frame with an .AddMessage function)
-- @param ... List of any values to be printed
function AceConsole:Print(...)
local frame = ...
if type(frame) == "table" and frame.AddMessage then -- Is first argument something with an .AddMessage member?
return Print(self, frame, select(2,...))
else
return Print(self, DEFAULT_CHAT_FRAME, ...)
end
 
for i=(frame and 2 or 1), select("#", ...) do
text = text .. tostring( select( i, ...) ) .." "
end
 
 
--- Formatted (using format()) print to DEFAULT_CHAT_FRAME or given ChatFrame (anything with an .AddMessage function)
-- @paramsig [chatframe ,] "format"[, ...]
-- @param chatframe Custom ChatFrame to print to (or any frame with an .AddMessage function)
-- @param format Format string - same syntax as standard Lua format()
-- @param ... Arguments to the format string
function AceConsole:Printf(...)
local frame = ...
if type(frame) == "table" and frame.AddMessage then -- Is first argument something with an .AddMessage member?
return Print(self, frame, format(select(2,...)))
else
return Print(self, DEFAULT_CHAT_FRAME, format(...))
end
(frame or DEFAULT_CHAT_FRAME):AddMessage( text )
end
 
 
-- AceConsole:RegisterChatCommand(. command, func, persist )
--
-- command (string) - chat command to be registered WITHOUT leading "/"
-- func (function|membername) - function to call, or self[membername](self, ...) call
-- persist (boolean) - false: the command will be soft disabled/enabled when aceconsole is used as a mixin (default: true)
--
-- Register a simple chat command
 
 
--- Register a simple chat command
-- @param command Chat command to be registered WITHOUT leading "/"
-- @param func Function to call when the slash command is being used (funcref or methodname)
-- @param persist if false, the command will be soft disabled/enabled when aceconsole is used as a mixin (default: true)
function AceConsole:RegisterChatCommand( command, func, persist )
if type(command)~="string" then error([[Usage: AceConsole:RegisterChatCommand( "command", func[, persist ]): 'command' - expected a string]], 2) end
 
74,10 → 106,8
return true
end
 
 
-- AceConsole:UnregisterChatCommand( command )
--
-- Unregister a chatcommand
--- Unregister a chatcommand
-- @param command Chat command to be unregistered WITHOUT leading "/"
function AceConsole:UnregisterChatCommand( command )
local name = AceConsole.commands[command]
if name then
88,6 → 118,8
end
end
 
--- Get an iterator over all Chat Commands registered with AceConsole
-- @return Iterator (pairs) over all commands
function AceConsole:IterateChatCommands() return pairs(AceConsole.commands) end
 
 
102,18 → 134,13
end
 
 
-- AceConsole:GetArgs(string, numargs, startpos)
--
-- Retreive one or more space-separated arguments from a string.
--- Retreive one or more space-separated arguments from a string.
-- Treats quoted strings and itemlinks as non-spaced.
--
-- string - The raw argument string
-- numargs - How many arguments to get (default 1)
-- startpos - Where in the string to start scanning (default 1)
--
-- Returns arg1, arg2, ..., nextposition
-- @param string The raw argument string
-- @param numargs How many arguments to get (default 1)
-- @param startpos Where in the string to start scanning (default 1)
-- @return Returns arg1, arg2, ..., nextposition\\
-- Missing arguments will be returned as nils. 'nextposition' is returned as 1e9 at the end of the string.
 
function AceConsole:GetArgs(str, numargs, startpos)
numargs = numargs or 1
startpos = max(startpos or 1, 1)
186,15 → 213,14
 
local mixins = {
"Print",
"Printf",
"RegisterChatCommand",
"UnregisterChatCommand",
"GetArgs",
}
 
-- AceConsole:Embed( target )
-- target (object) - target object to embed AceBucket in
--
-- Embeds AceConsole into the target object making the functions from the mixins list available on target:..
-- @param target target object to embed AceBucket in
function AceConsole:Embed( target )
for k, v in pairs( mixins ) do
target[v] = self[v]
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua
3,33 → 3,20
--Multiline Editbox Widget, Originally by bam
 
--]]
local assert, error, ipairs, next, pairs, select, tonumber, tostring, type, unpack, pcall, xpcall =
assert, error, ipairs, next, pairs, select, tonumber, tostring, type, unpack, pcall, xpcall
local getmetatable, setmetatable, rawequal, rawget, rawset, getfenv, setfenv, loadstring, debugstack =
getmetatable, setmetatable, rawequal, rawget, rawset, getfenv, setfenv, loadstring, debugstack
local math, string, table = math, string, table
local find, format, gmatch, gsub, tolower, match, toupper, join, split, trim =
string.find, string.format, string.gmatch, string.gsub, string.lower, string.match, string.upper, string.join, string.split, string.trim
local concat, insert, maxn, remove, sort = table.concat, table.insert, table.maxn, table.remove, table.sort
local max, min, abs, ceil, floor = math.max, math.min, math.abs, math.ceil, math.floor
local AceGUI = LibStub("AceGUI-3.0")
 
local LibStub = assert(LibStub)
-- Lua APIs
local format, pairs, tostring = string.format, pairs, tostring
 
local ChatFontNormal = ChatFontNormal
local ClearCursor = ClearCursor
local CreateFrame = CreateFrame
local GetCursorInfo = GetCursorInfo
local GetSpellName = GetSpellName
local UIParent = UIParent
local UISpecialFrames = UISpecialFrames
-- WoW APIs
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName
local CreateFrame, UIParent = CreateFrame, UIParent
 
-- No global variables after this!
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: ChatFontNormal, ACCEPT
 
local _G = getfenv()
 
local AceGUI = LibStub("AceGUI-3.0")
 
local Version = 7
local Version = 11
---------------------
-- Common Elements --
---------------------
101,11 → 88,14
self:Fire("OnEnterPressed",name)
ClearCursor()
end
self.button:Disable()
--self.button:Disable()
AceGUI:ClearFocus()
end
 
function MultiLineEditBox:OnAcquire()
self:SetWidth(200)
self:SetHeight(116)
self:SetNumLines(4)
self:SetDisabled(false)
self:ShowButton(true)
end
124,11 → 114,13
self.editbox:ClearFocus()
self.editbox:SetTextColor(0.5, 0.5, 0.5)
self.label:SetTextColor(0.5,0.5,0.5)
self.button:Disable()
else
self.editbox:EnableMouse(true)
self.scrollframe:EnableMouse(true)
self.editbox:SetTextColor(1, 1, 1)
self.label:SetTextColor(1,.82,0)
self.button:Enable()
end
end
 
155,6 → 147,11
self.label:SetText(text)
end
end
 
function MultiLineEditBox:SetNumLines(number)
number = number or 4
self:SetHeight(60 + (14*number))
end
 
function MultiLineEditBox:GetText()
return self.editbox:GetText()
193,10 → 190,10
scrollframe.obj = self
self.scrollframe = scrollframe
 
local scrollchild = CreateFrame("Frame", nil, scrollframe)
scrollframe:SetScrollChild(scrollchild)
scrollchild:SetHeight(2)
scrollchild:SetWidth(2)
--local scrollchild = CreateFrame("Frame", nil, scrollframe)
--scrollframe:SetScrollChild(scrollchild)
--scrollchild:SetHeight(2)
--scrollchild:SetWidth(2)
 
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-2)
205,10 → 202,11
label:SetHeight(18)
self.label = label
 
local editbox = CreateFrame("EditBox", nil, scrollchild)
local editbox = CreateFrame("EditBox", nil, scrollframe)
self.editbox = editbox
editbox.obj = self
editbox:SetPoint("TOPLEFT")
editbox:SetPoint("BOTTOMLEFT")
editbox:SetHeight(50)
editbox:SetWidth(50)
editbox:SetMultiLine(true)
217,6 → 215,7
editbox:EnableMouse(true)
editbox:SetAutoFocus(false)
editbox:SetFontObject(ChatFontNormal)
scrollframe:SetScrollChild(editbox)
 
local button = CreateFrame("Button",nil,scrollframe,"UIPanelButtonTemplate")
button:SetWidth(80)
224,6 → 223,7
button:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,2)
button:SetText(ACCEPT)
button:SetScript("OnClick", Button_OnClick)
button:SetFrameLevel(editbox:GetFrameLevel() + 1)
button:Disable()
button:Hide()
self.button = button
238,8 → 238,8
editbox:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end)
 
local function FixSize()
scrollchild:SetHeight(scrollframe:GetHeight())
scrollchild:SetWidth(scrollframe:GetWidth())
--scrollchild:SetHeight(scrollframe:GetHeight())
--scrollchild:SetWidth(scrollframe:GetWidth())
editbox:SetWidth(scrollframe:GetWidth())
end
scrollframe:SetScript("OnShow", FixSize)
250,9 → 250,11
scrollframe:UpdateScrollChildRect()
local value = editbox:GetText()
if value ~= self.lasttext then
self:Fire("OnTextChanged", value)
self.lasttext = value
self.button:Enable()
self:Fire("OnTextChanged", value)
self.lasttext = value
if not self.disabled then
self.button:Enable()
end
end
end)
 
263,36 → 265,36
local cursorOffset, cursorHeight
local idleTime
local function FixScroll(_, elapsed)
if cursorOffset and cursorHeight then
idleTime = 0
local height = scrollframe:GetHeight()
local range = scrollframe:GetVerticalScrollRange()
local scroll = scrollframe:GetVerticalScroll()
local size = height + range
cursorOffset = -cursorOffset
while cursorOffset < scroll do
scroll = scroll - (height / 2)
if scroll < 0 then scroll = 0 end
scrollframe:SetVerticalScroll(scroll)
if cursorOffset and cursorHeight then
idleTime = 0
local height = scrollframe:GetHeight()
local range = scrollframe:GetVerticalScrollRange()
local scroll = scrollframe:GetVerticalScroll()
local size = height + range
cursorOffset = -cursorOffset
while cursorOffset < scroll do
scroll = scroll - (height / 2)
if scroll < 0 then scroll = 0 end
scrollframe:SetVerticalScroll(scroll)
end
while cursorOffset + cursorHeight > scroll + height and scroll < range do
scroll = scroll + (height / 2)
if scroll > range then scroll = range end
scrollframe:SetVerticalScroll(scroll)
end
elseif not idleTime or idleTime > 2 then
frame:SetScript("OnUpdate", nil)
idleTime = nil
else
idleTime = idleTime + elapsed
end
while cursorOffset + cursorHeight > scroll + height and scroll < range do
scroll = scroll + (height / 2)
if scroll > range then scroll = range end
scrollframe:SetVerticalScroll(scroll)
end
elseif not idleTime or idleTime > 2 then
frame:SetScript("OnUpdate", nil)
idleTime = nil
else
idleTime = idleTime + elapsed
cursorOffset = nil
end
cursorOffset = nil
end
editbox:SetScript("OnCursorChanged", function(_, x, y, w, h)
cursorOffset, cursorHeight = y, h
if not idleTime then
frame:SetScript("OnUpdate", FixScroll)
end
cursorOffset, cursorHeight = y, h
if not idleTime then
frame:SetScript("OnUpdate", FixScroll)
end
end)
end
 
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua
1,16 → 1,29
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local tonumber = tonumber
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: GameFontHighlightSmall
 
--------------------------
-- Slider --
--------------------------
do
local Type = "Slider"
local Version = 5
local Version = 9
 
local function OnAcquire(self)
self:SetWidth(200)
self:SetHeight(44)
self:SetDisabled(false)
self:SetIsPercent(nil)
self:SetSliderValues(0,100,1)
self:SetIsPercent(nil)
self:SetValue(0)
end
 
30,13 → 43,25
end
 
local function UpdateText(self)
local value = self.value or 0
if self.ispercent then
self.editbox:SetText((math.floor(self.value*1000+0.5)/10)..'%')
self.editbox:SetText(("%s%%"):format(floor(value*1000+0.5)/10))
else
self.editbox:SetText(math.floor(self.value*100+0.5)/100)
self.editbox:SetText(floor(value*100+0.5)/100)
end
end
 
local function UpdateLabels(self)
local min, max = (self.min or 0), (self.max or 100)
if self.ispercent then
self.lowtext:SetFormattedText("%s%%",(min * 100))
self.hightext:SetFormattedText("%s%%",(max * 100))
else
self.lowtext:SetText(min)
self.hightext:SetText(max)
end
end
 
local function Slider_OnValueChanged(this)
local self = this.obj
if not this.setup then
63,9 → 88,9
if not self.disabled then
local value = self.value
if v > 0 then
value = math.min(value + (self.step or 1),self.max)
value = min(value + (self.step or 1),self.max)
else
value = math.max(value - (self.step or 1), self.min)
value = max(value - (self.step or 1), self.min)
end
self.slider:SetValue(value)
end
105,16 → 130,18
self.label:SetText(text)
end
 
local function SetSliderValues(self,min, max, step)
local function SetSliderValues(self, min, max, step)
local frame = self.slider
frame.setup = true
self.min = min
self.max = max
self.step = step
frame:SetMinMaxValues(min or 0,max or 100)
self.lowtext:SetText(min or 0)
self.hightext:SetText(max or 100)
UpdateLabels(self)
frame:SetValueStep(step or 1)
if self.value then
frame:SetValue(self.value)
end
frame.setup = nil
end
 
137,8 → 164,18
end
end
 
local function EditBox_OnEnter(this)
this:SetBackdropBorderColor(0.5,0.5,0.5,1)
end
 
local function EditBox_OnLeave(this)
this:SetBackdropBorderColor(0.3,0.3,0.3,0.8)
end
 
local function SetIsPercent(self, value)
self.ispercent = value
UpdateLabels(self)
UpdateText(self)
end
 
local function FrameOnMouseDown(this)
153,6 → 190,12
insets = { left = 3, right = 3, top = 6, bottom = 6 }
}
 
local ManualBackdrop = {
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
tile = true, edgeSize = 1, tileSize = 5,
}
 
local function Constructor()
local frame = CreateFrame("Frame",nil,UIParent)
local self = {}
211,15 → 254,14
editbox:EnableMouse(true)
editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed)
editbox:SetScript("OnEnterPressed",EditBox_OnEnterPressed)
editbox:SetScript("OnEnter",EditBox_OnEnter)
editbox:SetScript("OnLeave",EditBox_OnLeave)
editbox:SetBackdrop(ManualBackdrop)
editbox:SetBackdropColor(0,0,0,0.5)
editbox:SetBackdropBorderColor(0.3,0.3,0.30,0.80)
self.editbox = editbox
editbox.obj = self
 
local bg = editbox:CreateTexture(nil,"BACKGROUND")
editbox.bg = bg
bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
bg:SetVertexColor(0,0,0,0.25)
bg:SetAllPoints(editbox)
 
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal")
 
frame:SetWidth(200)
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua
1,12 → 1,22
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
 
-- WoW APIs
local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown
local CreateFrame, UIParent = CreateFrame, UIParent
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: NOT_BOUND
 
--------------------------
-- Keybinding --
--------------------------
 
do
local Type = "Keybinding"
local Version = 11
local Version = 13
 
local ControlBackdrop = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
100,6 → 110,8
end
 
local function OnAcquire(self)
self:SetWidth(200)
self:SetHeight(44)
self:SetLabel("")
self:SetKey("")
end
109,6 → 121,7
self.frame:Hide()
self.waitingForKey = nil
self.msgframe:Hide()
self:SetDisabled(false)
end
 
local function SetDisabled(self, disabled)
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-TabGroup.lua
1,5 → 1,16
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local pairs, ipairs, assert, type = pairs, ipairs, assert, type
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: PanelTemplates_TabResize, PanelTemplates_SetDisabledTabState, PanelTemplates_SelectTab, PanelTemplates_DeselectTab
 
-------------
-- Widgets --
-------------
30,7 → 41,7
 
do
local Type = "TabGroup"
local Version = 17
local Version = 24
 
local PaneBackdrop = {
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
51,11 → 62,16
self.localstatus[k] = nil
end
self.tablist = nil
for _, tab in pairs(self.tabs) do
tab:Hide()
end
self:SetTitle()
end
 
local function Tab_SetText(self, text)
self:_SetText(text)
PanelTemplates_TabResize(self, 0)
local width = self.obj.frame.width or self.obj.frame:GetWidth() or 0
PanelTemplates_TabResize(self, 0, nil, width)
end
 
local function UpdateTabLook(self)
104,6 → 120,11
tab.obj = self
tab.id = id
 
tab.text = _G[tabname .. "Text"]
tab.text:ClearAllPoints()
tab.text:SetPoint("LEFT", tab, "LEFT", 14, -3)
tab.text:SetPoint("RIGHT", tab, "RIGHT", -12, -3)
 
tab:SetScript("OnClick",Tab_OnClick)
tab:SetScript("OnEnter",Tab_OnEnter)
tab:SetScript("OnLeave",Tab_OnLeave)
119,6 → 140,12
 
local function SetTitle(self, text)
self.titletext:SetText(text or "")
if text and text ~= "" then
self.alignoffset = 25
else
self.alignoffset = 18
end
self:BuildTabs()
end
 
-- called to set an external table to store status in
136,7 → 163,7
v:SetSelected(true)
found = true
else
v:SetSelected(false)
v:SetSelected(false)
end
end
status.selected = value
153,18 → 180,14
 
local widths = {}
local rowwidths = {}
local rowends = {}
local rowends = {}
local function BuildTabs(self)
local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
local status = self.status or self.localstatus
local tablist = self.tablist
 
local tabs = self.tabs
 
for i, v in ipairs(tabs) do
v:Hide()
end
if not tablist then return end
 
 
local width = self.frame.width or self.frame:GetWidth() or 0
 
185,7 → 208,7
tab = self:CreateTab(i)
tabs[i] = tab
end
 
 
tab:Show()
tab:SetText(v.text)
tab:SetDisabled(v.disabled)
194,6 → 217,10
widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
end
 
for i = (#tablist)+1, #tabs, 1 do
tabs[i]:Hide()
end
 
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
local numtabs = #tablist
local numrows = 1
218,10 → 245,12
if rowends[numrows-1] == numtabs-1 then
--if there are more than 2 tabs in the 2nd last row
if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then
--move 1 tab from the second last row to the last
rowends[numrows-1] = rowends[numrows-1] - 1
rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1]
rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1]
--move 1 tab from the second last row to the last, if there is enough space
if (rowwidths[numrows] + widths[numtabs-1]) <= width then
rowends[numrows-1] = rowends[numrows-1] - 1
rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1]
rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1]
end
end
end
end
234,7 → 263,7
local tab = tabs[tabno]
tab:ClearAllPoints()
if first then
tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -7-(row-1)*20 )
tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -(hastitle and 14 or 7)-(row-1)*20 )
first = false
else
tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0)
249,13 → 278,13
end
 
for i = starttab, endtab do
PanelTemplates_TabResize(tabs[i], padding + 4)
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width)
end
starttab = endtab + 1
end
 
self.borderoffset = 10+((numrows)*20)
self.border:SetPoint("TOPLEFT",self.frame,"TOPLEFT",3,-self.borderoffset)
self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)
self.border:SetPoint("TOPLEFT",self.frame,"TOPLEFT",1,-self.borderoffset)
end
 
local function BuildTabsOnUpdate(this)
285,6 → 314,11
content:SetHeight(contentheight)
content.height = contentheight
end
 
local function LayoutFinished(self, width, height)
if self.noAutoHeight then return end
self:SetHeight((height or 0) + (self.borderoffset + 23))
end
 
local function Constructor()
local frame = CreateFrame("Frame",nil,UIParent)
303,6 → 337,7
self.BuildTabs = BuildTabs
self.SetStatusTable = SetStatusTable
self.SetTabs = SetTabs
self.LayoutFinished = LayoutFinished
self.frame = frame
 
self.OnWidthSet = OnWidthSet
314,19 → 349,22
frame:SetWidth(100)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
 
self.alignoffset = 18
 
local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0)
titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
titletext:SetJustifyH("LEFT")
titletext:SetHeight(18)
titletext:SetText("")
 
self.titletext = titletext
self.titletext = titletext
 
local border = CreateFrame("Frame",nil,frame)
self.border = border
self.borderoffset = 27
border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-27)
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3)
border:SetPoint("TOPLEFT",frame,"TOPLEFT",1,-27)
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-1,3)
 
border:SetBackdrop(PaneBackdrop)
border:SetBackdropColor(0.1,0.1,0.1,0.5)
338,8 → 376,8
local content = CreateFrame("Frame",nil,border)
self.content = content
content.obj = self
content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10)
content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10)
content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-7)
content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,7)
 
AceGUI:RegisterAsContainer(self)
return self
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua
1,5 → 1,15
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local select = select
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: SetDesaturation, GameFontHighlight
 
--------------------------
-- Check Box --
--------------------------
10,11 → 20,14
]]
do
local Type = "CheckBox"
local Version = 4
local Version = 13
 
local function OnAcquire(self)
self:SetValue(false)
self.tristate = nil
self:SetHeight(24)
self:SetWidth(200)
self:SetImage()
end
 
local function OnRelease(self)
26,21 → 39,18
self.checked = nil
self:SetType()
self:SetDisabled(false)
self:SetDescription(nil)
end
 
local function CheckBox_OnEnter(this)
local self = this.obj
if not self.disabled then
self.highlight:Show()
end
self.highlight:Show()
self:Fire("OnEnter")
end
 
local function CheckBox_OnLeave(this)
local self = this.obj
if not self.down then
self.highlight:Hide()
end
self.highlight:Hide()
self:Fire("OnLeave")
end
 
66,9 → 76,11
local function SetDisabled(self,disabled)
self.disabled = disabled
if disabled then
self.frame:Disable()
self.text:SetTextColor(0.5,0.5,0.5)
SetDesaturation(self.check, true)
else
self.frame:Enable()
self.text:SetTextColor(1,1,1)
if self.tristate and self.checked == nil then
SetDesaturation(self.check, true)
83,20 → 95,14
self.checked = value
if value then
SetDesaturation(self.check, false)
check:SetWidth(24)
check:SetHeight(24)
self.check:Show()
else
--Nil is the unknown tristate value
if self.tristate and value == nil then
SetDesaturation(self.check, true)
check:SetWidth(20)
check:SetHeight(20)
self.check:Show()
else
SetDesaturation(self.check, false)
check:SetWidth(24)
check:SetHeight(24)
self.check:Hide()
end
end
117,16 → 123,24
local highlight = self.highlight
 
if type == "radio" then
checkbg:SetHeight(16)
checkbg:SetWidth(16)
checkbg:SetTexture("Interface\\Buttons\\UI-RadioButton")
checkbg:SetTexCoord(0,0.25,0,1)
check:SetHeight(16)
check:SetWidth(16)
check:SetTexture("Interface\\Buttons\\UI-RadioButton")
check:SetTexCoord(0.5,0.75,0,1)
check:SetTexCoord(0.25,0.5,0,1)
check:SetBlendMode("ADD")
highlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
highlight:SetTexCoord(0.5,0.75,0,1)
else
checkbg:SetHeight(24)
checkbg:SetWidth(24)
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
checkbg:SetTexCoord(0,1,0,1)
check:SetHeight(24)
check:SetWidth(24)
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
check:SetTexCoord(0,1,0,1)
check:SetBlendMode("BLEND")
155,6 → 169,65
self.text:SetText(label)
end
 
local function SetDescription(self, desc)
if desc then
if not self.desc then
local desc = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
desc:ClearAllPoints()
desc:SetPoint("TOPLEFT", self.check, "TOPRIGHT", 5, -21)
desc:SetWidth(self.frame.width - 30)
desc:SetJustifyH("LEFT")
desc:SetJustifyV("TOP")
self.desc = desc
end
self.desc:Show()
--self.text:SetFontObject(GameFontNormal)
self.desc:SetText(desc)
self:SetHeight(28 + self.desc:GetHeight())
else
if self.desc then
self.desc:SetText("")
self.desc:Hide()
end
self.text:SetFontObject(GameFontHighlight)
self:SetHeight(24)
end
end
 
local function SetImage(self, path, ...)
local image = self.image
image:SetTexture(path)
 
if image:GetTexture() then
local n = select('#', ...)
if n == 4 or n == 8 then
image:SetTexCoord(...)
else
image:SetTexCoord(0, 1, 0, 1)
end
end
self:AlignImage()
end
 
local function AlignImage(self)
local img = self.image:GetTexture()
self.text:ClearAllPoints()
if not img then
self.text:SetPoint("LEFT", self.check, "RIGHT", 0, 0)
self.text:SetPoint("RIGHT", self.frame, "RIGHT", 0, 0)
else
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
self.text:SetPoint("RIGHT", self.frame,"RIGHT", 0, 0)
end
end
 
local function OnWidthSet(self, width)
if self.desc and self.desc:GetText() ~= "" then
self.desc:SetWidth(width - 30)
self:SetHeight(28 + self.desc:GetHeight())
end
end
 
local function Constructor()
local frame = CreateFrame("Button",nil,UIParent)
local self = {}
170,6 → 243,10
self.ToggleChecked = ToggleChecked
self.SetLabel = SetLabel
self.SetTriState = SetTriState
self.SetDescription = SetDescription
self.OnWidthSet = OnWidthSet
self.SetImage = SetImage
self.AlignImage = AlignImage
 
self.frame = frame
frame.obj = self
186,7 → 263,7
self.checkbg = checkbg
checkbg:SetWidth(24)
checkbg:SetHeight(24)
checkbg:SetPoint("LEFT",frame,"LEFT",0,0)
checkbg:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
local check = frame:CreateTexture(nil,"OVERLAY")
self.check = check
195,20 → 272,26
check:SetPoint("CENTER",checkbg,"CENTER",0,0)
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
 
local highlight = frame:CreateTexture(nil, "BACKGROUND")
local highlight = frame:CreateTexture(nil, "OVERLAY")
self.highlight = highlight
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
highlight:SetBlendMode("ADD")
highlight:SetAllPoints(checkbg)
highlight:Hide()
 
local image = frame:CreateTexture(nil, "OVERLAY")
self.image = image
image:SetHeight(16)
image:SetWidth(16)
image:SetPoint("LEFT", check, "RIGHT", 1, 0)
 
text:SetJustifyH("LEFT")
frame:SetHeight(24)
frame:SetWidth(200)
text:SetHeight(18)
text:SetPoint("LEFT",check,"RIGHT",0,0)
text:SetPoint("RIGHT",frame,"RIGHT",0,0)
 
 
AceGUI:RegisterAsWidget(self)
return self
end
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua
1,24 → 1,41
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local select = select
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
--------------------------
-- Label --
--------------------------
do
local Type = "Icon"
local Version = 4
local Version = 11
 
local function OnAcquire(self)
self:SetText("")
self:SetHeight(110)
self:SetWidth(110)
self:SetLabel("")
self:SetImage(nil)
self:SetImageSize(64, 64)
end
 
local function OnRelease(self)
self.frame:ClearAllPoints()
self.frame:Hide()
self:SetDisabled(false)
end
 
local function SetText(self, text)
self.label:SetText(text or "")
local function SetLabel(self, text)
if text and text ~= "" then
self.label:Show()
self.label:SetText(text)
self.frame:SetHeight(self.image:GetHeight() + 25)
else
self.label:Hide()
self.frame:SetHeight(self.image:GetHeight() + 10)
end
end
 
local function SetImage(self, path, ...)
30,23 → 47,51
local n = select('#', ...)
if n == 4 or n == 8 then
image:SetTexCoord(...)
else
image:SetTexCoord(0, 1, 0, 1)
end
else
self.imageshown = nil
end
end
 
local function OnClick(this)
this.obj:Fire("OnClick")
local function SetImageSize(self, width, height)
self.image:SetWidth(width)
self.image:SetHeight(height)
--self.frame:SetWidth(width + 30)
if self.label:IsShown() then
self.frame:SetHeight(height + 25)
else
self.frame:SetHeight(height + 10)
end
end
 
local function SetDisabled(self, disabled)
self.disabled = disabled
if disabled then
self.frame:Disable()
self.label:SetTextColor(0.5,0.5,0.5)
self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
else
self.frame:Enable()
self.label:SetTextColor(1,1,1)
self.image:SetVertexColor(1, 1, 1)
end
end
 
local function OnClick(this, button)
this.obj:Fire("OnClick", button)
AceGUI:ClearFocus()
end
 
local function OnEnter(this)
this.obj.highlight:Show()
this.obj:Fire("OnEnter")
end
 
local function OnLeave(this)
this.obj.highlight:Hide()
this.obj:Fire("OnLeave")
end
 
local function Constructor()
56,9 → 101,14
 
self.OnRelease = OnRelease
self.OnAcquire = OnAcquire
self.SetText = SetText
self.SetLabel = SetLabel
self.frame = frame
self.SetImage = SetImage
self.SetImageSize = SetImageSize
 
-- SetText should be deprecated along the way
self.SetText = SetLabel
self.SetDisabled = SetDisabled
 
frame.obj = self
 
69,8 → 119,8
frame:SetScript("OnLeave", OnLeave)
frame:SetScript("OnEnter", OnEnter)
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlight")
label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,10)
label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,10)
label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
label:SetJustifyH("CENTER")
label:SetJustifyV("TOP")
label:SetHeight(18)
80,7 → 130,7
self.image = image
image:SetWidth(64)
image:SetHeight(64)
image:SetPoint("TOP",frame,"TOP",0,-10)
image:SetPoint("TOP",frame,"TOP",0,-5)
 
local highlight = frame:CreateTexture(nil,"OVERLAY")
self.highlight = highlight
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-BlizOptionsGroup.lua
32,9 → 32,12
Group Designed to be added to the bliz interface options panel
]]
 
-- WoW APIs
local CreateFrame = CreateFrame
 
do
local Type = "BlizOptionsGroup"
local Version = 6
local Version = 10
 
local function OnAcquire(self)
 
96,10 → 99,10
local content = self.content
content:ClearAllPoints()
if not title or title == "" then
content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",15,-10)
content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",10,-10)
self.label:SetText("")
else
content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",15,-40)
content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",10,-40)
self.label:SetText(title)
end
content:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-10,10)
130,7 → 133,7
 
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalLarge")
self.label = label
label:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -15)
label:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -15)
label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
label:SetJustifyH("LEFT")
label:SetJustifyV("TOP")
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-Frame.lua
1,5 → 1,15
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local pairs, assert, type = pairs, assert, type
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: CLOSE
 
----------------
-- Main Frame --
----------------
10,7 → 20,7
]]
do
local Type = "Frame"
local Version = 7
local Version = 8
 
local FrameBackdrop = {
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background",
183,7 → 193,7
closebutton:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-27,17)
closebutton:SetHeight(20)
closebutton:SetWidth(100)
closebutton:SetText("Close")
closebutton:SetText(CLOSE)
 
self.closebutton = closebutton
closebutton.obj = self
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-InlineGroup.lua
1,5 → 1,7
local AceGUI = LibStub("AceGUI-3.0")
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
-------------
-- Widgets --
35,7 → 37,7
 
do
local Type = "InlineGroup"
local Version = 4
local Version = 6
 
local function OnAcquire(self)
self:SetWidth(300)
60,6 → 62,7
 
 
local function LayoutFinished(self, width, height)
if self.noAutoHeight then return end
self:SetHeight((height or 0) + 40)
end
 
113,8 → 116,8
 
local border = CreateFrame("Frame",nil,frame)
self.border = border
border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-17)
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3)
border:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-17)
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-1,3)
 
border:SetBackdrop(PaneBackdrop)
border:SetBackdropColor(0.1,0.1,0.1,0.5)
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua
1,8 → 1,19
--[[ $Id: AceGUIWidget-DropDown.lua 679 2008-09-06 12:51:18Z nargiddley $ ]]--
--[[ $Id: AceGUIWidget-DropDown.lua 877 2009-11-02 15:56:50Z nevcairiel $ ]]--
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local select, pairs, ipairs = select, pairs, ipairs
local tsort = table.sort
 
local AceGUI = LibStub("AceGUI-3.0")
-- WoW APIs
local UIParent, CreateFrame = UIParent, CreateFrame
local _G = _G
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: CLOSE
 
local function fixlevels(parent,...)
local i = 1
local child = select(i, ...)
27,12 → 38,12
 
do
local widgetType = "Dropdown-Pullout"
local widgetVersion = 2
local widgetVersion = 3
 
--[[ Static data ]]--
 
local backdrop = {
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
edgeSize = 32,
tileSize = 32,
342,9 → 353,9
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion)
end
 
do
do
local widgetType = "Dropdown"
local widgetVersion = 18
local widgetVersion = 21
 
--[[ Static data ]]--
 
444,6 → 455,9
pullout:SetCallback("OnOpen", OnPulloutOpen)
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
fixlevels(self.pullout.frame, self.pullout.frame:GetChildren())
 
self:SetHeight(44)
self:SetWidth(200)
end
 
-- exported, AceGUI callback
452,6 → 466,7
self.pullout:Close()
end
AceGUI:Release(self.pullout)
self.pullout = nil
 
self:SetText("")
self:SetLabel("")
459,12 → 474,12
self:SetMultiselect(false)
 
self.value = nil
self.list = nil
self.list = nil
self.open = nil
self.hasClose = nil
 
self.frame:ClearAllPoints()
self.frame:Hide()
self.frame:Hide()
end
 
-- exported
517,6 → 532,11
end
 
-- exported
local function GetValue(self)
return self.value
end
 
-- exported
local function SetItemValue(self, item, value)
if not self.multiselect then return end
for i, widget in self.pullout:IterateItems() do
552,7 → 572,7
local close = AceGUI:Create("Dropdown-Item-Execute")
close:SetText(CLOSE)
self.pullout:AddItem(close)
self.hasClose = true
self.hasClose = true
end
end
 
567,7 → 587,7
for v in pairs(list) do
sortlist[#sortlist + 1] = v
end
table.sort(sortlist)
tsort(sortlist)
 
for i, value in pairs(sortlist) do
AddListItem(self, value, list[value])
623,6 → 643,7
 
self.SetText = SetText
self.SetValue = SetValue
self.GetValue = GetValue
self.SetList = SetList
self.SetLabel = SetLabel
self.SetDisabled = SetDisabled
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua
1,5 → 1,36
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local tostring = tostring
 
-- WoW APIs
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY
 
local Type = "EditBox"
local Version = 13
 
if not AceGUIEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
end
 
function _G.AceGUIEditBoxInsertLink(text)
for i = 1, AceGUI:GetNextWidgetNum(Type)-1 do
local editbox = _G["AceGUI-3.0EditBox"..i]
if editbox and editbox:IsVisible() and editbox:HasFocus() then
editbox:Insert(text)
return true
end
end
end
 
 
--------------------------
-- Edit box --
--------------------------
10,11 → 41,11
 
]]
do
local Type = "EditBox"
local Version = 9
 
local function OnAcquire(self)
self:SetHeight(26)
self:SetWidth(200)
self:SetDisabled(false)
self:SetLabel()
self.showbutton = true
end
 
22,6 → 53,7
self.frame:ClearAllPoints()
self.frame:Hide()
self:SetDisabled(false)
self:SetText()
end
 
local function Control_OnEnter(this)
86,7 → 118,7
local function EditBox_OnTextChanged(this)
local self = this.obj
local value = this:GetText()
if value ~= self.lasttext then
if tostring(value) ~= tostring(self.lasttext) then
self:Fire("OnTextChanged",value)
self.lasttext = value
ShowButton(self)
114,22 → 146,18
HideButton(self)
end
 
local function SetWidth(self, width)
self.frame:SetWidth(width)
end
 
local function SetLabel(self, text)
if text and text ~= "" then
self.label:SetText(text)
self.label:Show()
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18)
self.frame:SetHeight(44)
self:SetHeight(44)
self.alignoffset = 30
else
self.label:SetText("")
self.label:Hide()
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0)
self.frame:SetHeight(26)
self:SetHeight(26)
self.alignoffset = 12
end
end
149,7 → 177,6
 
self.SetDisabled = SetDisabled
self.SetText = SetText
self.SetWidth = SetWidth
self.SetLabel = SetLabel
 
self.frame = frame
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua
1,14 → 1,19
local AceGUI = LibStub("AceGUI-3.0")
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
--------------------------
-- Heading --
--------------------------
do
local Type = "Heading"
local Version = 3
local Version = 5
 
local function OnAcquire(self)
self:SetText("")
self:SetFullWidth()
self:SetHeight(18)
end
 
local function OnRelease(self)
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-SimpleGroup.lua
1,5 → 1,7
local AceGUI = LibStub("AceGUI-3.0")
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
-------------
-- Widgets --
35,7 → 37,7
 
do
local Type = "SimpleGroup"
local Version = 4
local Version = 5
 
local function OnAcquire(self)
self:SetWidth(300)
48,6 → 50,7
end
 
local function LayoutFinished(self, width, height)
if self.noAutoHeight then return end
self:SetHeight(height or 0)
end
 
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDownGroup.lua
1,5 → 1,11
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local assert, pairs, type = assert, pairs, type
 
-- WoW APIs
local CreateFrame = CreateFrame
 
--[[
Selection Group controls all have an interface to select a group for thier contents
None of them will auto size to thier contents, and should usually be used with a scrollframe
16,10 → 22,12
]]
do
local Type = "DropdownGroup"
local Version = 9
local Version = 13
 
local function OnAcquire(self)
self.dropdown:SetText("")
self:SetDropdownWidth(200)
self:SetTitle("")
end
 
local function OnRelease(self)
41,6 → 49,12
 
local function SetTitle(self,title)
self.titletext:SetText(title)
self.dropdown.frame:ClearAllPoints()
if title and title ~= "" then
self.dropdown.frame:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -2, 0)
else
self.dropdown.frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", -1, 0)
end
end
 
 
89,6 → 103,14
content.height = contentheight
end
 
local function LayoutFinished(self, width, height)
self:SetHeight((height or 0) + 63)
end
 
local function SetDropdownWidth(self, width)
self.dropdown:SetWidth(width)
end
 
local function Constructor()
local frame = CreateFrame("Frame")
local self = {}
101,42 → 123,41
self.SetGroupList = SetGroupList
self.SetGroup = SetGroup
self.SetStatusTable = SetStatusTable
self.SetDropdownWidth = SetDropdownWidth
self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet
self.LayoutFinished = LayoutFinished
 
self.localstatus = {}
 
self.frame = frame
frame.obj = self
 
 
frame:SetHeight(100)
frame:SetWidth(100)
frame:SetFrameStrata("FULLSCREEN_DIALOG")
 
local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0)
titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
titletext:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -5)
titletext:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -4, -5)
titletext:SetJustifyH("LEFT")
titletext:SetHeight(18)
self.titletext = titletext
 
 
self.titletext = titletext
 
local dropdown = AceGUI:Create("Dropdown")
self.dropdown = dropdown
dropdown.frame:SetParent(frame)
dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2)
dropdown.parentgroup = self
dropdown:SetCallback("OnValueChanged",SelectedGroup)
 
dropdown.frame:SetPoint("TOPLEFT",titletext,"BOTTOMLEFT",-7,3)
dropdown.frame:SetPoint("TOPLEFT",frame,"TOPLEFT", -1, 0)
dropdown.frame:Show()
dropdown:SetLabel("")
 
local border = CreateFrame("Frame",nil,frame)
self.border = border
border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-40)
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3)
border:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-26)
border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,3)
 
border:SetBackdrop(PaneBackdrop)
border:SetBackdropColor(0.1,0.1,0.1,0.5)
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-ScrollFrame.lua
1,5 → 1,13
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local pairs, assert, type = pairs, assert, type
local min, max, floor = math.min, math.max, math.floor
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
 
-------------
-- Widgets --
-------------
29,7 → 37,7
--------------------------
do
local Type = "ScrollFrame"
local Version = 3
local Version = 9
 
local function OnAcquire(self)
 
39,35 → 47,40
self.frame:ClearAllPoints()
self.frame:Hide()
self.status = nil
-- do SetScroll after niling status, but before clearing localstatus
-- so the scroll value isnt populated back into status, but not kept in localstatus either
self:SetScroll(0)
for k in pairs(self.localstatus) do
self.localstatus[k] = nil
end
self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
self.scrollbar:Hide()
self.scrollBarShown = nil
self.content.height, self.content.width = nil, nil
end
 
local function SetScroll(self, value)
 
local status = self.status or self.localstatus
local viewheight = self.scrollframe:GetHeight()
local height = self.content:GetHeight()
local offset
 
local frame, child = self.scrollframe, self.content
local viewheight = frame:GetHeight()
local height = child:GetHeight()
local offset
if viewheight > height then
offset = 0
else
offset = floor((height - viewheight) / 1000.0 * value)
end
child:ClearAllPoints()
child:SetPoint("TOPLEFT",frame,"TOPLEFT",0,offset)
child:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,offset)
self.content:ClearAllPoints()
self.content:SetPoint("TOPLEFT", self.scrollframe, "TOPLEFT", 0, offset)
self.content:SetPoint("TOPRIGHT", self.scrollframe, "TOPRIGHT", 0, offset)
status.offset = offset
status.scrollvalue = value
end
 
local function MoveScroll(self, value)
local status = self.status or self.localstatus
local frame, child = self.scrollframe, self.content
local height, viewheight = frame:GetHeight(), child:GetHeight()
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
 
if height > viewheight then
self.scrollbar:Hide()
else
77,41 → 90,48
if value < 0 then
delta = -1
end
self.scrollbar:SetValue(math.min(math.max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
self.scrollbar:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
end
end
 
 
local function FixScroll(self)
if self.updateLock then return end
self.updateLock = true
local status = self.status or self.localstatus
local frame, child = self.scrollframe, self.content
local height, viewheight = frame:GetHeight(), child:GetHeight()
local offset = status.offset
if not offset then
offset = 0
end
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
local offset = status.offset or 0
local curvalue = self.scrollbar:GetValue()
if viewheight < height then
self.scrollbar:Hide()
self.scrollbar:SetValue(0)
--self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
if self.scrollBarShown then
self.scrollBarShown = nil
self.scrollbar:Hide()
self.scrollbar:SetValue(0)
self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0)
self:DoLayout()
end
else
self.scrollbar:Show()
--self.scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-16,0)
if not self.scrollBarShown then
self.scrollBarShown = true
self.scrollbar:Show()
self.scrollframe:SetPoint("BOTTOMRIGHT", self.frame,"BOTTOMRIGHT",-20,0)
self:DoLayout()
end
local value = (offset / (viewheight - height) * 1000)
if value > 1000 then value = 1000 end
self.scrollbar:SetValue(value)
self:SetScroll(value)
if value < 1000 then
child:ClearAllPoints()
child:SetPoint("TOPLEFT",frame,"TOPLEFT",0,offset)
child:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,offset)
self.content:ClearAllPoints()
self.content:SetPoint("TOPLEFT", self.scrollframe, "TOPLEFT", 0, offset)
self.content:SetPoint("TOPRIGHT", self.scrollframe, "TOPRIGHT", 0, offset)
status.offset = offset
end
end
self.updateLock = nil
end
 
local function OnMouseWheel(this,value)
local function OnMouseWheel(this, value)
this.obj:MoveScroll(value)
end
 
123,14 → 143,14
this:SetScript("OnUpdate", nil)
this.obj:FixScroll()
end
 
local function OnSizeChanged(this)
--this:SetScript("OnUpdate", FixScrollOnUpdate)
this.obj:FixScroll()
this:SetScript("OnUpdate", FixScrollOnUpdate)
end
 
local function LayoutFinished(self,width,height)
local function LayoutFinished(self, width, height)
self.content:SetHeight(height or 0 + 20)
self:FixScroll()
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
end
 
-- called to set an external table to store status in
142,9 → 162,6
end
end
 
 
local createdcount = 0
 
local function OnWidthSet(self, width)
local content = self.content
content.width = width
157,7 → 174,7
end
 
local function Constructor()
local frame = CreateFrame("Frame",nil,UIParent)
local frame = CreateFrame("Frame", nil, UIParent)
local self = {}
self.type = Type
 
172,50 → 189,49
self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet
 
self.localstatus = {}
self.localstatus = {}
self.frame = frame
frame.obj = self
 
--Container Support
local scrollframe = CreateFrame("ScrollFrame",nil,frame)
local content = CreateFrame("Frame",nil,scrollframe)
createdcount = createdcount + 1
local scrollbar = CreateFrame("Slider",("AceConfigDialogScrollFrame%dScrollBar"):format(createdcount),scrollframe,"UIPanelScrollBarTemplate")
local scrollbg = scrollbar:CreateTexture(nil,"BACKGROUND")
scrollbg:SetAllPoints(scrollbar)
scrollbg:SetTexture(0,0,0,0.4)
self.scrollframe = scrollframe
self.content = content
self.scrollbar = scrollbar
 
scrollbar.obj = self
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
scrollframe.obj = self
content.obj = self
 
scrollframe:SetScrollChild(content)
scrollframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
scrollframe:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-16,0)
scrollframe:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)
scrollframe:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 0)
scrollframe:EnableMouseWheel(true)
scrollframe:SetScript("OnMouseWheel", OnMouseWheel)
scrollframe:SetScript("OnSizeChanged", OnSizeChanged)
self.scrollframe = scrollframe
 
 
content:SetPoint("TOPLEFT",scrollframe,"TOPLEFT",0,0)
content:SetPoint("TOPRIGHT",scrollframe,"TOPRIGHT",0,0)
local content = CreateFrame("Frame", nil, scrollframe)
content.obj = self
content:SetPoint("TOPLEFT", scrollframe, "TOPLEFT", 0, 0)
content:SetPoint("TOPRIGHT", scrollframe, "TOPRIGHT", 0, 0)
content:SetHeight(400)
self.content = content
scrollframe:SetScrollChild(content)
 
scrollbar:SetPoint("TOPLEFT",scrollframe,"TOPRIGHT",0,-16)
scrollbar:SetPoint("BOTTOMLEFT",scrollframe,"BOTTOMRIGHT",0,16)
local num = AceGUI:GetNextWidgetNum(Type)
local name = ("AceConfigDialogScrollFrame%dScrollBar"):format(num)
local scrollbar = CreateFrame("Slider", name, scrollframe, "UIPanelScrollBarTemplate")
scrollbar.obj = self
scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
scrollbar:SetScript("OnValueChanged", OnScrollValueChanged)
scrollbar:SetMinMaxValues(0,1000)
scrollbar:SetMinMaxValues(0, 1000)
scrollbar:SetValueStep(1)
scrollbar:SetValue(0)
scrollbar:SetWidth(16)
scrollbar:Hide()
self.scrollbar = scrollbar
 
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
scrollbg:SetAllPoints(scrollbar)
scrollbg:SetTexture(0, 0, 0, 0.4)
 
self.localstatus.scrollvalue = 0
 
 
self:FixScroll()
--self:FixScroll()
AceGUI:RegisterAsContainer(self)
--AceGUI:RegisterAsWidget(self)
return self
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua
1,13 → 1,20
local AceGUI = LibStub("AceGUI-3.0")
 
-- WoW APIs
local _G = _G
local CreateFrame, UIParent = CreateFrame, UIParent
 
--------------------------
-- Button --
--------------------------
do
local Type = "Button"
local Version = 7
local Version = 12
 
local function OnAcquire(self)
-- restore default values
self:SetHeight(24)
self:SetWidth(200)
end
 
local function OnRelease(self)
16,8 → 23,8
self:SetDisabled(false)
end
 
local function Button_OnClick(this)
this.obj:Fire("OnClick")
local function Button_OnClick(this, ...)
this.obj:Fire("OnClick", ...)
AceGUI:ClearFocus()
end
 
44,16 → 51,32
 
local function Constructor()
local num = AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Button","AceGUI30Button"..num,UIParent,"UIPanelButtonTemplate2")
local name = "AceGUI30Button"..num
local frame = CreateFrame("Button",name,UIParent,"UIPanelButtonTemplate2")
local self = {}
self.num = num
self.type = Type
self.frame = frame
 
local left = _G[name .. "Left"]
local right = _G[name .. "Right"]
local middle = _G[name .. "Middle"]
 
left:SetPoint("TOP", frame, "TOP", 0, 0)
left:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
 
right:SetPoint("TOP", frame, "TOP", 0, 0)
right:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
 
middle:SetPoint("TOP", frame, "TOP", 0, 0)
middle:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
 
local text = frame:GetFontString()
self.text = text
text:SetPoint("LEFT",frame,"LEFT",15,0)
text:SetPoint("RIGHT",frame,"RIGHT",-15,0)
text:ClearAllPoints()
text:SetPoint("TOPLEFT",frame,"TOPLEFT", 15, -1)
text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT", -15, 1)
text:SetJustifyV("MIDDLE")
 
frame:SetScript("OnClick",Button_OnClick)
frame:SetScript("OnEnter",Button_OnEnter)
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua
1,7 → 1,13
--[[ $Id: AceGUIWidget-DropDown-Items.lua 656 2008-05-31 11:47:08Z nargiddley $ ]]--
--[[ $Id: AceGUIWidget-DropDown-Items.lua 877 2009-11-02 15:56:50Z nevcairiel $ ]]--
 
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local select, assert = select, assert
 
-- WoW APIs
local CreateFrame = CreateFrame
 
local function fixlevels(parent,...)
local i = 1
local child = select(i, ...)
365,7 → 371,7
-- Does not close the pullout on click
do
local widgetType = "Dropdown-Item-Menu"
local widgetVersion = 1
local widgetVersion = 2
 
local function OnEnter(this)
local self = this.obj
390,13 → 396,13
end
 
-- exported
function SetMenu(self, menu)
local function SetMenu(self, menu)
assert(menu.type == "Dropdown-Pullout")
self.submenu = menu
end
 
-- exported
function CloseMenu(self)
local function CloseMenu(self)
self.submenu:Close()
end
 
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-TreeGroup.lua
1,5 → 1,17
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type
local math_min, math_max, floor = math.min, math.max, floor
local select, tremove, unpack = select, table.remove, unpack
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: GameTooltip, FONT_COLOR_CODE_CLOSE
 
-- Recycling functions
local new, del
do
27,7 → 39,7
 
do
local Type = "TreeGroup"
local Version = 17
local Version = 23
 
local DEFAULT_TREE_WIDTH = 175
local DEFAULT_TREE_SIZABLE = true
113,20 → 125,20
status[button.uniquevalue] = not status[button.uniquevalue]
self:RefreshTree()
end
 
local function EnableButtonTooltips(self, enable)
self.enabletooltips = enable
end
 
local function Button_OnEnter(this)
local self = this.obj
self:Fire("OnButtonEnter", this.uniquevalue, this)
 
if self.enabletooltips then
GameTooltip:SetOwner(this, "ANCHOR_NONE")
GameTooltip:SetPoint("LEFT",this,"RIGHT")
GameTooltip:SetText(this.text:GetText(), 1, .82, 0, 1)
 
 
local function EnableButtonTooltips(self, enable)
self.enabletooltips = enable
end
 
local function Button_OnEnter(this)
local self = this.obj
self:Fire("OnButtonEnter", this.uniquevalue, this)
 
if self.enabletooltips then
GameTooltip:SetOwner(this, "ANCHOR_NONE")
GameTooltip:SetPoint("LEFT",this,"RIGHT")
GameTooltip:SetText(this.text:GetText() or "", 1, .82, 0, 1)
 
GameTooltip:Show()
end
end
146,7 → 158,12
local button = CreateFrame("Button",("AceGUI30TreeButton%d"):format(buttoncount),self.treeframe, "OptionsListButtonTemplate")
buttoncount = buttoncount + 1
button.obj = self
 
 
local icon = button:CreateTexture(nil, "OVERLAY")
icon:SetWidth(14)
icon:SetHeight(14)
button.icon = icon
 
button:SetScript("OnClick",ButtonOnClick)
button:SetScript("OnDoubleClick", ButtonOnDoubleClick)
button:SetScript("OnEnter",Button_OnEnter)
163,6 → 180,8
local toggle = button.toggle
local frame = self.frame
local text = treeline.text or ""
local icon = treeline.icon
local iconCoords = treeline.iconCoords
local level = treeline.level
local value = treeline.value
local uniquevalue = treeline.uniquevalue
178,18 → 197,17
button:UnlockHighlight()
button.selected = false
end
local normalText = button.text
local normalTexture = button:GetNormalTexture()
local line = button.line
button.level = level
if ( level == 1 ) then
button:SetNormalFontObject("GameFontNormal")
button:SetHighlightFontObject("GameFontHighlight")
button.text:SetPoint("LEFT", 8, 2)
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2)
else
button:SetNormalFontObject("GameFontHighlightSmall")
button:SetHighlightFontObject("GameFontHighlightSmall")
button.text:SetPoint("LEFT", 8 * level, 2)
button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2)
end
 
if disabled then
200,6 → 218,19
button:EnableMouse(true)
end
 
if icon then
button.icon:SetTexture(icon)
button.icon:SetPoint("LEFT", button, "LEFT", 8 * level, (level == 1) and 0 or 1)
else
button.icon:SetTexture(nil)
end
 
if iconCoords then
button.icon:SetTexCoord(unpack(iconCoords))
else
button.icon:SetTexCoord(0, 1, 0, 1)
end
 
if canExpand then
if not isExpanded then
toggle:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP")
312,6 → 343,8
local line = new()
line.value = v.value
line.text = v.text
line.icon = v.icon
line.iconCoords = v.iconCoords
line.disabled = v.disabled
line.tree = tree
line.level = level
383,7 → 416,7
 
local numlines = #lines
 
local maxlines = (math.floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18))
 
local first, last
 
473,7 → 506,7
 
--Selects a tree node by UniqueValue
local function SelectByValue(self, uniquevalue)
self:Select(uniquevalue,string.split("\001", uniquevalue))
self:Select(uniquevalue, ("\001"):split(uniquevalue))
end
 
 
496,6 → 529,7
local content = self.content
local treeframe = self.treeframe
local status = self.status or self.localstatus
status.fullwidth = width
 
local contentwidth = width - status.treewidth - 20
if contentwidth < 0 then
504,7 → 538,7
content:SetWidth(contentwidth)
content.width = contentwidth
 
local maxtreewidth = math.min(400, width - 50)
local maxtreewidth = math_min(400, width - 50)
 
if maxtreewidth > 100 and status.treewidth > maxtreewidth then
self:SetTreeWidth(maxtreewidth, status.treesizable)
530,7 → 564,7
local scrollbar = self.scrollbar
local min, max = scrollbar:GetMinMaxValues()
local value = scrollbar:GetValue()
local newvalue = math.min(max,math.max(min,value - delta))
local newvalue = math_min(max,math_max(min,value - delta))
if value ~= newvalue then
scrollbar:SetValue(newvalue)
end
555,6 → 589,11
local status = self.status or self.localstatus
status.treewidth = treewidth
status.treesizable = resizable
 
-- recalculate the content width
if status.fullwidth then
self:OnWidthSet(status.fullwidth)
end
end
 
local function draggerLeave(this)
581,11 → 620,21
treeframe:SetHeight(0)
treeframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
 
local status = self.status or self.localstatus
status.treewidth = treeframe:GetWidth()
 
treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth())
-- recalculate the content width
treeframe.obj:OnWidthSet(status.fullwidth)
-- update the layout of the content
treeframe.obj:DoLayout()
end
 
local function LayoutFinished(self, width, height)
if self.noAutoHeight then return end
self:SetHeight((height or 0) + 20)
end
 
local createdcount = 0
local function Constructor()
646,9 → 695,10
self.SelectByValue = SelectByValue
self.SelectByPath = SelectByPath
self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet
self.OnHeightSet = OnHeightSet
self.EnableButtonTooltips = EnableButtonTooltips
self.Filter = Filter
--self.Filter = Filter
self.LayoutFinished = LayoutFinished
 
self.frame = frame
frame.obj = self
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua
1,15 → 1,24
local AceGUI = LibStub("AceGUI-3.0")
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: ShowUIPanel, HideUIPanel, ColorPickerFrame, OpacitySliderFrame
 
--------------------------
-- ColorPicker --
--------------------------
do
local Type = "ColorPicker"
local Version = 9
local Version = 11
 
local function OnAcquire(self)
self.HasAlpha = false
self:SetColor(0,0,0,1)
self:SetHeight(24)
self:SetWidth(200)
end
 
local function SetLabel(self, text)
94,8 → 103,10
local function SetDisabled(self, disabled)
self.disabled = disabled
if self.disabled then
self.frame:Disable()
self.text:SetTextColor(0.5,0.5,0.5)
else
self.frame:Enable()
self.text:SetTextColor(1,1,1)
end
end
trunk/Plink!/Libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua
1,16 → 1,29
local AceGUI = LibStub("AceGUI-3.0")
 
-- Lua APIs
local max, select = math.max, select
 
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: GameFontHighlightSmall
 
--------------------------
-- Label --
--------------------------
do
local Type = "Label"
local Version = 8
local Version = 11
 
local function OnAcquire(self)
self:SetHeight(18)
self:SetWidth(200)
self:SetText("")
self:SetImage(nil)
self:SetColor()
self:SetFontObject()
end
 
local function OnRelease(self)
40,9 → 53,9
else
--image on the left
image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0)
label:SetPoint("TOPLEFT",image,"TOPRIGHT",0,0)
label:SetPoint("TOPLEFT",image,"TOPRIGHT",4,0)
label:SetWidth(width - imagewidth)
height = math.max(image:GetHeight(), label:GetHeight())
height = max(image:GetHeight(), label:GetHeight())
end
else
--no image shown
90,6 → 103,14
UpdateImageAnchor(self)
end
 
local function SetFont(self, font, height, flags)
self.label:SetFont(font, height, flags)
end
 
local function SetFontObject(self, font)
self.label:SetFontObject(font or GameFontHighlightSmall)
end
 
local function SetImageSize(self, width, height)
self.image:SetWidth(width)
self.image:SetHeight(height)
109,6 → 130,8
self.OnWidthSet = OnWidthSet
self.SetImage = SetImage
self.SetImageSize = SetImageSize
self.SetFont = SetFont
self.SetFontObject = SetFontObject
frame.obj = self
 
frame:SetHeight(18)
trunk/Plink!/Libs/AceGUI-3.0/AceGUI-3.0.xml
9,6 → 9,7
<Script file="widgets\AceGUIWidget-DropDown-Items.lua"/>
<Script file="widgets\AceGUIWidget-EditBox.lua"/>
<Script file="widgets\AceGUIWidget-Frame.lua"/>
<Script file="widgets\AceGUIWidget-Window.lua"/>
<Script file="widgets\AceGUIWidget-Heading.lua"/>
<Script file="widgets\AceGUIWidget-InlineGroup.lua"/>
<Script file="widgets\AceGUIWidget-Keybinding.lua"/>
20,5 → 21,6
<Script file="widgets\AceGUIWidget-Label.lua"/>
<Script file="widgets\AceGUIWidget-MultiLineEditBox.lua"/>
<Script file="widgets\AceGUIWidget-BlizOptionsGroup.lua"/>
<Script file="widgets\AceGUIWidget-InteractiveLabel.lua"/>
<Script file="widgets\AceGUIWidget-Icon.lua"/>
</Ui>
\ No newline at end of file
trunk/Plink!/Libs/AceGUI-3.0/AceGUI-3.0.lua
1,12 → 1,49
--- AceGUI-3.0 provides access to numerous widgets which can be used to create GUIs.
--- **AceGUI-3.0** provides access to numerous widgets which can be used to create GUIs.
-- AceGUI is used by AceConfigDialog to create the option GUIs, but you can use it by itself
-- to create any custom GUI. There are more extensive examples in the test suite in the Ace3
-- stand-alone distribution.
--
-- **Note**: When using AceGUI-3.0 directly, please do not modify the frames of the widgets directly,
-- as any "unknown" change to the widgets will cause addons that get your widget out of the widget pool
-- to misbehave. If you think some part of a widget should be modifiable, please open a ticket, and we'll
-- implement a proper API to modify it.
-- @usage
-- local AceGUI = LibStub("AceGUI-3.0")
-- -- Create a container frame
-- local f = AceGUI:Create("Frame")
-- f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
-- f:SetTitle("AceGUI-3.0 Example")
-- f:SetStatusText("Status Bar")
-- f:SetLayout("Flow")
-- -- Create a button
-- local btn = AceGUI:Create("Button")
-- btn:SetWidth(170)
-- btn:SetText("Button !")
-- btn:SetCallback("OnClick", function() print("Click!") end)
-- -- Add the button to the container
-- f:AddChild(btn)
-- @class file
-- @name AceGUI-3.0
-- @release $Id: AceGUI-3.0.lua 740 2009-02-15 13:56:40Z nevcairiel $
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 18
-- @release $Id: AceGUI-3.0.lua 896 2009-12-06 16:29:49Z nevcairiel $
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 30
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)
 
if not AceGUI then return end -- No upgrade needed
 
-- Lua APIs
local tconcat, tremove, tinsert = table.concat, table.remove, table.insert
local select, pairs, next, type = select, pairs, next, type
local error, assert, loadstring = error, assert, loadstring
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
local math_max = math.max
 
-- WoW APIs
local UIParent = UIParent
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: geterrorhandler, LibStub
 
--local con = LibStub("AceConsole-3.0",true)
 
AceGUI.WidgetRegistry = AceGUI.WidgetRegistry or {}
20,17 → 57,6
local LayoutRegistry = AceGUI.LayoutRegistry
local WidgetVersions = AceGUI.WidgetVersions
 
local pcall = pcall
local select = select
local pairs = pairs
local ipairs = ipairs
local type = type
local assert = assert
local tinsert = tinsert
local tremove = tremove
local CreateFrame = CreateFrame
local UIParent = UIParent
 
--[[
xpcall safecall implementation
]]
58,7 → 84,7
 
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("ARGS", table.concat(ARGS, ", "))
code = code:gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
 
76,39 → 102,58
end
 
-- Recycling functions
local new, del
local newWidget, delWidget
do
-- Version Upgrade in Minor 29
-- Internal Storage of the objects changed, from an array table
-- to a hash table, and additionally we introduced versioning on
-- the widgets which would discard all widgets from a pre-29 version
-- anyway, so we just clear the storage now, and don't try to
-- convert the storage tables to the new format.
-- This should generally not cause *many* widgets to end up in trash,
-- since once dialogs are opened, all addons should be loaded already
-- and AceGUI should be on the latest version available on the users
-- setup.
-- -- nevcairiel - Nov 2nd, 2009
if oldminor and oldminor < 29 and AceGUI.objPools then
AceGUI.objPools = nil
end
 
AceGUI.objPools = AceGUI.objPools or {}
local objPools = AceGUI.objPools
--Returns a new instance, if none are available either returns a new table or calls the given contructor
function new(type,constructor,...)
if not type then
type = "table"
function newWidget(type)
if not WidgetRegistry[type] then
error("Attempt to instantiate unknown widget type", 2)
end
 
if not objPools[type] then
objPools[type] = {}
end
local newObj = tremove(objPools[type])
 
local newObj = next(objPools[type])
if not newObj then
newObj = constructor and constructor(...) or {}
newObj = WidgetRegistry[type]()
newObj.AceGUIWidgetVersion = WidgetVersions[type]
else
objPools[type][newObj] = nil
-- if the widget is older then the latest, don't even try to reuse it
-- just forget about it, and grab a new one.
if not newObj.AceGUIWidgetVersion or newObj.AceGUIWidgetVersion < WidgetVersions[type] then
return newWidget(type)
end
end
return newObj
end
-- Releases an instance to the Pool
function del(obj,type)
if not type then
type = "table"
end
function delWidget(obj,type)
if not objPools[type] then
objPools[type] = {}
end
for i,v in ipairs(objPools[type]) do
if v == obj then
error("Attempt to Release Widget that is already released")
return
end
if objPools[type][obj] then
error("Attempt to Release Widget that is already released", 2)
end
tinsert(objPools[type],obj)
objPools[type][obj] = true
end
end
 
119,10 → 164,14
 
-- Gets a widget Object
 
--- Create a new Widget of the given type.
-- This function will instantiate a new widget (or use one from the widget pool), and call the
-- OnAcquire function on it, before returning.
-- @param type The type of the widget.
-- @return The newly created widget.
function AceGUI:Create(type)
local reg = WidgetRegistry
if reg[type] then
local widget = new(type,reg[type])
if WidgetRegistry[type] then
local widget = newWidget(type)
 
if rawget(widget,'Acquire') then
widget.OnAcquire = widget.Acquire
141,13 → 190,19
widget:OnAcquire()
else
error(("Widget type %s doesn't supply an OnAcquire Function"):format(type))
end
end
-- Set the default Layout ('List')
safecall(widget.SetLayout, widget, 'List')
safecall(widget.ResumeLayout, widget)
return widget
end
end
 
-- Releases a widget Object
--- Releases a widget Object.
-- This function calls OnRelease on the widget and places it back in the widget pool.
-- Any data on the widget is being erased, and the widget will be hidden.\\
-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well.
-- @param widget The widget to release
function AceGUI:Release(widget)
safecall( widget.PauseLayout, widget )
widget:Fire("OnRelease")
164,26 → 219,31
for k in pairs(widget.events) do
widget.events[k] = nil
end
widget.width = nil
--widget.frame:SetParent(nil)
widget.width = nil
widget.relWidth = nil
widget.height = nil
widget.relHeight = nil
widget.noAutoHeight = nil
widget.frame:ClearAllPoints()
widget.frame:Hide()
widget.frame:SetParent(nil)
widget.frame:SetParent(UIParent)
widget.frame.width = nil
widget.frame.height = nil
if widget.content then
widget.content.width = nil
widget.content.height = nil
end
del(widget,widget.type)
delWidget(widget, widget.type)
end
 
-----------
-- Focus --
-----------
 
-----
-- Called when a widget has taken focus
 
--- Called when a widget has taken focus.
-- e.g. Dropdowns opening, Editboxes gaining kb focus
-----
-- @param widget The widget that should be focused
function AceGUI:SetFocus(widget)
if self.FocusedWidget and self.FocusedWidget ~= widget then
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
191,10 → 251,9
self.FocusedWidget = widget
end
 
-----
-- Called when something has happened that could cause widgets with focus to drop it
 
--- Called when something has happened that could cause widgets with focus to drop it
-- e.g. titlebar of a frame being clicked
-----
function AceGUI:ClearFocus()
if self.FocusedWidget then
safecall(self.FocusedWidget.ClearFocus, self.FocusedWidget)
226,7 → 285,7
:OnHeightSet(height) - Called when the height of the widget is changed
Widgets should not use the OnSizeChanged events of thier frame or content members, use these methods instead
AceGUI already sets a handler to the event
:OnLayoutFinished(width, height) - called after a layout has finished, the width and height will be the width and height of the
:LayoutFinished(width, height) - called after a layout has finished, the width and height will be the width and height of the
area used for controls. These can be nil if the layout used the existing size to layout the controls.
 
]]
253,7 → 312,7
frame:SetParent(nil)
frame:SetParent(parent.content)
self.parent = parent
fixlevels(parent.frame,parent.frame:GetChildren())
--fixlevels(parent.frame,parent.frame:GetChildren())
end
 
WidgetBase.SetCallback = function(self, name, func)
279,6 → 338,14
end
end
 
WidgetBase.SetRelativeWidth = function(self, width)
if width <= 0 or width > 1 then
error(":SetRelativeWidth(width): Invalid relative width.", 2)
end
self.relWidth = width
self.width = "relative"
end
 
WidgetBase.SetHeight = function(self, height)
self.frame:SetHeight(height)
self.frame.height = height
286,6 → 353,14
self:OnHeightSet(height)
end
end
 
--[[ WidgetBase.SetRelativeHeight = function(self, height)
if height <= 0 or height > 1 then
error(":SetRelativeHeight(height): Invalid relative height.", 2)
end
self.relHeight = height
self.height = "relative"
end ]]
 
WidgetBase.IsVisible = function(self)
return self.frame:IsVisible()
399,9 → 474,19
self:DoLayout()
end
 
WidgetContainerBase.AddChildren = function(self, ...)
for i = 1, select("#", ...) do
local child = select(i, ...)
tinsert(self.children, child)
child:SetParent(self)
child.frame:Show()
end
self:DoLayout()
end
 
WidgetContainerBase.ReleaseChildren = function(self)
local children = self.children
for i in ipairs(children) do
for i = 1,#children do
AceGUI:Release(children[i])
children[i] = nil
end
411,6 → 496,14
self.LayoutFunc = AceGUI:GetLayout(Layout)
end
 
WidgetContainerBase.SetAutoAdjustHeight = function(self, adjust)
if adjust then
self.noAutoHeight = nil
else
self.noAutoHeight = true
end
end
 
local function FrameResize(this)
local self = this.obj
if this:GetWidth() and this:GetHeight() then
434,6 → 527,9
setmetatable(WidgetContainerBase,{__index=WidgetBase})
 
--One of these function should be called on each Widget Instance as part of its creation process
 
--- Register a widget-class as a container for newly created widgets.
-- @param widget The widget class
function AceGUI:RegisterAsContainer(widget)
widget.children = {}
widget.userdata = {}
447,6 → 543,8
widget:SetLayout("List")
end
 
--- Register a widget-class as a widget.
-- @param widget The widget class
function AceGUI:RegisterAsWidget(widget)
widget.userdata = {}
widget.events = {}
463,7 → 561,11
------------------
-- Widget API --
------------------
-- Registers a widget Constructor, this function returns a new instance of the Widget
 
--- Registers a widget Constructor, this function returns a new instance of the Widget
-- @param Name The name of the widget
-- @param Constructor The widget constructor function
-- @param Version The version of the widget
function AceGUI:RegisterWidgetType(Name, Constructor, Version)
assert(type(Constructor) == "function")
assert(type(Version) == "number")
475,7 → 577,9
WidgetRegistry[Name] = Constructor
end
 
-- Registers a Layout Function
--- Registers a Layout Function
-- @param Name The name of the layout
-- @param LayoutFunc Reference to the layout function
function AceGUI:RegisterLayout(Name, LayoutFunc)
assert(type(LayoutFunc) == "function")
if type(Name) == "string" then
484,6 → 588,8
LayoutRegistry[Name] = LayoutFunc
end
 
--- Get a Layout Function from the registry
-- @param Name The name of the layout
function AceGUI:GetLayout(Name)
if type(Name) == "string" then
Name = Name:upper()
493,6 → 599,10
 
AceGUI.counts = AceGUI.counts or {}
 
--- A type-based counter to count the number of widgets created.
-- This is used by widgets that require a named frame, e.g. when a Blizzard
-- Template requires it.
-- @param type The widget type
function AceGUI:GetNextWidgetNum(type)
if not self.counts[type] then
self.counts[type] = 0
562,9 → 672,9
 
local height = 0
local width = content.width or content:GetWidth() or 0
for i, child in ipairs(children) do
for i = 1, #children do
local child = children[i]
 
 
local frame = child.frame
frame:ClearAllPoints()
frame:Show()
583,6 → 693,14
if child.DoLayout then
child:DoLayout()
end
elseif child.width == "relative" then
child:SetWidth(width * child.relWidth)
if child.OnWidthSet then
child:OnWidthSet(content.width or content:GetWidth())
end
if child.DoLayout then
child:DoLayout()
end
end
 
height = height + (frame.height or frame:GetHeight() or 0)
626,19 → 744,29
local frameoffset
local lastframeoffset
local oversize
for i, child in ipairs(children) do
for i = 1, #children do
local child = children[i]
oversize = nil
local frame = child.frame
local frameheight = frame.height or frame:GetHeight() or 0
local framewidth = frame.width or frame:GetWidth() or 0
lastframeoffset = frameoffset
-- HACK: Why did we set a frameoffset of (frameheight / 2) ?
-- That was moving all widgets half the widgets size down, is that intended?
-- Actually, it seems to be neccessary for many cases, we'll leave it in for now.
-- If widgets seem to anchor weirdly with this, provide a valid alignoffset for them.
-- TODO: Investigate moar!
frameoffset = child.alignoffset or (frameheight / 2)
 
if child.width == "relative" then
framewidth = width * child.relWidth
end
 
frame:Show()
frame:ClearAllPoints()
if i == 1 then
-- anchor the first control to the top left
--frame:SetPoint("TOPLEFT",content,"TOPLEFT",0,0)
frame:SetPoint("TOPLEFT",content,"TOPLEFT",0,0)
rowheight = frameheight
rowoffset = frameoffset
rowstart = frame
651,6 → 779,11
-- if there isn't available width for the control start a new row
-- if a control is "fill" it will be on a row of its own full width
if usedwidth == 0 or ((framewidth) + usedwidth > width) or child.width == "fill" then
if isfullheight then
-- a previous row has already filled the entire height, there's nothing we can usefully do anymore
-- (maybe error/warn about this?)
break
end
--anchor the previous row, we will now know its height and offset
rowstart:SetPoint("TOPLEFT",content,"TOPLEFT",0,-(height+(rowoffset-rowstartoffset)+3))
height = height + rowheight + 3
659,7 → 792,7
rowstartoffset = frameoffset
rowheight = frameheight
rowoffset = frameoffset
usedwidth = frame.width or frame:GetWidth()
usedwidth = framewidth
if usedwidth > width then
oversize = true
end
669,9 → 802,10
--math.max(rowheight-rowoffset+frameoffset, frameheight-frameoffset+rowoffset)
 
--offset is always the larger of the two offsets
rowoffset = math.max(rowoffset, frameoffset)
rowoffset = math_max(rowoffset, frameoffset)
 
rowheight = math.max(rowheight,rowoffset+(frameheight/2))
rowheight = math_max(rowheight,rowoffset+(frameheight/2))
--print("type:", child.type, "offset:",frameoffset-lastframeoffset)
frame:SetPoint("TOPLEFT",children[i-1].frame,"TOPRIGHT",0,frameoffset-lastframeoffset)
usedwidth = framewidth + usedwidth
end
685,12 → 819,25
rowstart = frame
rowstartoffset = frameoffset
 
if child.OnWidthSet then
child:OnWidthSet(width)
end
if child.DoLayout then
child:DoLayout()
end
rowheight = frame.height or frame:GetHeight() or 0
rowoffset = child.alignoffset or (rowheight / 2)
rowstartoffset = rowoffset
elseif child.width == "relative" then
child:SetWidth(width * child.relWidth)
 
if child.OnWidthSet then
child:OnWidthSet(width)
end
 
if child.DoLayout then
child:DoLayout()
end
elseif oversize then
if width > 1 then
frame:SetPoint("RIGHT",content,"RIGHT",0,0)
700,7 → 847,6
if child.height == "fill" then
frame:SetPoint("BOTTOM",content,"BOTTOM")
isfullheight = true
break
end
end
 
trunk/Plink!/Libs/AceAddon-3.0/AceAddon-3.0.lua
1,12 → 1,35
--- '''AceAddon-3.0''' provides a template for creating addon objects.
--- **AceAddon-3.0** provides a template for creating addon objects.
-- It'll provide you with a set of callback functions that allow you to simplify the loading
-- process of your addon. Callbacks provided are:<br>
-- - '''OnInitialize''', which is called directly after the addon is fully loaded.<br>
-- - '''OnEnable''' which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present.<br>
-- - '''OnDisable''', which is only called when your addon is manually being disabled.<br>
-- process of your addon.\\
-- Callbacks provided are:\\
-- * **OnInitialize**, which is called directly after the addon is fully loaded.
-- * **OnEnable** which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present.
-- * **OnDisable**, which is only called when your addon is manually being disabled.
-- @usage
-- -- A small (but complete) addon, that doesn't do anything,
-- -- but shows usage of the callbacks.
-- local MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
--
-- function MyAddon:OnInitialize()
-- -- do init tasks here, like loading the Saved Variables,
-- -- or setting up slash commands.
-- end
--
-- function MyAddon:OnEnable()
-- -- Do more initialization here, that really enables the use of your addon.
-- -- Register Events, Hook functions, Create Frames, Get information from
-- -- the game that wasn't available in OnInitialize
-- end
--
-- function MyAddon:OnDisable()
-- -- Unhook, Unregister Events, Hide frames that you created.
-- -- You would probably only use an OnDisable if you want to
-- -- build a "standby" mode, or be able to toggle modules on/off.
-- end
-- @class file
-- @name AceAddon-3.0.lua
-- @release $Id: AceAddon-3.0.lua 732 2009-02-03 15:07:43Z nevcairiel $
-- @release $Id: AceAddon-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $
 
local MAJOR, MINOR = "AceAddon-3.0", 5
local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
19,10 → 42,17
AceAddon.enablequeue = AceAddon.enablequeue or {} -- addons that are initialized and waiting to be enabled
AceAddon.embeds = AceAddon.embeds or setmetatable({}, {__index = function(tbl, key) tbl[key] = {} return tbl[key] end }) -- contains a list of libraries embedded in an addon
 
local tinsert, tconcat = table.insert, table.concat
local fmt = string.format
local pairs, next, type = pairs, next, type
-- Lua APIs
local tinsert, tconcat, tremove = table.insert, table.concat, table.remove
local fmt, tostring = string.format, tostring
local select, pairs, next, type, unpack = select, pairs, next, type, unpack
local loadstring, assert, error = loadstring, assert, error
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: LibStub, IsLoggedIn, geterrorhandler
 
--[[
xpcall safecall implementation
]]
79,6 → 109,9
local function addontostring( self ) return self.name end
 
--- Create a new AceAddon-3.0 addon.
-- Any libraries you specified will be embeded, and the addon will be scheduled for
-- its OnInitialize and OnEnable callbacks.
-- The final addon object, with all libraries embeded, will be returned.
-- @paramsig [object ,]name[, lib, ...]
-- @param object Table to use as a base for the addon (optional)
-- @param name Name of the addon object to create
89,8 → 122,7
--
-- -- Create a Addon object based on the table of a frame
-- local MyFrame = CreateFrame("Frame")
-- local MyBetterAddon = LibStub("AceAddon-3.0"):NewAddon(MyFrame, "MyBetterAddon", "AceEvent-3.0")
-- @return The newly created addon object
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon(MyFrame, "MyAddon", "AceEvent-3.0")
function AceAddon:NewAddon(objectorname, ...)
local object,name
local i=1
138,7 → 170,6
-- @usage
-- -- Get the Addon
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- @return The addon object, if found
function AceAddon:GetAddon(name, silent)
if not silent and not self.addons[name] then
error(("Usage: GetAddon(name): 'name' - Cannot find an AceAddon '%s'."):format(tostring(name)), 2)
146,8 → 177,11
return self.addons[name]
end
 
--- Embed a list of libraries into the specified addon.
-- Note: This function is for internal use by :NewAddon/:NewModule
-- - Embed a list of libraries into the specified addon.
-- This function will try to embed all of the listed libraries into the addon
-- and error if a single one fails.
--
-- **Note:** This function is for internal use by :NewAddon/:NewModule
-- @paramsig addon, [lib, ...]
-- @param addon addon object to embed the libs in
-- @param lib List of libraries to embed into the addon
158,8 → 192,12
end
end
 
--- Embed a library into the addon object.
-- Note: This function is for internal use by :EmbedLibraries
-- - Embed a library into the addon object.
-- This function will check if the specified library is registered with LibStub
-- and if it has a :Embed function to call. It'll error if any of those conditions
-- fails.
--
-- **Note:** This function is for internal use by :EmbedLibraries
-- @paramsig addon, libname[, silent[, offset]]
-- @param addon addon object to embed the library in
-- @param libname name of the library to embed
180,6 → 218,7
 
--- Return the specified module from an addon object.
-- Throws an error if the addon object cannot be found (except if silent is set)
-- @name //addon//:GetModule
-- @paramsig name[, silent]
-- @param name unique name of the module
-- @param silent if true, the module is optional, silently return nil if its not found (optional)
188,7 → 227,6
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- -- Get the Module
-- MyModule = MyAddon:GetModule("MyModule")
-- @return the module object, if found
function GetModule(self, name, silent)
if not self.modules[name] and not silent then
error(("Usage: GetModule(name, silent): 'name' - Cannot find module '%s'."):format(tostring(name)), 2)
199,9 → 237,10
local function IsModuleTrue(self) return true end
 
--- Create a new module for the addon.
-- The new module can have its own embeded libraries and/or use a module prototype to be mixed into the module.<br>
-- The new module can have its own embeded libraries and/or use a module prototype to be mixed into the module.\\
-- A module has the same functionality as a real addon, it can have modules of its own, and has the same API as
-- an addon object.
-- @name //addon//:NewModule
-- @paramsig name[, prototype|lib[, lib, ...]]
-- @param name unique name of the module
-- @param prototype object to derive this module from, methods and values from this table will be mixed into the module (optional)
213,7 → 252,6
-- -- Create a module with a prototype
-- local prototype = { OnEnable = function(self) print("OnEnable called!") end }
-- MyModule = MyAddon:NewModule("MyModule", prototype, "AceEvent-3.0", "AceHook-3.0")
-- @return the module object, if successfull
function NewModule(self, name, prototype, ...)
if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end
if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end
252,26 → 290,26
end
 
--- Returns the real name of the addon or module, without any prefix.
-- @name //addon//:GetName
-- @paramsig
-- @usage
-- print(MyAddon:GetName())
-- -- prints "MyAddon"
-- @return The name of the addon or module
function GetName(self)
return self.moduleName or self.name
end
 
--- Enables the Addon, if possible, return true or false depending on success.
-- This internally calls AceAddon:EnableAddon(), thus dispatching a OnEnable callback
-- and enabling all modules of the addon (unless explicitly disabled).<br>
-- and enabling all modules of the addon (unless explicitly disabled).\\
-- :Enable() also sets the internal `enableState` variable to true
-- @name //addon//:Enable
-- @paramsig
-- @usage
-- -- Enable MyModule
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyModule = MyAddon:GetModule("MyModule")
-- MyModule:Enable()
-- @return true if the addon was enabled successfully
function Enable(self)
self:SetEnabledState(true)
return AceAddon:EnableAddon(self)
279,14 → 317,14
 
--- Disables the Addon, if possible, return true or false depending on success.
-- This internally calls AceAddon:DisableAddon(), thus dispatching a OnDisable callback
-- and disabling all modules of the addon.<br>
-- and disabling all modules of the addon.\\
-- :Disable() also sets the internal `enableState` variable to false
-- @name //addon//:Disable
-- @paramsig
-- @usage
-- -- Disable MyAddon
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyAddon:Disable()
-- @return true if the addon was disabled successfully
function Disable(self)
self:SetEnabledState(false)
return AceAddon:DisableAddon(self)
294,6 → 332,7
 
--- Enables the Module, if possible, return true or false depending on success.
-- Short-hand function that retrieves the module via `:GetModule` and calls `:Enable` on the module object.
-- @name //addon//:EnableModule
-- @paramsig name
-- @usage
-- -- Enable MyModule using :GetModule
304,8 → 343,6
-- -- Enable MyModule using the short-hand
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyAddon:EnableModule("MyModule")
-- @return true if the module was enabled successfully
-- @see Enable
function EnableModule(self, name)
local module = self:GetModule( name )
return module:Enable()
313,6 → 350,7
 
--- Disables the Module, if possible, return true or false depending on success.
-- Short-hand function that retrieves the module via `:GetModule` and calls `:Disable` on the module object.
-- @name //addon//:DisableModule
-- @paramsig name
-- @usage
-- -- Disable MyModule using :GetModule
323,8 → 361,6
-- -- Disable MyModule using the short-hand
-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
-- MyAddon:DisableModule("MyModule")
-- @return true if the module was disabled successfully
-- @see Disable
function DisableModule(self, name)
local module = self:GetModule( name )
return module:Disable()
332,6 → 368,7
 
--- Set the default libraries to be mixed into all modules created by this object.
-- Note that you can only change the default module libraries before any module is created.
-- @name //addon//:SetDefaultModuleLibraries
-- @paramsig lib[, lib, ...]
-- @param lib List of libraries to embed into the addon
-- @usage
350,6 → 387,7
 
--- Set the default state in which new modules are being created.
-- Note that you can only change the default state before any module is created.
-- @name //addon//:SetDefaultModuleState
-- @paramsig state
-- @param state Default state for new modules, true for enabled, false for disabled
-- @usage
369,6 → 407,7
 
--- Set the default prototype to use for new modules on creation.
-- Note that you can only change the default prototype before any module is created.
-- @name //addon//:SetDefaultModulePrototype
-- @paramsig prototype
-- @param prototype Default prototype for the new modules (table)
-- @usage
392,7 → 431,8
end
 
--- Set the state of an addon or module
-- This should only be caleld before any enabling actually happend, aka in/before OnInitialize.
-- This should only be called before any enabling actually happend, e.g. in/before OnInitialize.
-- @name //addon//:SetEnabledState
-- @paramsig state
-- @param state the state of an addon or module (enabled=true, disabled=false)
function SetEnabledState(self, state)
401,27 → 441,27
 
 
--- Return an iterator of all modules associated to the addon.
-- @name //addon//:IterateModules
-- @paramsig
-- @usage
-- -- Enable all modules
-- for name, module in MyAddon:IterateModules() do
-- module:Enable()
-- end
-- @return Iterator of all modules
local function IterateModules(self) return pairs(self.modules) end
 
-- Returns an iterator of all embeds in the addon
-- @name //addon//:IterateEmbeds
-- @paramsig
-- @return Iterator of all embeded libraries
local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end
 
--- Query the enabledState of an addon.
-- @name //addon//:IsEnabled
-- @paramsig
-- @usage
-- if MyAddon:IsEnabled() then
-- MyAddon:Disable()
-- end
-- @return true if the addon/module is enabled, false otherwise
local function IsEnabled(self) return self.enabledState end
local mixins = {
NewModule = NewModule,
459,11 → 499,12
end
 
 
--- Initialize the addon after creation.
-- Note: This function is only used internally during the ADDON_LOADED event
-- It will call the '''OnInitialize''' function on the addon object (if present),
-- and the '''OnEmbedInitialize''' function on all embeded libraries. <br>
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- - Initialize the addon after creation.
-- This function is only used internally during the ADDON_LOADED event
-- It will call the **OnInitialize** function on the addon object (if present),
-- and the **OnEmbedInitialize** function on all embeded libraries.
--
-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- @param addon addon object to intialize
function AceAddon:InitializeAddon(addon)
safecall(addon.OnInitialize, addon)
478,13 → 519,15
-- from the event handler and only done _once_
end
 
--- Enable the addon after creation.
-- - Enable the addon after creation.
-- Note: This function is only used internally during the PLAYER_LOGIN event, or during ADDON_LOADED,
-- if IsLoggedIn() already returns true at that point, e.g. for LoD Addons.
-- It will call the '''OnEnable''' function on the addon object (if present),
-- and the '''OnEmbedEnable''' function on all embeded libraries.<br>
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled.<br>
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- It will call the **OnEnable** function on the addon object (if present),
-- and the **OnEmbedEnable** function on all embeded libraries.\\
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled.
--
-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- Use :Enable on the addon itself instead.
-- @param addon addon object to enable
function AceAddon:EnableAddon(addon)
if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end
511,12 → 554,14
return self.statuses[addon.name] -- return true if we're disabled
end
 
--- Disable the addon
-- - Disable the addon
-- Note: This function is only used internally.
-- It will call the '''OnDisable''' function on the addon object (if present),
-- and the '''OnEmbedDisable''' function on all embeded libraries.<br>
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled.<br>
-- Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- It will call the **OnDisable** function on the addon object (if present),
-- and the **OnEmbedDisable** function on all embeded libraries.\\
-- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled.
--
-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing.
-- Use :Disable on the addon itself instead.
-- @param addon addon object to enable
function AceAddon:DisableAddon(addon)
if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end
543,16 → 588,12
return not self.statuses[addon.name] -- return true if we're disabled
end
 
--The next few funcs are just because no one should be reaching into the internal registries
--Thoughts?
 
--- Get an iterator over all registered addons.
-- @usage
-- -- Print a list of all installed AceAddon's
-- for name, addon in AceAddon:IterateAddons() do
-- print("Addon: " .. name)
-- end
-- @return Iterator over all addons (pairs)
function AceAddon:IterateAddons() return pairs(self.addons) end
 
--- Get an iterator over the internal status registry.
563,7 → 604,6
-- print("EnabledAddon: " .. name)
-- end
-- end
-- @return Iterator over the status registry
function AceAddon:IterateAddonStatus() return pairs(self.statuses) end
 
-- Following Iterators are deprecated, and their addon specific versions should be used
trunk/Plink!/Libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua
1,30 → 1,38
--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.
-- Options tables can be registered as raw tables, or as function refs that return a table.<br>
-- These functions receive two arguments: "uiType" and "uiName". <br>
-- Valid "uiTypes": "cmd", "dropdown", "dialog". This is verified by the library at call time. <br>
-- The "uiName" field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.<br>
-- :IterateOptionsTables() and :GetOptionsTable() always return a function reference that the requesting config handling addon must call with the above arguments.
--- AceConfigRegistry-3.0 handles central registration of options tables in use by addons and modules.\\
-- Options tables can be registered as raw tables, OR as function refs that return a table.\\
-- Such functions receive three arguments: "uiType", "uiName", "appName". \\
-- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\
-- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\
-- * The **appName** field is the options table name as given at registration time \\
--
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
-- @class file
-- @name AceConfigRegistry-3.0
-- @release $Id: AceConfigRegistry-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $
local MAJOR, MINOR = "AceConfigRegistry-3.0", 6
local lib = LibStub:NewLibrary(MAJOR, MINOR)
-- @release $Id: AceConfigRegistry-3.0.lua 890 2009-12-06 12:50:05Z nevcairiel $
local MAJOR, MINOR = "AceConfigRegistry-3.0", 11
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
 
if not lib then return end
if not AceConfigRegistry then return end
 
lib.tables = lib.tables or {}
AceConfigRegistry.tables = AceConfigRegistry.tables or {}
 
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
 
if not lib.callbacks then
lib.callbacks = CallbackHandler:New(lib)
if not AceConfigRegistry.callbacks then
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
end
 
-- Lua APIs
local tinsert, tconcat = table.insert, table.concat
local strfind, strmatch = string.find, string.match
local type, tostring, select, pairs = type, tostring, select, pairs
local error, assert = error, assert
 
-----------------------------------------------------------------------
-- Validating options table consistency:
 
 
lib.validated = {
AceConfigRegistry.validated = {
-- list of options table names ran through :ValidateOptionsTable automatically.
-- CLEARED ON PURPOSE, since newer versions may have newer validators
cmd = {},
39,7 → 47,7
for i=select("#",...),1,-1 do
tinsert(t, (select(i, ...)))
end
error(MAJOR..":ValidateOptionsTable(): "..table.concat(t,".")..msg, errlvl+2)
error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
end
 
 
63,6 → 71,7
type=isstring,
name=isstringfunc,
desc=optstringfunc,
descStyle=optstring,
order=optmethodnumber,
validate=optmethodfalse,
confirm=optmethodbool,
90,6 → 99,7
imageCoords=optmethodtable,
imageHeight=optnumber,
imageWidth=optnumber,
fontSize=optstringfunc,
},
group={
args=istable,
102,11 → 112,10
childGroups=optstring,
},
execute={
-- func={
-- ["function"]=true,
-- ["string"]=true,
-- _="methodname or funcref"
-- },
image=optstringfunc,
imageCoords=optmethodtable,
imageHeight=optnumber,
imageWidth=optnumber,
},
input={
pattern=optstring,
118,6 → 127,8
},
toggle={
tristate=optbool,
image=optstringfunc,
imageCoords=optmethodtable,
},
tristate={
},
160,8 → 171,8
if type(k)~="string" then
err("["..tostring(k).."] - key is not a string", errlvl,...)
end
if strfind(k, "[%c \127]") then
err("["..tostring(k).."] - key name contained spaces (or control characters)", errlvl,...)
if strfind(k, "[%c\127]") then
err("["..tostring(k).."] - key name contained control characters", errlvl,...)
end
end
 
230,16 → 241,13
end
end
 
---------------------------------------------------------------------
-- :ValidateOptionsTable(options,name,errlvl)
-- - options - the table
-- - name - (string) name of table, used in error reports
-- - errlvl - (optional number) error level offset, default 0
--
-- Validates basic structure and integrity of an options table
-- Does NOT verify that get/set etc actually exist, since they can be defined at any depth
 
function lib:ValidateOptionsTable(options,name,errlvl)
--- Validates basic structure and integrity of an options table \\
-- Does NOT verify that get/set etc actually exist, since they can be defined at any depth
-- @param options The table to be validated
-- @param name The name of the table to be validated (shown in any error message)
-- @param errlvl (optional number) error level offset, default 0 (=errors point to the function calling :ValidateOptionsTable)
function AceConfigRegistry:ValidateOptionsTable(options,name,errlvl)
errlvl=(errlvl or 0)+1
name = name or "Optionstable"
if not options.name then
248,19 → 256,16
validate(options,errlvl,name)
end
 
------------------------------
-- :NotifyChange(appName)
-- - appName - string identifying the addon
--
-- Fires a ConfigTableChange callback for those listening in on it, allowing config GUIs to refresh
------------------------------
 
function lib:NotifyChange(appName)
if not lib.tables[appName] then return end
lib.callbacks:Fire("ConfigTableChange", appName)
--- Fires a "ConfigTableChange" callback for those listening in on it, allowing config GUIs to refresh.
-- You should call this function if your options table changed from any outside event, like a game event
-- or a timer.
-- @param appName The application name as given to `:RegisterOptionsTable()`
function AceConfigRegistry:NotifyChange(appName)
if not AceConfigRegistry.tables[appName] then return end
AceConfigRegistry.callbacks:Fire("ConfigTableChange", appName)
end
 
---------------------------------------------------------------------
-- -------------------------------------------------------------------
-- Registering and retreiving options tables:
 
 
276,34 → 281,32
end
end
 
 
---------------------------------------------------------------------
-- :RegisterOptionsTable(appName, options)
-- - appName - string identifying the addon
-- - options - table or function reference
 
function lib:RegisterOptionsTable(appName, options)
--- Register an options table with the config registry.
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param options The options table, OR a function reference that generates it on demand. \\
-- See the top of the page for info on arguments passed to such functions.
function AceConfigRegistry:RegisterOptionsTable(appName, options)
if type(options)=="table" then
if options.type~="group" then -- quick sanity checker
error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2)
end
lib.tables[appName] = function(uiType, uiName, errlvl)
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
errlvl=(errlvl or 0)+1
validateGetterArgs(uiType, uiName, errlvl)
if not lib.validated[uiType][appName] then
lib:ValidateOptionsTable(options, appName, errlvl) -- upgradable
lib.validated[uiType][appName] = true
if not AceConfigRegistry.validated[uiType][appName] then
AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
AceConfigRegistry.validated[uiType][appName] = true
end
return options
end
elseif type(options)=="function" then
lib.tables[appName] = function(uiType, uiName, errlvl)
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
errlvl=(errlvl or 0)+1
validateGetterArgs(uiType, uiName, errlvl)
local tab = assert(options(uiType, uiName))
if not lib.validated[uiType][appName] then
lib:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
lib.validated[uiType][appName] = true
local tab = assert(options(uiType, uiName, appName))
if not AceConfigRegistry.validated[uiType][appName] then
AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
AceConfigRegistry.validated[uiType][appName] = true
end
return tab
end
312,30 → 315,23
end
end
 
--- Returns an iterator of ["appName"]=funcref pairs
function AceConfigRegistry:IterateOptionsTables()
return pairs(AceConfigRegistry.tables)
end
 
---------------------------------------------------------------------
-- :IterateOptionsTables()
--
-- Returns an iterator of ["appName"]=funcref pairs
 
function lib:IterateOptionsTables()
return pairs(lib.tables)
end
 
 
---------------------------------------------------------------------
-- :GetOptionsTable(appName)
-- - appName - which addon to retreive the options table of
-- Optional:
-- - uiType - "cmd", "dropdown", "dialog"
-- - uiName - e.g. "MyLib-1.0"
--
--- Query the registry for a specific options table.
-- If only appName is given, a function is returned which you
-- can call with (uiType,uiName) to get the table.
-- can call with (uiType,uiName) to get the table.\\
-- If uiType&uiName are given, the table is returned.
 
function lib:GetOptionsTable(appName, uiType, uiName)
local f = lib.tables[appName]
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param uiType The type of UI to get the table for, one of "cmd", "dropdown", "dialog"
-- @param uiName The name of the library/addon querying for the table, e.g. "MyLib-1.0"
function AceConfigRegistry:GetOptionsTable(appName, uiType, uiName)
local f = AceConfigRegistry.tables[appName]
if not f then
return nil
end
trunk/Plink!/Libs/AceConfig-3.0/AceConfig-3.0.lua
3,37 → 3,45
-- as well as associate it with a slash command.
-- @class file
-- @name AceConfig-3.0
-- @release $Id: AceConfig-3.0.lua 710 2008-12-19 10:14:39Z nevcairiel $
-- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $
 
--[[
AceConfig-3.0
 
Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
 
Also automatically adds "config", "enable" and "disable" commands to options table as appropriate.
 
]]
 
local MAJOR, MINOR = "AceConfig-3.0", 2
local lib = LibStub:NewLibrary(MAJOR, MINOR)
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
 
if not lib then return end
if not AceConfig then return end
 
 
local cfgreg = LibStub("AceConfigRegistry-3.0")
local cfgcmd = LibStub("AceConfigCmd-3.0")
local cfgdlg = LibStub("AceConfigDialog-3.0")
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0")
 
-- Lua APIs
local pcall, error, type, pairs = pcall, error, type, pairs
 
---------------------------------------------------------------------
-- -------------------------------------------------------------------
-- :RegisterOptionsTable(appName, options, slashcmd, persist)
--
-- - appName - (string) application name
-- - options - table or function ref, see AceConfigRegistry
-- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
 
function lib:RegisterOptionsTable(appName, options, slashcmd)
--- Register a option table with the AceConfig registry.
-- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
-- @paramsig appName, options [, slashcmd]
-- @param appName The application name for the config table.
-- @param options The option table (or a function to generate one on demand)
-- @param slashcmd A slash command to register for the option table, or a table of slash commands.
-- @usage
-- local AceConfig = LibStub("AceConfig-3.0")
-- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
if not ok then error(msg, 2) end
 
trunk/Plink!/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua
1,38 → 1,40
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables.
-- @class file
-- @name AceConfigDialog-3.0
-- @release $Id: AceConfigDialog-3.0.lua 736 2009-02-14 11:13:43Z nevcairiel $
-- @release $Id: AceConfigDialog-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $
 
local LibStub = LibStub
local MAJOR, MINOR = "AceConfigDialog-3.0", 26
local lib = LibStub:NewLibrary(MAJOR, MINOR)
local MAJOR, MINOR = "AceConfigDialog-3.0", 41
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
if not lib then return end
if not AceConfigDialog then return end
 
lib.OpenFrames = lib.OpenFrames or {}
lib.Status = lib.Status or {}
lib.frame = lib.frame or CreateFrame("Frame")
AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {}
AceConfigDialog.Status = AceConfigDialog.Status or {}
AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame")
 
lib.frame.apps = lib.frame.apps or {}
lib.frame.closing = lib.frame.closing or {}
AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {}
AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
 
local gui = LibStub("AceGUI-3.0")
local reg = LibStub("AceConfigRegistry-3.0")
 
local select = select
local pairs = pairs
local type = type
local assert = assert
local tinsert = tinsert
local tremove = tremove
local error = error
local table = table
local unpack = unpack
local string = string
local next = next
local math = math
local _
-- Lua APIs
local tconcat, tinsert, tsort, tremove = table.concat, table.insert, table.sort, table.remove
local strmatch, format = string.match, string.format
local assert, loadstring, error = assert, loadstring, error
local pairs, next, select, type, unpack = pairs, next, select, type, unpack
local rawset, tostring = rawset, tostring
local math_min, math_max, math_floor = math.min, math.max, math.floor
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: NORMAL_FONT_COLOR, GameTooltip, StaticPopupDialogs, ACCEPT, CANCEL, StaticPopup_Show
-- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge
-- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler
 
local emptyTbl = {}
 
--[[
xpcall safecall implementation
]]
60,7 → 62,7
 
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("ARGS", table.concat(ARGS, ", "))
code = code:gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
 
179,11 → 181,13
usage = true,
width = true,
image = true,
fontSize = true,
}
 
--Is Never a function or method
local allIsLiteral = {
type = true,
descStyle = true,
imageWidth = true,
imageHeight = true,
}
249,7 → 253,7
if handler and handler[member] then
a,b,c,d = handler[member](handler, info, ...)
else
error(string.format("Method %s doesn't exist in handler for type %s", member, membername))
error(format("Method %s doesn't exist in handler for type %s", member, membername))
end
end
del(info)
370,7 → 374,7
end
end
 
table.sort(keySort, compareOptions)
tsort(keySort, compareOptions)
 
del(tempOrders)
del(tempNames)
422,10 → 426,11
end
end
 
--[[
Gets a status table for the given appname and options path
]]
function lib:GetStatusTable(appName, path)
-- - Gets a status table for the given appname and options path.
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param path The path to the options (a table with all group keys)
-- @return
function AceConfigDialog:GetStatusTable(appName, path)
local status = self.Status
 
if not status[appName] then
451,10 → 456,11
return status.status
end
 
--[[
Sets the given path to be selected
]]
function lib:SelectGroup(appName, ...)
--- Selects the specified path in the options window.
-- The path specified has to match the keys of the groups in the table.
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param ... The path to the key that should be selected
function AceConfigDialog:SelectGroup(appName, ...)
local path = new()
 
 
530,7 → 536,10
local name = GetOptionsMemberValue("name", opt, options, path, appName)
local desc = GetOptionsMemberValue("desc", opt, options, path, appName)
local usage = GetOptionsMemberValue("usage", opt, options, path, appName)
local descStyle = opt.descStyle
 
if descStyle and descStyle ~= "tooltip" then return end
 
GameTooltip:SetText(name, 1, .82, 0, 1)
 
if opt.type == 'multiselect' then
575,14 → 584,14
if dialog and oldstrata then
dialog:SetFrameStrata(oldstrata)
end
lib:Open(appName, rootframe, basepath and unpack(basepath))
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
del(info)
end
t.OnCancel = function()
if dialog and oldstrata then
dialog:SetFrameStrata(oldstrata)
end
lib:Open(appName, rootframe, basepath and unpack(basepath))
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl))
del(info)
end
for i = 1, select('#', ...) do
675,7 → 684,7
success, validated = safecall(handler[validate], handler, info, ...)
if not success then validated = false end
else
error(string.format("Method %s doesn't exist in handler for type execute", validate))
error(format("Method %s doesn't exist in handler for type execute", validate))
end
elseif type(validate) == "function" then
success, validated = safecall(validate, info, ...)
688,6 → 697,8
--validate function returned a message to display
if rootframe.SetStatusText then
rootframe:SetStatusText(validated)
else
-- TODO: do something else.
end
PlaySound("igPlayerInviteDecline")
del(info)
704,6 → 715,8
rootframe:SetStatusText(name..": Invalid Value")
end
end
else
-- TODO: do something else
end
PlaySound("igPlayerInviteDecline")
del(info)
722,7 → 735,7
confirm = false
end
else
error(string.format("Method %s doesn't exist in handler for type confirm", confirm))
error(format("Method %s doesn't exist in handler for type confirm", confirm))
end
elseif type(confirm) == "function" then
success, confirm = safecall(confirm, info, ...)
762,7 → 775,7
if handler and handler[func] then
confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, ...)
else
error(string.format("Method %s doesn't exist in handler for type func", func))
error(format("Method %s doesn't exist in handler for type func", func))
end
elseif type(func) == "function" then
confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, ...)
777,7 → 790,7
if handler and handler[func] then
safecall(handler[func],handler, info, ...)
else
error(string.format("Method %s doesn't exist in handler for type func", func))
error(format("Method %s doesn't exist in handler for type func", func))
end
elseif type(func) == "function" then
safecall(func,info, ...)
786,23 → 799,23
 
 
local iscustom = user.rootframe:GetUserData('iscustom')
local basepath = user.rootframe:GetUserData('basepath')
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl
--full refresh of the frame, some controls dont cause this on all events
if option.type == "color" then
if event == "OnValueConfirmed" then
 
if iscustom then
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
else
lib:Open(user.appName, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, unpack(basepath))
end
end
elseif option.type == "range" then
if event == "OnMouseUp" then
if iscustom then
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
else
lib:Open(user.appName, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, unpack(basepath))
end
end
--multiselects don't cause a refresh on 'OnValueChanged' only 'OnClosed'
810,9 → 823,9
user.valuechanged = true
else
if iscustom then
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
else
lib:Open(user.appName, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, unpack(basepath))
end
end
 
824,9 → 837,9
local option = widget:GetUserData('option')
local min, max, step = option.min or 0, option.max or 100, option.step
if step then
value = math.floor((value - min) / step + 0.5) * step + min
value = math_floor((value - min) / step + 0.5) * step + min
else
value = math.max(math.min(value,max),min)
value = math_max(math_min(value,max),min)
end
ActivateControl(widget,event,value)
end
837,11 → 850,11
ActivateControl(widget, event, widget:GetUserData('value'), ...)
local user = widget:GetUserDataTable()
local iscustom = user.rootframe:GetUserData('iscustom')
local basepath = user.rootframe:GetUserData('basepath')
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl
if iscustom then
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
else
lib:Open(user.appName, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, unpack(basepath))
end
end
 
849,18 → 862,18
local user = widget:GetUserDataTable()
if user.valuechanged then
local iscustom = user.rootframe:GetUserData('iscustom')
local basepath = user.rootframe:GetUserData('basepath')
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl
if iscustom then
lib:Open(user.appName, user.rootframe, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath))
else
lib:Open(user.appName, basepath and unpack(basepath))
AceConfigDialog:Open(user.appName, unpack(basepath))
end
end
end
 
local function FrameOnClose(widget, event)
local appName = widget:GetUserData('appName')
lib.OpenFrames[appName] = nil
AceConfigDialog.OpenFrames[appName] = nil
gui:Release(widget)
end
 
957,6 → 970,7
local entry = new()
entry.value = k
entry.text = GetOptionsMemberValue("name", v, options, path, appName)
entry.icon = GetOptionsMemberValue("icon", v, options, path, appName)
entry.disabled = CheckOptionDisabled(v, options, path, appName)
if not tree.children then tree.children = new() end
tinsert(tree.children,entry)
990,6 → 1004,7
local entry = new()
entry.value = k
entry.text = GetOptionsMemberValue("name", v, options, path, appName)
entry.icon = GetOptionsMemberValue("icon", v, options, path, appName)
entry.disabled = CheckOptionDisabled(v, options, path, appName)
tinsert(tree,entry)
if recurse and (v.childGroups or "tree") == "tree" then
1063,8 → 1078,35
local name = GetOptionsMemberValue("name", v, options, path, appName)
 
if v.type == "execute" then
control = gui:Create("Button")
control:SetText(name)
 
local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
 
if type(image) == 'string' then
control = gui:Create("Icon")
if not width then
width = GetOptionsMemberValue("imageWidth",v, options, path, appName)
end
if not height then
height = GetOptionsMemberValue("imageHeight",v, options, path, appName)
end
if type(imageCoords) == 'table' then
control:SetImage(image, unpack(imageCoords))
else
control:SetImage(image)
end
if type(width) ~= "number" then
width = 32
end
if type(height) ~= "number" then
height = 32
end
control:SetImageSize(width, height)
control:SetLabel(name)
else
control = gui:Create("Button")
control:SetText(name)
end
control:SetCallback("OnClick",ActivateControl)
 
elseif v.type == "input" then
1096,7 → 1138,22
local value = GetOptionsMemberValue("get",v, options, path, appName)
control:SetValue(value)
control:SetCallback("OnValueChanged",ActivateControl)
 
 
if v.descStyle == "inline" then
local desc = GetOptionsMemberValue("desc", v, options, path, appName)
control:SetDescription(desc)
end
 
local image = GetOptionsMemberValue("image", v, options, path, appName)
local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName)
 
if type(image) == 'string' then
if type(imageCoords) == 'table' then
control:SetImage(image, unpack(imageCoords))
else
control:SetImage(image)
end
end
elseif v.type == "range" then
control = gui:Create("Slider")
control:SetLabel(name)
1138,8 → 1195,8
tinsert(valuesort, value)
end
end
table.sort(valuesort)
 
tsort(valuesort)
 
if controlType then
control = gui:Create(controlType)
if not control then
1228,6 → 1285,16
elseif v.type == "description" then
control = gui:Create("Label")
control:SetText(name)
 
local fontSize = GetOptionsMemberValue("fontSize",v, options, path, appName)
if fontSize == "medium" then
control:SetFontObject(GameFontHighlight)
elseif fontSize == "large" then
control:SetFontObject(GameFontHighlightLarge)
else -- small or invalid
control:SetFontObject(GameFontHighlightSmall)
end
 
local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
 
1308,7 → 1375,7
feedpath[i] = path[i]
end
 
BuildPath(feedpath, string.split("\001", uniquevalue))
BuildPath(feedpath, ("\001"):split(uniquevalue))
local group = options
for i = 1, #feedpath do
if not group then return end
1320,9 → 1387,9
 
GameTooltip:SetOwner(button, "ANCHOR_NONE")
if widget.type == "TabGroup" then
GameTooltip:SetPoint("BOTTOM",button,"TOP")
GameTooltip:SetPoint("BOTTOM",button,"TOP")
else
GameTooltip:SetPoint("LEFT",button,"RIGHT")
GameTooltip:SetPoint("LEFT",button,"RIGHT")
end
 
GameTooltip:SetText(name, 1, .82, 0, 1)
1348,7 → 1415,7
feedpath[i] = path[i]
end
 
BuildPath(feedpath, string.split("\001", uniquevalue))
BuildPath(feedpath, ("\001"):split(uniquevalue))
 
local group = options
for i = 1, #feedpath do
1381,13 → 1448,13
feedpath[i] = path[i]
end
 
BuildPath(feedpath, string.split("\001", uniquevalue))
BuildPath(feedpath, ("\001"):split(uniquevalue))
local group = options
for i = 1, #feedpath do
group = GetSubOption(group, feedpath[i])
end
widget:ReleaseChildren()
lib:FeedGroup(user.appName,options,widget,rootframe,feedpath)
AceConfigDialog:FeedGroup(user.appName,options,widget,rootframe,feedpath)
 
del(feedpath)
end
1395,6 → 1462,7
 
 
--[[
-- INTERNAL --
This function will feed one group, and any inline child groups into the given container
Select Groups will only have the selection control (tree, tabs, dropdown) fed in
and have a group selected, this event will trigger the feeding of child groups
1409,7 → 1477,7
if its parent is a tree group, its already a node on a tree
--]]
 
function lib:FeedGroup(appName,options,container,rootframe,path, isRoot)
function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isRoot)
local group = options
--follow the path to get to the curent group
local inline
1435,14 → 1503,14
--check if the group has child groups
local hasChildGroups
for k, v in pairs(group.args) do
if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) then
if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) and not CheckOptionHidden(v, options, path, appName) then
hasChildGroups = true
end
end
if group.plugins then
for plugin, t in pairs(group.plugins) do
for k, v in pairs(t) do
if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) then
if v.type == "group" and not pickfirstset(v.dialogInline,v.guiInline,v.inline, false) and not CheckOptionHidden(v, options, path, appName) then
hasChildGroups = true
end
end
1454,7 → 1522,7
 
--Add a scrollframe if we are not going to add a group control, this is the inverse of the conditions for that later on
if (not (hasChildGroups and not inline)) or (grouptype ~= "tab" and grouptype ~= "select" and (parenttype == "tree" and not isRoot)) then
if container.type ~= "InlineGroup" then
if container.type ~= "InlineGroup" and container.type ~= "SimpleGroup" then
scroll = gui:Create("ScrollFrame")
scroll:SetLayout("flow")
scroll.width = "fill"
1477,7 → 1545,7
end
 
if hasChildGroups and not inline then
 
local name = GetOptionsMemberValue("name", group, options, path, appName)
if grouptype == "tab" then
 
local tab = gui:Create("TabGroup")
1486,7 → 1554,7
tab:SetCallback("OnTabEnter", TreeOnButtonEnter)
tab:SetCallback("OnTabLeave", TreeOnButtonLeave)
 
local status = lib:GetStatusTable(appName, path)
local status = AceConfigDialog:GetStatusTable(appName, path)
if not status.groups then
status.groups = {}
end
1511,9 → 1579,10
elseif grouptype == "select" then
 
local select = gui:Create("DropdownGroup")
select:SetTitle(name)
InjectInfo(select, options, group, path, rootframe, appName)
select:SetCallback("OnGroupSelected", GroupSelected)
local status = lib:GetStatusTable(appName, path)
local status = AceConfigDialog:GetStatusTable(appName, path)
if not status.groups then
status.groups = {}
end
1529,7 → 1598,7
end
 
if firstgroup then
select:SetGroup( (GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup)
select:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup)
end
 
select.width = "fill"
1551,7 → 1620,7
tree:SetCallback("OnButtonEnter", TreeOnButtonEnter)
tree:SetCallback("OnButtonLeave", TreeOnButtonLeave)
 
local status = lib:GetStatusTable(appName, path)
local status = AceConfigDialog:GetStatusTable(appName, path)
if not status.groups then
status.groups = {}
end
1579,29 → 1648,37
 
local function RefreshOnUpdate(this)
for appName in pairs(this.closing) do
if lib.OpenFrames[appName] then
lib.OpenFrames[appName]:Hide()
if AceConfigDialog.OpenFrames[appName] then
AceConfigDialog.OpenFrames[appName]:Hide()
end
if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then
for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do
if not widget:IsVisible() then
widget:ReleaseChildren()
end
end
end
this.closing[appName] = nil
end
 
if this.closeAll then
for k, v in pairs(lib.OpenFrames) do
for k, v in pairs(AceConfigDialog.OpenFrames) do
v:Hide()
end
this.closeAll = nil
end
 
for appName in pairs(this.apps) do
if lib.OpenFrames[appName] then
local user = lib.OpenFrames[appName]:GetUserDataTable()
lib:Open(appName, user.basepath and unpack(user.basepath))
if AceConfigDialog.OpenFrames[appName] then
local user = AceConfigDialog.OpenFrames[appName]:GetUserDataTable()
AceConfigDialog:Open(appName, unpack(user.basepath or emptyTbl))
end
if lib.BlizOptions and lib.BlizOptions[appName] then
local widget = lib.BlizOptions[appName]
local user = widget:GetUserDataTable()
if widget:IsVisible() then
lib:Open(widget:GetUserData('appName'), widget, user.basepath and unpack(user.basepath))
if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then
for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do
local user = widget:GetUserDataTable()
if widget:IsVisible() then
AceConfigDialog:Open(widget:GetUserData('appName'), widget, unpack(user.basepath or emptyTbl))
end
end
end
this.apps[appName] = nil
1609,39 → 1686,53
this:SetScript("OnUpdate", nil)
end
 
function lib:CloseAll()
lib.frame.closeAll = true
lib.frame:SetScript("OnUpdate", RefreshOnUpdate)
--- Close all open options windows
function AceConfigDialog:CloseAll()
AceConfigDialog.frame.closeAll = true
AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
if next(self.OpenFrames) then
return true
end
end
 
function lib:Close(appName)
--- Close a specific options window.
-- @param appName The application name as given to `:RegisterOptionsTable()`
function AceConfigDialog:Close(appName)
if self.OpenFrames[appName] then
lib.frame.closing[appName] = true
lib.frame:SetScript("OnUpdate", RefreshOnUpdate)
AceConfigDialog.frame.closing[appName] = true
AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
return true
end
end
 
function lib:ConfigTableChanged(event, appName)
lib.frame.apps[appName] = true
lib.frame:SetScript("OnUpdate", RefreshOnUpdate)
-- Internal -- Called by AceConfigRegistry
function AceConfigDialog:ConfigTableChanged(event, appName)
AceConfigDialog.frame.apps[appName] = true
AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
end
 
reg.RegisterCallback(lib, "ConfigTableChange", "ConfigTableChanged")
reg.RegisterCallback(AceConfigDialog, "ConfigTableChange", "ConfigTableChanged")
 
function lib:SetDefaultSize(appName, width, height)
local status = lib:GetStatusTable(appName)
--- Sets the default size of the options window for a specific application.
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param width The default width
-- @param height The default height
function AceConfigDialog:SetDefaultSize(appName, width, height)
local status = AceConfigDialog:GetStatusTable(appName)
if type(width) == "number" and type(height) == "number" then
status.width = width
status.height = height
end
end
 
-- :Open(appName, [container], [path ...])
function lib:Open(appName, container, ...)
--- Open an option window at the specified path (if any).
-- This function can optionally feed the group into a pre-created container
-- instead of creating a new container frame.
-- @paramsig appName [, container][, ...]
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param container An optional container frame to feed the options into
-- @param ... The path to open after creating the options window (see `:SelectGroup` for details)
function AceConfigDialog:Open(appName, container, ...)
if not old_CloseSpecialWindows then
old_CloseSpecialWindows = CloseSpecialWindows
CloseSpecialWindows = function()
1679,7 → 1770,7
if #path > 0 then
f:SetUserData('basepath', copy(path))
end
local status = lib:GetStatusTable(appName)
local status = AceConfigDialog:GetStatusTable(appName)
if not status.width then
status.width = 700
end
1689,6 → 1780,9
if f.SetStatusTable then
f:SetStatusTable(status)
end
if f.SetTitle then
f:SetTitle(name or "")
end
else
if not self.OpenFrames[appName] then
f = gui:Create("Frame")
1703,7 → 1797,7
f:SetUserData('basepath', copy(path))
end
f:SetTitle(name or "")
local status = lib:GetStatusTable(appName)
local status = AceConfigDialog:GetStatusTable(appName)
f:SetStatusTable(status)
end
 
1714,28 → 1808,63
del(path)
end
 
lib.BlizOptions = lib.BlizOptions or {}
-- convert pre-39 BlizOptions structure to the new format
if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then
local old = AceConfigDialog.BlizOptions
local new = {}
for key, widget in pairs(old) do
local appName = widget:GetUserData('appName')
if not new[appName] then new[appName] = {} end
new[appName][key] = widget
end
AceConfigDialog.BlizOptions = new
else
AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or {}
end
 
local function FeedToBlizPanel(widget, event)
local path = widget:GetUserData('path')
lib:Open(widget:GetUserData('appName'), widget, path and unpack(path))
AceConfigDialog:Open(widget:GetUserData('appName'), widget, unpack(path or emptyTbl))
end
 
local function ClearBlizPanel(widget, event)
widget:ReleaseChildren()
local appName = widget:GetUserData('appName')
AceConfigDialog.frame.closing[appName] = true
AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate)
end
 
function lib:AddToBlizOptions(appName, name, parent, ...)
local BlizOptions = lib.BlizOptions
--- Add an option table into the Blizzard Interface Options panel.
-- You can optionally supply a descriptive name to use and a parent frame to use,
-- as well as a path in the options table.\\
-- If no name is specified, the appName will be used instead.
--
-- If you specify a proper `parent` (by name), the interface options will generate a
-- tree layout. Note that only one level of children is supported, so the parent always
-- has to be a head-level note.
--
-- This function returns a reference to the container frame registered with the Interface
-- Options. You can use this reference to open the options with the API function
-- `InterfaceOptionsFrame_OpenToCategory`.
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param name A descriptive name to display in the options tree (defaults to appName)
-- @param parent The parent to use in the interface options tree.
-- @param ... The path in the options table to feed into the interface options panel.
-- @return The reference to the frame registered into the Interface Options.
function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...)
local BlizOptions = AceConfigDialog.BlizOptions
 
local key = appName
for n = 1, select('#', ...) do
key = key..'\001'..select(n, ...)
end
 
if not BlizOptions[key] then
if not BlizOptions[appName] then
BlizOptions[appName] = {}
end
 
if not BlizOptions[appName][key] then
local group = gui:Create("BlizOptionsGroup")
BlizOptions[key] = group
BlizOptions[appName][key] = group
group:SetName(name or appName, parent)
 
group:SetTitle(name or appName)
trunk/Plink!/Libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua
1,7 → 1,7
--- AceConfigCmd-3.0 handles access to optionstable through the "command line" interface via the ChatFrames.
--- AceConfigCmd-3.0 handles access to an options table through the "command line" interface via the ChatFrames.
-- @class file
-- @name AceConfigCmd-3.0
-- @release $Id: AceConfigCmd-3.0.lua 733 2009-02-03 22:24:44Z nevcairiel $
-- @release $Id: AceConfigCmd-3.0.lua 897 2009-12-06 17:02:27Z mikk $
 
--[[
AceConfigCmd-3.0
12,24 → 12,36
 
]]
 
-- TODO: handle disabled / hidden
-- TODO: implement handlers for all types
-- TODO: plugin args
 
 
local MAJOR, MINOR = "AceConfigCmd-3.0", 7
local lib = LibStub:NewLibrary(MAJOR, MINOR)
local MAJOR, MINOR = "AceConfigCmd-3.0", 11
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR)
 
if not lib then return end
if not AceConfigCmd then return end
 
lib.commands = lib.commands or {}
local commands = lib.commands
AceConfigCmd.commands = AceConfigCmd.commands or {}
local commands = AceConfigCmd.commands
 
local cfgreg = LibStub("AceConfigRegistry-3.0")
local AceConsole -- LoD
local AceConsoleName = "AceConsole-3.0"
 
-- Lua APIs
local strsub, strsplit, strlower, strmatch, strtrim = string.sub, string.split, string.lower, string.match, string.trim
local format, tonumber, tostring = string.format, tonumber, tostring
local tsort, tinsert = table.sort, table.insert
local select, pairs, next, type = select, pairs, next, type
local error, assert = error, assert
 
-- WoW APIs
local _G = _G
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: LibStub, SELECTED_CHAT_FRAME, DEFAULT_CHAT_FRAME
 
 
local L = setmetatable({}, { -- TODO: replace with proper locale
__index = function(self,k) return k end
})
169,6 → 181,19
end
end
 
local function checkhidden(info, inputpos, tab)
if tab.cmdHidden~=nil then
return tab.cmdHidden
end
local hidden = tab.hidden
if type(hidden) == "function" or type(hidden) == "string" then
info.hidden = hidden
hidden = callmethod(info, inputpos, tab, 'hidden')
info.hidden = nil
end
return hidden
end
 
local function showhelp(info, inputpos, tab, noHead)
if not noHead then
print("|cff33ff99"..info.appName.."|r: Arguments to |cffffff78/"..info[0].."|r "..strsub(info.input,1,inputpos-1)..":")
179,12 → 204,12
 
for k,v in iterateargs(tab) do
if not refTbl[k] then -- a plugin overriding something in .args
table.insert(sortTbl, k)
tinsert(sortTbl, k)
refTbl[k] = v
end
end
 
table.sort(sortTbl, function(one, two)
tsort(sortTbl, function(one, two)
local o1 = refTbl[one].order or 100
local o2 = refTbl[two].order or 100
if type(o1) == "function" or type(o1) == "string" then
208,9 → 233,10
return o1<o2
end)
 
for _,k in ipairs(sortTbl) do
for i = 1, #sortTbl do
local k = sortTbl[i]
local v = refTbl[k]
if not pickfirstset(v.cmdHidden, v.hidden, false) then
if not checkhidden(info, inputpos, v) then
-- recursively show all inline groups
local name, desc = v.name, v.desc
if type(name) == "function" then
223,7 → 249,8
print(" "..(desc or name)..":")
showhelp(info, inputpos, v, true)
elseif v.type ~= "description" and v.type ~= "header" then
print(" |cffffff78"..k.."|r - "..(desc or name or ""))
local key = k:gsub(" ", "_")
print(" |cffffff78"..key.."|r - "..(desc or name or ""))
end
end
end
326,7 → 353,7
if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end
 
-- grab next arg from input
local _,nextpos,arg = string.find(info.input, " *([^ ]+) *", inputpos)
local _,nextpos,arg = (info.input):find(" *([^ ]+) *", inputpos)
if not arg then
showhelp(info, inputpos, tab)
return
347,7 → 374,7
return -- done, name was found in inline group
end
-- matching name and not a inline group
elseif strlower(arg)==strlower(k) then
elseif strlower(arg)==strlower(k:gsub(" ", "_")) then
info[depth+1] = k
return handle(info,nextpos,v,depth+1)
end
457,10 → 484,6
elseif tab.type=="select" then
------------ select ------------------------------------
local str = strtrim(strlower(str))
if str == "" then
--TODO: Show current selection and possible values
return
end
 
local values = tab.values
if type(values) == "function" or type(values) == "string" then
468,6 → 491,21
values = callmethod(info, inputpos, tab, "values")
info.values = nil
end
 
if str == "" then
local b = callmethod(info, inputpos, tab, "get")
local fmt = "|cffffff78- [%s]|r %s"
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
print(L["Options for |cffffff78"..info[#info].."|r:"])
for k, v in pairs(values) do
if b == k then
print(fmt_sel:format(k, v))
else
print(fmt:format(k, v))
end
end
return
end
 
local ok
for k,v in pairs(values) do
487,25 → 525,35
elseif tab.type=="multiselect" then
------------ multiselect -------------------------------------------
local str = strtrim(strlower(str))
if str == "" then
--TODO: Show current values
return
end
 
local values = tab.values
if type(values) == "function" or type(values) == "string" then
info.values = values
values = callmethod(info, inputpos, tab, "values")
info.values = nil
end
end
 
if str == "" then
local fmt = "|cffffff78- [%s]|r %s"
local fmt_sel = "|cffffff78- [%s]|r %s |cffff0000*|r"
print(L["Options for |cffffff78"..info[#info].."|r (multiple possible):"])
for k, v in pairs(values) do
if callmethod(info, inputpos, tab, "get", k) then
print(fmt_sel:format(k, v))
else
print(fmt:format(k, v))
end
end
return
end
 
--build a table of the selections, checking that they exist
--parse for =on =off =default in the process
--table will be key = true for options that should toggle, key = [on|off|default] for options to be set
local sels = {}
for v in string.gmatch(str, "[^ ]+") do
for v in str:gmatch("[^ ]+") do
--parse option=on etc
local opt, val = string.match(v,'(.+)=(.+)')
local opt, val = v:match('(.+)=(.+)')
--get option if toggling
if not opt then
opt = v
668,18 → 716,28
end
end
 
 
-----------------------------------------------------------------------
-- HandleCommand(slashcmd, appName, input)
--
-- Call this from a chat command handler to parse the command input as operations on an aceoptions table
--- Handle the chat command.
-- This is usually called from a chat command handler to parse the command input as operations on an aceoptions table.\\
-- AceConfigCmd uses this function internally when a slash command is registered with `:CreateChatCommand`
-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
-- @param appName The application name as given to `:RegisterOptionsTable()`
-- @param input The commandline input (as given by the WoW handler, i.e. without the command itself)
-- @usage
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceConsole-3.0")
-- -- Use AceConsole-3.0 to register a Chat Command
-- MyAddon:RegisterChatCommand("mychat", "ChatCommand")
--
-- slashcmd (string) - the slash command WITHOUT leading slash (only used for error output)
-- appName (string) - the application name as given to AceConfigRegistry:RegisterOptionsTable()
-- input (string) -- the commandline input (as given by the WoW handler, i.e. without the command itself)
-- -- Show the GUI if no input is supplied, otherwise handle the chat input.
-- function MyAddon:ChatCommand(input)
-- -- Assuming "MyOptions" is the appName of a valid options table
-- if not input or input:trim() == "" then
-- LibStub("AceConfigDialog-3.0"):Open("MyOptions")
-- else
-- LibStub("AceConfigCmd-3.0").HandleCommand(MyAddon, "mychat", "MyOptions", input)
-- end
-- end
function AceConfigCmd:HandleCommand(slashcmd, appName, input)
 
function lib:HandleCommand(slashcmd, appName, input)
 
local optgetter = cfgreg:GetOptionsTable(appName)
if not optgetter then
error([[Usage: HandleCommand("slashcmd", "appName", "input"): 'appName' - no options table "]]..tostring(appName)..[[" has been registered]], 2)
700,34 → 758,26
handle(info, 1, options, 0) -- (info, inputpos, table, depth)
end
 
 
 
-----------------------------------------------------------------------
-- CreateChatCommand(slashcmd, appName)
--
-- Utility function to create a slash command handler.
--- Utility function to create a slash command handler.
-- Also registers tab completion with AceTab
--
-- slashcmd (string) - the slash command WITHOUT leading slash (only used for error output)
-- appName (string) - the application name as given to AceConfigRegistry:RegisterOptionsTable()
 
function lib:CreateChatCommand(slashcmd, appName)
-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
-- @param appName The application name as given to `:RegisterOptionsTable()`
function AceConfigCmd:CreateChatCommand(slashcmd, appName)
if not AceConsole then
AceConsole = LibStub(AceConsoleName)
end
if AceConsole.RegisterChatCommand(self, slashcmd, function(input)
lib.HandleCommand(self, slashcmd, appName, input) -- upgradable
AceConfigCmd.HandleCommand(self, slashcmd, appName, input) -- upgradable
end,
true) then -- succesfully registered so lets get the command -> app table in
commands[slashcmd] = appName
end
end
 
-- GetChatCommandOptions(slashcmd)
--
-- Utility function that returns the options table that belongs to a slashcommand
-- mainly used by AceTab
 
function lib:GetChatCommandOptions(slashcmd)
--- Utility function that returns the options table that belongs to a slashcommand.
-- Designed to be used for the AceTab interface.
-- @param slashcmd The slash command WITHOUT leading slash (only used for error output)
-- @return The options table associated with the slash command (or nil if the slash command was not registered)
function AceConfigCmd:GetChatCommandOptions(slashcmd)
return commands[slashcmd]
end
trunk/Plink!/Libs/AceDB-3.0/AceDB-3.0.lua
1,17 → 1,61
--- AceDB-3.0 allows you to create profiles and smart default values for the SavedVariables of your addon.
--- **AceDB-3.0** manages the SavedVariables of your addon.
-- It offers profile management, smart defaults and namespaces for modules.\\
-- Data can be saved in different data-types, depending on its intended usage.
-- The most common data-type is the `profile` type, which allows the user to choose
-- the active profile, and manage the profiles of all of his characters.\\
-- The following data types are available:
-- * **char** Character-specific data. Every character has its own database.
-- * **realm** Realm-specific data. All of the players characters on the same realm share this database.
-- * **class** Class-specific data. All of the players characters of the same class share this database.
-- * **race** Race-specific data. All of the players characters of the same race share this database.
-- * **faction** Faction-specific data. All of the players characters of the same faction share this database.
-- * **factionrealm** Faction and realm specific data. All of the players characters on the same realm and of the same faction share this database.
-- * **global** Global Data. All characters on the same account share this database.
-- * **profile** Profile-specific data. All characters using the same profile share this database. The user can control which profile should be used.
--
-- Creating a new Database using the `:New` function will return a new DBObject. A database will inherit all functions
-- of the DBObjectLib listed here. \\
-- If you create a new namespaced child-database (`:RegisterNamespace`), you'll get a DBObject as well, but note
-- that the child-databases cannot individually change their profile, and are linked to their parents profile - and because of that,
-- the profile related APIs are not available. Only `:RegisterDefaults` and `:ResetProfile` are available on child-databases.
--
-- For more details on how to use AceDB-3.0, see the [[AceDB-3.0 Tutorial]].
--
-- You may also be interested in [[libdualspec-1-0|LibDualSpec-1.0]] to do profile switching automatically when switching specs.
--
-- @usage
-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("DBExample")
--
-- -- declare defaults to be used in the DB
-- local defaults = {
-- profile = {
-- setting = true,
-- }
-- }
--
-- function MyAddon:OnInitialize()
-- -- Assuming the .toc says ## SavedVariables: MyAddonDB
-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
-- end
-- @class file
-- @name AceDB-3.0.lua
-- @release $Id: AceDB-3.0.lua 735 2009-02-14 11:10:48Z nevcairiel $
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 10
-- @release $Id: AceDB-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 19
local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR)
 
if not AceDB then return end -- No upgrade needed
 
local type = type
local pairs, next = pairs, next
local rawget, rawset = rawget, rawset
local setmetatable = setmetatable
-- Lua APIs
local type, pairs, next, error = type, pairs, next, error
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
 
-- WoW APIs
local _G = _G
 
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: LibStub
 
AceDB.db_registry = AceDB.db_registry or {}
AceDB.frame = AceDB.frame or CreateFrame("Frame")
 
91,6 → 135,9
 
-- Called to remove all defaults in the default table from the database
local function removeDefaults(db, defaults, blocker)
-- remove all metatables from the db, so we don't accidentally create new sub-tables through them
setmetatable(db, nil)
-- loop through the defaults and remove their content
for k,v in pairs(defaults) do
if k == "*" or k == "**" then
if type(v) == "table" then
105,7 → 152,7
db[key] = nil
end
-- if it was specified, only strip ** content, but block values which were set in the key table
elseif k == "**" then
elseif k == "**" then
removeDefaults(value, v, defaults[key])
end
end
131,28 → 178,26
end
end
end
-- remove all metatables from the db
setmetatable(db, nil)
end
 
-- This is called when a table section is first accessed, to set up the defaults
local function initSection(db, section, svstore, key, defaults)
local sv = rawget(db, "sv")
 
 
local tableCreated
if not sv[svstore] then sv[svstore] = {} end
if not sv[svstore][key] then
sv[svstore][key] = {}
tableCreated = true
end
 
 
local tbl = sv[svstore][key]
 
 
if defaults then
copyDefaults(tbl, defaults)
end
rawset(db, section, tbl)
 
 
return tableCreated, tbl
end
 
164,7 → 209,7
if key then
local defaultTbl = rawget(t, "defaults")
local defaults = defaultTbl and defaultTbl[section]
 
 
if section == "profile" then
local new = initSection(t, section, "profiles", key, defaults)
if new then
186,7 → 231,7
initSection(t, section, section, key, defaults)
end
end
 
 
return rawget(t, section)
end
}
218,15 → 263,29
-- Actual database initialization function
local function initdb(sv, defaults, defaultProfile, olddb, parent)
-- Generate the database keys for each section
 
-- Make a container for profile keys
if not sv.profileKeys then sv.profileKeys = {} end
 
-- Try to get the profile selected from the char db
local profileKey = sv.profileKeys[charKey] or defaultProfile or charKey
sv.profileKeys[charKey] = profileKey
 
-- This table contains keys that enable the dynamic creation
 
-- map "true" to our "Default" profile
if defaultProfile == true then defaultProfile = "Default" end
 
local profileKey
if not parent then
-- Make a container for profile keys
if not sv.profileKeys then sv.profileKeys = {} end
 
-- Try to get the profile selected from the char db
profileKey = sv.profileKeys[charKey] or defaultProfile or charKey
 
-- save the selected profile for later
sv.profileKeys[charKey] = profileKey
else
-- Use the profile of the parents DB
profileKey = parent.keys.profile or defaultProfile or charKey
 
-- clear the profileKeys in the DB, namespaces don't need to store them
sv.profileKeys = nil
end
 
-- This table contains keys that enable the dynamic creation
-- of each section of the table. The 'global' and 'profiles'
-- have a key of true, since they are handled in a special case
local keyTbl= {
240,27 → 299,27
["global"] = true,
["profiles"] = true,
}
 
 
validateDefaults(defaults, keyTbl, 1)
 
 
-- This allows us to use this function to reset an entire database
-- Clear out the old database
if olddb then
for k,v in pairs(olddb) do if not preserve_keys[k] then olddb[k] = nil end end
end
 
 
-- Give this database the metatable so it initializes dynamically
local db = setmetatable(olddb or {}, dbmt)
 
if not rawget(db, "callbacks") then
 
if not rawget(db, "callbacks") then
-- try to load CallbackHandler-1.0 if it loaded after our library
if not CallbackHandler then CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0", true) end
db.callbacks = CallbackHandler and CallbackHandler:New(db) or CallbackDummy
end
 
 
-- Copy methods locally into the database object, to avoid hitting
-- the metatable when calling methods
 
 
if not parent then
for name, func in pairs(DBObjectLib) do
db[name] = func
270,7 → 329,7
db.RegisterDefaults = DBObjectLib.RegisterDefaults
db.ResetProfile = DBObjectLib.ResetProfile
end
 
 
-- Set some properties in the database object
db.profiles = sv.profiles
db.keys = keyTbl
278,10 → 337,10
--db.sv_name = name
db.defaults = defaults
db.parent = parent
 
 
-- store the DB in the registry
AceDB.db_registry[db] = true
 
 
return db
end
 
315,9 → 374,9
if defaults and type(defaults) ~= "table" then
error("Usage: AceDBObject:RegisterDefaults(defaults): 'defaults' - table or nil expected.", 2)
end
 
 
validateDefaults(defaults, self.keys)
 
 
-- Remove any currently set defaults
if self.defaults then
for section,key in pairs(self.keys) do
326,10 → 385,10
end
end
end
 
 
-- Set the DBObject.defaults table
self.defaults = defaults
 
 
-- Copy in any defaults, only touching those sections already created
if defaults then
for section,key in pairs(self.keys) do
347,32 → 406,37
if type(name) ~= "string" then
error("Usage: AceDBObject:SetProfile(name): 'name' - string expected.", 2)
end
 
 
-- changing to the same profile, dont do anything
if name == self.keys.profile then return end
 
 
local oldProfile = self.profile
local defaults = self.defaults and self.defaults.profile
 
 
-- Callback: OnProfileShutdown, database
self.callbacks:Fire("OnProfileShutdown", self)
 
 
if oldProfile and defaults then
-- Remove the defaults from the old profile
removeDefaults(oldProfile, defaults)
end
 
 
self.profile = nil
self.keys["profile"] = name
self.sv.profileKeys[charKey] = name
 
-- if the storage exists, save the new profile
-- this won't exist on namespaces.
if self.sv.profileKeys then
self.sv.profileKeys[charKey] = name
end
 
-- populate to child namespaces
if self.children then
for _, db in pairs(self.children) do
DBObjectLib.SetProfile(db, name)
end
end
 
 
-- Callback: OnProfileChanged, database, newProfileKey
self.callbacks:Fire("OnProfileChanged", self, name)
end
393,7 → 457,7
end
 
local curProfile = self.keys.profile
 
 
local i = 0
for profileKey in pairs(self.profiles) do
i = i + 1
406,7 → 470,7
i = i + 1
tbl[i] = curProfile
end
 
 
return tbl, i
end
 
422,24 → 486,24
if type(name) ~= "string" then
error("Usage: AceDBObject:DeleteProfile(name): 'name' - string expected.", 2)
end
 
 
if self.keys.profile == name then
error("Cannot delete the active profile in an AceDBObject.", 2)
end
 
 
if not rawget(self.sv.profiles, name) and not silent then
error("Cannot delete profile '" .. name .. "'. It does not exist.", 2)
end
 
 
self.sv.profiles[name] = nil
 
 
-- populate to child namespaces
if self.children then
for _, db in pairs(self.children) do
DBObjectLib.DeleteProfile(db, name, true)
end
end
 
 
-- Callback: OnProfileDeleted, database, profileKey
self.callbacks:Fire("OnProfileDeleted", self, name)
end
452,57 → 516,60
if type(name) ~= "string" then
error("Usage: AceDBObject:CopyProfile(name): 'name' - string expected.", 2)
end
 
 
if name == self.keys.profile then
error("Cannot have the same source and destination profiles.", 2)
end
 
 
if not rawget(self.sv.profiles, name) and not silent then
error("Cannot copy profile '" .. name .. "'. It does not exist.", 2)
end
 
 
-- Reset the profile before copying
DBObjectLib.ResetProfile(self)
 
DBObjectLib.ResetProfile(self, nil, true)
 
local profile = self.profile
local source = self.sv.profiles[name]
 
 
copyTable(source, profile)
 
 
-- populate to child namespaces
if self.children then
for _, db in pairs(self.children) do
DBObjectLib.CopyProfile(db, name, true)
end
end
 
 
-- Callback: OnProfileCopied, database, sourceProfileKey
self.callbacks:Fire("OnProfileCopied", self, name)
end
 
--- Resets the current profile to the default values (if specified).
-- @param noChildren if set to true, the reset will not be populated to the child namespaces of this DB object
function DBObjectLib:ResetProfile(noChildren)
-- @param noCallbacks if set to true, won't fire the OnProfileReset callback
function DBObjectLib:ResetProfile(noChildren, noCallbacks)
local profile = self.profile
 
 
for k,v in pairs(profile) do
profile[k] = nil
end
 
 
local defaults = self.defaults and self.defaults.profile
if defaults then
copyDefaults(profile, defaults)
end
 
 
-- populate to child namespaces
if self.children and not noChildren then
for _, db in pairs(self.children) do
DBObjectLib.ResetProfile(db)
DBObjectLib.ResetProfile(db, nil, noCallbacks)
end
end
 
 
-- Callback: OnProfileReset, database
self.callbacks:Fire("OnProfileReset", self)
if not noCallbacks then
self.callbacks:Fire("OnProfileReset", self)
end
end
 
--- Resets the entire database, using the string defaultProfile as the new default
512,16 → 579,16
if defaultProfile and type(defaultProfile) ~= "string" then
error("Usage: AceDBObject:ResetDB(defaultProfile): 'defaultProfile' - string or nil expected.", 2)
end
 
 
local sv = self.sv
for k,v in pairs(sv) do
sv[k] = nil
end
 
 
local parent = self.parent
 
 
initdb(sv, self.defaults, defaultProfile, self)
 
 
-- fix the child namespaces
if self.children then
if not sv.namespaces then sv.namespaces = {} end
530,12 → 597,12
initdb(sv.namespaces[name], db.defaults, self.keys.profile, db, self)
end
end
 
-- Callback: OnDatabaseReset, database
 
-- Callback: OnDatabaseReset, database
self.callbacks:Fire("OnDatabaseReset", self)
-- Callback: OnProfileChanged, database, profileKey
self.callbacks:Fire("OnProfileChanged", self, self.keys["profile"])
 
 
return self
end
 
554,51 → 621,81
if self.children and self.children[name] then
error ("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - a namespace with that name already exists.", 2)
end
 
 
local sv = self.sv
if not sv.namespaces then sv.namespaces = {} end
if not sv.namespaces[name] then
sv.namespaces[name] = {}
end
 
 
local newDB = initdb(sv.namespaces[name], defaults, self.keys.profile, nil, self)
 
 
if not self.children then self.children = {} end
self.children[name] = newDB
return newDB
end
 
--- Returns an already existing namespace from the database object.
-- @param name The name of the new namespace
-- @param silent if true, the addon is optional, silently return nil if its not found
-- @usage
-- local namespace = self.db:GetNamespace('namespace')
-- @return the namespace object if found
function DBObjectLib:GetNamespace(name, silent)
if type(name) ~= "string" then
error("Usage: AceDBObject:GetNamespace(name): 'name' - string expected.", 2)
end
if not silent and not (self.children and self.children[name]) then
error ("Usage: AceDBObject:GetNamespace(name): 'name' - namespace does not exist.", 2)
end
if not self.children then self.children = {} end
return self.children[name]
end
 
--[[-------------------------------------------------------------------------
AceDB Exposed Methods
---------------------------------------------------------------------------]]
 
--- Creates a new database object that can be used to handle database settings
-- and profiles.
-- @param name The name of variable, or table to use for the database
--- Creates a new database object that can be used to handle database settings and profiles.
-- By default, an empty DB is created, using a character specific profile.
--
-- You can override the default profile used by passing any profile name as the third argument,
-- or by passing //true// as the third argument to use a globally shared profile called "Default".
--
-- Note that there is no token replacement in the default profile name, passing a defaultProfile as "char"
-- will use a profile named "char", and not a character-specific profile.
-- @param tbl The name of variable, or table to use for the database
-- @param defaults A table of database defaults
-- @param defaultProfile The name of the default profile
-- @param defaultProfile The name of the default profile. If not set, a character specific profile will be used as the default.
-- You can also pass //true// to use a shared global profile called "Default".
-- @usage
-- -- Create an empty DB using a character-specific default profile.
-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB")
-- @usage
-- -- Create a DB using defaults and using a shared default profile
-- self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, true)
function AceDB:New(tbl, defaults, defaultProfile)
if type(tbl) == "string" then
local name = tbl
tbl = getglobal(name)
tbl = _G[name]
if not tbl then
tbl = {}
setglobal(name, tbl)
_G[name] = tbl
end
end
 
 
if type(tbl) ~= "table" then
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'tbl' - table expected.", 2)
end
 
 
if defaults and type(defaults) ~= "table" then
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaults' - table expected.", 2)
end
 
if defaultProfile and type(defaultProfile) ~= "string" then
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string expected.", 2)
 
if defaultProfile and type(defaultProfile) ~= "string" and defaultProfile ~= true then
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string or true expected.", 2)
end
 
 
return initdb(tbl, defaults, defaultProfile)
end
 
610,5 → 707,6
end
else
db.RegisterDefaults = DBObjectLib.RegisterDefaults
db.ResetProfile = DBObjectLib.ResetProfile
end
end