/trunk/MyThreat
--- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles. |
-- @class file |
-- @name AceDBOptions-3.0 |
-- @release $Id: AceDBOptions-3.0.lua 765 2009-04-03 19:14:41Z nevcairiel $ |
local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 10 |
-- @release $Id: AceDBOptions-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ |
local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 11 |
local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR) |
if not AceDBOptions then return end -- No upgrade needed |
-- Lua APIs |
local pairs, next = pairs, next |
-- WoW APIs |
local UnitClass = UnitClass |
-- 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_CODE, FONT_COLOR_CODE_CLOSE |
AceDBOptions.optionTables = AceDBOptions.optionTables or {} |
AceDBOptions.handlers = AceDBOptions.handlers or {} |
delete_confirm = "Are you sure you want to delete the selected profile?", |
profiles = "Profiles", |
profiles_sub = "Manage Profiles", |
current = "Current Profile:", |
} |
local LOCALE = GetLocale() |
L["delete_confirm"] = "Willst du das ausgew\195\164hlte Profil wirklich l\195\182schen?" |
L["profiles"] = "Profile" |
L["profiles_sub"] = "Profile verwalten" |
--L["current"] = "Current Profile:" |
elseif LOCALE == "frFR" then |
L["default"] = "D\195\169faut" |
L["intro"] = "Vous pouvez changer le profil actuel afin d'avoir des param\195\168tres diff\195\169rents pour chaque personnage, permettant ainsi d'avoir une configuration tr\195\168s flexible." |
L["delete_confirm"] = "Etes-vous s\195\187r de vouloir supprimer le profil s\195\169lectionn\195\169 ?" |
L["profiles"] = "Profils" |
L["profiles_sub"] = "Gestion des profils" |
--L["current"] = "Current Profile:" |
elseif LOCALE == "koKR" then |
L["default"] = "기본ê°" |
L["intro"] = "모ë ìºë¦í°ì ë¤ìí ì¤ì ê³¼ ì¬ì©ì¤ì¸ ë°ì´í°ë² ì´ì¤ íë¡í, ì´ëê²ì´ëì§ ë§¤ì° ë¤ë£¨ê¸° ì½ê² ë°ê¿ì ììµëë¤." |
L["delete_confirm"] = "ì ë§ë¡ ì íí íë¡íì ìì 를 ìíìëê¹?" |
L["profiles"] = "íë¡í" |
L["profiles_sub"] = "íë¡í ì¤ì " |
elseif LOCALE == "esES" then |
--L["current"] = "Current Profile:" |
elseif LOCALE == "esES" or LOCALE == "esMX" then |
L["default"] = "Por defecto" |
L["intro"] = "Puedes cambiar el perfil activo de tal manera que cada personaje tenga diferentes configuraciones." |
L["reset_desc"] = "Reinicia el perfil actual a los valores por defectos, en caso de que se haya estropeado la configuración o quieras volver a empezar de nuevo." |
L["delete_confirm"] = "¿Estas seguro que quieres borrar el perfil seleccionado?" |
L["profiles"] = "Perfiles" |
L["profiles_sub"] = "Manejar Perfiles" |
--L["current"] = "Current Profile:" |
elseif LOCALE == "zhTW" then |
L["default"] = "é è¨" |
L["intro"] = "ä½ å¯ä»¥é¸æä¸åæ´»åçè³æè¨å®æªï¼éæ¨£ä½ çæ¯åè§è²å°±å¯ä»¥ææä¸åçè¨å®å¼ï¼å¯ä»¥çµ¦ä½ çæ件è¨å®å¸¶ä¾æ¥µå¤§çéæ´»æ§ã" |
L["delete_confirm"] = "ä½ ç¢ºå®è¦åªé¤æé¸æçè¨å®æªåï¼" |
L["profiles"] = "è¨å®æª" |
L["profiles_sub"] = "管çè¨å®æª" |
--L["current"] = "Current Profile:" |
elseif LOCALE == "zhCN" then |
L["default"] = "é»è®¤" |
L["intro"] = "ä½ å¯ä»¥éæ©ä¸ä¸ªæ´»å¨çæ°æ®é ç½®æ件ï¼è¿æ ·ä½ çæ¯ä¸ªè§è²å°±å¯ä»¥æ¥æä¸åç设置å¼ï¼å¯ä»¥ç»ä½ çæ件é 置带æ¥æ大ççµæ´»æ§ã" |
L["delete_confirm"] = "ä½ ç¡®å®è¦å é¤æéæ©çé ç½®æ件ä¹ï¼" |
L["profiles"] = "é ç½®æ件" |
L["profiles_sub"] = "管çé ç½®æ件" |
--L["current"] = "Current Profile:" |
elseif LOCALE == "ruRU" then |
L["default"] = "Ðо ÑмолÑаниÑ" |
L["intro"] = "ÐзменÑÑ Ð°ÐºÑивнÑй пÑоÑилÑ, Ð²Ñ Ð¼Ð¾Ð¶ÐµÑе задаÑÑ ÑазлиÑнÑе наÑÑÑойки модиÑикаÑий Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ пеÑÑонажа." |
L["delete_confirm"] = "ÐÑ ÑвеÑенÑ, ÑÑо Ð²Ñ Ñ Ð¾ÑиÑе ÑдалиÑÑ Ð²ÑбÑаннÑй пÑоÑилÑ?" |
L["profiles"] = "ÐÑоÑили" |
L["profiles_sub"] = "УпÑавление пÑоÑилÑми" |
--L["current"] = "Current Profile:" |
end |
local defaultProfiles |
desc = L["reset_sub"], |
func = "Reset", |
}, |
current = { |
order = 11, |
type = "description", |
name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end, |
width = "default", |
}, |
choosedesc = { |
order = 20, |
type = "description", |
-- make into AceEvent. |
-- @class file |
-- @name AceEvent-3.0 |
-- @release $Id: AceEvent-3.0.lua 766 2009-04-04 08:26:05Z 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, |
-- make into AceConsole. |
-- @class file |
-- @name AceConsole-3.0 |
-- @release $Id: AceConsole-3.0.lua 779 2009-04-05 08:52:46Z 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) |
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 |
-- 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 |
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 |
--- 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 text = "" |
if self ~= AceConsole then |
text = "|cff33ff99"..tostring( self ).."|r: " |
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 |
end |
local frame = select(1, ...) |
if not ( type(frame) == "table" and frame.AddMessage ) then -- Is first argument something with an .AddMessage member? |
frame=nil |
--- 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 |
for i=(frame and 2 or 1), select("#", ...) do |
text = text .. tostring( select( i, ...) ) .." " |
end |
(frame or DEFAULT_CHAT_FRAME):AddMessage( text ) |
end |
--- 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) |
local mixins = { |
"Print", |
"Printf", |
"RegisterChatCommand", |
"UnregisterChatCommand", |
"GetArgs", |
--[[ $Id: AceGUIWidget-DropDown.lua 815 2009-07-08 20:58:17Z nevcairiel $ ]]-- |
--[[ $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, ...) |
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, |
do |
local widgetType = "Dropdown" |
local widgetVersion = 20 |
local widgetVersion = 21 |
--[[ Static data ]]-- |
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 |
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]) |
self.SetText = SetText |
self.SetValue = SetValue |
self.GetValue = GetValue |
self.SetList = SetList |
self.SetLabel = SetLabel |
self.SetDisabled = SetDisabled |
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 -- |
-------------------------- |
]] |
do |
local Type = "EditBox" |
local Version = 11 |
local function OnAcquire(self) |
self:SetHeight(26) |
self:SetWidth(200) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
self:SetText() |
end |
local function Control_OnEnter(this) |
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) |
local AceGUI = LibStub("AceGUI-3.0") |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
-------------------------- |
-- Heading -- |
-------------------------- |
local AceGUI = LibStub("AceGUI-3.0") |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
------------- |
-- Widgets -- |
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: GameFontNormal |
---------------- |
-- Main Frame -- |
---------------- |
--[[ |
Events : |
OnClose |
]] |
do |
local Type = "Window" |
local Version = 2 |
local function frameOnClose(this) |
this.obj:Fire("OnClose") |
end |
local function closeOnClick(this) |
this.obj:Hide() |
end |
local function frameOnMouseDown(this) |
AceGUI:ClearFocus() |
end |
local function titleOnMouseDown(this) |
this:GetParent():StartMoving() |
AceGUI:ClearFocus() |
end |
local function frameOnMouseUp(this) |
local frame = this:GetParent() |
frame:StopMovingOrSizing() |
local self = frame.obj |
local status = self.status or self.localstatus |
status.width = frame:GetWidth() |
status.height = frame:GetHeight() |
status.top = frame:GetTop() |
status.left = frame:GetLeft() |
end |
local function sizerseOnMouseDown(this) |
this:GetParent():StartSizing("BOTTOMRIGHT") |
AceGUI:ClearFocus() |
end |
local function sizersOnMouseDown(this) |
this:GetParent():StartSizing("BOTTOM") |
AceGUI:ClearFocus() |
end |
local function sizereOnMouseDown(this) |
this:GetParent():StartSizing("RIGHT") |
AceGUI:ClearFocus() |
end |
local function sizerOnMouseUp(this) |
this:GetParent():StopMovingOrSizing() |
end |
local function SetTitle(self,title) |
self.titletext:SetText(title) |
end |
local function SetStatusText(self,text) |
-- self.statustext:SetText(text) |
end |
local function Hide(self) |
self.frame:Hide() |
end |
local function Show(self) |
self.frame:Show() |
end |
local function OnAcquire(self) |
self.frame:SetParent(UIParent) |
self.frame:SetFrameStrata("FULLSCREEN_DIALOG") |
self:ApplyStatus() |
self:EnableResize(true) |
end |
local function OnRelease(self) |
self.status = nil |
for k in pairs(self.localstatus) do |
self.localstatus[k] = nil |
end |
end |
-- called to set an external table to store status in |
local function SetStatusTable(self, status) |
assert(type(status) == "table") |
self.status = status |
self:ApplyStatus() |
end |
local function ApplyStatus(self) |
local status = self.status or self.localstatus |
local frame = self.frame |
self:SetWidth(status.width or 700) |
self:SetHeight(status.height or 500) |
if status.top and status.left then |
frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top) |
frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0) |
else |
frame:SetPoint("CENTER",UIParent,"CENTER") |
end |
end |
local function OnWidthSet(self, width) |
local content = self.content |
local contentwidth = width - 34 |
if contentwidth < 0 then |
contentwidth = 0 |
end |
content:SetWidth(contentwidth) |
content.width = contentwidth |
end |
local function OnHeightSet(self, height) |
local content = self.content |
local contentheight = height - 57 |
if contentheight < 0 then |
contentheight = 0 |
end |
content:SetHeight(contentheight) |
content.height = contentheight |
end |
local function EnableResize(self, state) |
local func = state and "Show" or "Hide" |
self.sizer_se[func](self.sizer_se) |
self.sizer_s[func](self.sizer_s) |
self.sizer_e[func](self.sizer_e) |
end |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.type = "Window" |
self.Hide = Hide |
self.Show = Show |
self.SetTitle = SetTitle |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetStatusText = SetStatusText |
self.SetStatusTable = SetStatusTable |
self.ApplyStatus = ApplyStatus |
self.OnWidthSet = OnWidthSet |
self.OnHeightSet = OnHeightSet |
self.EnableResize = EnableResize |
self.localstatus = {} |
self.frame = frame |
frame.obj = self |
frame:SetWidth(700) |
frame:SetHeight(500) |
frame:SetPoint("CENTER",UIParent,"CENTER",0,0) |
frame:EnableMouse() |
frame:SetMovable(true) |
frame:SetResizable(true) |
frame:SetFrameStrata("FULLSCREEN_DIALOG") |
frame:SetScript("OnMouseDown", frameOnMouseDown) |
frame:SetScript("OnHide",frameOnClose) |
frame:SetMinResize(240,240) |
frame:SetToplevel(true) |
local titlebg = frame:CreateTexture(nil, "BACKGROUND") |
titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]]) |
titlebg:SetPoint("TOPLEFT", 9, -6) |
titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24) |
local dialogbg = frame:CreateTexture(nil, "BACKGROUND") |
dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]]) |
dialogbg:SetPoint("TOPLEFT", 8, -24) |
dialogbg:SetPoint("BOTTOMRIGHT", -6, 8) |
dialogbg:SetVertexColor(0, 0, 0, .75) |
local topleft = frame:CreateTexture(nil, "BORDER") |
topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) |
topleft:SetWidth(64) |
topleft:SetHeight(64) |
topleft:SetPoint("TOPLEFT") |
topleft:SetTexCoord(0.501953125, 0.625, 0, 1) |
local topright = frame:CreateTexture(nil, "BORDER") |
topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) |
topright:SetWidth(64) |
topright:SetHeight(64) |
topright:SetPoint("TOPRIGHT") |
topright:SetTexCoord(0.625, 0.75, 0, 1) |
local top = frame:CreateTexture(nil, "BORDER") |
top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) |
top:SetHeight(64) |
top:SetPoint("TOPLEFT", topleft, "TOPRIGHT") |
top:SetPoint("TOPRIGHT", topright, "TOPLEFT") |
top:SetTexCoord(0.25, 0.369140625, 0, 1) |
local bottomleft = frame:CreateTexture(nil, "BORDER") |
bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) |
bottomleft:SetWidth(64) |
bottomleft:SetHeight(64) |
bottomleft:SetPoint("BOTTOMLEFT") |
bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1) |
local bottomright = frame:CreateTexture(nil, "BORDER") |
bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) |
bottomright:SetWidth(64) |
bottomright:SetHeight(64) |
bottomright:SetPoint("BOTTOMRIGHT") |
bottomright:SetTexCoord(0.875, 1, 0, 1) |
local bottom = frame:CreateTexture(nil, "BORDER") |
bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) |
bottom:SetHeight(64) |
bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT") |
bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT") |
bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1) |
local left = frame:CreateTexture(nil, "BORDER") |
left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) |
left:SetWidth(64) |
left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT") |
left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT") |
left:SetTexCoord(0.001953125, 0.125, 0, 1) |
local right = frame:CreateTexture(nil, "BORDER") |
right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) |
right:SetWidth(64) |
right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT") |
right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT") |
right:SetTexCoord(0.1171875, 0.2421875, 0, 1) |
local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") |
close:SetPoint("TOPRIGHT", 2, 1) |
close:SetScript("OnClick", closeOnClick) |
self.closebutton = close |
close.obj = self |
local titletext = frame:CreateFontString(nil, "ARTWORK") |
titletext:SetFontObject(GameFontNormal) |
titletext:SetPoint("TOPLEFT", 12, -8) |
titletext:SetPoint("TOPRIGHT", -32, -8) |
self.titletext = titletext |
local title = CreateFrame("Button", nil, frame) |
title:SetPoint("TOPLEFT", titlebg) |
title:SetPoint("BOTTOMRIGHT", titlebg) |
title:EnableMouse() |
title:SetScript("OnMouseDown",titleOnMouseDown) |
title:SetScript("OnMouseUp", frameOnMouseUp) |
self.title = title |
local sizer_se = CreateFrame("Frame",nil,frame) |
sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) |
sizer_se:SetWidth(25) |
sizer_se:SetHeight(25) |
sizer_se:EnableMouse() |
sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown) |
sizer_se:SetScript("OnMouseUp", sizerOnMouseUp) |
self.sizer_se = sizer_se |
local line1 = sizer_se:CreateTexture(nil, "BACKGROUND") |
self.line1 = line1 |
line1:SetWidth(14) |
line1:SetHeight(14) |
line1:SetPoint("BOTTOMRIGHT", -8, 8) |
line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") |
local x = 0.1 * 14/17 |
line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) |
local line2 = sizer_se:CreateTexture(nil, "BACKGROUND") |
self.line2 = line2 |
line2:SetWidth(8) |
line2:SetHeight(8) |
line2:SetPoint("BOTTOMRIGHT", -8, 8) |
line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") |
local x = 0.1 * 8/17 |
line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) |
local sizer_s = CreateFrame("Frame",nil,frame) |
sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0) |
sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) |
sizer_s:SetHeight(25) |
sizer_s:EnableMouse() |
sizer_s:SetScript("OnMouseDown",sizersOnMouseDown) |
sizer_s:SetScript("OnMouseUp", sizerOnMouseUp) |
self.sizer_s = sizer_s |
local sizer_e = CreateFrame("Frame",nil,frame) |
sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25) |
sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) |
sizer_e:SetWidth(25) |
sizer_e:EnableMouse() |
sizer_e:SetScript("OnMouseDown",sizereOnMouseDown) |
sizer_e:SetScript("OnMouseUp", sizerOnMouseUp) |
self.sizer_e = sizer_e |
--Container Support |
local content = CreateFrame("Frame",nil,frame) |
self.content = content |
content.obj = self |
content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32) |
content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13) |
AceGUI:RegisterAsContainer(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
end |
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 |
]] |
do |
local Type = "DropdownGroup" |
local Version = 11 |
local Version = 13 |
local function OnAcquire(self) |
self.dropdown:SetText("") |
self:SetDropdownWidth(200) |
self:SetTitle("") |
end |
local function OnRelease(self) |
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 |
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",4,0) |
titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-4,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 |
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",-3,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) |
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 -- |
------------- |
-------------------------- |
do |
local Type = "ScrollFrame" |
local Version = 4 |
local Version = 9 |
local function OnAcquire(self) |
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 |
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 |
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 |
end |
end |
local createdcount = 0 |
local function OnWidthSet(self, width) |
local content = self.content |
content.width = width |
end |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local frame = CreateFrame("Frame", nil, UIParent) |
local self = {} |
self.type = Type |
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",-20,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",4,-16) |
scrollbar:SetPoint("BOTTOMLEFT",scrollframe,"BOTTOMRIGHT",4,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 |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 808 2009-05-07 14:45:15Z ammo $ ]]-- |
--[[ $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, ...) |
local AceGUI = LibStub("AceGUI-3.0") |
-- WoW APIs |
local _G = _G |
local CreateFrame, UIParent = CreateFrame, UIParent |
-------------------------- |
-- Button -- |
-------------------------- |
do |
local Type = "Button" |
local Version = 11 |
local Version = 12 |
local function OnAcquire(self) |
-- restore default values |
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 |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
end |
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 -- |
-------------------------- |
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 |
do |
local Type = "TreeGroup" |
local Version = 20 |
local Version = 23 |
local DEFAULT_TREE_WIDTH = 175 |
local DEFAULT_TREE_SIZABLE = true |
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 |
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") |
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 |
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 |
--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 |
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 |
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) |
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 |
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) |
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) |
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 |
local AceGUI = LibStub("AceGUI-3.0") |
-- Lua APIs |
local select, max = select, math.max |
-- 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 = "InteractiveLabel" |
local Version = 5 |
local Version = 6 |
local function OnAcquire(self) |
self:SetHeight(18) |
height = image:GetHeight() + label:GetHeight() |
else |
--image on the left |
image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("TOPLEFT",image,"TOPRIGHT",0,0) |
local imageheight = image:GetHeight() |
local labelheight = label:GetHeight() |
--center image with label |
if imageheight > labelheight then |
image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("LEFT",image,"RIGHT",0,0) |
else |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",imagewidth,0) |
image:SetPoint("RIGHT",label,"LEFT",0,0) |
end |
label:SetWidth(width - imagewidth) |
height = math.max(image:GetHeight(), label:GetHeight()) |
height = max(imageheight, labelheight) |
end |
else |
--no image shown |
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 = 10 |
local Version = 11 |
local function OnAcquire(self) |
self:SetHeight(18) |
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 |
--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 = 10 |
local Version = 11 |
--------------------- |
-- Common Elements -- |
--------------------- |
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 |
if value ~= self.lasttext then |
self:Fire("OnTextChanged", value) |
self.lasttext = value |
self.button:Enable() |
if not self.disabled then |
self.button:Enable() |
end |
end |
end) |
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 = 7 |
local Version = 9 |
local function OnAcquire(self) |
self:SetWidth(200) |
local function UpdateText(self) |
local value = self.value or 0 |
if self.ispercent then |
self.editbox:SetText(("%s%%"):format(math.floor(value*1000+0.5)/10)) |
self.editbox:SetText(("%s%%"):format(floor(value*1000+0.5)/10)) |
else |
self.editbox:SetText(math.floor(value*100+0.5)/100) |
self.editbox:SetText(floor(value*100+0.5)/100) |
end |
end |
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 |
frame:SetMinMaxValues(min or 0,max or 100) |
UpdateLabels(self) |
frame:SetValueStep(step or 1) |
if self.value then |
frame:SetValue(self.value) |
end |
frame.setup = nil |
end |
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) |
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 = {} |
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) |
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 -- |
------------- |
do |
local Type = "TabGroup" |
local Version = 20 |
local Version = 24 |
local PaneBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
for _, tab in pairs(self.tabs) do |
tab:Hide() |
end |
self:SetTitle() |
end |
local function Tab_SetText(self, text) |
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 |
local rowwidths = {} |
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 |
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) |
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) |
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 |
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) |
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 |
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 -- |
-------------------------- |
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 -- |
-------------------------- |
]] |
do |
local Type = "CheckBox" |
local Version = 7 |
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) |
self.checked = nil |
self:SetType() |
self:SetDisabled(false) |
self:SetDescription(nil) |
end |
local function CheckBox_OnEnter(this) |
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(24) |
check:SetHeight(24) |
self.check:Show() |
else |
SetDesaturation(self.check, false) |
check:SetWidth(24) |
check:SetHeight(24) |
self.check:Hide() |
end |
end |
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") |
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 = {} |
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 |
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 |
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 |
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 = 10 |
local Version = 11 |
local function OnAcquire(self) |
self:SetHeight(110) |
local n = select('#', ...) |
if n == 4 or n == 8 then |
image:SetTexCoord(...) |
else |
image:SetTexCoord(0, 1, 0, 1) |
end |
else |
self.imageshown = nil |
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) |
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) |
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") |
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 -- |
---------------- |
local AceGUI = LibStub("AceGUI-3.0") |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
------------- |
-- Widgets -- |
do |
local Type = "InlineGroup" |
local Version = 5 |
local Version = 6 |
local function OnAcquire(self) |
self:SetWidth(300) |
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) |
<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"/> |
-- f:AddChild(btn) |
-- @class file |
-- @name AceGUI-3.0 |
-- @release $Id: AceGUI-3.0.lua 815 2009-07-08 20:58:17Z nevcairiel $ |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 25 |
-- @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 {} |
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 |
]] |
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 |
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 |
-- @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 |
widget.content.width = nil |
widget.content.height = nil |
end |
del(widget,widget.type) |
delWidget(widget, widget.type) |
end |
----------- |
: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. |
]] |
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() |
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 |
-- 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 |
--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 |
if child.height == "fill" then |
frame:SetPoint("BOTTOM",content,"BOTTOM") |
isfullheight = true |
break |
end |
end |
-- end |
-- @class file |
-- @name AceAddon-3.0.lua |
-- @release $Id: AceAddon-3.0.lua 777 2009-04-04 20:16:09Z 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) |
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 |
]] |
-- as well as associate it with a slash command. |
-- @class file |
-- @name AceConfig-3.0 |
-- @release $Id: AceConfig-3.0.lua 802 2009-04-11 12:12:37Z nevcairiel $ |
-- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ |
--[[ |
AceConfig-3.0 |
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) |
--- 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 796 2009-04-07 15:48:54Z nevcairiel $ |
-- @release $Id: AceConfigDialog-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ |
local LibStub = LibStub |
local MAJOR, MINOR = "AceConfigDialog-3.0", 34 |
local AceConfigDialog = LibStub:NewLibrary(MAJOR, MINOR) |
local MAJOR, MINOR = "AceConfigDialog-3.0", 41 |
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigDialog then return end |
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 |
]] |
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 |
--Is Never a function or method |
local allIsLiteral = { |
type = true, |
descStyle = true, |
imageWidth = true, |
imageHeight = true, |
} |
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) |
end |
end |
table.sort(keySort, compareOptions) |
tsort(keySort, compareOptions) |
del(tempOrders) |
del(tempNames) |
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 |
if dialog and oldstrata then |
dialog:SetFrameStrata(oldstrata) |
end |
AceConfigDialog: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 |
AceConfigDialog:Open(appName, rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl)) |
del(info) |
end |
for i = 1, select('#', ...) do |
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, ...) |
--validate function returned a message to display |
if rootframe.SetStatusText then |
rootframe:SetStatusText(validated) |
else |
-- TODO: do something else. |
end |
PlaySound("igPlayerInviteDecline") |
del(info) |
rootframe:SetStatusText(name..": Invalid Value") |
end |
end |
else |
-- TODO: do something else |
end |
PlaySound("igPlayerInviteDecline") |
del(info) |
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, ...) |
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, ...) |
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, ...) |
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 |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog: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 |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog: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' |
user.valuechanged = true |
else |
if iscustom then |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog:Open(user.appName, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, unpack(basepath)) |
end |
end |
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 |
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 |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog:Open(user.appName, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, unpack(basepath)) |
end |
end |
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 |
AceConfigDialog:Open(user.appName, user.rootframe, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
AceConfigDialog:Open(user.appName, basepath and unpack(basepath)) |
AceConfigDialog:Open(user.appName, unpack(basepath)) |
end |
end |
end |
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) |
tinsert(valuesort, value) |
end |
end |
table.sort(valuesort) |
tsort(valuesort) |
if controlType then |
control = gui:Create(controlType) |
if not control then |
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 |
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) |
feedpath[i] = path[i] |
end |
BuildPath(feedpath, string.split("\001", uniquevalue)) |
BuildPath(feedpath, ("\001"):split(uniquevalue)) |
local group = options |
for i = 1, #feedpath do |
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]) |
--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" |
end |
if hasChildGroups and not inline then |
local name = GetOptionsMemberValue("name", group, options, path, appName) |
if grouptype == "tab" then |
local tab = gui:Create("TabGroup") |
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 = AceConfigDialog:GetStatusTable(appName, path) |
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" |
AceConfigDialog.OpenFrames[appName]:Hide() |
end |
if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then |
local widget = AceConfigDialog.BlizOptions[appName] |
if not widget:IsVisible() then |
widget:ReleaseChildren() |
for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do |
if not widget:IsVisible() then |
widget:ReleaseChildren() |
end |
end |
end |
this.closing[appName] = nil |
for appName in pairs(this.apps) do |
if AceConfigDialog.OpenFrames[appName] then |
local user = AceConfigDialog.OpenFrames[appName]:GetUserDataTable() |
AceConfigDialog:Open(appName, user.basepath and unpack(user.basepath)) |
AceConfigDialog:Open(appName, unpack(user.basepath or emptyTbl)) |
end |
if AceConfigDialog.BlizOptions and AceConfigDialog.BlizOptions[appName] then |
local widget = AceConfigDialog.BlizOptions[appName] |
local user = widget:GetUserDataTable() |
if widget:IsVisible() then |
AceConfigDialog:Open(widget:GetUserData('appName'), widget, user.basepath and unpack(user.basepath)) |
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 |
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") |
del(path) |
end |
AceConfigDialog.BlizOptions = AceConfigDialog.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') |
AceConfigDialog: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) |
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) |
--- 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 801 2009-04-09 20:34:28Z nevcairiel $ |
-- @release $Id: AceConfigCmd-3.0.lua 897 2009-12-06 17:02:27Z mikk $ |
--[[ |
AceConfigCmd-3.0 |
]] |
-- TODO: handle disabled / hidden |
-- TODO: implement handlers for all types |
-- TODO: plugin args |
local MAJOR, MINOR = "AceConfigCmd-3.0", 9 |
local MAJOR, MINOR = "AceConfigCmd-3.0", 11 |
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigCmd then return end |
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 |
}) |
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)..":") |
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 |
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 |
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 |
--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 |
--- 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.\\ |
-- These functions receive two arguments: "uiType" and "uiName". \\ |
-- 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.\\ |
-- :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 785 2009-04-05 14:57:29Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 9 |
-- @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 AceConfigRegistry then return end |
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: |
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 |
type=isstring, |
name=isstringfunc, |
desc=optstringfunc, |
descStyle=optstring, |
order=optmethodnumber, |
validate=optmethodfalse, |
confirm=optmethodbool, |
}, |
toggle={ |
tristate=optbool, |
image=optstringfunc, |
imageCoords=optmethodtable, |
}, |
tristate={ |
}, |
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 |
--- 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" |
validate(options,errlvl,name) |
end |
--- Fires a ConfigTableChange callback for those listening in on it, allowing config GUIs to refresh. |
--- 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()` |
--- 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. |
-- @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 |
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) |
errlvl=(errlvl or 0)+1 |
validateGetterArgs(uiType, uiName, errlvl) |
local tab = assert(options(uiType, uiName)) |
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 |
--------------------------------------------------------------------- |
-- :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. |
-- can call with (uiType,uiName) to get the table.\\ |
-- If uiType&uiName are given, the table is returned. |
-- @param appName The application name as given to `:RegisterOptionsTable()` |
-- @param uiType The type of UI to get the table for. |
-- @param uiName The name of the library/addon querying the table. |
-- @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 |
-- end |
-- @class file |
-- @name AceDB-3.0.lua |
-- @release $Id: AceDB-3.0.lua 813 2009-07-06 21:36:37Z kaelten $ |
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 15 |
-- @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 _G = getfenv(0) |
-- Lua APIs |
local type, pairs, next, error = type, pairs, next, error |
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget |
local type = type |
local pairs, next = pairs, next |
local rawget, rawset = rawget, rawset |
local setmetatable = setmetatable |
-- 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") |
-- 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 |
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 |
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 |
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 |
initSection(t, section, section, key, defaults) |
end |
end |
return rawget(t, section) |
end |
} |
-- 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 |
-- map "true" to our "Default" profile |
if defaultProfile == true then defaultProfile = "Default" 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 |
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= { |
["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 |
db.RegisterDefaults = DBObjectLib.RegisterDefaults |
db.ResetProfile = DBObjectLib.ResetProfile |
end |
-- Set some properties in the database object |
db.profiles = sv.profiles |
db.keys = keyTbl |
--db.sv_name = name |
db.defaults = defaults |
db.parent = parent |
-- store the DB in the registry |
AceDB.db_registry[db] = true |
return db |
end |
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 |
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 |
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 |
end |
local curProfile = self.keys.profile |
local i = 0 |
for profileKey in pairs(self.profiles) do |
i = i + 1 |
i = i + 1 |
tbl[i] = curProfile |
end |
return tbl, i |
end |
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 |
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 |
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 |
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 |
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 |
--- 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 |
-- @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 |
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" and defaultProfile ~= true then |
error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string or true expected.", 2) |
end |
return initdb(tbl, defaults, defaultProfile) |
end |
--[[ $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) |
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 |
## Interface: 30200 |
## Interface: 30300 |
## Title: MyThreat |
## Notes: Summarized threat information based on the WoW Threat API. |
## Author: Brimm |