/
local crayon = AceLibrary("Crayon-2.0") |
local TYPES = { |
a = {var = "DPS", text = L["Your DPS"]}, |
b = {var = "DMG_IN", text = L["Your damage received"]}, |
c = {var = "DMG_OUT", text = L["Your damage dealt"]}, |
d = {var = "HEALING", text = L["Your healing"]}, |
e = {var = "OVERHEAL", text = L["Your over-healing percentage"]}, |
f = {var = "MAXHIT", text = L["Your max hit"]}, |
g = {var = "DPS_IN", text = L["Total DPS In"]}, |
h = {var = "DPS_OUT", text = L["Total DPS Out"]}, |
a = {var = "DPS", text = L["Your DPS"]}, |
b = {var = "DPS_IN", text = L["Total DPS In"]}, |
c = {var = "DPS_OUT", text = L["Total DPS Out"]}, |
d = {var = "HEALING", text = L["Your healing"]}, |
--b = {var = "DMG_IN", text = L["Your damage received"]}, |
--c = {var = "DMG_OUT", text = L["Your damage dealt"]}, |
--e = {var = "OVERHEAL", text = L["Your over-healing percentage"]}, |
--f = {var = "MAXHIT", text = L["Your max hit"]}, |
} |
local recapFu_index = 1 |
local options = { |
type = 'group', |
args = { |
pause = { |
type = 'toggle', |
order = 100, |
name = L["Pause"], |
desc = L["Pause/Resume Monitoring"], |
get = function() |
return recap.Opt.Paused.value |
end, |
set = function() |
Recap_OnClick("Pause") |
end, |
}, |
display = { |
type = 'group', |
order = 102, |
name = L["Display"], |
desc = L["Toggle what is displayed on the panel"], |
args = { |
label = { |
type = 'toggle', |
order = 100, |
name = L["Label"], |
desc = L["Show/Hide the DPS label"], |
get = function() |
return RecapFu.db.profile.showlabel |
end, |
set = function() |
RecapFu.db.profile.showlabel = not RecapFu.db.profile.showlabel |
RecapFu:UpdateText() |
end, |
}, |
dps = { |
type = 'toggle', |
order = 110, |
name = L["DPS"], |
desc = L["Your DPS"], |
get = function() |
return RecapFu.db.profile.DPS |
end, |
set = function() |
RecapFu.db.profile.DPS = not RecapFu.db.profile.DPS |
RecapFu:UpdateText() |
end, |
}, |
dmgin = { |
type = 'toggle', |
order = 120, |
name = L["Received"], |
desc = L["Your damage received"], |
get = function() |
return RecapFu.db.profile.DMG_IN |
end, |
set = function() |
RecapFu.db.profile.DMG_IN = not RecapFu.db.profile.DMG_IN |
RecapFu:UpdateText() |
end, |
}, |
dmgout = { |
type = 'toggle', |
order = 130, |
name = L["Dealt"], |
desc = L["Your damage dealt"], |
get = function() |
return RecapFu.db.profile.DMG_OUT |
end, |
set = function() |
RecapFu.db.profile.DMG_OUT = not RecapFu.db.profile.DMG_OUT |
RecapFu:UpdateText() |
end, |
}, |
healing = { |
type = 'toggle', |
order = 140, |
name = L["Healing"], |
desc = L["Your healing"], |
get = function() |
return RecapFu.db.profile.HEALING |
end, |
set = function() |
RecapFu.db.profile.HEALING = not RecapFu.db.profile.HEALING |
RecapFu:UpdateText() |
end, |
}, |
overheal = { |
type = 'toggle', |
order = 150, |
name = L["Overhealing"], |
desc = L["Your over-healing percentage"], |
get = function() |
return RecapFu.db.profile.OVERHEAL |
end, |
set = function() |
RecapFu.db.profile.OVERHEAL = not RecapFu.db.profile.OVERHEAL |
RecapFu:UpdateText() |
end, |
}, |
maxhit = { |
type = 'toggle', |
order = 160, |
name = L["Max"], |
desc = L["Your max hit"], |
get = function() |
return RecapFu.db.profile.MAXHIT |
end, |
set = function() |
RecapFu.db.profile.MAXHIT = not RecapFu.db.profile.MAXHIT |
RecapFu:UpdateText() |
end, |
}, |
dpsin = { |
type = 'toggle', |
order = 170, |
name = L["DPSin"], |
desc = L["Total DPS In"], |
get = function() |
return RecapFu.db.profile.DPS_IN |
end, |
set = function() |
RecapFu.db.profile.DPS_IN = not RecapFu.db.profile.DPS_IN |
RecapFu:UpdateText() |
end, |
}, |
dpsout = { |
type = 'toggle', |
order = 180, |
name = L["DPSout"], |
desc = L["Total DPS Out"], |
get = function() |
return RecapFu.db.profile.DPS_OUT |
end, |
set = function() |
RecapFu.db.profile.DPS_OUT = not RecapFu.db.profile.DPS_OUT |
RecapFu:UpdateText() |
end, |
}, |
} |
}, |
} |
type = 'group', |
args = { |
pause = { |
type = "toggle", |
order = 100, |
name = L["Pause"], |
desc = L["Pause/Resume Monitoring"], |
get = function() |
return RecapFu.state and ("Stopped" == RecapFu.state); |
end, |
set = function() |
Recap_OnClick("Pause") |
end, |
}, |
display = { |
type = "group", |
order = 102, |
name = L["Display"], |
desc = L["Toggle what is displayed on the panel"], |
args = { |
label = { |
type = "toggle", |
order = 100, |
name = L["Label"], |
desc = L["Show/Hide the DPS label"], |
get = function() |
return RecapFu.db.profile.showlabel |
end, |
set = function() |
RecapFu.db.profile.showlabel = not RecapFu.db.profile.showlabel |
RecapFu:UpdateText() |
end, |
}, |
dps = { |
type = "toggle", |
order = 110, |
name = L["DPS"], |
desc = L["Your DPS"], |
get = function() |
return RecapFu.db.profile.DPS |
end, |
set = function() |
RecapFu.db.profile.DPS = not RecapFu.db.profile.DPS |
RecapFu:UpdateText() |
end, |
}, |
-- dmgin = { |
-- type = "toggle", |
-- order = 120, |
-- name = L["Received"], |
-- desc = L["Your damage received"], |
-- get = function() |
-- return RecapFu.db.profile.DMG_IN |
-- end, |
-- set = function() |
-- RecapFu.db.profile.DMG_IN = not RecapFu.db.profile.DMG_IN |
-- RecapFu:UpdateText() |
-- end, |
-- }, |
-- dmgout = { |
-- type = "toggle", |
-- order = 130, |
-- name = L["Dealt"], |
-- desc = L["Your damage dealt"], |
-- get = function() |
-- return RecapFu.db.profile.DMG_OUT |
-- end, |
-- set = function() |
-- RecapFu.db.profile.DMG_OUT = not RecapFu.db.profile.DMG_OUT |
-- RecapFu:UpdateText() |
-- end, |
-- }, |
healing = { |
type = "toggle", |
order = 140, |
name = L["Healing"], |
desc = L["Your healing"], |
get = function() |
return RecapFu.db.profile.HEALING |
end, |
set = function() |
RecapFu.db.profile.HEALING = not RecapFu.db.profile.HEALING |
RecapFu:UpdateText() |
end, |
}, |
-- overheal = { |
-- type = "toggle", |
-- order = 150, |
-- name = L["Overhealing"], |
-- desc = L["Your over-healing percentage"], |
-- get = function() |
-- return RecapFu.db.profile.OVERHEAL |
-- end, |
-- set = function() |
-- RecapFu.db.profile.OVERHEAL = not RecapFu.db.profile.OVERHEAL |
-- RecapFu:UpdateText() |
-- end, |
-- }, |
-- maxhit = { |
-- type = "toggle", |
-- order = 160, |
-- name = L["Max"], |
-- desc = L["Your max hit"], |
-- get = function() |
-- return RecapFu.db.profile.MAXHIT |
-- end, |
-- set = function() |
-- RecapFu.db.profile.MAXHIT = not RecapFu.db.profile.MAXHIT |
-- RecapFu:UpdateText() |
-- end, |
-- }, |
dpsin = { |
type = "toggle", |
order = 170, |
name = L["DPSin"], |
desc = L["Total DPS In"], |
get = function() |
return RecapFu.db.profile.DPS_IN |
end, |
set = function() |
RecapFu.db.profile.DPS_IN = not RecapFu.db.profile.DPS_IN |
RecapFu:UpdateText() |
end, |
}, |
dpsout = { |
type = "toggle", |
order = 180, |
name = L["DPSout"], |
desc = L["Total DPS Out"], |
get = function() |
return RecapFu.db.profile.DPS_OUT |
end, |
set = function() |
RecapFu.db.profile.DPS_OUT = not RecapFu.db.profile.DPS_OUT |
RecapFu:UpdateText() |
end, |
}, |
} |
}, |
} |
} |
RecapFu:RegisterDB("RecapFuDB") |
RecapFu:RegisterDefaults('profile', { |
showlabel = true, |
DPS = true, |
}) |
RecapFu.version = "2.0." .. string.sub("$Revision: 30568 $", 12, -3) |
RecapFu.date = string.sub("$Date: 2007-03-19 22:48:32 -0400 (Mon, 19 Mar 2007) $", 8, 17) |
RecapFu.hasIcon = "Interface\\AddOns\\Recap\\Recap-Status" |
RecapFu.hasIcon = "Interface\\AddOns\\Recap\\Images\\Recap-Status" |
RecapFu.hasNoColor = true |
RecapFu.canHideText = true |
RecapFu.clickableTooltip = true |
RecapFu.independentProfile = true |
RecapFu.cannotDetachTooltip = true |
RecapFu.OnMenuRequest = options |
RecapFu.defaultPosition = 'LEFT' |
RecapFu:RegisterChatCommand({"/recapfu", "/fubar_recapfu"}, options) |
RecapFu:RegisterDB("RecapFuDB") |
RecapFu:RegisterDefaults('profile', { |
showlabel = true, |
DPS = true, |
}) |
function RecapFu:OnInitialize() |
self.state = "unknown" |
self.viewtype = "unknown" |
self.yourdps = 0 |
self.dpsin = 0 |
self.dpsout = 0 |
self.healing = 0 |
self.dmgin = 0 |
self.dmgout = 0 |
self.overheal = 0 |
self.maxhit = 0 |
end |
function RecapFu:OnEnable() |
self.text = {} |
self.text = {} |
end |
function RecapFu:OnDisable() |
self.text = nil |
self.text = nil |
end |
function RecapFu:OnClick() |
RecapFrame_Toggle() |
RecapFrame_Toggle() |
end |
function RecapFu:UpdateData() |
self:Debug("Update Data") |
self:Debug(" Update Data ") |
if recap.Opt then |
if recap.Opt.State then |
self.state = recap.Opt.State.value or "n/a" |
else |
self.state = "n/a" |
end |
if recap.Opt.View and recap_temp.LastAll then |
self.viewtype = recap_temp.LastAll[recap.Opt.View.value] or "n/a" |
else |
self.viewtype = "n/a" |
end |
else |
self.state = "n/a" |
self.viewtype = "n/a" |
end |
local Player |
if (recapFu_index < recap_temp.ListSize) and (recap_temp.List[recapFu_index].Name == recap_temp.Player) then |
Player = recap_temp.List[recapFu_index] |
else |
local i |
for i=1,(recap_temp.ListSize-1) do |
if recap_temp.List[i].Name==recap_temp.Player then |
recapFu_index = i |
Player = recap_temp.List[i] |
break |
end |
end |
end |
if Player == nil then |
self.dmgin = 0 |
self.dmgout = 0 |
self.maxhit = 0 |
self.healing = 0 |
self.overheal = 0 |
self.dpsin = 0 |
self.dpsout = 0 |
else |
self.dmgin = Player.DmgIn |
self.dmgout = Player.DmgOut |
self.maxhit = Player.MaxHit |
self.healing = Player.Heal |
self.overheal = Player.Over |
end |
if not self.yourdps then |
self.yourdps = RecapMinYourDPS_Text:GetText() |
end |
if not self.dpsin then |
self.dpsin = RecapMinDPSIn_Text:GetText() |
end |
if not self.dpsout then |
self.dpsout = RecapMinDPSOut_Text:GetText() |
end |
self.text.DPS = crayon:White(self.yourdps) |
self.text.DPS_IN = crayon:Red(self.dpsin) |
self.text.DPS_OUT = crayon:Green(self.dpsout) |
self.text.DMG_IN = crayon:Red(self.dmgin) |
self.text.DMG_OUT = crayon:Green(self.dmgout) |
self.text.HEALING = crayon:Colorize("00ffff", self.healing) |
self.text.OVERHEAL = crayon:Colorize("00ffff", self.overheal.."%") |
self.text.MAXHIT = crayon:Orange(self.maxhit) |
self.text.DPS = crayon:White(self.yourdps) |
self.text.DPS_IN = crayon:Red(self.dpsin) |
self.text.DPS_OUT = crayon:Green(self.dpsout) |
self.text.DMG_IN = crayon:Red(self.dmgin) |
self.text.DMG_OUT = crayon:Green(self.dmgout) |
self.text.HEALING = crayon:Colorize("00ffff", self.healing) |
self.text.OVERHEAL = crayon:Colorize("00ffff", self.overheal) .. "%" |
self.text.MAXHIT = crayon:Orange(self.maxhit) |
end |
function RecapFu:UpdateText() |
self:Debug("Update Text") |
-- format the colored status bubble |
if (self:IsIconShown()) then |
if self.state=="Idle" then |
self.iconFrame:SetVertexColor(.5,.5,.5) |
elseif self.state=="Active" then |
self.iconFrame:SetVertexColor(0,1,0) |
elseif self.state=="Stopped" then |
self.iconFrame:SetVertexColor(1,0,0) |
end |
end |
self:Debug(" Update Text") |
-- format the colored status bubble |
if (self:IsIconShown()) then |
if self.state=="Idle" then |
self.iconFrame:SetVertexColor(.5,.5,.5) |
elseif self.state=="Active" then |
self.iconFrame:SetVertexColor(0,1,0) |
elseif self.state=="Stopped" then |
self.iconFrame:SetVertexColor(1,0,0) |
end |
end |
local t = {} |
if self.db.profile.showlabel then |
table.insert(t, L["DPS"]..": ") |
end |
local t = {} |
if self.db.profile.showlabel then |
table.insert(t, L["DPS"]..": ") |
end |
for i,e in self:pairsByKeys(TYPES) do |
if self.db.profile[e.var] then |
table.insert(t, self.text[e.var]) |
end |
end |
for i,e in self:pairsByKeys(TYPES) do |
if self.db.profile[e.var] then |
table.insert(t, self.text[e.var]) |
end |
end |
self:SetText(table.concat(t, " ")) |
self:SetText(table.concat(t, " ")) |
end |
function RecapFu:OnTooltipUpdate() |
self:Debug("Update Tooltip") |
local cat = tablet:AddCategory( |
'columns', 2, |
'child_textR', 1, |
'child_textG', 1, |
'child_textB', 0, |
'child_text2R', 1, |
'child_text2G', 1, |
'child_text2B', 1 |
) |
cat:AddLine('text', L["State"], 'text2', self.state) |
cat:AddLine('text', L["View Type"], 'text2', self.viewtype) |
self:Debug(" Update Tooltip") |
local cat = tablet:AddCategory( |
'columns', 2, |
'child_textR', 1, |
'child_textG', 1, |
'child_textB', 0, |
'child_text2R', 1, |
'child_text2G', 1, |
'child_text2B', 1 |
) |
cat:AddLine('text', L["State"], |
'text2', self.state, |
'func', function(self,ign) Recap_OnClick("Pause") end, |
'arg1', self, |
'arg2', 0 |
) |
cat:AddLine('text', L["View Type"], |
'text2', self.viewtype, |
'func', function(self,ign) Recap_ToggleView() end, |
'arg1', self, |
'arg2', 0 |
) |
local cat = tablet:AddCategory( |
'columns', 2, |
'child_textR', 1, |
'child_textG', 1, |
'child_textB', 0 |
) |
for i,e in self:pairsByKeys(TYPES) do |
cat:AddLine('text', e.text, 'text2', self.text[e.var]) |
end |
tablet:SetHint(L["Left-click to toggle Recap window"]) |
local cat = tablet:AddCategory( |
'columns', 2, |
'child_textR', 1, |
'child_textG', 1, |
'child_textB', 0 |
) |
for i,e in self:pairsByKeys(TYPES) do |
cat:AddLine('text', e.text, 'text2', self.text[e.var]) |
end |
tablet:SetHint(L["Left-click to toggle Recap window"]) |
end |
function RecapFu:pairsByKeys (t, f) |
--taken from an example in the Programming in Lua book |
local a = {} |
for n in pairs(t) do |
table.insert(a, n) |
end |
table.sort(a, f) |
local i = 0 -- iterator variable |
local iter = function () -- iterator function |
i = i + 1 |
if a[i] == nil then |
return nil |
else |
return a[i], t[a[i]] |
end |
end |
return iter |
local a = {} |
for n in pairs(t) do |
table.insert(a, n) |
end |
table.sort(a, f) |
local i = 0 -- iterator variable |
local iter = function () -- iterator function |
i = i + 1 |
if a[i] == nil then |
return nil |
else |
return a[i], t[a[i]] |
end |
end |
return iter |
end |
-- Simulate Titan Panel plugin |
-- Necessary or updates to dps data on the plugin may not occur until after combat ends |
function TitanPanelRecap_Update(state,yourdps,dpsin,dpsout) |
RecapFu.state = state |
RecapFu.yourdps = yourdps |
RecapFu.dpsin = dpsin |
RecapFu.dpsout = dpsout |
RecapFu:Update() |
end |
## Interface: 20003 |
## Interface: 30200 |
## Title: FuBar - |cffffffffRecap|r|cff00ff00Fu|r |
## Notes: FuBar plugin for Recap |
## Author: Prandur |
## X-Credits: Gello (for Recap), Darravis (enhancement ideas) |
## Version: 2.0 |
## Author: Kitjan |
## X-Credits: Hawksy (for Recap) |
## Version: 2.1 |
## X-Category: Combat |
## X-WoWIPortal: prandur |
## X-WoWIPortal: Kitjan |
## Dependencies: FuBar, Recap |
## OptionalDeps: Ace2, FuBarPlugin-2.0, TabletLib, DewdropLib, CrayonLib |
# Core addon |
RecapFu_Locale_enUS.lua |
RecapFu.lua |
--[[ |
--[[ |
Name: Dewdrop-2.0 |
Revision: $Rev: 30385 $ |
Revision: $Rev: 320 $ |
Author(s): ckknight (ckknight@gmail.com) |
Website: http://ckknight.wowinterface.com/ |
Documentation: http://wiki.wowace.com/index.php/Dewdrop-2.0 |
]] |
local MAJOR_VERSION = "Dewdrop-2.0" |
local MINOR_VERSION = "$Revision: 30385 $" |
local MINOR_VERSION = tonumber(strmatch("$Revision: 320 $", "%d+")) + 90000 |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end |
if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
local Dewdrop = {} |
local SharedMedia |
local CLOSE = "Close" |
local CLOSE_DESC = "Close the menu." |
local VALIDATION_ERROR = "Validation error." |
local USAGE_TOOLTIP = "Usage: %s." |
local RANGE_TOOLTIP = "Note that you can scroll your mouse wheel while over the slider to step by one." |
local RESET_KEYBINDING_DESC = "Hit escape to clear the keybinding." |
local KEY_BUTTON1 = "Left Mouse" |
local KEY_BUTTON2 = "Right Mouse" |
CLOSE = "Schlie\195\159en" |
CLOSE_DESC = "Men\195\188 schlie\195\159en." |
VALIDATION_ERROR = "Validierungsfehler." |
USAGE_TOOLTIP = "Benutzung: %s." |
RANGE_TOOLTIP = "Beachte das du mit dem Mausrad scrollen kannst solange du mit dem Mauszeiger \195\188ber dem Schieberegler bist, um feinere Spr\195\188nge zu machen." |
RESET_KEYBINDING_DESC = "Escape dr\195\188cken, um die Tastenbelegung zu l\195\182schen." |
KEY_BUTTON1 = "Linke Maustaste" |
KEY_BUTTON2 = "Rechte Maustaste" |
DISABLED = "Deaktiviert" |
DEFAULT_CONFIRM_MESSAGE = "Bist du sicher das du `%s' machen willst?" |
elseif GetLocale() == "koKR" then |
CLOSE = "ë«ê¸°" |
CLOSE_DESC = "ë©ë´ë¥¼ ë«ìµëë¤." |
VALIDATION_ERROR = "ì¤ë¥ íì¸." |
USAGE_TOOLTIP = "ì¬ì©ë²: %s." |
RANGE_TOOLTIP = "ì림 : ì¬ë¼ì´ë ììì ë§ì°ì¤ í ì ì¬ì©íë©´ íë¨ê³ì© ì¡°ì í ì ììµëë¤." |
RESET_KEYBINDING_DESC = "ë¨ì¶í¤ë¥¼ í´ì íë ¤ë©´ ESCí¤ë¥¼ ë르ì¸ì." |
KEY_BUTTON1 = "ì¼ìª½ ë§ì°ì¤" |
KEY_BUTTON2 = "ì¤ë¥¸ìª½ ë§ì°ì¤" |
DISABLED = "ë¹íì±íë¨" |
DEFAULT_CONFIRM_MESSAGE = "ì ë§ë¡ `%s' ì¤íì íìê² ìµëê¹ ?" |
elseif GetLocale() == "frFR" then |
CLOSE = "Fermer" |
CLOSE_DESC = "Ferme le menu." |
VALIDATION_ERROR = "Erreur de validation." |
USAGE_TOOLTIP = "Utilisation : %s." |
RANGE_TOOLTIP = "Vous pouvez aussi utiliser la molette de la souris pour pour modifier progressivement." |
RESET_KEYBINDING_DESC = "Appuyez sur la touche Echappement pour effacer le raccourci." |
KEY_BUTTON1 = "Clic gauche" |
KEY_BUTTON2 = "Clic droit" |
DISABLED = "D\195\169sactiv\195\169" |
DEFAULT_CONFIRM_MESSAGE = "\195\138tes-vous s\195\187r de vouloir effectuer '%s' ?" |
elseif GetLocale() == "esES" then |
CLOSE = "Cerrar" |
CLOSE_DESC = "Cierra el men\195\186." |
VALIDATION_ERROR = "Error de validaci\195\179n" |
RESET_KEYBINDING_DESC = "Pulsa Escape para limpiar la asignaci\195\179n de tecla." |
CLOSE_DESC = "Cierra el menú." |
VALIDATION_ERROR = "Error de validación." |
USAGE_TOOLTIP = "Uso: %s." |
RANGE_TOOLTIP = "Puedes desplazarte verticalmente con la rueda del ratón sobre el desplazador." |
RESET_KEYBINDING_DESC = "Pulsa Escape para borrar la asignación de tecla." |
KEY_BUTTON1 = "Clic Izquierdo" |
KEY_BUTTON2 = "Clic Derecho" |
DISABLED = "Desactivado" |
DEFAULT_CONFIRM_MESSAGE = "¿Estás seguro de querer realizar `%s'?" |
elseif GetLocale() == "zhTW" then |
CLOSE = "éé" |
CLOSE_DESC = "ééé¸å®ã" |
VALIDATION_ERROR = "é©èé¯èª¤ã" |
USAGE_TOOLTIP = "ç¨æ³: %sã" |
RANGE_TOOLTIP = "ä½ å¯ä»¥å¨æ²åæ¢ä¸ä½¿ç¨æ»é¼ 滾輪ä¾æ²åã" |
RESET_KEYBINDING_DESC = "æEscéµæ¸ é¤å¿«æ·éµã" |
KEY_BUTTON1 = "æ»é¼ å·¦éµ" |
KEY_BUTTON2 = "æ»é¼ å³éµ" |
DISABLED = "åç¨" |
DEFAULT_CONFIRM_MESSAGE = "æ¯å¦å·è¡ã%sã?" |
elseif GetLocale() == "zhCN" then |
CLOSE = "å ³é" |
CLOSE_DESC = "å ³éèå" |
VALIDATION_ERROR = "éªè¯é误." |
USAGE_TOOLTIP = "ç¨æ³: %s." |
RANGE_TOOLTIP = "ä½ å¯ä»¥å¨æ»å¨æ¡ä¸ä½¿ç¨é¼ æ æ»è½®æ¥ç¿»é¡µ." |
RESET_KEYBINDING_DESC = "æESCé®æ¸ é¤æé®ç»å®" |
KEY_BUTTON1 = "é¼ æ å·¦é®" |
KEY_BUTTON2 = "é¼ æ å³é®" |
DISABLED = "ç¦ç¨" |
DEFAULT_CONFIRM_MESSAGE = "æ¯å¦æ§è¡'%s'?" |
elseif GetLocale() == "ruRU" then |
CLOSE = "ÐакÑÑÑÑ" |
CLOSE_DESC = "ÐакÑÑÑÑ Ð¼ÐµÐ½Ñ." |
VALIDATION_ERROR = "ÐÑибка пÑовеÑки даннÑÑ ." |
USAGE_TOOLTIP = "ÐÑполÑзÑйÑе: %s." |
RANGE_TOOLTIP = "ÐÑполÑзÑйÑе колеÑо мÑÑи Ð´Ð»Ñ Ð¿ÑокÑÑÑки ползÑнка." |
RESET_KEYBINDING_DESC = "ÐажмиÑе клавиÑÑ Escape Ð´Ð»Ñ Ð¾ÑиÑÑки клавиÑи." |
KEY_BUTTON1 = "ÐÐÐ" |
KEY_BUTTON2 = "ÐÐÐ" |
DISABLED = "ÐÑклÑÑено" |
DEFAULT_CONFIRM_MESSAGE = "ÐÑ ÑвеÑÐµÐ½Ñ ÑÑо Ð²Ñ Ñ Ð¾ÑиÑе вÑполнÑÑÑ `%s'?" |
end |
Dewdrop.KEY_BUTTON1 = KEY_BUTTON1 |
local levels |
local buttons |
-- Secure frame handling: |
-- Rather than using secure buttons in the menu (has problems), we have one |
-- master secureframe that we pop onto menu items on mouseover. This requires |
-- some dark magic with OnLeave etc, but it's not too bad. |
local secureFrame = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate") |
secureFrame:Hide() |
local function secureFrame_Show(self) |
local owner = self.owner |
if self.secure then -- Leftovers from previos owner, clean up! ("Shouldn't" happen but does..) |
for k,v in pairs(self.secure) do |
self:SetAttribute(k, nil) |
end |
end |
self.secure = owner.secure; -- Grab hold of new secure data |
local scale = owner:GetEffectiveScale() |
self:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", owner:GetLeft() * scale, owner:GetTop() * scale) |
self:SetPoint("BOTTOMRIGHT", nil, "BOTTOMLEFT", owner:GetRight() * scale, owner:GetBottom() * scale) |
self:EnableMouse(true) |
for k,v in pairs(self.secure) do |
self:SetAttribute(k, v) |
end |
secureFrame:SetFrameStrata(owner:GetFrameStrata()) |
secureFrame:SetFrameLevel(owner:GetFrameLevel()+1) |
self:Show() |
end |
local function secureFrame_Hide(self) |
self:Hide() |
if self.secure then |
for k,v in pairs(self.secure) do |
self:SetAttribute(k, nil) |
end |
end |
self.secure = nil |
end |
secureFrame:SetScript("OnEvent", |
function() |
if event=="PLAYER_REGEN_ENABLED" then |
this.combat = false |
if not this:IsShown() and this.owner then |
secureFrame_Show(this) |
end |
elseif event=="PLAYER_REGEN_DISABLED" then |
this.combat = true |
if this:IsShown() then |
secureFrame_Hide(this) |
end |
end |
end |
) |
secureFrame:RegisterEvent("PLAYER_REGEN_ENABLED") |
secureFrame:RegisterEvent("PLAYER_REGEN_DISABLED") |
secureFrame:SetScript("OnLeave", |
function() |
local owner=this.owner |
this:Deactivate() |
owner:GetScript("OnLeave")() |
end |
) |
secureFrame:HookScript("OnClick", |
function() |
local realthis = this |
this = this.owner |
this:GetScript("OnClick")() |
end |
) |
function secureFrame:IsOwnedBy(frame) |
return self.owner == frame |
end |
function secureFrame:Activate(owner) |
if self.owner then -- "Shouldn't" happen but apparently it does and I cba to troubleshoot... |
if not self.combat then |
secureFrame_Hide(self) |
end |
end |
self.owner = owner |
if not self.combat then |
secureFrame_Show(self) |
end |
end |
function secureFrame:Deactivate() |
if not self.combat then |
secureFrame_Hide(self) |
end |
self.owner = nil |
end |
-- END secure frame utilities |
-- Underline on mouseover - use a single global underline that we move around, no point in creating lots of copies |
local underlineFrame = CreateFrame("Frame", nil) |
underlineFrame.tx = underlineFrame:CreateTexture() |
underlineFrame.tx:SetTexture(1,1,0.5,0.75) |
underlineFrame:SetScript("OnHide", function(this) this:Hide(); end) |
underlineFrame:SetScript("OnShow", function(this) -- change sizing on the fly to catch runtime uiscale changes |
underlineFrame.tx:SetPoint("TOPLEFT", -1, -2/this:GetEffectiveScale()) |
underlineFrame.tx:SetPoint("RIGHT", 1,0) |
underlineFrame.tx:SetHeight(0.6 / this:GetEffectiveScale()); |
end) |
underlineFrame:SetHeight(1) |
-- END underline on mouseover |
local function GetScaledCursorPosition() |
local x, y = GetCursorPosition() |
local scale = UIParent:GetEffectiveScale() |
level:SetWidth(width + 20) |
if level:GetLeft() and level:GetRight() and level:GetTop() and level:GetBottom() and (level:GetLeft() < 0 or level:GetRight() > GetScreenWidth() or level:GetTop() > GetScreenHeight() or level:GetBottom() < 0) then |
level:ClearAllPoints() |
local parent = level.parent or level:GetParent() |
if type(parent) ~= "table" then |
parent = UIParent |
end |
if level.lastDirection == "RIGHT" then |
if level.lastVDirection == "DOWN" then |
level:SetPoint("TOPLEFT", level.parent or level:GetParent(), "TOPRIGHT", 5, 10) |
level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) |
else |
level:SetPoint("BOTTOMLEFT", level.parent or level:GetParent(), "BOTTOMRIGHT", 5, -10) |
level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) |
end |
else |
if level.lastVDirection == "DOWN" then |
level:SetPoint("TOPRIGHT", level.parent or level:GetParent(), "TOPLEFT", -5, 10) |
level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) |
else |
level:SetPoint("BOTTOMRIGHT", level.parent or level:GetParent(), "BOTTOMLEFT", -5, -10) |
level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) |
end |
end |
end |
end |
if dirty then |
level:ClearAllPoints() |
local parent = level.parent or level:GetParent() |
if type(parent) ~= "table" then |
parent = UIParent |
end |
if level.lastDirection == "RIGHT" then |
if level.lastVDirection == "DOWN" then |
level:SetPoint("TOPLEFT", level.parent or level:GetParent(), "TOPRIGHT", 5, 10) |
level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) |
else |
level:SetPoint("BOTTOMLEFT", level.parent or level:GetParent(), "BOTTOMRIGHT", 5, -10) |
level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) |
end |
else |
if level.lastVDirection == "DOWN" then |
level:SetPoint("TOPRIGHT", level.parent or level:GetParent(), "TOPLEFT", -5, 10) |
level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) |
else |
level:SetPoint("BOTTOMRIGHT", level.parent or level:GetParent(), "BOTTOMLEFT", -5, -10) |
level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) |
end |
end |
end |
local sliderFrame |
local editBoxFrame |
local normalFont |
local lastSetFont |
local justSetFont = false |
local regionTmp = {} |
local function fillRegionTmp(...) |
for i = 1, select('#', ...) do |
regionTmp[i] = select(i, ...) |
end |
end |
local function showGameTooltip(this) |
if this.tooltipTitle or this.tooltipText then |
GameTooltip_SetDefaultAnchor(GameTooltip, this) |
local disabled = not this.isTitle and this.disabled |
local font |
if this.tooltipTitle then |
if SharedMedia and SharedMedia:IsValid("font", this.tooltipTitle) then |
font = SharedMedia:Fetch("font", this.tooltipTitle) |
end |
if disabled then |
GameTooltip:SetText(this.tooltipTitle, 0.5, 0.5, 0.5, 1) |
else |
GameTooltip:SetText(this.tooltipTitle, 1, 1, 1, 1) |
end |
if this.tooltipText then |
if not font and SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then |
font = SharedMedia:Fetch("font", this.tooltipText) |
end |
if disabled then |
GameTooltip:AddLine(this.tooltipText, (NORMAL_FONT_COLOR.r + 0.5) / 2, (NORMAL_FONT_COLOR.g + 0.5) / 2, (NORMAL_FONT_COLOR.b + 0.5) / 2, 1) |
else |
end |
end |
else |
if SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then |
font = SharedMedia:Fetch("font", this.tooltipText) |
end |
if disabled then |
GameTooltip:SetText(this.tooltipText, 0.5, 0.5, 0.5, 1) |
else |
GameTooltip:SetText(this.tooltipText, 1, 1, 1, 1) |
end |
end |
if font then |
fillRegionTmp(GameTooltip:GetRegions()) |
lastSetFont = font |
justSetFont = true |
for i,v in ipairs(regionTmp) do |
if v.SetFont then |
local norm,size,outline = v:GetFont() |
v:SetFont(font, size, outline) |
if not normalFont then |
normalFont = norm |
end |
end |
regionTmp[i] = nil |
end |
elseif not normalFont then |
fillRegionTmp(GameTooltip:GetRegions()) |
for i,v in ipairs(regionTmp) do |
if v.GetFont and not normalFont then |
normalFont = v:GetFont() |
end |
regionTmp[i] = nil |
end |
end |
GameTooltip:Show() |
end |
if this.tooltipFunc then |
end |
self:Close(this.level.num + 1) |
if not this.disabled then |
if this.hasSlider then |
if this.secure then |
secureFrame:Activate(this) |
elseif this.hasSlider then |
OpenSlider(self, this) |
elseif this.hasEditBox then |
OpenEditBox(self, this) |
if this.isRadio then |
button.radioHighlight:Show() |
end |
if this.mouseoverUnderline then |
underlineFrame:SetParent(this) |
underlineFrame:SetPoint("BOTTOMLEFT",this.text,0,0) |
underlineFrame:SetWidth(this.text:GetWidth()) |
underlineFrame:Show() |
end |
end |
showGameTooltip(this) |
end) |
button:SetScript("OnHide", function() |
if this.secure and secureFrame:IsOwnedBy(this) then |
secureFrame:Deactivate() |
end |
end) |
button:SetScript("OnLeave", function() |
if this.secure and secureFrame:IsShown() then |
return; -- it's ok, we didn't actually mouse out of the button, only onto the secure frame on top of it |
end |
underlineFrame:Hide() |
if not this.selected then |
highlight:Hide() |
end |
Dewdrop:Close(i+1) |
end |
value = levels[i].value |
end |
end |
end |
elseif this.closeWhenClicked then |
self:Close() |
arrow:SetWidth(16) |
arrow:SetHeight(16) |
arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow") |
local colorSwatch = button:CreateTexture(nil, "OVERLAY") |
local colorSwatch = button:CreateTexture(nil, "ARTWORK") |
button.colorSwatch = colorSwatch |
colorSwatch:SetWidth(20) |
colorSwatch:SetHeight(20) |
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch") |
local texture = button:CreateTexture(nil, "OVERLAY") |
colorSwatch.texture = texture |
texture:SetTexture(1, 1, 1) |
texture:SetTexture("Interface\\Buttons\\WHITE8X8") |
texture:SetWidth(11.5) |
texture:SetHeight(11.5) |
texture:Show() |
level.parented = true |
level:ClearAllPoints() |
if level.num == 1 then |
if level.parent ~= UIParent then |
if level.parent ~= UIParent and type(level.parent) == "table" then |
level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT") |
else |
level:SetPoint("CENTER", level.parent, "CENTER") |
level:SetPoint("CENTER", UIParent, "CENTER") |
end |
else |
if level.lastDirection == "RIGHT" then |
end |
end |
end |
local fullscreenFrame = GetFullScreenFrame() |
local fullscreenFrame = GetUIPanel("fullscreen") |
local l = levels[level] |
local strata, framelevel = l:GetFrameStrata(), l:GetFrameLevel() |
if fullscreenFrame then |
local kind = options.type |
if type(kind) ~= "string" then |
return '"type" must be a string.', position |
elseif kind ~= "group" and kind ~= "range" and kind ~= "text" and kind ~= "execute" and kind ~= "toggle" and kind ~= "color" and kind ~= "header" then |
return '"type" must either be "range", "text", "group", "toggle", "execute", "color", or "header".', position |
elseif kind ~= "group" and kind ~= "range" and kind ~= "text" and kind ~= "execute" and kind ~= "toggle" and kind ~= "color" and kind ~= "dragLink" and kind ~= "header" then |
return '"type" must either be "range", "text", "group", "toggle", "execute", "color", "dragLink", or "header".', position |
end |
if options.aliases then |
if type(options.aliases) ~= "table" and type(options.aliases) ~= "string" then |
return '"func" must be a string or function', position |
end |
end |
else |
if kind == "group" then |
return 'cannot have "type" = "group" as a subgroup of a passing group', position |
end |
end |
if options ~= baseOptions then |
if kind == "header" then |
return '"step" must be nonnegative', position |
end |
end |
if options.bigStep then |
if type(options.bigStep) ~= "number" then |
return '"bigStep" must be a number', position |
elseif options.bigStep < 0 then |
return '"bigStep" must be nonnegative', position |
end |
end |
if options.isPercent and options.isPercent ~= true then |
return '"isPercent" must either be nil, true, or false', position |
end |
t.timeout = 0 |
t.whileDead = 1 |
t.hideOnEscape = 1 |
Dewdrop:Close() |
StaticPopup_Show("DEWDROP20_CONFIRM_DIALOG") |
end |
local function getMethod(settingname, handler, v, methodName, ...) -- "..." is simply returned straight out cause you can't do "a,b,c = 111,f(),222" |
assert(v and type(v)=="table") |
assert(methodName and type(methodName)=="string") |
local method = v[methodName] |
if type(method)=="function" then |
return method, ... |
elseif type(method)=="string" then |
if not handler then |
Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method) |
elseif not handler[method] then |
Dewdrop:error("[%s] 'handler' method %q not defined", tostring(settingname), method) |
end |
return handler[method], handler, ... |
end |
Dewdrop:error("[%s] Missing %q directive", tostring(settingname), methodName) |
end |
local function callMethod(settingname, handler, v, methodName, ...) |
assert(v and type(v)=="table") |
assert(methodName and type(methodName)=="string") |
local method = v[methodName] |
if type(method)=="function" then |
local success, ret,ret2,ret3,ret4 = pcall(v[methodName], ...) |
if not success then |
geterrorhandler()(ret) |
return nil |
end |
return ret,ret2,ret3,ret4 |
elseif type(method)=="string" then |
local neg = method:match("^~(.-)$") |
if neg then |
method = neg |
end |
if not handler then |
Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method) |
elseif not handler[method] then |
Dewdrop:error("[%s] 'handler' (%q) method %q not defined", tostring(settingname), handler.name or "(unnamed)", method) |
end |
local success, ret,ret2,ret3,ret4 = pcall(handler[method], handler, ...) |
if not success then |
geterrorhandler()(ret) |
return nil |
end |
if neg then |
return not ret |
end |
return ret,ret2,ret3,ret4 |
elseif method == false then |
return nil |
end |
Dewdrop:error("[%s] Missing %q directive in %q", tostring(settingname), methodName, v.name or "(unnamed)") |
end |
local function skip1Nil(...) |
if select(1,...)==nil then |
return select(2,...) |
end |
return ... |
end |
function Dewdrop:FeedAceOptionsTable(options, difference) |
self:argCheck(options, 2, "table") |
self:argCheck(difference, 3, "nil", "number") |
end |
local current = level |
while current do |
while current do -- this traverses from higher level numbers to lower, building "values" with leaf nodes first and trunk nodes later |
if current.num == difference + 1 then |
break |
end |
local handler = options.handler |
local passTable |
local passValue |
while #values > 0 do |
passTable = options.pass and options or nil |
while #values > 0 do -- This loop traverses values from the END (trunk nodes first, then onto leaf nodes) |
if options.pass then |
if options.get and options.set then |
passTable = options |
elseif not passTable then |
passTable = options |
end |
else |
passTable = nil |
end |
local value = table.remove(values) |
options = options.args and options.args[value] |
if not options then |
end |
if options.type == "group" then |
local hidden, disabled = options.hidden |
if hidden then |
if type(hidden) == "function" then |
hidden = hidden() |
elseif type(hidden) == "string" then |
local f = hidden |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
hidden = handler[f](handler) |
if neg then |
hidden = not hidden |
end |
end |
local hidden = options.hidden |
if type(hidden) == "function" or type(hidden) == "string" then |
hidden = callMethod(options.name or "(options root)", handler, options, "hidden", options.passValue) or false |
end |
if hidden then |
return |
end |
local disabled = options.disabled |
if disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
hidden = handler[f](handler) |
if neg then |
disabled = not disabled |
end |
end |
if type(disabled) == "function" or type(disabled) == "string" then |
disabled = callMethod(options.name or "(options root)", handler, options, "disabled", options.passValue) or false |
end |
if disabled then |
self:AddLine( |
for k in pairs(options.args) do |
table.insert(values, k) |
end |
passTable = options.pass and options or nil |
if options.pass then |
if options.get and options.set then |
passTable = options |
elseif not passTable then |
passTable = options |
end |
else |
passTable = nil |
end |
if not mysort then |
mysort = function(a, b) |
local alpha, bravo = mysort_args[a], mysort_args[b] |
local bravo_name = bravo.guiName or bravo.name |
if alpha_order == bravo_order then |
if not alpha_name then |
return true |
return bravo_name |
elseif not bravo_name then |
return false |
else |
self:AddLine() |
end |
local hidden, disabled = v.guiHidden or v.hidden, v.disabled |
if type(hidden) == "function" then |
local success |
success, hidden = pcall(hidden) |
if not success then |
geterrorhandler()(hidden) |
hidden = false |
end |
elseif type(hidden) == "string" then |
local f = hidden |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
local success |
success, hidden = pcall(handler[f], handler) |
if not success then |
geterrorhandler()(hidden) |
hidden = false |
end |
if neg then |
hidden = not hidden |
end |
if type(hidden) == "function" or type(hidden) == "string" then |
hidden = callMethod(k, handler, v, "hidden", v.passValue) or false |
end |
if not hidden then |
if type(disabled) == "function" then |
local success |
success, disabled = pcall(disabled) |
if not success then |
geterrorhandler()(disabled) |
disabled = false |
end |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
local success |
success, disabled = pcall(handler[f], handler) |
if not success then |
geterrorhandler()(disabled) |
disabled = false |
end |
if neg then |
disabled = not disabled |
end |
if type(disabled) == "function" or type(disabled) == "string" then |
disabled = callMethod(k, handler, v, "disabled", v.passValue) or false |
end |
local name = (v.guiIconOnly and v.icon) and "" or (v.guiName or v.name) |
local desc = v.desc |
local desc = v.guiDesc or v.desc |
local iconHeight = v.iconHeight or 16 |
local iconWidth = v.iconWidth or 16 |
local iconCoordLeft = v.iconCoordLeft |
tooltipText = USAGE_TOOLTIP:format(v.usage) |
end |
end |
local v_p = passTable or v |
local passValue = passTable and k or nil |
local v_p = passTable |
if not v_p or (v.type ~= "execute" and v.get and v.set) or (v.type == "execute" and v.func) then |
v_p = v |
end |
local passValue = v.passValue or (v_p~=v and k) or nil |
if v.type == "toggle" then |
local checked |
local checked_arg |
if type(v_p.get) == "function" then |
local success, ret = pcall(v_p.get, passValue) |
if success then |
checked = ret |
else |
geterrorhandler()(ret) |
checked = false |
end |
checked_arg = checked |
else |
local f = v_p.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
if not handler[f] then |
Dewdrop:error("Handler %q not available", f) |
end |
local success, ret = pcall(handler[f], handler, passValue) |
if success then |
checked = ret |
else |
geterrorhandler()(ret) |
checked = false |
end |
checked_arg = checked |
if neg then |
checked = not checked |
end |
local checked = callMethod(name, handler, v_p, "get", passValue) or false |
local checked_arg = checked |
if type(v_p.get)=="string" and v_p.get:match("^~") then |
checked_arg = not checked |
end |
local func, arg1, arg2, arg3 |
if type(v_p.set) == "function" then |
func = v_p.set |
if passValue then |
arg1 = passValue |
arg2 = not checked_arg |
else |
arg1 = not checked_arg |
end |
else |
if not handler[v_p.set] then |
Dewdrop:error("Handler %q not available", v_p.set) |
end |
func = handler[v_p.set] |
arg1 = handler |
if passValue then |
arg2 = passValue |
arg3 = not checked_arg |
else |
arg2 = not checked_arg |
end |
end |
local func, arg1, arg2, arg3 = getMethod(name, handler, v_p, "set", skip1Nil(passValue, not checked_arg)) |
if v.guiNameIsMap then |
checked = checked and true or false |
name = tostring(v.map and v.map[checked]):gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1") |
local confirm = v.confirm |
if confirm == true then |
confirm = DEFAULT_CONFIRM_MESSAGE:format(tooltipText or tooltipTitle) |
end |
if type(v_p.func) == "function" then |
if confirm then |
func = confirmPopup |
arg1 = confirm |
arg2 = v_p.func |
arg3 = passValue |
else |
func = v_p.func |
arg1 = passValue |
end |
func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue) |
elseif type(confirm) == "string" then |
func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue) |
else |
if not handler[v_p.func] then |
Dewdrop:error("Handler %q not available", v_p.func) |
end |
if confirm then |
func = confirmPopup |
arg1 = confirm |
arg2 = handler[v_p.func] |
arg3 = handler |
arg4 = passValue |
else |
func = handler[v_p.func] |
arg1 = handler |
arg2 = passValue |
end |
func,arg1,arg2 = getMethod(name, handler, v_p, "func", passValue) |
end |
self:AddLine( |
'text', name, |
) |
elseif v.type == "range" then |
local sliderValue |
if type(v_p.get) == "function" then |
local success, ret = pcall(v_p.get, passValue) |
if success then |
sliderValue = ret |
else |
geterrorhandler()(ret) |
sliderValue = 0 |
end |
sliderValue = callMethod(name, handler, v_p, "get", passValue) or 0 |
local sliderFunc, sliderArg1, sliderArg2 = getMethod(name, handler, v_p, "set", passValue) |
if tooltipText then |
tooltipText = format("%s\n\n%s", tooltipText, RANGE_TOOLTIP) |
else |
if not handler[v_p.get] then |
Dewdrop:error("Handler %q not available", v_p.get) |
end |
local success, ret = pcall(handler[v_p.get], handler, passValue) |
if success then |
sliderValue = ret |
else |
geterrorhandler()(ret) |
sliderValue = 0 |
end |
tooltipText = RANGE_TOOLTIP |
end |
local sliderFunc, sliderArg1, sliderArg2 |
if type(v_p.set) == "function" then |
sliderFunc = v_p.set |
sliderArg1 = passValue |
else |
if not handler[v_p.set] then |
Dewdrop:error("Handler %q not available", v_p.set) |
end |
sliderFunc = handler[v_p.set] |
sliderArg1 = handler |
sliderArg2 = passValue |
end |
self:AddLine( |
'text', name, |
'hasArrow', true, |
'sliderMin', v.min or 0, |
'sliderMax', v.max or 1, |
'sliderStep', v.step or 0, |
'sliderBigStep', v.bigStep or nil, |
'sliderIsPercent', v.isPercent or false, |
'sliderValue', sliderValue, |
'sliderFunc', sliderFunc, |
'sliderArg1', sliderArg1, |
'sliderArg2', sliderArg2, |
'fromAceOptions', true, |
'disabled', disabled, |
'tooltipTitle', tooltipTitle, |
'tooltipText', tooltipText, |
'iconCoordBottom', iconCoordBottom |
) |
elseif v.type == "color" then |
local r,g,b,a |
if type(v_p.get) == "function" then |
local success |
success, r, g, b, a = pcall(v_p.get, passValue) |
if not success then |
geterrorhandler()(r) |
r, g, b, a = 0, 0, 0, 0 |
end |
else |
if not handler[v_p.get] then |
Dewdrop:error("Handler %q not available", v_p.get) |
end |
local success |
success, r, g, b, a = pcall(handler[v_p.get], handler, passValue) |
if not success then |
geterrorhandler()(r) |
r, g, b, a = 0, 0, 0, 0 |
end |
local r,g,b,a = callMethod(name, handler, v_p, "get", passValue) |
if not r then |
r,g,b,a = 0,0,0,0 |
end |
local colorFunc, colorArg1, colorArg2 |
if type(v_p.set) == "function" then |
colorFunc = v_p.set |
colorArg1 = passValue |
else |
if not handler[v_p.set] then |
Dewdrop:error("Handler %q not available", v_p.set) |
end |
colorFunc = handler[v_p.set] |
colorArg1 = handler |
colorArg2 = passValue |
end |
local colorFunc, colorArg1, colorArg2 = getMethod(name, handler, v_p, "set", passValue) |
self:AddLine( |
'text', name, |
'hasArrow', true, |
'tooltipText', tooltipText |
) |
elseif v.type == "text" then |
if type(v.validate) == "table" then |
if type(v.validate) == "table" then |
local func,arg1,arg2 |
if v.onClick then |
func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue) |
end |
local checked |
if v.isChecked then |
checked = callMethod(name, handler, v, "isChecked", passValue) or false |
end |
self:AddLine( |
'text', name, |
'hasArrow', true, |
'value', k, |
'func', func, |
'arg1', arg1, |
'arg2', arg2, |
'mouseoverUnderline', func and true or nil, |
'disabled', disabled, |
'checked', checked, |
'tooltipTitle', tooltipTitle, |
'tooltipText', tooltipText, |
'icon', v.icon, |
) |
else |
local editBoxText |
if type(v_p.get) == "function" then |
local success, ret = pcall(v_p.get, passValue) |
if success then |
editBoxText = ret |
else |
geterrorhandler()(ret) |
editBoxText = "" |
end |
elseif v_p.get == false then |
editBoxText = nil |
else |
if not handler[v_p.get] then |
Dewdrop:error("Handler %q not available", v_p.get) |
end |
local success, ret = pcall(handler[v_p.get], handler, passValue) |
if success then |
editBoxText = ret |
else |
geterrorhandler()(ret) |
editBoxText = "" |
end |
end |
local editBoxFunc, editBoxArg1, editBoxArg2 |
if type(v_p.set) == "function" then |
editBoxFunc = v_p.set |
editBoxArg1 = passValue |
else |
if not handler[v_p.set] then |
Dewdrop:error("Handler %q not available", v_p.set) |
end |
editBoxFunc = handler[v_p.set] |
editBoxArg1 = handler |
editBoxArg2 = passValue |
end |
editBoxText = callMethod(name, handler, v_p, "get", passValue) or "" |
local editBoxFunc, editBoxArg1, editBoxArg2 = getMethod(name, handler, v_p, "set", passValue) |
local editBoxValidateFunc, editBoxValidateArg1 |
if v.validate and v.validate ~= "keybinding" then |
if type(v.validate) == "function" then |
editBoxValidateFunc = v.validate |
else |
if not handler[v.validate] then |
Dewdrop:error("Handler %q not available", v.validate) |
if v.validate == "keybinding" then |
if tooltipText then |
tooltipText = format("%s\n\n%s", tooltipText, RESET_KEYBINDING_DESC) |
else |
tooltipText = RESET_KEYBINDING_DESC |
end |
editBoxValidateFunc = handler[v.validate] |
editBoxValidateArg1 = handler |
end |
elseif v.validate then |
if tooltipText then |
tooltipText = tooltipText .. "\n\n" .. RESET_KEYBINDING_DESC |
else |
tooltipText = RESET_KEYBINDING_DESC |
editBoxValidateFunc, editBoxValidateArg1 = getMethod(name, handler, v, "validate") -- no passvalue! |
end |
end |
self:AddLine( |
'text', name, |
'hasArrow', true, |
) |
end |
elseif v.type == "group" then |
local func,arg1,arg2 |
if v.onClick then |
func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue) |
end |
local checked |
if v.isChecked then |
checked = callMethod(name, handler, v, "isChecked", passValue) or false |
end |
self:AddLine( |
'text', name, |
'hasArrow', true, |
'value', k, |
'func', func, |
'arg1', arg1, |
'arg2', arg2, |
'mouseoverUnderline', func and true or nil, |
'disabled', disabled, |
'checked', checked, |
'tooltipTitle', tooltipTitle, |
'tooltipText', tooltipText, |
'icon', v.icon, |
end |
elseif options.type == "text" and type(options.validate) == "table" then |
local current |
local options_p = passTable or options |
local multiToggle = options_p.multiToggle |
local options_p = passTable |
if not options_p or (options.get and options.set) then |
options_p = options |
passTable = nil |
passValue = nil |
end |
local multiToggle = options.multiToggle |
local passValue = options.passValue or passValue |
if not multiToggle then |
if type(options_p.get) == "function" then |
current = options_p.get(passValue) |
elseif options_p.get ~= false then |
if not handler[options_p.get] then |
Dewdrop:error("Handler %q not available", options_p.get) |
end |
current = handler[options_p.get](handler, passValue) |
end |
current = callMethod(k, handler, options_p, "get", passValue) |
end |
local indexed = true |
for k,v in pairs(options.validate) do |
if type(k) == "number" then |
k = v |
end |
local func, arg1, arg2, arg3, arg4 |
if type(options_p.set) == "function" then |
func = options_p.set |
if passValue then |
arg1 = passValue |
arg2 = k |
else |
arg1 = k |
end |
else |
if not handler[options_p.set] then |
Dewdrop:error("Handler %q not available", options_p.set) |
end |
func = handler[options_p.set] |
arg1 = handler |
if passValue then |
arg2 = passValue |
arg3 = k |
else |
arg2 = k |
end |
end |
local func, arg1, arg2, arg3, arg4 = getMethod(k, handler, options_p, "set", skip1Nil(passValue, k)) |
local checked |
if multiToggle then |
if type(options_p.get) == "function" then |
if passValue == nil then |
checked = options_p.get(k) |
else |
checked = options_p.get(passValue, k) |
end |
elseif options_p.get ~= false then |
if not handler[options_p.get] then |
Dewdrop:error("Handler %q not available", options_p.get) |
end |
if passValue == nil then |
checked = handler[options_p.get](handler, k) |
else |
checked = handler[options_p.get](handler, passValue, k) |
end |
end |
checked = callMethod(k, handler, options_p, "get", skip1Nil(passValue, k)) or false |
if arg2 == nil then |
arg2 = not checked |
elseif arg3 == nil then |
func, arg1, arg2, arg3, arg4 = nil, nil, nil, nil, nil |
end |
end |
local tooltipTitle |
local tooltipText |
if options.validateDesc then |
tooltipTitle = v |
tooltipText = options.validateDesc[k] |
else |
tooltipTitle = options.guiName or options.name |
tooltipText = v |
end |
self:AddLine( |
'text', v, |
'func', func, |
'arg4', arg4, |
'isRadio', not multiToggle, |
'checked', checked, |
'tooltipTitle', options.guiName or options.name, |
'tooltipText', v |
'tooltipTitle', tooltipTitle, |
'tooltipText', tooltipText |
) |
end |
for k in pairs(values) do |
return true |
end |
function Dewdrop:FeedTable(s, difference) |
self:argCheck(s, 2, "table") |
self:argCheck(difference, 3, "nil", "number") |
if not currentLevel then |
self:error("Cannot call `FeedTable' outside of a Dewdrop declaration") |
end |
if not difference then |
difference = 0 |
end |
local level = levels[currentLevel] |
if not level then |
self:error("Improper level given") |
end |
if not values then |
values = {} |
else |
for k,v in pairs(values) do |
values[k] = nil |
end |
end |
local t = s.subMenu and s or {subMenu = s} |
local current = level |
while current do |
if current.num == difference + 1 then |
break |
end |
table.insert(values, current.value) |
current = levels[current.num - 1] |
end |
while #values > 0 do |
local value = table.remove(values) |
t = t.subMenu and t.subMenu[value] |
if not t then |
return |
end |
end |
if t.subMenu or current.num == 1 then |
for k in pairs(t.subMenu) do |
table.insert(values, k) |
end |
table.sort(values) |
for _,k in ipairs(values) do |
local argTable = {"value", k} |
for key, val in pairs(t.subMenu[k]) do |
table.insert(argTable, key) |
table.insert(argTable, val) |
end |
self:AddLine(unpack(argTable)) |
end |
for k in pairs(values) do |
values[k] = nil |
end |
return false |
end |
return true |
end |
function Refresh(self, level) |
if type(level) == "number" then |
level = levels[level] |
end |
function Dewdrop:Refresh(level) |
self:argCheck(level, 2, "number") |
Refresh(self, levels[level]) |
self:argCheck(level, 2, "number", "nil") |
if not level then |
for k,v in pairs(levels) do |
Refresh(self, v) |
end |
else |
Refresh(self, levels[level]) |
end |
end |
function OpenSlider(self, parent) |
if not sliderFrame then |
sliderFrame = CreateFrame("Frame", nil, nil) |
sliderFrame:SetWidth(80) |
sliderFrame:SetWidth(100) |
sliderFrame:SetHeight(170) |
sliderFrame:SetScale(UIParent:GetScale()) |
sliderFrame:SetBackdrop(tmp( |
sliderFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) |
sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) |
sliderFrame:EnableMouse(true) |
sliderFrame:EnableMouseWheel(true) |
sliderFrame:Hide() |
sliderFrame:SetPoint("CENTER", UIParent, "CENTER") |
local slider = CreateFrame("Slider", nil, sliderFrame) |
sliderFrame.slider = slider |
slider:SetOrientation("VERTICAL") |
slider:SetMinMaxValues(0, 1) |
slider:SetValueStep(0.01) |
slider:SetValueStep(0.000000001) |
slider:SetValue(0.5) |
slider:SetWidth(16) |
slider:SetHeight(128) |
text:SetFontObject(GameFontGreenSmall) |
text:SetText("0%") |
text:SetPoint("TOP", slider, "BOTTOM") |
local text = slider:CreateFontString(nil, "ARTWORK") |
sliderFrame.currentText = text |
text:SetFontObject(GameFontHighlightSmall) |
text:SetText("50%") |
text:SetPoint("LEFT", slider, "RIGHT") |
text:SetPoint("RIGHT", sliderFrame, "RIGHT", -6, 0) |
text:SetJustifyH("CENTER") |
local editBox = CreateFrame("EditBox", nil, sliderFrame) |
sliderFrame.currentText = editBox |
editBox:SetFontObject(ChatFontNormal) |
editBox:SetHeight(13) |
editBox:SetPoint("RIGHT", sliderFrame, "RIGHT", -16, 0) |
editBox:SetPoint("LEFT", slider, "RIGHT", 12, 0) |
editBox:SetText("50%") |
editBox:SetJustifyH("CENTER") |
local width = editBox:GetWidth()/2 + 10 |
local left = editBox:CreateTexture(nil, "BACKGROUND") |
left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left") |
left:SetTexCoord(0, width / 256, 0, 1) |
left:SetWidth(width) |
left:SetHeight(32) |
left:SetPoint("LEFT", editBox, "LEFT", -10, 0) |
local right = editBox:CreateTexture(nil, "BACKGROUND") |
right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right") |
right:SetTexCoord(1 - width / 256, 1, 0, 1) |
right:SetWidth(width) |
right:SetHeight(32) |
right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0) |
local changed = false |
local inside = false |
slider:SetScript("OnValueChanged", function() |
if sliderFrame.parent and sliderFrame.parent.sliderFunc then |
local min = sliderFrame.parent.sliderMin or 0 |
local max = sliderFrame.parent.sliderMax or 1 |
local step = sliderFrame.parent.sliderStep or (max - min) / 100 |
local step |
if sliderFrame.fineStep then |
step = sliderFrame.parent.sliderStep or (max - min) / 100 |
else |
step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100 |
end |
local value = (1 - slider:GetValue()) * (max - min) + min |
if step > 0 then |
value = math.floor((value - min) / step + 0.5) * step + min |
end |
sliderFrame.lastValue = value |
local text = sliderFrame.parent.sliderFunc(getArgs(sliderFrame.parent, 'sliderArg', 1, value)) |
if text then |
if sliderFrame.parent.fromAceOptions then |
text = nil |
elseif type(text) == "string" or type(text) == "number" then |
sliderFrame.currentText:SetText(text) |
done = true |
end |
if not done then |
local min = sliderFrame.parent.sliderMin or 0 |
local max = sliderFrame.parent.sliderMax or 1 |
local step = sliderFrame.parent.sliderStep or (max - min) / 100 |
local step |
if sliderFrame.fineStep then |
step = sliderFrame.parent.sliderStep or (max - min) / 100 |
else |
step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100 |
end |
local value = (1 - slider:GetValue()) * (max - min) + min |
if step > 0 then |
value = math.floor((value - min) / step + 0.5) * step + min |
end |
end |
end) |
sliderFrame:SetScript("OnEnter", function() |
local function onEnter() |
StopCounting(self, sliderFrame.level) |
showGameTooltip(sliderFrame.parent) |
end) |
end |
local function onLeave() |
GameTooltip:Hide() |
end |
sliderFrame:SetScript("OnEnter", onEnter) |
sliderFrame:SetScript("OnLeave", function() |
StartCounting(self, sliderFrame.level) |
GameTooltip:Hide() |
if changed then |
local parent = sliderFrame.parent |
local sliderFunc = parent.sliderFunc |
for i = 1, sliderFrame.level - 1 do |
Refresh(self, levels[i]) |
end |
local newParent |
for _,button in ipairs(levels[sliderFrame.level-1].buttons) do |
if button.sliderFunc == sliderFunc then |
newParent = button |
break |
end |
end |
if newParent then |
OpenSlider(self, newParent) |
else |
sliderFrame:Hide() |
end |
end |
end) |
editBox:SetScript("OnEnter", onEnter) |
editBox:SetScript("OnLeave", onLeave) |
slider:SetScript("OnMouseDown", function() |
sliderFrame.mouseDown = true |
GameTooltip:Hide() |
end) |
slider:SetScript("OnLeave", function() |
inside = false |
StartCounting(self, sliderFrame.level) |
GameTooltip:Hide() |
if changed and not sliderFrame.mouseDown then |
local parent = sliderFrame.parent |
else |
sliderFrame:Hide() |
end |
changed = false |
end |
end) |
sliderFrame:SetScript("OnMouseWheel", function(t, a1) |
local arg1 = a1 or arg1 |
local up = arg1 > 0 |
local min = sliderFrame.parent.sliderMin or 0 |
local max = sliderFrame.parent.sliderMax or 1 |
local step = sliderFrame.parent.sliderStep or (max - min) / 100 |
if step <= 0 then |
step = (max - min) / 100 |
end |
local value = (1 - slider:GetValue()) * (max - min) + min |
if up then |
value = value + step |
else |
value = value - step |
end |
if value > max then |
value = max |
elseif value < min then |
value = min |
end |
sliderFrame.fineStep = true |
if max<=min then |
slider:SetValue(0) |
else |
slider:SetValue(1 - (value - min) / (max - min)) |
end |
sliderFrame.fineStep = nil |
end) |
slider:SetScript("OnMouseWheel", sliderFrame:GetScript("OnMouseWheel")) |
editBox:SetScript("OnEnterPressed", function(t, a1) |
local value = editBox:GetNumber() |
if sliderFrame.parent.sliderIsPercent then |
value = value / 100 |
end |
local min = sliderFrame.parent.sliderMin or 0 |
local max = sliderFrame.parent.sliderMax or 1 |
if value > max then |
value = max |
elseif value < min then |
value = min |
end |
sliderFrame.fineStep = true |
if max <= min then |
slider:SetValue(0) |
else |
slider:SetValue(1 - (value - min) / (max - min)) |
end |
sliderFrame.fineStep = nil |
StartCounting(self, sliderFrame.level) |
end) |
editBox:SetScript("OnEscapePressed", function() |
self:Close(sliderFrame.level) |
StartCounting(self, sliderFrame.level) |
end) |
editBox:SetAutoFocus(false) |
end |
sliderFrame.parent = parent |
sliderFrame.level = parent.level.num + 1 |
sliderFrame.parentValue = parent.level.value |
sliderFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3) |
sliderFrame.slider:SetFrameLevel(sliderFrame:GetFrameLevel() + 1) |
sliderFrame.currentText:SetFrameLevel(sliderFrame:GetFrameLevel() + 1) |
sliderFrame.currentText:ClearFocus() |
sliderFrame.changing = true |
if not parent.sliderMin or not parent.sliderMax then |
return |
if not parent.sliderValue then |
parent.sliderValue = (parent.sliderMin + parent.sliderMax) / 2 |
end |
sliderFrame.slider:SetValue(1 - (parent.sliderValue - parent.sliderMin) / (parent.sliderMax - parent.sliderMin)) |
if parent.sliderMax <= parent.sliderMin then |
sliderFrame.slider:SetValue(0) |
else |
sliderFrame.slider:SetValue(1 - (parent.sliderValue - parent.sliderMin) / (parent.sliderMax - parent.sliderMin)) |
end |
sliderFrame.changing = false |
sliderFrame.bottomText:SetText(parent.sliderMinText or "0") |
sliderFrame.topText:SetText(parent.sliderMaxText or "1") |
local text |
if parent.sliderFunc then |
if parent.sliderFunc and not parent.fromAceOptions then |
text = parent.sliderFunc(getArgs(parent, 'sliderArg', 1, parent.sliderValue)) |
end |
if text then |
if type(text) == "number" or type(text) == "string" then |
sliderFrame.currentText:SetText(text) |
elseif parent.sliderIsPercent then |
sliderFrame.currentText:SetText(string.format("%.0f%%", parent.sliderValue * 100)) |
else |
sliderFrame.currentText:SetText(parent.sliderValue) |
if parent.sliderStep < 0.1 then |
sliderFrame.currentText:SetText(string.format("%.2f", parent.sliderValue)) |
elseif parent.sliderStep < 1 then |
sliderFrame.currentText:SetText(string.format("%.1f", parent.sliderValue)) |
else |
sliderFrame.currentText:SetText(string.format("%.0f", parent.sliderValue)) |
end |
end |
sliderFrame.lastValue = parent.sliderValue |
local level = parent.level |
sliderFrame:Show() |
sliderFrame:ClearAllPoints() |
right:SetWidth(100) |
right:SetHeight(32) |
right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0) |
editBox:SetScript("OnEnterPressed", function() |
if editBoxFrame.parent and editBoxFrame.parent.editBoxValidateFunc then |
local t = editBox.realText or editBox:GetText() or "" |
end |
if text ~= oldText then |
changing = true |
self:SetText(text) |
self:SetText(tostring(text)) |
changing = false |
skipNext = true |
end |
Screenshot() |
return |
end |
if arg1 == "LeftButton" then |
arg1 = "BUTTON1" |
elseif arg1 == "RightButton" then |
editBoxFrame.editBox:SetFrameLevel(editBoxFrame:GetFrameLevel() + 1) |
editBoxFrame.editBox.realText = nil |
editBoxFrame:SetClampedToScreen(false) |
editBoxFrame.editBox:SpecialSetText("") |
if parent.editBoxIsKeybinding then |
local s = parent.editBoxText |
else |
editBoxFrame.editBox:SpecialSetText(parent.editBoxText) |
end |
editBoxFrame.editBox.keybinding = parent.editBoxIsKeybinding |
editBoxFrame.editBox.keybindingOnly = parent.editBoxKeybindingOnly |
editBoxFrame.editBox.keybindingExcept = parent.editBoxKeybindingExcept |
end |
function Dewdrop:IsOpen(parent) |
self:argCheck(parent, 2, "table", "nil") |
self:argCheck(parent, 2, "table", "string", "nil") |
return levels[1] and levels[1]:IsShown() and (not parent or parent == levels[1].parent or parent == levels[1]:GetParent()) |
end |
DewdropLib:GetInstance('1.0'):Close() |
end |
end |
parent:GetCenter() |
if type(parent) == "table" then |
parent:GetCenter() |
end |
local frame = AcquireLevel(self, level) |
if level == 1 then |
frame.lastDirection = "RIGHT" |
-- levels[level].parentTooltipTitle = parent.tooltipTitle |
-- levels[level].parentTooltipText = parent.tooltipText |
-- levels[level].parentTooltipFunc = parent.tooltipFunc |
if parent.arrow then |
if type(parent) == "table" and parent.arrow then |
-- parent.arrow:SetVertexColor(0.2, 0.6, 0) |
-- parent.arrow:SetHeight(24) |
-- parent.arrow:SetWidth(24) |
point, relativePoint = point .. "RIGHT", relativePoint .. "LEFT" |
end |
end |
frame:SetPoint(point, parent, relativePoint) |
frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint) |
if cursorX and cursorY then |
local left = frame:GetLeft() |
local width = frame:GetWidth() |
if curX > GetScreenWidth() / 2 then |
xOffset = -width |
end |
frame:SetPoint(point, parent, relativePoint, curX - left + xOffset, curY - bottom + yOffset) |
frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left + xOffset, curY - bottom + yOffset) |
if level == 1 then |
frame.lastDirection = "RIGHT" |
end |
point = "RIGHT" |
end |
end |
frame:SetPoint(point, parent, relativePoint, curX - left - width / 2, 0) |
frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left - width / 2, 0) |
if level == 1 then |
frame.lastDirection = "RIGHT" |
end |
point = "TOP" |
end |
end |
frame:SetPoint(point, parent, relativePoint, 0, curY - bottom - height / 2) |
frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, 0, curY - bottom - height / 2) |
if level == 1 then |
frame.lastDirection = "DOWN" |
end |
end |
function Dewdrop:IsRegistered(parent) |
self:argCheck(parent, 2, "table") |
self:argCheck(parent, 2, "table", "string") |
return not not self.registry[parent] |
end |
function Dewdrop:Register(parent, ...) |
self:argCheck(parent, 2, "table") |
self:argCheck(parent, 2, "table", "string") |
if self.registry[parent] then |
self:Unregister(parent) |
end |
local info = new(...) |
if type(info.children) == "table" then |
local err, position = validateOptions(info.children) |
if err then |
if position then |
Dewdrop:error(position .. ": " .. err) |
end |
end |
self.registry[parent] = info |
if not info.dontHook and not self.onceRegistered[parent] then |
if not info.dontHook and not self.onceRegistered[parent] and type(parent) == "table" then |
if parent:HasScript("OnMouseUp") then |
local script = parent:GetScript("OnMouseUp") |
parent:SetScript("OnMouseUp", function() |
parent:SetScript("OnMouseUp", function(this, ...) |
if script then |
script() |
script(this, ...) |
end |
if arg1 == "RightButton" and self.registry[parent] then |
if self:IsOpen(parent) then |
end |
if parent:HasScript("OnMouseDown") then |
local script = parent:GetScript("OnMouseDown") |
parent:SetScript("OnMouseDown", function() |
parent:SetScript("OnMouseDown", function(this, ...) |
if script then |
script() |
script(this, ...) |
end |
if self.registry[parent] then |
self:Close() |
end |
function Dewdrop:Unregister(parent) |
self:argCheck(parent, 2, "table") |
self:argCheck(parent, 2, "table", "string") |
self.registry[parent] = nil |
end |
function Dewdrop:Open(parent, ...) |
self:argCheck(parent, 2, "table") |
self:argCheck(parent, 2, "table", "string") |
local info |
local k1 = ... |
if type(k1) == "table" and k1[0] and k1.IsFrameType and self.registry[k1] then |
info = tmp() |
info = tmp(select(2, ...)) |
for k,v in pairs(self.registry[k1]) do |
info[k] = v |
if info[k] == nil then |
info[k] = v |
end |
end |
else |
info = tmp(...) |
end |
end |
function Dewdrop:AddSeparator(level) |
level = levels[level or currentLevel] |
if not level or not level.buttons then return; end |
local prevbutton = level.buttons[#level.buttons] |
if not prevbutton then return; end |
if prevbutton.disabled and prevbutton.text:GetText() == "" then |
return |
end |
self:AddLine("text", "", "disabled", true) |
end |
function Dewdrop:AddLine(...) |
local info = tmp(...) |
local level = info.level or currentLevel |
if not next(info) then |
info.disabled = true |
end |
button.disabled = info.isTitle or info.notClickable or info.disabled |
button.disabled = info.isTitle or info.notClickable or info.disabled or (self.combat and info.secure) |
button.isTitle = info.isTitle |
button.notClickable = info.notClickable |
if button.isTitle then |
button.notCheckable = info.notCheckable |
button.text:SetPoint("LEFT", button, "LEFT", button.notCheckable and 0 or 24, 0) |
button.checked = not info.notCheckable and info.checked |
button.mouseoverUnderline = info.mouseoverUnderline |
button.isRadio = not info.notCheckable and info.isRadio |
if info.isRadio then |
button.check:Show() |
end |
if not button.disabled then |
button.func = info.func |
button.secure = info.secure |
end |
button.hasColorSwatch = info.hasColorSwatch |
if button.hasColorSwatch then |
button.r = info.r or 1 |
button.g = info.g or 1 |
button.b = info.b or 1 |
button.colorSwatch.texture:SetTexture(button.r, button.g, button.b) |
button.colorSwatch.texture:SetVertexColor(button.r, button.g, button.b) |
button.checked = false |
button.func = nil |
button.colorFunc = info.colorFunc |
button.sliderMin = info.sliderMin or 0 |
button.sliderMax = info.sliderMax or 1 |
button.sliderStep = info.sliderStep or 0 |
button.sliderBigStep = info.sliderBigStep or button.sliderStep |
if button.sliderBigStep < button.sliderStep then |
button.sliderBigStep = button.sliderStep |
end |
button.sliderIsPercent = info.sliderIsPercent and true or false |
button.sliderMinText = info.sliderMinText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMin * 100) or button.sliderMin |
button.sliderMaxText = info.sliderMaxText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMax * 100) or button.sliderMax |
button.sliderFunc = info.sliderFunc |
button.sliderValue = info.sliderValue |
button.fromAceOptions = info.fromAceOptions |
local i = 1 |
while true do |
local k = "sliderArg" .. i |
options.handler = handler |
local class = handler.class |
if not AceLibrary:HasInstance("AceOO-2.0") or not class then |
self:error("Cannot retrieve AceOptions tables from a non-object argument #2") |
end |
while class and class ~= AceLibrary("AceOO-2.0").Class do |
if type(class.GetAceOptionsDataTable) == "function" then |
local t = class:GetAceOptionsDataTable(handler) |
for k,v in pairs(t) do |
if type(options.args) ~= "table" then |
options.args = {} |
end |
if options.args[k] == nil then |
options.args[k] = v |
end |
end |
end |
local mixins = class.mixins |
if mixins then |
for mixin in pairs(mixins) do |
if Rock then |
-- possible Rock object |
for mixin in Rock:IterateObjectMixins(handler) do |
if type(mixin.GetAceOptionsDataTable) == "function" then |
local t = mixin:GetAceOptionsDataTable(handler) |
for k,v in pairs(t) do |
end |
end |
end |
class = class.super |
else |
-- Ace2 object |
while class and class ~= AceLibrary("AceOO-2.0").Class do |
if type(class.GetAceOptionsDataTable) == "function" then |
local t = class:GetAceOptionsDataTable(handler) |
for k,v in pairs(t) do |
if type(options.args) ~= "table" then |
options.args = {} |
end |
if options.args[k] == nil then |
options.args[k] = v |
end |
end |
end |
local mixins = class.mixins |
if mixins then |
for mixin in pairs(mixins) do |
if type(mixin.GetAceOptionsDataTable) == "function" then |
local t = mixin:GetAceOptionsDataTable(handler) |
for k,v in pairs(t) do |
if type(options.args) ~= "table" then |
options.args = {} |
end |
if options.args[k] == nil then |
options.args[k] = v |
end |
end |
end |
end |
end |
class = class.super |
end |
end |
return options |
end |
function Dewdrop:OnTooltipHide() |
if lastSetFont then |
if lastSetFont == normalFont then |
lastSetFont = nil |
return |
end |
fillRegionTmp(GameTooltip:GetRegions()) |
for i,v in ipairs(regionTmp) do |
if v.GetFont then |
local font,size,outline = v:GetFont() |
if font == lastSetFont then |
v:SetFont(normalFont, size, outline) |
end |
end |
regionTmp[i] = nil |
end |
lastSetFont = nil |
end |
end |
local function activate(self, oldLib, oldDeactivate) |
Dewdrop = self |
if oldLib and oldLib.registry then |
local WorldFrame_OnMouseDown = WorldFrame:GetScript("OnMouseDown") |
local WorldFrame_OnMouseUp = WorldFrame:GetScript("OnMouseUp") |
local oldX, oldY, clickTime |
WorldFrame:SetScript("OnMouseDown", function() |
WorldFrame:SetScript("OnMouseDown", function(this, ...) |
oldX,oldY = GetCursorPosition() |
clickTime = GetTime() |
if WorldFrame_OnMouseDown then |
WorldFrame_OnMouseDown() |
WorldFrame_OnMouseDown(this, ...) |
end |
end) |
WorldFrame:SetScript("OnMouseUp", function() |
WorldFrame:SetScript("OnMouseUp", function(this, ...) |
local x,y = GetCursorPosition() |
if not oldX or not oldY or not x or not y or not clickTime then |
self:Close() |
if WorldFrame_OnMouseUp then |
WorldFrame_OnMouseUp() |
WorldFrame_OnMouseUp(this, ...) |
end |
return |
end |
self:Close() |
end |
if WorldFrame_OnMouseUp then |
WorldFrame_OnMouseUp() |
WorldFrame_OnMouseUp(this, ...) |
end |
end) |
self:Close() |
end |
end) |
hooksecurefunc("HideDropDownMenu", function() |
if levels[1] and levels[1]:IsVisible() then |
self:Close() |
end |
end) |
hooksecurefunc("CloseDropDownMenus", function() |
if levels[1] and levels[1]:IsVisible() then |
local stack = debugstack() |
self.frame:Hide() |
self.frame:SetScript("OnEvent", function(this, event) |
this:Show() |
if event=="PLAYER_REGEN_ENABLED" then -- track combat state for secure frame operations |
self.combat = false |
elseif event=="PLAYER_REGEN_DISABLED" then |
self.combat = true |
end |
end) |
self.frame:SetScript("OnUpdate", function(this) |
this:Hide() |
self:Refresh(1) |
end) |
self.hookedTooltip = true |
if not oldLib or not oldLib.hookedTooltip then |
local OnTooltipHide = GameTooltip:GetScript("OnHide") |
GameTooltip:SetScript("OnHide", function(this, ...) |
if OnTooltipHide then |
OnTooltipHide(this, ...) |
end |
if type(self.OnTooltipHide) == "function" then |
self:OnTooltipHide() |
end |
end) |
end |
levels = {} |
buttons = {} |
end |
end |
AceLibrary:Register(Dewdrop, MAJOR_VERSION, MINOR_VERSION, activate) |
local function external(lib, major, instance) |
if major == "LibSharedMedia-3.0" then |
SharedMedia = instance |
end |
end |
AceLibrary:Register(Dewdrop, MAJOR_VERSION, MINOR_VERSION, activate, nil, external) |
## Interface: 30000 |
## X-Curse-Packaged-Version: r1096 |
## X-Curse-Project-Name: Ace2 |
## X-Curse-Project-ID: ace2 |
## X-Curse-Repository-ID: wow/ace2/mainline |
## Title: Lib: AceOO-2.0 |
## Notes: AddOn development framework |
## Author: Ace Development Team |
## LoadOnDemand: 1 |
## X-Website: http://www.wowace.com |
## X-Category: Library |
## X-License: LGPL v2.1 + MIT for AceOO-2.0 |
## Dependencies: AceLibrary |
AceOO-2.0.lua |
--[[ |
Name: AceOO-2.0 |
Revision: $Rev: 25921 $ |
Revision: $Rev: 1091 $ |
Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team) |
Inspired By: Ace 1.x by Turan (turan@gryphon.com) |
Website: http://www.wowace.com/ |
Documentation: http://www.wowace.com/index.php/AceOO-2.0 |
SVN: http://svn.wowace.com/root/trunk/Ace2/AceOO-2.0 |
SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceOO-2.0 |
Description: Library to provide an object-orientation framework. |
Dependencies: AceLibrary |
License: MIT |
]] |
local MAJOR_VERSION = "AceOO-2.0" |
local MINOR_VERSION = "$Revision: 25921 $" |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 1091 $"):match("(%d+)")) |
-- This ensures the code is only executed if the libary doesn't already exist, or is a newer version |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end |
-- @brief Obtain a unique string identifier for the object in question. |
-- @param t The object to obtain the uid for. |
-- @return The uid string. |
local function pad(cap) |
return ("0"):rep(8 - cap:len()) .. cap |
end |
local function getuid(t) |
local mt = getmetatable(t) |
setmetatable(t, nil) |
local str = tostring(t) |
setmetatable(t, mt) |
local cap = str:match("[^:]*: 0x(.*)$") |
if not cap then |
cap = str:match("[^:]*: (.*)$") |
end |
local cap = str:match("[^:]*: 0x(.*)$") or str:match("[^:]*: (.*)$") |
if cap then |
return pad(cap) |
return ("0"):rep(8 - #cap) .. cap |
end |
end |
--[[ |
Name: AceLocale-2.2 |
Revision: $Rev: 27198 $ |
Revision: $Rev: 1094 $ |
Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team) |
Inspired By: Ace 1.x by Turan (turan@gryphon.com) |
Website: http://www.wowace.com/ |
Documentation: http://www.wowace.com/index.php/AceLocale-2.2 |
SVN: http://svn.wowace.com/root/trunk/Ace2/AceLocale-2.2 |
SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceLocale-2.2 |
Description: Localization library for addons to use to handle proper |
localization and internationalization. |
Dependencies: AceLibrary |
]] |
local MAJOR_VERSION = "AceLocale-2.2" |
local MINOR_VERSION = "$Revision: 27198 $" |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 1094 $"):match("(%d+)")) |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end |
if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
local AceLocale = {} |
AceLocale.prototype = { class = AceLocale } |
local DEFAULT_LOCALE = "enUS" |
local _G = getfenv(0) |
local BASE_TRANSLATIONS, DEBUGGING, TRANSLATIONS, BASE_LOCALE, TRANSLATION_TABLES, REVERSE_TRANSLATIONS, STRICTNESS, DYNAMIC_LOCALES, CURRENT_LOCALE, NAME |
local _G = _G |
local rawget = rawget |
local rawset = rawset |
local type = type |
local pairs = pairs |
local next = next |
local getmetatable = getmetatable |
local setmetatable = setmetatable |
local GetTime = GetTime |
local geterrorhandler = geterrorhandler |
local pcall = pcall |
local ipairs = ipairs |
local GetLocale = GetLocale |
local newRegistries = {} |
local scheduleClear |
local lastSelf |
local __index = function(self, key) |
local strict__index = function(self, key) |
lastSelf = self |
local value = (rawget(self, TRANSLATIONS) or AceLocale.prototype)[key] |
rawset(self, key, value) |
return value |
end |
local nonstrict__index = function(self, key) |
lastSelf = self |
local t = rawget(self, TRANSLATIONS) |
if t then |
local value = rawget(t, key) |
if value then |
rawset(self, key, value) |
return value |
end |
end |
local value = (rawget(self, BASE_TRANSLATIONS) or AceLocale.prototype)[key] |
rawset(self, key, value) |
return value |
end |
local __newindex = function(self, k, v) |
if type(v) ~= "function" and type(k) ~= "table" then |
end |
local function clearCache(self) |
for k, v in pairs(AceLocale.prototype) do |
if type(v) == "function" and type(rawget(self, k)) == "function" then |
self[k] = nil |
end |
end |
if not rawget(self, BASE_TRANSLATIONS) then |
return |
end |
self.tmp = nil |
end |
local strict_instance_mt, nonstrict_instance_mt |
local baseTranslations_mt |
local function refixInstance(instance) |
if getmetatable(instance) then |
setmetatable(instance, nil) |
setmetatable(baseTranslations, nil) |
end |
if translations == baseTranslations or instance[STRICTNESS] then |
setmetatable(instance, { |
__index = __index, |
__newindex = __newindex, |
__tostring = __tostring |
}) |
setmetatable(instance, strict_instance_mt) |
setmetatable(translations, { |
__index = AceLocale.prototype |
}) |
setmetatable(translations, baseTranslations_mt) |
else |
setmetatable(instance, { |
__index = __index, |
__newindex = __newindex, |
__tostring = __tostring |
}) |
setmetatable(instance, nonstrict_instance_mt) |
setmetatable(translations, { |
__index = baseTranslations, |
}) |
setmetatable(baseTranslations, { |
__index = AceLocale.prototype, |
}) |
setmetatable(baseTranslations, baseTranslations_mt) |
end |
else |
setmetatable(instance, { |
__index = __index, |
__newindex = __newindex, |
__tostring = __tostring, |
}) |
setmetatable(instance, strict_instance_mt) |
end |
clearCache(instance) |
newRegistries[instance] = true |
return AceLocale.registry[name] |
end |
AceLocale.prototype = { class = AceLocale } |
function AceLocale.prototype:EnableDebugging() |
if rawget(self, BASE_TRANSLATIONS) then |
AceLocale.error(self, "Cannot enable debugging after a translation has been registered.") |
end |
local value = rawget(x, text) |
if value == nil then |
AceLocale.error(self, "Translation %q does not exist for locale %s", text, self[CURRENT_LOCALE]) |
local _, ret = pcall(AceLocale.error, self, "Translation %q does not exist for locale %s", text, self[CURRENT_LOCALE]) |
geterrorhandler()(ret) |
return text |
end |
return value |
end |
end |
local translation = x[text] |
if not translation then |
AceLocale.error(self, "Reverse translation for %q does not exist", text) |
local _, ret = pcall(AceLocale.error, self, "Reverse translation for %q does not exist", text) |
geterrorhandler()(ret) |
return text |
end |
return translation |
end |
return |
end |
local words = {} |
local locales = {"enUS", "deDE", "frFR", "koKR", "zhCN", "zhTW", "esES"} |
local locales = {"enUS", "deDE", "frFR", "koKR", "zhCN", "zhTW", "esES", "ruRU"} |
local localizations = {} |
DEFAULT_CHAT_FRAME:AddMessage("--- AceLocale Debug ---") |
for _,locale in ipairs(locales) do |
setmetatable(AceLocale.prototype, { |
__index = function(self, k) |
if type(k) ~= "table" and k ~= 0 and k ~= "GetLibraryVersion" and k ~= "error" and k ~= "assert" and k ~= "argCheck" and k ~= "pcall" then -- HACK: remove "GetLibraryVersion" and such later. |
AceLocale.error(lastSelf or self, "Translation %q does not exist.", k) |
local _, ret = pcall(AceLocale.error, lastSelf or self, "Translation %q does not exist.", k) |
geterrorhandler()(ret) |
return k |
end |
return nil |
end |
DYNAMIC_LOCALES = self.DYNAMIC_LOCALES |
CURRENT_LOCALE = self.CURRENT_LOCALE |
strict_instance_mt = { |
__index = strict__index, |
__newindex = __newindex, |
__tostring = __tostring |
} |
nonstrict_instance_mt = { |
__index = nonstrict__index, |
__newindex = __newindex, |
__tostring = __tostring |
} |
baseTranslations_mt = { |
__index = AceLocale.prototype |
} |
local GetTime = GetTime |
local timeUntilClear = GetTime() + 5 |
end |
end |
if not self.registry then |
self.registry = {} |
else |
for name, instance in pairs(self.registry) do |
local name = name |
local mt = getmetatable(instance) |
setmetatable(instance, nil) |
instance[NAME] = name |
local strict |
if instance[STRICTNESS] ~= nil then |
strict = instance[STRICTNESS] |
elseif instance[TRANSLATIONS] ~= instance[BASE_TRANSLATIONS] then |
if getmetatable(instance[TRANSLATIONS]).__index == oldLib.prototype then |
strict = true |
end |
for name, instance in pairs(self.registry) do |
local name = name |
setmetatable(instance, nil) |
instance[NAME] = name |
local strict |
if instance[STRICTNESS] ~= nil then |
strict = instance[STRICTNESS] |
elseif instance[TRANSLATIONS] ~= instance[BASE_TRANSLATIONS] then |
if getmetatable(instance[TRANSLATIONS]).__index == oldLib.prototype then |
strict = true |
end |
instance[STRICTNESS] = strict and true or false |
refixInstance(instance) |
end |
instance[STRICTNESS] = strict and true or false |
refixInstance(instance) |
end |
self.frame:SetScript("OnEvent", scheduleClear) |
end |
AceLibrary:Register(AceLocale, MAJOR_VERSION, MINOR_VERSION, activate) |
--[[ |
if true then -- debug |
local L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG" or "AceLocale_DEBUG3") |
L:RegisterTranslations("enUS", function() return { |
Monkey = true, |
House = true, |
} end) |
L:RegisterTranslations("deDE", function() return { |
Monkey = "Affe" |
} end) |
L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG" or "AceLocale_DEBUG3") |
assert(L.Monkey == "Monkey") |
assert(L.House == "House") |
if not L.Debug then |
local pants = L.Pants |
assert(not pants) |
end |
assert(L.Debug) |
assert(L.Debug == AceLocale.prototype.Debug) |
if MINOR_VERSION == 100000 then |
L = AceLocale:new("AceLocale_DEBUG") |
assert(L.Monkey == "Monkey") |
assert(L.House == "House") |
assert(L.Debug) |
assert(type(L.Debug) == "function") |
assert(AceLocale.prototype.Debug) |
assert(type(AceLocale.prototype.Debug) == "function") |
assert(L.Debug == AceLocale.prototype.Debug) |
end |
local L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG2" or "AceLocale_DEBUG4") |
L:RegisterTranslations("deDE", function() return { |
Affe = true, |
Haus = true, |
} end) |
L:RegisterTranslations("enUS", function() return { |
Affe = "Monkey" |
} end) |
L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG2" or "AceLocale_DEBUG4") |
assert(L.Affe == "Monkey") |
assert(L.Haus == "Haus") |
assert(L.Debug) |
assert(L.Debug == AceLocale.prototype.Debug) |
if MINOR_VERSION == 100000 then |
L = AceLocale:new("AceLocale_DEBUG2") |
assert(L.Affe == "Monkey") |
assert(L.Haus == "Haus") |
assert(L.Debug) |
assert(L.Debug == AceLocale.prototype.Debug) |
end |
local L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG5" or "AceLocale_DEBUG6") |
L:RegisterTranslations("deDE", function() return { |
Affe = true, |
Haus = true, |
} end) |
L:RegisterTranslations("enUS", function() return { |
Affe = "Monkey" |
} end) |
L:SetStrictness(true) |
L = AceLocale:new(MINOR_VERSION ~= 100000 and "AceLocale_DEBUG5" or "AceLocale_DEBUG6") |
assert(L.Affe == "Monkey") |
assert(L.Haus == "Haus") |
assert(L.Debug) |
assert(L.Debug == AceLocale.prototype.Debug) |
if MINOR_VERSION == 100000 then |
L = AceLocale:new("AceLocale_DEBUG5") |
assert(L.Affe == "Monkey") |
assert(L.Haus == "Haus") |
assert(L.Debug) |
assert(L.Debug == AceLocale.prototype.Debug) |
end |
end |
]] |
## Interface: 30000 |
## X-Curse-Packaged-Version: r1096 |
## X-Curse-Project-Name: Ace2 |
## X-Curse-Project-ID: ace2 |
## X-Curse-Repository-ID: wow/ace2/mainline |
## Title: Lib: AceLocale-2.2 |
## Notes: AddOn development framework |
## Author: Ace Development Team |
## LoadOnDemand: 1 |
## X-Website: http://www.wowace.com |
## X-Category: Library |
## X-License: LGPL v2.1 + MIT for AceOO-2.0 |
## Dependencies: AceLibrary |
AceLocale-2.2.lua |
--[[ |
--[[ |
Name: AceConsole-2.0 |
Revision: $Rev: 30624 $ |
Revision: $Rev: 1094 $ |
Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team) |
Inspired By: Ace 1.x by Turan (turan@gryphon.com) |
Website: http://www.wowace.com/ |
]] |
local MAJOR_VERSION = "AceConsole-2.0" |
local MINOR_VERSION = "$Revision: 30624 $" |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 1094 $"):match("(%d+)")) |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end |
if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0.") end |
local WotLK = select(4,GetBuildInfo()) >= 30000 |
-- #AUTODOC_NAMESPACE AceConsole |
local MAP_ONOFF, USAGE, IS_CURRENTLY_SET_TO, IS_NOW_SET_TO, IS_NOT_A_VALID_OPTION_FOR, IS_NOT_A_VALID_VALUE_FOR, NO_OPTIONS_AVAILABLE, OPTION_HANDLER_NOT_FOUND, OPTION_HANDLER_NOT_VALID, OPTION_IS_DISABLED, KEYBINDING_USAGE, DEFAULT_CONFIRM_MESSAGE |
if GetLocale() == "deDE" then |
MAP_ONOFF = { [false] = "|cffff0000Aus|r", [true] = "|cff00ff00An|r" } |
elseif GetLocale() == "koKR" then |
MAP_ONOFF = { [false] = "|cffff0000ë|r", [true] = "|cff00ff00켬|r" } |
USAGE = "ì¬ì©ë²" |
IS_CURRENTLY_SET_TO = "|cffffff7f%s|r|1ì;ë; íì¬ ìíë |cffffff7f[|r%s|cffffff7f]|r|1ì¼ë¡;ë¡; ì¤ì ëì´ ììµëë¤" |
IS_NOW_SET_TO = "|cffffff7f%s|r|1ì;를; |cffffff7f[|r%s|cffffff7f]|r ìíë¡ ë³ê²½í©ëë¤" |
IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r]|1ì;ë; |cffffff7f%s|rìì ì¬ì©ë¶ê°ë¥í ì¤ì ì ëë¤" |
IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r]|1ì;ë; |cffffff7f%s|rìì ì¬ì©ë¶ê°ë¥í ì¤ì ê°ì ëë¤" |
NO_OPTIONS_AVAILABLE = "ê°ë¥í ì¤ì ì´ ììµëë¤" |
OPTION_HANDLER_NOT_FOUND = "ì¤ì ì¡°ì ê°ì¸ |cffffff7f%q|r|1ì;를; ì°¾ì§ ëª»íìµëë¤." |
OPTION_HANDLER_NOT_VALID = "ì¤ì ì¡°ì ê°ì´ ì¬ë°ë¥´ì§ ììµëë¤." |
IS_CURRENTLY_SET_TO = "|cffffff7f%s|r|1ì;ë; íì¬ ìíë |cffffff7f[|r%s|cffffff7f]|r|1ì¼ë¡;ë¡; ì¤ì ëì´ ììµëë¤." |
IS_NOW_SET_TO = "|cffffff7f%s|r|1ì;를; |cffffff7f[|r%s|cffffff7f]|r ìíë¡ ë³ê²½í©ëë¤." |
IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r]|1ì;ë; |cffffff7f%s|rìì ì¬ì© ë¶ê°ë¥í ì¤ì ì ëë¤." |
IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r]|1ì;ë; |cffffff7f%s|rìì ì¬ì© ë¶ê°ë¥í ì¤ì ê°ì ëë¤." |
NO_OPTIONS_AVAILABLE = "ê°ë¥í ì¤ì ì´ ììµëë¤." |
OPTION_HANDLER_NOT_FOUND = "ì¤ì ì¡°ì ê°ì¸ |cffffff7f%q|r|1ì;를; ì°¾ì§ ëª»íìµëë¤." |
OPTION_HANDLER_NOT_VALID = "ì¤ì ì¡°ì ê°ì´ ì¬ë°ë¥´ì§ ììµëë¤." |
OPTION_IS_DISABLED = "|cffffff7f%s|r ì¤ì ì ì¬ì©í ì ììµëë¤." |
KEYBINDING_USAGE = "<ALT-CTRL-SHIFT-KEY>" -- fix |
DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix |
KEYBINDING_USAGE = "<ALT-CTRL-SHIFT-KEY>" |
DEFAULT_CONFIRM_MESSAGE = "ì ë§ ë¹ì ì `%s'|1ì;를; íìê² ìµëê¹?" |
elseif GetLocale() == "zhCN" then |
MAP_ONOFF = { [false] = "|cffff0000\229\133\179\233\151\173|r", [true] = "|cff00ff00\229\188\128\229\144\175|r" } |
USAGE = "\231\148\168\230\179\149" |
elseif GetLocale() == "zhTW" then |
MAP_ONOFF = { [false] = "|cffff0000éé|r", [true] = "|cff00ff00éå|r" } |
USAGE = "ç¨æ³" |
IS_CURRENTLY_SET_TO = "|cffffff7f%s|r ç®åçè¨å®çº |cffffff7f[|r%s|cffffff7f]|r" |
IS_NOW_SET_TO = "|cffffff7f%s|r ç¾å¨è¢«è¨å®çº |cffffff7f[|r%s|cffffff7f]|r" |
IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r] æ¯ä¸åä¸ç¬¦åè¦å®çé¸é ï¼å° |cffffff7f%s|r" |
IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r] æ¯ä¸åä¸ç¬¦åè¦å®çæ¸å¼ï¼å° |cffffff7f%s|r" |
NO_OPTIONS_AVAILABLE = "æ²æå¯ç¨çé¸é èçå¨ã" |
OPTION_HANDLER_NOT_FOUND = "æ¾ä¸å° |cffffff7f%q|r é¸é èçå¨ã" |
IS_CURRENTLY_SET_TO = "|cffffff7f%s|rç®åçè¨å®çº|cffffff7f[|r%s|cffffff7f]|r" |
IS_NOW_SET_TO = "|cffffff7f%s|rç¾å¨è¢«è¨å®çº|cffffff7f[|r%s|cffffff7f]|r" |
IS_NOT_A_VALID_OPTION_FOR = "å°æ¼|cffffff7f%2$s|rï¼[|cffffff7f%1$s|r]æ¯ä¸åä¸ç¬¦åè¦å®çé¸é " |
IS_NOT_A_VALID_VALUE_FOR = "å°æ¼|cffffff7f%2$s|rï¼[|cffffff7f%1$s|r]æ¯ä¸åä¸ç¬¦åè¦å®çæ¸å¼" |
NO_OPTIONS_AVAILABLE = "æ²æå¯ç¨çé¸é " |
OPTION_HANDLER_NOT_FOUND = "æ¾ä¸å°|cffffff7f%q|ré¸é èçå¨ã" |
OPTION_HANDLER_NOT_VALID = "é¸é èçå¨ä¸ç¬¦åè¦å®ã" |
OPTION_IS_DISABLED = "|cffffff7f%s|r 已被åç¨ã" |
KEYBINDING_USAGE = "<ALT-CTRL-SHIFT-KEY>" -- fix |
DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix |
OPTION_IS_DISABLED = "|cffffff7f%s|r已被åç¨ã" |
KEYBINDING_USAGE = "<Alt-Ctrl-Shift-éµ>" |
DEFAULT_CONFIRM_MESSAGE = "æ¯å¦å·è¡ã%sã?" |
elseif GetLocale() == "esES" then |
MAP_ONOFF = { [false] = "|cffff0000Desactivado|r", [true] = "|cff00ff00Activado|r" } |
USAGE = "Uso" |
OPTION_IS_DISABLED = "La opci\195\179n |cffffff7f%s|r est\195\161 desactivada." |
KEYBINDING_USAGE = "<ALT-CTRL-SHIFT-KEY>" |
DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" -- fix |
elseif GetLocale() == "ruRU" then |
MAP_ONOFF = { [false] = "|cffff0000Off|r", [true] = "|cff00ff00On|r" } |
USAGE = "ÐÑполÑзование" |
IS_CURRENTLY_SET_TO = "|cffffff7f%s|r в наÑÑоÑÑее вÑÐµÐ¼Ñ ÑÑÑановлен на |cffffff7f[|r%s|cffffff7f]|r" |
IS_NOW_SET_TO = "|cffffff7f%s|r ÑепеÑÑ ÑÑÑановлен |cffffff7f[|r%s|cffffff7f]|r" |
IS_NOT_A_VALID_OPTION_FOR = "[|cffffff7f%s|r] - недейÑÑвиÑелÑÐ½Ð°Ñ Ð¾Ð¿ÑÐ¸Ñ Ð´Ð»Ñ |cffffff7f%s|r" |
IS_NOT_A_VALID_VALUE_FOR = "[|cffffff7f%s|r] - недейÑÑвиÑелÑное знаÑение Ð´Ð»Ñ |cffffff7f%s|r" |
NO_OPTIONS_AVAILABLE = "ÐÐµÑ Ð´Ð¾ÑÑÑпнÑÑ Ð¾Ð¿Ñий" |
OPTION_HANDLER_NOT_FOUND = "ÐпеÑаÑÐ¾Ñ Ð¾Ð¿Ñии |cffffff7f%q|r не найден." |
OPTION_HANDLER_NOT_VALID = "ÐпеÑаÑÐ¾Ñ Ð¾Ð¿Ñии недейÑÑвиÑелен." |
OPTION_IS_DISABLED = "ÐпÑÐ¸Ñ |cffffff7f%s|r оÑклÑÑена." |
KEYBINDING_USAGE = "<ALT-CTRL-SHIFT-ÐÐÐÐÐШÐ>" |
DEFAULT_CONFIRM_MESSAGE = "ÐÑ ÑвеÑенÑ, ÑÑо Ñ Ð¾ÑиÑе вÑполниÑÑ `%s'?" |
else -- enUS |
MAP_ONOFF = { [false] = "|cffff0000Off|r", [true] = "|cff00ff00On|r" } |
USAGE = "Usage" |
return {} |
end |
end |
function del(t) |
for k in pairs(t) do |
t[k] = nil |
local function literal_tostring_prime(t, depth) |
if type(t) == "string" then |
return ("|cff00ff00%q|r"):format((t:gsub("|", "||"))):gsub("[\001-\012\014-\031\128-\255]", escapeChar) |
return ("|cff00ff00%q|r"):format((t:gsub("|", "||"))):gsub("[%z\001-\009\011-\031\127-\255]", escapeChar) |
elseif type(t) == "table" then |
if t == _G then |
return "|cffffea00_G|r" |
if type(rawget(t, 0)) == "userdata" and type(t.GetObjectType) == "function" then |
return ("|cffffea00<%s:%s>|r"):format(t:GetObjectType(), t:GetName() or "(anon)") |
end |
if next(t) == nil then |
local mt = getmetatable(t) |
if type(mt) == "table" and type(mt.__raw) == "table" then |
t = mt.__raw |
end |
end |
if recurse[t] then |
local g = findGlobal[t] |
if g then |
table.insert(work, token) |
end |
end |
local path = chat |
for i = 1, index - 1 do |
path = path .. " " .. tostring(work[i]) |
end |
local passValue = options.passValue or (passTable and work[index-1]) |
passTable = passTable or options |
if type(options.args) == "table" then |
local disabled, hidden = options.disabled, options.cmdHidden or options.hidden |
if hidden then |
if type(hidden) == "function" then |
hidden = hidden() |
hidden = hidden(passValue) |
elseif type(hidden) == "string" then |
local handler = options.handler or self |
local f = hidden |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
hidden = handler[f](handler) |
hidden = handler[f](handler, passValue) |
if neg then |
hidden = not hidden |
end |
disabled = true |
elseif disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(passValue) |
elseif type(disabled) == "string" then |
local handler = options.handler or self |
local f = disabled |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, passValue) |
if neg then |
disabled = not disabled |
end |
good = true |
end |
if good then |
return findTableLevel(options.handler or self, v, chat, text, index + 1, options.pass and options or nil) |
work[index] = k -- revert it back to its original form as supplied in args |
if options.pass then |
passTable = passTable or options |
if options.get and options.set then |
passTable = options |
end |
else |
passTable = nil |
end |
return findTableLevel(options.handler or self, v, chat, text, index + 1, passTable) |
end |
end |
end |
for i = index, #work do |
table.insert(argwork, work[i]) |
end |
return options, path, argwork, options.handler or self, passTable, passTable and work[index - 1] |
return options, path, argwork, options.handler or self, passTable, passValue |
end |
local function validateOptionsMethods(self, options, position) |
return '"func" must be a string or function', position |
end |
end |
else |
if kind == "group" then |
return 'cannot have "type" = "group" as a subgroup of a passing group', position |
end |
end |
if options ~= baseOptions then |
if kind == "header" then |
return '"multiToggle" must be a boolean or nil if "validate" is a table', position |
end |
elseif options.validate == "keybinding" then |
else |
if type(options.usage) ~= "string" then |
return '"usage" must be a string', position |
end |
local tmp = {} |
local function printUsage(self, handler, realOptions, options, path, args, quiet, filter) |
local function printUsage(self, handler, realOptions, options, path, args, passValue, quiet, filter) |
if filter then |
filter = "^" .. filter:gsub("([%(%)%.%*%+%-%[%]%?%^%$%%])", "%%%1") |
end |
local hidden, disabled = options.cmdHidden or options.hidden, options.disabled |
if hidden then |
if type(hidden) == "function" then |
hidden = hidden() |
hidden = hidden(options.passValue) |
elseif type(hidden) == "string" then |
local f = hidden |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
hidden = handler[f](handler) |
hidden = handler[f](handler, options.passValue) |
if neg then |
hidden = not hidden |
end |
disabled = true |
elseif disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(options.passValue) |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, options.passValue) |
if neg then |
disabled = not disabled |
end |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = passTable.get(passValue, val) or nil |
if passValue == nil then |
var[val] = passTable.get(val) or nil |
else |
var[val] = passTable.get(passValue, val) or nil |
end |
end |
end |
else |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[passTable.get](handler, passValue, val) or nil |
if passValue == nil then |
var[val] = handler[passTable.get](handler, val) or nil |
else |
var[val] = handler[passTable.get](handler, passValue, val) or nil |
end |
end |
end |
end |
if not options.get then |
elseif type(options.get) == "function" then |
if not multiToggle then |
var = options.get() |
var = options.get(passValue) |
else |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = options.get(val) or nil |
if passValue == nil then |
var[val] = options.get(val) or nil |
else |
var[val] = options.get(passValue, val) or nil |
end |
end |
end |
else |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
if not multiToggle then |
var = handler[options.get](handler) |
var = handler[options.get](handler, passValue) |
else |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[options.get](handler, val) or nil |
if passValue == nil then |
var[val] = handler[options.get](handler, val) or nil |
else |
var[val] = handler[options.get](handler, passValue, val) or nil |
end |
end |
end |
end |
end |
local usage |
if type(options.validate) == "table" then |
if filter then |
end |
else |
if type(options.get) == "function" then |
var = options.get() |
var = options.get(passValue) |
else |
local handler = options.handler or handler |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
var = handler[options.get](handler) |
var = handler[options.get](handler, passValue) |
end |
end |
local usage |
local min = options.min or 0 |
local max = options.max or 1 |
end |
local passTable = options.pass and options or nil |
for _,k in ipairs(order) do |
local passValue = passTable and k |
local passValue = passTable and k or nil |
local real_k = k |
local v = options.args[k] |
if v then |
local v_p = passTable or v |
local k = k:gsub("%s", "-") |
if v.get and v.set then |
v_p = v |
passValue = nil |
end |
if v.passValue then |
passValue = v.passValue |
end |
local k = tostring(k):gsub("%s", "-") |
local disabled = v.disabled |
if disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(passValue) |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, passValue) |
if neg then |
disabled = not disabled |
end |
t.timeout = 0 |
t.whileDead = 1 |
t.hideOnEscape = 1 |
StaticPopup_Show("ACECONSOLE20_CONFIRM_DIALOG") |
end |
msg = msg:gsub("^%s*(.-)%s*$", "%1") |
msg = msg:gsub("%s+", " ") |
end |
local realOptions = options |
local options, path, args, handler, passTable, passValue = findTableLevel(self, options, chat, msg) |
if options.type == "execute" then |
if options.func then |
passTable = nil |
end |
else |
if options.get and options.set then |
passTable = nil |
end |
end |
passValue = options.passValue or passTable and passValue |
local hidden, disabled = options.cmdHidden or options.hidden, options.disabled |
if hidden then |
if type(hidden) == "function" then |
hidden = hidden() |
hidden = hidden(passValue) |
elseif type(hidden) == "string" then |
local f = hidden |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
hidden = handler[f](handler) |
hidden = handler[f](handler, passValue) |
if neg then |
hidden = not hidden |
end |
disabled = true |
elseif disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(passValue) |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, passValue) |
if neg then |
disabled = not disabled |
end |
end |
end |
local _G_this = this |
local kind = (options.type or "group"):lower() |
local options_p = passTable or options |
if disabled then |
print(OPTION_IS_DISABLED:format(path), realOptions.cmdName or realOptions.name or self) |
elseif kind == "text" then |
return |
end |
end |
local var |
local multiToggle |
for k in pairs(tmp) do |
tmp[k] = nil |
end |
if passTable then |
multiToggle = passTable.multiToggle |
if not passTable.get then |
elseif type(passTable.get) == "function" then |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = passTable.get(passValue, val) |
multiToggle = options_p.multiToggle |
if not options_p.get then |
elseif type(options_p.get) == "function" then |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
if passValue then |
var[val] = options_p.get(passValue, val) or nil |
else |
var[val] = options_p.get(val) or nil |
end |
else |
var = passTable.get(passValue) |
end |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[passTable.get](handler, passValue, val) |
end |
else |
var = handler[passTable.get](handler, passValue) |
end |
var = options_p.get(passValue) |
end |
else |
multiToggle = options.multiToggle |
if not options.get then |
elseif type(options.get) == "function" then |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = options.get(val) |
if type(handler[options_p.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
if passValue then |
var[val] = handler[options_p.get](handler, passValue, val) or nil |
else |
var[val] = handler[options_p.get](handler, val) or nil |
end |
else |
var = options.get() |
end |
else |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[options.get](handler, val) |
end |
else |
var = handler[options.get](handler) |
end |
var = handler[options_p.get](handler, passValue) |
end |
end |
if multiToggle or var ~= args[1] then |
if multiToggle then |
local current = var[args[1]] |
end |
args[2] = not current |
end |
if passTable then |
if type(passTable.set) == "function" then |
passTable.set(passValue, unpack(args)) |
if type(options_p.set) == "function" then |
if passValue then |
options_p.set(passValue, unpack(args)) |
else |
if type(handler[passTable.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.set))) |
end |
handler[passTable.set](handler, passTable.set, unpack(args)) |
options_p.set(unpack(args)) |
end |
else |
if type(options.set) == "function" then |
options.set(unpack(args)) |
if type(handler[options_p.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set))) |
end |
if passValue then |
handler[options_p.set](handler, passValue, unpack(args)) |
else |
if type(handler[options.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.set))) |
end |
handler[options.set](handler, unpack(args)) |
handler[options_p.set](handler, unpack(args)) |
end |
end |
end |
end |
if #args > 0 then |
local var |
local multiToggle |
for k in pairs(tmp) do |
tmp[k] = nil |
end |
if passTable then |
multiToggle = passTable.multiToggle |
if not passTable.get then |
elseif type(passTable.get) == "function" then |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = passTable.get(passValue, val) |
multiToggle = options_p.multiToggle |
if not options_p.get then |
elseif type(options_p.get) == "function" then |
if multiToggle then |
var = tmp |
for k,v in pairs(options_p.validate) do |
local val = type(k) ~= "number" and k or v |
if passValue then |
var[val] = options_p.get(passValue, val) or nil |
else |
var[val] = options_p.get(val) or nil |
end |
else |
var = passTable.get(passValue) |
end |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[passTable.get](handler, passValue, val) |
end |
else |
var = handler[passTable.get](handler, passValue) |
end |
var = options_p.get(passValue) |
end |
else |
multiToggle = options.multiToggle |
if not options.get then |
elseif type(options.get) == "function" then |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = options.get(val) |
if type(handler[options_p.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
if passValue then |
var[val] = handler[options_p.get](handler, passValue, val) or nil |
else |
var[val] = handler[options_p.get](handler, val) or nil |
end |
else |
var = options.get() |
end |
else |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
if multiToggle then |
var = tmp |
for k,v in pairs(options.validate) do |
local val = type(k) ~= "number" and k or v |
var[val] = handler[options.get](handler, val) |
end |
else |
var = handler[options.get](handler) |
end |
var = handler[options_p.get](handler, passValue) |
end |
end |
if multiToggle then |
elseif type(options.validate) == "table" then |
var = options.validate[var] or var |
end |
if (passTable and passTable.get) or options.get then |
if options_p.get then |
print((options.message or IS_NOW_SET_TO):format(tostring(options.cmdName or options.name), tostring(var or NONE)), realOptions.cmdName or realOptions.name or self) |
end |
if var == args[1] then |
return |
end |
else |
printUsage(self, handler, realOptions, options, path, args) |
printUsage(self, handler, realOptions, options, path, args, passValue) |
return |
end |
elseif kind == "execute" then |
if confirm == true then |
confirm = DEFAULT_CONFIRM_MESSAGE:format(options.desc or options.name or UNKNOWN or "Unknown") |
end |
if passTable then |
if type(passTable.func) == "function" then |
if confirm then |
confirmPopup(confirm, set, passValue) |
else |
passTable.func(passValue) |
end |
if type(options_p.func) == "function" then |
if confirm then |
confirmPopup(confirm, options_p.func, passValue) |
else |
if type(handler[passTable.func]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.func))) |
end |
if confirm then |
confirmPopup(confirm, handler[passTable.func], handler, passValue) |
else |
handler[passTable.func](handler, passValue) |
end |
options_p.func(passValue) |
end |
else |
local ret, msg |
if type(options.func) == "function" then |
if confirm then |
confirmPopup(confirm, options.func) |
else |
options.func() |
end |
if type(handler[options_p.func]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.func))) |
end |
if confirm then |
confirmPopup(confirm, handler[options_p.func], handler, passValue) |
else |
local handler = options.handler or self |
if type(handler[options.func]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.func))) |
end |
if confirm then |
confirmPopup(confirm, handler[options.func], handler) |
else |
handler[options.func](handler) |
end |
handler[options_p.func](handler, passValue) |
end |
end |
elseif kind == "toggle" then |
local var |
if passTable then |
if type(passTable.get) == "function" then |
var = passTable.get(passValue) |
else |
local f = passTable.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
var = handler[f](handler, passValue) |
if neg then |
var = not var |
end |
if type(options_p.get) == "function" then |
var = options_p.get(passValue) |
else |
local f = options_p.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
if type(passTable.set) == "function" then |
passTable.set(passValue, not var) |
else |
if type(handler[passTable.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.set))) |
end |
handler[passTable.set](handler, passValue, not var) |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
if type(passTable.get) == "function" then |
var = passTable.get(passValue) |
var = handler[f](handler, passValue) |
if neg then |
var = not var |
end |
end |
if type(options_p.set) == "function" then |
if passValue then |
options_p.set(passValue, not var) |
else |
local f = passTable.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
var = handler[f](handler, passValue) |
if neg then |
var = not var |
end |
options_p.set(not var) |
end |
else |
local handler = options.handler or self |
if type(options.get) == "function" then |
var = options.get() |
else |
local f = options.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
if type(handler[f]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
var = handler[f](handler) |
if neg then |
var = not var |
end |
if type(handler[options_p.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set))) |
end |
if type(options.set) == "function" then |
options.set(not var) |
if passValue then |
handler[options_p.set](handler, passValue, not var) |
else |
if type(handler[options.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.set))) |
end |
handler[options.set](handler, not var) |
handler[options_p.set](handler, not var) |
end |
if type(options.get) == "function" then |
var = options.get() |
else |
local f = options.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
var = handler[f](handler) |
if neg then |
var = not var |
end |
end |
if type(options_p.get) == "function" then |
var = options_p.get(passValue) |
else |
local f = options_p.get |
local neg = f:match("^~(.-)$") |
if neg then |
f = neg |
end |
var = handler[f](handler, passValue) |
if neg then |
var = not var |
end |
end |
print((options.message or IS_NOW_SET_TO):format(tostring(options.cmdName or options.name), (options.map or MAP_ONOFF)[var and true or false] or NONE), realOptions.cmdName or realOptions.name or self) |
elseif kind == "range" then |
local arg |
if arg >= min and arg <= max then |
good = true |
end |
if good and type(options.step) == "number" and options.step > 0 then |
local step = options.step |
arg = math.floor((arg - min) / step + 0.5) * step + min |
print(("|cffffff7f%s:|r %s %s"):format(USAGE, path, usage)) |
return |
end |
local var |
if passTable then |
if type(passTable.get) == "function" then |
var = passTable.get(passValue) |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
var = handler[passTable.get](handler, passValue) |
end |
if type(options_p.get) == "function" then |
var = options_p.get(passValue) |
else |
if type(options.get) == "function" then |
var = options.get() |
else |
local handler = options.handler or self |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
var = handler[options.get](handler) |
if type(handler[options_p.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get))) |
end |
var = handler[options_p.get](handler, passValue) |
end |
if var ~= arg then |
if passTable then |
if type(passTable.set) == "function" then |
passTable.set(passValue, arg) |
if type(options_p.set) == "function" then |
if passValue then |
options_p.set(passValue, arg) |
else |
if type(handler[passTable.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.set))) |
end |
handler[passTable.set](handler, passValue, arg) |
options_p.set(arg) |
end |
else |
if type(options.set) == "function" then |
options.set(arg) |
if type(handler[options_p.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set))) |
end |
if passValue then |
handler[options_p.set](handler, passValue, arg) |
else |
local handler = options.handler or self |
if type(handler[options.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.set))) |
end |
handler[options.set](handler, arg) |
handler[options_p.set](handler, arg) |
end |
end |
end |
end |
if arg then |
local var |
if passTable then |
if type(passTable.get) == "function" then |
var = passTable.get(passValue) |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
var = handler[passTable.get](handler, passValue) |
end |
if type(options_p.get) == "function" then |
var = options_p.get(passValue) |
else |
if type(options.get) == "function" then |
var = options.get() |
else |
local handler = options.handler or self |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
var = handler[options.get](handler) |
if type(handler[options_p.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get))) |
end |
var = handler[options_p.get](handler, passValue) |
end |
if var and options.isPercent then |
var = tostring(var * 100) .. "%" |
end |
return |
end |
else |
printUsage(self, handler, realOptions, options, path, args) |
printUsage(self, handler, realOptions, options, path, args, passValue) |
return |
end |
elseif kind == "color" then |
print(("|cffffff7f%s:|r %s {0-1} {0-1} {0-1}%s"):format(USAGE, path, options.hasAlpha and " {0-1}" or "")) |
return |
end |
if passTable then |
if type(passTable.set) == "function" then |
passTable.set(passValue, r,g,b,a) |
if type(options_p.set) == "function" then |
if passValue then |
options_p.set(passValue, r,g,b,a) |
else |
if type(handler[passTable.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.set))) |
end |
handler[passTable.set](handler, passValue, r,g,b,a) |
options_p.set(r,g,b,a) |
end |
else |
if type(options.set) == "function" then |
options.set(r,g,b,a) |
if type(handler[options_p.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.set))) |
end |
if passValue then |
handler[options_p.set](handler, passValue, r,g,b,a) |
else |
if type(handler[options.set]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.set))) |
end |
handler[options.set](handler, r,g,b,a) |
handler[options_p.set](handler, r,g,b,a) |
end |
end |
local r,g,b,a |
if passTable then |
if type(passTable.get) == "function" then |
r,g,b,a = passTable.get(passValue) |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
r,g,b,a = handler[passTable.get](handler, passValue) |
end |
if type(options_p.get) == "function" then |
r,g,b,a = options_p.get(passValue) |
else |
if type(options.get) == "function" then |
r,g,b,a = options.get() |
else |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
r,g,b,a = handler[options.get](handler) |
if type(handler[options_p.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get))) |
end |
r,g,b,a = handler[options_p.get](handler, passValue) |
end |
local s |
if type(r) == "number" and type(g) == "number" and type(b) == "number" then |
if options.hasAlpha and type(a) == "number" then |
print((options.message or IS_NOW_SET_TO):format(tostring(options.cmdName or options.name), s), realOptions.cmdName or realOptions.name or self) |
else |
local r,g,b,a |
if passTable then |
if type(passTable.get) == "function" then |
r,g,b,a = passTable.get(passValue) |
else |
if type(handler[passTable.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(passTable.get))) |
end |
r,g,b,a = handler[passTable.get](handler, passValue) |
end |
if type(options_p.get) == "function" then |
r,g,b,a = options_p.get(passValue) |
else |
if type(options.get) == "function" then |
r,g,b,a = options.get() |
else |
if type(handler[options.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options.get))) |
end |
r,g,b,a = handler[options.get](handler) |
if type(handler[options_p.get]) ~= "function" then |
AceConsole:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(options_p.get))) |
end |
r,g,b,a = handler[options_p.get](handler, passValue) |
end |
if not colorTable then |
colorTable = {} |
local t = colorTable |
if ColorPickerOkayButton then |
local ColorPickerOkayButton_OnClick = ColorPickerOkayButton:GetScript("OnClick") |
ColorPickerOkayButton:SetScript("OnClick", function() |
colorTable[k] = nil |
end |
end |
if type(r) ~= "number" or type(g) ~= "number" or type(b) ~= "number" then |
r,g,b = 1, 1, 1 |
end |
t.realOptions = realOptions |
t.hasAlpha = options.hasAlpha |
t.handler = handler |
t.set = passTable and passTable.set or options.set |
t.get = passTable and passTable.get or options.get |
t.set = options_p.set |
t.get = options_p.get |
t.name = options.cmdName or options.name |
t.message = options.message or IS_NOW_SET_TO |
t.passValue = passValue |
t.active = true |
if not colorFunc then |
colorFunc = function() |
local r,g,b = ColorPickerFrame:GetColorRGB() |
end |
end |
end |
ColorPickerFrame.func = colorFunc |
ColorPickerFrame.hasOpacity = options.hasAlpha |
if options.hasAlpha then |
ColorPickerFrame.opacity = 1 - a |
end |
ColorPickerFrame:SetColorRGB(r,g,b) |
if not colorCancelFunc then |
colorCancelFunc = function() |
if t.hasAlpha then |
ColorPickerFrame.opacityFunc = nil |
end |
end |
ColorPickerFrame.cancelFunc = colorCancelFunc |
ShowUIPanel(ColorPickerFrame) |
end |
return |
elseif kind == "group" then |
if #args == 0 then |
printUsage(self, handler, realOptions, options, path, args) |
printUsage(self, handler, realOptions, options, path, args, passValue) |
else |
-- invalid argument |
print((options.error or IS_NOT_A_VALID_OPTION_FOR):format(args[1], path), realOptions.cmdName or realOptions.name or self) |
end |
return |
end |
this = _G_this |
if Dewdrop then |
Dewdrop:Refresh(1) |
Dewdrop:Refresh(2) |
Dewdrop:Refresh(3) |
Dewdrop:Refresh(4) |
Dewdrop:Refresh(5) |
Dewdrop:Refresh() |
end |
end |
local external |
function AceConsole:RegisterChatCommand(slashCommands, options, name) |
local tmp |
function AceConsole:RegisterChatCommand(...) -- slashCommands, options, name |
local slashCommands, options, name |
if type((...)) == "string" then |
if not tmp then |
tmp = {} |
else |
for i in ipairs(tmp) do |
tmp[i] = nil |
end |
end |
for i = 1, select('#', ...)+1 do |
local v = select(i, ...) |
if type(v) == "string" then |
tmp[#tmp+1] = v |
else |
slashCommands = tmp |
options = v |
name = select(i+1, ...) |
break |
end |
end |
else |
slashCommands, options, name = ... |
end |
if type(slashCommands) ~= "table" and slashCommands ~= false then |
AceConsole:error("Bad argument #2 to `RegisterChatCommand' (expected table, got %s)", type(slashCommands)) |
end |
if #slashCommands == 0 then |
AceConsole:error("Argument #2 to `RegisterChatCommand' must include at least one string") |
end |
for k,v in pairs(slashCommands) do |
if type(k) ~= "number" then |
AceConsole:error("All keys in argument #2 to `RegisterChatCommand' must be numbers") |
end |
end |
end |
if not options then |
options = { |
type = 'group', |
handler = self |
} |
end |
if type(options) == "table" then |
local err, position = validateOptions(options) |
if err then |
AceConsole:error(err) |
end |
end |
if not options.handler then |
options.handler = self |
end |
if options.handler == self and options.type:lower() == "group" and self.class then |
AceConsole:InjectAceOptionsTable(self, options) |
end |
end |
local chat |
if slashCommands then |
chat = slashCommands[1] |
else |
chat = _G["SLASH_"..name..1] |
end |
local handler |
if type(options) == "function" then |
handler = options |
for k,v in pairs(_G) do |
if handler == v then |
local k = k |
handler = function(msg) |
return _G[k](msg) |
handler = function(msg, chatFrame) |
return _G[k](msg, chatFrame) |
end |
break |
end |
end |
else |
function handler(msg) |
function handler(msg, chatFrame) |
handlerFunc(self, chat, msg, options) |
end |
end |
if not _G.SlashCmdList then |
_G.SlashCmdList = {} |
end |
name = string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) .. string.char(math.random(26) + A - 1) |
until not _G.SlashCmdList[name] |
end |
if slashCommands then |
if _G.SlashCmdList[name] then |
local i = 0 |
end |
end |
end |
local i = 0 |
for _,command in ipairs(slashCommands) do |
local good = true |
for k in pairs(_G.SlashCmdList) do |
local j = 0 |
while true do |
j = j + 1 |
local cmd = _G["SLASH_" .. k .. j] |
if not cmd then |
break |
end |
if command:lower() == cmd:lower() then |
good = false |
break |
end |
end |
if not good then |
break |
end |
end |
if good then |
i = i + 1 |
_G["SLASH_"..name..i] = command |
if command:lower() ~= command then |
i = i + 1 |
_G["SLASH_"..name..i] = command |
if command:lower() ~= command then |
i = i + 1 |
_G["SLASH_"..name..i] = command:lower() |
end |
_G["SLASH_"..name..i] = command:lower() |
end |
end |
end |
if self ~= AceConsole and self.slashCommand == nil then |
self.slashCommand = chat |
end |
if not AceEvent and AceLibrary:HasInstance("AceEvent-2.0") then |
external(AceConsole, "AceEvent-2.0", AceLibrary("AceEvent-2.0")) |
end |
end |
end |
end |
AceConsole.registry[name] = options |
if slashCommands == tmp then |
for i in ipairs(tmp) do |
tmp[i] = nil |
end |
end |
end |
function AceConsole:InjectAceOptionsTable(handler, options) |
end |
options.handler = handler |
local class = handler.class |
if not class then |
self:error("Cannot retrieve AceOptions tables from a non-object argument #2") |
end |
while class and class ~= AceOO.Class do |
if type(class.GetAceOptionsDataTable) == "function" then |
local t = class:GetAceOptionsDataTable(handler) |
for k,v in pairs(t) do |
if type(options.args) ~= "table" then |
options.args = {} |
end |
if options.args[k] == nil then |
options.args[k] = v |
end |
end |
end |
local mixins = class.mixins |
if mixins then |
for mixin in pairs(mixins) do |
if not AceLibrary:HasInstance("AceOO-2.0") or not class then |
if Rock then |
-- possible Rock object |
for mixin in Rock:IterateObjectMixins(handler) do |
if type(mixin.GetAceOptionsDataTable) == "function" then |
local t = mixin:GetAceOptionsDataTable(handler) |
for k,v in pairs(t) do |
end |
end |
end |
class = class.super |
else |
-- Ace2 object |
while class and class ~= AceLibrary("AceOO-2.0").Class do |
if type(class.GetAceOptionsDataTable) == "function" then |
local t = class:GetAceOptionsDataTable(handler) |
for k,v in pairs(t) do |
if type(options.args) ~= "table" then |
options.args = {} |
end |
if options.args[k] == nil then |
options.args[k] = v |
end |
end |
end |
local mixins = class.mixins |
if mixins then |
for mixin in pairs(mixins) do |
if type(mixin.GetAceOptionsDataTable) == "function" then |
local t = mixin:GetAceOptionsDataTable(handler) |
for k,v in pairs(t) do |
if type(options.args) ~= "table" then |
options.args = {} |
end |
if options.args[k] == nil then |
options.args[k] = v |
end |
end |
end |
end |
end |
class = class.super |
end |
end |
return options |
end |
if major == "AceEvent-2.0" then |
if not AceEvent then |
AceEvent = instance |
AceEvent:embed(self) |
end |
elseif major == "AceTab-2.0" then |
local handler = v.handler or handler |
if hidden then |
if type(hidden) == "function" then |
hidden = hidden() |
hidden = hidden(v.passValue) |
elseif type(hidden) == "string" then |
local f = hidden |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
self:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
hidden = handler[f](handler) |
hidden = handler[f](handler, v.passValue) |
if neg then |
hidden = not hidden |
end |
local disabled = hidden or v.disabled |
if disabled then |
if type(disabled) == "function" then |
disabled = disabled() |
disabled = disabled(v.passValue) |
elseif type(disabled) == "string" then |
local f = disabled |
local neg = f:match("^~(.-)$") |
if type(handler[f]) ~= "function" then |
self:error("%s: %s", handler, OPTION_HANDLER_NOT_FOUND:format(tostring(f))) |
end |
disabled = handler[f](handler) |
disabled = handler[f](handler, v.passValue) |
if neg then |
disabled = not disabled |
end |
local name, cmd, path = self:TabCompleteInfo(cmdpath) |
if self.registry[name] then |
local validArgs, path2, argwork, handler = findTableLevel(self, self.registry[name], cmd, path) |
printUsage(self, validArgs.handler or handler, self.registry[name], validArgs, path2, argwork, not gcs or gcs ~= "", gcs) |
printUsage(self, validArgs.handler or handler, self.registry[name], validArgs, path2, argwork, argwork[#argwork], not gcs or gcs ~= "", gcs) |
end |
end) |
elseif major == "Dewdrop-2.0" then |
local function activate(self, oldLib, oldDeactivate) |
AceConsole = self |
if oldLib then |
self.registry = oldLib.registry |
self.nextAddon = oldLib.nextAddon |
end |
if not self.registry then |
self.registry = {} |
else |
self:RegisterChatCommand(false, options, name) |
end |
end |
self:RegisterChatCommand({ "/reload", "/rl", "/reloadui" }, function() ReloadUI() end, "RELOAD") |
self:RegisterChatCommand({ "/gm" }, function() ToggleHelpFrame() end, "GM") |
self:RegisterChatCommand("/reload", "/rl", "/reloadui", ReloadUI, "RELOAD") |
self:RegisterChatCommand("/gm", ToggleHelpFrame, "GM") |
local t = { "/print", "/echo" } |
local _,_,_,enabled,loadable = GetAddOnInfo("DevTools") |
if not enabled and not loadable then |
f() |
end |
end, "PRINT") |
self:activate(oldLib, oldDeactivate) |
if oldDeactivate then |
oldDeactivate(oldLib) |
end |
## Interface: 30000 |
## X-Curse-Packaged-Version: r1096 |
## X-Curse-Project-Name: Ace2 |
## X-Curse-Project-ID: ace2 |
## X-Curse-Repository-ID: wow/ace2/mainline |
## Title: Lib: AceConsole-2.0 |
## Notes: AddOn development framework |
## Author: Ace Development Team |
## LoadOnDemand: 1 |
## X-Website: http://www.wowace.com |
## X-Category: Library |
## X-License: LGPL v2.1 + MIT for AceOO-2.0 |
## Dependencies: AceLibrary, AceEvent-2.0, AceOO-2.0 |
AceConsole-2.0.lua |
--[[ |
Name: Crayon-2.0 |
Revision: $Rev: 25921 $ |
Revision: $Rev: 52899 $ |
Author(s): ckknight (ckknight@gmail.com) |
Website: http://ckknight.wowinterface.com/ |
Documentation: http://wiki.wowace.com/index.php/Crayon-2.0 |
--Theondry (theondry@gmail.com) added the purple. yell at me if it's wrong, please |
local MAJOR_VERSION = "Crayon-2.0" |
local MINOR_VERSION = "$Revision: 25921 $" |
local MINOR_VERSION = "$Revision: 52899 $" |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end |
if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
Crayon.COLOR_HEX_SILVER = "c7c7cf" |
Crayon.COLOR_HEX_GOLD = "ffd700" |
Crayon.COLOR_HEX_PURPLE = "9980CC" |
Crayon.COLOR_HEX_BLUE = "0000ff" |
Crayon.COLOR_HEX_BLACK = "000000" |
function Crayon:Colorize(hexColor, text) |
return "|cff" .. tostring(hexColor or 'ffffff') .. tostring(text) .. "|r" |
function Crayon:Silver(text) return self:Colorize(self.COLOR_HEX_SILVER, text) end |
function Crayon:Gold(text) return self:Colorize(self.COLOR_HEX_GOLD, text) end |
function Crayon:Purple(text) return self:Colorize(self.COLOR_HEX_PURPLE, text) end |
function Crayon:Blue(text) return self:Colorize(self.COLOR_HEX_BLUE, text) end |
function Crayon:Black(text) return self:Colorize(self.COLOR_HEX_BLACK, text) end |
local inf = 1/0 |
--[[ |
Name: Tablet-2.0 |
Revision: $Rev: 30695 $ |
Revision: $Rev: 216 $ |
Author(s): ckknight (ckknight@gmail.com) |
Website: http://ckknight.wowinterface.com/ |
Documentation: http://www.wowace.com/index.php/Tablet-2.0 |
]] |
local MAJOR_VERSION = "Tablet-2.0" |
local MINOR_VERSION = tonumber(("$Revision: 30695 $"):sub(12, -3)) |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 216 $"):match("(%d+)")) |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end |
if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
LOCK = "éå®" |
LOCK_DESC = "éå®èåå½åä½ç½®. alt+å³é® å°æ¾ç¤ºé项, alt+æå¨ å¯ä»¥ç§»å¨å·²éå®çèå." |
elseif GetLocale() == "zhTW" then |
SCROLL_UP = "åä¸ç¿»è½" |
SCROLL_DOWN = "åä¸ç¿»è½" |
SCROLL_UP = "åä¸ç¿»æ²" |
SCROLL_DOWN = "åä¸ç¿»æ²" |
HINT = "æ示" |
DETACH = "åé¢" |
DETACH_DESC = "åé¢é¸å®çºç¨ç«æ示ã" |
SIZE = "尺寸" |
SIZE_DESC = "縮æ¾é¸å®é¡¯ç¤ºå°ºå¯¸ã" |
CLOSE_MENU = "ééé¸å®" |
CLOSE_MENU_DESC = "ééé¸å®" |
CLOSE_MENU_DESC = "ééé¸å®ã" |
COLOR = "èæ¯é¡è²" |
COLOR_DESC = "è¨ç½®é¸å®èæ¯é¡è²ã" |
COLOR_DESC = "è¨å®é¸å®èæ¯é¡è²ã" |
LOCK = "éå®" |
LOCK_DESC = "éå®é¸å®ç®åä½ç½®. Alt+å³éµ å°é¡¯ç¤ºé¸é ï¼Alt+æå å¯ä»¥ç§»åå·²éå®çé¸å®ã" |
LOCK_DESC = "éå®é¸å®ç®åä½ç½®è¨å®ãAlt-å³éµå°é¡¯ç¤ºé¸é ï¼Alt-æåå¯ä»¥ç§»åå·²éå®çé¸å®ã" |
elseif GetLocale() == "frFR" then |
SCROLL_UP = "Parcourir vers le haut" |
SCROLL_DOWN = "Parcourir vers le bas" |
COLOR_DESC = "Establece el color de fondo" |
LOCK = "Bloquear" |
LOCK_DESC = "Bloquea el tooltip en su posici\195\179n actual. Clic+Alt para el men\195\186 y arrastra+Alt para arrastrarlo cuando est\195\161 bloqueado" |
elseif GetLocale() == "ruRU" then |
SCROLL_UP = "ÐÑокÑÑÑка ввеÑÑ " |
SCROLL_DOWN = "ÐÑокÑÑÑка вниз" |
HINT = "СовеÑ" |
DETACH = "ÐÑделиÑÑ" |
DETACH_DESC = "ÐÑделиÑÑ Ð¿Ð»Ð°Ð½ÑÐµÑ Ð¾Ñ ÐµÐ³Ð¾ иÑÑоÑника." |
SIZE = "РазмеÑ" |
SIZE_DESC = "ÐаÑÑÑаб планÑеÑа." |
CLOSE_MENU = "ÐакÑÑÑÑ Ð¼ÐµÐ½Ñ" |
CLOSE_MENU_DESC = "ÐакÑÑÑÑ Ð¼ÐµÐ½Ñ." |
COLOR = "Ð¦Ð²ÐµÑ Ñона" |
COLOR_DESC = "УÑÑановиÑÑ ÑÐ²ÐµÑ Ñона." |
LOCK = "ÐаÑикÑиÑоваÑÑ" |
LOCK_DESC = "ÐаÑикÑиÑоваÑÑ Ð¿Ð»Ð°Ð½ÑÐµÑ Ð² его ÑекÑÑем позиÑии. Alt+ÐÐÐ Ð´Ð»Ñ Ð¼ÐµÐ½Ñ Ð¸Ð»Ð¸ Alt+пеÑеÑаÑкивание Ð´Ð»Ñ Ð¿ÐµÑеÑаÑÐºÐ¸Ð²Ð°Ð½Ð¸Ñ ÐºÐ¾Ð³Ð´Ð° планÑÐµÑ Ð·Ð°ÑикÑиÑован." |
end |
local start = GetTime() |
if UIParent:IsShown() then |
return UIParent |
end |
local f = GetFullScreenFrame() |
local f = GetUIPanel("fullscreen") |
if f and f:IsShown() then |
return f |
end |
return nil |
end |
GetMainFrame = wrap(GetMainFrame, "GetMainFrame") |
local MIN_TOOLTIP_SIZE = 200 |
local TESTSTRING_EXTRA_WIDTH = 8 |
local pool = {} |
local function del(t) |
if t then |
for k in pairs(t) do |
t[k] = nil |
end |
setmetatable(t, nil) |
pool[t] = true |
setmetatable(t, nil) |
for k in pairs(t) do |
t[k] = nil |
end |
t[''] = true |
t[''] = nil |
pool[t] = true |
return nil |
end |
local new |
local function copy(parent) |
local t = next(pool) or {} |
pool[t] = nil |
local t = next(pool) |
if not t then |
t = {} |
else |
pool[t] = nil |
end |
if parent then |
for k,v in pairs(parent) do |
t[k] = v |
return t |
end |
function new(...) |
local t = next(pool) or {} |
pool[t] = nil |
local function new(...) |
local t = next(pool) |
if not t then |
t = {} |
else |
pool[t] = nil |
end |
for i = 1, select('#', ...), 2 do |
local k = select(i, ...) |
local headerSize, normalSize |
if GameTooltipHeaderText then |
_,headerSize = GameTooltipHeaderText:GetFont() |
headerSize = select(2,GameTooltipHeaderText:GetFont()) |
else |
headerSize = 14 |
end |
if GameTooltipText then |
_,normalSize = GameTooltipText:GetFont() |
normalSize = select(2,GameTooltipText:GetFont()) |
else |
normalSize = 12 |
end |
testString:SetText(text) |
return testString:GetStringWidth()-- + TESTSTRING_EXTRA_WIDTH |
end |
getTestWidth = wrap(getTestWidth, "getTestWidth") |
do |
local TabletData_mt = { __index = TabletData } |
function TabletData:new(tablet) |
setmetatable(self, TabletData_mt) |
return self |
end |
TabletData.new = wrap(TabletData.new, "TabletData:new") |
function TabletData:checkMinWidth() |
local min = self.minWidth or MIN_TOOLTIP_SIZE |
self.width = width |
end |
end |
TabletData.checkMinWidth = wrap(TabletData.checkMinWidth, "TabletData:checkMinWidth") |
function TabletData:del() |
for k, v in ipairs(self.categories) do |
del(self.categories) |
del(self) |
end |
TabletData.del = wrap(TabletData.del, "TabletData:del") |
function TabletData:Display() |
if self.title and (self.tablet == tooltip or self.tablet.registration.showTitleWhenDetached) then |
self.tablet.tmpHidden = nil |
end |
end |
TabletData.Display = wrap(TabletData.Display, "TabletData:Display") |
function TabletData:AddCategory(info, index) |
local made = false |
end |
return cat |
end |
TabletData.AddCategory = wrap(TabletData.AddCategory, "TabletData:AddCategory") |
function TabletData:SetHint(hint) |
self.hint = hint |
end |
TabletData.SetHint = wrap(TabletData.SetHint, "TabletData:SetHint") |
function TabletData:SetTitle(title) |
self.title = title or "Title" |
end |
TabletData.SetTitle = wrap(TabletData.SetTitle, "TabletData:SetTitle") |
function TabletData:SetTitleColor(r, g, b) |
self.titleR = r |
self.titleG = g |
self.titleB = b |
end |
TabletData.SetTitleColor = wrap(TabletData.SetTitleColor, "TabletData:SetTitleColor") |
end |
do |
local Category_mt = { __index = Category } |
if superCategory and not self.noInherit then |
self.superCategory = superCategory.superCategory |
for k, v in pairs(superCategory) do |
if string.find(k, "^child_") then |
if k:find("^child_") then |
local k = strsub(k, 7) |
if self[k] == nil then |
self[k] = v |
x['size' .. i] = self['size' .. i] |
x['justify' .. i] = self['justify' .. i] |
end |
if self.checkIcon and string.find(self.checkIcon, "^Interface\\Icons\\") then |
if self.checkIcon and self.checkIcon:find("^Interface\\Icons\\") then |
x.checkCoordLeft = self.checkCoordLeft or 0.05 |
x.checkCoordRight = self.checkCoordRight or 0.95 |
x.checkCoordTop = self.checkCoordTop or 0.05 |
end |
return self |
end |
Category.new = wrap(Category.new, "Category:new") |
function Category:del() |
local prev = garbageLine |
del(self.lines) |
del(self) |
end |
Category.del = wrap(Category.del, "Category:del") |
function Category:AddLine(...) |
self.lastWasTitle = nil |
info = del(info) |
end |
end |
Category.AddLine = wrap(Category.AddLine, "Category:AddLine") |
function Category:AddCategory(...) |
local lastWasTitle = self.lastWasTitle |
end |
return cat |
end |
Category.AddCategory = wrap(Category.AddCategory, "Category:AddCategory") |
function Category:HasChildren() |
local hasChildren = false |
end |
return false |
end |
Category.HasChildren = wrap(Category.HasChildren, "Category:HasChildren") |
local lastWasTitle = false |
function Category:Display(tablet) |
if not self.hideBlankLine and not lastWasTitle then |
local info = new( |
'blank', true, |
'fakeChild', true |
'fakeChild', true, |
'noInherit', true |
) |
self:AddLine(info, 1) |
del(info) |
lastWasTitle = self.isTitle |
return good |
end |
Category.Display = wrap(Category.Display, "Category:Display") |
end |
do |
local Line_mt = { __index = Line } |
local self = copy(info) |
if not info.noInherit then |
for k, v in pairs(category) do |
if string.find(k, "^child_") then |
if k:find("^child_") then |
local k = strsub(k, 7) |
if self[k] == nil then |
self[k] = v |
end |
end |
if not self.size then |
_,self.size = self.font:GetFont() |
self.size = select(2,self.font:GetFont()) |
end |
for i = 2, columns do |
if not self['size' .. i] then |
_,self['size' .. i] = self['font' .. i]:GetFont() |
self['size' .. i] = select(2,self['font' .. i]:GetFont()) |
end |
end |
if self.checkIcon and string.find(self.checkIcon, "^Interface\\Icons\\") then |
if self.checkIcon and self.checkIcon:find("^Interface\\Icons\\") then |
if not self.checkCoordLeft then |
self.checkCoordLeft = 0.05 |
end |
end |
return self |
end |
Line.new = wrap(Line.new, "Line:new") |
function Line:del() |
del(self) |
end |
Line.del = wrap(Line.del, "Line:del") |
function Line:Display(tablet) |
tablet:AddLine(self) |
return true |
end |
Line.Display = wrap(Line.Display, "Line:Display") |
end |
local fake_ipairs |
end |
return iter, tmp, 0 |
end |
fake_ipairs = wrap(fake_ipairs, "fake_ipairs") |
end |
local function argunpack(t, key, i) |
if v then |
return v, argunpack(t, key, i+1) |
end |
end |
end |
argunpack = wrap(argunpack, "argunpack") |
local delstring, newstring |
t:SetParent(UIParent) |
return nil |
end |
delstring = wrap(delstring, "delstring") |
function newstring(parent) |
if #cache ~= 0 then |
local t = cache[#cache] |
local t = parent:CreateFontString(nil, "ARTWORK") |
return t |
end |
newstring = wrap(newstring, "newstring") |
end |
local function button_OnEnter(this, ...) |
geterrorhandler()(ret) |
end |
end |
end |
end |
button_OnEnter = wrap(button_OnEnter, "button_OnEnter") |
local function button_OnLeave(this, ...) |
if type(this.self:GetScript("OnLeave")) == "function" then |
end |
end |
end |
button_OnLeave = wrap(button_OnLeave, "button_OnLeave") |
local lastMouseDown |
local function button_OnClick(this, arg1, ...) |
if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then |
end |
end |
end |
button_OnClick = wrap(button_OnClick, "button_OnClick") |
local function button_OnMouseUp(this, arg1, ...) |
if this.self:HasScript("OnMouseUp") and type(this.self:GetScript("OnMouseUp")) == "function" then |
this.self:GetScript("OnMouseUp")(this.self, arg1, ...) |
end |
end |
end |
button_OnMouseUp = wrap(button_OnMouseUp, "button_OnMouseUp") |
local function button_OnMouseDown(this, arg1, ...) |
if this.self:HasScript("OnMouseDown") and type(this.self:GetScript("OnMouseDown")) == "function" then |
this.self:GetScript("OnMouseDown")(this.self, arg1, ...) |
this.clicked = true |
end |
end |
button_OnMouseDown = wrap(button_OnMouseDown, "button_OnMouseDown") |
local function button_OnDragStart(this, ...) |
local parent = this:GetParent() and this:GetParent().tablet |
if parent:GetScript("OnDragStart") then |
return parent:GetScript("OnDragStart")(parent, ...) |
end |
end |
button_OnDragStart = wrap(button_OnDragStart, "button_OnDragStart") |
local function button_OnDragStop(this, ...) |
local parent = this:GetParent() and this:GetParent().tablet |
if parent:GetScript("OnDragStop") then |
return parent:GetScript("OnDragStop")(parent, ...) |
end |
end |
button_OnDragStop = wrap(button_OnDragStop, "button_OnDragStop") |
local num_buttons = 0 |
local function NewLine(self) |
check.shown = false |
check:SetPoint("TOPLEFT", button, "TOPLEFT") |
col1:SetPoint("TOPLEFT", check, "TOPLEFT") |
local _,size = GameTooltipText:GetFont() |
local size = select(2,GameTooltipText:GetFont()) |
check:SetHeight(size * 1.5) |
check:SetWidth(size * 1.5) |
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") |
elseif c:find("^BOTTOM") then |
top = b:GetBottom() |
else |
_,top = b:GetCenter() |
top = select(2,b:GetCenter()) |
end |
if top then |
top = top + e |
elseif c:find("^BOTTOM") then |
bottom = b:GetBottom() |
else |
_,bottom = b:GetCenter() |
bottom = select(2,b:GetCenter()) |
end |
if bottom then |
bottom = bottom + e |
end |
end |
end |
RecalculateTabletHeight = wrap(RecalculateTabletHeight, "RecalculateTabletHeight") |
local function GetTooltipHeight(self) |
RecalculateTabletHeight(self) |
info.font = GameTooltipText |
end |
if not info.size then |
_,info.size = info.font:GetFont() |
info.size = select(2,info.font:GetFont()) |
end |
local catStart = false |
local columns = category and category.columns or 1 |
button.func = nil |
button.onEnterFunc = nil |
button.onLeaveFunc = nil |
button:SetFrameLevel(12) -- hack suggested on forum. Added 06/17/2007. (hC) |
if not self.locked or IsAltKeyDown() then |
local func = info.func |
if func then |
if not frame then |
frame = CreateFrame("Frame") |
frame:SetScript("OnEvent", function(this, _, modifier) |
if modifier == "ALT" then |
if modifier == "LALT" or modifier == "RALT" then |
this.func() |
end |
end) |
frame:RegisterEvent("MODIFIER_STATE_CHANGED") |
frame.func = func |
end |
StartCheckingAlt = wrap(StartCheckingAlt, "StartCheckingAlt") |
function StopCheckingAlt() |
if frame then |
frame:UnregisterEvent("MODIFIER_STATE_CHANGED") |
end |
end |
StopCheckingAlt = wrap(StopCheckingAlt, "StopCheckingAlt") |
end |
function AcquireDetachedFrame(self, registration, data, detachedData) |
detached.r = 0 |
detached.g = 0 |
detached.b = 0 |
detached:SetFrameStrata(registration.strata or "BACKGROUND") |
detached:SetFrameStrata(registration and registration.strata or "BACKGROUND") |
detached:SetBackdrop(tmp.a( |
'bgFile', "Interface\\Buttons\\WHITE8X8", |
'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", |
local width = GetScreenWidth() |
local height = GetScreenHeight() |
if registration.movable == false then |
if registration and registration.movable == false then |
detached:RegisterForDrag() |
else |
detached:RegisterForDrag("LeftButton") |
detached:SetScript("OnDragStop", function(this) |
detached:StopMovingOrSizing() |
detached.moving = nil |
detached:SetClampedToScreen(1) |
detached:SetClampedToScreen(nil) |
local anchor |
local offsetx |
local offsety |
return |
end |
if detached.menu then |
detached.menu(level, value) |
if type(detached.menu) == "function" then |
detached.menu(level, value) |
else |
Dewdrop:FeedAceOptionsTable(detached.menu) |
end |
if level == 1 then |
Dewdrop:AddLine() |
end |
function detached:Lock() |
self:EnableMouse(self.locked) |
self.locked = not self.locked |
self.detachedData.locked = self.locked or nil |
if self.detachedData then |
self.detachedData.locked = self.locked or nil |
end |
self:children() |
end |
local detachedData = info.detachedData |
if detachedData and detachedData.detached then |
ReleaseDetachedFrame(self, data, detachedData) |
elseif tooltip.data == data then |
elseif tooltip and tooltip.data == data then |
tooltip:Hide() |
if tooltip.registration then |
tooltip.registration.tooltip = nil |
tooltip.registration = nil |
end |
end |
tooltip.enteredFrame = false |
if tooltip then tooltip.enteredFrame = false end |
end |
Tablet.Close = wrap(Tablet.Close, "Tablet:Close") |
local function frame_children(self) |
if not self.preventRefresh and self:GetParent() and self:GetParent():IsShown() then |
Tablet.currentFrame = self |
Tablet.currentTabletData = TabletData:new(self) |
Tablet.currentTabletData.minWidth = self.minWidth |
self:ClearLines() |
if self.runChildren then |
self.runChildren() |
end |
Tablet.currentTabletData:Display(Tablet.currentFrame) |
self:Show(Tablet.currentTabletData) |
Tablet.currentTabletData:del() |
Tablet.currentTabletData = nil |
Tablet.currentFrame = nil |
end |
end |
frame_children = wrap(frame_children, "frame_children") |
function Tablet:Open(fakeParent, parent) |
self:argCheck(fakeParent, 2, "table", "string") |
self:argCheck(parent, 3, "nil", "table", "string") |
frame.minWidth = info.minWidth |
if not frame.children or not frame.childrenVer or frame.childrenVer < MINOR_VERSION then |
frame.childrenVer = MINOR_VERSION |
function frame:children() |
if not self.preventRefresh and self:GetParent():IsShown() then |
Tablet.currentFrame = self |
Tablet.currentTabletData = TabletData:new(self) |
Tablet.currentTabletData.minWidth = self.minWidth |
self:ClearLines() |
if self.runChildren then |
self.runChildren() |
end |
Tablet.currentTabletData:Display(Tablet.currentFrame) |
self:Show(Tablet.currentTabletData) |
Tablet.currentTabletData:del() |
Tablet.currentTabletData = nil |
Tablet.currentFrame = nil |
end |
end |
frame.children = frame_children |
end |
frame:SetOwner(fakeParent) |
frame:children() |
end |
local offsetx = 0 |
local offsety = 0 |
frame:SetClampedToScreen(1) |
frame:SetClampedToScreen(nil) |
if frame:GetBottom() and frame:GetLeft() then |
if frame:GetRight() > GetScreenWidth() then |
offsetx = frame:GetRight() - GetScreenWidth() |
info = new(...) |
end |
self.registry[parent] = info |
info.data = info.data or info.detachedData or {} |
info.data = info.data or info.detachedData or new() |
info.detachedData = info.detachedData or info.data |
local data = info.data |
local detachedData = info.detachedData |
end |
_id = 0 |
end |
CleanCategoryPool = wrap(CleanCategoryPool, "CleanCategoryPool") |
function Tablet:AddCategory(...) |
if not self.currentFrame then |
function Tablet:GetNormalFontSize() |
return normalSize |
end |
Tablet.GetNormalFontSize = wrap(Tablet.GetNormalFontSize, "Tablet:GetNormalFontSize") |
function Tablet:GetHeaderFontSize() |
return headerSize |
end |
Tablet.GetHeaderFontSize = wrap(Tablet.GetHeaderFontSize, "Tablet:GetHeaderFontSize") |
function Tablet:GetNormalFontObject() |
return GameTooltipText |
end |
Tablet.GetNormalFontObject = wrap(Tablet.GetNormalFontObject, "Tablet:GetNormalFontObject") |
function Tablet:GetHeaderFontObject() |
return GameTooltipHeaderText |
end |
Tablet.GetHeaderFontObject = wrap(Tablet.GetHeaderFontObject, "Tablet:GetHeaderFontObject") |
function Tablet:SetFontSizePercent(parent, percent) |
self:argCheck(parent, 2, "table", "string") |
if not info.detachedData then |
self:error("You cannot detach tablet without a data field.") |
end |
if info.tooltip and info.tooltip == tooltip then |
if info.tooltip and info.tooltip == tooltip and tooltip.registration then |
tooltip:Detach() |
else |
info.detachedData.detached = true |
detached.minWidth = info.minWidth |
if not detached.children or not detached.childrenVer or detached.childrenVer < MINOR_VERSION then |
detached.childrenVer = MINOR_VERSION |
function detached:children() |
if not self.preventRefresh then |
Tablet.currentFrame = self |
Tablet.currentTabletData = TabletData:new(self) |
Tablet.currentTabletData.minWidth = self.minWidth |
self:ClearLines() |
if self.runChildren then |
self.runChildren() |
end |
Tablet.currentTabletData:Display(Tablet.currentFrame) |
self:Show(Tablet.currentTabletData) |
Tablet.currentTabletData:del() |
Tablet.currentTabletData = nil |
Tablet.currentFrame = nil |
end |
end |
detached.children = frame_children |
end |
detached:SetOwner(parent) |
detached:children() |
SLASH_TABLET1 = "/tablet" |
SLASH_TABLET2 = "/tabletlib" |
SlashCmdList["TABLET"] = function(msg) |
TabletLib:GetInstance(MAJOR_VERSION):ListProfileInfo() |
AceLibrary(MAJOR_VERSION):ListProfileInfo() |
end |
end |
--[[ |
--[[ |
Name: AceAddon-2.0 |
Revision: $Rev: 28672 $ |
Revision: $Rev: 1096 $ |
Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team) |
Inspired By: Ace 1.x by Turan (turan@gryphon.com) |
Website: http://www.wowace.com/ |
]] |
local MAJOR_VERSION = "AceAddon-2.0" |
local MINOR_VERSION = "$Revision: 28672 $" |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 1096 $"):match("(%d+)")) |
-- This ensures the code is only executed if the libary doesn't already exist, or is a newer version |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end |
if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("\n(.-: )in.-\n") or "") .. err) end |
end |
-- Localization |
local STANDBY, TITLE, NOTES, VERSION, AUTHOR, DATE, CATEGORY, EMAIL, CREDITS, WEBSITE, CATEGORIES, ABOUT, LICENSE, PRINT_ADDON_INFO |
local STANDBY, TITLE, NOTES, VERSION, AUTHOR, DATE, CATEGORY, EMAIL, CREDITS, WEBSITE, CATEGORIES, ABOUT, LICENSE, PRINT_ADDON_INFO, DONATE, DONATE_DESC, HOWTO_DONATE_WINDOWS, HOWTO_DONATE_MAC |
if GetLocale() == "deDE" then |
STANDBY = "|cffff5050(Standby)|r" -- capitalized |
ABOUT = "Ãber" |
PRINT_ADDON_INFO = "Gibt Addondaten aus" |
DONATE = "Donate" -- fix |
DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix |
HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix |
HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix |
CATEGORIES = { |
["Action Bars"] = "Aktionsleisten", |
} |
elseif GetLocale() == "frFR" then |
STANDBY = "|cffff5050(attente)|r" |
TITLE = "Titre" |
NOTES = "Notes" |
VERSION = "Version" |
WEBSITE = "Site web" |
CREDITS = "Credits" -- fix |
LICENSE = "License" -- fix |
ABOUT = "A propos" |
PRINT_ADDON_INFO = "Afficher les informations sur l'addon" |
DONATE = "Donate" -- fix |
DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix |
HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix |
HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix |
CATEGORIES = { |
["Action Bars"] = "Barres d'action", |
["Auction"] = "Hôtel des ventes", |
} |
elseif GetLocale() == "koKR" then |
STANDBY = "|cffff5050(ì¬ì©ê°ë¥)|r" |
TITLE = "ì 목" |
NOTES = "ë ¸í¸" |
VERSION = "ë²ì " |
AUTHOR = "ì ìì" |
DATE = "ë ì§" |
CATEGORY = "ë¶ë¥" |
EMAIL = "E-mail" |
WEBSITE = "ì¹ì¬ì´í¸" |
CREDITS = "Credits" -- fix |
LICENSE = "License" -- fix |
EMAIL = "ì ì ì°í¸" |
WEBSITE = "ì¹ ì¬ì´í¸" |
CREDITS = "ê³µë¡ì" |
LICENSE = "ë¼ì´ì¼ì¤" |
ABOUT = "ì ë³´" |
PRINT_ADDON_INFO = "ì ëì¨ ì ë³´ ì¶ë ¥" |
PRINT_ADDON_INFO = "ì ëì¨ì ëí ì 보를 ì¶ë ¥í©ëë¤." |
DONATE = "기ë¶" |
DONATE_DESC = "ì´ ì ëì¨ì ì ìììê² ê¸°ë¶ë¥¼ í©ëë¤." |
HOWTO_DONATE_WINDOWS = "Ctrl-A를 ëë ¤ ë§í¬ë¥¼ ì íí, Ctrl-Cë¡ ë³µì¬í©ëë¤. Alt-Tab ëë ¤ ê²ìì¼ë¡ ë¶í° ëê°í ì¹ ë¸ë¼ì°ì 를 ì½ëë¤. ë³µì¬ë ë§í¬ë¥¼ 주ì ì°½ì ë¶ì¬ë£ê¸° í©ëë¤." |
HOWTO_DONATE_MAC = "Cmd-A를 ëë ¤ ë§í¬ë¥¼ ì íí, Cmd-Cë¡ ë³µì¬í©ëë¤. Cmd-Tab ëë ¤ ê²ìì¼ë¡ ë¶í° ëê°í ì¹ ë¸ë¼ì°ì 를 ì½ëë¤. ë³µì¬ë ë§í¬ë¥¼ 주ì ì°½ì ë¶ì¬ë£ê¸° í©ëë¤." |
CATEGORIES = { |
["Action Bars"] = "ì¡ì ë°", |
["Auction"] = "경매", |
} |
elseif GetLocale() == "zhTW" then |
STANDBY = "|cffff5050(å¾ å½)|r" |
TITLE = "æ¨é¡" |
NOTES = "註è¨" |
VERSION = "çæ¬" |
AUTHOR = "ä½è " |
DATE = "æ¥æ" |
CATEGORY = "é¡å¥" |
EMAIL = "E-mail" |
EMAIL = "é»åéµä»¶" |
WEBSITE = "網ç«" |
CREDITS = "Credits" -- fix |
LICENSE = "License" -- fix |
CREDITS = "ç¹å¥æè¬" |
LICENSE = "çæ¬" |
ABOUT = "éæ¼" |
PRINT_ADDON_INFO = "顯示æ件è³è¨" |
PRINT_ADDON_INFO = "顯示æ件è³è¨ã" |
DONATE = "æè´" |
DONATE_DESC = "æè´éé¢çµ¦æ件ä½è ã" |
HOWTO_DONATE_WINDOWS = "è«æCtrl-Aé¸æ網ç«é£çµï¼Ctrl-Cè¤è£½ç¶²åï¼Alt-Tabåæå°é»è ¦æ¡é¢ï¼æéç覽å¨ï¼å¨ç¶²ååè²¼ä¸ç¶²åã" |
HOWTO_DONATE_MAC = "è«æCmd-Aé¸æ網ç«é£çµï¼Cmd-Cè¤è£½ç¶²åï¼Cmd-Tabåæå°é»è ¦æ¡é¢ï¼æéç覽å¨ï¼å¨ç¶²ååè²¼ä¸ç¶²åã" |
CATEGORIES = { |
["Action Bars"] = "åä½å", |
["Action Bars"] = "åä½æ¢", |
["Auction"] = "æè³£", |
["Audio"] = "é³æ¨", |
["Audio"] = "é³æ", |
["Battlegrounds/PvP"] = "æ°å ´/PvP", |
["Buffs"] = "å¢ç", |
["Chat/Communication"] = "è天/éè¨", |
["Tank"] = "å¦å ", |
["Caster"] = "æ½æ³è ", |
["Combat"] = "æ°é¬¥", |
["Compilations"] = "編輯", |
["Compilations"] = "æ´å", |
["Data Export"] = "è³æå¯åº", |
["Development Tools"] = "éç¼å·¥å ·", |
["Guild"] = "å ¬æ", |
["Frame Modification"] = "æ¡æ¶ä¿®æ¹", |
["Interface Enhancements"] = "ä»é¢å¢å¼·", |
["Inventory"] = "èå ", |
["Library"] = "è³æ庫", |
["Inventory"] = "庫å", |
["Library"] = "ç¨å¼åº«", |
["Map"] = "å°å", |
["Mail"] = "éµä»¶", |
["Miscellaneous"] = "ç¶å", |
["Miscellaneous"] = "éé ", |
["Quest"] = "ä»»å", |
["Raid"] = "åé", |
["Tradeskill"] = "åæ¥æè½", |
["Tradeskill"] = "交ææè½", |
["UnitFrame"] = "å®ä½æ¡æ¶", |
} |
elseif GetLocale() == "zhCN" then |
STANDBY = "|cffff5050(ææ)|r" |
TITLE = "æ é¢" |
NOTES = "é注" |
VERSION = "çæ¬" |
WEBSITE = "ç½ç«" |
CREDITS = "Credits" -- fix |
LICENSE = "License" -- fix |
ABOUT = "å ³äº" |
PRINT_ADDON_INFO = "å°ååºæ件信æ¯" |
DONATE = "Donate" -- fix |
DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix |
HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix |
HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix |
CATEGORIES = { |
["Action Bars"] = "å¨ä½æ¡", |
["Auction"] = "æå", |
["Shaman"] = "è¨æ»¡ç¥å¸", |
["Warlock"] = "æ¯å£«", |
["Warrior"] = "æ士", |
-- ["Healer"] = "æ²»çä¿é", |
-- ["Tank"] = "è¿ææ§å¶", |
-- ["Caster"] = "è¿ç¨è¾åº", |
["Healer"] = "Healer", |
["Tank"] = "Tank", |
["Caster"] = "Caster", |
["Combat"] = "ææ", |
["Compilations"] = "ç¼è¯", |
["Data Export"] = "æ°æ®å¯¼åº", |
} |
elseif GetLocale() == "esES" then |
STANDBY = "|cffff5050(espera)|r" |
TITLE = "TÃtulo" |
NOTES = "Notas" |
VERSION = "Versión" |
WEBSITE = "Web" |
CREDITS = "Créditos" |
LICENSE = "License" -- fix |
ABOUT = "Acerca de" |
PRINT_ADDON_INFO = "Muestra información acerca del accesorio." |
DONATE = "Donate" -- fix |
DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix |
HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix |
HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix |
CATEGORIES = { |
["Action Bars"] = "Barras de Acción", |
["Auction"] = "Subasta", |
["Tradeskill"] = "Habilidad de Comercio", |
["UnitFrame"] = "Marco de Unidades", |
} |
elseif GetLocale() == "ruRU" then |
STANDBY = "|cffff5050(в Ñежиме ожиданиÑ)|r" |
TITLE = "Ðазвание" |
NOTES = "ÐпиÑание" |
VERSION = "ÐеÑÑиÑ" |
AUTHOR = "ÐвÑоÑ" |
DATE = "ÐаÑа" |
CATEGORY = "ÐаÑегоÑиÑ" |
EMAIL = "E-mail" |
WEBSITE = "СайÑ" |
CREDITS = "ТиÑÑÑ" |
LICENSE = "ÐиÑензиÑ" |
ABOUT = "Ðб аддоне" |
PRINT_ADDON_INFO = "ÐоказаÑÑ Ð¸Ð½ÑоÑмаÑÐ¸Ñ Ð¾Ð± аддоне." |
DONATE = "ÐожеÑÑвоваÑÑ" |
DONATE_DESC = "ÐÑблагодаÑиÑÑ Ð°Ð²ÑоÑа за ÑазÑабоÑÐºÑ Ð°Ð´Ð´Ð¾Ð½Ð°." |
HOWTO_DONATE_WINDOWS = "ÐÐ»Ñ Ð²ÑÐ´ÐµÐ»ÐµÐ½Ð¸Ñ Ð²Ñей ÑÑÑлки нажмиÑе Ctrl-A, поÑом Ð´Ð»Ñ ÐµÑ ÐºÐ¾Ð¿Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ctrl-C, ÑÑÐ¾Ð±Ñ ÑвеÑнÑÑÑ Ð¸Ð³ÑÑ - Alt-Tab, оÑкÑойÑе Ð²Ð°Ñ Ð±ÑаÑÐ·ÐµÑ Ð¸ вÑÑавÑÑе ÑÑÑÐ»ÐºÑ Ð² адÑеÑнÑÑ ÑÑÑÐ¾ÐºÑ - Ctrl-V" |
HOWTO_DONATE_MAC = "ÐÐ»Ñ Ð²ÑÐ´ÐµÐ»ÐµÐ½Ð¸Ñ Ð²Ñей ÑÑÑлки нажмиÑе Cmd-A, поÑом Ð´Ð»Ñ ÐµÑ ÐºÐ¾Ð¿Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ctrl-C, ÑÑÐ¾Ð±Ñ ÑвеÑнÑÑÑ Ð¸Ð³ÑÑ - Cmd-Tab, оÑкÑойÑе Ð²Ð°Ñ Ð±ÑаÑÐ·ÐµÑ Ð¸ вÑÑавÑÑе ÑÑÑÐ»ÐºÑ Ð² адÑеÑнÑÑ ÑÑÑÐ¾ÐºÑ Cmd-V" |
CATEGORIES = { |
["Action Bars"] = "Ðанели команд", |
["Auction"] = "ÐÑкÑион", |
["Audio"] = "ÐÑдио", |
["Battlegrounds/PvP"] = "ÐÐ¾Ð»Ñ ÑÑажений/PvP", |
["Buffs"] = "ÐаÑÑÑ", |
["Chat/Communication"] = "ЧаÑ/ÐоммÑникаÑиÑ", |
["Druid"] = "ÐÑÑид", |
["Hunter"] = "ÐÑ Ð¾Ñник", |
["Mage"] = "Ðаг", |
["Paladin"] = "Ðаладин", |
["Priest"] = "ÐÑеÑ", |
["Rogue"] = "Разбойник", |
["Shaman"] = "Шаман", |
["Warlock"] = "ЧеÑнокнижник", |
["Warrior"] = "Ðоин", |
["Healer"] = "ÐекаÑÑ", |
["Tank"] = "Танк", |
["Caster"] = "ÐаÑÑеÑ", |
["Combat"] = "СÑажениÑ", |
["Compilations"] = "ÐомпилÑÑиÑ", |
["Data Export"] = "ÐкÑпоÑÑ Ð´Ð°Ð½Ð½ÑÑ ", |
["Development Tools"] = "ÐнÑÑÑÑменÑÑ ÑазÑабоÑÑика", |
["Guild"] = "ÐилÑдиÑ", |
["Frame Modification"] = "ÐодиÑикаÑÐ¸Ñ ÑÑеймов", |
["Interface Enhancements"] = "УлÑÑÑение инÑеÑÑейÑа", |
["Inventory"] = "ÐнвенÑаÑÑ", |
["Library"] = "ÐиблиоÑеки", |
["Map"] = "ÐаÑÑа", |
["Mail"] = "ÐоÑÑа", |
["Miscellaneous"] = "Разное", |
["Quest"] = "ÐаданиÑ", |
["Raid"] = "Рейд", |
["Tradeskill"] = "УмениÑ", |
["UnitFrame"] = "ФÑÐµÐ¹Ð¼Ñ Ð¿ÐµÑÑонажей", |
} |
else -- enUS |
STANDBY = "|cffff5050(standby)|r" |
TITLE = "Title" |
NOTES = "Notes" |
VERSION = "Version" |
WEBSITE = "Website" |
CREDITS = "Credits" |
LICENSE = "License" |
ABOUT = "About" |
PRINT_ADDON_INFO = "Show information about the addon." |
DONATE = "Donate" |
DONATE_DESC = "Give a much-needed donation to the author of this addon." |
HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." |
HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." |
CATEGORIES = { |
["Action Bars"] = "Action Bars", |
["Auction"] = "Auction", |
local lowerKey = key:lower() |
for k,v in pairs(CATEGORIES) do |
if k:lower() == lowerKey then |
self[lowerKey] = v |
return v |
end |
end |
if AceAddon.playerLoginFired then |
AceAddon.addonsStarted[self] = true |
if (type(self.IsActive) ~= "function" or self:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(self) or AceModuleCore:IsModuleActive(self)) then |
AceAddon.addonsEnabled[self] = true |
local current = self.class |
while true do |
if current == AceOO.Class or not current then |
break |
end |
if current.mixins then |
for mixin in pairs(current.mixins) do |
if type(mixin.OnEmbedEnable) == "function" then |
safecall(mixin.OnEmbedEnable,mixin,self,true) |
end |
end |
end |
current = current.super |
end |
if type(self.OnEnable) == "function" then |
safecall(self.OnEnable,self,true) |
end |
if AceEvent then |
AceEvent:TriggerEvent("Ace2_AddonEnabled", self, true) |
end |
AceAddon:ManualEnable(self) |
end |
else |
if not AceAddon.addonsToOnEnable then |
end |
if addon.version == nil then |
addon.version = GetAddOnMetadata(name, "Version") |
end |
end |
if type(addon.version) == "string" then |
if addon.version:find("%$Revision: (%d+) %$") then |
addon.version = addon.version:gsub("%$Revision: (%d+) %$", "%1") |
if type(addon.credits) == "string" then |
addon.credits = addon.credits:trim() |
end |
if addon.donate == nil then |
addon.donate = GetAddOnMetadata(name, "X-Donate") |
end |
if type(addon.donate) == "string" then |
addon.donate = addon.donate:trim() |
end |
if addon.date == nil then |
addon.date = GetAddOnMetadata(name, "X-Date") or GetAddOnMetadata(name, "X-ReleaseDate") |
end |
current = current.super |
end |
local n = AceAddon.addonsToOnEnable and #AceAddon.addonsToOnEnable or 0 |
if type(addon.OnInitialize) == "function" then |
safecall(addon.OnInitialize, addon, name) |
end |
end |
end |
local aboutFrame |
local function createAboutFrame() |
aboutFrame = CreateFrame("Frame", "AceAddon20AboutFrame", UIParent, "DialogBoxFrame") |
aboutFrame:SetWidth(500) |
aboutFrame:SetHeight(400) |
aboutFrame:SetPoint("CENTER") |
aboutFrame:SetBackdrop({ |
bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], |
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 5, right = 5, top = 5, bottom = 5 } |
}) |
aboutFrame:SetBackdropColor(0,0,0,1) |
local donateButton = CreateFrame("Button", "AceAddon20AboutFrameDonateButton", aboutFrame, "UIPanelButtonTemplate2") |
aboutFrame.donateButton = donateButton |
donateButton:SetPoint("BOTTOMRIGHT", -20, 20) |
_G.AceAddon20AboutFrameDonateButtonText:SetText(DONATE) |
donateButton:SetWidth(_G.AceAddon20AboutFrameDonateButtonText:GetWidth()+20) |
donateButton:SetScript("OnClick", function() |
aboutFrame.currentAddon:OpenDonationFrame() |
end) |
local text = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge") |
aboutFrame.title = text |
text:SetPoint("TOP", 0, -5) |
aboutFrame:Hide() |
aboutFrame.lefts = {} |
aboutFrame.rights = {} |
aboutFrame.textLefts = {} |
aboutFrame.textRights = {} |
function aboutFrame:Clear() |
self.title:SetText("") |
for i = 1, #self.lefts do |
self.lefts[i] = nil |
self.rights[i] = nil |
end |
end |
function aboutFrame:AddLine(left, right) |
aboutFrame.lefts[#aboutFrame.lefts+1] = left |
aboutFrame.rights[#aboutFrame.rights+1] = right |
end |
local aboutFrame_Show = aboutFrame.Show |
function aboutFrame:Show(...) |
local maxLeftWidth = 0 |
local maxRightWidth = 0 |
local textHeight = 0 |
for i = 1, #self.lefts do |
if not self.textLefts[i] then |
local left = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal") |
self.textLefts[i] = left |
local right = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") |
self.textRights[i] = right |
if i == 1 then |
left:SetPoint("TOPRIGHT", aboutFrame, "TOPLEFT", 75, -35) |
else |
left:SetPoint("TOPRIGHT", self.textLefts[i-1], "BOTTOMRIGHT", 0, -5) |
end |
right:SetPoint("LEFT", left, "RIGHT", 5, 0) |
end |
self.textLefts[i]:SetText(self.lefts[i] .. ":") |
self.textRights[i]:SetText(self.rights[i]) |
local leftWidth = self.textLefts[i]:GetWidth() |
local rightWidth = self.textRights[i]:GetWidth() |
textHeight = self.textLefts[i]:GetHeight() |
if maxLeftWidth < leftWidth then |
maxLeftWidth = leftWidth |
end |
if maxRightWidth < rightWidth then |
maxRightWidth = rightWidth |
end |
end |
for i = #self.lefts+1, #self.textLefts do |
self.textLefts[i]:SetText('') |
self.textRights[i]:SetText('') |
end |
aboutFrame:SetWidth(75 + maxRightWidth + 20) |
aboutFrame:SetHeight(#self.lefts * (textHeight + 5) + 100) |
aboutFrame_Show(self, ...) |
end |
aboutFrame:Hide() |
createAboutFrame = nil |
end |
local donateFrame |
local function unobfuscateEmail(email) |
return email:gsub(" AT ", "@"):gsub(" DOT ", ".") |
end |
local function isGoodVariable(var) |
return type(var) == "string" or type(var) == "number" |
end |
function AceAddon.prototype:PrintAddonInfo() |
if createAboutFrame then |
createAboutFrame() |
end |
aboutFrame:Clear() |
local x |
if isGoodVariable(self.title) then |
x = "|cffffff7f" .. tostring(self.title) .. "|r" |
x = tostring(self.title) |
elseif isGoodVariable(self.name) then |
x = "|cffffff7f" .. tostring(self.name) .. "|r" |
x = tostring(self.name) |
else |
x = "|cffffff7f<" .. tostring(self.class) .. " instance>|r" |
x = "<" .. tostring(self.class) .. " instance>" |
end |
if type(self.IsActive) == "function" then |
if not self:IsActive() then |
x = x .. " " .. STANDBY |
end |
end |
aboutFrame.title:SetText(x) |
if isGoodVariable(self.version) then |
x = x .. " - |cffffff7f" .. tostring(self.version) .. "|r" |
aboutFrame:AddLine(VERSION, tostring(self.version)) |
end |
if isGoodVariable(self.notes) then |
x = x .. " - " .. tostring(self.notes) |
aboutFrame:AddLine(NOTES, tostring(self.notes)) |
end |
print(x) |
if isGoodVariable(self.author) then |
print(" - |cffffff7f" .. AUTHOR .. ":|r " .. tostring(self.author)) |
aboutFrame:AddLine(AUTHOR, tostring(self.author)) |
end |
if isGoodVariable(self.credits) then |
print(" - |cffffff7f" .. CREDITS .. ":|r " .. tostring(self.credits)) |
aboutFrame:AddLine(CREDITS, tostring(self.credits)) |
end |
if isGoodVariable(self.date) then |
print(" - |cffffff7f" .. DATE .. ":|r " .. tostring(self.date)) |
aboutFrame:AddLine(DATE, tostring(self.date)) |
end |
if self.category then |
if isGoodVariable(self.category) then |
local category = CATEGORIES[self.category] |
if category then |
print(" - |cffffff7f" .. CATEGORY .. ":|r " .. category) |
end |
aboutFrame:AddLine(CATEGORY, category or tostring(self.category)) |
end |
if isGoodVariable(self.email) then |
print(" - |cffffff7f" .. EMAIL .. ":|r " .. tostring(self.email)) |
aboutFrame:AddLine(EMAIL, unobfuscateEmail(tostring(self.email))) |
end |
if isGoodVariable(self.website) then |
print(" - |cffffff7f" .. WEBSITE .. ":|r " .. tostring(self.website)) |
aboutFrame:AddLine(WEBSITE, tostring(self.website)) |
end |
if isGoodVariable(self.license) then |
print(" - |cffffff7f" .. LICENSE .. ":|r " .. tostring(self.license)) |
aboutFrame:AddLine(LICENSE, tostring(self.license)) |
end |
if donateFrame and donateFrame:IsShown() then |
donateFrame:Hide() |
end |
aboutFrame.currentAddon = self |
aboutFrame:Show() |
if self.donate then |
aboutFrame.donateButton:Show() |
else |
aboutFrame.donateButton:Hide() |
end |
end |
local function createDonateFrame() |
donateFrame = CreateFrame("Frame", "AceAddon20Frame", UIParent, "DialogBoxFrame") |
donateFrame:SetWidth(500) |
donateFrame:SetHeight(200) |
donateFrame:SetPoint("CENTER") |
donateFrame:SetBackdrop({ |
bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], |
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 5, right = 5, top = 5, bottom = 5 } |
}) |
donateFrame:SetBackdropColor(0,0,0,1) |
local text = donateFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge") |
text:SetPoint("TOP", 0, -5) |
text:SetText(DONATE) |
local howto = donateFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") |
howto:SetPoint("TOP", text, "BOTTOM", 0, -5) |
howto:SetPoint("LEFT", 16, 0) |
howto:SetPoint("RIGHT", -16, 0) |
if not IsMacClient() then |
-- Windows or Linux |
howto:SetText(HOWTO_DONATE_WINDOWS) |
else |
howto:SetText(HOWTO_DONATE_MAC) |
end |
local scrollFrame = CreateFrame("ScrollFrame", "AceAddon20FrameScrollFrame", donateFrame, "UIPanelScrollFrameTemplate") |
scrollFrame:SetToplevel(true) |
scrollFrame:SetPoint("TOP", -10, -76) |
scrollFrame:SetWidth(455) |
scrollFrame:SetHeight(70) |
howto:SetPoint("BOTTOM", scrollFrame, "TOP") |
local editBox = CreateFrame("EditBox", nil, scrollFrame) |
donateFrame.editBox = editBox |
scrollFrame:SetScrollChild(editBox) |
editBox:SetFontObject(ChatFontNormal) |
editBox:SetMultiLine(true) |
editBox:SetMaxLetters(99999) |
editBox:SetWidth(450) |
editBox:SetHeight(54) |
editBox:SetPoint("BOTTOM", 5, 0) |
editBox:SetJustifyH("LEFT") |
editBox:SetJustifyV("TOP") |
editBox:SetAutoFocus(false) |
editBox:SetScript("OnTextChanged", function(this) |
if this:GetText() ~= this.text then |
this:SetText(this.text) |
end |
end) |
editBox:SetScript("OnEscapePressed", function(this) |
this:ClearFocus() |
end) |
createDonateFrame = nil |
end |
local function fix(char) |
return ("%%%02x"):format(char:byte()) |
end |
local function urlencode(text) |
return text:gsub("[^0-9A-Za-z]", fix) |
end |
function AceAddon.prototype:OpenDonationFrame() |
if createDonateFrame then |
createDonateFrame() |
end |
local donate = self.donate |
if type(donate) ~= "string" then |
donate = "Wowace" |
end |
local style, data = (":"):split(donate, 2) |
style = style:lower() |
if style ~= "website" and style ~= "paypal" then |
style = "wowace" |
end |
if style == "wowace" then |
donateFrame.editBox.text = "http://www.wowace.com/wiki/Donations" |
elseif style == "website" then |
donateFrame.editBox.text = data |
else -- PayPal |
local text = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" .. urlencode(unobfuscateEmail(data)) |
local name |
if type(self.title) == "string" then |
name = self.title |
elseif type(self.name) == "string" then |
name = self.name |
end |
if name then |
name = name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "") |
text = text .. "&item_name=" .. urlencode(name) |
end |
donateFrame.editBox.text = text |
end |
donateFrame.editBox:SetText(donateFrame.editBox.text) |
if aboutFrame and aboutFrame:IsShown() then |
aboutFrame:Hide() |
end |
donateFrame:Show() |
donateFrame.editBox:SetFocus() |
end |
local options |
function AceAddon:GetAceOptionsDataTable(target) |
if not options then |
options = { |
about = { |
name = ABOUT, |
desc = PRINT_ADDON_INFO, |
type = "execute", |
func = "PrintAddonInfo", |
order = -1, |
} |
return { |
about = { |
name = ABOUT, |
desc = PRINT_ADDON_INFO, |
type = "execute", |
func = "PrintAddonInfo", |
order = -1, |
}, |
donate = { |
name = DONATE, |
desc = DONATE_DESC, |
type = "execute", |
func = "OpenDonationFrame", |
order = -1, |
hidden = function() |
return not target.donate |
end |
} |
end |
return options |
} |
end |
function AceAddon:PLAYER_LOGIN() |
local addon = table.remove(self.addonsToOnEnable, 1) |
self.addonsStarted[addon] = true |
if (type(addon.IsActive) ~= "function" or addon:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(addon) or AceModuleCore:IsModuleActive(addon)) then |
self.addonsEnabled[addon] = true |
local current = addon.class |
while true do |
if current == AceOO.Class or not current then |
break |
end |
if current.mixins then |
for mixin in pairs(current.mixins) do |
if type(mixin.OnEmbedEnable) == "function" then |
safecall(mixin.OnEmbedEnable, mixin, addon, true) |
end |
end |
end |
current = current.super |
end |
if type(addon.OnEnable) == "function" then |
safecall(addon.OnEnable, addon, true) |
end |
if AceEvent then |
AceEvent:TriggerEvent("Ace2_AddonEnabled", addon, true) |
end |
AceAddon:ManualEnable(addon) |
end |
end |
self.addonsToOnEnable = nil |
return class:new() |
end |
function AceAddon:ManualEnable(addon) |
AceAddon:argCheck(addon, 2, "table") |
local first = nil |
if AceOO.inherits(addon, "AceAddon-2.0") then |
if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[addon] then |
first = true |
AceAddon.addonsEnabled[addon] = true |
end |
end |
local current = addon.class |
while current and current ~= AceOO.Class do |
if current.mixins then |
for mixin in pairs(current.mixins) do |
if type(mixin.OnEmbedEnable) == "function" then |
safecall(mixin.OnEmbedEnable, mixin, addon, first) |
end |
end |
end |
current = current.super |
end |
if type(addon.OnEnable) == "function" then |
safecall(addon.OnEnable, addon, first) |
end |
if AceEvent then |
AceEvent:TriggerEvent("Ace2_AddonEnabled", addon, first) |
end |
end |
function AceAddon:ManualDisable(addon) |
AceAddon:argCheck(addon, 2, "table") |
local current = addon.class |
while current and current ~= AceOO.Class do |
if current.mixins then |
for mixin in pairs(current.mixins) do |
if type(mixin.OnEmbedDisable) == "function" then |
safecall(mixin.OnEmbedDisable, mixin, addon) |
end |
end |
end |
current = current.super |
end |
if type(module.OnDisable) == "function" then |
safecall(module.OnDisable, addon) |
end |
if AceEvent then |
AceEvent:TriggerEvent("Ace2_AddonDisabled", addon) |
end |
end |
local function external(self, major, instance) |
if major == "AceEvent-2.0" then |
AceEvent = instance |
AceEvent:embed(self) |
self:RegisterEvent("PLAYER_LOGIN", "PLAYER_LOGIN", true) |
elseif major == "AceConsole-2.0" then |
AceConsole = instance |
local slashCommands = { "/ace2" } |
local _,_,_,enabled,loadable = GetAddOnInfo("Ace") |
if not enabled or not loadable then |
if not depth then |
depth = 0 |
end |
local s = (" "):rep(depth) .. " - " .. tostring(addon) |
if rawget(addon, 'version') then |
s = s .. " - |cffffff7f" .. tostring(addon.version) .. "|r" |
local function activate(self, oldLib, oldDeactivate) |
AceAddon = self |
self.playerLoginFired = oldLib and oldLib.playerLoginFired or DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage |
self.addonsToOnEnable = oldLib and oldLib.addonsToOnEnable |
self.addons = oldLib and oldLib.addons or {} |
self.skipAddon = oldLib and oldLib.skipAddon or {} |
self.addonsStarted = oldLib and oldLib.addonsStarted or {} |
self.addonsEnabled = oldLib and oldLib.addonsEnabled or {} |
if oldDeactivate then |
oldDeactivate(oldLib) |
end |
## Interface: 30000 |
## X-Curse-Packaged-Version: r1096 |
## X-Curse-Project-Name: Ace2 |
## X-Curse-Project-ID: ace2 |
## X-Curse-Repository-ID: wow/ace2/mainline |
## Title: Lib: AceAddon-2.0 |
## Notes: AddOn development framework |
## Author: Ace Development Team |
## LoadOnDemand: 1 |
## X-Website: http://www.wowace.com |
## X-Category: Library |
## X-License: LGPL v2.1 + MIT for AceOO-2.0 |
## Dependencies: AceLibrary, AceOO-2.0 |
AceAddon-2.0.lua |
--[[ |
--[[ |
Name: AceDB-2.0 |
Revision: $Rev: 29174 $ |
Revision: $Rev: 1094 $ |
Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team) |
Inspired By: Ace 1.x by Turan (turan@gryphon.com) |
Website: http://www.wowace.com/ |
Documentation: http://www.wowace.com/index.php/AceDB-2.0 |
SVN: http://svn.wowace.com/root/trunk/Ace2/AceDB-2.0 |
SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceDB-2.0 |
Description: Mixin to allow for fast, clean, and featureful saved variable |
access. |
Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0 |
]] |
local MAJOR_VERSION = "AceDB-2.0" |
local MINOR_VERSION = "$Revision: 29174 $" |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 1094 $"):match("(%d+)")) |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end |
if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
local ACTIVE, ENABLED, STATE, TOGGLE_ACTIVE, MAP_ACTIVESUSPENDED, SET_PROFILE, SET_PROFILE_USAGE, PROFILE, PLAYER_OF_REALM, CHOOSE_PROFILE_DESC, CHOOSE_PROFILE_GUI, COPY_PROFILE_DESC, COPY_PROFILE_GUI, OTHER_PROFILE_DESC, OTHER_PROFILE_GUI, OTHER_PROFILE_USAGE, RESET_PROFILE, RESET_PROFILE_DESC, CHARACTER_COLON, REALM_COLON, CLASS_COLON, DEFAULT, ALTERNATIVE |
-- Move these into "enUS" when they've been translated in all other locales |
local DELETE_PROFILE = "Delete" |
local DELETE_PROFILE_DESC = "Deletes a profile. Note that no check is made whether this profile is in use by other characters or not." |
local DELETE_PROFILE_USAGE = "<profile name>" |
if GetLocale() == "deDE" then |
DELETE_PROFILE = "L\195\182schen" |
DELETE_PROFILE_DESC = "L\195\182scht ein Profil. Beachte das nicht \195\188berpr\195\188ft wird ob das zu l\195\182schende Profil von anderen Charakteren genutzt wird oder nicht." |
DELETE_PROFILE_USAGE = "<profil name>" |
ACTIVE = "Aktiv" |
ENABLED = "Aktiviert" |
STATE = "Status" |
OTHER_PROFILE_DESC = "W\195\164hle ein anderes Profil." |
OTHER_PROFILE_GUI = "Anderes" |
OTHER_PROFILE_USAGE = "<Profilname>" |
RESET_PROFILE = "Reset profile" -- fix |
RESET_PROFILE_DESC = "Clear all settings of the current profile." -- fix |
RESET_PROFILE = "Resette das Profil" |
RESET_PROFILE_DESC = "Entfernt alle Einstellungen des gegenw\195\164rtigen Profils." |
CHARACTER_COLON = "Charakter: " |
REALM_COLON = "Realm: " |
CLASS_COLON = "Klasse: " |
DEFAULT = "Default" -- fix |
ALTERNATIVE = "Alternative" -- fix |
DEFAULT = "Vorgabe" |
ALTERNATIVE = "Alternativ" |
elseif GetLocale() == "frFR" then |
ACTIVE = "Actif" |
ENABLED = "Activ\195\169" |
CHARACTER_COLON = "Personnage: " |
REALM_COLON = "Royaume: " |
CLASS_COLON = "Classe: " |
DEFAULT = "Default" -- fix |
ALTERNATIVE = "Alternative" -- fix |
elseif GetLocale() == "koKR" then |
ACTIVE = "íì±í" |
ENABLED = "íì±í" |
DELETE_PROFILE = "ìì " |
DELETE_PROFILE_DESC = "íë¡íì ìì í©ëë¤." |
DELETE_PROFILE_USAGE = "<íë¡íëª >" |
ACTIVE = "ì¬ì©" |
ENABLED = "ì¬ì©" |
STATE = "ìí" |
TOGGLE_ACTIVE = "ì´ ì ëì¨ ì¤ì§/ê³ì ì¤í" |
MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00íì±í|r", [false] = "|cffff0000ì¤ì§ë¨|r" } |
TOGGLE_ACTIVE = "ì´ ì ëì¨ ì¤ì§/ë¤ì ìì" |
MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00ì¬ì©|r", [false] = "|cffff0000ì¤ì§|r" } |
SET_PROFILE = "ì´ ì ëì¨ì íë¡í ì¤ì " |
SET_PROFILE_USAGE = "{ìºë¦í°ëª || ì§ì || ìë²ëª || <íë¡íëª >}" |
PROFILE = "íë¡í" |
PLAYER_OF_REALM = "%s (%s ìë²)" |
CHOOSE_PROFILE_DESC = "íë¡íì¼ì ì íí©ëë¤." |
CHOOSE_PROFILE_DESC = "íë¡íì ì íí©ëë¤." |
CHOOSE_PROFILE_GUI = "ì í" |
COPY_PROFILE_DESC = "ë¤ë¥¸ íë¡íì¼ìì ì¤ì ì ë³µì¬í©ëë¤." |
COPY_PROFILE_DESC = "ë¤ë¥¸ íë¡í ì¤ì ì ë³µì¬í©ëë¤." |
COPY_PROFILE_GUI = "ë³µì¬" |
OTHER_PROFILE_DESC = "ë¤ë¥¸ íë¡íì¼ì ì íí©ëë¤." |
OTHER_PROFILE_DESC = "ë¤ë¥¸ íë¡íì ì íí©ëë¤." |
OTHER_PROFILE_GUI = "기í" |
OTHER_PROFILE_USAGE = "<íë¡íì¼ëª >" |
RESET_PROFILE = "Reset profile" -- fix |
RESET_PROFILE_DESC = "Clear all settings of the current profile." -- fix |
OTHER_PROFILE_USAGE = "<íë¡íëª >" |
RESET_PROFILE = "íë¡í ì´ê¸°í" |
RESET_PROFILE_DESC = "모ë ì¸í ìì íì¬ íë¡íì ì´ê¸°í í©ëë¤." |
CHARACTER_COLON = "ìºë¦í°: " |
REALM_COLON = "ìë²: " |
CLASS_COLON = "ì§ì : " |
DEFAULT = "Default" -- fix |
ALTERNATIVE = "Alternative" -- fix |
DEFAULT = "기본ê°" |
ALTERNATIVE = "ëì²´" |
elseif GetLocale() == "zhTW" then |
DELETE_PROFILE = "åªé¤" |
DELETE_PROFILE_DESC = "åªé¤è¨éæªã注æï¼æå¯è½å¥çè§è²ä¹ä½¿ç¨éåè¨éæªã" |
DELETE_PROFILE_USAGE = "<è¨éæªå稱>" |
ACTIVE = "åå" |
ENABLED = "åç¨" |
STATE = "çæ " |
TOGGLE_ACTIVE = "æ«å/éåéåæ件ã" |
TOGGLE_ACTIVE = "æ«å/ç¹¼çºä½¿ç¨éåæ件ã" |
MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00åå|r", [false] = "|cffff0000å·²æ«å|r" } |
SET_PROFILE = "è¨å®éæ件çè¨éæªã" |
SET_PROFILE_USAGE = "{è§è² || è¯æ¥ || 伺æå¨ || <è¨éæªå稱>}" |
SET_PROFILE_USAGE = "{è§è² || è·æ¥ || 伺æå¨ || <è¨éæªå稱>}" |
PROFILE = "è¨éæª" |
PLAYER_OF_REALM = "%s æ¼ %s" |
CHOOSE_PROFILE_DESC = "é¸æä¸åè¨éæª" |
PLAYER_OF_REALM = "%s - %s" |
CHOOSE_PROFILE_DESC = "é¸æä¸åè¨éæªã" |
CHOOSE_PROFILE_GUI = "é¸æ" |
COPY_PROFILE_DESC = "ç±å ¶ä»è¨éæªè¤è£½è¨å®ã" |
COPY_PROFILE_GUI = "è¤è£½ç±" |
COPY_PROFILE_GUI = "è¤è£½èª" |
OTHER_PROFILE_DESC = "é¸æå ¶ä»è¨éæªã" |
OTHER_PROFILE_GUI = "å ¶ä»" |
OTHER_PROFILE_USAGE = "<è¨éæªå稱>" |
RESET_PROFILE = "Reset profile" -- fix |
RESET_PROFILE_DESC = "Clear all settings of the current profile." -- fix |
RESET_PROFILE = "éè¨è¨éæª" |
RESET_PROFILE_DESC = "æ¸ é¤ç®åçè¨éæªä¸çææè¨å®ã" |
CHARACTER_COLON = "è§è²ï¼" |
REALM_COLON = "伺æå¨ï¼" |
CLASS_COLON = "è¯æ¥ï¼" |
DEFAULT = "Default" -- fix |
ALTERNATIVE = "Alternative" -- fix |
CHARACTER_COLON = "è§è²: " |
REALM_COLON = "伺æå¨: " |
CLASS_COLON = "è·æ¥: " |
DEFAULT = "é è¨" |
ALTERNATIVE = "æ¿ä»£" |
elseif GetLocale() == "zhCN" then |
ACTIVE = "\230\156\137\230\149\136" |
ENABLED = "\229\144\175\231\148\168" |
CHARACTER_COLON = "\229\173\151\231\172\166: " |
REALM_COLON = "\229\159\159: " |
CLASS_COLON = "\233\128\137\228\187\182\231\177\187: " |
DEFAULT = "Default" -- fix |
ALTERNATIVE = "Alternative" -- fix |
elseif GetLocale() == "esES" then |
CHARACTER_COLON = "Personaje: " |
REALM_COLON = "Reino: " |
CLASS_COLON = "Clase: " |
DEFAULT = "Por defecto" |
ALTERNATIVE = "Alternativo" |
elseif GetLocale() == "ruRU" then |
DELETE_PROFILE = "УдалиÑÑ" |
DELETE_PROFILE_DESC = "УдалиÑÑ Ð¿ÑоÑилÑ. ÐзнаÑалÑно пÑовеÑÑÑе не иÑполÑзÑеÑÑÑ Ð»Ð¸ ÑÑÐ¾Ñ Ð¿ÑоÑÐ¸Ð»Ñ Ð´ÑÑгими пеÑÑонажами, ÑÑÐ¾Ð±Ñ Ð½Ðµ наÑвоÑиÑÑ Ñебе неÑдобÑÑв." |
DELETE_PROFILE_USAGE = "<название пÑоÑилÑ>" |
ACTIVE = "ÐкÑивнÑй" |
ENABLED = "ÐклÑÑÑн" |
STATE = "СоÑÑоÑние" |
TOGGLE_ACTIVE = "ÐÑклÑÑиÑÑ/ÐапÑÑÑиÑÑ Ð°Ð´Ð´Ð¾Ð½." |
MAP_ACTIVESUSPENDED = { [true] = "|cff00ff00ÐкÑивнÑй|r", [false] = "|cffff0000Suspended|r" } |
SET_PROFILE = "УÑÑановиÑÑ Ð¿ÑоÑÐ¸Ð»Ñ Ð´Ð»Ñ ÑÑого аддона." |
SET_PROFILE_USAGE = "{ÑÐ°Ñ || клаÑÑ || ÑеÑÐ²ÐµÑ || <название пÑоÑилÑ>}" |
PROFILE = "ÐÑоÑилÑ" |
PLAYER_OF_REALM = "%s из %s" |
CHOOSE_PROFILE_DESC = "ÐÑбеÑиÑе пÑоÑилÑ." |
CHOOSE_PROFILE_GUI = "ÐÑбоÑ" |
COPY_PROFILE_DESC = "СкопиÑоваÑÑ Ð½Ð°ÑÑÑойки из дÑÑгого пÑоÑилÑ." |
COPY_PROFILE_GUI = "СкопиÑоваÑÑ Ð¸Ð·" |
OTHER_PROFILE_DESC = "ÐÑбÑаÑÑ Ð´ÑÑгой пÑоÑилÑ." |
OTHER_PROFILE_GUI = "ÐÑÑгое" |
OTHER_PROFILE_USAGE = "<название пÑоÑилÑ>" |
RESET_PROFILE = "СбÑÐ¾Ñ Ð¿ÑоÑилÑ" |
RESET_PROFILE_DESC = "ÐÑиÑÑиÑÑ Ð²Ñе наÑÑÑойки Ð´Ð»Ñ ÑекÑÑего пÑоÑилÑ." |
CHARACTER_COLON = "ÐеÑÑонаж: " |
REALM_COLON = "СеÑвеÑ: " |
CLASS_COLON = "ÐлаÑÑ: " |
DEFAULT = "Ðо-ÑмолÑаниÑ" |
ALTERNATIVE = "ÐлÑÑеÑнаÑива" |
else -- enUS |
ACTIVE = "Active" |
ENABLED = "Enabled" |
CHARACTER_COLON = "Character: " |
REALM_COLON = "Realm: " |
CLASS_COLON = "Class: " |
DEFAULT = "Default" |
ALTERNATIVE = "Alternative" |
end |
"SetProfile", |
"GetProfile", |
"CopyProfileFrom", |
"DeleteProfile", |
"ToggleActive", |
"IsActive", |
"AcquireDBNamespace", |
return t |
end |
for k,v in pairs(defaults) do |
if k == "*" then |
if k == "*" or k == "**" then |
local v = v |
if type(v) == "table" then |
setmetatable(t, { |
} ) |
end |
for key in pairs(t) do |
if (defaults[key] == nil or key == "*") and type(t[key]) == "table" then |
if (defaults[key] == nil or key == k) and type(t[key]) == "table" then |
inheritDefaults(t[key], v) |
end |
end |
else |
if type(v) == "table" then |
if type(t[k]) ~= "table" then |
if type(rawget(t, k)) ~= "table" then |
t[k] = {} |
end |
inheritDefaults(t[k], v) |
elseif t[k] == nil then |
if defaults["**"] then |
inheritDefaults(t[k], defaults["**"]) |
end |
elseif rawget(t, k) == nil then |
t[k] = v |
end |
end |
return {} |
end |
end |
function del(t) |
setmetatable(t, nil) |
for k in pairs(t) do |
local tmp = {} |
function AceDB:InitializeDB(addonName) |
local db = self.db |
if not db then |
if addonName then |
AceDB.addonsLoaded[addonName] = true |
end |
return |
end |
if db.raw then |
-- someone manually initialized |
return |
end |
if type(_G[db.name]) ~= "table" then |
_G[db.name] = {} |
else |
CrawlForDeserialization(_G[db.name]) |
end |
if type(_G[db.charName]) == "table" then |
CrawlForDeserialization(_G[db.charName]) |
if db.charName then |
if type(_G[db.charName]) ~= "table" then |
_G[db.charName] = {} |
else |
CrawlForDeserialization(_G[db.charName]) |
end |
end |
rawset(db, 'raw', _G[db.name]) |
if not db.raw.currentProfile then |
name, kind = kind, a2 |
AceDB:argCheck(name, 2, "nil", "string") |
AceDB:argCheck(kind, 3, "nil", "string") |
else |
else |
AceDB:argCheck(kind, 2, "nil", "string") |
if kind ~= "char" and kind ~= "class" and kind ~= "profile" and kind ~= "account" and kind ~= "realm" and kind ~= "faction" and kind ~= "server" then |
name, kind = kind, nil |
else |
if db.raw.namespaces then |
db.raw.namespaces[name] = nil |
end |
end |
if db.namespaces then |
local v = db.namespaces[name] |
if v then |
rawset(v, 'realm', nil) |
end |
end |
else |
else |
if db.raw.namespaces then |
local v = db.raw.namespaces[name] |
if v and v.realms then |
end |
end |
end |
elseif kind == "profile" then |
elseif kind == "profile" then |
local id = db.raw.currentProfile and db.raw.currentProfile[charID] or AceDB.registry[self] or "Default" |
if id == "char" then |
id = "char/" .. charID |
elseif id == "realm" then |
id = "realm/" .. realmID |
end |
local current = self.class |
while current and current ~= AceOO.Class do |
if current.mixins then |
safecall(self.OnProfileDisable, self, id) |
end |
local active = self:IsActive() |
if not name then |
if db.raw.profiles then |
db.raw.profiles[id] = nil |
end |
end |
end |
local current = self.class |
while current and current ~= AceOO.Class do |
if current.mixins then |
end |
local newactive = self:IsActive() |
if active ~= newactive then |
local first = nil |
if AceOO.inherits(self, "AceAddon-2.0") then |
local AceAddon = AceLibrary("AceAddon-2.0") |
if not AceAddon.addonsStarted[self] then |
return |
if newactive then |
local first = nil |
if AceOO.inherits(self, "AceAddon-2.0") then |
local AceAddon = AceLibrary("AceAddon-2.0") |
if not AceAddon.addonsStarted[self] then |
return |
end |
if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[self] then |
AceAddon.addonsEnabled[self] = true |
first = true |
end |
end |
if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[self] then |
first = true |
end |
end |
if newactive then |
local current = self.class |
while current and current ~= AceOO.Class do |
if current.mixins then |
end |
end |
end |
else |
return -- skip event |
end |
if AceEvent then |
AceEvent:TriggerEvent("AceDB20_ResetDB", self, self.db.name, kind) |
end |
end |
local function cleanDefaults(t, defaults) |
local function cleanDefaults(t, defaults, blocker) |
if defaults then |
for k,v in pairs(defaults) do |
if k == "*" then |
if type(v) == "table" then |
for k in pairs(t) do |
if (defaults[k] == nil or k == "*") and type(t[k]) == "table" then |
if cleanDefaults(t[k], v) then |
for k,v in pairs(t) do |
if (not blocker or (blocker[k] == nil and blocker['*'] == nil and blocker['**'] == nil)) and (defaults[k] ~= nil or defaults['*'] ~= nil or defaults['**'] ~= nil) then |
local u = defaults[k] |
if u == nil then |
u = defaults['*'] |
if u == nil then |
u = defaults['**'] |
end |
end |
if v == u then |
t[k] = nil |
elseif type(v) == "table" and type(u) == "table" then |
if cleanDefaults(v, u) then |
t[k] = nil |
else |
local w = defaults['**'] |
if w ~= u then |
if cleanDefaults(v, w, u) then |
t[k] = nil |
end |
end |
end |
else |
for k in pairs(t) do |
if (defaults[k] == nil or k == "*") and t[k] == v then |
t[k] = nil |
end |
end |
end |
else |
if type(v) == "table" then |
if type(t[k]) == "table" then |
if cleanDefaults(t[k], v) then |
t[k] = nil |
end |
end |
elseif t[k] == v then |
t[k] = nil |
end |
end |
end |
end |
return t and not next(t) |
return t and next(t) == nil |
end |
function AceDB:GetProfile() |
RecalculateAceDBCopyFromList(self) |
end |
if Dewdrop then |
Dewdrop:Refresh(1) |
Dewdrop:Refresh(2) |
Dewdrop:Refresh(3) |
Dewdrop:Refresh(4) |
Dewdrop:Refresh(5) |
Dewdrop:Refresh() |
end |
end |
RecalculateAceDBCopyFromList(self) |
end |
if Dewdrop then |
Dewdrop:Refresh(1) |
Dewdrop:Refresh(2) |
Dewdrop:Refresh(3) |
Dewdrop:Refresh(4) |
Dewdrop:Refresh(5) |
Dewdrop:Refresh() |
end |
end |
function AceDB:DeleteProfile(profile, noconfirm) |
AceDB:argCheck(profile , 2, "string") |
if not self.db or not self.db.raw then |
AceDB:error("Cannot call \"DeleteProfile\" before \"RegisterDB\" has been called and before \"ADDON_LOADED\" has been fired.") |
end |
local db = self.db |
local currentProfile = db.raw.currentProfile[charID] |
if currentProfile:lower() == profile:lower() then |
AceDB:error("Cannot delete profile %q, it is currently in use.", profile) |
end |
if not (noconfirm or IsShiftKeyDown()) then |
if not StaticPopupDialogs["ACEDB20_CONFIRM_DELETE_DIALOG"] then |
StaticPopupDialogs["ACEDB20_CONFIRM_DELETE_DIALOG"] = {} |
end |
local t = StaticPopupDialogs["ACEDB20_CONFIRM_DELETE_DIALOG"] |
t.text = format("%s: %s?", DELETE_PROFILE, profile) |
t.button1 = DELETE_PROFILE |
t.button2 = CANCEL or "Cancel" |
t.OnAccept = function() |
self:DeleteProfile(profile, true) |
end |
t.timeout = 0 |
t.whileDead = 1 |
t.hideOnEscape = 1 |
StaticPopup_Show("ACEDB20_CONFIRM_DELETE_DIALOG") |
return; |
end |
local good = false |
if db.raw.profiles and db.raw.profiles[profile] then |
good = true; |
db.raw.profiles[profile] = nil; |
end |
if db.raw.namespaces then |
for _,n in pairs(db.raw.namespaces) do |
if n.profiles and n.profiles[profile] then |
n.profiles[profile] = nil; |
good = true |
end |
end |
end |
if not good then |
AceDB:error("Cannot delete profile %q, it does not exist.", profile) |
end |
if self['acedb-profile-list'] then |
RecalculateAceDBProfileList(self) |
end |
if self['acedb-profile-copylist'] then |
RecalculateAceDBCopyFromList(self) |
end |
if Dewdrop then |
Dewdrop:Refresh() |
end |
end |
function AceDB:IsActive() |
return not self.db or not self.db.raw or not self.db.raw.disabled or not self.db.raw.disabled[self.db.raw.currentProfile[charID]] |
end |
for addon, defaultProfile in pairs(AceDB.registry) do |
local db = addon.db |
if db then |
if type(addon.OnDatabaseCleanup) == "function" then |
safecall(addon.OnDatabaseCleanup, addon) |
end |
setmetatable(db, nil) |
CrawlForSerialization(db.raw) |
if type(_G[db.charName]) == "table" then |
get = "GetProfile", |
set = "SetProfile", |
}, |
delete = { |
name = DELETE_PROFILE, |
desc = DELETE_PROFILE_DESC, |
usage = DELETE_PROFILE_USAGE, |
type = 'text', |
set = "DeleteProfile", |
get = false, |
validate = target['acedb-profile-copylist'], |
disabled = function() |
return not next(target['acedb-profile-copylist']) |
end, |
}, |
reset = { |
name = RESET_PROFILE, |
desc = RESET_PROFILE_DESC, |
local function activate(self, oldLib, oldDeactivate) |
AceDB = self |
AceEvent = AceLibrary:HasInstance("AceEvent-2.0") and AceLibrary("AceEvent-2.0") |
self.addonsToBeInitialized = oldLib and oldLib.addonsToBeInitialized or {} |
self.addonsLoaded = oldLib and oldLib.addonsLoaded or {} |
self.registry = oldLib and oldLib.registry or {} |
self.registry[k] = "Default" |
end |
end |
self:activate(oldLib, oldDeactivate) |
for t in pairs(self.embedList) do |
if t.db then |
rawset(t.db, 'char', nil) |
setmetatable(t.db, db_mt) |
end |
end |
if oldLib then |
oldDeactivate(oldLib) |
end |
local function external(self, major, instance) |
if major == "AceEvent-2.0" then |
AceEvent = instance |
AceEvent:embed(self) |
self:RegisterEvent("ADDON_LOADED") |
self:RegisterEvent("PLAYER_LOGOUT") |
elseif major == "Dewdrop-2.0" then |
## Interface: 30000 |
## X-Curse-Packaged-Version: r1096 |
## X-Curse-Project-Name: Ace2 |
## X-Curse-Project-ID: ace2 |
## X-Curse-Repository-ID: wow/ace2/mainline |
## Title: Lib: AceDB-2.0 |
## Notes: AddOn development framework |
## Author: Ace Development Team |
## LoadOnDemand: 1 |
## X-Website: http://www.wowace.com |
## X-Category: Library |
## X-License: LGPL v2.1 + MIT for AceOO-2.0 |
## Dependencies: AceLibrary, AceEvent-2.0, AceOO-2.0 |
AceDB-2.0.lua |
--[[ |
--[[ |
Name: FuBarPlugin-2.0 |
Revision: $Rev: 29795 $ |
Revision: $Rev: 9 $ |
Author: Cameron Kenneth Knight (ckknight@gmail.com) |
Website: http://wiki.wowace.com/index.php/FuBarPlugin-2.0 |
Documentation: http://wiki.wowace.com/index.php/FuBarPlugin-2.0 |
SVN: svn://svn.wowace.com/root/branches/FuBar/FuBarPlugin-2.0/FuBarPlugin-2.0/ |
SVN: svn://svn.wowace.com/wowace/trunk/FuBarPlugin-2.0/FuBarPlugin-2.0/ |
Description: Plugin for FuBar. |
Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0, Tablet-2.0, Dewdrop-2.0 |
Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0, (optional) Tablet-2.0, Dewdrop-2.0 |
License: LGPL v2.1 |
Notes: When embeding this library, FuBar should be set as an optional dependency. |
]] |
local MAJOR_VERSION = "FuBarPlugin-2.0" |
local MINIMAPCONTAINER_MAJOR_VERSION = "FuBarPlugin-MinimapContainer-2.0" |
local MINOR_VERSION = "$Revision: 29795 $" |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 9 $"):match("(%d+)")) |
-- This ensures the code is only executed if the libary doesn't already exist, or is a newer version |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end |
local AceEvent = AceLibrary:HasInstance("AceEvent-2.0") and AceLibrary("AceEvent-2.0") |
local Tablet = AceLibrary:HasInstance("Tablet-2.0") and AceLibrary("Tablet-2.0") |
local Dewdrop = AceLibrary:HasInstance("Dewdrop-2.0") and AceLibrary("Dewdrop-2.0") |
local AceAddon |
local epsilon = 1e-5 |
local _G = getfenv(0) |
CLOSE_DESC = "Ferme le menu." |
elseif GetLocale() == "zhCN" then |
SHOW_ICON = "æ¾ç¤ºå¾æ " |
SHOW_ICON_DESC = "å¨é¢æ¿ä¸æ¾ç¤ºæ件å¾æ ." |
SHOW_ICON_DESC = "å¨é¢æ¿ä¸æ¾ç¤ºæ件å¾æ ã" |
SHOW_TEXT = "æ¾ç¤ºæå" |
SHOW_TEXT_DESC = "å¨é¢æ¿ä¸æ¾ç¤ºæåæ é¢." |
SHOW_TEXT_DESC = "å¨é¢æ¿ä¸æ¾ç¤ºæåæ é¢ã" |
SHOW_COLORED_TEXT = "æ¾ç¤ºå½©è²æå" |
SHOW_COLORED_TEXT_DESC = "å 许æ件æ¾ç¤ºå½©è²æå." |
SHOW_COLORED_TEXT_DESC = "å 许æ件æ¾ç¤ºå½©è²æåã" |
DETACH_TOOLTIP = "ç¬ç«æ示信æ¯" |
DETACH_TOOLTIP_DESC = "ä»é¢æ¿ä¸ç¬ç«æ示信æ¯." |
DETACH_TOOLTIP_DESC = "ä»é¢æ¿ä¸ç¬ç«æ示信æ¯ã" |
LOCK_TOOLTIP = "éå®æ示信æ¯" |
LOCK_TOOLTIP_DESC = "éå®æ示信æ¯ä½ç½®." |
LOCK_TOOLTIP_DESC = "éå®æ示信æ¯ä½ç½®ã" |
POSITION = "ä½ç½®" |
POSITION_DESC = "æ件å¨é¢æ¿ä¸çä½ç½®." |
POSITION_DESC = "æ件å¨é¢æ¿ä¸çä½ç½®ã" |
POSITION_LEFT = "å± å·¦" |
POSITION_RIGHT = "å± å³" |
POSITION_CENTER = "å± ä¸" |
ATTACH_TO_MINIMAP = "ä¾éå¨å°å°å¾" |
ATTACH_TO_MINIMAP_DESC = "æ件å¾æ ä¾éå¨å°å°å¾èä¸æ¾ç¤ºå¨é¢æ¿ä¸." |
HIDE_FUBAR_PLUGIN = "éèFuBaræ件" |
HIDE_FUBAR_PLUGIN_CMD = "Hidden" |
HIDE_FUBAR_PLUGIN_DESC = "å¨é¢æ¿ä¸éè该æ件." |
ATTACH_TO_MINIMAP_DESC = "æ件å¾æ ä¾éå¨å°å°å¾èä¸æ¾ç¤ºå¨é¢æ¿ä¸ã" |
HIDE_FUBAR_PLUGIN = "éè FuBar æ件" |
HIDE_FUBAR_PLUGIN_CMD = "éè" |
HIDE_FUBAR_PLUGIN_DESC = "å¨é¢æ¿ä¸éè该æ件ã" |
OTHER = "å ¶ä»" |
CLOSE = "å ³é" |
CLOSE_DESC = "å ³éèå" |
elseif GetLocale() == "zhTW" then |
SHOW_ICON = "顯示å示" |
SHOW_ICON_DESC = "å¨é¢æ¿ä¸é¡¯ç¤ºæ件å示ã" |
SHOW_TEXT = "顯示æå" |
SHOW_TEXT_DESC = "å¨é¢æ¿ä¸é¡¯ç¤ºæåæ¨é¡ã" |
SHOW_COLORED_TEXT = "顯示彩è²æå" |
SHOW_COLORED_TEXT_DESC = "å 許æ件顯示彩è²æåã" |
SHOW_TEXT_DESC = "å¨é¢æ¿ä¸é¡¯ç¤ºæ件æåã" |
SHOW_COLORED_TEXT = "å 許彩è²æå" |
SHOW_COLORED_TEXT_DESC = "å 許æ件å¨é¢æ¿ä¸ä½¿ç¨å½©è²æåã" |
DETACH_TOOLTIP = "ç¨ç«æ示è¨æ¯" |
DETACH_TOOLTIP_DESC = "å¾é¢æ¿ä¸ç¨ç«æ示è¨æ¯ã" |
LOCK_TOOLTIP = "éå®æ示è¨æ¯" |
LOCK_TOOLTIP_DESC = "éå®æ示è¨æ¯ä½ç½®ã" |
LOCK_TOOLTIP_DESC = "éå®æ示è¨æ¯ä½ç½®ãç¶æ示è¨æ¯éå®æï¼éè¦ç¨Altéµä½¿ç¨æ示è¨æ¯çåè½ã" |
POSITION = "ä½ç½®" |
POSITION_DESC = "æ件å¨é¢æ¿ä¸çä½ç½®ã" |
POSITION_LEFT = "é å·¦" |
POSITION_CENTER = "ç½®ä¸" |
ATTACH_TO_MINIMAP = "ä¾éå¨å°å°å" |
ATTACH_TO_MINIMAP_DESC = "æ件åæ¨ä¾éå¨å°å°åèä¸é¡¯ç¤ºå¨é¢æ¿ä¸ã" |
HIDE_FUBAR_PLUGIN = "é±èFuBaræ件" |
HIDE_FUBAR_PLUGIN_CMD = "Hidden" |
HIDE_FUBAR_PLUGIN_DESC = "å¨é¢æ¿ä¸é±è該æ件." |
HIDE_FUBAR_PLUGIN = "é±èæ件" |
HIDE_FUBAR_PLUGIN_CMD = "é±è" |
HIDE_FUBAR_PLUGIN_DESC = "å¨é¢æ¿æå°å°åä¸é±è該æ件ï¼ä½ä¿æå·è¡çæ ã" |
OTHER = "å ¶ä»" |
CLOSE = "éé" |
CLOSE_DESC = "ééé¸å®ã" |
elseif GetLocale() == "esES" then |
SHOW_ICON = "Mostrar icono" |
SHOW_ICON_DESC = "Muestra el icono del plugin en el panel" |
OTHER = "Otros" |
CLOSE = "Cerrar" |
CLOSE_DESC = "Cierra el men\195\186." |
elseif GetLocale() == "ruRU" then |
SHOW_ICON = "ÐоказÑваÑÑ Ð¸ÐºÐ¾Ð½ÐºÑ" |
SHOW_ICON_DESC = "ÐоказÑваÑÑ Ð¸ÐºÐ¾Ð½ÐºÑ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° на панели." |
SHOW_TEXT = "ÐоказÑваÑÑ ÑекÑÑ" |
SHOW_TEXT_DESC = "ÐоказÑваÑÑ ÑекÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° на панели." |
SHOW_COLORED_TEXT = "ÐоказÑваÑÑ ÑвеÑной ÑекÑÑ" |
SHOW_COLORED_TEXT_DESC = "ÐозволиÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½Ñ Ð¸ÑполÑзоваÑÑ ÐµÐ³Ð¾ ÑвеÑа в ÑекÑÑе." |
DETACH_TOOLTIP = "ÐÑделиÑÑ Ð¿Ð¾Ð´ÑказкÑ" |
DETACH_TOOLTIP_DESC = "ÐÑделиÑÑ Ð²ÑплÑваÑÑÑÑ Ð¿Ð¾Ð´ÑÐºÐ°Ð·ÐºÑ Ð¾Ñ Ð¿Ð°Ð½ÐµÐ»Ð¸." |
LOCK_TOOLTIP = "ÐакÑепиÑÑ Ð¿Ð¾Ð´ÑказкÑ" |
LOCK_TOOLTIP_DESC = "ÐакÑепиÑÑ Ð¿Ð¾Ð·Ð¸ÑÐ¸Ñ Ð²ÑплÑваÑÑей подÑказки. Ðогда вÑплÑваÑÑÐ°Ñ Ð¿Ð¾Ð´Ñказка закÑеплена, иÑполÑзÑйÑе Alt Ð´Ð»Ñ Ð¾ÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ ÐµÐµ Ñ Ð¼ÑÑи." |
POSITION = "ÐозиÑиÑ" |
POSITION_DESC = "ÐозиÑÐ¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° на панели." |
POSITION_LEFT = "Слева" |
POSITION_RIGHT = "СпÑава" |
POSITION_CENTER = "Ðо ÑенÑÑÑ" |
ATTACH_TO_MINIMAP = "ÐакÑепиÑÑ Ñ Ð¼Ð¸Ð½Ð¸-каÑÑÑ" |
ATTACH_TO_MINIMAP_DESC = "ÐакÑепиÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½ Ñ Ð¼Ð¸Ð½Ð¸-каÑÑÑ, вмеÑÑо панели." |
HIDE_FUBAR_PLUGIN = "СкÑÑÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½" |
HIDE_FUBAR_PLUGIN_CMD = "СкÑÑÑÑ" |
HIDE_FUBAR_PLUGIN_DESC = "СкÑÑÑÑ Ð¿Ð»Ð°Ð³Ð¸Ð½ Ñ Ð¿Ð°Ð½ÐµÐ»Ð¸ или мини-каÑÑÑ, но оÑÑавиÑÑ Ð°Ð´Ð´Ð¾Ð½ в ÑабоÑем ÑоÑÑоÑнии." |
OTHER = "ÐÑÑгое" |
CLOSE = "ÐакÑÑÑÑ" |
CLOSE_DESC = "ÐакÑÑÑÑ Ð¼ÐµÐ½Ñ." |
end |
local AceOO = AceLibrary("AceOO-2.0") |
local FuBarPlugin = AceOO.Mixin { |
"GetTitle", |
"GetName", |
"GetCategory", |
"SetFontSize", |
"GetFrame", |
"Show", |
"Hide", |
"GetPanel", |
"IsTextColored", |
"ToggleTextColored", |
"IsMinimapAttached", |
"ToggleMinimapAttached", |
"Update", |
"UpdateDisplay", |
"UpdateData", |
"UpdateText", |
"UpdateTooltip", |
"SetIcon", |
"GetIcon", |
"CheckWidth", |
"SetText", |
"GetText", |
"IsIconShown", |
"ToggleIconShown", |
"ShowIcon", |
"HideIcon", |
"IsTextShown", |
"ToggleTextShown", |
"ShowText", |
"HideText", |
"IsTooltipDetached", |
"ToggleTooltipDetached", |
"DetachTooltip", |
"ReattachTooltip", |
"GetDefaultPosition", |
"SetPanel", |
"IsLoadOnDemand", |
"IsDisabled", |
"CreateBasicPluginFrame", |
"CreatePluginChildFrame", |
"OpenMenu", |
"AddImpliedMenuOptions", |
} |
"GetTitle", |
"GetName", |
"GetCategory", |
"SetFontSize", |
"GetFrame", |
"Show", |
"Hide", |
"GetPanel", |
"IsTextColored", |
"ToggleTextColored", |
"IsMinimapAttached", |
"ToggleMinimapAttached", |
"Update", |
"UpdateDisplay", |
"UpdateData", |
"UpdateText", |
"UpdateTooltip", |
"SetIcon", |
"GetIcon", |
"CheckWidth", |
"SetText", |
"GetText", |
"IsIconShown", |
"ToggleIconShown", |
"ShowIcon", |
"HideIcon", |
"IsTextShown", |
"ToggleTextShown", |
"ShowText", |
"HideText", |
"IsTooltipDetached", |
"ToggleTooltipDetached", |
"DetachTooltip", |
"ReattachTooltip", |
"GetDefaultPosition", |
"SetPanel", |
"IsLoadOnDemand", |
"IsDisabled", |
"CreateBasicPluginFrame", |
"CreatePluginChildFrame", |
"OpenMenu", |
"AddImpliedMenuOptions", |
} |
local MinimapContainer |
local good = nil |
local function CheckFuBar() |
if self.panel then |
self.panel:RemovePlugin(self) |
end |
FuBar:GetPanel(1):AddPlugin(self, nil, self.defaultPosition) |
if self.defaultPosition == "MINIMAP" then |
FuBar:GetPanel(1):AddPlugin(self, nil, "LEFT") |
else |
FuBar:GetPanel(1):AddPlugin(self, nil, self.defaultPosition) |
end |
else |
if self.panel then |
self.panel:RemovePlugin(self) |
end |
AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION):AddPlugin(self) |
MinimapContainer:AddPlugin(self) |
end |
end |
Dewdrop:Close() |
if not CheckFuBar() then |
return true |
end |
return self.panel == AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION) |
return self.panel == MinimapContainer |
end |
function FuBarPlugin:Update() |
end |
function FuBarPlugin:RegisterTablet() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then |
return |
end |
if not Tablet:IsRegistered(self.frame) then |
if self.db and self.db.profile and not self.db.profile.detachedTooltip then |
self.db.profile.detachedTooltip = {} |
'hideWhenEmpty', self.tooltipHiddenWhenEmpty |
) |
local func = self.frame:GetScript("OnEnter") |
local function newFunc(...) |
func(...) |
local function newFunc(this, ...) |
func(this, ...) |
if FuBar and FuBar.IsHidingTooltipsInCombat and FuBar:IsHidingTooltipsInCombat() and InCombatLockdown() then |
local frame = this.self.frame |
if Tablet:IsAttached(frame) then |
if self.blizzardTooltip then |
if GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then |
GameTooltip:Hide() |
end |
elseif self.overrideTooltip and type(self.CloseTooltip) == "function" then |
self:CloseTooltip() |
elseif not self.overrideTooltip and Tablet and Tablet:IsAttached(frame) then |
Tablet:Close(frame) |
end |
end |
end |
function FuBarPlugin:UpdateTooltip() |
if self.blizzardTooltip then |
if GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then |
GameTooltip:Hide() |
local frame = self:IsMinimapAttached() and self.minimapFrame or self.frame |
local anchor |
if frame:GetTop() > GetScreenHeight() / 2 then |
local x = frame:GetCenter() |
if x < GetScreenWidth() / 2 then |
anchor = "ANCHOR_BOTTOMRIGHT" |
else |
anchor = "ANCHOR_BOTTOMLEFT" |
end |
else |
local x = frame:GetCenter() |
if x < GetScreenWidth() / 2 then |
anchor = "ANCHOR_TOPLEFT" |
else |
anchor = "ANCHOR_TOPRIGHT" |
end |
end |
GameTooltip:SetOwner(frame, anchor) |
if type(self.OnTooltipUpdate) == "function" and not self:IsDisabled() then |
self:OnTooltipUpdate() |
end |
GameTooltip:Show() |
end |
return |
elseif self.overrideTooltip then |
if type(self.OnTooltipUpdate) == "function" and not self:IsDisabled() then |
self:OnTooltipUpdate() |
end |
return |
end |
if not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
if self:IsMinimapAttached() and not self:IsTooltipDetached() and self.minimapFrame then |
Tablet:Refresh(self.minimapFrame) |
end |
elseif not self.db or not self.db.profile.hidden then |
if panelId == 0 or not CheckFuBar() then |
AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION):AddPlugin(self) |
MinimapContainer:AddPlugin(self) |
else |
FuBar:ShowPlugin(self, panelId or self.panelIdTmp) |
end |
end |
end |
if AceOO.inherits(self, "AceAddon-2.0") then |
local AceAddon = AceLibrary("AceAddon-2.0") |
if not AceAddon then |
AceAddon = AceLibrary("AceAddon-2.0") |
end |
if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[self] then |
return |
end |
self.db.profile.hidden = true |
end |
if not self.hideWithoutStandby then |
if self.db and not self.overrideTooltip and not self.cannotDetachTooltip and self:IsTooltipDetached() and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then |
if self.db and not self.overrideTooltip and not self.blizzardTooltip and not self.cannotDetachTooltip and self:IsTooltipDetached() and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then |
self:ReattachTooltip() |
self.db.profile.detachedTooltip.detached = true |
end |
end |
function FuBarPlugin:IsTooltipDetached() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
return not Tablet:IsAttached(self.frame) |
end |
function FuBarPlugin:ToggleTooltipDetached() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
if self:IsTooltipDetached() then |
Tablet:Attach(self.frame) |
end |
function FuBarPlugin:DetachTooltip() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
Tablet:Detach(self.frame) |
end |
function FuBarPlugin:ReattachTooltip() |
if self.blizzardTooltip or self.overrideTooltip or not Tablet then return end |
FuBarPlugin.RegisterTablet(self) |
Tablet:Attach(self.frame) |
end |
end |
function FuBarPlugin:IsLoadOnDemand() |
return IsAddOnLoadOnDemand(FuBarPlugin.folderNames[self] or self.folderName) |
local addon = FuBarPlugin.folderNames[self] or self.folderName |
if not addon then |
return |
end |
return IsAddOnLoadOnDemand(addon) |
end |
function FuBarPlugin:IsDisabled() |
function FuBarPlugin:OnInstanceInit(target) |
if not AceEvent then |
self:error(MAJOR_VERSION .. " requires AceEvent-2.0.") |
elseif not Tablet then |
self:error(MAJOR_VERSION .. " requires Tablet-2.0.") |
elseif not Dewdrop then |
self:error(MAJOR_VERSION .. " requires Dewdrop-2.0.") |
end |
self.registry[target] = true |
local folderName = select(3, debugstack(6, 1, 0):find("\\AddOns\\(.*)\\")) |
local folderName |
for i = 6, 3, -1 do |
folderName = debugstack(i, 1, 0):match("\\AddOns\\(.*)\\") |
if folderName then |
break |
end |
end |
target.folderName = folderName |
self.folderNames[target] = folderName |
end |
FuBarPlugin.OnManualEmbed = FuBarPlugin.OnInstanceInit |
local frame_OnClick, frame_OnDoubleClick, frame_OnMouseDown, frame_OnMouseUp, frame_OnReceiveDrag, frame_OnEnter, frame_OnLeave |
function FuBarPlugin:CreateBasicPluginFrame(name) |
local frame = CreateFrame("Button", name, UIParent) |
frame:SetFrameStrata("HIGH") |
frame:SetPoint("CENTER", UIParent, "CENTER") |
frame.self = self |
if not frame_OnEnter then |
function frame_OnEnter() |
if type(this.self.OnEnter) == "function" then |
this.self:OnEnter() |
function frame_OnEnter(this, ...) |
local self = this.self |
if self.blizzardTooltip then |
GameTooltip:SetOwner(self:IsMinimapAttached() and self.minimapFrame or self.frame, "ANCHOR_CURSOR") |
self:UpdateTooltip() |
end |
if type(self.OnEnter) == "function" then |
self:OnEnter(...) |
end |
end |
end |
frame:SetScript("OnEnter", frame_OnEnter) |
if not frame_OnLeave then |
function frame_OnLeave() |
if type(this.self.OnLeave) == "function" then |
this.self:OnLeave() |
function frame_OnLeave(this, ...) |
local self = this.self |
if type(self.OnLeave) == "function" then |
self:OnLeave(...) |
end |
if self.blizzardTooltip and GameTooltip:IsOwned(self:IsMinimapAttached() and self.minimapFrame or self.frame) then |
GameTooltip:Hide() |
end |
end |
end |
frame:SetScript("OnLeave", frame_OnLeave) |
if not frame_OnClick then |
function frame_OnClick() |
function frame_OnClick(this, ...) |
if this.self:IsMinimapAttached() and this.dragged then return end |
if type(this.self.OnClick) == "function" then |
this.self:OnClick(arg1) |
this.self:OnClick(...) |
end |
end |
end |
frame:SetScript("OnClick", frame_OnClick) |
if not frame_OnDoubleClick then |
function frame_OnDoubleClick() |
function frame_OnDoubleClick(this, ...) |
if type(this.self.OnDoubleClick) == "function" then |
this.self:OnDoubleClick(arg1) |
this.self:OnDoubleClick(...) |
end |
end |
end |
frame:SetScript("OnDoubleClick", frame_OnDoubleClick) |
if not frame_OnMouseDown then |
function frame_OnMouseDown() |
if arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then |
function frame_OnMouseDown(this, ...) |
if (...) == "RightButton" and not IsModifierKeyDown() then |
this.self:OpenMenu() |
return |
else |
HideDropDownMenu(1) |
if type(this.self.OnMouseDown) == "function" then |
this.self:OnMouseDown(arg1) |
this.self:OnMouseDown(...) |
end |
end |
end |
end |
frame:SetScript("OnMouseDown", frame_OnMouseDown) |
if not frame_OnMouseUp then |
function frame_OnMouseUp() |
function frame_OnMouseUp(this, ...) |
if type(this.self.OnMouseUp) == "function" then |
this.self:OnMouseUp(arg1) |
this.self:OnMouseUp(...) |
end |
end |
end |
frame:SetScript("OnMouseUp", frame_OnMouseUp) |
if not frame_OnReceiveDrag then |
function frame_OnReceiveDrag() |
if type(this.self.OnReceiveDrag) == "function" then |
this.self:OnReceiveDrag() |
function frame_OnReceiveDrag(this, ...) |
if (this.self:IsMinimapAttached() and not this.dragged) and type(this.self.OnReceiveDrag) == "function" then |
this.self:OnReceiveDrag(...) |
end |
end |
end |
end |
child.self = self |
if not child_OnEnter then |
function child_OnEnter(...) |
function child_OnEnter(this, ...) |
if this.self.frame:GetScript("OnEnter") then |
this.self.frame:GetScript("OnEnter")(...) |
this.self.frame:GetScript("OnEnter")(this, ...) |
end |
end |
end |
child:SetScript("OnEnter", child_OnEnter) |
if not child_OnLeave then |
function child_OnLeave(...) |
function child_OnLeave(this, ...) |
if this.self.frame:GetScript("OnLeave") then |
this.self.frame:GetScript("OnLeave")(...) |
this.self.frame:GetScript("OnLeave")(this, ...) |
end |
end |
end |
child:SetScript("OnLeave", child_OnLeave) |
if child:HasScript("OnClick") then |
if not child_OnClick then |
function child_OnClick(...) |
function child_OnClick(this, ...) |
if this.self.frame:HasScript("OnClick") and this.self.frame:GetScript("OnClick") then |
this.self.frame:GetScript("OnClick")(...) |
this.self.frame:GetScript("OnClick")(this, ...) |
end |
end |
end |
end |
if child:HasScript("OnDoubleClick") then |
if not child_OnDoubleClick then |
function child_OnDoubleClick(...) |
function child_OnDoubleClick(this, ...) |
if this.self.frame:HasScript("OnDoubleClick") and this.self.frame:GetScript("OnDoubleClick") then |
this.self.frame:GetScript("OnDoubleClick")(...) |
this.self.frame:GetScript("OnDoubleClick")(this, ...) |
end |
end |
end |
child:SetScript("OnDoubleClick", child_OnDoubleClick) |
end |
if not child_OnMouseDown then |
function child_OnMouseDown(...) |
function child_OnMouseDown(this, ...) |
if this.self.frame:HasScript("OnMouseDown") and this.self.frame:GetScript("OnMouseDown") then |
this.self.frame:GetScript("OnMouseDown")(...) |
this.self.frame:GetScript("OnMouseDown")(this, ...) |
end |
end |
end |
child:SetScript("OnMouseDown", child_OnMouseDown) |
if not child_OnMouseUp then |
function child_OnMouseUp(...) |
function child_OnMouseUp(this, ...) |
if this.self.frame:HasScript("OnMouseUp") and this.self.frame:GetScript("OnMouseUp") then |
this.self.frame:GetScript("OnMouseUp")(...) |
this.self.frame:GetScript("OnMouseUp")(this, ...) |
end |
end |
end |
child:SetScript("OnMouseUp", child_OnMouseUp) |
if not child_OnReceiveDrag then |
function child_OnReceiveDrag(this) |
function child_OnReceiveDrag(this, ...) |
if this.self.frame:HasScript("OnReceiveDrag") and this.self.frame:GetScript("OnReceiveDrag") then |
this.self.frame:GetScript("OnReceiveDrag")() |
this.self.frame:GetScript("OnReceiveDrag")(this, ...) |
end |
end |
end |
function FuBarPlugin:OpenMenu(frame) |
if not frame then |
frame = self:GetFrame() |
frame = self:IsMinimapAttached() and self.minimapFrame or self.frame |
end |
if not frame:IsVisible() then |
frame = UIParent |
end |
if not frame or not self:GetFrame() or Dewdrop:IsOpen(frame) then |
Dewdrop:Close() |
return |
end |
Tablet:Close() |
if self.blizzardTooltip then |
if GameTooltip:IsOwned(frame) then |
GameTooltip:Hide() |
end |
elseif self.overrideTooltip and type(self.CloseTooltip) == "function" then |
self:CloseTooltip() |
elseif not self.overrideTooltip and Tablet then |
Tablet:Close() |
end |
if not Dewdrop:IsRegistered(self:GetFrame()) then |
if type(self.OnMenuRequest) == "table" and (not self.OnMenuRequest.handler or self.OnMenuRequest.handler == self) and self.OnMenuRequest.type == "group" then |
end |
if frame == self:GetFrame() then |
Dewdrop:Open(self:GetFrame()) |
elseif frame ~= UIParent then |
Dewdrop:Open(frame, self:GetFrame()) |
else |
Dewdrop:Open(frame, self:GetFrame()) |
Dewdrop:Open(frame, self:GetFrame(), 'cursorX', true, 'cursorY', true) |
end |
end |
end |
local recheckPlugins |
local AceConsole |
function FuBarPlugin.OnEmbedEnable(FuBarPlugin, self) |
if not self.userDefinedFrame then |
if self:IsIconShown() then |
if FuBarPlugin.enabledPlugins[self] then |
CheckShow(self, self.panelIdTmp) |
else |
FuBarPlugin:ScheduleEvent(CheckShow, 0, self, self.panelIdTmp) |
FuBarPlugin:ScheduleEvent("FuBarPlugin-CheckShow-" .. tostring(self), CheckShow, 0, self, self.panelIdTmp) |
end |
end |
FuBarPlugin.enabledPlugins[self] = true |
if not self.overrideTooltip and not self.cannotDetachTooltip and self.db and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then |
FuBarPlugin:ScheduleEvent(self.DetachTooltip, 0, self) |
if not self.blizzardTooltip and not self.overrideTooltip and not self.cannotDetachTooltip and self.db and self.db.profile.detachedTooltip and self.db.profile.detachedTooltip.detached then |
FuBarPlugin:ScheduleEvent("FuBarPlugin-DetachTooltip-" .. tostring(self), self.DetachTooltip, 0, self) |
end |
if self:IsLoadOnDemand() and CheckFuBar() then |
if CheckFuBar() and AceLibrary:HasInstance("AceConsole-2.0") then |
if not recheckPlugins then |
local AceConsole = AceLibrary("AceConsole-2.0") |
local AceOO = AceLibrary("AceOO-2.0") |
function recheckPlugins() |
if not AceConsole then |
AceConsole = AceLibrary("AceConsole-2.0") |
end |
recheckPlugins = function() |
for k,v in pairs(AceConsole.registry) do |
if type(v) == "table" and v.args and AceOO.inherits(v.handler, FuBarPlugin) and not v.handler.independentProfile then |
v.args.profile = nil |
end |
end |
end |
FuBarPlugin:ScheduleEvent(recheckPlugins, 0) |
FuBarPlugin:ScheduleEvent("FuBarPlugin-recheckPlugins", recheckPlugins, 0) |
end |
end |
if not self.db.profile.detachedTooltip then |
self.db.profile.detachedTooltip = {} |
end |
if Tablet.registry[self.frame] then |
Tablet:UpdateDetachedData(self.frame, self.db.profile.detachedTooltip) |
else |
FuBarPlugin.RegisterTablet(self) |
if not self.blizzardTooltip and not self.overrideTooltip and Tablet then |
if Tablet.registry[self.frame] then |
Tablet:UpdateDetachedData(self.frame, self.db.profile.detachedTooltip) |
else |
FuBarPlugin.RegisterTablet(self) |
end |
end |
local MinimapContainer = AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION) |
if MinimapContainer:HasPlugin(self) then |
AceLibrary(MINIMAPCONTAINER_MAJOR_VERSION):ReadjustLocation(self) |
MinimapContainer:ReadjustLocation(self) |
end |
end |
end |
get = "IsTooltipDetached", |
set = "ToggleTooltipDetached", |
hidden = function() |
return self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled() |
return not Tablet or self.blizzardTooltip or self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled() |
end, |
order = -13.4, |
handler = self, |
return not self:IsTooltipDetached() |
end, |
hidden = function() |
return self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled() |
return not Tablet or self.blizzardTooltip or self.overrideTooltip or self.cannotDetachTooltip or self:IsDisabled() |
end, |
order = -13.3, |
handler = self, |
local function external(self, major, instance) |
if major == "AceEvent-2.0" then |
AceEvent = instance |
AceEvent:embed(self) |
elseif major == "Tablet-2.0" then |
Tablet = instance |
AceLibrary:Register(FuBarPlugin, MAJOR_VERSION, MINOR_VERSION, activate, nil, external) |
local MinimapContainer = {} |
MinimapContainer = {} |
local minimap_OnMouseDown, minimap_OnMouseUp |
function MinimapContainer:AddPlugin(plugin) |
if CheckFuBar() and FuBar:IsChangingProfile() then |
return |
if not plugin.minimapFrame then |
local frame = CreateFrame("Button", plugin.frame:GetName() .. "MinimapButton", Minimap) |
plugin.minimapFrame = frame |
AceLibrary(MAJOR_VERSION).RegisterTablet(plugin) |
Tablet:Register(frame, plugin.frame) |
frame.plugin = plugin |
frame:SetWidth(31) |
frame:SetHeight(31) |
icon:SetHeight(20) |
icon:SetPoint("TOPLEFT", frame, "TOPLEFT", 7, -5) |
local overlay = frame:CreateTexture(frame:GetName() .. "Overlay","OVERLAY") |
overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") |
overlay:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") |
overlay:SetWidth(53) |
overlay:SetHeight(53) |
overlay:SetPoint("TOPLEFT",frame,"TOPLEFT") |
frame:EnableMouse(true) |
frame:RegisterForClicks("LeftButtonUp") |
frame.plugin = plugin |
frame:SetScript("OnClick", function() |
if type(plugin.OnClick) == "function" then |
if not this.dragged then |
plugin:OnClick(arg1) |
frame.self = plugin |
if not frame_OnEnter then |
function frame_OnEnter(this, ...) |
if type(this.self.OnEnter) == "function" then |
this.self:OnEnter(...) |
end |
end |
end) |
frame:SetScript("OnDoubleClick", function() |
if type(plugin.OnDoubleClick) == "function" then |
plugin:OnDoubleClick(arg1) |
end |
frame:SetScript("OnEnter", frame_OnEnter) |
if not frame_OnLeave then |
function frame_OnLeave(this, ...) |
if type(this.self.OnLeave) == "function" then |
this.self:OnLeave(...) |
end |
end |
end) |
frame:SetScript("OnReceiveDrag", function() |
if type(plugin.OnReceiveDrag) == "function" then |
if not this.dragged then |
plugin:OnReceiveDrag() |
end |
frame:SetScript("OnLeave", frame_OnLeave) |
if not frame_OnClick then |
function frame_OnClick(this, ...) |
if this.self:IsMinimapAttached() and this.dragged then return end |
if type(this.self.OnClick) == "function" then |
this.self:OnClick(...) |
end |
end |
end) |
frame:SetScript("OnMouseDown", function() |
this.dragged = false |
if arg1 == "LeftButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then |
HideDropDownMenu(1) |
if type(plugin.OnMouseDown) == "function" then |
plugin:OnMouseDown(arg1) |
end |
frame:SetScript("OnClick", frame_OnClick) |
if not frame_OnDoubleClick then |
function frame_OnDoubleClick(this, ...) |
if type(this.self.OnDoubleClick) == "function" then |
this.self:OnDoubleClick(...) |
end |
elseif arg1 == "RightButton" and not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() then |
plugin:OpenMenu(frame) |
else |
HideDropDownMenu(1) |
if type(plugin.OnMouseDown) == "function" then |
plugin:OnMouseDown(arg1) |
end |
end |
frame:SetScript("OnDoubleClick", frame_OnDoubleClick) |
if not frame_OnReceiveDrag then |
function frame_OnReceiveDrag(this, ...) |
if (this.self:IsMinimapAttached() and not this.dragged) and type(this.self.OnReceiveDrag) == "function" then |
this.self:OnReceiveDrag(...) |
end |
end |
if plugin.OnClick or plugin.OnMouseDown or plugin.OnMouseUp or plugin.OnDoubleClick then |
if this.plugin.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
plugin.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86) |
end |
frame:SetScript("OnReceiveDrag", frame_OnReceiveDrag) |
if not minimap_OnMouseDown then |
function minimap_OnMouseDown(this, ...) |
this.dragged = false |
if (...) == "RightButton" and not IsModifierKeyDown() then |
this.self:OpenMenu(this) |
else |
plugin.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9) |
HideDropDownMenu(1) |
if type(this.self.OnMouseDown) == "function" then |
this.self:OnMouseDown(...) |
end |
end |
if this.self.OnClick or this.self.OnMouseDown or this.self.OnMouseUp or this.self.OnDoubleClick then |
if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
this.self.minimapIcon:SetTexCoord(0.14, 0.86, 0.14, 0.86) |
else |
this.self.minimapIcon:SetTexCoord(0.1, 0.9, 0.1, 0.9) |
end |
end |
end |
end) |
frame:SetScript("OnMouseUp", function() |
if not this.dragged and type(plugin.OnMouseUp) == "function" then |
plugin:OnMouseUp(arg1) |
end |
frame:SetScript("OnMouseDown", minimap_OnMouseDown) |
if not minimap_OnMouseUp then |
function minimap_OnMouseUp(this, ...) |
if not this.dragged and type(this.self.OnMouseUp) == "function" then |
this.self:OnMouseUp(...) |
end |
if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
else |
this.self.minimapIcon:SetTexCoord(0, 1, 0, 1) |
end |
end |
if this.plugin.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
plugin.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
else |
plugin.minimapIcon:SetTexCoord(0, 1, 0, 1) |
end |
end) |
end |
frame:SetScript("OnMouseUp", minimap_OnMouseUp) |
frame:RegisterForDrag("LeftButton") |
frame:SetScript("OnDragStart", self.OnDragStart) |
frame:SetScript("OnDragStop", self.OnDragStop) |
if not plugin.blizzardTooltip and not plugin.overrideTooltip and Tablet then |
-- Note that we have to do this after :SetScript("OnEnter"), etc, |
-- so that Tablet-2.0 can override it properly. |
FuBarPlugin.RegisterTablet(plugin) |
Tablet:Register(frame, plugin.frame) |
end |
end |
plugin.frame:Hide() |
plugin.minimapFrame:Show() |
round = false |
end |
elseif minimapShape == "SIDE-TOP" then |
if sin > 0 then |
if sin < 0 then |
round = false |
end |
elseif minimapShape == "SIDE-BOTTOM" then |
if sin < 0 then |
if sin > 0 then |
round = false |
end |
elseif minimapShape == "TRICORNER-TOPRIGHT" then |
if cos < 0 and sin > 0 then |
if cos < 0 and sin < 0 then |
round = false |
end |
elseif minimapShape == "TRICORNER-TOPLEFT" then |
if cos > 0 and sin > 0 then |
if cos > 0 and sin < 0 then |
round = false |
end |
elseif minimapShape == "TRICORNER-BOTTOMRIGHT" then |
if cos < 0 and sin < 0 then |
if cos < 0 and sin > 0 then |
round = false |
end |
elseif minimapShape == "TRICORNER-BOTTOMLEFT" then |
if cos > 0 and sin < 0 then |
if cos > 0 and sin > 0 then |
round = false |
end |
end |
if round then |
x = cos * 80 |
y = sin * 80 |
else |
x = 110 * cos |
y = 110 * sin |
x = math.max(-82, math.min(x, 84)) |
y = math.max(-86, math.min(y, 82)) |
x = 80 * 2^0.5 * cos |
y = 80 * 2^0.5 * sin |
if x < -80 then |
x = -80 |
elseif x > 80 then |
x = 80 |
end |
if y < -80 then |
y = -80 |
elseif y > 80 then |
y = 80 |
end |
end |
frame:SetPoint("CENTER", Minimap, "CENTER", x, y) |
end |
end |
function MinimapContainer:GetNumPlugins() |
return table.getn(self.plugins) |
return #self.plugins |
end |
function MinimapContainer:IndexOfPlugin(plugin) |
return "MINIMAP" |
end |
function MinimapContainer.OnDragStart() |
function MinimapContainer.OnDragStart(this) |
this.dragged = true |
this:LockHighlight() |
this:SetScript("OnUpdate", MinimapContainer.OnUpdate) |
if this.plugin.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
this.plugin.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
if this.self.minimapIcon:GetTexture():sub(1, 16) == "Interface\\Icons\\" then |
this.self.minimapIcon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
else |
this.plugin.minimapIcon:SetTexCoord(0, 1, 0, 1) |
this.self.minimapIcon:SetTexCoord(0, 1, 0, 1) |
end |
end |
function MinimapContainer.OnDragStop() |
function MinimapContainer.OnDragStop(this) |
this:SetScript("OnUpdate", nil) |
this:UnlockHighlight() |
end |
function MinimapContainer.OnUpdate() |
function MinimapContainer.OnUpdate(this) |
if not IsAltKeyDown() then |
local mx, my = Minimap:GetCenter() |
local px, py = GetCursorPosition() |
elseif position > 360 then |
position = position - 360 |
end |
if this.plugin.db then |
this.plugin.db.profile.minimapPosition = position |
this.plugin.db.profile.minimapPositionX = nil |
this.plugin.db.profile.minimapPositionY = nil |
this.plugin.db.profile.minimapPositionWild = nil |
if this.self.db then |
this.self.db.profile.minimapPosition = position |
this.self.db.profile.minimapPositionX = nil |
this.self.db.profile.minimapPositionY = nil |
this.self.db.profile.minimapPositionWild = nil |
else |
this.plugin.minimapPosition = position |
this.plugin.minimapPositionX = nil |
this.plugin.minimapPositionY = nil |
this.plugin.minimapPositionWild = nil |
this.self.minimapPosition = position |
this.self.minimapPositionX = nil |
this.self.minimapPositionY = nil |
this.self.minimapPositionWild = nil |
end |
else |
local px, py = GetCursorPosition() |
local scale = UIParent:GetEffectiveScale() |
px, py = px / scale, py / scale |
if this.plugin.db then |
this.plugin.db.profile.minimapPositionX = px |
this.plugin.db.profile.minimapPositionY = py |
this.plugin.db.profile.minimapPosition = nil |
this.plugin.db.profile.minimapPositionWild = true |
if this.self.db then |
this.self.db.profile.minimapPositionX = px |
this.self.db.profile.minimapPositionY = py |
this.self.db.profile.minimapPosition = nil |
this.self.db.profile.minimapPositionWild = true |
else |
this.plugin.minimapPositionX = px |
this.plugin.minimapPositionY = py |
this.plugin.minimapPosition = nil |
this.plugin.minimapPositionWild = true |
this.self.minimapPositionX = px |
this.self.minimapPositionY = py |
this.self.minimapPosition = nil |
this.self.minimapPositionWild = true |
end |
end |
MinimapContainer:ReadjustLocation(this.plugin) |
MinimapContainer:ReadjustLocation(this.self) |
end |
local function activate(self, oldLib, oldDeactivate) |
--[[ |
--[[ |
Name: AceDebug-2.0 |
Revision: $Rev: 25921 $ |
Revision: $Rev: 1091 $ |
Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team) |
Inspired By: Ace 1.x by Turan (turan@gryphon.com) |
Website: http://www.wowace.com/ |
Documentation: http://www.wowace.com/index.php/AceDebug-2.0 |
SVN: http://svn.wowace.com/root/trunk/Ace2/AceDebug-2.0 |
SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceDebug-2.0 |
Description: Mixin to allow for simple debugging capabilities. |
Dependencies: AceLibrary, AceOO-2.0 |
License: LGPL v2.1 |
]] |
local MAJOR_VERSION = "AceDebug-2.0" |
local MINOR_VERSION = "$Revision: 25921 $" |
local MINOR_VERSION = 90000 + tonumber(("$Revision: 1091 $"):match("(%d+)")) |
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end |
if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("\n(.-: )in.-\n") or "") .. err) end |
end |
local DEBUGGING, TOGGLE_DEBUGGING |
if GetLocale() == "frFR" then |
DEBUGGING = "D\195\169boguage" |
TOGGLE_DEBUGGING = "Activer/d\195\169sactiver le d\195\169boguage" |
TOGGLE_DEBUGGING = "ëë²ê¹ ê¸°ë¥ ì¬ì©í¨/ì¬ì©ìí¨" |
elseif GetLocale() == "zhTW" then |
DEBUGGING = "é¤é¯" |
TOGGLE_DEBUGGING = "åç¨/åç¨é¤é¯åè½" |
TOGGLE_DEBUGGING = "åç¨/åç¨é¤é¯åè½ã" |
elseif GetLocale() == "zhCN" then |
DEBUGGING = "\232\176\131\232\175\149" |
TOGGLE_DEBUGGING = "\229\144\175\231\148\168/\231\166\129\231\148\168 \232\176\131\232\175\149." |
elseif GetLocale() == "esES" then |
DEBUGGING = "Debugging" |
TOGGLE_DEBUGGING = "Activar/desactivar Debugging." |
elseif GetLocale() == "ruRU" then |
DEBUGGING = "ÐÑладка" |
TOGGLE_DEBUGGING = "Ðкл/ÐÑкл оÑÐ»Ð°Ð´ÐºÑ Ð´Ð»Ñ ÑÑого аддона." |
else -- enUS |
DEBUGGING = "Debugging" |
TOGGLE_DEBUGGING = "Toggle debugging for this addon." |
end |
local AceOO = AceLibrary:GetInstance("AceOO-2.0") |
local AceDebug = AceOO.Mixin {"Debug", "CustomDebug", "IsDebugging", "SetDebugging", "SetDebugLevel", "LevelDebug", "CustomLevelDebug", "GetDebugLevel"} |
local AceDebug = AceOO.Mixin { |
"Debug", |
"CustomDebug", |
"IsDebugging", |
"SetDebugging", |
"SetDebugLevel", |
"LevelDebug", |
"CustomLevelDebug", |
"GetDebugLevel", |
"GetDebugPrefix", |
} |
local function print(text, r, g, b, frame, delay) |
(frame or DEFAULT_CHAT_FRAME):AddMessage(text, r, g, b, 1, delay or 5) |
return |
end |
local output = ("|cff7fff7f(DEBUG) %s:[%s.%3d]|r"):format(tostring(self), date("%H:%M:%S"), (GetTime() % 1) * 1000) |
local output = self:GetDebugPrefix() |
a1 = tostring(a1) |
if a1:find("%%") and select('#', ...) >= 1 then |
self.debuglevel = level |
end |
function AceDebug:GetDebugPrefix() |
return ("|cff7fff7f(DEBUG) %s:[%s.%3d]|r"):format( tostring(self), date("%H:%M:%S"), (GetTime() % 1) * 1000) |
end |
function AceDebug:GetDebugLevel() |
return self.debuglevel |
end |
end |
if level > self.debuglevel then return end |
local output = ("|cff7fff7f(DEBUG) %s:[%s.%3d]|r"):format( tostring(self), date("%H:%M:%S"), (GetTime() % 1) * 1000) |
local output = self:GetDebugPrefix() |
a1 = tostring(a1) |
if a1:find("%%") and select('#', ...) >= 1 then |
## Interface: 30000 |
## X-Curse-Packaged-Version: r1096 |
## X-Curse-Project-Name: Ace2 |
## X-Curse-Project-ID: ace2 |
## X-Curse-Repository-ID: wow/ace2/mainline |
## Title: Lib: AceDebug-2.0 |
## Notes: AddOn development framework |
## Author: Ace Development Team |
## LoadOnDemand: 1 |
## X-Website: http://www.wowace.com |
## X-Category: Library |
## X-License: LGPL v2.1 + MIT for AceOO-2.0 |
## Dependencies: AceLibrary, AceOO-2.0 |
AceDebug-2.0.lua |
## Interface: 30000 |
## X-Curse-Packaged-Version: r1096 |
## X-Curse-Project-Name: Ace2 |
## X-Curse-Project-ID: ace2 |
## X-Curse-Repository-ID: wow/ace2/mainline |
## Title: Lib: AceLibrary |
## Notes: AddOn development framework |
## Author: Ace Development Team |
## X-Website: http://www.wowace.com |
## X-Category: Library |
## X-License: LGPL v2.1 + MIT for AceOO-2.0 |
AceLibrary.lua |
--[[ |
Name: AceLibrary |
Revision: $Rev: 29796 $ |
Revision: $Rev: 1091 $ |
Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team) |
Inspired By: Iriel (iriel@vigilance-committee.org) |
Tekkub (tekkub@gmail.com) |
Revision: $Rev: 29796 $ |
Revision: $Rev: 1091 $ |
Website: http://www.wowace.com/ |
Documentation: http://www.wowace.com/index.php/AceLibrary |
SVN: http://svn.wowace.com/root/trunk/Ace2/AceLibrary |
SVN: http://svn.wowace.com/wowace/trunk/Ace2/AceLibrary |
Description: Versioning library to handle other library instances, upgrading, |
and proper access. |
It also provides a base for libraries to work off of, providing |
]] |
local ACELIBRARY_MAJOR = "AceLibrary" |
local ACELIBRARY_MINOR = "$Revision: 29796 $" |
local ACELIBRARY_MINOR = 90000 + tonumber(("$Revision: 1091 $"):match("(%d+)")) |
local _G = getfenv(0) |
local previous = _G[ACELIBRARY_MAJOR] |
if previous and not previous:IsNewVersion(ACELIBRARY_MAJOR, ACELIBRARY_MINOR) then return end |
do |
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info |
-- LibStub is hereby placed in the Public Domain -- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke |
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! |
local LibStub = _G[LIBSTUB_MAJOR] |
if not LibStub or LibStub.minor < LIBSTUB_MINOR then |
LibStub = LibStub or {libs = {}, minors = {} } |
_G[LIBSTUB_MAJOR] = LibStub |
LibStub.minor = LIBSTUB_MINOR |
function LibStub:NewLibrary(major, minor) |
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") |
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") |
local oldminor = self.minors[major] |
if oldminor and oldminor >= minor then return nil end |
self.minors[major], self.libs[major] = minor, self.libs[major] or {} |
return self.libs[major], oldminor |
end |
function LibStub:GetLibrary(major, silent) |
if not self.libs[major] and not silent then |
error(("Cannot find a library instance of %q."):format(tostring(major)), 2) |
end |
return self.libs[major], self.minors[major] |
end |
function LibStub:IterateLibraries() return pairs(self.libs) end |
setmetatable(LibStub, { __call = LibStub.GetLibrary }) |
end |
end |
local LibStub = _G.LibStub |
-- If you don't want AceLibrary to enable libraries that are LoadOnDemand but |
-- disabled in the addon screen, set this to true. |
local DONT_ENABLE_LIBRARIES = nil |
local function safecall(func,...) |
local success, err = pcall(func,...) |
if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("\n(.-: )in.-\n") or "") .. err) end |
end |
local WoW22 = false |
if type(GetBuildInfo) == "function" then |
local success, buildinfo = pcall(GetBuildInfo) |
if success and type(buildinfo) == "string" then |
local num = tonumber(buildinfo:match("^(%d+%.%d+)")) |
if num and num >= 2.2 then |
WoW22 = true |
end |
end |
end |
-- @table AceLibrary |
-- @brief System to handle all versioning of libraries. |
local AceLibrary = {} |
local stack = debugstack() |
if not message then |
local _,_,second = stack:find("\n(.-)\n") |
local second = stack:match("\n(.-)\n") |
message = "error raised! " .. second |
else |
local arg = { ... } -- not worried about table creation, as errors don't happen often |
return _G.error(message, 2) |
end |
local assert |
if not WoW22 then |
function assert(self, condition, message, ...) |
if not condition then |
if not message then |
local stack = debugstack() |
local _,_,second = stack:find("\n(.-)\n") |
message = "assertion failed! " .. second |
end |
return error(self, message, ...) |
end |
return condition |
end |
end |
local type = type |
local function argCheck(self, arg, num, kind, kind2, kind3, kind4, kind5) |
if type(num) ~= "number" then |
return error(self, "Bad argument #3 to `argCheck' (number expected, got %s)", type(num)) |
elseif type(kind) ~= "string" then |
return error(self, "Bad argument #4 to `argCheck' (string expected, got %s)", type(kind)) |
end |
local errored = false |
arg = type(arg) |
if arg ~= kind and arg ~= kind2 and arg ~= kind3 and arg ~= kind4 and arg ~= kind5 then |
local stack = debugstack() |
local _,_,func = stack:find("`argCheck'.-([`<].-['>])") |
local func = stack:match("`argCheck'.-([`<].-['>])") |
if not func then |
_,_,func = stack:find("([`<].-['>])") |
func = stack:match("([`<].-['>])") |
end |
if kind5 then |
return error(self, "Bad argument #%s to %s (%s, %s, %s, %s, or %s expected, got %s)", tonumber(num) or 0/0, func, kind, kind2, kind3, kind4, kind5, arg) |
end |
local function svnRevisionToNumber(text) |
if type(text) == "string" then |
local kind = type(text) |
if kind == "number" or tonumber(text) then |
return tonumber(text) |
elseif kind == "string" then |
if text:find("^%$Revision: (%d+) %$$") then |
return tonumber((text:gsub("^%$Revision: (%d+) %$$", "%1"))) |
return tonumber((text:match("^%$Revision: (%d+) %$$"))) |
elseif text:find("^%$Rev: (%d+) %$$") then |
return tonumber((text:gsub("^%$Rev: (%d+) %$$", "%1"))) |
return tonumber((text:match("^%$Rev: (%d+) %$$"))) |
elseif text:find("^%$LastChangedRevision: (%d+) %$$") then |
return tonumber((text:gsub("^%$LastChangedRevision: (%d+) %$$", "%1"))) |
return tonumber((text:match("^%$LastChangedRevision: (%d+) %$$"))) |
end |
elseif type(text) == "number" then |
return text |
end |
return nil |
end |
-- @brief Create a shallow copy of a table and return it. |
-- @param from The table to copy from |
-- @return A shallow copy of the table |
local function copyTable(from) |
local to = {} |
local function copyTable(from, to) |
if not to then |
to = {} |
end |
for k,v in pairs(from) do |
to[k] = v |
end |
end |
end |
local function TryToEnable(addon) |
if DONT_ENABLE_LIBRARIES then return end |
local isondemand = IsAddOnLoadOnDemand(addon) |
if isondemand then |
local _, _, _, enabled = GetAddOnInfo(addon) |
EnableAddOn(addon) |
local _, _, _, _, loadable = GetAddOnInfo(addon) |
if not loadable and not enabled then |
DisableAddOn(addon) |
end |
return loadable |
end |
end |
-- @method TryToLoadStandalone |
-- @brief Attempt to find and load a standalone version of the requested library |
-- @param major A string representing the major version |
-- @return If library is found, return values from the call to LoadAddOn are returned |
-- @return If library is found and loaded, true is return. If not loadable, false is returned. |
-- If the library has been requested previously, nil is returned. |
local function TryToLoadStandalone(major) |
if not AceLibrary.scannedlibs then AceLibrary.scannedlibs = {} end |
AceLibrary.scannedlibs[major] = true |
local name, _, _, enabled, loadable = GetAddOnInfo(major) |
loadable = (enabled and loadable) or TryToEnable(name) |
local loaded = false |
if loadable then |
return LoadAddOn(name) |
loaded = true |
LoadAddOn(name) |
end |
for i=1,GetNumAddOns() do |
if GetAddOnMetadata(i, "X-AceLibrary-"..major) then |
local name, _, _, enabled, loadable = GetAddOnInfo(i) |
local field = "X-AceLibrary-" .. major |
for i = 1, GetNumAddOns() do |
if GetAddOnMetadata(i, field) then |
name, _, _, enabled, loadable = GetAddOnInfo(i) |
loadable = (enabled and loadable) or TryToEnable(name) |
if loadable then |
return LoadAddOn(name) |
loaded = true |
LoadAddOn(name) |
end |
end |
end |
return loaded |
end |
-- @method IsNewVersion |
end |
end |
argCheck(self, minor, 3, "number") |
local lib, oldMinor = LibStub:GetLibrary(major, true) |
if lib then |
return oldMinor < minor |
end |
local data = self.libs[major] |
if not data then |
return true |
if minor ~= false then |
TryToLoadStandalone(major) |
end |
local lib, ver = LibStub:GetLibrary(major, true) |
if not lib and self.libs[major] then |
lib, ver = self.libs[major].instance, self.libs[major].minor |
end |
if minor then |
if type(minor) == "string" then |
local m = svnRevisionToNumber(minor) |
end |
end |
argCheck(self, minor, 3, "number") |
if not self.libs[major] then |
return |
if not lib then |
return false |
end |
return self.libs[major].minor == minor |
return ver == minor |
end |
return self.libs[major] and true |
return not not lib |
end |
-- @method GetInstance |
-- @return The library with the given major/minor version. |
function AceLibrary:GetInstance(major, minor) |
argCheck(self, major, 2, "string") |
TryToLoadStandalone(major) |
if minor ~= false then |
TryToLoadStandalone(major) |
end |
local data = self.libs[major] |
local data, ver = LibStub:GetLibrary(major, true) |
if not data then |
_G.error(("Cannot find a library instance of %s."):format(major), 2) |
return |
if self.libs[major] then |
data, ver = self.libs[major].instance, self.libs[major].minor |
else |
_G.error(("Cannot find a library instance of %s."):format(major), 2) |
return |
end |
end |
if minor then |
if type(minor) == "string" then |
end |
end |
argCheck(self, minor, 2, "number") |
if data.minor ~= minor then |
if ver ~= minor then |
_G.error(("Cannot find a library instance of %s, minor version %d."):format(major, minor), 2) |
end |
end |
return data.instance |
return data |
end |
-- Syntax sugar. AceLibrary("FooBar-1.0") |
local AceEvent |
local tmp = {} |
-- @method Register |
-- @brief Registers a new version of a given library. |
-- @param newInstance the library to register |
local data = self.libs[major] |
if not data then |
-- This is new |
local instance = copyTable(newInstance) |
if LibStub:GetLibrary(major, true) then |
error(self, "Cannot register library %q. It is already registered with LibStub.", major) |
end |
local instance = LibStub:NewLibrary(major, minor) |
copyTable(newInstance, instance) |
crawlReplace(instance, instance, newInstance) |
destroyTable(newInstance) |
if AceLibrary == newInstance then |
if not rawget(instance, 'error') then |
rawset(instance, 'error', error) |
end |
if not WoW22 and not rawget(instance, 'assert') then |
rawset(instance, 'assert', assert) |
end |
if not rawget(instance, 'argCheck') then |
rawset(instance, 'argCheck', argCheck) |
end |
addToPositions(instance, major) |
if activateFunc then |
safecall(activateFunc, instance, nil, nil) -- no old version, so explicit nil |
--[[ if major ~= ACELIBRARY_MAJOR then |
for k,v in pairs(_G) do |
if v == instance then |
geterrorhandler()((debugstack():match("(.-: )in.-\n") or "") .. ("Cannot register library %q. It is part of the global table in _G[%q]."):format(major, k)) |
end |
end |
end]] |
end |
if externalFunc then |
for k,data in pairs(self.libs) do |
for k, data_instance in LibStub:IterateLibraries() do -- all libraries |
tmp[k] = data_instance |
end |
for k, data in pairs(self.libs) do -- Ace libraries which may not have been registered with LibStub |
tmp[k] = data.instance |
end |
for k, data_instance in pairs(tmp) do |
if k ~= major then |
safecall(externalFunc, instance, k, data.instance) |
safecall(externalFunc, instance, k, data_instance) |
end |
tmp[k] = nil |
end |
end |
for k,data in pairs(self.libs) do |
for k,data in pairs(self.libs) do -- only Ace libraries |
if k ~= major and data.externalFunc then |
safecall(data.externalFunc, data.instance, major, instance) |
end |
return instance |
end |
local instance = data.instance |
if minor <= data.minor then |
-- This one is already obsolete, raise an error. |
_G.error(("Obsolete library registered. %s is already registered at version %d. You are trying to register version %d. Hint: if not AceLibrary:IsNewVersion(%q, %d) then return end"):format(major, data.minor, minor, major, minor), 2) |
return |
end |
local instance = data.instance |
-- This is an update |
local oldInstance = {} |
local libStubInstance = LibStub:GetLibrary(major, true) |
if not libStubInstance then -- non-LibStub AceLibrary registered the library |
-- pass |
elseif libStubInstance ~= instance then |
error(self, "Cannot register library %q. It is already registered with LibStub.", major) |
else |
LibStub:NewLibrary(major, minor) -- upgrade the minor version |
end |
addToPositions(newInstance, major) |
local isAceLibrary = (AceLibrary == newInstance) |
local old_error, old_assert, old_argCheck, old_pcall |
local old_error, old_argCheck, old_pcall |
if isAceLibrary then |
self = instance |
AceLibrary = instance |
old_error = instance.error |
if not WoW22 then |
old_assert = instance.assert |
end |
old_argCheck = instance.argCheck |
old_pcall = instance.pcall |
self.error = error |
if not WoW22 then |
self.assert = assert |
end |
self.argCheck = argCheck |
self.pcall = pcall |
end |
data.minor = minor |
data.deactivateFunc = deactivateFunc |
data.externalFunc = externalFunc |
rawset(instance, 'GetLibraryVersion', function(self) |
rawset(instance, 'GetLibraryVersion', function() |
return major, minor |
end) |
if not rawget(instance, 'error') then |
rawset(instance, 'error', error) |
end |
if not WoW22 and not rawget(instance, 'assert') then |
rawset(instance, 'assert', assert) |
end |
if not rawget(instance, 'argCheck') then |
rawset(instance, 'argCheck', argCheck) |
end |
if not rawget(i, 'error') or i.error == old_error then |
rawset(i, 'error', error) |
end |
if not WoW22 and (not rawget(i, 'assert') or i.assert == old_assert) then |
rawset(i, 'assert', assert) |
end |
if not rawget(i, 'argCheck') or i.argCheck == old_argCheck then |
rawset(i, 'argCheck', argCheck) |
end |
end |
end |
if activateFunc then |
safecall(activateFunc, instance, oldInstance, oldDeactivateFunc) |
--[[ if major ~= ACELIBRARY_MAJOR then |
for k,v in pairs(_G) do |
if v == instance then |
geterrorhandler()((debugstack():match("(.-: )in.-\n") or "") .. ("Cannot register library %q. It is part of the global table in _G[%q]."):format(major, k)) |
end |
end |
end]] |
safecall(activateFunc, instance, oldInstance, oldDeactivateFunc) |
else |
safecall(oldDeactivateFunc, oldInstance) |
end |
oldInstance = nil |
if externalFunc then |
for k,data in pairs(self.libs) do |
for k, data_instance in LibStub:IterateLibraries() do -- all libraries |
tmp[k] = data_instance |
end |
for k, data in pairs(self.libs) do -- Ace libraries which may not have been registered with LibStub |
tmp[k] = data.instance |
end |
for k, data_instance in pairs(tmp) do |
if k ~= major then |
safecall(externalFunc, instance, k, data.instance) |
safecall(externalFunc, instance, k, data_instance) |
end |
tmp[k] = nil |
end |
end |
return instance |
end |
local iter |
function AceLibrary:IterateLibraries() |
if not iter then |
local function iter(t, k) |
k = next(t, k) |
if not k then |
return nil |
else |
return k, t[k].instance |
end |
local t = {} |
for major, instance in LibStub:IterateLibraries() do |
t[major] = instance |
end |
for major, data in pairs(self.libs) do |
t[major] = data.instance |
end |
return pairs(t) |
end |
local function manuallyFinalize(major, instance) |
if AceLibrary.libs[major] then |
-- don't work on Ace libraries |
return |
end |
local finalizedExternalLibs = AceLibrary.finalizedExternalLibs |
if finalizedExternalLibs[major] then |
return |
end |
finalizedExternalLibs[major] = true |
for k,data in pairs(AceLibrary.libs) do -- only Ace libraries |
if k ~= major and data.externalFunc then |
safecall(data.externalFunc, data.instance, major, instance) |
end |
end |
return iter, self.libs, nil |
end |
-- @function Activate |
if not self.positions then |
self.positions = oldLib and oldLib.positions or setmetatable({}, { __mode = "k" }) |
end |
self.finalizedExternalLibs = oldLib and oldLib.finalizedExternalLibs or {} |
self.frame = oldLib and oldLib.frame or CreateFrame("Frame") |
self.frame:UnregisterAllEvents() |
self.frame:RegisterEvent("ADDON_LOADED") |
self.frame:SetScript("OnEvent", function() |
for major, instance in LibStub:IterateLibraries() do |
manuallyFinalize(major, instance) |
end |
end) |
for major, instance in LibStub:IterateLibraries() do |
manuallyFinalize(major, instance) |
end |
-- Expose the library in the global environment |
_G[ACELIBRARY_MAJOR] = self |
previous.positions = setmetatable({}, { __mode = "k" }) |
end |
AceLibrary.positions = previous.positions |
AceLibrary:Register(AceLibrary, ACELIBRARY_MAJOR, ACELIBRARY_MINOR, activate) |
AceLibrary:Register(AceLibrary, ACELIBRARY_MAJOR, ACELIBRARY_MINOR, activate, nil) |