/branches/Ace3/Aloft/Libs
local select = select |
-- WoW APIs |
local PlaySound = PlaySound |
local CreateFrame, UIParent = CreateFrame, UIParent |
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded |
]] |
do |
local Type = "CheckBox" |
local Version = 13 |
local Version = 16 |
local function OnAcquire(self) |
self:SetValue(false) |
local self = this.obj |
if not self.disabled then |
self:ToggleChecked() |
if self.checked then |
PlaySound("igMainMenuOptionCheckBoxOn") |
else -- for both nil and false (tristate) |
PlaySound("igMainMenuOptionCheckBoxOff") |
end |
self:Fire("OnValueChanged",self.checked) |
self.text:SetPoint("LEFT",self.check,"RIGHT",0,0) |
end |
self.check:Hide() |
end |
end |
SetDisabled(self, self.disabled) |
end |
local function SetTriState(self, enabled) |
end |
local function OnWidthSet(self, width) |
if self.desc and self.desc:GetText() ~= "" then |
if self.desc and self.desc:GetText() ~= "" and self.desc:GetText() ~= nil then |
self.desc:SetWidth(width - 30) |
self:SetHeight(28 + self.desc:GetHeight()) |
end |
-------------------------- |
do |
local Type = "Icon" |
local Version = 11 |
local Version = 12 |
local function OnAcquire(self) |
self:SetHeight(110) |
if text and text ~= "" then |
self.label:Show() |
self.label:SetText(text) |
self.frame:SetHeight(self.image:GetHeight() + 25) |
self:SetHeight(self.image:GetHeight() + 25) |
else |
self.label:Hide() |
self.frame:SetHeight(self.image:GetHeight() + 10) |
self:SetHeight(self.image:GetHeight() + 10) |
end |
end |
self.image:SetHeight(height) |
--self.frame:SetWidth(width + 30) |
if self.label:IsShown() then |
self.frame:SetHeight(height + 25) |
self:SetHeight(height + 25) |
else |
self.frame:SetHeight(height + 10) |
self:SetHeight(height + 10) |
end |
end |
local pairs, assert, type = pairs, assert, type |
-- WoW APIs |
local PlaySound = PlaySound |
local CreateFrame, UIParent = CreateFrame, UIParent |
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded |
]] |
do |
local Type = "Frame" |
local Version = 9 |
local Version = 11 |
local FrameBackdrop = { |
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", |
end |
local function closeOnClick(this) |
PlaySound("gsTitleOptionExit") |
this.obj:Hide() |
end |
self.frame:SetParent(UIParent) |
self.frame:SetFrameStrata("FULLSCREEN_DIALOG") |
self:ApplyStatus() |
self:Show() |
end |
local function OnRelease(self) |
--[[ $Id: AceGUIWidget-DropDown.lua 877 2009-11-02 15:56:50Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
-- Lua APIs |
local tsort = table.sort |
-- WoW APIs |
local PlaySound = PlaySound |
local UIParent, CreateFrame = UIParent, CreateFrame |
local _G = _G |
do |
local widgetType = "Dropdown" |
local widgetVersion = 21 |
local widgetVersion = 22 |
--[[ Static data ]]-- |
local function Dropdown_TogglePullout(this) |
local self = this.obj |
PlaySound("igMainMenuOptionCheckBoxOn") -- missleading name, but the Blizzard code uses this sound |
if self.open then |
self.open = nil |
self.pullout:Close() |
local tostring = tostring |
-- WoW APIs |
local PlaySound = PlaySound |
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName |
local CreateFrame, UIParent = CreateFrame, UIParent |
local _G = _G |
-- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY |
local Type = "EditBox" |
local Version = 13 |
local Version = 14 |
if not AceGUIEditBoxInsertLink then |
-- upgradeable hook |
local value = this:GetText() |
local cancel = self:Fire("OnEnterPressed",value) |
if not cancel then |
PlaySound("igMainMenuOptionCheckBoxOn") |
HideButton(self) |
end |
end |
local pairs, assert, type = pairs, assert, type |
-- WoW APIs |
local PlaySound = PlaySound |
local CreateFrame, UIParent = CreateFrame, UIParent |
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded |
]] |
do |
local Type = "Window" |
local Version = 2 |
local Version = 4 |
local function frameOnClose(this) |
this.obj:Fire("OnClose") |
end |
local function closeOnClick(this) |
PlaySound("gsTitleOptionExit") |
this.obj:Hide() |
end |
self.frame:SetFrameStrata("FULLSCREEN_DIALOG") |
self:ApplyStatus() |
self:EnableResize(true) |
self:Show() |
end |
local function OnRelease(self) |
-- WoW APIs |
local _G = _G |
local PlaySound = PlaySound |
local CreateFrame, UIParent = CreateFrame, UIParent |
-------------------------- |
-------------------------- |
do |
local Type = "Button" |
local Version = 12 |
local Version = 13 |
local function OnAcquire(self) |
-- restore default values |
end |
local function Button_OnClick(this, ...) |
PlaySound("igMainMenuOption") |
this.obj:Fire("OnClick", ...) |
AceGUI:ClearFocus() |
end |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 877 2009-11-02 15:56:50Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
local select, assert = select, assert |
-- WoW APIs |
local PlaySound = PlaySound |
local CreateFrame = CreateFrame |
local function fixlevels(parent,...) |
-- Does not close the pullout on click. |
do |
local widgetType = "Dropdown-Item-Toggle" |
local widgetVersion = 2 |
local widgetVersion = 3 |
local function UpdateToggle(self) |
if self.value then |
local self = this.obj |
if self.disabled then return end |
self.value = not self.value |
if self.value then |
PlaySound("igMainMenuOptionCheckBoxOn") |
else |
PlaySound("igMainMenuOptionCheckBoxOff") |
end |
UpdateToggle(self) |
self:Fire("OnValueChanged", self.value) |
end |
-------------------------- |
do |
local Type = "Label" |
local Version = 11 |
local Version = 12 |
local function OnAcquire(self) |
self:SetHeight(18) |
self:SetWidth(200) |
self:SetText("") |
self:SetImage(nil) |
self:SetImageSize(16, 16) |
self:SetColor() |
self:SetFontObject() |
end |
local n = select('#', ...) |
if n == 4 or n == 8 then |
image:SetTexCoord(...) |
else |
image:SetTexCoord(0, 1, 0, 1) |
end |
else |
self.imageshown = nil |
local tonumber = tonumber |
-- WoW APIs |
local PlaySound = PlaySound |
local CreateFrame, UIParent = CreateFrame, UIParent |
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded |
-------------------------- |
do |
local Type = "Slider" |
local Version = 9 |
local Version = 10 |
local function OnAcquire(self) |
self:SetWidth(200) |
end |
if value then |
PlaySound("igMainMenuOptionCheckBoxOn") |
self:Fire("OnMouseUp",value) |
end |
end |
local pairs, ipairs, assert, type = pairs, ipairs, assert, type |
-- WoW APIs |
local PlaySound = PlaySound |
local CreateFrame, UIParent = CreateFrame, UIParent |
local _G = _G |
do |
local Type = "TabGroup" |
local Version = 24 |
local Version = 25 |
local PaneBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
local function Tab_OnClick(self) |
if not (self.selected or self.disabled) then |
PlaySound("igCharacterInfoTab") |
self.obj:SelectTab(self.value) |
end |
end |
-- end |
-- @class file |
-- @name AceDB-3.0.lua |
-- @release $Id: AceDB-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ |
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 19 |
-- @release $Id: AceDB-3.0.lua 914 2010-03-08 12:09:22Z nevcairiel $ |
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 20 |
local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR) |
if not AceDB then return end -- No upgrade needed |
-- handle PLAYER_LOGOUT |
-- strip all defaults from all databases |
-- and cleans up empty sections |
local function logoutHandler(frame, event) |
if event == "PLAYER_LOGOUT" then |
for db in pairs(AceDB.db_registry) do |
db.callbacks:Fire("OnDatabaseShutdown", db) |
for section, key in pairs(db.keys) do |
if db.defaults and db.defaults[section] and rawget(db, section) then |
removeDefaults(db[section], db.defaults[section]) |
db:RegisterDefaults(nil) |
-- cleanup sections that are empty without defaults |
local sv = rawget(db, "sv") |
for section in pairs(db.keys) do |
if rawget(sv, section) then |
-- global is special, all other sections have sub-entrys |
-- also don't delete empty profiles on main dbs, only on namespaces |
if section ~= "global" and (section ~= "profiles" or rawget(db, "parent")) then |
for key in pairs(sv[section]) do |
if not next(sv[section][key]) then |
sv[section][key] = nil |
end |
end |
end |
if not next(sv[section]) then |
sv[section] = nil |
end |
end |
end |
end |
--- 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 902 2009-12-12 14:56:14Z nevcairiel $ |
-- @release $Id: AceConfigDialog-3.0.lua 913 2010-02-13 12:16:13Z nevcairiel $ |
local LibStub = LibStub |
local MAJOR, MINOR = "AceConfigDialog-3.0", 43 |
local MAJOR, MINOR = "AceConfigDialog-3.0", 45 |
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigDialog then return end |
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 |
else |
value = math_max(math_min(value,max),min) |
end |
value = math_max(math_min(value,max),min) |
ActivateControl(widget,event,value) |
end |
entry.value = k |
entry.text = GetOptionsMemberValue("name", v, options, path, appName) |
entry.icon = GetOptionsMemberValue("icon", v, options, path, appName) |
entry.iconCoords = GetOptionsMemberValue("iconCoords", v, options, path, appName) |
entry.disabled = CheckOptionDisabled(v, options, path, appName) |
if not tree.children then tree.children = new() end |
tinsert(tree.children,entry) |
-- make into AceSerializer. |
-- @class file |
-- @name AceSerializer-3.0 |
-- @release $Id: AceSerializer-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ |
local MAJOR,MINOR = "AceSerializer-3.0", 2 |
-- @release $Id: AceSerializer-3.0.lua 910 2010-02-11 21:54:24Z mikk $ |
local MAJOR,MINOR = "AceSerializer-3.0", 3 |
local AceSerializer, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceSerializer then return end |
local function SerializeStringHelper(ch) -- Used by SerializeValue for strings |
-- We use \126 ("~") as an escape character for all nonprints plus a few more |
local n = strbyte(ch) |
if n<=32 then -- nonprint + space |
if n==30 then -- v3 / ticket 115: catch a nonprint that ends up being "~^" when encoded... DOH |
return "\126\122" |
elseif n<=32 then -- nonprint + space |
return "\126"..strchar(n+64) |
elseif n==94 then -- value separator |
return "\126\125" |
-- Deserialization functions |
local function DeserializeStringHelper(escape) |
if escape<"~\123" then |
if escape<"~\122" then |
return strchar(strbyte(escape,2,2)-64) |
elseif escape=="~\122" then -- v3 / ticket 115: special case encode since 30+64=94 ("^") - OOPS. |
return "\030" |
elseif escape=="~\123" then |
return "\127" |
elseif escape=="~\124" then |