mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 16:34:45 +00:00
revert code style changes in oUF
This commit is contained in:
@@ -8,19 +8,19 @@ local hiddenParent = CreateFrame("Frame")
|
|||||||
-- sourced from FrameXML/PartyMemberFrame.lua
|
-- sourced from FrameXML/PartyMemberFrame.lua
|
||||||
local MAX_PARTY_MEMBERS = MAX_PARTY_MEMBERS or 4
|
local MAX_PARTY_MEMBERS = MAX_PARTY_MEMBERS or 4
|
||||||
|
|
||||||
local hiddenParent = CreateFrame("Frame", nil, UIParent)
|
local hiddenParent = CreateFrame('Frame', nil, UIParent)
|
||||||
hiddenParent:SetAllPoints()
|
hiddenParent:SetAllPoints()
|
||||||
hiddenParent:Hide()
|
hiddenParent:Hide()
|
||||||
|
|
||||||
local function handleFrame(baseName)
|
local function handleFrame(baseName)
|
||||||
local frame
|
local frame
|
||||||
if type(baseName) == "string" then
|
if(type(baseName) == 'string') then
|
||||||
frame = _G[baseName]
|
frame = _G[baseName]
|
||||||
else
|
else
|
||||||
frame = baseName
|
frame = baseName
|
||||||
end
|
end
|
||||||
|
|
||||||
if frame then
|
if(frame) then
|
||||||
frame:UnregisterAllEvents()
|
frame:UnregisterAllEvents()
|
||||||
frame:Hide()
|
frame:Hide()
|
||||||
|
|
||||||
@@ -28,46 +28,46 @@ local function handleFrame(baseName)
|
|||||||
frame:SetParent(hiddenParent)
|
frame:SetParent(hiddenParent)
|
||||||
|
|
||||||
local health = frame.healthBar or frame.healthbar
|
local health = frame.healthBar or frame.healthbar
|
||||||
if health then
|
if(health) then
|
||||||
health:UnregisterAllEvents()
|
health:UnregisterAllEvents()
|
||||||
end
|
end
|
||||||
|
|
||||||
local power = frame.manabar
|
local power = frame.manabar
|
||||||
if power then
|
if(power) then
|
||||||
power:UnregisterAllEvents()
|
power:UnregisterAllEvents()
|
||||||
end
|
end
|
||||||
|
|
||||||
local spell = frame.castBar or frame.spellbar
|
local spell = frame.castBar or frame.spellbar
|
||||||
if spell then
|
if(spell) then
|
||||||
spell:UnregisterAllEvents()
|
spell:UnregisterAllEvents()
|
||||||
end
|
end
|
||||||
|
|
||||||
local buffFrame = frame.BuffFrame
|
local buffFrame = frame.BuffFrame
|
||||||
if buffFrame then
|
if(buffFrame) then
|
||||||
buffFrame:UnregisterAllEvents()
|
buffFrame:UnregisterAllEvents()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function oUF:DisableBlizzard(unit)
|
function oUF:DisableBlizzard(unit)
|
||||||
if not unit then return end
|
if(not unit) then return end
|
||||||
|
|
||||||
if unit == "player" then
|
if(unit == 'player') then
|
||||||
handleFrame(PlayerFrame)
|
handleFrame(PlayerFrame)
|
||||||
elseif unit == "pet" then
|
elseif(unit == 'pet') then
|
||||||
handleFrame(PetFrame)
|
handleFrame(PetFrame)
|
||||||
elseif unit == "target" then
|
elseif(unit == 'target') then
|
||||||
handleFrame(TargetFrame)
|
handleFrame(TargetFrame)
|
||||||
handleFrame(ComboFrame)
|
handleFrame(ComboFrame)
|
||||||
elseif unit == "targettarget" then
|
elseif(unit == 'targettarget') then
|
||||||
handleFrame(TargetofTargetFrame)
|
handleFrame(TargetofTargetFrame)
|
||||||
elseif match(unit, "party%d?$") then
|
elseif(match(unit, 'party%d?$')) then
|
||||||
local id = match(unit, "party(%d)")
|
local id = match(unit, 'party(%d)')
|
||||||
if id then
|
if(id) then
|
||||||
handleFrame("PartyMemberFrame" .. id)
|
handleFrame('PartyMemberFrame' .. id)
|
||||||
else
|
else
|
||||||
for i = 1, MAX_PARTY_MEMBERS do
|
for i = 1, MAX_PARTY_MEMBERS do
|
||||||
handleFrame(format("PartyMemberFrame%d", i))
|
handleFrame(format('PartyMemberFrame%d', i))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+108
-110
@@ -9,7 +9,7 @@ local print = Private.print
|
|||||||
local error = Private.error
|
local error = Private.error
|
||||||
|
|
||||||
local gsub, lower, match, split, upper = string.gsub, string.lower, string.match, string.split, string.upper
|
local gsub, lower, match, split, upper = string.gsub, string.lower, string.match, string.split, string.upper
|
||||||
local insert, remove = table.insert, table.remove
|
local tinsert, tremove = table.insert, table.remove
|
||||||
|
|
||||||
local styles, style = {}
|
local styles, style = {}
|
||||||
local callback, units, objects, headers = {}, {}, {}, {}
|
local callback, units, objects, headers = {}, {}, {}, {}
|
||||||
@@ -23,11 +23,11 @@ local function enableTargetUpdate(object)
|
|||||||
object.__eventless = true
|
object.__eventless = true
|
||||||
|
|
||||||
local total = 0
|
local total = 0
|
||||||
object:SetScript("OnUpdate", function()
|
object:SetScript('OnUpdate', function()
|
||||||
if not this.unit then
|
if(not self.unit) then
|
||||||
return
|
return
|
||||||
elseif total > this.onUpdateFrequency then
|
elseif(total > self.onUpdateFrequency) then
|
||||||
this:UpdateAllElements("OnUpdate")
|
self:UpdateAllElements('OnUpdate')
|
||||||
total = 0
|
total = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ end
|
|||||||
Private.enableTargetUpdate = enableTargetUpdate
|
Private.enableTargetUpdate = enableTargetUpdate
|
||||||
|
|
||||||
local frame_metatable = {
|
local frame_metatable = {
|
||||||
__index = CreateFrame("Button")
|
__index = CreateFrame('Button')
|
||||||
}
|
}
|
||||||
Private.frame_metatable = frame_metatable
|
Private.frame_metatable = frame_metatable
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ for k, v in next, {
|
|||||||
local element = elements[name]
|
local element = elements[name]
|
||||||
if(not element or not self:IsElementEnabled(name) or not activeElements[self]) then return end
|
if(not element or not self:IsElementEnabled(name) or not activeElements[self]) then return end
|
||||||
if(element.update) then
|
if(element.update) then
|
||||||
element.update(self, "OnShow", unit)
|
element.update(self, 'OnShow', unit)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -58,14 +58,14 @@ for k, v in next, {
|
|||||||
|
|
||||||
* self - unit frame for which the element should be enabled
|
* self - unit frame for which the element should be enabled
|
||||||
* name - name of the element to be enabled (string)
|
* name - name of the element to be enabled (string)
|
||||||
* unit - unit to be passed to the element"s Enable function. Defaults to the frame"s unit (string?)
|
* unit - unit to be passed to the element's Enable function. Defaults to the frame's unit (string?)
|
||||||
--]]
|
--]]
|
||||||
EnableElement = function(self, name, unit)
|
EnableElement = function(self, name, unit)
|
||||||
local unit = unit or self.unit
|
local unit = unit or self.unit
|
||||||
if not unit then return end
|
if not unit then return end
|
||||||
|
|
||||||
argcheck(name, 2, "string")
|
argcheck(name, 2, 'string')
|
||||||
argcheck(unit or self.unit, 3, "string", "nil")
|
argcheck(unit or self.unit, 3, 'string', 'nil')
|
||||||
|
|
||||||
local element = elements[name]
|
local element = elements[name]
|
||||||
if(not element or self:IsElementEnabled(name) or not activeElements[self]) then return end
|
if(not element or self:IsElementEnabled(name) or not activeElements[self]) then return end
|
||||||
@@ -74,7 +74,7 @@ for k, v in next, {
|
|||||||
activeElements[self][name] = true
|
activeElements[self][name] = true
|
||||||
|
|
||||||
if(element.update) then
|
if(element.update) then
|
||||||
insert(self.__elements, element.update)
|
tinsert(self.__elements, element.update)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -86,7 +86,7 @@ for k, v in next, {
|
|||||||
* name - name of the element to be disabled (string)
|
* name - name of the element to be disabled (string)
|
||||||
--]]
|
--]]
|
||||||
DisableElement = function(self, name)
|
DisableElement = function(self, name)
|
||||||
argcheck(name, 2, "string")
|
argcheck(name, 2, 'string')
|
||||||
|
|
||||||
local enabled = self:IsElementEnabled(name)
|
local enabled = self:IsElementEnabled(name)
|
||||||
if(not enabled) then return end
|
if(not enabled) then return end
|
||||||
@@ -94,7 +94,7 @@ for k, v in next, {
|
|||||||
local update = elements[name].update
|
local update = elements[name].update
|
||||||
for k, func in next, self.__elements do
|
for k, func in next, self.__elements do
|
||||||
if(func == update) then
|
if(func == update) then
|
||||||
remove(self.__elements, k)
|
tremove(self.__elements, k)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -105,7 +105,7 @@ for k, v in next, {
|
|||||||
-- The main reason we do this is to make sure the full update is completed
|
-- The main reason we do this is to make sure the full update is completed
|
||||||
-- if an element for some reason removes itself _during_ the update
|
-- if an element for some reason removes itself _during_ the update
|
||||||
-- progress.
|
-- progress.
|
||||||
self:UpdateAllElements("DisableElement")
|
self:UpdateAllElements('DisableElement')
|
||||||
|
|
||||||
return elements[name].disable(self)
|
return elements[name].disable(self)
|
||||||
end,
|
end,
|
||||||
@@ -117,7 +117,7 @@ for k, v in next, {
|
|||||||
* name - name of the element (string)
|
* name - name of the element (string)
|
||||||
--]]
|
--]]
|
||||||
IsElementEnabled = function(self, name)
|
IsElementEnabled = function(self, name)
|
||||||
argcheck(name, 2, "string")
|
argcheck(name, 2, 'string')
|
||||||
|
|
||||||
local element = elements[name]
|
local element = elements[name]
|
||||||
if(not element) then return end
|
if(not element) then return end
|
||||||
@@ -131,7 +131,7 @@ for k, v in next, {
|
|||||||
`RegisterUnitWatch`.
|
`RegisterUnitWatch`.
|
||||||
|
|
||||||
* self - unit frame
|
* self - unit frame
|
||||||
* asState - if true, the frame"s "state-unitexists" attribute will be set to a boolean value denoting whether the
|
* asState - if true, the frame's "state-unitexists" attribute will be set to a boolean value denoting whether the
|
||||||
unit exists; if false, the frame will be shown if its unit exists, and hidden if it does not (boolean)
|
unit exists; if false, the frame will be shown if its unit exists, and hidden if it does not (boolean)
|
||||||
--]]
|
--]]
|
||||||
Enable = RegisterUnitWatch,
|
Enable = RegisterUnitWatch,
|
||||||
@@ -149,13 +149,13 @@ for k, v in next, {
|
|||||||
Used to update all enabled elements on the given frame.
|
Used to update all enabled elements on the given frame.
|
||||||
|
|
||||||
* self - unit frame
|
* self - unit frame
|
||||||
* event - event name to pass to the elements" update functions (string)
|
* event - event name to pass to the elements' update functions (string)
|
||||||
--]]
|
--]]
|
||||||
UpdateAllElements = function(self, event)
|
UpdateAllElements = function(self, event)
|
||||||
local unit = self.unit
|
local unit = self.unit
|
||||||
if(not UnitExists(unit)) then return end
|
if(not UnitExists(unit)) then return end
|
||||||
|
|
||||||
assert(type(event) == "string", "Invalid argument 'event' in UpdateAllElements.")
|
assert(type(event) == 'string', "Invalid argument 'event' in UpdateAllElements.")
|
||||||
|
|
||||||
if(self.PreUpdate) then
|
if(self.PreUpdate) then
|
||||||
self:PreUpdate(event)
|
self:PreUpdate(event)
|
||||||
@@ -184,23 +184,23 @@ local function InitializeSecureMenu()
|
|||||||
local unit = SecureTemplatesDropdown.unit
|
local unit = SecureTemplatesDropdown.unit
|
||||||
if(not unit) then return end
|
if(not unit) then return end
|
||||||
|
|
||||||
local unitType = match(unit, "^([a-z]+)[0-9]+$") or unit
|
local unitType = match(unit, '^([a-z]+)[0-9]+$') or unit
|
||||||
|
|
||||||
local menu
|
local menu
|
||||||
if(unitType == "party") then
|
if(unitType == 'party') then
|
||||||
menu = "PARTY"
|
menu = 'PARTY'
|
||||||
elseif(UnitIsUnit(unit, "player")) then
|
elseif(UnitIsUnit(unit, 'player')) then
|
||||||
menu = "SELF"
|
menu = 'SELF'
|
||||||
elseif(UnitIsUnit(unit, "pet")) then
|
elseif(UnitIsUnit(unit, 'pet')) then
|
||||||
menu = "PET"
|
menu = 'PET'
|
||||||
elseif(UnitIsPlayer(unit)) then
|
elseif(UnitIsPlayer(unit)) then
|
||||||
if(UnitInRaid(unit) or UnitInParty(unit)) then
|
if(UnitInRaid(unit) or UnitInParty(unit)) then
|
||||||
menu = "PARTY"
|
menu = 'PARTY'
|
||||||
else
|
else
|
||||||
menu = "PLAYER"
|
menu = 'PLAYER'
|
||||||
end
|
end
|
||||||
elseif(UnitIsUnit(unit, "target")) then
|
elseif(UnitIsUnit(unit, 'target')) then
|
||||||
menu = "RAID_TARGET_ICON"
|
menu = 'RAID_TARGET_ICON'
|
||||||
end
|
end
|
||||||
|
|
||||||
if(menu) then
|
if(menu) then
|
||||||
@@ -210,11 +210,11 @@ end
|
|||||||
|
|
||||||
local function togglemenu(self, unit)
|
local function togglemenu(self, unit)
|
||||||
if(not secureDropdown) then
|
if(not secureDropdown) then
|
||||||
secureDropdown = CreateFrame("Frame", "SecureTemplatesDropdown", nil, "UIDropDownMenuTemplate")
|
secureDropdown = CreateFrame('Frame', 'SecureTemplatesDropdown', nil, 'UIDropDownMenuTemplate')
|
||||||
secureDropdown:SetID(1)
|
secureDropdown:SetID(1)
|
||||||
|
|
||||||
insert(UnitPopupFrames, secureDropdown:GetName())
|
tinsert(UnitPopupFrames, secureDropdown:GetName())
|
||||||
UIDropDownMenu_Initialize(secureDropdown, InitializeSecureMenu, "MENU")
|
UIDropDownMenu_Initialize(secureDropdown, InitializeSecureMenu, 'MENU')
|
||||||
end
|
end
|
||||||
|
|
||||||
if(secureDropdown.openedFor and secureDropdown.openedFor ~= self) then
|
if(secureDropdown.openedFor and secureDropdown.openedFor ~= self) then
|
||||||
@@ -224,11 +224,11 @@ local function togglemenu(self, unit)
|
|||||||
secureDropdown.unit = lower(unit)
|
secureDropdown.unit = lower(unit)
|
||||||
secureDropdown.openedFor = self
|
secureDropdown.openedFor = self
|
||||||
|
|
||||||
ToggleDropDownMenu(1, nil, secureDropdown, "cursor")
|
ToggleDropDownMenu(1, nil, secureDropdown, 'cursor')
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onShow(self)
|
local function onShow(self)
|
||||||
return self:UpdateAllElements("OnShow")
|
return self:UpdateAllElements('OnShow')
|
||||||
end
|
end
|
||||||
|
|
||||||
local function initObject(unit, style, styleFunc, header, ...)
|
local function initObject(unit, style, styleFunc, header, ...)
|
||||||
@@ -236,7 +236,7 @@ local function initObject(unit, style, styleFunc, header, ...)
|
|||||||
for i = 1, num do
|
for i = 1, num do
|
||||||
local object = arg[i]
|
local object = arg[i]
|
||||||
local objectUnit = object.guessUnit or unit
|
local objectUnit = object.guessUnit or unit
|
||||||
local suffix = objectUnit and match(objectUnit or unit, "%w+target")
|
local suffix = objectUnit and match(objectUnit or unit, '%w+target')
|
||||||
|
|
||||||
object.__elements = {}
|
object.__elements = {}
|
||||||
object.__registeredEvents = {}
|
object.__registeredEvents = {}
|
||||||
@@ -244,13 +244,13 @@ local function initObject(unit, style, styleFunc, header, ...)
|
|||||||
object = setmetatable(object, frame_metatable)
|
object = setmetatable(object, frame_metatable)
|
||||||
|
|
||||||
-- Expose the frame through oUF.objects.
|
-- Expose the frame through oUF.objects.
|
||||||
insert(objects, object)
|
tinsert(objects, object)
|
||||||
|
|
||||||
-- We have to force update the frames when PEW fires.
|
-- We have to force update the frames when PEW fires.
|
||||||
object:RegisterEvent("PLAYER_ENTERING_WORLD", object.UpdateAllElements)
|
object:RegisterEvent('PLAYER_ENTERING_WORLD', object.UpdateAllElements)
|
||||||
|
|
||||||
object:SetScript("OnClick", function()
|
object:SetScript('OnClick', function()
|
||||||
if arg1 == "RightButton" then
|
if arg1 == 'RightButton' then
|
||||||
togglemenu(this, object.unit)
|
togglemenu(this, object.unit)
|
||||||
else
|
else
|
||||||
TargetUnit(this.unit)
|
TargetUnit(this.unit)
|
||||||
@@ -259,14 +259,14 @@ local function initObject(unit, style, styleFunc, header, ...)
|
|||||||
|
|
||||||
if(not header) then
|
if(not header) then
|
||||||
-- Other target units are handled by :HandleUnit().
|
-- Other target units are handled by :HandleUnit().
|
||||||
if(suffix == "target") then
|
if(suffix == 'target') then
|
||||||
enableTargetUpdate(object)
|
enableTargetUpdate(object)
|
||||||
else
|
else
|
||||||
oUF:HandleUnit(object, unit)
|
oUF:HandleUnit(object, unit)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Used to update frames when they change position in a group.
|
-- Used to update frames when they change position in a group.
|
||||||
object:RegisterEvent("RAID_ROSTER_UPDATE", object.UpdateAllElements)
|
object:RegisterEvent('RAID_ROSTER_UPDATE', object.UpdateAllElements)
|
||||||
|
|
||||||
if(num > 1) then
|
if(num > 1) then
|
||||||
if(object:GetParent() == header) then
|
if(object:GetParent() == header) then
|
||||||
@@ -276,7 +276,7 @@ local function initObject(unit, style, styleFunc, header, ...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if(suffix == "target") then
|
if(suffix == 'target') then
|
||||||
enableTargetUpdate(object)
|
enableTargetUpdate(object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -285,7 +285,7 @@ local function initObject(unit, style, styleFunc, header, ...)
|
|||||||
|
|
||||||
styleFunc(object, objectUnit, not header)
|
styleFunc(object, objectUnit, not header)
|
||||||
|
|
||||||
object:SetScript("OnShow", function() onShow(this) end)
|
object:SetScript('OnShow', function() onShow(this) end)
|
||||||
|
|
||||||
activeElements[object] = {}
|
activeElements[object] = {}
|
||||||
for element in next, elements do
|
for element in next, elements do
|
||||||
@@ -325,7 +325,7 @@ Used to add a function to a table to be executed upon unit frame/header initiali
|
|||||||
* func - function to be added
|
* func - function to be added
|
||||||
--]]
|
--]]
|
||||||
function oUF:RegisterInitCallback(func)
|
function oUF:RegisterInitCallback(func)
|
||||||
insert(callback, func)
|
tinsert(callback, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ oUF:RegisterMetaFunction(name, func)
|
--[[ oUF:RegisterMetaFunction(name, func)
|
||||||
@@ -336,8 +336,8 @@ Used to make a (table of) function(s) available to all unit frames.
|
|||||||
* func - function or a table of functions (function or table)
|
* func - function or a table of functions (function or table)
|
||||||
--]]
|
--]]
|
||||||
function oUF:RegisterMetaFunction(name, func)
|
function oUF:RegisterMetaFunction(name, func)
|
||||||
argcheck(name, 2, "string")
|
argcheck(name, 2, 'string')
|
||||||
argcheck(func, 3, "function", "table")
|
argcheck(func, 3, 'function', 'table')
|
||||||
|
|
||||||
if(frame_metatable.__index[name]) then
|
if(frame_metatable.__index[name]) then
|
||||||
return
|
return
|
||||||
@@ -347,17 +347,17 @@ function oUF:RegisterMetaFunction(name, func)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--[[ oUF:RegisterStyle(name, func)
|
--[[ oUF:RegisterStyle(name, func)
|
||||||
Used to register a style with oUF. This will also set the active style if it hasn"t been set yet.
|
Used to register a style with oUF. This will also set the active style if it hasn't been set yet.
|
||||||
|
|
||||||
* self - the global oUF object
|
* self - the global oUF object
|
||||||
* name - name of the style
|
* name - name of the style
|
||||||
* func - function(s) defining the style (function or table)
|
* func - function(s) defining the style (function or table)
|
||||||
--]]
|
--]]
|
||||||
function oUF:RegisterStyle(name, func)
|
function oUF:RegisterStyle(name, func)
|
||||||
argcheck(name, 2, "string")
|
argcheck(name, 2, 'string')
|
||||||
argcheck(func, 3, "function", "table")
|
argcheck(func, 3, 'function', 'table')
|
||||||
|
|
||||||
if(styles[name]) then return error("Style [%s] already registered.", name) end
|
if(styles[name]) then return error('Style [%s] already registered.', name) end
|
||||||
if(not style) then style = name end
|
if(not style) then style = name end
|
||||||
|
|
||||||
styles[name] = func
|
styles[name] = func
|
||||||
@@ -370,15 +370,15 @@ Used to set the active style.
|
|||||||
* name - name of the style (string)
|
* name - name of the style (string)
|
||||||
--]]
|
--]]
|
||||||
function oUF:SetActiveStyle(name)
|
function oUF:SetActiveStyle(name)
|
||||||
argcheck(name, 2, "string")
|
argcheck(name, 2, 'string')
|
||||||
if(not styles[name]) then return error("Style [%s] does not exist.", name) end
|
if(not styles[name]) then return error('Style [%s] does not exist.', name) end
|
||||||
|
|
||||||
style = name
|
style = name
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local function iter(_, n)
|
local function iter(_, n)
|
||||||
-- don"t expose the style functions.
|
-- don't expose the style functions.
|
||||||
return (next(styles, n))
|
return (next(styles, n))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -395,16 +395,16 @@ end
|
|||||||
local getCondition
|
local getCondition
|
||||||
do
|
do
|
||||||
local conditions = {
|
local conditions = {
|
||||||
raid40 = "[target=raid26,exists] show;",
|
raid40 = '[target=raid26,exists] show;',
|
||||||
raid25 = "[target=raid11,exists] show;",
|
raid25 = '[target=raid11,exists] show;',
|
||||||
raid10 = "[target=raid6,exists] show;",
|
raid10 = '[target=raid6,exists] show;',
|
||||||
raid = "[group:raid] show;",
|
raid = '[group:raid] show;',
|
||||||
party = "[group:party,nogroup:raid] show;",
|
party = '[group:party,nogroup:raid] show;',
|
||||||
solo = "[target=player,exists,nogroup:party] show;",
|
solo = '[target=player,exists,nogroup:party] show;',
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCondition(...)
|
function getCondition(...)
|
||||||
local cond = ""
|
local cond = ''
|
||||||
|
|
||||||
for i = 1, arg.n do
|
for i = 1, arg.n do
|
||||||
local short = arg[i]
|
local short = arg[i]
|
||||||
@@ -415,21 +415,21 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return cond .. "hide"
|
return cond .. 'hide'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function generateName(unit, ...)
|
local function generateName(unit, ...)
|
||||||
local name = "oUF_" .. gsub(style, gsub("^oUF_?", ""), gsub("[^%a%d_]+", ""))
|
local name = 'oUF_' .. gsub(style, gsub('^oUF_?', ""), gsub('[^%a%d_]+', ''))
|
||||||
|
|
||||||
local raid, party, groupFilter
|
local raid, party, groupFilter
|
||||||
for i = 1, arg.n, 2 do
|
for i = 1, arg.n, 2 do
|
||||||
local att, val = arg[i], arg[i+1]
|
local att, val = arg[i], arg[i+1]
|
||||||
if(att == "showRaid") then
|
if(att == 'showRaid') then
|
||||||
raid = true
|
raid = true
|
||||||
elseif(att == "showParty") then
|
elseif(att == 'showParty') then
|
||||||
party = true
|
party = true
|
||||||
elseif(att == "groupFilter") then
|
elseif(att == 'groupFilter') then
|
||||||
groupFilter = val
|
groupFilter = val
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -437,27 +437,27 @@ local function generateName(unit, ...)
|
|||||||
local append
|
local append
|
||||||
if(raid) then
|
if(raid) then
|
||||||
if(groupFilter) then
|
if(groupFilter) then
|
||||||
if(type(groupFilter) == "number" and groupFilter > 0) then
|
if(type(groupFilter) == 'number' and groupFilter > 0) then
|
||||||
append = groupFilter
|
append = groupFilter
|
||||||
elseif(match(groupFilter, "TANK")) then
|
elseif(match(groupFilter, 'TANK')) then
|
||||||
append = "MainTank"
|
append = 'MainTank'
|
||||||
elseif(match(groupFilter, "ASSIST")) then
|
elseif(match(groupFilter, 'ASSIST')) then
|
||||||
append = "MainAssist"
|
append = 'MainAssist'
|
||||||
else
|
else
|
||||||
local _, count = gsub(groupFilter, ",", "")
|
local _, count = gsub(groupFilter, ',', '')
|
||||||
if(count == 0) then
|
if(count == 0) then
|
||||||
append = "Raid" .. groupFilter
|
append = 'Raid' .. groupFilter
|
||||||
else
|
else
|
||||||
append = "Raid"
|
append = 'Raid'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
append = "Raid"
|
append = 'Raid'
|
||||||
end
|
end
|
||||||
elseif(party) then
|
elseif(party) then
|
||||||
append = "Party"
|
append = 'Party'
|
||||||
elseif(unit) then
|
elseif(unit) then
|
||||||
append = gsub(unit, "^%l", upper)
|
append = gsub(unit, '^%l', upper)
|
||||||
end
|
end
|
||||||
|
|
||||||
if(append) then
|
if(append) then
|
||||||
@@ -485,19 +485,19 @@ do
|
|||||||
|
|
||||||
local unit
|
local unit
|
||||||
if(not self.onlyProcessChildren) then
|
if(not self.onlyProcessChildren) then
|
||||||
local groupFilter = header:GetAttribute("groupFilter")
|
local groupFilter = header:GetAttribute('groupFilter')
|
||||||
|
|
||||||
if(header:GetAttribute("showRaid")) then
|
if(header:GetAttribute('showRaid')) then
|
||||||
unit = "raid"
|
unit = 'raid'
|
||||||
elseif(header:GetAttribute("showParty")) then
|
elseif(header:GetAttribute('showParty')) then
|
||||||
unit = "party"
|
unit = 'party'
|
||||||
end
|
end
|
||||||
|
|
||||||
self.menu = togglemenu
|
self.menu = togglemenu
|
||||||
--self:SetAttribute("type1", "target")
|
-- self:SetAttribute('type1', 'target')
|
||||||
--self:SetAttribute("type2", "menu")
|
-- self:SetAttribute('type2', 'menu')
|
||||||
self.guessUnit = unit
|
self.guessUnit = unit
|
||||||
self.unit = "player"
|
self.unit = 'player'
|
||||||
-- self.onlyProcessChildren = true
|
-- self.onlyProcessChildren = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -522,7 +522,7 @@ do
|
|||||||
* self - the global oUF object
|
* self - the global oUF object
|
||||||
* overrideName - unique global name to be used for the header. Defaults to an auto-generated name based on the name
|
* overrideName - unique global name to be used for the header. Defaults to an auto-generated name based on the name
|
||||||
of the active style and other arguments passed to `:SpawnHeader` (string?)
|
of the active style and other arguments passed to `:SpawnHeader` (string?)
|
||||||
* template - name of a template to be used for creating the header. Defaults to `"oUF_GroupHeaderTemplate"`
|
* template - name of a template to be used for creating the header. Defaults to `'oUF_GroupHeaderTemplate'`
|
||||||
(string?)
|
(string?)
|
||||||
* visibility - macro conditional(s) which define when to display the header (string).
|
* visibility - macro conditional(s) which define when to display the header (string).
|
||||||
* ... - further argument pairs. Consult [Group Headers](http://wowprogramming.com/docs/secure_template/Group_Headers)
|
* ... - further argument pairs. Consult [Group Headers](http://wowprogramming.com/docs/secure_template/Group_Headers)
|
||||||
@@ -536,24 +536,23 @@ do
|
|||||||
* oUF-onlyProcessChildren - can be used to force headers to only process children (boolean?)
|
* oUF-onlyProcessChildren - can be used to force headers to only process children (boolean?)
|
||||||
--]]
|
--]]
|
||||||
function oUF:SpawnHeader(overrideName, template, visibility, ...)
|
function oUF:SpawnHeader(overrideName, template, visibility, ...)
|
||||||
if(not style) then return error("Unable to create frame. No styles have been registered.") end
|
if(not style) then return error('Unable to create frame. No styles have been registered.') end
|
||||||
|
|
||||||
template = (template or "oUF_GroupHeaderTemplate")
|
template = (template or 'oUF_GroupHeaderTemplate')
|
||||||
|
|
||||||
local isPetHeader = match(template, "PetHeader")
|
local isPetHeader = match(template, 'PetHeader')
|
||||||
local name = overrideName or generateName(nil, unpack(arg))
|
local name = overrideName or generateName(nil, unpack(arg))
|
||||||
local header = CreateFrame("Frame", name, UIParent, template)
|
local header = CreateFrame('Frame', name, UIParent, template)
|
||||||
header:Hide()
|
header:Hide()
|
||||||
|
|
||||||
header.attributes = {}
|
header.attributes = {}
|
||||||
header.SetAttribute = setAttribute
|
header.SetAttribute = setAttribute
|
||||||
header.GetAttribute = getAttribute
|
header.GetAttribute = getAttribute
|
||||||
|
|
||||||
--header:SetAttribute("template", "SecureUnitButtonTemplate")
|
-- header:SetAttribute('template', 'SecureUnitButtonTemplate')
|
||||||
for i = 1, arg.n, 2 do
|
for i = 1, arg.n, 2 do
|
||||||
local att, val = arg[i], arg[i+1]
|
local att, val = arg[i], arg[i+1]
|
||||||
if(not att) then break end
|
if(not att) then break end
|
||||||
|
|
||||||
header:SetAttribute(att, val)
|
header:SetAttribute(att, val)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -562,24 +561,23 @@ do
|
|||||||
header.visibility = visibility
|
header.visibility = visibility
|
||||||
|
|
||||||
-- Expose the header through oUF.headers.
|
-- Expose the header through oUF.headers.
|
||||||
insert(headers, header)
|
tinsert(headers, header)
|
||||||
|
|
||||||
header.initialConfigFunction = initialConfigFunction
|
header.initialConfigFunction = initialConfigFunction
|
||||||
header.headerType = isPetHeader and "pet" or "group"
|
header.headerType = isPetHeader and 'pet' or 'group'
|
||||||
|
|
||||||
if(header:GetAttribute("showParty")) then
|
if(header:GetAttribute('showParty')) then
|
||||||
self:DisableBlizzard("party")
|
self:DisableBlizzard('party')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if(visibility) then
|
if(visibility) then
|
||||||
local type, list = split(" ", visibility, 2)
|
local type, list = split(' ', visibility, 2)
|
||||||
if(list and type == "custom") then
|
if(list and type == 'custom') then
|
||||||
RegisterStateDriver(header, "visibility", list)
|
RegisterStateDriver(header, 'visibility', list)
|
||||||
header.visibility = list
|
header.visibility = list
|
||||||
else
|
else
|
||||||
local condition = getCondition(split(",", visibility))
|
local condition = getCondition(split(',', visibility))
|
||||||
RegisterStateDriver(header, "visibility", condition)
|
RegisterStateDriver(header, 'visibility', condition)
|
||||||
header.visibility = condition
|
header.visibility = condition
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -592,18 +590,18 @@ end
|
|||||||
Used to create a single unit frame and apply the currently active style to it.
|
Used to create a single unit frame and apply the currently active style to it.
|
||||||
|
|
||||||
* self - the global oUF object
|
* self - the global oUF object
|
||||||
* unit - the frame"s unit (string)
|
* unit - the frame's unit (string)
|
||||||
* overrideName - unique global name to use for the unit frame. Defaults to an auto-generated name based on the unit
|
* overrideName - unique global name to use for the unit frame. Defaults to an auto-generated name based on the unit
|
||||||
(string?)
|
(string?)
|
||||||
--]]
|
--]]
|
||||||
function oUF:Spawn(unit, overrideName)
|
function oUF:Spawn(unit, overrideName)
|
||||||
argcheck(unit, 2, "string")
|
argcheck(unit, 2, 'string')
|
||||||
if(not style) then return error("Unable to create frame. No styles have been registered.") end
|
if(not style) then return error('Unable to create frame. No styles have been registered.') end
|
||||||
|
|
||||||
unit = lower(unit)
|
unit = lower(unit)
|
||||||
|
|
||||||
local name = overrideName or generateName(unit)
|
local name = overrideName or generateName(unit)
|
||||||
local object = CreateFrame("Button", name, UIParent)
|
local object = CreateFrame('Button', name, UIParent)
|
||||||
object:Hide()
|
object:Hide()
|
||||||
Private.UpdateUnits(object, unit)
|
Private.UpdateUnits(object, unit)
|
||||||
|
|
||||||
@@ -626,12 +624,12 @@ Used to register an element with oUF.
|
|||||||
* disable - used to disable the element for a given unit frame (function?)
|
* disable - used to disable the element for a given unit frame (function?)
|
||||||
--]]
|
--]]
|
||||||
function oUF:AddElement(name, update, enable, disable)
|
function oUF:AddElement(name, update, enable, disable)
|
||||||
argcheck(name, 2, "string")
|
argcheck(name, 2, 'string')
|
||||||
argcheck(update, 3, "function", "nil")
|
argcheck(update, 3, 'function', 'nil')
|
||||||
argcheck(enable, 4, "function", "nil")
|
argcheck(enable, 4, 'function', 'nil')
|
||||||
argcheck(disable, 5, "function", "nil")
|
argcheck(disable, 5, 'function', 'nil')
|
||||||
|
|
||||||
if(elements[name]) then return error("Element [%s] is already registered.", name) end
|
if(elements[name]) then return error('Element [%s] is already registered.', name) end
|
||||||
elements[name] = {
|
elements[name] = {
|
||||||
update = update;
|
update = update;
|
||||||
enable = enable;
|
enable = enable;
|
||||||
|
|||||||
Reference in New Issue
Block a user