From 2bac834580ae3604336a06a9fe9810b907653348 Mon Sep 17 00:00:00 2001 From: Kkthnx <40672673+Kkthnx@users.noreply.github.com> Date: Sun, 17 Nov 2024 16:15:52 -0500 Subject: [PATCH] Formatting --- .../cargBags/base-add/bags.sieve.lua | 6 +- .../cargBags/base-add/filters.sieve.lua | 30 +- .../Libraries/cargBags/base/container.lua | 44 +- KkthnxUI/Libraries/cargBags/base/core.lua | 83 +-- .../Libraries/cargBags/base/itembutton.lua | 47 +- .../cargBags/mixins-add/default.scaffold.lua | 42 +- .../mixins-add/itemkeys/equipSets.lua | 14 +- .../cargBags/mixins-add/itemkeys/tooltip.lua | 14 +- .../Libraries/cargBags/mixins-add/layouts.lua | 30 +- .../Libraries/cargBags/mixins-add/sorts.lua | 2 +- .../Libraries/cargBags/mixins/api-common.lua | 6 +- .../Libraries/cargBags/mixins/parseBags.lua | 42 +- .../Libraries/cargBags/mixins/textFilter.lua | 28 +- KkthnxUI/Libraries/oUF/blizzard.lua | 76 +-- KkthnxUI/Libraries/oUF/colors.lua | 109 ++-- KkthnxUI/Libraries/oUF/combatevents.lua | 48 +- .../oUF/elements/additionalpower.lua | 100 ++-- .../oUF/elements/alternativepower.lua | 118 ++-- .../oUF/elements/assistantindicator.lua | 22 +- KkthnxUI/Libraries/oUF/elements/castbar.lua | 276 +++++---- .../Libraries/oUF/elements/classpower.lua | 135 +++-- .../oUF/elements/combatindicator.lua | 30 +- .../oUF/elements/grouproleindicator.lua | 34 +- KkthnxUI/Libraries/oUF/elements/health.lua | 154 ++--- .../oUF/elements/leaderindicator.lua | 26 +- .../Libraries/oUF/elements/phaseindicator.lua | 46 +- KkthnxUI/Libraries/oUF/elements/portrait.lua | 54 +- KkthnxUI/Libraries/oUF/elements/power.lua | 168 +++--- .../elements/pvpclassificationindicator.lua | 24 +- .../Libraries/oUF/elements/questindicator.lua | 26 +- .../oUF/elements/raidroleindicator.lua | 26 +- .../oUF/elements/raidtargetindicator.lua | 26 +- .../oUF/elements/readycheckindicator.lua | 46 +- .../oUF/elements/restingindicator.lua | 22 +- .../oUF/elements/resurrectindicator.lua | 26 +- KkthnxUI/Libraries/oUF/elements/runes.lua | 66 ++- KkthnxUI/Libraries/oUF/elements/stagger.lua | 88 +-- .../oUF/elements/summonindicator.lua | 36 +- KkthnxUI/Libraries/oUF/elements/tags.lua | 401 +++++++------ .../oUF/elements/threatindicator.lua | 38 +- KkthnxUI/Libraries/oUF/events.lua | 74 +-- KkthnxUI/Libraries/oUF/factory.lua | 16 +- KkthnxUI/Libraries/oUF/finalize.lua | 2 +- KkthnxUI/Libraries/oUF/init.lua | 2 +- KkthnxUI/Libraries/oUF/ouf.lua | 559 ++++++++++-------- KkthnxUI/Libraries/oUF/private.lua | 54 +- KkthnxUI/Libraries/oUF/units.lua | 160 ++--- .../Automation/Elements/Screenshot.lua | 5 +- .../Modules/Miscellaneous/Elements/ExpRep.lua | 18 + 49 files changed, 1885 insertions(+), 1614 deletions(-) diff --git a/KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua b/KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua index 3e29546b5..a1039207a 100644 --- a/KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua +++ b/KkthnxUI/Libraries/cargBags/base-add/bags.sieve.lua @@ -45,11 +45,13 @@ local Container = cargBags.classes.Container @param bags ]] function Container:SetBags(bags) - if(cargBags.ParseBags) then + if cargBags.ParseBags then bags = cargBags:ParseBags(bags) end - if(not bags) then return end + if not bags then + return + end self.implementation.bagToContainer = self.implementation.bagToContainer or {} local b2c = self.implementation.bagToContainer diff --git a/KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua b/KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua index 3a67be5a0..064b31286 100644 --- a/KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua +++ b/KkthnxUI/Libraries/cargBags/base-add/filters.sieve.lua @@ -46,9 +46,15 @@ end Empties the filter table ]] function FilterSet:Empty() - for k in pairs(self.funcs) do self.funcs[k] = nil end - for k in pairs(self.params) do self.params[k] = nil end - for k in pairs(self.chained) do self.chained[k] = nil end + for k in pairs(self.funcs) do + self.funcs[k] = nil + end + for k in pairs(self.params) do + self.params[k] = nil + end + for k in pairs(self.chained) do + self.chained[k] = nil + end end --[[! @@ -67,7 +73,7 @@ end @param flag whether the filter is enabled (-1: inverted) [optional] ]] function FilterSet:SetExtended(filter, param, flag) - if(not flag and param) then + if not flag and param then flag = true end @@ -81,7 +87,7 @@ end @param ... a list of filters ]] function FilterSet:SetMultiple(flag, ...) - for i=1, select("#", ...) do + for i = 1, select("#", ...) do local filter = select(i, ...) self:Set(filter, flag) end @@ -107,14 +113,14 @@ function FilterSet:Check(item) -- check own filters for filter, flag in pairs(funcs) do local result = filter(item, params[filter]) - if((flag == true and not result) or (flag == -1 and result)) then + if (flag == true and not result) or (flag == -1 and result) then return nil end end -- check filters of chained sets for tbl in pairs(self.chained) do - if(not tbl:Check(item)) then + if not tbl:Check(item) then return nil end end @@ -129,7 +135,7 @@ end ]] function Implementation:GetContainerForItem(item) for _, container in ipairs(self.contByID) do - if(not container.filters or container.filters:Check(item)) then + if not container.filters or container.filters:Check(item) then return container end end @@ -138,13 +144,13 @@ end --[[ Simple function shortcuts for Containers ]] -for name, func in pairs{ +for name, func in pairs({ ["SetFilter"] = "Set", ["SetExtendedFilter"] = "SetExtended", ["SetMultipleFilters"] = "SetMultiple", ["ChainFilters"] = "Chain", - ["CheckFilters"]= "Check", -} do + ["CheckFilters"] = "Check", +}) do Container[name] = function(self, ...) self.filters = self.filters or FilterSet:New() self.filters[func](self.filters, ...) @@ -163,4 +169,4 @@ function Container:FilterForFunction(func, filters) local result = filters:Check(button:GetInfo()) func(button, result) end -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/cargBags/base/container.lua b/KkthnxUI/Libraries/cargBags/base/container.lua index ab2b96f4d..fa9f820ca 100644 --- a/KkthnxUI/Libraries/cargBags/base/container.lua +++ b/KkthnxUI/Libraries/cargBags/base/container.lua @@ -26,11 +26,13 @@ local cargBags = ns.cargBags ]] local Container = cargBags:NewClass("Container", nil, "Button") -local mt_bags = {__index=function(self, bagID) - self[bagID] = CreateFrame("Frame", nil, self.container) - self[bagID]:SetID(bagID) - return self[bagID] -end} +local mt_bags = { + __index = function(self, bagID) + self[bagID] = CreateFrame("Frame", nil, self.container) + self[bagID]:SetID(bagID) + return self[bagID] + end, +} --[[! Creates a new instance of the class @@ -41,11 +43,11 @@ end} ]] function Container:New(name, ...) local implName = self.implementation.name - local container = setmetatable(CreateFrame("Button", implName..name), self.__index) + local container = setmetatable(CreateFrame("Button", implName .. name), self.__index) container.name = name container.buttons = {} - container.bags = setmetatable({container = container}, mt_bags) + container.bags = setmetatable({ container = container }, mt_bags) container:ScheduleContentCallback() container.implementation.contByName[name] = container -- Make this into pretty function? @@ -53,7 +55,9 @@ function Container:New(name, ...) container:SetParent(self.implementation) - if(container.OnCreate) then container:OnCreate(name, ...) end + if container.OnCreate then + container:OnCreate(name, ...) + end return container end @@ -69,8 +73,12 @@ function Container:AddButton(button) button:SetParent(self.bags[button.bagId]) self:ScheduleContentCallback() table.insert(self.buttons, button) - if(button.OnAdd) then button:OnAdd(self) end - if(self.OnButtonAdd) then self:OnButtonAdd(button) end + if button.OnAdd then + button:OnAdd(self) + end + if self.OnButtonAdd then + self:OnButtonAdd(button) + end end --[[! @@ -81,11 +89,15 @@ end ]] function Container:RemoveButton(button) for i, single in ipairs(self.buttons) do - if(button == single) then + if button == single then self:ScheduleContentCallback() button.container = nil - if(button.OnRemove) then button:OnRemove(self) end - if(self.OnButtonRemove) then self:OnButtonRemove(button) end + if button.OnRemove then + button:OnRemove(self) + end + if self.OnButtonRemove then + self:OnButtonRemove(button) + end return table.remove(self.buttons, i) end end @@ -94,12 +106,14 @@ end --[[ @callback OnContentsChanged() ]] -local updater, scheduled = CreateFrame"Frame", {} +local updater, scheduled = CreateFrame("Frame"), {} updater:Hide() updater:SetScript("OnUpdate", function(self) self:Hide() for container in pairs(scheduled) do - if(container.OnContentsChanged) then container:OnContentsChanged() end + if container.OnContentsChanged then + container:OnContentsChanged() + end scheduled[container] = nil end end) diff --git a/KkthnxUI/Libraries/cargBags/base/core.lua b/KkthnxUI/Libraries/cargBags/base/core.lua index 2d5bfae69..a9b88c39b 100644 --- a/KkthnxUI/Libraries/cargBags/base/core.lua +++ b/KkthnxUI/Libraries/cargBags/base/core.lua @@ -19,7 +19,7 @@ class-generation, helper-functions and the Blizzard-replacement. ]] local parent, ns = ... -local global = C_AddOns.GetAddOnMetadata(parent, 'X-cargBags') +local global = C_AddOns.GetAddOnMetadata(parent, "X-cargBags") --- @class table -- @name cargBags @@ -27,19 +27,20 @@ local global = C_AddOns.GetAddOnMetadata(parent, 'X-cargBags') -- class-generation, helper-functions and the Blizzard-replacement local cargBags = CreateFrame("Button") - ns.cargBags = cargBags -if(global) then +if global then _G[global] = cargBags end cargBags.classes = {} --- Holds all classes by their name cargBags.itemKeys = {} ---
Holds all ItemKeys by their name -local widgets = setmetatable({}, {__index = function(self, widget) - self[widget] = getmetatable(CreateFrame(widget)) - return self[widget] -end}) +local widgets = setmetatable({}, { + __index = function(self, widget) + self[widget] = getmetatable(CreateFrame(widget)) + return self[widget] + end, +}) --- Creates a new class -- @param name The name of the class @@ -47,7 +48,9 @@ end}) -- @param widget The widget type of the class -- @return class
The prototype of the class function cargBags:NewClass(name, parent, widget) - if(self.classes[name]) then return end + if self.classes[name] then + return + end parent = parent and self.classes[parent] local class = setmetatable({}, parent or (widget and widgets[widget])) class.__index = class @@ -70,9 +73,15 @@ function cargBags:GetImplementation(name) return self.classes.Implementation:Get(name) end -local function toggleBag(forceopen) cargBags.blizzard:Toggle(forceopen) end -local function toggleNoForce() cargBags.blizzard:Toggle() end -local function closeBag() cargBags.blizzard:Hide() end +local function toggleBag(forceopen) + cargBags.blizzard:Toggle(forceopen) +end +local function toggleNoForce() + cargBags.blizzard:Toggle() +end +local function closeBag() + cargBags.blizzard:Hide() +end --- Overwrites Blizzards Bag-Toggle-Functions with the implementation's ones -- @param name The name of the implementation [optional] @@ -85,11 +94,11 @@ function cargBags:ReplaceBlizzard(name) ToggleBag = toggleNoForce ToggleBackpack = toggleNoForce - OpenAllBags = toggleBag -- Name is misleading, Blizz-function actually toggles bags + OpenAllBags = toggleBag -- Name is misleading, Blizz-function actually toggles bags OpenBackpack = toggleBag -- Blizz does not provide toggling here CloseAllBags = closeBag CloseBackpack = closeBag - OpenBag = toggleBag -- fixed the loot won alert frame + OpenBag = toggleBag -- fixed the loot won alert frame BankFrame:UnregisterAllEvents() end @@ -99,7 +108,7 @@ end function cargBags:RegisterBlizzard(implementation) self.blizzard = implementation - if(IsLoggedIn()) then + if IsLoggedIn() then self:ReplaceBlizzard(self.blizzard) else self:RegisterEvent("PLAYER_LOGIN") @@ -112,7 +121,7 @@ end -- @param ... arguments of the event [optional] function cargBags:FireEvent(force, event, ...) for _, impl in pairs(self.classes.Implementation.instances) do - if(force or impl:IsShown()) then + if force or impl:IsShown() then impl:OnEvent(event or "BAG_UPDATE", ...) end end @@ -122,47 +131,53 @@ cargBags:RegisterEvent("BANKFRAME_OPENED") cargBags:RegisterEvent("BANKFRAME_CLOSED") cargBags:SetScript("OnEvent", function(self, event) - if(not self.blizzard) then return end + if not self.blizzard then + return + end local impl = self.blizzard - if(event == "PLAYER_LOGIN") then + if event == "PLAYER_LOGIN" then self:ReplaceBlizzard(impl) - elseif(event == "BANKFRAME_OPENED") then + elseif event == "BANKFRAME_OPENED" then self.atBank = true - if(impl:IsShown()) then + if impl:IsShown() then impl:OnEvent("BAG_UPDATE") else impl:Show() end - if(impl.OnBankOpened) then + if impl.OnBankOpened then impl:OnBankOpened() end - elseif(event == "BANKFRAME_CLOSED") then + elseif event == "BANKFRAME_CLOSED" then self.atBank = nil - if(impl:IsShown()) then + if impl:IsShown() then impl:Hide() end - if(impl.OnBankClosed) then + if impl.OnBankClosed then impl:OnBankClosed() end end end) -local handlerFuncs = setmetatable({}, {__index=function(self, handler) - self[handler] = function(self, ...) return self[handler] and self[handler](self, ...) end - return self[handler] -end}) +local handlerFuncs = setmetatable({}, { + __index = function(self, handler) + self[handler] = function(self, ...) + return self[handler] and self[handler](self, ...) + end + return self[handler] + end, +}) --- Sets a number of script handlers by redirecting them to the members function, e.g. self:OnEvent(self, ...) -- @param self -- @param ... A number of script handlers function cargBags.SetScriptHandlers(self, ...) - for i=1, select("#", ...) do + for i = 1, select("#", ...) do local handler = select(i, ...) self:SetScript(handler, handlerFuncs[handler]) end @@ -173,22 +188,24 @@ end -- @param slotID -- @return bagSlot function cargBags.ToBagSlot(bagID, slotID) - return bagID*100+slotID + return bagID * 100 + slotID end - --- Gets the bagID-slotID-pair of a bagSlot-index -- @param bagSlot -- @return bagID -- @return bagSlot function cargBags.FromBagSlot(bagSlot) - return floor(bagSlot/100), bagSlot % 100 + return floor(bagSlot / 100), bagSlot % 100 end --- Creates a new item table which has access to ItemKeys -- @return itemTable
-local m_item = {__index = function(i,k) return cargBags.itemKeys[k] and cargBags.itemKeys[k](i,k) end} +local m_item = { + __index = function(i, k) + return cargBags.itemKeys[k] and cargBags.itemKeys[k](i, k) + end, +} function cargBags:NewItemTable() return setmetatable({}, m_item) end - diff --git a/KkthnxUI/Libraries/cargBags/base/itembutton.lua b/KkthnxUI/Libraries/cargBags/base/itembutton.lua index 127215b1f..8e7458054 100644 --- a/KkthnxUI/Libraries/cargBags/base/itembutton.lua +++ b/KkthnxUI/Libraries/cargBags/base/itembutton.lua @@ -47,18 +47,15 @@ local ItemButton = cargBags:NewClass("ItemButton", nil, "ItemButton") ]] function ItemButton:GetTemplate(bagID) bagID = bagID or self.bagId - return (bagID == REAGENTBANK_CONTAINER and "ReagentBankItemButtonGenericTemplate") - or (bagID == BANK_CONTAINER and "BankItemButtonGenericTemplate") - or (bagID and "ContainerFrameItemButtonTemplate") - or "", - (bagID == REAGENTBANK_CONTAINER and ReagentBankFrame) - or (bagID == BANK_CONTAINER and BankFrame) - or (bagID and _G["ContainerFrame"..(bagID + 1)]) - or (ACCOUNTBANK_CONTAINERS[bagID] and AccountBankPanel) - or "" + return (bagID == REAGENTBANK_CONTAINER and "ReagentBankItemButtonGenericTemplate") or (bagID == BANK_CONTAINER and "BankItemButtonGenericTemplate") or (bagID and "ContainerFrameItemButtonTemplate") or "", (bagID == REAGENTBANK_CONTAINER and ReagentBankFrame) or (bagID == BANK_CONTAINER and BankFrame) or (bagID and _G["ContainerFrame" .. (bagID + 1)]) or (ACCOUNTBANK_CONTAINERS[bagID] and AccountBankPanel) or "" end -local mt_gen_key = {__index = function(self,k) self[k] = {}; return self[k]; end} +local mt_gen_key = { + __index = function(self, k) + self[k] = {} + return self[k] + end, +} --[[! Fetches a new instance of the ItemButton, creating one if necessary @@ -113,19 +110,31 @@ function ItemButton:Create(tpl, parent) impl.numSlots = (impl.numSlots or 0) + 1 local name = ("%sSlot%d"):format(impl.name, impl.numSlots) - local button = setmetatable(CreateFrame("ItemButton", name, parent, tpl..", BackdropTemplate"), self.__index) + local button = setmetatable(CreateFrame("ItemButton", name, parent, tpl .. ", BackdropTemplate"), self.__index) - if(button.Scaffold) then button:Scaffold(tpl) end - if(button.OnCreate) then button:OnCreate(tpl) end + if button.Scaffold then + button:Scaffold(tpl) + end + if button.OnCreate then + button:OnCreate(tpl) + end - local btnNT = _G[button:GetName().."NormalTexture"] + local btnNT = _G[button:GetName() .. "NormalTexture"] local btnNIT = button.NewItemTexture local btnBIT = button.BattlepayItemTexture local btnICO = button.ItemContextOverlay - if btnNT then btnNT:SetTexture("") end - if btnNIT then btnNIT:SetTexture("") end - if btnBIT then btnBIT:SetTexture("") end - if btnICO then btnICO:SetTexture("") end + if btnNT then + btnNT:SetTexture("") + end + if btnNIT then + btnNIT:SetTexture("") + end + if btnBIT then + btnBIT:SetTexture("") + end + if btnICO then + btnICO:SetTexture("") + end button:RegisterForDrag("LeftButton") -- fix button drag in 9.0 @@ -147,4 +156,4 @@ end ]] function ItemButton:GetInfo(item) return self.implementation:GetItemInfo(self.bagId, self.slotId, item) -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/cargBags/mixins-add/default.scaffold.lua b/KkthnxUI/Libraries/cargBags/mixins-add/default.scaffold.lua index 3c9f481c3..5cab061d6 100644 --- a/KkthnxUI/Libraries/cargBags/mixins-add/default.scaffold.lua +++ b/KkthnxUI/Libraries/cargBags/mixins-add/default.scaffold.lua @@ -33,19 +33,19 @@ local function ItemButton_Scaffold(self) local name = self:GetName() if not self.Icon then - self.Icon = _G[name.."IconTexture"] + self.Icon = _G[name .. "IconTexture"] end if not self.Count then - self.Count = _G[name.."Count"] + self.Count = _G[name .. "Count"] end if not self.Cooldown then - self.Cooldown = _G[name.."Cooldown"] + self.Cooldown = _G[name .. "Cooldown"] end if not self.Quest then - self.Quest = _G[name.."IconQuestTexture"] + self.Quest = _G[name .. "IconQuestTexture"] end if not self.Border then - self.Border = _G[name.."NormalTexture"] + self.Border = _G[name .. "NormalTexture"] end end @@ -57,7 +57,7 @@ end local function ItemButton_Update(self, item) self.Icon:SetTexture(item.texture or self.bgTex) - if(item.count and item.count > 1) then + if item.count and item.count > 1 then self.Count:SetText(item.count > 1e4 and "*" or item.count) self.Count:Show() else @@ -69,7 +69,9 @@ local function ItemButton_Update(self, item) self:ButtonUpdateLock(item) self:ButtonUpdateQuest(item) - if(self.OnUpdateButton) then self:OnUpdateButton(item) end + if self.OnUpdateButton then + self:OnUpdateButton(item) + end end --[[! @@ -78,14 +80,16 @@ end @callback OnUpdateCooldown(item) ]] local function ItemButton_UpdateCooldown(self, item) - if(item.cdEnable == 1 and item.cdStart and item.cdStart > 0) then + if item.cdEnable == 1 and item.cdStart and item.cdStart > 0 then self.Cooldown:SetCooldown(item.cdStart, item.cdFinish) self.Cooldown:Show() else self.Cooldown:Hide() end - if(self.OnUpdateCooldown) then self:OnUpdateCooldown(item) end + if self.OnUpdateCooldown then + self:OnUpdateCooldown(item) + end end --[[! @@ -96,7 +100,9 @@ end local function ItemButton_UpdateLock(self, item) self.Icon:SetDesaturated(item.locked) - if(self.OnUpdateLock) then self:OnUpdateLock(item) end + if self.OnUpdateLock then + self:OnUpdateLock(item) + end end --[[! @@ -105,22 +111,28 @@ end @callback OnUpdateQuest(item) ]] local function ItemButton_UpdateQuest(self, item) - if(self.OnUpdateQuest) then self:OnUpdateQuest(item) end + if self.OnUpdateQuest then + self:OnUpdateQuest(item) + end end local function ItemButton_OnEnter(self) - if(self.ItemOnEnter) then self:ItemOnEnter() end + if self.ItemOnEnter then + self:ItemOnEnter() + end end local function ItemButton_OnLeave(self) - if(self.ItemOnLeave) then self:ItemOnLeave() end + if self.ItemOnLeave then + self:ItemOnLeave() + end end cargBags:RegisterScaffold("Default", function(self) self.glowTex = "Interface\\Buttons\\UI-ActionButton-Border" --! @property glowTex The textures used for the glow self.glowAlpha = 0.8 --! @property glowAlpha The alpha of the glow texture self.glowBlend = "ADD" --! @property glowBlend The blendMode of the glow texture - self.glowCoords = { 14/64, 50/64, 14/64, 50/64 } --! @property glowCoords
Indexed table of texCoords for the glow texture + self.glowCoords = { 14 / 64, 50 / 64, 14 / 64, 50 / 64 } --! @property glowCoords
Indexed table of texCoords for the glow texture self.bgTex = nil --! @property bgTex Texture used as a background if no item is in the slot self.CreateFrame = ItemButton_CreateFrame @@ -133,4 +145,4 @@ cargBags:RegisterScaffold("Default", function(self) self.ButtonOnEnter = ItemButton_OnEnter self.ButtonOnLeave = ItemButton_OnLeave -end) \ No newline at end of file +end) diff --git a/KkthnxUI/Libraries/cargBags/mixins-add/itemkeys/equipSets.lua b/KkthnxUI/Libraries/cargBags/mixins-add/itemkeys/equipSets.lua index 8f184a2db..b44eab1e4 100644 --- a/KkthnxUI/Libraries/cargBags/mixins-add/itemkeys/equipSets.lua +++ b/KkthnxUI/Libraries/cargBags/mixins-add/itemkeys/equipSets.lua @@ -32,7 +32,9 @@ local setItems, isUpdating local function initUpdater() local function updateSets() - if isUpdating then return end + if isUpdating then + return + end isUpdating = true setItems = setItems or {} @@ -44,7 +46,7 @@ local function initUpdater() for _, location in pairs(locations) do local _, bank, bags, _, slot, bag = EquipmentManager_UnpackLocation(location) if (bank or bags) and slot and bag then - setItems[bag..":"..slot] = true + setItems[bag .. ":" .. slot] = true end end end @@ -63,6 +65,8 @@ local function initUpdater() end ItemKeys["isItemSet"] = function(item) - if not setItems then initUpdater() end - return setItems[item.bagId..":"..item.slotId] -end \ No newline at end of file + if not setItems then + initUpdater() + end + return setItems[item.bagId .. ":" .. item.slotId] +end diff --git a/KkthnxUI/Libraries/cargBags/mixins-add/itemkeys/tooltip.lua b/KkthnxUI/Libraries/cargBags/mixins-add/itemkeys/tooltip.lua index 5148c2400..5149dfd2a 100644 --- a/KkthnxUI/Libraries/cargBags/mixins-add/itemkeys/tooltip.lua +++ b/KkthnxUI/Libraries/cargBags/mixins-add/itemkeys/tooltip.lua @@ -38,14 +38,20 @@ local bindTypeToString = { } cargBags.itemKeys["bindOn"] = function(i) - if not i.link then return end + if not i.link then + return + end local data = C_TooltipInfo.GetBagItem(i.bagId, i.slotId) - if not data then return end + if not data then + return + end for j = 2, 5 do local lineData = data.lines[j] - if not lineData then break end + if not lineData then + break + end local lineText = lineData.leftText local bindOn = lineText and bindTypeToString[lineText] if bindOn then @@ -53,4 +59,4 @@ cargBags.itemKeys["bindOn"] = function(i) return bindOn end end -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/cargBags/mixins-add/layouts.lua b/KkthnxUI/Libraries/cargBags/mixins-add/layouts.lua index a89790854..a482186ec 100644 --- a/KkthnxUI/Libraries/cargBags/mixins-add/layouts.lua +++ b/KkthnxUI/Libraries/cargBags/mixins-add/layouts.lua @@ -30,27 +30,27 @@ function layouts.grid(self, columns, spacing, xOffset, yOffset) columns, spacing = columns or 8, spacing or 5 xOffset, yOffset = xOffset or 0, yOffset or 0 - local width, height = 0, 0 local col, row = 0, 0 for i, button in ipairs(self.buttons) do - - if(i == 1) then -- Hackish, I know + if i == 1 then -- Hackish, I know width, height = button:GetSize() end col = i % columns - if(col == 0) then col = columns end - row = math.ceil(i/columns) + if col == 0 then + col = columns + end + row = math.ceil(i / columns) - local xPos = (col-1) * (width + spacing) - local yPos = -1 * (row-1) * (height + spacing) + local xPos = (col - 1) * (width + spacing) + local yPos = -1 * (row - 1) * (height + spacing) button:ClearAllPoints() - button:SetPoint("TOPLEFT", self, "TOPLEFT", xPos+xOffset, yPos+yOffset) + button:SetPoint("TOPLEFT", self, "TOPLEFT", xPos + xOffset, yPos + yOffset) end - return columns * (width+spacing)-spacing, row * (height+spacing)-spacing + return columns * (width + spacing) - spacing, row * (height + spacing) - spacing end --[[! @@ -60,17 +60,17 @@ end @param yOffset y-offset of the whole layout [default: 0] ]] function layouts.circle(self, radius, xOffset, yOffset) - radius = radius or (#self.buttons*50)/math.pi/2 + radius = radius or (#self.buttons * 50) / math.pi / 2 xOffset, yOffset = xOffset or 0, yOffset or 0 - local a = 360/#self.buttons + local a = 360 / #self.buttons for i, button in ipairs(self.buttons) do - local x = radius*cos(a*i) - local y = -radius*sin(a*i) + local x = radius * cos(a * i) + local y = -radius * sin(a * i) button:ClearAllPoints() - button:SetPoint("TOPLEFT", self, "TOPLEFT", radius+x+xOffset, y-radius+yOffset) + button:SetPoint("TOPLEFT", self, "TOPLEFT", radius + x + xOffset, y - radius + yOffset) end - return radius*2, radius*2 + return radius * 2, radius * 2 end diff --git a/KkthnxUI/Libraries/cargBags/mixins-add/sorts.lua b/KkthnxUI/Libraries/cargBags/mixins-add/sorts.lua index 9f663f90f..05036d33c 100644 --- a/KkthnxUI/Libraries/cargBags/mixins-add/sorts.lua +++ b/KkthnxUI/Libraries/cargBags/mixins-add/sorts.lua @@ -31,7 +31,7 @@ local sorts = ns.cargBags.classes.Container.sorts Sorts the buttons depending on their bagSlot ]] function sorts.bagSlot(a, b) - if(a.bagId == b.bagId) then + if a.bagId == b.bagId then return a.slotId < b.slotId else return a.bagId < b.bagId diff --git a/KkthnxUI/Libraries/cargBags/mixins/api-common.lua b/KkthnxUI/Libraries/cargBags/mixins/api-common.lua index a6fae6c50..29d99a024 100644 --- a/KkthnxUI/Libraries/cargBags/mixins/api-common.lua +++ b/KkthnxUI/Libraries/cargBags/mixins/api-common.lua @@ -40,7 +40,6 @@ function Container:LayoutButtons(layout, ...) return self.layouts[layout](self, ...) end - --[[################################ Plugins Additional widgets for a bag @@ -49,9 +48,9 @@ end cargBags.plugins = {} function Implementation:SpawnPlugin(name, ...) - if(cargBags.plugins[name]) then + if cargBags.plugins[name] then local plugin = cargBags.plugins[name](self, ...) - if(plugin) then + if plugin then plugin.parent = self end return plugin @@ -63,7 +62,6 @@ function cargBags:RegisterPlugin(name, func) cargBags.plugins[name] = func end - --[[################################ Sorts Sort-functions for your containers diff --git a/KkthnxUI/Libraries/cargBags/mixins/parseBags.lua b/KkthnxUI/Libraries/cargBags/mixins/parseBags.lua index e89aa8c2d..6a43b2831 100644 --- a/KkthnxUI/Libraries/cargBags/mixins/parseBags.lua +++ b/KkthnxUI/Libraries/cargBags/mixins/parseBags.lua @@ -32,15 +32,15 @@ local _, ns = ... local cargBags = ns.cargBags local bagStrings = { - ["backpack"] = { 0 }, - ["bags"] = { 1, 2, 3, 4, 5 }, - ["backpack+bags"] = { 0, 1, 2, 3, 4, 5 }, - ["bankframe"] = { -1 }, - ["bankframe+bank"] = { -1, 6, 7, 8, 9, 10, 11, 12 }, - ["bankreagent"] = { -3 }, - ["bank"] = { 6, 7, 8, 9, 10, 11, 12 }, - ["keyring"] = { -2 }, - ["accountbank"] = { 13, 14, 15, 16, 17 }, + ["backpack"] = { 0 }, + ["bags"] = { 1, 2, 3, 4, 5 }, + ["backpack+bags"] = { 0, 1, 2, 3, 4, 5 }, + ["bankframe"] = { -1 }, + ["bankframe+bank"] = { -1, 6, 7, 8, 9, 10, 11, 12 }, + ["bankreagent"] = { -3 }, + ["bank"] = { 6, 7, 8, 9, 10, 11, 12 }, + ["keyring"] = { -2 }, + ["accountbank"] = { 13, 14, 15, 16, 17 }, } cargBags.BagStrings = bagStrings @@ -50,20 +50,26 @@ cargBags.BagStrings = bagStrings @return bags
]] function cargBags:ParseBags(bags) - if not bags then return end - if(type(bags) == "table") then return bags end - if(bagStrings[bags]) then return bagStrings[bags] end + if not bags then + return + end + if type(bags) == "table" then + return bags + end + if bagStrings[bags] then + return bagStrings[bags] + end local min, max = bags:match("(%d+)-(%d+)") - if(min) then + if min then local t = {} - for i=min, max do - t[#t+1] = i + for i = min, max do + t[#t + 1] = i end bagStrings[bags] = t return t - elseif(tonumber(bags)) then - local t = {tonumber(bags)} + elseif tonumber(bags) then + local t = { tonumber(bags) } bagStrings[bags] = t return t end -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/cargBags/mixins/textFilter.lua b/KkthnxUI/Libraries/cargBags/mixins/textFilter.lua index bf06302ed..555b8a7ea 100644 --- a/KkthnxUI/Libraries/cargBags/mixins/textFilter.lua +++ b/KkthnxUI/Libraries/cargBags/mixins/textFilter.lua @@ -32,12 +32,24 @@ local Container = cargBags.classes.Container local Implementation = cargBags.classes.Implementation local defaultFilters = { - n = function(i, arg) return i.name and i.name:lower():match(arg) end, - t = function(i, arg) return (i.type and i.type:lower():match(arg)) or (i.subType and i.subType:lower():match(arg)) or (i.equipLoc and i.equipLoc:lower():match(arg)) end, - b = function(i, arg) return i.bindOn and i.bindOn:match(arg) end, - q = function(i, arg) return i.quality == tonumber(arg) end, - bag = function(i, arg) return i.bagId == tonumber(arg) end, - quest = function(i) return i.isQuestItem end, + n = function(i, arg) + return i.name and i.name:lower():match(arg) + end, + t = function(i, arg) + return (i.type and i.type:lower():match(arg)) or (i.subType and i.subType:lower():match(arg)) or (i.equipLoc and i.equipLoc:lower():match(arg)) + end, + b = function(i, arg) + return i.bindOn and i.bindOn:match(arg) + end, + q = function(i, arg) + return i.quality == tonumber(arg) + end, + bag = function(i, arg) + return i.bagId == tonumber(arg) + end, + quest = function(i) + return i.isQuestItem + end, _default = "n", } @@ -57,9 +69,9 @@ function Implementation:ParseTextFilter(text, filters, textFilters) for match in text:gmatch("[^,;&]+") do local mod, type, value = match:trim():match("^(!?)(.-)[:=]?([^:=]*)$") mod = (mod == "!" and -1) or true - if(value and type ~= "" and textFilters[type]) then + if value and type ~= "" and textFilters[type] then filters:SetExtended(textFilters[type], value:lower(), mod) - elseif(value and type == "" and textFilters._default) then + elseif value and type == "" and textFilters._default then local name = textFilters._default filters:SetExtended(textFilters[name], value:lower(), mod) end diff --git a/KkthnxUI/Libraries/oUF/blizzard.lua b/KkthnxUI/Libraries/oUF/blizzard.lua index d85371ad8..2bf48f352 100644 --- a/KkthnxUI/Libraries/oUF/blizzard.lua +++ b/KkthnxUI/Libraries/oUF/blizzard.lua @@ -13,7 +13,7 @@ local isArenaHooked = false local isBossHooked = false local isPartyHooked = false -local hiddenParent = CreateFrame('Frame', nil, UIParent) +local hiddenParent = CreateFrame("Frame", nil, UIParent) hiddenParent:SetAllPoints() hiddenParent:Hide() @@ -22,98 +22,100 @@ local function insecureHide(self) end local function resetParent(self, parent) - if(parent ~= hiddenParent) then + if parent ~= hiddenParent then self:SetParent(hiddenParent) end end local function handleFrame(baseName, doNotReparent) local frame - if(type(baseName) == 'string') then + if type(baseName) == "string" then frame = _G[baseName] else frame = baseName end - if(frame) then + if frame then frame:UnregisterAllEvents() frame:Hide() - if(not doNotReparent) then + if not doNotReparent then frame:SetParent(hiddenParent) - if(not hookedFrames[frame]) then - hooksecurefunc(frame, 'SetParent', resetParent) + if not hookedFrames[frame] then + hooksecurefunc(frame, "SetParent", resetParent) hookedFrames[frame] = true end end local health = frame.healthBar or frame.healthbar or frame.HealthBar - if(health) then + if health then health:UnregisterAllEvents() end local power = frame.manabar or frame.ManaBar - if(power) then + if power then power:UnregisterAllEvents() end local spell = frame.castBar or frame.spellbar or frame.CastingBarFrame - if(spell) then + if spell then spell:UnregisterAllEvents() end local altpowerbar = frame.powerBarAlt or frame.PowerBarAlt - if(altpowerbar) then + if altpowerbar then altpowerbar:UnregisterAllEvents() end local buffFrame = frame.BuffFrame - if(buffFrame) then + if buffFrame then buffFrame:UnregisterAllEvents() end local petFrame = frame.petFrame or frame.PetFrame - if(petFrame) then + if petFrame then petFrame:UnregisterAllEvents() end local totFrame = frame.totFrame - if(totFrame) then + if totFrame then totFrame:UnregisterAllEvents() end local classPowerBar = frame.classPowerBar - if(classPowerBar) then + if classPowerBar then classPowerBar:UnregisterAllEvents() end local ccRemoverFrame = frame.CcRemoverFrame - if(ccRemoverFrame) then + if ccRemoverFrame then ccRemoverFrame:UnregisterAllEvents() end local debuffFrame = frame.DebuffFrame - if(debuffFrame) then + if debuffFrame then debuffFrame:UnregisterAllEvents() end end end 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) - elseif(unit == 'pet') then + elseif unit == "pet" then handleFrame(PetFrame) - elseif(unit == 'target') then + elseif unit == "target" then handleFrame(TargetFrame) - elseif(unit == 'focus') then + elseif unit == "focus" then handleFrame(FocusFrame) - elseif(unit:match('boss%d?$')) then - if(not isBossHooked) then + elseif unit:match("boss%d?$") then + if not isBossHooked then isBossHooked = true -- it's needed because the layout manager can bring frames that are @@ -128,11 +130,11 @@ function oUF:DisableBlizzard(unit) -- the size properly, 0 or negative sizes in turn will break the -- layout manager, fun... for i = 1, MAX_BOSS_FRAMES do - handleFrame('Boss' .. i .. 'TargetFrame', true) + handleFrame("Boss" .. i .. "TargetFrame", true) end end - elseif(unit:match('party%d?$')) then - if(not isPartyHooked) then + elseif unit:match("party%d?$") then + if not isPartyHooked then isPartyHooked = true handleFrame(PartyFrame) @@ -142,11 +144,11 @@ function oUF:DisableBlizzard(unit) end for i = 1, MEMBERS_PER_RAID_GROUP do - handleFrame('CompactPartyFrameMember' .. i) + handleFrame("CompactPartyFrameMember" .. i) end end - elseif(unit:match('arena%d?$')) then - if(not isArenaHooked) then + elseif unit:match("arena%d?$") then + if not isArenaHooked then isArenaHooked = true handleFrame(CompactArenaFrame) @@ -159,14 +161,18 @@ function oUF:DisableBlizzard(unit) end function oUF:DisableNamePlate(frame) - if(not(frame and frame.UnitFrame)) then return end - if(frame.UnitFrame:IsForbidden()) then return end + if not (frame and frame.UnitFrame) then + return + end + if frame.UnitFrame:IsForbidden() then + return + end - if(not hookedNameplates[frame]) then - frame.UnitFrame:HookScript('OnShow', insecureHide) + if not hookedNameplates[frame] then + frame.UnitFrame:HookScript("OnShow", insecureHide) hookedNameplates[frame] = true end handleFrame(frame.UnitFrame, true) -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/oUF/colors.lua b/KkthnxUI/Libraries/oUF/colors.lua index 36771ddc0..0c4eaf633 100644 --- a/KkthnxUI/Libraries/oUF/colors.lua +++ b/KkthnxUI/Libraries/oUF/colors.lua @@ -6,7 +6,7 @@ local frame_metatable = Private.frame_metatable local colorMixin = { SetRGBA = function(self, r, g, b, a) - if(r > 1 or g > 1 or b > 1) then + if r > 1 or g > 1 or b > 1 then r, g, b = r / 255, g / 255, b / 255 end @@ -19,7 +19,7 @@ local colorMixin = { self.a = a -- pre-generate the hex color, there's no point to this being generated on the fly - self.hex = string.format('ff%02x%02x%02x', self:GetRGBAsBytes()) + self.hex = string.format("ff%02x%02x%02x", self:GetRGBAsBytes()) end, SetAtlas = function(self, atlas) self.atlas = atlas @@ -57,9 +57,15 @@ end local colors = { smooth = { - 1, 0, 0, - 1, 1, 0, - 0, 1, 0 + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0, }, health = oUF:CreateColor(49, 207, 37), disconnected = oUF:CreateColor(0.6, 0.6, 0.6), @@ -70,16 +76,16 @@ local colors = { oUF:CreateColor(173, 235, 66), -- unholy }, selection = { - [ 0] = oUF:CreateColor(255, 0, 0), -- HOSTILE - [ 1] = oUF:CreateColor(255, 129, 0), -- UNFRIENDLY - [ 2] = oUF:CreateColor(255, 255, 0), -- NEUTRAL - [ 3] = oUF:CreateColor(0, 255, 0), -- FRIENDLY - [ 4] = oUF:CreateColor(0, 0, 255), -- PLAYER_SIMPLE - [ 5] = oUF:CreateColor(96, 96, 255), -- PLAYER_EXTENDED - [ 6] = oUF:CreateColor(170, 170, 255), -- PARTY - [ 7] = oUF:CreateColor(170, 255, 170), -- PARTY_PVP - [ 8] = oUF:CreateColor(83, 201, 255), -- FRIEND - [ 9] = oUF:CreateColor(128, 128, 128), -- DEAD + [0] = oUF:CreateColor(255, 0, 0), -- HOSTILE + [1] = oUF:CreateColor(255, 129, 0), -- UNFRIENDLY + [2] = oUF:CreateColor(255, 255, 0), -- NEUTRAL + [3] = oUF:CreateColor(0, 255, 0), -- FRIENDLY + [4] = oUF:CreateColor(0, 0, 255), -- PLAYER_SIMPLE + [5] = oUF:CreateColor(96, 96, 255), -- PLAYER_EXTENDED + [6] = oUF:CreateColor(170, 170, 255), -- PARTY + [7] = oUF:CreateColor(170, 255, 170), -- PARTY_PVP + [8] = oUF:CreateColor(83, 201, 255), -- FRIEND + [9] = oUF:CreateColor(128, 128, 128), -- DEAD -- [10] = {}, -- COMMENTATOR_TEAM_1, unavailable to players -- [11] = {}, -- COMMENTATOR_TEAM_2, unavailable to players [12] = oUF:CreateColor(255, 255, 139), -- SELF, buggy @@ -95,14 +101,14 @@ local colors = { -- We do this because people edit the vars directly, and changing the default -- globals makes SPICE FLOW! local function customClassColors() - if(_G.CUSTOM_CLASS_COLORS) then + if _G.CUSTOM_CLASS_COLORS then local function updateColors() for classToken, color in next, _G.CUSTOM_CLASS_COLORS do colors.class[classToken] = oUF:CreateColor(color.r, color.g, color.b) end for _, obj in next, oUF.objects do - obj:UpdateAllElements('CUSTOM_CLASS_COLORS') + obj:UpdateAllElements("CUSTOM_CLASS_COLORS") end end @@ -113,17 +119,17 @@ local function customClassColors() end end -if(not customClassColors()) then +if not customClassColors() then for classToken, color in next, _G.RAID_CLASS_COLORS do colors.class[classToken] = oUF:CreateColor(color.r, color.g, color.b) end - local eventHandler = CreateFrame('Frame') - eventHandler:RegisterEvent('ADDON_LOADED') - eventHandler:SetScript('OnEvent', function(self) - if(customClassColors()) then - self:UnregisterEvent('ADDON_LOADED') - self:SetScript('OnEvent', nil) + local eventHandler = CreateFrame("Frame") + eventHandler:RegisterEvent("ADDON_LOADED") + eventHandler:SetScript("OnEvent", function(self) + if customClassColors() then + self:UnregisterEvent("ADDON_LOADED") + self:SetScript("OnEvent", nil) end end) end @@ -139,15 +145,15 @@ end local staggerIndices = { green = 1, yellow = 2, - red = 3 + red = 3, } for power, color in next, PowerBarColor do - if (type(power) == 'string') then - if(color.r) then + if type(power) == "string" then + if color.r then colors.power[power] = oUF:CreateColor(color.r, color.g, color.b) - if(color.atlas) then + if color.atlas then colors.power[power]:SetAtlas(color.atlas) end else @@ -156,10 +162,10 @@ for power, color in next, PowerBarColor do for name, color_ in next, color do local index = staggerIndices[name] - if(index) then + if index then colors.power[power][index] = oUF:CreateColor(color_.r, color_.g, color_.b) - if(color_.atlas) then + if color_.atlas then colors.power[power][index]:SetAtlas(color_.atlas) end end @@ -203,13 +209,13 @@ for i = 0, 3 do end local function colorsAndPercent(a, b, ...) - if(a <= 0 or b == 0) then + if a <= 0 or b == 0 then return nil, ... - elseif(a >= b) then + elseif a >= b then return nil, select(-3, ...) end - local num = select('#', ...) / 3 + local num = select("#", ...) / 3 local segment, relperc = math.modf((a / b) * (num - 1)) return relperc, select((segment * 3) + 1, ...) end @@ -229,7 +235,7 @@ last 3 RGB values are returned. --]] function oUF:RGBColorGradient(...) local relperc, r1, g1, b1, r2, g2, b2 = colorsAndPercent(...) - if(relperc) then + if relperc then return r1 + (r2 - r1) * relperc, g1 + (g2 - g1) * relperc, b1 + (b2 - b1) * relperc else return r1, g1, b1 @@ -245,12 +251,12 @@ local function rgbToHCY(r, g, b) local min, max = math.min(r, g, b), math.max(r, g, b) local chroma = max - min local hue - if(chroma > 0) then - if(r == max) then + if chroma > 0 then + if r == max then hue = ((g - b) / chroma) % 6 - elseif(g == max) then + elseif g == max then hue = (b - r) / chroma + 2 - elseif(b == max) then + elseif b == max then hue = (r - g) / chroma + 4 end hue = hue / 6 @@ -260,27 +266,27 @@ end local function hcyToRGB(hue, chroma, luma) local r, g, b = 0, 0, 0 - if(hue and luma > 0) then + if hue and luma > 0 then local h2 = hue * 6 local x = chroma * (1 - math.abs(h2 % 2 - 1)) - if(h2 < 1) then + if h2 < 1 then r, g, b = chroma, x, 0 - elseif(h2 < 2) then + elseif h2 < 2 then r, g, b = x, chroma, 0 - elseif(h2 < 3) then + elseif h2 < 3 then r, g, b = 0, chroma, x - elseif(h2 < 4) then + elseif h2 < 4 then r, g, b = 0, x, chroma - elseif(h2 < 5) then + elseif h2 < 5 then r, g, b = x, 0, chroma else r, g, b = chroma, 0, x end local y = getY(r, g, b) - if(luma < y) then + if luma < y then chroma = chroma * (luma / y) - elseif(y < 1) then + elseif y < 1 then chroma = chroma * (1 - luma) / (1 - y) end @@ -305,7 +311,7 @@ last 3 HCY values are returned. --]] function oUF:HCYColorGradient(...) local relperc, r1, g1, b1, r2, g2, b2 = colorsAndPercent(...) - if(not relperc) then + if not relperc then return r1, g1, b1 end @@ -314,11 +320,11 @@ function oUF:HCYColorGradient(...) local c = c1 + (c2 - c1) * relperc local y = y1 + (y2 - y1) * relperc - if(h1 and h2) then + if h1 and h2 then local dh = h2 - h1 - if(dh < -0.5) then + if dh < -0.5 then dh = dh + 1 - elseif(dh > 0.5) then + elseif dh > 0.5 then dh = dh - 1 end @@ -326,7 +332,6 @@ function oUF:HCYColorGradient(...) else return hcyToRGB(h1 or h2, c, y) end - end --[[ Colors: oUF:ColorGradient(a, b, ...) or frame:ColorGradient(a, b, ...) @@ -346,4 +351,4 @@ oUF.colors = colors oUF.useHCYColorGradient = false frame_metatable.__index.colors = colors -frame_metatable.__index.ColorGradient = oUF.ColorGradient \ No newline at end of file +frame_metatable.__index.ColorGradient = oUF.ColorGradient diff --git a/KkthnxUI/Libraries/oUF/combatevents.lua b/KkthnxUI/Libraries/oUF/combatevents.lua index d54ad3c8e..7ddda059d 100644 --- a/KkthnxUI/Libraries/oUF/combatevents.lua +++ b/KkthnxUI/Libraries/oUF/combatevents.lua @@ -10,7 +10,7 @@ local CombatLogGetCurrentEventInfo = _G.CombatLogGetCurrentEventInfo local event_metatable = { __call = function(funcs, ...) for self, func in next, funcs do - if (self:IsVisible()) then + if self:IsVisible() then func(self, ...) end end @@ -22,19 +22,19 @@ local self_metatable = { for _, func in next, funcs do func(self, ...) end - end + end, } -local listener = CreateFrame('Frame') +local listener = CreateFrame("Frame") listener.activeEvents = 0 local function filter(_, event, ...) - if(listener[event]) then + if listener[event] then listener[event](event, ...) end end -listener:SetScript('OnEvent', function(self, event) +listener:SetScript("OnEvent", function(self, event) filter(CombatLogGetCurrentEventInfo()) end) @@ -47,29 +47,31 @@ Used to register a frame for a combat log event and add an event handler. same frame and event (function) --]] function frame_metatable.__index:RegisterCombatEvent(event, handler) - argcheck(event, 2, 'string') - argcheck(handler, 3, 'function') + argcheck(event, 2, "string") + argcheck(handler, 3, "function") - if(not listener[event]) then + if not listener[event] then listener[event] = setmetatable({}, event_metatable) listener.activeEvents = listener.activeEvents + 1 end local current = listener[event][self] - if(current) then + if current then for _, func in next, current do - if(func == handler) then return end + if func == handler then + return + end end table.insert(current, handler) else -- even with a single handler we want to make sure the frame is visible - listener[event][self] = setmetatable({handler}, self_metatable) + listener[event][self] = setmetatable({ handler }, self_metatable) end - if(listener.activeEvents > 0) then - listener:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') + if listener.activeEvents > 0 then + listener:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") end end @@ -81,35 +83,37 @@ Used to remove a function from the event handler list for a combat log event. * handler - function to be removed from the list of event handlers --]] function frame_metatable.__index:UnregisterCombatEvent(event, handler) - argcheck(event, 2, 'string') + argcheck(event, 2, "string") - if(not listener[event]) then return end + if not listener[event] then + return + end local cleanUp = false local current = listener[event][self] - if(current) then + if current then for i, func in next, current do - if(func == handler) then + if func == handler then current[i] = nil break end end - if(not next(current)) then + if not next(current) then cleanUp = true end end - if(cleanUp) then + if cleanUp then listener[event][self] = nil - if(not next(listener[event])) then + if not next(listener[event]) then listener[event] = nil listener.activeEvents = listener.activeEvents - 1 - if(listener.activeEvents <= 0) then - listener:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED') + if listener.activeEvents <= 0 then + listener:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED") end end end diff --git a/KkthnxUI/Libraries/oUF/elements/additionalpower.lua b/KkthnxUI/Libraries/oUF/elements/additionalpower.lua index 476c40de0..f6c7f9b2b 100644 --- a/KkthnxUI/Libraries/oUF/elements/additionalpower.lua +++ b/KkthnxUI/Libraries/oUF/elements/additionalpower.lua @@ -57,36 +57,38 @@ The following options are listed by priority. The first check that returns true local _, ns = ... local oUF = ns.oUF -local _, playerClass = UnitClass('player') +local _, playerClass = UnitClass("player") -- sourced from Blizzard_UnitFrame/AlternatePowerBar.lua local ALT_POWER_BAR_PAIR_DISPLAY_INFO = _G.ALT_POWER_BAR_PAIR_DISPLAY_INFO -local ADDITIONAL_POWER_BAR_NAME = 'MANA' +local ADDITIONAL_POWER_BAR_NAME = "MANA" local ADDITIONAL_POWER_BAR_INDEX = 0 local function UpdateColor(self, event, unit, powerType) - if(not (unit and UnitIsUnit(unit, 'player') and powerType == ADDITIONAL_POWER_BAR_NAME)) then return end + if not (unit and UnitIsUnit(unit, "player") and powerType == ADDITIONAL_POWER_BAR_NAME) then + return + end local element = self.AdditionalPower local r, g, b, color - if(element.colorPower) then + if element.colorPower then color = self.colors.power[ADDITIONAL_POWER_BAR_INDEX] - elseif(element.colorClass) then + elseif element.colorClass then color = self.colors.class[playerClass] - elseif(element.colorSmooth) then + elseif element.colorSmooth then r, g, b = self:ColorGradient(element.cur or 1, element.max or 1, unpack(element.smoothGradient or self.colors.smooth)) end - if(color) then + if color then r, g, b = color[1], color[2], color[3] end - if(b) then + if b then element:SetStatusBarColor(r, g, b) local bg = element.bg - if(bg) then + if bg then local mu = bg.multiplier or 1 bg:SetVertexColor(r * mu, g * mu, b * mu) end @@ -100,13 +102,15 @@ local function UpdateColor(self, event, unit, powerType) * g - the green component of the used color (number)[0-1] * b - the blue component of the used color (number)[0-1] --]] - if(element.PostUpdateColor) then + if element.PostUpdateColor then element:PostUpdateColor(r, g, b) end end local function Update(self, event, unit, powerType) - if(not (unit and UnitIsUnit(unit, 'player') and powerType == ADDITIONAL_POWER_BAR_NAME)) then return end + if not (unit and UnitIsUnit(unit, "player") and powerType == ADDITIONAL_POWER_BAR_NAME) then + return + end local element = self.AdditionalPower --[[ Callback: AdditionalPower:PreUpdate(unit) @@ -115,11 +119,11 @@ local function Update(self, event, unit, powerType) * self - the AdditionalPower element * unit - the unit for which the update has been triggered (string) --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate(unit) end - local cur, max = UnitPower('player', ADDITIONAL_POWER_BAR_INDEX), UnitPowerMax('player', ADDITIONAL_POWER_BAR_INDEX) + local cur, max = UnitPower("player", ADDITIONAL_POWER_BAR_INDEX), UnitPowerMax("player", ADDITIONAL_POWER_BAR_INDEX) element:SetMinMaxValues(0, max) element:SetValue(cur) @@ -133,7 +137,7 @@ local function Update(self, event, unit, powerType) * cur - the current value of the player's additional power (number) * max - the maximum value of the player's additional power (number) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(cur, max) end end @@ -147,7 +151,7 @@ local function Path(self, ...) * unit - the unit accompanying the event (string) * ... - the arguments accompanying the event --]] - (self.AdditionalPower.Override or Update) (self, ...); + (self.AdditionalPower.Override or Update)(self, ...); --[[ Override: AdditionalPower.UpdateColor(self, event, unit, ...) Used to completely override the internal function for updating the widgets' colors. @@ -157,46 +161,46 @@ local function Path(self, ...) * unit - the unit accompanying the event (string) * ... - the arguments accompanying the event --]] - (self.AdditionalPower.UpdateColor or UpdateColor) (self, ...) + (self.AdditionalPower.UpdateColor or UpdateColor)(self, ...) end local function ElementEnable(self) local element = self.AdditionalPower - if(element.frequentUpdates) then - self:RegisterEvent('UNIT_POWER_FREQUENT', Path) + if element.frequentUpdates then + self:RegisterEvent("UNIT_POWER_FREQUENT", Path) else - self:RegisterEvent('UNIT_POWER_UPDATE', Path) + self:RegisterEvent("UNIT_POWER_UPDATE", Path) end - self:RegisterEvent('UNIT_MAXPOWER', Path) + self:RegisterEvent("UNIT_MAXPOWER", Path) element:Show() element.__isEnabled = true - Path(self, 'ElementEnable', 'player', ADDITIONAL_POWER_BAR_NAME) + Path(self, "ElementEnable", "player", ADDITIONAL_POWER_BAR_NAME) end local function ElementDisable(self) local element = self.AdditionalPower - self:UnregisterEvent('UNIT_MAXPOWER', Path) - self:UnregisterEvent('UNIT_POWER_FREQUENT', Path) - self:UnregisterEvent('UNIT_POWER_UPDATE', Path) + self:UnregisterEvent("UNIT_MAXPOWER", Path) + self:UnregisterEvent("UNIT_POWER_FREQUENT", Path) + self:UnregisterEvent("UNIT_POWER_UPDATE", Path) element:Hide() element.__isEnabled = false - Path(self, 'ElementDisable', 'player', ADDITIONAL_POWER_BAR_NAME) + Path(self, "ElementDisable", "player", ADDITIONAL_POWER_BAR_NAME) end local function Visibility(self, event, unit) local element = self.AdditionalPower local shouldEnable - if(not UnitHasVehicleUI('player')) then - if(UnitPowerMax(unit, ADDITIONAL_POWER_BAR_INDEX) ~= 0) then - if(element.displayPairs[playerClass]) then + if not UnitHasVehicleUI("player") then + if UnitPowerMax(unit, ADDITIONAL_POWER_BAR_INDEX) ~= 0 then + if element.displayPairs[playerClass] then local powerType = UnitPowerType(unit) shouldEnable = element.displayPairs[playerClass][powerType] end @@ -205,7 +209,7 @@ local function Visibility(self, event, unit) local isEnabled = element.__isEnabled - if(shouldEnable and not isEnabled) then + if shouldEnable and not isEnabled then ElementEnable(self) --[[ Callback: AdditionalPower:PostVisibility(isVisible) @@ -214,16 +218,16 @@ local function Visibility(self, event, unit) * self - the AdditionalPower element * isVisible - the current visibility state of the element (boolean) --]] - if(element.PostVisibility) then + if element.PostVisibility then element:PostVisibility(true) end - elseif(not shouldEnable and (isEnabled or isEnabled == nil)) then + elseif not shouldEnable and (isEnabled or isEnabled == nil) then ElementDisable(self) - if(element.PostVisibility) then + if element.PostVisibility then element:PostVisibility(false) end - elseif(shouldEnable and isEnabled) then + elseif shouldEnable and isEnabled then Path(self, event, unit, ADDITIONAL_POWER_BAR_NAME) end end @@ -236,11 +240,11 @@ local function VisibilityPath(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event (string) --]] - (self.AdditionalPower.OverrideVisibility or Visibility) (self, ...) + (self.AdditionalPower.OverrideVisibility or Visibility)(self, ...) end local function ForceUpdate(element) - VisibilityPath(element.__owner, 'ForceUpdate', element.__owner.unit) + VisibilityPath(element.__owner, "ForceUpdate", element.__owner.unit) end --[[ Power:SetFrequentUpdates(state, isForced) @@ -251,32 +255,32 @@ Used to toggle frequent updates. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetFrequentUpdates(element, state, isForced) - if(element.frequentUpdates ~= state or isForced) then + if element.frequentUpdates ~= state or isForced then element.frequentUpdates = state - if(state) then - element.__owner:UnregisterEvent('UNIT_POWER_UPDATE', Path) - element.__owner:RegisterEvent('UNIT_POWER_FREQUENT', Path) + if state then + element.__owner:UnregisterEvent("UNIT_POWER_UPDATE", Path) + element.__owner:RegisterEvent("UNIT_POWER_FREQUENT", Path) else - element.__owner:UnregisterEvent('UNIT_POWER_FREQUENT', Path) - element.__owner:RegisterEvent('UNIT_POWER_UPDATE', Path) + element.__owner:UnregisterEvent("UNIT_POWER_FREQUENT", Path) + element.__owner:RegisterEvent("UNIT_POWER_UPDATE", Path) end end end local function Enable(self, unit) local element = self.AdditionalPower - if(element and UnitIsUnit(unit, 'player')) then + if element and UnitIsUnit(unit, "player") then element.__owner = self element.ForceUpdate = ForceUpdate element.SetFrequentUpdates = SetFrequentUpdates - self:RegisterEvent('UNIT_DISPLAYPOWER', VisibilityPath) + self:RegisterEvent("UNIT_DISPLAYPOWER", VisibilityPath) - if(not element.displayPairs) then + if not element.displayPairs then element.displayPairs = CopyTable(ALT_POWER_BAR_PAIR_DISPLAY_INFO) end - if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then + if element:IsObjectType("StatusBar") and not element:GetStatusBarTexture() then element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end @@ -286,11 +290,11 @@ end local function Disable(self) local element = self.AdditionalPower - if(element) then + if element then ElementDisable(self) - self:UnregisterEvent('UNIT_DISPLAYPOWER', VisibilityPath) + self:UnregisterEvent("UNIT_DISPLAYPOWER", VisibilityPath) end end -oUF:AddElement('AdditionalPower', VisibilityPath, Enable, Disable) \ No newline at end of file +oUF:AddElement("AdditionalPower", VisibilityPath, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/alternativepower.lua b/KkthnxUI/Libraries/oUF/elements/alternativepower.lua index 518c7bab8..8ad63c738 100644 --- a/KkthnxUI/Libraries/oUF/elements/alternativepower.lua +++ b/KkthnxUI/Libraries/oUF/elements/alternativepower.lua @@ -59,17 +59,19 @@ local unitSelectionType = Private.unitSelectionType -- sourced from Blizzard_UnitFrame/UnitPowerBarAlt.lua local ALTERNATE_POWER_INDEX = Enum.PowerType.Alternate or 10 -local ALTERNATE_POWER_NAME = 'ALTERNATE' +local ALTERNATE_POWER_NAME = "ALTERNATE" local function updateTooltip(self) local name, tooltip = GetUnitPowerBarStringsByID(self.__barID) - GameTooltip:SetText(name or '', 1, 1, 1) - GameTooltip:AddLine(tooltip or '', nil, nil, nil, true) + GameTooltip:SetText(name or "", 1, 1, 1) + GameTooltip:AddLine(tooltip or "", nil, nil, nil, true) GameTooltip:Show() end local function onEnter(self) - if(not self:IsVisible()) then return end + if not self:IsVisible() then + return + end GameTooltip_SetDefaultAnchor(GameTooltip, self) self:UpdateTooltip() @@ -80,36 +82,37 @@ local function onLeave() end local function UpdateColor(self, event, unit, powerType) - if(self.unit ~= unit or powerType ~= ALTERNATE_POWER_NAME) then return end + if self.unit ~= unit or powerType ~= ALTERNATE_POWER_NAME then + return + end local element = self.AlternativePower local r, g, b, color - if(element.colorThreat and not UnitPlayerControlled(unit) and UnitThreatSituation('player', unit)) then - color = self.colors.threat[UnitThreatSituation('player', unit)] - elseif(element.colorPower) then + if element.colorThreat and not UnitPlayerControlled(unit) and UnitThreatSituation("player", unit) then + color = self.colors.threat[UnitThreatSituation("player", unit)] + elseif element.colorPower then color = self.colors.power[ALTERNATE_POWER_INDEX] - elseif(element.colorClass and (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) - or (element.colorClassNPC and not (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) then + elseif (element.colorClass and (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) or (element.colorClassNPC and not (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) then local _, class = UnitClass(unit) color = self.colors.class[class] - elseif(element.colorSelection and unitSelectionType(unit, element.considerSelectionInCombatHostile)) then + elseif element.colorSelection and unitSelectionType(unit, element.considerSelectionInCombatHostile) then color = self.colors.selection[unitSelectionType(unit, element.considerSelectionInCombatHostile)] - elseif(element.colorReaction and UnitReaction(unit, 'player')) then - color = self.colors.reaction[UnitReaction(unit, 'player')] - elseif(element.colorSmooth) then + elseif element.colorReaction and UnitReaction(unit, "player") then + color = self.colors.reaction[UnitReaction(unit, "player")] + elseif element.colorSmooth then local adjust = 0 - (element.min or 0) r, g, b = self:ColorGradient((element.cur or 1) + adjust, (element.max or 1) + adjust, unpack(element.smoothGradient or self.colors.smooth)) end - if(color) then + if color then r, g, b = color[1], color[2], color[3] end - if(b) then + if b then element:SetStatusBarColor(r, g, b) local bg = element.bg - if(bg) then + if bg then local mu = bg.multiplier or 1 bg:SetVertexColor(r * mu, g * mu, b * mu) end @@ -124,13 +127,15 @@ local function UpdateColor(self, event, unit, powerType) * g - the green component of the used color (number)[0-1] * b - the blue component of the used color (number)[0-1] --]] - if(element.PostUpdateColor) then + if element.PostUpdateColor then element:PostUpdateColor(unit, r, g, b) end end local function Update(self, event, unit, powerType) - if(self.unit ~= unit or powerType ~= ALTERNATE_POWER_NAME) then return end + if self.unit ~= unit or powerType ~= ALTERNATE_POWER_NAME then + return + end local element = self.AlternativePower --[[ Callback: AlternativePower:PreUpdate() @@ -138,13 +143,13 @@ local function Update(self, event, unit, powerType) * self - the AlternativePower element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local cur, max, min local barInfo = element.__barInfo - if(barInfo) then + if barInfo then cur = UnitPower(unit, ALTERNATE_POWER_INDEX) max = UnitPowerMax(unit, ALTERNATE_POWER_INDEX) min = barInfo.minPower @@ -165,7 +170,7 @@ local function Update(self, event, unit, powerType) * min - the minimum value of the unit's alternative power (number?) * max - the maximum value of the unit's alternative power (number?) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(unit, cur, min, max) end end @@ -179,7 +184,7 @@ local function Path(self, ...) * unit - the unit accompanying the event (string) * ... - the arguments accompanying the event --]] - (self.AlternativePower.Override or Update) (self, ...); + (self.AlternativePower.Override or Update)(self, ...); --[[ Override: AlternativePower.UpdateColor(self, event, unit, ...) Used to completely override the internal function for updating the widgets' colors. @@ -189,29 +194,28 @@ local function Path(self, ...) * unit - the unit accompanying the event (string) * ... - the arguments accompanying the event --]] - (self.AlternativePower.UpdateColor or UpdateColor) (self, ...) + (self.AlternativePower.UpdateColor or UpdateColor)(self, ...) end local function Visibility(self, event, unit) - if(unit ~= self.unit) then return end + if unit ~= self.unit then + return + end local element = self.AlternativePower local barID = UnitPowerBarID(unit) local barInfo = GetUnitPowerBarInfoByID(barID) element.__barID = barID element.__barInfo = barInfo - if(barInfo and (barInfo.showOnRaid and (UnitInParty(unit) or UnitInRaid(unit)) - or not barInfo.hideFromOthers - or UnitIsUnit(unit, 'player'))) - then - self:RegisterEvent('UNIT_POWER_UPDATE', Path) - self:RegisterEvent('UNIT_MAXPOWER', Path) + if barInfo and (barInfo.showOnRaid and (UnitInParty(unit) or UnitInRaid(unit)) or not barInfo.hideFromOthers or UnitIsUnit(unit, "player")) then + self:RegisterEvent("UNIT_POWER_UPDATE", Path) + self:RegisterEvent("UNIT_MAXPOWER", Path) element:Show() Path(self, event, unit, ALTERNATE_POWER_NAME) else - self:UnregisterEvent('UNIT_POWER_UPDATE', Path) - self:UnregisterEvent('UNIT_MAXPOWER', Path) + self:UnregisterEvent("UNIT_POWER_UPDATE", Path) + self:UnregisterEvent("UNIT_MAXPOWER", Path) element:Hide() Path(self, event, unit, ALTERNATE_POWER_NAME) @@ -226,33 +230,33 @@ local function VisibilityPath(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event (string) --]] - return (self.AlternativePower.OverrideVisibility or Visibility) (self, ...) + return (self.AlternativePower.OverrideVisibility or Visibility)(self, ...) end local function ForceUpdate(element) - return VisibilityPath(element.__owner, 'ForceUpdate', element.__owner.unit) + return VisibilityPath(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self, unit) local element = self.AlternativePower - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('UNIT_POWER_BAR_SHOW', VisibilityPath) - self:RegisterEvent('UNIT_POWER_BAR_HIDE', VisibilityPath) + self:RegisterEvent("UNIT_POWER_BAR_SHOW", VisibilityPath) + self:RegisterEvent("UNIT_POWER_BAR_HIDE", VisibilityPath) - if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then + if element:IsObjectType("StatusBar") and not element:GetStatusBarTexture() then element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end - if(element:IsMouseEnabled()) then - if(not element:GetScript('OnEnter')) then - element:SetScript('OnEnter', onEnter) + if element:IsMouseEnabled() then + if not element:GetScript("OnEnter") then + element:SetScript("OnEnter", onEnter) end - if(not element:GetScript('OnLeave')) then - element:SetScript('OnLeave', onLeave) + if not element:GetScript("OnLeave") then + element:SetScript("OnLeave", onLeave) end --[[ Override: AlternativePower:UpdateTooltip() @@ -260,15 +264,15 @@ local function Enable(self, unit) * self - the AlternativePower element --]] - if(not element.UpdateTooltip) then + if not element.UpdateTooltip then element.UpdateTooltip = updateTooltip end end - if(unit == 'player') then - PlayerPowerBarAlt:UnregisterEvent('UNIT_POWER_BAR_SHOW') - PlayerPowerBarAlt:UnregisterEvent('UNIT_POWER_BAR_HIDE') - PlayerPowerBarAlt:UnregisterEvent('PLAYER_ENTERING_WORLD') + if unit == "player" then + PlayerPowerBarAlt:UnregisterEvent("UNIT_POWER_BAR_SHOW") + PlayerPowerBarAlt:UnregisterEvent("UNIT_POWER_BAR_HIDE") + PlayerPowerBarAlt:UnregisterEvent("PLAYER_ENTERING_WORLD") end return true @@ -277,18 +281,18 @@ end local function Disable(self, unit) local element = self.AlternativePower - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_POWER_BAR_SHOW', VisibilityPath) - self:UnregisterEvent('UNIT_POWER_BAR_HIDE', VisibilityPath) + self:UnregisterEvent("UNIT_POWER_BAR_SHOW", VisibilityPath) + self:UnregisterEvent("UNIT_POWER_BAR_HIDE", VisibilityPath) - if(unit == 'player') then - PlayerPowerBarAlt:RegisterEvent('UNIT_POWER_BAR_SHOW') - PlayerPowerBarAlt:RegisterEvent('UNIT_POWER_BAR_HIDE') - PlayerPowerBarAlt:RegisterEvent('PLAYER_ENTERING_WORLD') + if unit == "player" then + PlayerPowerBarAlt:RegisterEvent("UNIT_POWER_BAR_SHOW") + PlayerPowerBarAlt:RegisterEvent("UNIT_POWER_BAR_HIDE") + PlayerPowerBarAlt:RegisterEvent("PLAYER_ENTERING_WORLD") end end end -oUF:AddElement('AlternativePower', VisibilityPath, Enable, Disable) \ No newline at end of file +oUF:AddElement("AlternativePower", VisibilityPath, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/assistantindicator.lua b/KkthnxUI/Libraries/oUF/elements/assistantindicator.lua index 01a178d5c..9dfa46d70 100644 --- a/KkthnxUI/Libraries/oUF/elements/assistantindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/assistantindicator.lua @@ -34,12 +34,12 @@ local function Update(self, event) * self - the AssistantIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local isAssistant = UnitInRaid(unit) and UnitIsGroupAssistant(unit) and not UnitIsGroupLeader(unit) - if(isAssistant) then + if isAssistant then element:Show() else element:Hide() @@ -51,7 +51,7 @@ local function Update(self, event) * self - the AssistantIndicator element * isAssistant - indicates whether the unit is a raid assistant (boolean) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(isAssistant) end end @@ -64,22 +64,22 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event (string) --]] - return (self.AssistantIndicator.Override or Update) (self, ...) + return (self.AssistantIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate') + return Path(element.__owner, "ForceUpdate") end local function Enable(self) local element = self.AssistantIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('GROUP_ROSTER_UPDATE', Path, true) + self:RegisterEvent("GROUP_ROSTER_UPDATE", Path, true) - if(element:IsObjectType('Texture') and not element:GetTexture()) then + if element:IsObjectType("Texture") and not element:GetTexture() then element:SetTexture([[Interface\GroupFrame\UI-Group-AssistantIcon]]) end @@ -89,11 +89,11 @@ end local function Disable(self) local element = self.AssistantIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path) + self:UnregisterEvent("GROUP_ROSTER_UPDATE", Path) end end -oUF:AddElement('AssistantIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("AssistantIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/castbar.lua b/KkthnxUI/Libraries/oUF/elements/castbar.lua index 22da1ad68..46014b7dd 100644 --- a/KkthnxUI/Libraries/oUF/elements/castbar.lua +++ b/KkthnxUI/Libraries/oUF/elements/castbar.lua @@ -95,8 +95,8 @@ local _, ns = ... local oUF = ns.oUF local FALLBACK_ICON = 136243 -- Interface\ICONS\Trade_Engineering -local FAILED = _G.FAILED or 'Failed' -local INTERRUPTED = _G.INTERRUPTED or 'Interrupted' +local FAILED = _G.FAILED or "Failed" +local INTERRUPTED = _G.INTERRUPTED or "Interrupted" local CASTBAR_STAGE_DURATION_INVALID = -1 -- defined in FrameXML/CastingBarFrame.lua local function resetAttributes(self) @@ -117,26 +117,26 @@ local function resetAttributes(self) end local function CreatePip(element) - return CreateFrame('Frame', nil, element, 'CastingBarFrameStagePipTemplate') + return CreateFrame("Frame", nil, element, "CastingBarFrameStagePipTemplate") end local function UpdatePips(element, numStages) local stageTotalDuration = 0 local stageMaxValue = element.max * 1000 - local isHoriz = element:GetOrientation() == 'HORIZONTAL' + local isHoriz = element:GetOrientation() == "HORIZONTAL" local elementSize = isHoriz and element:GetWidth() or element:GetHeight() element.numStages = numStages element.curStage = 0 -- NOTE: Updates only if the PostUpdateStage callback is present for stage = 1, numStages do local duration - if(stage > numStages) then + if stage > numStages then duration = GetUnitEmpowerHoldAtMaxTime(element.__owner.unit) else duration = GetUnitEmpowerStageDuration(element.__owner.unit, stage - 1) end - if(duration > CASTBAR_STAGE_DURATION_INVALID) then + if duration > CASTBAR_STAGE_DURATION_INVALID then stageTotalDuration = stageTotalDuration + duration element.stagePoints[stage] = stageTotalDuration / 1000 @@ -144,7 +144,7 @@ local function UpdatePips(element, numStages) local offset = elementSize * portion local pip = element.Pips[stage] - if(not pip) then + if not pip then --[[ Override: Castbar:CreatePip(stage) Creates a "pip" for the given stage, used for empowered casts. @@ -154,36 +154,36 @@ local function UpdatePips(element, numStages) * pip - a frame used to depict an empowered stage boundary, typically with a line texture (frame) --]] - pip = (element.CreatePip or CreatePip) (element, stage) + pip = (element.CreatePip or CreatePip)(element, stage) element.Pips[stage] = pip end pip:ClearAllPoints() pip:Show() - if(isHoriz) then - if(pip.RotateTextures) then + if isHoriz then + if pip.RotateTextures then pip:RotateTextures(0) end - if(element:GetReverseFill()) then - pip:SetPoint('TOP', element, 'TOPRIGHT', -offset, 0) - pip:SetPoint('BOTTOM', element, 'BOTTOMRIGHT', -offset, 0) + if element:GetReverseFill() then + pip:SetPoint("TOP", element, "TOPRIGHT", -offset, 0) + pip:SetPoint("BOTTOM", element, "BOTTOMRIGHT", -offset, 0) else - pip:SetPoint('TOP', element, 'TOPLEFT', offset, 0) - pip:SetPoint('BOTTOM', element, 'BOTTOMLEFT', offset, 0) + pip:SetPoint("TOP", element, "TOPLEFT", offset, 0) + pip:SetPoint("BOTTOM", element, "BOTTOMLEFT", offset, 0) end else - if(pip.RotateTextures) then + if pip.RotateTextures then pip:RotateTextures(1.5708) end - if(element:GetReverseFill()) then - pip:SetPoint('LEFT', element, 'TOPLEFT', 0, -offset) - pip:SetPoint('RIGHT', element, 'TOPRIGHT', 0, -offset) + if element:GetReverseFill() then + pip:SetPoint("LEFT", element, "TOPLEFT", 0, -offset) + pip:SetPoint("RIGHT", element, "TOPRIGHT", 0, -offset) else - pip:SetPoint('LEFT', element, 'BOTTOMLEFT', 0, offset) - pip:SetPoint('RIGHT', element, 'BOTTOMRIGHT', 0, offset) + pip:SetPoint("LEFT", element, "BOTTOMLEFT", 0, offset) + pip:SetPoint("RIGHT", element, "BOTTOMRIGHT", 0, offset) end end end @@ -195,7 +195,7 @@ local function UpdatePips(element, numStages) * self - the Castbar widget * numStages - the number of stages in the current cast (number) --]] - if(element.PostUpdatePips) then + if element.PostUpdatePips then element:PostUpdatePips(numStages) end end @@ -213,30 +213,30 @@ end local function CastStart(self, event, unit) local element = self.Castbar - if(not (element.ShouldShow or ShouldShow) (element, unit)) then + if not (element.ShouldShow or ShouldShow)(element, unit) then return end local numStages, _ local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo(unit) - event = 'UNIT_SPELLCAST_START' - if(not name) then + event = "UNIT_SPELLCAST_START" + if not name then name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = UnitChannelInfo(unit) - event = (numStages and numStages > 0) and 'UNIT_SPELLCAST_EMPOWER_START' or 'UNIT_SPELLCAST_CHANNEL_START' + event = (numStages and numStages > 0) and "UNIT_SPELLCAST_EMPOWER_START" or "UNIT_SPELLCAST_CHANNEL_START" end - if(not name or (isTradeSkill and element.hideTradeSkills)) then + if not name or (isTradeSkill and element.hideTradeSkills) then resetAttributes(element) element:Hide() return end - element.casting = event == 'UNIT_SPELLCAST_START' - element.channeling = event == 'UNIT_SPELLCAST_CHANNEL_START' - element.empowering = event == 'UNIT_SPELLCAST_EMPOWER_START' + element.casting = event == "UNIT_SPELLCAST_START" + element.channeling = event == "UNIT_SPELLCAST_CHANNEL_START" + element.empowering = event == "UNIT_SPELLCAST_EMPOWER_START" - if(element.empowering) then + if element.empowering then endTime = endTime + GetUnitEmpowerHoldAtMaxTime(unit) end @@ -251,7 +251,7 @@ local function CastStart(self, event, unit) element.castID = castID element.spellID = spellID - if(element.channeling) then + if element.channeling then element.duration = endTime - GetTime() else element.duration = GetTime() - startTime @@ -260,42 +260,52 @@ local function CastStart(self, event, unit) element:SetMinMaxValues(0, element.max) element:SetValue(element.duration) - if(element.Icon) then element.Icon:SetTexture(texture or FALLBACK_ICON) end - if(element.Shield) then element.Shield:SetShown(notInterruptible) end - if(element.Spark) then element.Spark:Show() end - if(element.Text) then element.Text:SetText(text) end - if(element.Time) then element.Time:SetText() end + if element.Icon then + element.Icon:SetTexture(texture or FALLBACK_ICON) + end + if element.Shield then + element.Shield:SetShown(notInterruptible) + end + if element.Spark then + element.Spark:Show() + end + if element.Text then + element.Text:SetText(text) + end + if element.Time then + element.Time:SetText() + end local safeZone = element.SafeZone - if(safeZone) then - local isHoriz = element:GetOrientation() == 'HORIZONTAL' + if safeZone then + local isHoriz = element:GetOrientation() == "HORIZONTAL" safeZone:ClearAllPoints() - safeZone:SetPoint(isHoriz and 'TOP' or 'LEFT') - safeZone:SetPoint(isHoriz and 'BOTTOM' or 'RIGHT') + safeZone:SetPoint(isHoriz and "TOP" or "LEFT") + safeZone:SetPoint(isHoriz and "BOTTOM" or "RIGHT") - if(element.channeling) then - safeZone:SetPoint(element:GetReverseFill() and (isHoriz and 'RIGHT' or 'TOP') or (isHoriz and 'LEFT' or 'BOTTOM')) + if element.channeling then + safeZone:SetPoint(element:GetReverseFill() and (isHoriz and "RIGHT" or "TOP") or (isHoriz and "LEFT" or "BOTTOM")) else - safeZone:SetPoint(element:GetReverseFill() and (isHoriz and 'LEFT' or 'BOTTOM') or (isHoriz and 'RIGHT' or 'TOP')) + safeZone:SetPoint(element:GetReverseFill() and (isHoriz and "LEFT" or "BOTTOM") or (isHoriz and "RIGHT" or "TOP")) end local ratio = (select(4, GetNetStats()) / 1000) / element.max - if(ratio > 1) then + if ratio > 1 then ratio = 1 end - safeZone[isHoriz and 'SetWidth' or 'SetHeight'](safeZone, element[isHoriz and 'GetWidth' or 'GetHeight'](element) * ratio) + safeZone[isHoriz and "SetWidth" or "SetHeight"](safeZone, element[isHoriz and "GetWidth" or "GetHeight"](element) * ratio) end - if(element.empowering) then + if element.empowering then --[[ Override: Castbar:UpdatePips(numStages) Handles updates for stage separators (pips) in an empowered cast. * self - the Castbar widget * numStages - the number of stages in the current cast (number) --]] - (element.UpdatePips or UpdatePips) (element, numStages) + (element.UpdatePips or UpdatePips)(element, numStages) end --[[ Callback: Castbar:PostCastStart(unit) @@ -304,7 +314,7 @@ local function CastStart(self, event, unit) * self - the Castbar widget * unit - the unit for which the update has been triggered (string) --]] - if(element.PostCastStart) then + if element.PostCastStart then element:PostCastStart(unit) end @@ -313,24 +323,26 @@ end local function CastUpdate(self, event, unit, castID, spellID) local element = self.Castbar - if(not (element.ShouldShow or ShouldShow) (element, unit)) then + if not (element.ShouldShow or ShouldShow)(element, unit) then return end - if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then + if not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID then return end local name, startTime, endTime, _ - if(event == 'UNIT_SPELLCAST_DELAYED') then + if event == "UNIT_SPELLCAST_DELAYED" then name, _, _, startTime, endTime = UnitCastingInfo(unit) else name, _, _, startTime, endTime = UnitChannelInfo(unit) end - if(not name) then return end + if not name then + return + end - if(element.empowering) then + if element.empowering then endTime = endTime + GetUnitEmpowerHoldAtMaxTime(unit) end @@ -338,7 +350,7 @@ local function CastUpdate(self, event, unit, castID, spellID) startTime = startTime / 1000 local delta - if(element.channeling) then + if element.channeling then delta = element.startTime - startTime element.duration = endTime - GetTime() @@ -348,7 +360,7 @@ local function CastUpdate(self, event, unit, castID, spellID) element.duration = GetTime() - startTime end - if(delta < 0) then + if delta < 0 then delta = 0 end @@ -365,18 +377,18 @@ local function CastUpdate(self, event, unit, castID, spellID) * self - the Castbar widget * unit - the unit that the update has been triggered (string) --]] - if(element.PostCastUpdate) then + if element.PostCastUpdate then return element:PostCastUpdate(unit) end end local function CastStop(self, event, unit, castID, spellID) local element = self.Castbar - if(not (element.ShouldShow or ShouldShow) (element, unit)) then + if not (element.ShouldShow or ShouldShow)(element, unit) then return end - if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then + if not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID then return end @@ -389,26 +401,28 @@ local function CastStop(self, event, unit, castID, spellID) * unit - the unit for which the update has been triggered (string) * spellID - the ID of the spell (number) --]] - if(element.PostCastStop) then + if element.PostCastStop then return element:PostCastStop(unit, spellID) end end local function CastFail(self, event, unit, castID, spellID) local element = self.Castbar - if(not (element.ShouldShow or ShouldShow) (element, unit)) then + if not (element.ShouldShow or ShouldShow)(element, unit) then return end - if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then + if not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID then return end - if(element.Text) then - element.Text:SetText(event == 'UNIT_SPELLCAST_FAILED' and FAILED or INTERRUPTED) + if element.Text then + element.Text:SetText(event == "UNIT_SPELLCAST_FAILED" and FAILED or INTERRUPTED) end - if(element.Spark) then element.Spark:Hide() end + if element.Spark then + element.Spark:Hide() + end element.holdTime = element.timeToHold or 0 @@ -422,22 +436,26 @@ local function CastFail(self, event, unit, castID, spellID) * unit - the unit for which the update has been triggered (string) * spellID - the ID of the spell (number) --]] - if(element.PostCastFail) then + if element.PostCastFail then return element:PostCastFail(unit, spellID) end end local function CastInterruptible(self, event, unit) local element = self.Castbar - if(not (element.ShouldShow or ShouldShow) (element, unit)) then + if not (element.ShouldShow or ShouldShow)(element, unit) then return end - if(not element:IsShown()) then return end + if not element:IsShown() then + return + end - element.notInterruptible = event == 'UNIT_SPELLCAST_NOT_INTERRUPTIBLE' + element.notInterruptible = event == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE" - if(element.Shield) then element.Shield:SetShown(element.notInterruptible) end + if element.Shield then + element.Shield:SetShown(element.notInterruptible) + end --[[ Callback: Castbar:PostCastInterruptible(unit) Called after the element has been updated when a spell cast has become interruptible or uninterruptible. @@ -445,23 +463,23 @@ local function CastInterruptible(self, event, unit) * self - the Castbar widget * unit - the unit for which the update has been triggered (string) --]] - if(element.PostCastInterruptible) then + if element.PostCastInterruptible then return element:PostCastInterruptible(unit) end end local function onUpdate(self, elapsed) - if(self.casting or self.channeling or self.empowering) then + if self.casting or self.channeling or self.empowering then local isCasting = self.casting or self.empowering - if(isCasting) then + if isCasting then self.duration = self.duration + elapsed - if(self.duration >= self.max) then + if self.duration >= self.max then local spellID = self.spellID resetAttributes(self) self:Hide() - if(self.PostCastStop) then + if self.PostCastStop then self:PostCastStop(self.__owner.unit, spellID) end @@ -469,13 +487,13 @@ local function onUpdate(self, elapsed) end else self.duration = self.duration - elapsed - if(self.duration <= 0) then + if self.duration <= 0 then local spellID = self.spellID resetAttributes(self) self:Hide() - if(self.PostCastStop) then + if self.PostCastStop then self:PostCastStop(self.__owner.unit, spellID) end @@ -483,18 +501,18 @@ local function onUpdate(self, elapsed) end end - if(self.Time) then - if(self.delay ~= 0) then - if(self.CustomDelayText) then + if self.Time then + if self.delay ~= 0 then + if self.CustomDelayText then self:CustomDelayText(self.duration) else - self.Time:SetFormattedText('%.1f|cffff0000%s%.2f|r', self.duration, isCasting and '+' or '-', self.delay) + self.Time:SetFormattedText("%.1f|cffff0000%s%.2f|r", self.duration, isCasting and "+" or "-", self.delay) end else - if(self.CustomTimeText) then + if self.CustomTimeText then self:CustomTimeText(self.duration) else - self.Time:SetFormattedText('%.1f', self.duration) + self.Time:SetFormattedText("%.1f", self.duration) end end end @@ -505,14 +523,14 @@ local function onUpdate(self, elapsed) * self - the Castbar widget * stage - the stage of the empowered cast (number) --]] - if(self.empowering and self.PostUpdateStage) then + if self.empowering and self.PostUpdateStage then local old = self.curStage for i = old + 1, self.numStages do - if(self.stagePoints[i]) then - if(self.duration > self.stagePoints[i]) then + if self.stagePoints[i] then + if self.duration > self.stagePoints[i] then self.curStage = i - if(self.curStage ~= old) then + if self.curStage ~= old then self:PostUpdateStage(i) end else @@ -523,7 +541,7 @@ local function onUpdate(self, elapsed) end self:SetValue(self.duration) - elseif(self.holdTime > 0) then + elseif self.holdTime > 0 then self.holdTime = self.holdTime - elapsed else resetAttributes(self) @@ -536,57 +554,57 @@ local function Update(...) end local function ForceUpdate(element) - return Update(element.__owner, 'ForceUpdate', element.__owner.unit) + return Update(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self, unit) local element = self.Castbar - if(element and unit and not unit:match('%wtarget$')) then + if element and unit and not unit:match("%wtarget$") then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('UNIT_SPELLCAST_START', CastStart) - self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_START', CastStart) - self:RegisterEvent('UNIT_SPELLCAST_EMPOWER_START', CastStart) - self:RegisterEvent('UNIT_SPELLCAST_STOP', CastStop) - self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', CastStop) - self:RegisterEvent('UNIT_SPELLCAST_EMPOWER_STOP', CastStop) - self:RegisterEvent('UNIT_SPELLCAST_DELAYED', CastUpdate) - self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', CastUpdate) - self:RegisterEvent('UNIT_SPELLCAST_EMPOWER_UPDATE', CastUpdate) - self:RegisterEvent('UNIT_SPELLCAST_FAILED', CastFail) - self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED', CastFail) - self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTIBLE', CastInterruptible) - self:RegisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTIBLE', CastInterruptible) + self:RegisterEvent("UNIT_SPELLCAST_START", CastStart) + self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", CastStart) + self:RegisterEvent("UNIT_SPELLCAST_EMPOWER_START", CastStart) + self:RegisterEvent("UNIT_SPELLCAST_STOP", CastStop) + self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", CastStop) + self:RegisterEvent("UNIT_SPELLCAST_EMPOWER_STOP", CastStop) + self:RegisterEvent("UNIT_SPELLCAST_DELAYED", CastUpdate) + self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", CastUpdate) + self:RegisterEvent("UNIT_SPELLCAST_EMPOWER_UPDATE", CastUpdate) + self:RegisterEvent("UNIT_SPELLCAST_FAILED", CastFail) + self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED", CastFail) + self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE", CastInterruptible) + self:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE", CastInterruptible) element.holdTime = 0 element.stagePoints = {} element.Pips = element.Pips or {} - element:SetScript('OnUpdate', element.OnUpdate or onUpdate) + element:SetScript("OnUpdate", element.OnUpdate or onUpdate) - if(self.unit == 'player' and not (self.hasChildren or self.isChild or self.isNamePlate)) then + if self.unit == "player" and not (self.hasChildren or self.isChild or self.isNamePlate) then PlayerCastingBarFrame:SetUnit(nil) PetCastingBarFrame:SetUnit(nil) - PetCastingBarFrame:UnregisterEvent('UNIT_PET') + PetCastingBarFrame:UnregisterEvent("UNIT_PET") end - if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then + if element:IsObjectType("StatusBar") and not element:GetStatusBarTexture() then element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end local spark = element.Spark - if(spark and spark:IsObjectType('Texture') and not spark:GetTexture()) then + if spark and spark:IsObjectType("Texture") and not spark:GetTexture() then spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]]) end local shield = element.Shield - if(shield and shield:IsObjectType('Texture') and not shield:GetTexture()) then + if shield and shield:IsObjectType("Texture") and not shield:GetTexture() then shield:SetTexture([[Interface\CastingBar\UI-CastingBar-Small-Shield]]) end local safeZone = element.SafeZone - if(safeZone and safeZone:IsObjectType('Texture') and not safeZone:GetTexture()) then + if safeZone and safeZone:IsObjectType("Texture") and not safeZone:GetTexture() then safeZone:SetColorTexture(1, 0, 0) end @@ -598,30 +616,30 @@ end local function Disable(self) local element = self.Castbar - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_SPELLCAST_START', CastStart) - self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_START', CastStart) - self:UnregisterEvent('UNIT_SPELLCAST_EMPOWER_START', CastStart) - self:UnregisterEvent('UNIT_SPELLCAST_STOP', CastStop) - self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', CastStop) - self:UnregisterEvent('UNIT_SPELLCAST_EMPOWER_STOP', CastStop) - self:UnregisterEvent('UNIT_SPELLCAST_DELAYED', CastUpdate) - self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', CastUpdate) - self:UnregisterEvent('UNIT_SPELLCAST_EMPOWER_UPDATE', CastUpdate) - self:UnregisterEvent('UNIT_SPELLCAST_FAILED', CastFail) - self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTED', CastFail) - self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTIBLE', CastInterruptible) - self:UnregisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTIBLE', CastInterruptible) - - element:SetScript('OnUpdate', nil) - - if(self.unit == 'player' and not (self.hasChildren or self.isChild or self.isNamePlate)) then + self:UnregisterEvent("UNIT_SPELLCAST_START", CastStart) + self:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_START", CastStart) + self:UnregisterEvent("UNIT_SPELLCAST_EMPOWER_START", CastStart) + self:UnregisterEvent("UNIT_SPELLCAST_STOP", CastStop) + self:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", CastStop) + self:UnregisterEvent("UNIT_SPELLCAST_EMPOWER_STOP", CastStop) + self:UnregisterEvent("UNIT_SPELLCAST_DELAYED", CastUpdate) + self:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", CastUpdate) + self:UnregisterEvent("UNIT_SPELLCAST_EMPOWER_UPDATE", CastUpdate) + self:UnregisterEvent("UNIT_SPELLCAST_FAILED", CastFail) + self:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED", CastFail) + self:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE", CastInterruptible) + self:UnregisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE", CastInterruptible) + + element:SetScript("OnUpdate", nil) + + if self.unit == "player" and not (self.hasChildren or self.isChild or self.isNamePlate) then PlayerCastingBarFrame:OnLoad() PetCastingBarFrame:PetCastingBar_OnLoad() end end end -oUF:AddElement('Castbar', Update, Enable, Disable) \ No newline at end of file +oUF:AddElement("Castbar", Update, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/classpower.lua b/KkthnxUI/Libraries/oUF/elements/classpower.lua index 769ace0af..0d2d26d38 100644 --- a/KkthnxUI/Libraries/oUF/elements/classpower.lua +++ b/KkthnxUI/Libraries/oUF/elements/classpower.lua @@ -48,7 +48,7 @@ Supported class powers: local _, ns = ... local oUF = ns.oUF -local _, PlayerClass = UnitClass('player') +local _, PlayerClass = UnitClass("player") -- sourced from Blizzard_FrameXMLBase/Constants.lua local SPEC_MAGE_ARCANE = _G.SPEC_MAGE_ARCANE or 1 @@ -76,7 +76,7 @@ local function UpdateColor(element, powerType) bar:SetStatusBarColor(r, g, b) local bg = bar.bg - if(bg) then + if bg then local mu = bg.multiplier or 1 bg:SetVertexColor(r * mu, g * mu, b * mu) end @@ -90,14 +90,13 @@ local function UpdateColor(element, powerType) * g - the green component of the used color (number)[0-1] * b - the blue component of the used color (number)[0-1] --]] - if(element.PostUpdateColor) then + if element.PostUpdateColor then element:PostUpdateColor(r, g, b) end end local function Update(self, event, unit, powerType) - if(not (unit and (UnitIsUnit(unit, 'player') and (not powerType or powerType == ClassPowerType) - or unit == 'vehicle' and powerType == 'COMBO_POINTS'))) then + if not (unit and (UnitIsUnit(unit, "player") and (not powerType or powerType == ClassPowerType) or unit == "vehicle" and powerType == "COMBO_POINTS")) then return end @@ -108,13 +107,13 @@ local function Update(self, event, unit, powerType) * self - the ClassPower element ]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local cur, max, mod, oldMax, chargedPoints - if(event ~= 'ClassPowerDisable') then - local powerID = unit == 'vehicle' and SPELL_POWER_COMBO_POINTS or ClassPowerID + if event ~= "ClassPowerDisable" then + local powerID = unit == "vehicle" and SPELL_POWER_COMBO_POINTS or ClassPowerID cur = UnitPower(unit, powerID, true) max = UnitPowerMax(unit, powerID) mod = UnitPowerDisplayMod(powerID) @@ -127,13 +126,13 @@ local function Update(self, event, unit, powerType) cur = mod == 0 and 0 or cur / mod -- BUG: Destruction is supposed to show partial soulshards, but Affliction and Demonology should only show full ones - if(ClassPowerType == 'SOUL_SHARDS' and GetSpecialization() ~= SPEC_WARLOCK_DESTRUCTION) then + if ClassPowerType == "SOUL_SHARDS" and GetSpecialization() ~= SPEC_WARLOCK_DESTRUCTION then cur = cur - cur % 1 end local numActive = cur + 0.9 for i = 1, max do - if(i > numActive) then + if i > numActive then element[i]:Hide() element[i]:SetValue(0) else @@ -143,8 +142,8 @@ local function Update(self, event, unit, powerType) end oldMax = element.__max - if(max ~= oldMax) then - if(max < oldMax) then + if max ~= oldMax then + if max < oldMax then for i = max + 1, oldMax do element[i]:Hide() element[i]:SetValue(0) @@ -164,7 +163,7 @@ local function Update(self, event, unit, powerType) * powerType - the active power type (string) * ... - the indices of currently charged power points, if any --]] - if(element.PostUpdate) then + if element.PostUpdate then --return element:PostUpdate(cur, max, oldMax ~= max, powerType, unpack(chargedPoints or {})) return element:PostUpdate(cur, max, oldMax ~= max, powerType, chargedPoints) -- NDui end @@ -179,45 +178,45 @@ local function Path(self, ...) * unit - the unit accompanying the event (string) * ... - the arguments accompanying the event --]] - return (self.ClassPower.Override or Update) (self, ...) + return (self.ClassPower.Override or Update)(self, ...) end local function Visibility(self, event, unit) local element = self.ClassPower local shouldEnable - if(UnitHasVehicleUI('player')) then + if UnitHasVehicleUI("player") then shouldEnable = PlayerVehicleHasComboPoints() - unit = 'vehicle' - elseif(ClassPowerID) then - if(not RequireSpec or RequireSpec == GetSpecialization()) then + unit = "vehicle" + elseif ClassPowerID then + if not RequireSpec or RequireSpec == GetSpecialization() then -- use 'player' instead of unit because 'SPELLS_CHANGED' is a unitless event - if(not RequirePower or RequirePower == UnitPowerType('player')) then - if(not RequireSpell or IsPlayerSpell(RequireSpell)) then - self:UnregisterEvent('SPELLS_CHANGED', Visibility) + if not RequirePower or RequirePower == UnitPowerType("player") then + if not RequireSpell or IsPlayerSpell(RequireSpell) then + self:UnregisterEvent("SPELLS_CHANGED", Visibility) shouldEnable = true - unit = 'player' + unit = "player" else - self:RegisterEvent('SPELLS_CHANGED', Visibility, true) + self:RegisterEvent("SPELLS_CHANGED", Visibility, true) end end end end local isEnabled = element.__isEnabled - local powerType = unit == 'vehicle' and 'COMBO_POINTS' or ClassPowerType + local powerType = unit == "vehicle" and "COMBO_POINTS" or ClassPowerType - if(shouldEnable) then + if shouldEnable then --[[ Override: ClassPower:UpdateColor(powerType) Used to completely override the internal function for updating the widgets' colors. * self - the ClassPower element * powerType - the active power type (string) --]] - (element.UpdateColor or UpdateColor) (element, powerType) + (element.UpdateColor or UpdateColor)(element, powerType) end - if(shouldEnable and not isEnabled) then + if shouldEnable and not isEnabled then ClassPowerEnable(self) --[[ Callback: ClassPower:PostVisibility(isVisible) @@ -226,16 +225,16 @@ local function Visibility(self, event, unit) * self - the ClassPower element * isVisible - the current visibility state of the element (boolean) --]] - if(element.PostVisibility) then + if element.PostVisibility then element:PostVisibility(true) end - elseif(not shouldEnable and (isEnabled or isEnabled == nil)) then + elseif not shouldEnable and (isEnabled or isEnabled == nil) then ClassPowerDisable(self) - if(element.PostVisibility) then + if element.PostVisibility then element:PostVisibility(false) end - elseif(shouldEnable and isEnabled) then + elseif shouldEnable and isEnabled then Path(self, event, unit, powerType) end end @@ -248,34 +247,34 @@ local function VisibilityPath(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event (string) --]] - return (self.ClassPower.OverrideVisibility or Visibility) (self, ...) + return (self.ClassPower.OverrideVisibility or Visibility)(self, ...) end local function ForceUpdate(element) - return VisibilityPath(element.__owner, 'ForceUpdate', element.__owner.unit) + return VisibilityPath(element.__owner, "ForceUpdate", element.__owner.unit) end do function ClassPowerEnable(self) - self:RegisterEvent('UNIT_MAXPOWER', Path) - self:RegisterEvent('UNIT_POWER_UPDATE', Path) + self:RegisterEvent("UNIT_MAXPOWER", Path) + self:RegisterEvent("UNIT_POWER_UPDATE", Path) -- according to Blizz any class may receive this event due to specific spell auras - self:RegisterEvent('UNIT_POWER_POINT_CHARGE', Path) + self:RegisterEvent("UNIT_POWER_POINT_CHARGE", Path) self.ClassPower.__isEnabled = true - if(UnitHasVehicleUI('player')) then - Path(self, 'ClassPowerEnable', 'vehicle', 'COMBO_POINTS') + if UnitHasVehicleUI("player") then + Path(self, "ClassPowerEnable", "vehicle", "COMBO_POINTS") else - Path(self, 'ClassPowerEnable', 'player', ClassPowerType) + Path(self, "ClassPowerEnable", "player", ClassPowerType) end end function ClassPowerDisable(self) - self:UnregisterEvent('UNIT_POWER_UPDATE', Path) - self:UnregisterEvent('UNIT_MAXPOWER', Path) - self:UnregisterEvent('UNIT_POWER_POINT_CHARGE', Path) + self:UnregisterEvent("UNIT_POWER_UPDATE", Path) + self:UnregisterEvent("UNIT_MAXPOWER", Path) + self:UnregisterEvent("UNIT_POWER_POINT_CHARGE", Path) local element = self.ClassPower for i = 1, #element do @@ -283,50 +282,50 @@ do end element.__isEnabled = false - Path(self, 'ClassPowerDisable', 'player', ClassPowerType) + Path(self, "ClassPowerDisable", "player", ClassPowerType) end - if(PlayerClass == 'MONK') then + if PlayerClass == "MONK" then ClassPowerID = SPELL_POWER_CHI - ClassPowerType = 'CHI' + ClassPowerType = "CHI" RequireSpec = SPEC_MONK_WINDWALKER - elseif(PlayerClass == 'PALADIN') then + elseif PlayerClass == "PALADIN" then ClassPowerID = SPELL_POWER_HOLY_POWER - ClassPowerType = 'HOLY_POWER' - elseif(PlayerClass == 'WARLOCK') then + ClassPowerType = "HOLY_POWER" + elseif PlayerClass == "WARLOCK" then ClassPowerID = SPELL_POWER_SOUL_SHARDS - ClassPowerType = 'SOUL_SHARDS' - elseif(PlayerClass == 'ROGUE' or PlayerClass == 'DRUID') then + ClassPowerType = "SOUL_SHARDS" + elseif PlayerClass == "ROGUE" or PlayerClass == "DRUID" then ClassPowerID = SPELL_POWER_COMBO_POINTS - ClassPowerType = 'COMBO_POINTS' + ClassPowerType = "COMBO_POINTS" - if(PlayerClass == 'DRUID') then + if PlayerClass == "DRUID" then RequirePower = SPELL_POWER_ENERGY RequireSpell = 5221 -- Shred end - elseif(PlayerClass == 'MAGE') then + elseif PlayerClass == "MAGE" then ClassPowerID = SPELL_POWER_ARCANE_CHARGES - ClassPowerType = 'ARCANE_CHARGES' + ClassPowerType = "ARCANE_CHARGES" RequireSpec = SPEC_MAGE_ARCANE - elseif(PlayerClass == 'EVOKER') then + elseif PlayerClass == "EVOKER" then ClassPowerID = SPELL_POWER_ESSENCE - ClassPowerType = 'ESSENCE' + ClassPowerType = "ESSENCE" end end local function Enable(self, unit) local element = self.ClassPower - if(element and UnitIsUnit(unit, 'player')) then + if element and UnitIsUnit(unit, "player") then element.__owner = self element.__max = #element element.ForceUpdate = ForceUpdate - if(RequireSpec or RequireSpell) then - self:RegisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath, true) + if RequireSpec or RequireSpell then + self:RegisterEvent("PLAYER_TALENT_UPDATE", VisibilityPath, true) end - if(RequirePower) then - self:RegisterEvent('UNIT_DISPLAYPOWER', VisibilityPath) + if RequirePower then + self:RegisterEvent("UNIT_DISPLAYPOWER", VisibilityPath) end element.ClassPowerEnable = ClassPowerEnable @@ -334,8 +333,8 @@ local function Enable(self, unit) for i = 1, #element do local bar = element[i] - if(bar:IsObjectType('StatusBar')) then - if(not bar:GetStatusBarTexture()) then + if bar:IsObjectType("StatusBar") then + if not bar:GetStatusBarTexture() then bar:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end @@ -348,13 +347,13 @@ local function Enable(self, unit) end local function Disable(self) - if(self.ClassPower) then + if self.ClassPower then ClassPowerDisable(self) - self:UnregisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath) - self:UnregisterEvent('UNIT_DISPLAYPOWER', VisibilityPath) - self:UnregisterEvent('SPELLS_CHANGED', Visibility) + self:UnregisterEvent("PLAYER_TALENT_UPDATE", VisibilityPath) + self:UnregisterEvent("UNIT_DISPLAYPOWER", VisibilityPath) + self:UnregisterEvent("SPELLS_CHANGED", Visibility) end end -oUF:AddElement('ClassPower', VisibilityPath, Enable, Disable) \ No newline at end of file +oUF:AddElement("ClassPower", VisibilityPath, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/combatindicator.lua b/KkthnxUI/Libraries/oUF/elements/combatindicator.lua index 9e0d92889..2fb0d1d8f 100644 --- a/KkthnxUI/Libraries/oUF/elements/combatindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/combatindicator.lua @@ -33,12 +33,12 @@ local function Update(self, event) * self - the CombatIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end - local inCombat = UnitAffectingCombat('player') - if(inCombat) then + local inCombat = UnitAffectingCombat("player") + if inCombat then element:Show() else element:Hide() @@ -50,7 +50,7 @@ local function Update(self, event) * self - the CombatIndicator element * inCombat - indicates if the player is affecting combat (boolean) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(inCombat) end end @@ -62,25 +62,25 @@ local function Path(self, ...) * self - the parent object * event - the event triggering the update (string) --]] - return (self.CombatIndicator.Override or Update) (self, ...) + return (self.CombatIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate') + return Path(element.__owner, "ForceUpdate") end local function Enable(self, unit) local element = self.CombatIndicator - if(element and UnitIsUnit(unit, 'player')) then + if element and UnitIsUnit(unit, "player") then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('PLAYER_REGEN_DISABLED', Path, true) - self:RegisterEvent('PLAYER_REGEN_ENABLED', Path, true) + self:RegisterEvent("PLAYER_REGEN_DISABLED", Path, true) + self:RegisterEvent("PLAYER_REGEN_ENABLED", Path, true) - if(element:IsObjectType('Texture') and not element:GetTexture()) then + if element:IsObjectType("Texture") and not element:GetTexture() then element:SetTexture([[Interface\CharacterFrame\UI-StateIcon]]) - element:SetTexCoord(.5, 1, 0, .49) + element:SetTexCoord(0.5, 1, 0, 0.49) end return true @@ -89,12 +89,12 @@ end local function Disable(self) local element = self.CombatIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('PLAYER_REGEN_DISABLED', Path) - self:UnregisterEvent('PLAYER_REGEN_ENABLED', Path) + self:UnregisterEvent("PLAYER_REGEN_DISABLED", Path) + self:UnregisterEvent("PLAYER_REGEN_ENABLED", Path) end end -oUF:AddElement('CombatIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("CombatIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/grouproleindicator.lua b/KkthnxUI/Libraries/oUF/elements/grouproleindicator.lua index fe46eefdf..3143229e4 100644 --- a/KkthnxUI/Libraries/oUF/elements/grouproleindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/grouproleindicator.lua @@ -27,11 +27,11 @@ local oUF = ns.oUF -- originally sourced from Blizzard_Deprecated/Deprecated_10_1_5.lua local function GetTexCoordsForRoleSmallCircle(role) - if(role == 'TANK') then + if role == "TANK" then return 0, 19 / 64, 22 / 64, 41 / 64 - elseif(role == 'HEALER') then + elseif role == "HEALER" then return 20 / 64, 39 / 64, 1 / 64, 20 / 64 - elseif(role == 'DAMAGER') then + elseif role == "DAMAGER" then return 20 / 64, 39 / 64, 22 / 64, 41 / 64 end end @@ -44,12 +44,12 @@ local function Update(self, event) * self - the GroupRoleIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local role = UnitGroupRolesAssigned(self.unit) - if(role == 'TANK' or role == 'HEALER' or role == 'DAMAGER') then + if role == "TANK" or role == "HEALER" or role == "DAMAGER" then element:SetTexCoord(GetTexCoordsForRoleSmallCircle(role)) element:Show() else @@ -62,7 +62,7 @@ local function Update(self, event) * self - the GroupRoleIndicator element * role - the role as returned by [UnitGroupRolesAssigned](https://warcraft.wiki.gg/wiki/API_UnitGroupRolesAssigned) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(role) end end @@ -75,26 +75,26 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.GroupRoleIndicator.Override or Update) (self, ...) + return (self.GroupRoleIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate') + return Path(element.__owner, "ForceUpdate") end local function Enable(self) local element = self.GroupRoleIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - if(self.unit == 'player') then - self:RegisterEvent('PLAYER_ROLES_ASSIGNED', Path, true) + if self.unit == "player" then + self:RegisterEvent("PLAYER_ROLES_ASSIGNED", Path, true) else - self:RegisterEvent('GROUP_ROSTER_UPDATE', Path, true) + self:RegisterEvent("GROUP_ROSTER_UPDATE", Path, true) end - if(element:IsObjectType('Texture') and not element:GetTexture()) then + if element:IsObjectType("Texture") and not element:GetTexture() then element:SetTexture([[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]]) end @@ -104,12 +104,12 @@ end local function Disable(self) local element = self.GroupRoleIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('PLAYER_ROLES_ASSIGNED', Path) - self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path) + self:UnregisterEvent("PLAYER_ROLES_ASSIGNED", Path) + self:UnregisterEvent("GROUP_ROSTER_UPDATE", Path) end end -oUF:AddElement('GroupRoleIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("GroupRoleIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/health.lua b/KkthnxUI/Libraries/oUF/elements/health.lua index 524ca1a97..ce1dd3861 100644 --- a/KkthnxUI/Libraries/oUF/elements/health.lua +++ b/KkthnxUI/Libraries/oUF/elements/health.lua @@ -117,40 +117,40 @@ local Private = oUF.Private local unitSelectionType = Private.unitSelectionType local function UpdateColor(self, event, unit) - if(not unit or self.unit ~= unit) then return end + if not unit or self.unit ~= unit then + return + end local element = self.Health local r, g, b, color - if(element.colorDisconnected and not UnitIsConnected(unit)) then + if element.colorDisconnected and not UnitIsConnected(unit) then color = self.colors.disconnected - elseif(element.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit)) then + elseif element.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit) then color = self.colors.tapped - elseif(element.colorThreat and not UnitPlayerControlled(unit) and UnitThreatSituation('player', unit)) then - color = self.colors.threat[UnitThreatSituation('player', unit)] - elseif(element.colorClass and (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) - or (element.colorClassNPC and not (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) - or (element.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then + elseif element.colorThreat and not UnitPlayerControlled(unit) and UnitThreatSituation("player", unit) then + color = self.colors.threat[UnitThreatSituation("player", unit)] + elseif (element.colorClass and (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) or (element.colorClassNPC and not (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) or (element.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then local _, class = UnitClass(unit) color = self.colors.class[class] - elseif(element.colorSelection and unitSelectionType(unit, element.considerSelectionInCombatHostile)) then + elseif element.colorSelection and unitSelectionType(unit, element.considerSelectionInCombatHostile) then color = self.colors.selection[unitSelectionType(unit, element.considerSelectionInCombatHostile)] - elseif(element.colorReaction and UnitReaction(unit, 'player')) then - color = self.colors.reaction[UnitReaction(unit, 'player')] - elseif(element.colorSmooth) then + elseif element.colorReaction and UnitReaction(unit, "player") then + color = self.colors.reaction[UnitReaction(unit, "player")] + elseif element.colorSmooth then r, g, b = self:ColorGradient(element.cur or 1, element.max or 1, unpack(element.smoothGradient or self.colors.smooth)) - elseif(element.colorHealth) then + elseif element.colorHealth then color = self.colors.health end - if(color) then + if color then r, g, b = color[1], color[2], color[3] end - if(b) then + if b then element:SetStatusBarColor(r, g, b) local bg = element.bg - if(bg) then + if bg then local mu = bg.multiplier or 1 bg:SetVertexColor(r * mu, g * mu, b * mu) end @@ -165,7 +165,7 @@ local function UpdateColor(self, event, unit) * g - the green component of the used color (number)[0-1] * b - the blue component of the used color (number)[0-1] --]] - if(element.PostUpdateColor) then + if element.PostUpdateColor then element:PostUpdateColor(unit, r, g, b) end end @@ -178,11 +178,13 @@ local function ColorPath(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event (string) --]] - (self.Health.UpdateColor or UpdateColor) (self, ...) + (self.Health.UpdateColor or UpdateColor)(self, ...) end local function Update(self, event, unit) - if(not unit or self.unit ~= unit) then return end + if not unit or self.unit ~= unit then + return + end local element = self.Health --[[ Callback: Health:PreUpdate(unit) @@ -191,14 +193,14 @@ local function Update(self, event, unit) * self - the Health element * unit - the unit for which the update has been triggered (string) --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate(unit) end local cur, max = UnitHealth(unit), UnitHealthMax(unit) element:SetMinMaxValues(0, max) - if(UnitIsConnected(unit)) then + if UnitIsConnected(unit) then element:SetValue(cur) else element:SetValue(max) @@ -208,7 +210,7 @@ local function Update(self, event, unit) element.max = max local lossPerc = 0 - if(element.TempLoss) then + if element.TempLoss then lossPerc = Clamp(GetUnitTotalModifiedMaxHealthPercent(unit), 0, 1) element.TempLoss:SetValue(lossPerc) @@ -223,7 +225,7 @@ local function Update(self, event, unit) * max - the unit's maximum possible health value (number) * lossPerc - the percent by which the unit's max health has been temporarily reduced (number) --]] - if(element.PostUpdate) then + if element.PostUpdate then element:PostUpdate(unit, cur, max, lossPerc) end end @@ -236,13 +238,13 @@ local function Path(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event (string) --]] - (self.Health.Override or Update) (self, ...); + (self.Health.Override or Update)(self, ...) ColorPath(self, ...) end local function ForceUpdate(element) - Path(element.__owner, 'ForceUpdate', element.__owner.unit) + Path(element.__owner, "ForceUpdate", element.__owner.unit) end --[[ Health:SetColorDisconnected(state, isForced) @@ -253,16 +255,16 @@ Used to toggle coloring if the unit is offline. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetColorDisconnected(element, state, isForced) - if(element.colorDisconnected ~= state or isForced) then + if element.colorDisconnected ~= state or isForced then element.colorDisconnected = state - if(state) then - element.__owner:RegisterEvent('UNIT_CONNECTION', ColorPath) - element.__owner:RegisterEvent('PARTY_MEMBER_ENABLE', ColorPath) - element.__owner:RegisterEvent('PARTY_MEMBER_DISABLE', ColorPath) + if state then + element.__owner:RegisterEvent("UNIT_CONNECTION", ColorPath) + element.__owner:RegisterEvent("PARTY_MEMBER_ENABLE", ColorPath) + element.__owner:RegisterEvent("PARTY_MEMBER_DISABLE", ColorPath) else - element.__owner:UnregisterEvent('UNIT_CONNECTION', ColorPath) - element.__owner:UnregisterEvent('PARTY_MEMBER_ENABLE', ColorPath) - element.__owner:UnregisterEvent('PARTY_MEMBER_DISABLE', ColorPath) + element.__owner:UnregisterEvent("UNIT_CONNECTION", ColorPath) + element.__owner:UnregisterEvent("PARTY_MEMBER_ENABLE", ColorPath) + element.__owner:UnregisterEvent("PARTY_MEMBER_DISABLE", ColorPath) end end end @@ -275,12 +277,12 @@ Used to toggle coloring by the unit's selection. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetColorSelection(element, state, isForced) - if(element.colorSelection ~= state or isForced) then + if element.colorSelection ~= state or isForced then element.colorSelection = state - if(state) then - element.__owner:RegisterEvent('UNIT_FLAGS', ColorPath) + if state then + element.__owner:RegisterEvent("UNIT_FLAGS", ColorPath) else - element.__owner:UnregisterEvent('UNIT_FLAGS', ColorPath) + element.__owner:UnregisterEvent("UNIT_FLAGS", ColorPath) end end end @@ -293,12 +295,12 @@ Used to toggle coloring if the unit isn't tapped by the player. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetColorTapping(element, state, isForced) - if(element.colorTapping ~= state or isForced) then + if element.colorTapping ~= state or isForced then element.colorTapping = state - if(state) then - element.__owner:RegisterEvent('UNIT_FACTION', ColorPath) + if state then + element.__owner:RegisterEvent("UNIT_FACTION", ColorPath) else - element.__owner:UnregisterEvent('UNIT_FACTION', ColorPath) + element.__owner:UnregisterEvent("UNIT_FACTION", ColorPath) end end end @@ -311,19 +313,19 @@ Used to toggle coloring by the unit's threat status. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetColorThreat(element, state, isForced) - if(element.colorThreat ~= state or isForced) then + if element.colorThreat ~= state or isForced then element.colorThreat = state - if(state) then - element.__owner:RegisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) + if state then + element.__owner:RegisterEvent("UNIT_THREAT_LIST_UPDATE", ColorPath) else - element.__owner:UnregisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) + element.__owner:UnregisterEvent("UNIT_THREAT_LIST_UPDATE", ColorPath) end end end local function Enable(self) local element = self.Health - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate element.SetColorDisconnected = SetColorDisconnected @@ -331,40 +333,40 @@ local function Enable(self) element.SetColorTapping = SetColorTapping element.SetColorThreat = SetColorThreat - if(element.colorDisconnected) then - self:RegisterEvent('UNIT_CONNECTION', ColorPath) - self:RegisterEvent('PARTY_MEMBER_ENABLE', ColorPath) - self:RegisterEvent('PARTY_MEMBER_DISABLE', ColorPath) + if element.colorDisconnected then + self:RegisterEvent("UNIT_CONNECTION", ColorPath) + self:RegisterEvent("PARTY_MEMBER_ENABLE", ColorPath) + self:RegisterEvent("PARTY_MEMBER_DISABLE", ColorPath) end - if(element.colorSelection) then - self:RegisterEvent('UNIT_FLAGS', ColorPath) + if element.colorSelection then + self:RegisterEvent("UNIT_FLAGS", ColorPath) end - if(element.colorTapping) then - self:RegisterEvent('UNIT_FACTION', ColorPath) + if element.colorTapping then + self:RegisterEvent("UNIT_FACTION", ColorPath) end - if(element.colorThreat) then - self:RegisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) + if element.colorThreat then + self:RegisterEvent("UNIT_THREAT_LIST_UPDATE", ColorPath) end - self:RegisterEvent('UNIT_HEALTH', Path) - self:RegisterEvent('UNIT_MAXHEALTH', Path) - self:RegisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) + self:RegisterEvent("UNIT_HEALTH", Path) + self:RegisterEvent("UNIT_MAXHEALTH", Path) + self:RegisterEvent("UNIT_MAX_HEALTH_MODIFIERS_CHANGED", Path) - if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then + if element:IsObjectType("StatusBar") and not element:GetStatusBarTexture() then element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end element:Show() - if(element.TempLoss) then - if(element.TempLoss:IsObjectType('StatusBar')) then + if element.TempLoss then + if element.TempLoss:IsObjectType("StatusBar") then element.TempLoss:SetMinMaxValues(0, 1) element.TempLoss:SetValue(0) - if(not element.TempLoss:GetStatusBarTexture()) then + if not element.TempLoss:GetStatusBarTexture() then element.TempLoss:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end end @@ -378,23 +380,23 @@ end local function Disable(self) local element = self.Health - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_HEALTH', Path) - self:UnregisterEvent('UNIT_MAXHEALTH', Path) - self:UnregisterEvent('UNIT_CONNECTION', ColorPath) - self:UnregisterEvent('UNIT_FACTION', ColorPath) - self:UnregisterEvent('UNIT_FLAGS', ColorPath) - self:UnregisterEvent('PARTY_MEMBER_ENABLE', ColorPath) - self:UnregisterEvent('PARTY_MEMBER_DISABLE', ColorPath) - self:UnregisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) - self:UnregisterEvent('UNIT_MAX_HEALTH_MODIFIERS_CHANGED', Path) - - if(element.TempLoss) then + self:UnregisterEvent("UNIT_HEALTH", Path) + self:UnregisterEvent("UNIT_MAXHEALTH", Path) + self:UnregisterEvent("UNIT_CONNECTION", ColorPath) + self:UnregisterEvent("UNIT_FACTION", ColorPath) + self:UnregisterEvent("UNIT_FLAGS", ColorPath) + self:UnregisterEvent("PARTY_MEMBER_ENABLE", ColorPath) + self:UnregisterEvent("PARTY_MEMBER_DISABLE", ColorPath) + self:UnregisterEvent("UNIT_THREAT_LIST_UPDATE", ColorPath) + self:UnregisterEvent("UNIT_MAX_HEALTH_MODIFIERS_CHANGED", Path) + + if element.TempLoss then element.TempLoss:Hide() end end end -oUF:AddElement('Health', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("Health", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/leaderindicator.lua b/KkthnxUI/Libraries/oUF/elements/leaderindicator.lua index eb3e74e09..04664db50 100644 --- a/KkthnxUI/Libraries/oUF/elements/leaderindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/leaderindicator.lua @@ -34,7 +34,7 @@ local function Update(self, event) * self - the LeaderIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end @@ -49,8 +49,8 @@ local function Update(self, event) -- true for the instance leader. local isInLFGInstance = HasLFGRestrictions() local isLeader = UnitIsGroupLeader(unit) - if(isLeader) then - if(isInLFGInstance) then + if isLeader then + if isInLFGInstance then --element:SetTexture([[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]]) --element:SetTexCoord(0, 0.296875, 0.015625, 0.3125) element:SetTexCoord(0, 1, 0, 1) @@ -72,7 +72,7 @@ local function Update(self, event) * isLeader - indicates whether the unit is the leader of the group (boolean) * isInLFGInstance - indicates whether the current party is subject to LFG restrictions (boolean) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(isLeader, isInLFGInstance) end end @@ -85,21 +85,21 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.LeaderIndicator.Override or Update) (self, ...) + return (self.LeaderIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate') + return Path(element.__owner, "ForceUpdate") end local function Enable(self) local element = self.LeaderIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('PARTY_LEADER_CHANGED', Path, true) - self:RegisterEvent('GROUP_ROSTER_UPDATE', Path, true) + self:RegisterEvent("PARTY_LEADER_CHANGED", Path, true) + self:RegisterEvent("GROUP_ROSTER_UPDATE", Path, true) return true end @@ -107,12 +107,12 @@ end local function Disable(self) local element = self.LeaderIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('PARTY_LEADER_CHANGED', Path) - self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path) + self:UnregisterEvent("PARTY_LEADER_CHANGED", Path) + self:UnregisterEvent("GROUP_ROSTER_UPDATE", Path) end end -oUF:AddElement('LeaderIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("LeaderIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/phaseindicator.lua b/KkthnxUI/Libraries/oUF/elements/phaseindicator.lua index 1694ac1eb..1eff95d70 100644 --- a/KkthnxUI/Libraries/oUF/elements/phaseindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/phaseindicator.lua @@ -43,17 +43,19 @@ Used to populate the tooltip when the widget is hovered. --]] local function UpdateTooltip(element) local text = PartyUtil.GetPhasedReasonString(element.reason, element.__owner.unit) - if(text) then + if text then GameTooltip:SetText(text, nil, nil, nil, nil, true) GameTooltip:Show() end end local function onEnter(element) - if(not element:IsVisible()) then return end + if not element:IsVisible() then + return + end - if(element.reason) then - GameTooltip:SetOwner(element, 'ANCHOR_BOTTOMRIGHT') + if element.reason then + GameTooltip:SetOwner(element, "ANCHOR_BOTTOMRIGHT") element:UpdateTooltip() end end @@ -63,7 +65,9 @@ local function onLeave() end local function Update(self, event, unit) - if(self.unit ~= unit) then return end + if self.unit ~= unit then + return + end local element = self.PhaseIndicator @@ -72,14 +76,14 @@ local function Update(self, event, unit) * self - the PhaseIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end -- BUG: UnitPhaseReason returns wrong data for friendly NPCs in phased scenarios like WM or Chromie Time -- https://github.com/Stanzilla/WoWUIBugs/issues/49 local phaseReason = UnitIsPlayer(unit) and UnitIsConnected(unit) and UnitPhaseReason(unit) or nil - if(phaseReason) then + if phaseReason then element:Show() else element:Hide() @@ -94,7 +98,7 @@ local function Update(self, event, unit) * isInSamePhase - indicates whether the unit is in the same phase as the player (boolean) * phaseReason - the reason why the unit is in a different phase (number?) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(not phaseReason, phaseReason) end end @@ -107,33 +111,33 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.PhaseIndicator.Override or Update) (self, ...) + return (self.PhaseIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate', element.__owner.unit) + return Path(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self) local element = self.PhaseIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('UNIT_PHASE', Path) + self:RegisterEvent("UNIT_PHASE", Path) local icon = (element.Icon or element) - if(icon:IsObjectType('Texture') and not icon:GetTexture()) then + if icon:IsObjectType("Texture") and not icon:GetTexture() then icon:SetTexture([[Interface\TargetingFrame\UI-PhasingIcon]]) end - if(element.IsMouseEnabled and element:IsMouseEnabled()) then - if(not element:GetScript('OnEnter')) then - element:SetScript('OnEnter', onEnter) + if element.IsMouseEnabled and element:IsMouseEnabled() then + if not element:GetScript("OnEnter") then + element:SetScript("OnEnter", onEnter) end - if(not element:GetScript('OnLeave')) then - element:SetScript('OnLeave', onLeave) + if not element:GetScript("OnLeave") then + element:SetScript("OnLeave", onLeave) end element.UpdateTooltip = element.UpdateTooltip or UpdateTooltip @@ -145,11 +149,11 @@ end local function Disable(self) local element = self.PhaseIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_PHASE', Path) + self:UnregisterEvent("UNIT_PHASE", Path) end end -oUF:AddElement('PhaseIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("PhaseIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/portrait.lua b/KkthnxUI/Libraries/oUF/elements/portrait.lua index d14466a5b..d3b071efa 100644 --- a/KkthnxUI/Libraries/oUF/elements/portrait.lua +++ b/KkthnxUI/Libraries/oUF/elements/portrait.lua @@ -40,7 +40,9 @@ local _, ns = ... local oUF = ns.oUF local function Update(self, event, unit) - if(not unit or not UnitIsUnit(self.unit, unit)) then return end + if not unit or not UnitIsUnit(self.unit, unit) then + return + end local element = self.Portrait @@ -50,14 +52,16 @@ local function Update(self, event, unit) * self - the Portrait element * unit - the unit for which the update has been triggered (string) --]] - if(element.PreUpdate) then element:PreUpdate(unit) end + if element.PreUpdate then + element:PreUpdate(unit) + end local guid = UnitGUID(unit) local isAvailable = UnitIsConnected(unit) and UnitIsVisible(unit) - local hasStateChanged = event ~= 'OnUpdate' or element.guid ~= guid or element.state ~= isAvailable - if(hasStateChanged) then - if(element:IsObjectType('PlayerModel')) then - if(not isAvailable) then + local hasStateChanged = event ~= "OnUpdate" or element.guid ~= guid or element.state ~= isAvailable + if hasStateChanged then + if element:IsObjectType("PlayerModel") then + if not isAvailable then element:SetCamDistanceScale(0.25) element:SetPortraitZoom(0) element:SetPosition(0, 0, 0.25) @@ -72,8 +76,8 @@ local function Update(self, event, unit) end else local class = element.showClass and UnitClassBase(unit) - if(class) then - element:SetAtlas('classicon-' .. class) + if class then + element:SetAtlas("classicon-" .. class) else SetPortraitTexture(element, unit) end @@ -90,7 +94,7 @@ local function Update(self, event, unit) * unit - the unit for which the update has been triggered (string) * hasStateChanged - indicates whether the state has changed since the last update (boolean) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(unit, hasStateChanged) end end @@ -103,23 +107,23 @@ local function Path(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event (string) --]] - return (self.Portrait.Override or Update) (self, ...) + return (self.Portrait.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate', element.__owner.unit) + return Path(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self, unit) local element = self.Portrait - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('UNIT_MODEL_CHANGED', Path) - self:RegisterEvent('UNIT_PORTRAIT_UPDATE', Path) - self:RegisterEvent('PORTRAITS_UPDATED', Path, true) - self:RegisterEvent('UNIT_CONNECTION', Path) + self:RegisterEvent("UNIT_MODEL_CHANGED", Path) + self:RegisterEvent("UNIT_PORTRAIT_UPDATE", Path) + self:RegisterEvent("PORTRAITS_UPDATED", Path, true) + self:RegisterEvent("UNIT_CONNECTION", Path) -- The quest log uses PARTY_MEMBER_{ENABLE,DISABLE} to handle updating of -- party members overlapping quests. This will probably be enough to handle @@ -127,8 +131,8 @@ local function Enable(self, unit) -- -- DISABLE isn't used as it fires when we most likely don't have the -- information we want. - if(unit == 'party') then - self:RegisterEvent('PARTY_MEMBER_ENABLE', Path) + if unit == "party" then + self:RegisterEvent("PARTY_MEMBER_ENABLE", Path) end element:Show() @@ -139,15 +143,15 @@ end local function Disable(self) local element = self.Portrait - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_MODEL_CHANGED', Path) - self:UnregisterEvent('UNIT_PORTRAIT_UPDATE', Path) - self:UnregisterEvent('PORTRAITS_UPDATED', Path) - self:UnregisterEvent('PARTY_MEMBER_ENABLE', Path) - self:UnregisterEvent('UNIT_CONNECTION', Path) + self:UnregisterEvent("UNIT_MODEL_CHANGED", Path) + self:UnregisterEvent("UNIT_PORTRAIT_UPDATE", Path) + self:UnregisterEvent("PORTRAITS_UPDATED", Path) + self:UnregisterEvent("PARTY_MEMBER_ENABLE", Path) + self:UnregisterEvent("UNIT_CONNECTION", Path) end end -oUF:AddElement('Portrait', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("Portrait", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/power.lua b/KkthnxUI/Libraries/oUF/elements/power.lua index b588a1c08..c51556484 100644 --- a/KkthnxUI/Libraries/oUF/elements/power.lua +++ b/KkthnxUI/Libraries/oUF/elements/power.lua @@ -109,33 +109,35 @@ type and zero for the minimum value. local function GetDisplayPower(element) local unit = element.__owner.unit local barInfo = GetUnitPowerBarInfo(unit) - if(barInfo and barInfo.showOnRaid and (UnitInParty(unit) or UnitInRaid(unit))) then + if barInfo and barInfo.showOnRaid and (UnitInParty(unit) or UnitInRaid(unit)) then return ALTERNATE_POWER_INDEX, barInfo.minPower end end local function UpdateColor(self, event, unit) - if(self.unit ~= unit) then return end + if self.unit ~= unit then + return + end local element = self.Power local pType, pToken, altR, altG, altB = UnitPowerType(unit) local r, g, b, color - if(element.colorDisconnected and not UnitIsConnected(unit)) then + if element.colorDisconnected and not UnitIsConnected(unit) then color = self.colors.disconnected - elseif(element.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit)) then + elseif element.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit) then color = self.colors.tapped - elseif(element.colorThreat and not UnitPlayerControlled(unit) and UnitThreatSituation('player', unit)) then - color = self.colors.threat[UnitThreatSituation('player', unit)] - elseif(element.colorPower) then - if(element.displayType ~= ALTERNATE_POWER_INDEX) then + elseif element.colorThreat and not UnitPlayerControlled(unit) and UnitThreatSituation("player", unit) then + color = self.colors.threat[UnitThreatSituation("player", unit)] + elseif element.colorPower then + if element.displayType ~= ALTERNATE_POWER_INDEX then color = self.colors.power[pToken] - if(not color) then - if(element.GetAlternativeColor) then + if not color then + if element.GetAlternativeColor then r, g, b = element:GetAlternativeColor(unit, pType, pToken, altR, altG, altB) - elseif(altR) then + elseif altR then r, g, b = altR, altG, altB - if(r > 1 or g > 1 or b > 1) then + if r > 1 or g > 1 or b > 1 then -- BUG: As of 7.0.3, altR, altG, altB may be in 0-1 or 0-255 range. r, g, b = r / 255, g / 255, b / 255 end @@ -146,29 +148,27 @@ local function UpdateColor(self, event, unit) else color = self.colors.power[ALTERNATE_POWER_INDEX] end - elseif(element.colorClass and (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) - or (element.colorClassNPC and not (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) - or (element.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then + elseif (element.colorClass and (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) or (element.colorClassNPC and not (UnitIsPlayer(unit) or UnitInPartyIsAI(unit))) or (element.colorClassPet and UnitPlayerControlled(unit) and not UnitIsPlayer(unit)) then local _, class = UnitClass(unit) color = self.colors.class[class] - elseif(element.colorSelection and unitSelectionType(unit, element.considerSelectionInCombatHostile)) then + elseif element.colorSelection and unitSelectionType(unit, element.considerSelectionInCombatHostile) then color = self.colors.selection[unitSelectionType(unit, element.considerSelectionInCombatHostile)] - elseif(element.colorReaction and UnitReaction(unit, 'player')) then - color = self.colors.reaction[UnitReaction(unit, 'player')] - elseif(element.colorSmooth) then + elseif element.colorReaction and UnitReaction(unit, "player") then + color = self.colors.reaction[UnitReaction(unit, "player")] + elseif element.colorSmooth then local adjust = 0 - (element.min or 0) r, g, b = self:ColorGradient((element.cur or 1) + adjust, (element.max or 1) + adjust, unpack(element.smoothGradient or self.colors.smooth)) end - if(color) then + if color then r, g, b = color[1], color[2], color[3] end - if(b) then + if b then element:SetStatusBarColor(r, g, b) local bg = element.bg - if(bg) then + if bg then local mu = bg.multiplier or 1 bg:SetVertexColor(r * mu, g * mu, b * mu) end @@ -183,7 +183,7 @@ local function UpdateColor(self, event, unit) * g - the green component of the used color (number)[0-1] * b - the blue component of the used color (number)[0-1] --]] - if(element.PostUpdateColor) then + if element.PostUpdateColor then element:PostUpdateColor(unit, r, g, b) end end @@ -196,11 +196,13 @@ local function ColorPath(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event (string) --]] - (self.Power.UpdateColor or UpdateColor) (self, ...) + (self.Power.UpdateColor or UpdateColor)(self, ...) end local function Update(self, event, unit) - if(self.unit ~= unit) then return end + if self.unit ~= unit then + return + end local element = self.Power --[[ Callback: Power:PreUpdate(unit) @@ -209,19 +211,19 @@ local function Update(self, event, unit) * self - the Power element * unit - the unit for which the update has been triggered (string) --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate(unit) end local displayType, min - if(element.displayAltPower) then + if element.displayAltPower then displayType, min = element:GetDisplayPower() end local cur, max = UnitPower(unit, displayType), UnitPowerMax(unit, displayType) element:SetMinMaxValues(min or 0, max) - if(UnitIsConnected(unit)) then + if UnitIsConnected(unit) then element:SetValue(cur) else element:SetValue(max) @@ -241,7 +243,7 @@ local function Update(self, event, unit) * min - the unit's minimum possible power value (number) * max - the unit's maximum possible power value (number) --]] - if(element.PostUpdate) then + if element.PostUpdate then element:PostUpdate(unit, cur, min, max) end end @@ -255,13 +257,13 @@ local function Path(self, ...) * unit - the unit accompanying the event (string) * ... - the arguments accompanying the event --]] - (self.Power.Override or Update) (self, ...); + (self.Power.Override or Update)(self, ...) ColorPath(self, ...) end local function ForceUpdate(element) - Path(element.__owner, 'ForceUpdate', element.__owner.unit) + Path(element.__owner, "ForceUpdate", element.__owner.unit) end --[[ Power:SetColorDisconnected(state, isForced) @@ -272,12 +274,12 @@ Used to toggle coloring if the unit is offline. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetColorDisconnected(element, state, isForced) - if(element.colorDisconnected ~= state or isForced) then + if element.colorDisconnected ~= state or isForced then element.colorDisconnected = state - if(state) then - element.__owner:RegisterEvent('UNIT_CONNECTION', ColorPath) + if state then + element.__owner:RegisterEvent("UNIT_CONNECTION", ColorPath) else - element.__owner:UnregisterEvent('UNIT_CONNECTION', ColorPath) + element.__owner:UnregisterEvent("UNIT_CONNECTION", ColorPath) end end end @@ -290,12 +292,12 @@ Used to toggle coloring by the unit's selection. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetColorSelection(element, state, isForced) - if(element.colorSelection ~= state or isForced) then + if element.colorSelection ~= state or isForced then element.colorSelection = state - if(state) then - element.__owner:RegisterEvent('UNIT_FLAGS', ColorPath) + if state then + element.__owner:RegisterEvent("UNIT_FLAGS", ColorPath) else - element.__owner:UnregisterEvent('UNIT_FLAGS', ColorPath) + element.__owner:UnregisterEvent("UNIT_FLAGS", ColorPath) end end end @@ -308,12 +310,12 @@ Used to toggle coloring if the unit isn't tapped by the player. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetColorTapping(element, state, isForced) - if(element.colorTapping ~= state or isForced) then + if element.colorTapping ~= state or isForced then element.colorTapping = state - if(state) then - element.__owner:RegisterEvent('UNIT_FACTION', ColorPath) + if state then + element.__owner:RegisterEvent("UNIT_FACTION", ColorPath) else - element.__owner:UnregisterEvent('UNIT_FACTION', ColorPath) + element.__owner:UnregisterEvent("UNIT_FACTION", ColorPath) end end end @@ -326,12 +328,12 @@ Used to toggle coloring by the unit's threat status. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetColorThreat(element, state, isForced) - if(element.colorThreat ~= state or isForced) then + if element.colorThreat ~= state or isForced then element.colorThreat = state - if(state) then - element.__owner:RegisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) + if state then + element.__owner:RegisterEvent("UNIT_THREAT_LIST_UPDATE", ColorPath) else - element.__owner:UnregisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) + element.__owner:UnregisterEvent("UNIT_THREAT_LIST_UPDATE", ColorPath) end end end @@ -344,21 +346,21 @@ Used to toggle frequent updates. * isForced - forces the event update even if the state wasn't changed (boolean) --]] local function SetFrequentUpdates(element, state, isForced) - if(element.frequentUpdates ~= state or isForced) then + if element.frequentUpdates ~= state or isForced then element.frequentUpdates = state - if(state) then - element.__owner:UnregisterEvent('UNIT_POWER_UPDATE', Path) - element.__owner:RegisterEvent('UNIT_POWER_FREQUENT', Path) + if state then + element.__owner:UnregisterEvent("UNIT_POWER_UPDATE", Path) + element.__owner:RegisterEvent("UNIT_POWER_FREQUENT", Path) else - element.__owner:UnregisterEvent('UNIT_POWER_FREQUENT', Path) - element.__owner:RegisterEvent('UNIT_POWER_UPDATE', Path) + element.__owner:UnregisterEvent("UNIT_POWER_FREQUENT", Path) + element.__owner:RegisterEvent("UNIT_POWER_UPDATE", Path) end end end local function Enable(self) local element = self.Power - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate element.SetColorDisconnected = SetColorDisconnected @@ -367,38 +369,38 @@ local function Enable(self) element.SetColorThreat = SetColorThreat element.SetFrequentUpdates = SetFrequentUpdates - if(element.colorDisconnected) then - self:RegisterEvent('UNIT_CONNECTION', ColorPath) + if element.colorDisconnected then + self:RegisterEvent("UNIT_CONNECTION", ColorPath) end - if(element.colorSelection) then - self:RegisterEvent('UNIT_FLAGS', ColorPath) + if element.colorSelection then + self:RegisterEvent("UNIT_FLAGS", ColorPath) end - if(element.colorTapping) then - self:RegisterEvent('UNIT_FACTION', ColorPath) + if element.colorTapping then + self:RegisterEvent("UNIT_FACTION", ColorPath) end - if(element.colorThreat) then - self:RegisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) + if element.colorThreat then + self:RegisterEvent("UNIT_THREAT_LIST_UPDATE", ColorPath) end - if(element.frequentUpdates) then - self:RegisterEvent('UNIT_POWER_FREQUENT', Path) + if element.frequentUpdates then + self:RegisterEvent("UNIT_POWER_FREQUENT", Path) else - self:RegisterEvent('UNIT_POWER_UPDATE', Path) + self:RegisterEvent("UNIT_POWER_UPDATE", Path) end - self:RegisterEvent('UNIT_DISPLAYPOWER', Path) - self:RegisterEvent('UNIT_MAXPOWER', Path) - self:RegisterEvent('UNIT_POWER_BAR_HIDE', Path) - self:RegisterEvent('UNIT_POWER_BAR_SHOW', Path) + self:RegisterEvent("UNIT_DISPLAYPOWER", Path) + self:RegisterEvent("UNIT_MAXPOWER", Path) + self:RegisterEvent("UNIT_POWER_BAR_HIDE", Path) + self:RegisterEvent("UNIT_POWER_BAR_SHOW", Path) - if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then + if element:IsObjectType("StatusBar") and not element:GetStatusBarTexture() then element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end - if(not element.GetDisplayPower) then + if not element.GetDisplayPower then element.GetDisplayPower = GetDisplayPower end @@ -410,20 +412,20 @@ end local function Disable(self) local element = self.Power - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_DISPLAYPOWER', Path) - self:UnregisterEvent('UNIT_MAXPOWER', Path) - self:UnregisterEvent('UNIT_POWER_BAR_HIDE', Path) - self:UnregisterEvent('UNIT_POWER_BAR_SHOW', Path) - self:UnregisterEvent('UNIT_POWER_FREQUENT', Path) - self:UnregisterEvent('UNIT_POWER_UPDATE', Path) - self:UnregisterEvent('UNIT_CONNECTION', ColorPath) - self:UnregisterEvent('UNIT_FACTION', ColorPath) - self:UnregisterEvent('UNIT_FLAGS', ColorPath) - self:UnregisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath) + self:UnregisterEvent("UNIT_DISPLAYPOWER", Path) + self:UnregisterEvent("UNIT_MAXPOWER", Path) + self:UnregisterEvent("UNIT_POWER_BAR_HIDE", Path) + self:UnregisterEvent("UNIT_POWER_BAR_SHOW", Path) + self:UnregisterEvent("UNIT_POWER_FREQUENT", Path) + self:UnregisterEvent("UNIT_POWER_UPDATE", Path) + self:UnregisterEvent("UNIT_CONNECTION", ColorPath) + self:UnregisterEvent("UNIT_FACTION", ColorPath) + self:UnregisterEvent("UNIT_FLAGS", ColorPath) + self:UnregisterEvent("UNIT_THREAT_LIST_UPDATE", ColorPath) end end -oUF:AddElement('Power', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("Power", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/pvpclassificationindicator.lua b/KkthnxUI/Libraries/oUF/elements/pvpclassificationindicator.lua index 4fcdb2d3d..77bf512a4 100644 --- a/KkthnxUI/Libraries/oUF/elements/pvpclassificationindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/pvpclassificationindicator.lua @@ -45,7 +45,9 @@ local ICONS = { } local function Update(self, event, unit) - if(unit ~= self.unit) then return end + if unit ~= self.unit then + return + end local element = self.PvPClassificationIndicator @@ -55,13 +57,13 @@ local function Update(self, event, unit) * self - the PvPClassificationIndicator element * unit - the unit for which the update has been triggered (string) --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate(unit) end local class = UnitPvpClassification(unit) local icon = ICONS[class] - if(icon) then + if icon then element:SetAtlas(icon, element.useAtlasSize) element:Show() else @@ -75,7 +77,7 @@ local function Update(self, event, unit) * unit - the unit for which the update has been triggered (string) * class - the pvp classification of the unit (number?) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(unit, class) end end @@ -88,20 +90,20 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.PvPClassificationIndicator.Override or Update) (self, ...) + return (self.PvPClassificationIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate', element.__owner.unit) + return Path(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self) local element = self.PvPClassificationIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('UNIT_CLASSIFICATION_CHANGED', Path) + self:RegisterEvent("UNIT_CLASSIFICATION_CHANGED", Path) return true end @@ -109,11 +111,11 @@ end local function Disable(self) local element = self.PvPClassificationIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_CLASSIFICATION_CHANGED', Path) + self:UnregisterEvent("UNIT_CLASSIFICATION_CHANGED", Path) end end -oUF:AddElement('PvPClassificationIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("PvPClassificationIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/questindicator.lua b/KkthnxUI/Libraries/oUF/elements/questindicator.lua index b9721974b..64561b9eb 100644 --- a/KkthnxUI/Libraries/oUF/elements/questindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/questindicator.lua @@ -26,7 +26,9 @@ local _, ns = ... local oUF = ns.oUF local function Update(self, event, unit) - if(unit ~= self.unit) then return end + if unit ~= self.unit then + return + end local element = self.QuestIndicator @@ -35,12 +37,12 @@ local function Update(self, event, unit) * self - the QuestIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local isQuestBoss = UnitIsQuestBoss(unit) - if(isQuestBoss) then + if isQuestBoss then element:Show() else element:Hide() @@ -52,7 +54,7 @@ local function Update(self, event, unit) * self - the QuestIndicator element * isQuestBoss - indicates if the element is shown (boolean) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(isQuestBoss) end end @@ -65,22 +67,22 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.QuestIndicator.Override or Update) (self, ...) + return (self.QuestIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate', element.__owner.unit) + return Path(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self) local element = self.QuestIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('UNIT_CLASSIFICATION_CHANGED', Path) + self:RegisterEvent("UNIT_CLASSIFICATION_CHANGED", Path) - if(element:IsObjectType('Texture') and not element:GetTexture()) then + if element:IsObjectType("Texture") and not element:GetTexture() then element:SetTexture([[Interface\TargetingFrame\PortraitQuestBadge]]) end @@ -90,11 +92,11 @@ end local function Disable(self) local element = self.QuestIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_CLASSIFICATION_CHANGED', Path) + self:UnregisterEvent("UNIT_CLASSIFICATION_CHANGED", Path) end end -oUF:AddElement('QuestIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("QuestIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/raidroleindicator.lua b/KkthnxUI/Libraries/oUF/elements/raidroleindicator.lua index e448b20f5..2f4feac5c 100644 --- a/KkthnxUI/Libraries/oUF/elements/raidroleindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/raidroleindicator.lua @@ -37,20 +37,20 @@ local function Update(self, event) * self - the RaidRoleIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local role, isShown - if(UnitInRaid(unit) and not UnitHasVehicleUI(unit)) then - if(GetPartyAssignment('MAINTANK', unit)) then + if UnitInRaid(unit) and not UnitHasVehicleUI(unit) then + if GetPartyAssignment("MAINTANK", unit) then isShown = true element:SetTexture(MAINTANK_ICON) - role = 'MAINTANK' - elseif(GetPartyAssignment('MAINASSIST', unit)) then + role = "MAINTANK" + elseif GetPartyAssignment("MAINASSIST", unit) then isShown = true element:SetTexture(MAINASSIST_ICON) - role = 'MAINASSIST' + role = "MAINASSIST" end end @@ -62,7 +62,7 @@ local function Update(self, event) * self - the RaidRoleIndicator element * role - the unit's raid assignment (string?)['MAINTANK', 'MAINASSIST'] --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(role) end end @@ -79,16 +79,16 @@ local function Path(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate') + return Path(element.__owner, "ForceUpdate") end local function Enable(self) local element = self.RaidRoleIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('GROUP_ROSTER_UPDATE', Path, true) + self:RegisterEvent("GROUP_ROSTER_UPDATE", Path, true) return true end @@ -96,11 +96,11 @@ end local function Disable(self) local element = self.RaidRoleIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path) + self:UnregisterEvent("GROUP_ROSTER_UPDATE", Path) end end -oUF:AddElement('RaidRoleIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("RaidRoleIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/raidtargetindicator.lua b/KkthnxUI/Libraries/oUF/elements/raidtargetindicator.lua index 3ec2d12e1..8b49e8c6f 100644 --- a/KkthnxUI/Libraries/oUF/elements/raidtargetindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/raidtargetindicator.lua @@ -36,12 +36,12 @@ local function Update(self, event) * self - the RaidTargetIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local index = GetRaidTargetIndex(self.unit) - if(index) then + if index then SetRaidTargetIconTexture(element, index) element:Show() else @@ -54,7 +54,7 @@ local function Update(self, event) * self - the RaidTargetIndicator element * index - the index of the raid target marker (number?)[1-8] --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(index) end end @@ -66,23 +66,25 @@ local function Path(self, ...) * self - the parent object * event - the event triggering the update (string) --]] - return (self.RaidTargetIndicator.Override or Update) (self, ...) + return (self.RaidTargetIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - if(not element.__owner.unit) then return end - return Path(element.__owner, 'ForceUpdate') + if not element.__owner.unit then + return + end + return Path(element.__owner, "ForceUpdate") end local function Enable(self) local element = self.RaidTargetIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('RAID_TARGET_UPDATE', Path, true) + self:RegisterEvent("RAID_TARGET_UPDATE", Path, true) - if(element:IsObjectType('Texture') and not element:GetTexture()) then + if element:IsObjectType("Texture") and not element:GetTexture() then element:SetTexture([[Interface\TargetingFrame\UI-RaidTargetingIcons]]) end @@ -92,11 +94,11 @@ end local function Disable(self) local element = self.RaidTargetIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('RAID_TARGET_UPDATE', Path) + self:UnregisterEvent("RAID_TARGET_UPDATE", Path) end end -oUF:AddElement('RaidTargetIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("RaidTargetIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/readycheckindicator.lua b/KkthnxUI/Libraries/oUF/elements/readycheckindicator.lua index e8071fca8..94223492a 100644 --- a/KkthnxUI/Libraries/oUF/elements/readycheckindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/readycheckindicator.lua @@ -55,7 +55,7 @@ local function OnFinished(self) * self - the ReadyCheckIndicator element --]] - if(element.PostUpdateFadeOut) then + if element.PostUpdateFadeOut then element:PostUpdateFadeOut() end end @@ -69,15 +69,15 @@ local function Update(self, event) * self - the ReadyCheckIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local status = GetReadyCheckStatus(unit) - if(unitExists(unit) and status) then - if(status == 'ready') then + if unitExists(unit) and status then + if status == "ready" then element:SetAtlas(element.readyTexture) - elseif(status == 'notready') then + elseif status == "notready" then element:SetAtlas(element.notReadyTexture) else element:SetAtlas(element.waitingTexture) @@ -85,13 +85,13 @@ local function Update(self, event) element.status = status element:Show() - elseif(event ~= 'READY_CHECK_FINISHED') then + elseif event ~= "READY_CHECK_FINISHED" then element.status = nil element:Hide() end - if(event == 'READY_CHECK_FINISHED') then - if(element.status == 'waiting') then + if event == "READY_CHECK_FINISHED" then + if element.status == "waiting" then element:SetTexture(element.notReadyTexture) end @@ -104,7 +104,7 @@ local function Update(self, event) * self - the ReadyCheckIndicator element * status - the unit's ready check status (string?)['ready', 'notready', 'waiting'] --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(status) end end @@ -117,17 +117,17 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.ReadyCheckIndicator.Override or Update) (self, ...) + return (self.ReadyCheckIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate') + return Path(element.__owner, "ForceUpdate") end local function Enable(self, unit) local element = self.ReadyCheckIndicator - unit = unit and unit:match('(%a+)%d*$') - if(element and (unit == 'party' or unit == 'raid')) then + unit = unit and unit:match("(%a+)%d*$") + if element and (unit == "party" or unit == "raid") then element.__owner = self element.ForceUpdate = ForceUpdate @@ -136,18 +136,18 @@ local function Enable(self, unit) element.waitingTexture = element.waitingTexture or READY_CHECK_WAITING_TEXTURE local AnimationGroup = element:CreateAnimationGroup() - AnimationGroup:HookScript('OnFinished', OnFinished) + AnimationGroup:HookScript("OnFinished", OnFinished) element.Animation = AnimationGroup - local Animation = AnimationGroup:CreateAnimation('Alpha') + local Animation = AnimationGroup:CreateAnimation("Alpha") Animation:SetFromAlpha(1) Animation:SetToAlpha(0) Animation:SetDuration(element.fadeTime or 1.5) Animation:SetStartDelay(element.finishedTime or 10) - self:RegisterEvent('READY_CHECK', Path, true) - self:RegisterEvent('READY_CHECK_CONFIRM', Path, true) - self:RegisterEvent('READY_CHECK_FINISHED', Path, true) + self:RegisterEvent("READY_CHECK", Path, true) + self:RegisterEvent("READY_CHECK_CONFIRM", Path, true) + self:RegisterEvent("READY_CHECK_FINISHED", Path, true) return true end @@ -155,13 +155,13 @@ end local function Disable(self) local element = self.ReadyCheckIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('READY_CHECK', Path) - self:UnregisterEvent('READY_CHECK_CONFIRM', Path) - self:UnregisterEvent('READY_CHECK_FINISHED', Path) + self:UnregisterEvent("READY_CHECK", Path) + self:UnregisterEvent("READY_CHECK_CONFIRM", Path) + self:UnregisterEvent("READY_CHECK_FINISHED", Path) end end -oUF:AddElement('ReadyCheckIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("ReadyCheckIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/restingindicator.lua b/KkthnxUI/Libraries/oUF/elements/restingindicator.lua index 274738666..98e39ad1b 100644 --- a/KkthnxUI/Libraries/oUF/elements/restingindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/restingindicator.lua @@ -33,12 +33,12 @@ local function Update(self, event) * self - the RestingIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local isResting = IsResting() - if(isResting) then + if isResting then element:Show() else element:Hide() @@ -50,7 +50,7 @@ local function Update(self, event) * self - the RestingIndicator element * isResting - indicates if the player is resting (boolean) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(isResting) end end @@ -62,22 +62,22 @@ local function Path(self, ...) * self - the parent object * event - the event triggering the update (string) --]] - return (self.RestingIndicator.Override or Update) (self, ...) + return (self.RestingIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate') + return Path(element.__owner, "ForceUpdate") end local function Enable(self, unit) local element = self.RestingIndicator - if(element and UnitIsUnit(unit, 'player')) then + if element and UnitIsUnit(unit, "player") then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('PLAYER_UPDATE_RESTING', Path, true) + self:RegisterEvent("PLAYER_UPDATE_RESTING", Path, true) - if(element:IsObjectType('Texture') and not element:GetTexture()) then + if element:IsObjectType("Texture") and not element:GetTexture() then element:SetTexture([[Interface\CharacterFrame\UI-StateIcon]]) element:SetTexCoord(0, 0.5, 0, 0.421875) end @@ -88,11 +88,11 @@ end local function Disable(self) local element = self.RestingIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('PLAYER_UPDATE_RESTING', Path) + self:UnregisterEvent("PLAYER_UPDATE_RESTING", Path) end end -oUF:AddElement('RestingIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("RestingIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/resurrectindicator.lua b/KkthnxUI/Libraries/oUF/elements/resurrectindicator.lua index f8aef42f9..c7c616339 100644 --- a/KkthnxUI/Libraries/oUF/elements/resurrectindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/resurrectindicator.lua @@ -26,7 +26,9 @@ local _, ns = ... local oUF = ns.oUF local function Update(self, event, unit) - if(self.unit ~= unit) then return end + if self.unit ~= unit then + return + end local element = self.ResurrectIndicator @@ -35,12 +37,12 @@ local function Update(self, event, unit) * self - the ResurrectIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local incomingResurrect = UnitHasIncomingResurrection(unit) - if(incomingResurrect) then + if incomingResurrect then element:Show() else element:Hide() @@ -52,7 +54,7 @@ local function Update(self, event, unit) * self - the ResurrectIndicator element * incomingResurrect - indicates if the unit has an incoming resurrection (boolean) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(incomingResurrect) end end @@ -65,22 +67,22 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.ResurrectIndicator.Override or Update) (self, ...) + return (self.ResurrectIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate', element.__owner.unit) + return Path(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self) local element = self.ResurrectIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('INCOMING_RESURRECT_CHANGED', Path) + self:RegisterEvent("INCOMING_RESURRECT_CHANGED", Path) - if(element:IsObjectType('Texture') and not element:GetTexture()) then + if element:IsObjectType("Texture") and not element:GetTexture() then element:SetTexture([[Interface\RaidFrame\Raid-Icon-Rez]]) end @@ -90,11 +92,11 @@ end local function Disable(self) local element = self.ResurrectIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('INCOMING_RESURRECT_CHANGED', Path) + self:UnregisterEvent("INCOMING_RESURRECT_CHANGED", Path) end end -oUF:AddElement('ResurrectIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("ResurrectIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/runes.lua b/KkthnxUI/Libraries/oUF/elements/runes.lua index 6c26eadfd..4805b182c 100644 --- a/KkthnxUI/Libraries/oUF/elements/runes.lua +++ b/KkthnxUI/Libraries/oUF/elements/runes.lua @@ -42,12 +42,14 @@ A default texture will be applied if the sub-widgets are StatusBars and don't ha self.Runes = Runes --]] -if(select(2, UnitClass('player')) ~= 'DEATHKNIGHT') then return end +if select(2, UnitClass("player")) ~= "DEATHKNIGHT" then + return +end local _, ns = ... local oUF = ns.oUF -local runemap = {1, 2, 3, 4, 5, 6} +local runemap = { 1, 2, 3, 4, 5, 6 } local hasSortOrder = false local function onUpdate(self, elapsed) @@ -59,9 +61,9 @@ end local function ascSort(runeAID, runeBID) local runeAStart, _, runeARuneReady = GetRuneCooldown(runeAID) local runeBStart, _, runeBRuneReady = GetRuneCooldown(runeBID) - if(runeARuneReady ~= runeBRuneReady) then + if runeARuneReady ~= runeBRuneReady then return runeARuneReady - elseif(runeAStart ~= runeBStart) then + elseif runeAStart ~= runeBStart then return runeAStart < runeBStart else return runeAID < runeBID @@ -71,9 +73,9 @@ end local function descSort(runeAID, runeBID) local runeAStart, _, runeARuneReady = GetRuneCooldown(runeAID) local runeBStart, _, runeBRuneReady = GetRuneCooldown(runeBID) - if(runeARuneReady ~= runeBRuneReady) then + if runeARuneReady ~= runeBRuneReady then return runeBRuneReady - elseif(runeAStart ~= runeBStart) then + elseif runeAStart ~= runeBStart then return runeAStart > runeBStart else return runeAID > runeBID @@ -86,7 +88,7 @@ local function UpdateColor(self, event) local spec = GetSpecialization() or 0 local color - if(spec > 0 and spec < 4 and element.colorSpec) then + if spec > 0 and spec < 4 and element.colorSpec then color = self.colors.runes[spec] else color = self.colors.power.RUNES @@ -98,7 +100,7 @@ local function UpdateColor(self, event) element[index]:SetStatusBarColor(r, g, b) local bg = element[index].bg - if(bg) then + if bg then local mu = bg.multiplier or 1 bg:SetVertexColor(r * mu, g * mu, b * mu) end @@ -112,7 +114,7 @@ local function UpdateColor(self, event) * g - the green component of the used color (number)[0-1] * b - the blue component of the used color (number)[0-1] --]] - if(element.PostUpdateColor) then + if element.PostUpdateColor then element:PostUpdateColor(r, g, b) end end @@ -125,19 +127,19 @@ local function ColorPath(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - (self.Runes.UpdateColor or UpdateColor) (self, ...) + (self.Runes.UpdateColor or UpdateColor)(self, ...) end local function Update(self, event) local element = self.Runes - if(element.sortOrder == 'asc') then + if element.sortOrder == "asc" then table.sort(runemap, ascSort) hasSortOrder = true - elseif(element.sortOrder == 'desc') then + elseif element.sortOrder == "desc" then table.sort(runemap, descSort) hasSortOrder = true - elseif(hasSortOrder) then + elseif hasSortOrder then table.sort(runemap) hasSortOrder = false end @@ -145,21 +147,23 @@ local function Update(self, event) local rune, start, duration, runeReady for index, runeID in next, runemap do rune = element[index] - if(not rune) then break end + if not rune then + break + end - if(UnitHasVehicleUI('player')) then + if UnitHasVehicleUI("player") then rune:Hide() else start, duration, runeReady = GetRuneCooldown(runeID) - if(runeReady) then + if runeReady then rune:SetMinMaxValues(0, 1) rune:SetValue(1) - rune:SetScript('OnUpdate', nil) - elseif(start) then + rune:SetScript("OnUpdate", nil) + elseif start then rune.duration = GetTime() - start rune:SetMinMaxValues(0, duration) rune:SetValue(0) - rune:SetScript('OnUpdate', onUpdate) + rune:SetScript("OnUpdate", onUpdate) end rune:Show() @@ -172,7 +176,7 @@ local function Update(self, event) * self - the Runes element * runemap - the ordered list of runes' indices (table) --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(runemap) end end @@ -185,7 +189,7 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - (self.Runes.Override or Update) (self, ...) + (self.Runes.Override or Update)(self, ...) end local function AllPath(...) @@ -194,25 +198,25 @@ local function AllPath(...) end local function ForceUpdate(element) - Path(element.__owner, 'ForceUpdate') - ColorPath(element.__owner, 'ForceUpdate') + Path(element.__owner, "ForceUpdate") + ColorPath(element.__owner, "ForceUpdate") end local function Enable(self, unit) local element = self.Runes - if(element and UnitIsUnit(unit, 'player')) then + if element and UnitIsUnit(unit, "player") then element.__owner = self element.ForceUpdate = ForceUpdate for i = 1, #element do local rune = element[i] - if(rune:IsObjectType('StatusBar') and not rune:GetStatusBarTexture()) then + if rune:IsObjectType("StatusBar") and not rune:GetStatusBarTexture() then rune:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end end - self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED', ColorPath) - self:RegisterEvent('RUNE_POWER_UPDATE', Path, true) + self:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED", ColorPath) + self:RegisterEvent("RUNE_POWER_UPDATE", Path, true) return true end @@ -220,14 +224,14 @@ end local function Disable(self) local element = self.Runes - if(element) then + if element then for i = 1, #element do element[i]:Hide() end - self:UnregisterEvent('PLAYER_SPECIALIZATION_CHANGED', ColorPath) - self:UnregisterEvent('RUNE_POWER_UPDATE', Path) + self:UnregisterEvent("PLAYER_SPECIALIZATION_CHANGED", ColorPath) + self:UnregisterEvent("RUNE_POWER_UPDATE", Path) end end -oUF:AddElement('Runes', AllPath, Enable, Disable) \ No newline at end of file +oUF:AddElement("Runes", AllPath, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/stagger.lua b/KkthnxUI/Libraries/oUF/elements/stagger.lua index 031d1519c..61166a1c3 100644 --- a/KkthnxUI/Libraries/oUF/elements/stagger.lua +++ b/KkthnxUI/Libraries/oUF/elements/stagger.lua @@ -29,7 +29,9 @@ A default texture will be applied if the widget is a StatusBar and doesn't have self.Stagger = Stagger --]] -if(select(2, UnitClass('player')) ~= 'MONK') then return end +if select(2, UnitClass("player")) ~= "MONK" then + return +end local _, ns = ... local oUF = ns.oUF @@ -37,10 +39,10 @@ local oUF = ns.oUF -- sourced from Blizzard_FrameXMLBase/Constants.lua local SPEC_MONK_BREWMASTER = SPEC_MONK_BREWMASTER or 1 -local BREWMASTER_POWER_BAR_NAME = 'STAGGER' +local BREWMASTER_POWER_BAR_NAME = "STAGGER" -- percentages at which bar should change color -local STAGGER_YELLOW_TRANSITION = STAGGER_YELLOW_TRANSITION or 0.3 +local STAGGER_YELLOW_TRANSITION = STAGGER_YELLOW_TRANSITION or 0.3 local STAGGER_RED_TRANSITION = STAGGER_RED_TRANSITION or 0.6 -- table indices of bar colors @@ -49,29 +51,31 @@ local STAGGER_YELLOW_INDEX = STAGGER_YELLOW_INDEX or 2 local STAGGER_RED_INDEX = STAGGER_RED_INDEX or 3 local function UpdateColor(self, event, unit) - if(unit and unit ~= self.unit) then return end + if unit and unit ~= self.unit then + return + end local element = self.Stagger local colors = self.colors.power[BREWMASTER_POWER_BAR_NAME] local perc = (element.cur or 0) / (element.max or 1) local color - if(perc >= STAGGER_RED_TRANSITION) then + if perc >= STAGGER_RED_TRANSITION then color = colors and colors[STAGGER_RED_INDEX] - elseif(perc > STAGGER_YELLOW_TRANSITION) then + elseif perc > STAGGER_YELLOW_TRANSITION then color = colors and colors[STAGGER_YELLOW_INDEX] else color = colors and colors[STAGGER_GREEN_INDEX] end local r, g, b - if(color) then + if color then r, g, b = color[1], color[2], color[3] - if(b) then + if b then element:SetStatusBarColor(r, g, b) local bg = element.bg - if(bg and b) then + if bg and b then local mu = bg.multiplier or 1 bg:SetVertexColor(r * mu, g * mu, b * mu) end @@ -86,13 +90,15 @@ local function UpdateColor(self, event, unit) * g - the green component of the used color (number)[0-1] * b - the blue component of the used color (number)[0-1] --]] - if(element.PostUpdateColor) then + if element.PostUpdateColor then element:PostUpdateColor(r, g, b) end end local function Update(self, event, unit) - if(unit and unit ~= self.unit) then return end + if unit and unit ~= self.unit then + return + end local element = self.Stagger @@ -101,13 +107,13 @@ local function Update(self, event, unit) * self - the Stagger element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end -- Blizzard code has nil checks for UnitStagger return - local cur = UnitStagger('player') or 0 - local max = UnitHealthMax('player') + local cur = UnitStagger("player") or 0 + local max = UnitHealthMax("player") element:SetMinMaxValues(0, max) element:SetValue(cur) @@ -122,7 +128,7 @@ local function Update(self, event, unit) * cur - the amount of staggered damage (number) * max - the player's maximum possible health value (number) --]] - if(element.PostUpdate) then + if element.PostUpdate then element:PostUpdate(cur, max) end end @@ -144,19 +150,19 @@ local function Path(self, ...) * event - the event triggering the update (string) * unit - the unit accompanying the event (string) --]] - (self.Stagger.UpdateColor or UpdateColor) (self, ...) + (self.Stagger.UpdateColor or UpdateColor)(self, ...) end local function Visibility(self, event, unit) - if(SPEC_MONK_BREWMASTER ~= GetSpecialization() or UnitHasVehiclePlayerFrameUI('player')) then - if(self.Stagger:IsShown()) then + if SPEC_MONK_BREWMASTER ~= GetSpecialization() or UnitHasVehiclePlayerFrameUI("player") then + if self.Stagger:IsShown() then self.Stagger:Hide() - self:UnregisterEvent('UNIT_AURA', Path) + self:UnregisterEvent("UNIT_AURA", Path) end else - if(not self.Stagger:IsShown()) then + if not self.Stagger:IsShown() then self.Stagger:Show() - self:RegisterEvent('UNIT_AURA', Path) + self:RegisterEvent("UNIT_AURA", Path) end Path(self, event, unit) @@ -175,28 +181,28 @@ local function VisibilityPath(self, ...) end local function ForceUpdate(element) - VisibilityPath(element.__owner, 'ForceUpdate', element.__owner.unit) + VisibilityPath(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self, unit) local element = self.Stagger - if(element and UnitIsUnit(unit, 'player')) then + if element and UnitIsUnit(unit, "player") then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('UNIT_DISPLAYPOWER', VisibilityPath) - self:RegisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath, true) + self:RegisterEvent("UNIT_DISPLAYPOWER", VisibilityPath) + self:RegisterEvent("PLAYER_TALENT_UPDATE", VisibilityPath, true) - if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then + if element:IsObjectType("StatusBar") and not element:GetStatusBarTexture() then element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) end if self.mystyle == "player" then -- NDui: only disable MonkStaggerBar for oUF_Player - MonkStaggerBar:UnregisterEvent('PLAYER_ENTERING_WORLD') - MonkStaggerBar:UnregisterEvent('PLAYER_SPECIALIZATION_CHANGED') - MonkStaggerBar:UnregisterEvent('UNIT_DISPLAYPOWER') - MonkStaggerBar:UnregisterEvent('UNIT_EXITED_VEHICLE') - MonkStaggerBar:UnregisterEvent('UPDATE_VEHICLE_ACTIONBAR') + MonkStaggerBar:UnregisterEvent("PLAYER_ENTERING_WORLD") + MonkStaggerBar:UnregisterEvent("PLAYER_SPECIALIZATION_CHANGED") + MonkStaggerBar:UnregisterEvent("UNIT_DISPLAYPOWER") + MonkStaggerBar:UnregisterEvent("UNIT_EXITED_VEHICLE") + MonkStaggerBar:UnregisterEvent("UPDATE_VEHICLE_ACTIONBAR") end element:Hide() @@ -207,19 +213,19 @@ end local function Disable(self) local element = self.Stagger - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_AURA', Path) - self:UnregisterEvent('UNIT_DISPLAYPOWER', VisibilityPath) - self:UnregisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath) + self:UnregisterEvent("UNIT_AURA", Path) + self:UnregisterEvent("UNIT_DISPLAYPOWER", VisibilityPath) + self:UnregisterEvent("PLAYER_TALENT_UPDATE", VisibilityPath) - MonkStaggerBar:RegisterEvent('PLAYER_ENTERING_WORLD') - MonkStaggerBar:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED') - MonkStaggerBar:RegisterEvent('UNIT_DISPLAYPOWER') - MonkStaggerBar:RegisterEvent('UNIT_EXITED_VEHICLE') - MonkStaggerBar:RegisterEvent('UPDATE_VEHICLE_ACTIONBAR') + MonkStaggerBar:RegisterEvent("PLAYER_ENTERING_WORLD") + MonkStaggerBar:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED") + MonkStaggerBar:RegisterEvent("UNIT_DISPLAYPOWER") + MonkStaggerBar:RegisterEvent("UNIT_EXITED_VEHICLE") + MonkStaggerBar:RegisterEvent("UPDATE_VEHICLE_ACTIONBAR") end end -oUF:AddElement('Stagger', VisibilityPath, Enable, Disable) \ No newline at end of file +oUF:AddElement("Stagger", VisibilityPath, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/summonindicator.lua b/KkthnxUI/Libraries/oUF/elements/summonindicator.lua index 1a7e183a2..91f6ef3ae 100644 --- a/KkthnxUI/Libraries/oUF/elements/summonindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/summonindicator.lua @@ -32,7 +32,9 @@ local SUMMON_STATUS_ACCEPTED = Enum.SummonStatus.Accepted or 2 local SUMMON_STATUS_DECLINED = Enum.SummonStatus.Declined or 3 local function Update(self, event, unit) - if(self.unit ~= unit) then return end + if self.unit ~= unit then + return + end local element = self.SummonIndicator @@ -41,18 +43,18 @@ local function Update(self, event, unit) * self - the SummonIndicator element --]] - if(element.PreUpdate) then + if element.PreUpdate then element:PreUpdate() end local status = C_IncomingSummon.IncomingSummonStatus(unit) - if(status ~= SUMMON_STATUS_NONE) then - if(status == SUMMON_STATUS_PENDING) then - element:SetAtlas('Raid-Icon-SummonPending') - elseif(status == SUMMON_STATUS_ACCEPTED) then - element:SetAtlas('Raid-Icon-SummonAccepted') - elseif(status == SUMMON_STATUS_DECLINED) then - element:SetAtlas('Raid-Icon-SummonDeclined') + if status ~= SUMMON_STATUS_NONE then + if status == SUMMON_STATUS_PENDING then + element:SetAtlas("Raid-Icon-SummonPending") + elseif status == SUMMON_STATUS_ACCEPTED then + element:SetAtlas("Raid-Icon-SummonAccepted") + elseif status == SUMMON_STATUS_DECLINED then + element:SetAtlas("Raid-Icon-SummonDeclined") end element:Show() @@ -66,7 +68,7 @@ local function Update(self, event, unit) * self - the SummonIndicator element * status - the unit's incoming summon status (number)[0-3] --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(status) end end @@ -79,20 +81,20 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.SummonIndicator.Override or Update) (self, ...) + return (self.SummonIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate', element.__owner.unit) + return Path(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self) local element = self.SummonIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('INCOMING_SUMMON_CHANGED', Path) + self:RegisterEvent("INCOMING_SUMMON_CHANGED", Path) return true end @@ -100,11 +102,11 @@ end local function Disable(self) local element = self.SummonIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('INCOMING_SUMMON_CHANGED', Path) + self:UnregisterEvent("INCOMING_SUMMON_CHANGED", Path) end end -oUF:AddElement('SummonIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("SummonIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/elements/tags.lua b/KkthnxUI/Libraries/oUF/elements/tags.lua index e5bfda6e1..4696844ff 100644 --- a/KkthnxUI/Libraries/oUF/elements/tags.lua +++ b/KkthnxUI/Libraries/oUF/elements/tags.lua @@ -110,35 +110,35 @@ local nierror = Private.nierror local unitExists = Private.unitExists local validateEvent = Private.validateEvent -local _PATTERN = '%[..-%]+' +local _PATTERN = "%[..-%]+" local _ENV = { Hex = function(r, g, b) - if(type(r) == 'table') then - if(r.r) then + if type(r) == "table" then + if r.r then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end end - return string.format('|cff%02x%02x%02x', r * 255, g * 255, b * 255) + return string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255) end, } _ENV.ColorGradient = function(...) return _ENV._FRAME:ColorGradient(...) end -local _PROXY = setmetatable(_ENV, {__index = _G}) +local _PROXY = setmetatable(_ENV, { __index = _G }) local tagStrings = { - ['affix'] = [[function(u) + ["affix"] = [[function(u) local c = UnitClassification(u) if(c == 'minus') then return 'Affix' end end]], - ['arcanecharges'] = [[function() + ["arcanecharges"] = [[function() if(GetSpecialization() == SPEC_MAGE_ARCANE) then local num = UnitPower('player', Enum.PowerType.ArcaneCharges) if(num > 0) then @@ -147,7 +147,7 @@ local tagStrings = { end end]], - ['arenaspec'] = [[function(u) + ["arenaspec"] = [[function(u) local id = u:match('arena(%d)$') if(id) then local specID = GetArenaOpponentSpec(tonumber(id)) @@ -158,7 +158,7 @@ local tagStrings = { end end]], - ['chi'] = [[function() + ["chi"] = [[function() if(GetSpecialization() == SPEC_MONK_WINDWALKER) then local num = UnitPower('player', Enum.PowerType.Chi) if(num > 0) then @@ -167,7 +167,7 @@ local tagStrings = { end end]], - ['classification'] = [[function(u) + ["classification"] = [[function(u) local c = UnitClassification(u) if(c == 'rare') then return 'Rare' @@ -182,7 +182,7 @@ local tagStrings = { end end]], - ['cpoints'] = [[function(u) + ["cpoints"] = [[function(u) local cp = UnitPower(u, Enum.PowerType.ComboPoints) if(cp > 0) then @@ -190,15 +190,15 @@ local tagStrings = { end end]], - ['creature'] = [[function(u) + ["creature"] = [[function(u) return UnitCreatureFamily(u) or UnitCreatureType(u) end]], - ['curmana'] = [[function(unit) + ["curmana"] = [[function(unit) return UnitPower(unit, Enum.PowerType.Mana) end]], - ['dead'] = [[function(u) + ["dead"] = [[function(u) if(UnitIsDead(u)) then return 'Dead' elseif(UnitIsGhost(u)) then @@ -206,7 +206,7 @@ local tagStrings = { end end]], - ['deficit:name'] = [[function(u) + ["deficit:name"] = [[function(u) local missinghp = _TAGS['missinghp'](u) if(missinghp) then return '-' .. missinghp @@ -215,14 +215,14 @@ local tagStrings = { end end]], - ['difficulty'] = [[function(u) + ["difficulty"] = [[function(u) if UnitCanAttack('player', u) then local l = UnitEffectiveLevel(u) return Hex(GetCreatureDifficultyColor((l > 0) and l or 999)) end end]], - ['group'] = [[function(unit) + ["group"] = [[function(unit) local name, server = UnitName(unit) if(server and server ~= '') then name = string.format('%s-%s', name, server) @@ -236,7 +236,7 @@ local tagStrings = { end end]], - ['holypower'] = [[function() + ["holypower"] = [[function() if(GetSpecialization() == SPEC_PALADIN_RETRIBUTION) then local num = UnitPower('player', Enum.PowerType.HolyPower) if(num > 0) then @@ -245,19 +245,19 @@ local tagStrings = { end end]], - ['leader'] = [[function(u) + ["leader"] = [[function(u) if(UnitIsGroupLeader(u)) then return 'L' end end]], - ['leaderlong'] = [[function(u) + ["leaderlong"] = [[function(u) if(UnitIsGroupLeader(u)) then return 'Leader' end end]], - ['level'] = [[function(u) + ["level"] = [[function(u) local l = UnitEffectiveLevel(u) if(UnitIsWildBattlePet(u) or UnitIsBattlePetCompanion(u)) then l = UnitBattlePetLevel(u) @@ -270,35 +270,35 @@ local tagStrings = { end end]], - ['maxmana'] = [[function(unit) + ["maxmana"] = [[function(unit) return UnitPowerMax(unit, Enum.PowerType.Mana) end]], - ['missinghp'] = [[function(u) + ["missinghp"] = [[function(u) local current = UnitHealthMax(u) - UnitHealth(u) if(current > 0) then return current end end]], - ['missingpp'] = [[function(u) + ["missingpp"] = [[function(u) local current = UnitPowerMax(u) - UnitPower(u) if(current > 0) then return current end end]], - ['name'] = [[function(u, r) + ["name"] = [[function(u, r) return UnitName(r or u) end]], - ['offline'] = [[function(u) + ["offline"] = [[function(u) if(not UnitIsConnected(u)) then return 'Offline' end end]], - ['perhp'] = [[function(u) + ["perhp"] = [[function(u) local m = UnitHealthMax(u) if(m == 0) then return 0 @@ -307,7 +307,7 @@ local tagStrings = { end end]], - ['perpp'] = [[function(u) + ["perpp"] = [[function(u) local m = UnitPowerMax(u) if(m == 0) then return 0 @@ -316,14 +316,14 @@ local tagStrings = { end end]], - ['plus'] = [[function(u) + ["plus"] = [[function(u) local c = UnitClassification(u) if(c == 'elite' or c == 'rareelite') then return '+' end end]], - ['powercolor'] = [[function(u) + ["powercolor"] = [[function(u) local pType, pToken, altR, altG, altB = UnitPowerType(u) local t = _COLORS.power[pToken] @@ -342,13 +342,13 @@ local tagStrings = { return Hex(t) end]], - ['pvp'] = [[function(u) + ["pvp"] = [[function(u) if(UnitIsPVP(u)) then return 'PvP' end end]], - ['raidcolor'] = [[function(u) + ["raidcolor"] = [[function(u) local _, class = UnitClass(u) if(class) then return Hex(_COLORS.class[class]) @@ -364,20 +364,20 @@ local tagStrings = { end end]], - ['rare'] = [[function(u) + ["rare"] = [[function(u) local c = UnitClassification(u) if(c == 'rare' or c == 'rareelite') then return 'Rare' end end]], - ['resting'] = [[function(u) + ["resting"] = [[function(u) if(u == 'player' and IsResting()) then return 'zzz' end end]], - ['runes'] = [[function() + ["runes"] = [[function() local amount = 0 for i = 1, 6 do @@ -390,7 +390,7 @@ local tagStrings = { return amount end]], - ['sex'] = [[function(u) + ["sex"] = [[function(u) local s = UnitSex(u) if(s == 2) then return 'Male' @@ -399,7 +399,7 @@ local tagStrings = { end end]], - ['shortclassification'] = [[function(u) + ["shortclassification"] = [[function(u) local c = UnitClassification(u) if(c == 'rare') then return 'R' @@ -414,7 +414,7 @@ local tagStrings = { end end]], - ['smartclass'] = [[function(u) + ["smartclass"] = [[function(u) if(UnitIsPlayer(u)) then return _TAGS['class'](u) end @@ -422,7 +422,7 @@ local tagStrings = { return _TAGS['creature'](u) end]], - ['smartlevel'] = [[function(u) + ["smartlevel"] = [[function(u) local c = UnitClassification(u) if(c == 'worldboss') then return 'Boss' @@ -437,14 +437,14 @@ local tagStrings = { end end]], - ['soulshards'] = [[function() + ["soulshards"] = [[function() local num = UnitPower('player', Enum.PowerType.SoulShards) if(num > 0) then return num end end]], - ['status'] = [[function(u) + ["status"] = [[function(u) if(UnitIsDead(u)) then return 'Dead' elseif(UnitIsGhost(u)) then @@ -456,7 +456,7 @@ local tagStrings = { end end]], - ['threat'] = [[function(u) + ["threat"] = [[function(u) local s = UnitThreatSituation(u) if(s == 1) then return '++' @@ -467,62 +467,59 @@ local tagStrings = { end end]], - ['threatcolor'] = [[function(u) + ["threatcolor"] = [[function(u) return Hex(GetThreatStatusColor(UnitThreatSituation(u) or 0)) end]], } -local tagFuncs = setmetatable( - { - curhp = UnitHealth, - curpp = UnitPower, - maxhp = UnitHealthMax, - maxpp = UnitPowerMax, - class = UnitClass, - faction = UnitFactionGroup, - race = UnitRace, - }, - { - __index = function(self, key) - local tagString = tagStrings[key] - if(tagString) then - self[key] = tagString - tagStrings[key] = nil - end - - return rawget(self, key) - end, - __newindex = function(self, key, val) - if(type(val) == 'string') then - local func, err = loadstring('return ' .. val) - if(func) then - val = func() - else - error(err, 3) - end +local tagFuncs = setmetatable({ + curhp = UnitHealth, + curpp = UnitPower, + maxhp = UnitHealthMax, + maxpp = UnitPowerMax, + class = UnitClass, + faction = UnitFactionGroup, + race = UnitRace, +}, { + __index = function(self, key) + local tagString = tagStrings[key] + if tagString then + self[key] = tagString + tagStrings[key] = nil + end + + return rawget(self, key) + end, + __newindex = function(self, key, val) + if type(val) == "string" then + local func, err = loadstring("return " .. val) + if func then + val = func() + else + error(err, 3) end + end - assert(type(val) == 'function', 'Tag function must be a function or a string that evaluates to a function.') + assert(type(val) == "function", "Tag function must be a function or a string that evaluates to a function.") - -- We don't want to clash with any custom envs - if(getfenv(val) == _G) then - -- pcall is needed for cases when Blizz functions are passed as strings, for - -- intance, 'UnitPowerMax', an attempt to set a custom env will result in an error - pcall(setfenv, val, _PROXY) - end + -- We don't want to clash with any custom envs + if getfenv(val) == _G then + -- pcall is needed for cases when Blizz functions are passed as strings, for + -- intance, 'UnitPowerMax', an attempt to set a custom env will result in an error + pcall(setfenv, val, _PROXY) + end - rawset(self, key, val) - end, - } -) + rawset(self, key, val) + end, +}) _ENV._TAGS = tagFuncs local vars = setmetatable({}, { __newindex = function(self, key, val) - if(type(val) == 'string') then - local func = loadstring('return ' .. val) - if(func) then + if type(val) == "string" then + local func = loadstring("return " .. val) + if func then val = func() or val end end @@ -534,45 +531,45 @@ local vars = setmetatable({}, { _ENV._VARS = vars local tagEvents = { - ['affix'] = 'UNIT_CLASSIFICATION_CHANGED', - ['arcanecharges'] = 'UNIT_POWER_UPDATE PLAYER_TALENT_UPDATE', - ['arenaspec'] = 'ARENA_PREP_OPPONENT_SPECIALIZATIONS', - ['chi'] = 'UNIT_POWER_UPDATE PLAYER_TALENT_UPDATE', - ['classification'] = 'UNIT_CLASSIFICATION_CHANGED', - ['cpoints'] = 'UNIT_POWER_FREQUENT PLAYER_TARGET_CHANGED', - ['curhp'] = 'UNIT_HEALTH UNIT_MAXHEALTH', - ['curmana'] = 'UNIT_POWER_UPDATE UNIT_MAXPOWER', - ['curpp'] = 'UNIT_POWER_UPDATE UNIT_MAXPOWER', - ['dead'] = 'UNIT_HEALTH', - ['deficit:name'] = 'UNIT_HEALTH UNIT_MAXHEALTH UNIT_NAME_UPDATE', - ['difficulty'] = 'UNIT_FACTION', - ['faction'] = 'NEUTRAL_FACTION_SELECT_RESULT', - ['group'] = 'GROUP_ROSTER_UPDATE', - ['holypower'] = 'UNIT_POWER_UPDATE PLAYER_TALENT_UPDATE', - ['leader'] = 'PARTY_LEADER_CHANGED', - ['leaderlong'] = 'PARTY_LEADER_CHANGED', - ['level'] = 'UNIT_LEVEL PLAYER_LEVEL_UP', - ['maxhp'] = 'UNIT_MAXHEALTH', - ['maxmana'] = 'UNIT_POWER_UPDATE UNIT_MAXPOWER', - ['maxpp'] = 'UNIT_MAXPOWER', - ['missinghp'] = 'UNIT_HEALTH UNIT_MAXHEALTH', - ['missingpp'] = 'UNIT_MAXPOWER UNIT_POWER_UPDATE', - ['name'] = 'UNIT_NAME_UPDATE', - ['offline'] = 'UNIT_HEALTH UNIT_CONNECTION', - ['perhp'] = 'UNIT_HEALTH UNIT_MAXHEALTH', - ['perpp'] = 'UNIT_MAXPOWER UNIT_POWER_UPDATE', - ['plus'] = 'UNIT_CLASSIFICATION_CHANGED', - ['powercolor'] = 'UNIT_DISPLAYPOWER', - ['pvp'] = 'UNIT_FACTION', - ['rare'] = 'UNIT_CLASSIFICATION_CHANGED', - ['resting'] = 'PLAYER_UPDATE_RESTING', - ['runes'] = 'RUNE_POWER_UPDATE', - ['shortclassification'] = 'UNIT_CLASSIFICATION_CHANGED', - ['smartlevel'] = 'UNIT_LEVEL PLAYER_LEVEL_UP UNIT_CLASSIFICATION_CHANGED', - ['soulshards'] = 'UNIT_POWER_UPDATE', - ['status'] = 'UNIT_HEALTH PLAYER_UPDATE_RESTING UNIT_CONNECTION', - ['threat'] = 'UNIT_THREAT_SITUATION_UPDATE', - ['threatcolor'] = 'UNIT_THREAT_SITUATION_UPDATE', + ["affix"] = "UNIT_CLASSIFICATION_CHANGED", + ["arcanecharges"] = "UNIT_POWER_UPDATE PLAYER_TALENT_UPDATE", + ["arenaspec"] = "ARENA_PREP_OPPONENT_SPECIALIZATIONS", + ["chi"] = "UNIT_POWER_UPDATE PLAYER_TALENT_UPDATE", + ["classification"] = "UNIT_CLASSIFICATION_CHANGED", + ["cpoints"] = "UNIT_POWER_FREQUENT PLAYER_TARGET_CHANGED", + ["curhp"] = "UNIT_HEALTH UNIT_MAXHEALTH", + ["curmana"] = "UNIT_POWER_UPDATE UNIT_MAXPOWER", + ["curpp"] = "UNIT_POWER_UPDATE UNIT_MAXPOWER", + ["dead"] = "UNIT_HEALTH", + ["deficit:name"] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_NAME_UPDATE", + ["difficulty"] = "UNIT_FACTION", + ["faction"] = "NEUTRAL_FACTION_SELECT_RESULT", + ["group"] = "GROUP_ROSTER_UPDATE", + ["holypower"] = "UNIT_POWER_UPDATE PLAYER_TALENT_UPDATE", + ["leader"] = "PARTY_LEADER_CHANGED", + ["leaderlong"] = "PARTY_LEADER_CHANGED", + ["level"] = "UNIT_LEVEL PLAYER_LEVEL_UP", + ["maxhp"] = "UNIT_MAXHEALTH", + ["maxmana"] = "UNIT_POWER_UPDATE UNIT_MAXPOWER", + ["maxpp"] = "UNIT_MAXPOWER", + ["missinghp"] = "UNIT_HEALTH UNIT_MAXHEALTH", + ["missingpp"] = "UNIT_MAXPOWER UNIT_POWER_UPDATE", + ["name"] = "UNIT_NAME_UPDATE", + ["offline"] = "UNIT_HEALTH UNIT_CONNECTION", + ["perhp"] = "UNIT_HEALTH UNIT_MAXHEALTH", + ["perpp"] = "UNIT_MAXPOWER UNIT_POWER_UPDATE", + ["plus"] = "UNIT_CLASSIFICATION_CHANGED", + ["powercolor"] = "UNIT_DISPLAYPOWER", + ["pvp"] = "UNIT_FACTION", + ["rare"] = "UNIT_CLASSIFICATION_CHANGED", + ["resting"] = "PLAYER_UPDATE_RESTING", + ["runes"] = "RUNE_POWER_UPDATE", + ["shortclassification"] = "UNIT_CLASSIFICATION_CHANGED", + ["smartlevel"] = "UNIT_LEVEL PLAYER_LEVEL_UP UNIT_CLASSIFICATION_CHANGED", + ["soulshards"] = "UNIT_POWER_UPDATE", + ["status"] = "UNIT_HEALTH PLAYER_UPDATE_RESTING UNIT_CONNECTION", + ["threat"] = "UNIT_THREAT_SITUATION_UPDATE", + ["threatcolor"] = "UNIT_THREAT_SITUATION_UPDATE", } local unitlessEvents = { @@ -590,12 +587,12 @@ local unitlessEvents = { local eventFontStrings = {} local stringsToUpdate = {} -local eventFrame = CreateFrame('Frame') -eventFrame:SetScript('OnEvent', function(self, event, unit) +local eventFrame = CreateFrame("Frame") +eventFrame:SetScript("OnEvent", function(self, event, unit) local strings = eventFontStrings[event] - if(strings) then + if strings then for fs in next, strings do - if(not stringsToUpdate[fs] and fs:IsVisible() and (unitlessEvents[event] or fs.parent.unit == unit or (fs.extraUnits and fs.extraUnits[unit]))) then + if not stringsToUpdate[fs] and fs:IsVisible() and (unitlessEvents[event] or fs.parent.unit == unit or (fs.extraUnits and fs.extraUnits[unit])) then stringsToUpdate[fs] = true end end @@ -605,11 +602,11 @@ end) local eventTimer = 0 local eventTimerThreshold = 0.1 -eventFrame:SetScript('OnUpdate', function(self, elapsed) +eventFrame:SetScript("OnUpdate", function(self, elapsed) eventTimer = eventTimer + elapsed - if(eventTimer >= eventTimerThreshold) then + if eventTimer >= eventTimerThreshold then for fs in next, stringsToUpdate do - if(fs:IsVisible()) then + if fs:IsVisible() then fs:UpdateTag() end end @@ -625,15 +622,15 @@ local timerFontStrings = {} local function enableTimer(timer) local frame = timerFrames[timer] - if(not frame) then + if not frame then local total = timer local strings = timerFontStrings[timer] - frame = CreateFrame('Frame') - frame:SetScript('OnUpdate', function(self, elapsed) - if(total >= timer) then + frame = CreateFrame("Frame") + frame:SetScript("OnUpdate", function(self, elapsed) + if total >= timer then for fs in next, strings do - if(fs.parent:IsShown() and unitExists(fs.parent.unit)) then + if fs.parent:IsShown() and unitExists(fs.parent.unit) then fs:UpdateTag() end end @@ -652,7 +649,7 @@ end local function disableTimer(timer) local frame = timerFrames[timer] - if(frame) then + if frame then frame:Hide() end end @@ -663,7 +660,7 @@ Used to update all tags on a frame. * self - the unit frame from which to update the tags --]] local function Update(self) - if(self.__tags) then + if self.__tags then for fs in next, self.__tags do fs:UpdateTag() end @@ -676,18 +673,18 @@ local bracketData = {} local function getBracketData(bracket) local data = bracketData[bracket] - if(not data) then - local prefixEnd, prefixOffset = bracket:match('()$>'), 1 - if(not prefixEnd) then + if not data then + local prefixEnd, prefixOffset = bracket:match("()$>"), 1 + if not prefixEnd then prefixEnd = 1 else prefixEnd = prefixEnd - 1 prefixOffset = 3 end - local suffixEnd = (bracket:match('()%(', prefixOffset + 1) or -1) - 1 - local suffixStart, suffixOffset = bracket:match('<$()', prefixEnd), 1 - if(not suffixStart) then + local suffixEnd = (bracket:match("()%(", prefixOffset + 1) or -1) - 1 + local suffixStart, suffixOffset = bracket:match("<$()", prefixEnd), 1 + if not suffixStart then suffixStart = suffixEnd + 1 else suffixOffset = 3 @@ -698,7 +695,7 @@ local function getBracketData(bracket) prefixEnd, suffixStart, suffixEnd, - bracket:match('%((.-)%)', suffixOffset + 1), + bracket:match("%((.-)%)", suffixOffset + 1), } bracketData[bracket] = data @@ -714,42 +711,42 @@ local buffer = {} local function getTagFunc(tagstr) local func = tagStringFuncs[tagstr] - if(not func) then - local format, num = tagstr:gsub('%%', '%%%%'):gsub(_PATTERN, '%%s') + if not func then + local format, num = tagstr:gsub("%%", "%%%%"):gsub(_PATTERN, "%%s") local funcs = {} for bracket in tagstr:gmatch(_PATTERN) do local tagFunc = bracketFuncs[bracket] or tagFuncs[bracket:sub(2, -2)] - if(not tagFunc) then + if not tagFunc then local tagName, prefixEnd, suffixStart, suffixEnd, customArgs = getBracketData(bracket) local tag = tagFuncs[tagName] - if(tag) then - if(prefixEnd ~= 1 or suffixStart - suffixEnd ~= 1) then - local prefix = prefixEnd ~= 1 and bracket:sub(2, prefixEnd) or '' - local suffix = suffixStart - suffixEnd ~= 1 and bracket:sub(suffixStart, suffixEnd) or '' + if tag then + if prefixEnd ~= 1 or suffixStart - suffixEnd ~= 1 then + local prefix = prefixEnd ~= 1 and bracket:sub(2, prefixEnd) or "" + local suffix = suffixStart - suffixEnd ~= 1 and bracket:sub(suffixStart, suffixEnd) or "" tagFunc = function(unit, realUnit) local str - if(customArgs) then - str = tag(unit, realUnit, string.split(',', customArgs)) + if customArgs then + str = tag(unit, realUnit, string.split(",", customArgs)) else str = tag(unit, realUnit) end - if(str and str ~= '') then + if str and str ~= "" then return prefix .. str .. suffix end end else tagFunc = function(unit, realUnit) local str - if(customArgs) then - str = tag(unit, realUnit, string.split(',', customArgs)) + if customArgs then + str = tag(unit, realUnit, string.split(",", customArgs)) else str = tag(unit, realUnit) end - if(str and str ~= '') then + if str and str ~= "" then return str end end @@ -759,15 +756,15 @@ local function getTagFunc(tagstr) end end - if(not tagFunc) then - nierror(string.format('Attempted to use invalid tag %s.', bracket)) + if not tagFunc then + nierror(string.format("Attempted to use invalid tag %s.", bracket)) -- don't check for these earlier in the function because a valid tag under the same -- name could've been created at some point tagFunc = invalidBrackets[bracket] - if(not tagFunc) then + if not tagFunc then tagFunc = function() - return '|cffffffff' .. bracket .. '|r' + return "|cffffffff" .. bracket .. "|r" end invalidBrackets[bracket] = tagFunc @@ -781,7 +778,7 @@ local function getTagFunc(tagstr) local parent = self.parent local unit = parent.unit local realUnit - if(self.overrideUnit) then + if self.overrideUnit then realUnit = parent.realUnit end @@ -789,7 +786,7 @@ local function getTagFunc(tagstr) _ENV._FRAME = parent for i, f in next, funcs do - buffer[i] = f(unit, realUnit) or '' + buffer[i] = f(unit, realUnit) or "" end -- we do 1 to num because buffer is shared by all tags and can hold several unneeded vars @@ -803,8 +800,8 @@ local function getTagFunc(tagstr) end local function registerEvent(event, fs) - if(validateEvent(event)) then - if(not eventFontStrings[event]) then + if validateEvent(event) then + if not eventFontStrings[event] then eventFontStrings[event] = {} end @@ -817,8 +814,8 @@ end local function registerEvents(fs, ts) for tag in ts:gmatch(_PATTERN) do local tagevents = tagEvents[getBracketData(tag)] - if(tagevents) then - for event in tagevents:gmatch('%S+') do + if tagevents then + for event in tagevents:gmatch("%S+") do registerEvent(event, fs) end end @@ -829,14 +826,14 @@ local function unregisterEvents(fs) for event, strings in next, eventFontStrings do strings[fs] = nil - if(not next(strings)) then + if not next(strings) then eventFrame:UnregisterEvent(event) end end end local function registerTimer(fs, timer) - if(not timerFontStrings[timer]) then + if not timerFontStrings[timer] then timerFontStrings[timer] = {} end @@ -849,7 +846,7 @@ local function unregisterTimer(fs) for timer, strings in next, timerFontStrings do strings[fs] = nil - if(not next(strings)) then + if not next(strings) then disableTimer(timer) end end @@ -866,12 +863,14 @@ Used to register a tag on a unit frame. * ... - additional optional unitID(s) the tag should update for --]] local function Tag(self, fs, ts, ...) - if(not fs or not ts) then return end + if not fs or not ts then + return + end - if(not self.__tags) then + if not self.__tags then self.__tags = {} table.insert(self.__elements, Update) - elseif(self.__tags[fs]) then + elseif self.__tags[fs] then -- We don't need to remove it from the __tags table as Untag handles that for us. self:Untag(fs) end @@ -879,9 +878,9 @@ local function Tag(self, fs, ts, ...) fs.parent = self fs.UpdateTag = getTagFunc(ts) - if(self.__eventless or fs.frequentUpdates) then + if self.__eventless or fs.frequentUpdates then local timer = 0.5 - if(type(fs.frequentUpdates) == 'number') then + if type(fs.frequentUpdates) == "number" then timer = fs.frequentUpdates end @@ -889,12 +888,12 @@ local function Tag(self, fs, ts, ...) else registerEvents(fs, ts) - if(...) then - if(not fs.extraUnits) then + if ... then + if not fs.extraUnits then fs.extraUnits = {} end - for index = 1, select('#', ...) do + for index = 1, select("#", ...) do fs.extraUnits[select(index, ...)] = true end end @@ -911,7 +910,9 @@ Used to unregister a tag from a unit frame. * fs - the font string holding the tag (FontString) --]] local function Untag(self, fs) - if(not fs or not self.__tags) then return end + if not fs or not self.__tags then + return + end unregisterEvents(fs) unregisterTimer(fs) @@ -924,7 +925,7 @@ end local function strip(tag) -- remove prefix, custom args, and suffix - return tag:gsub('%[.-$>', '['):gsub('%(.-%)%]', ']'):gsub('<$.-%]', ']') + return tag:gsub("%[.-$>", "["):gsub("%(.-%)%]", "]"):gsub("<$.-%]", "]") end oUF.Tags = { @@ -933,27 +934,29 @@ oUF.Tags = { SharedEvents = unitlessEvents, Vars = vars, RefreshMethods = function(self, tag) - if(not tag) then return end + if not tag then + return + end -- if a tag's name contains magic chars, there's a chance that string.match will fail to -- find the match - tag = '%[' .. tag:gsub('[%^%$%(%)%%%.%*%+%-%?]', '%%%1') .. '%]' + tag = "%[" .. tag:gsub("[%^%$%(%)%%%.%*%+%-%?]", "%%%1") .. "%]" for bracket in next, bracketFuncs do - if(strip(bracket):match(tag)) then + if strip(bracket):match(tag) then bracketFuncs[bracket] = nil end end for tagstr, func in next, tagStringFuncs do - if(strip(tagstr):match(tag)) then + if strip(tagstr):match(tag) then tagStringFuncs[tagstr] = nil for fs in next, taggedFontStrings do - if(fs.UpdateTag == func) then + if fs.UpdateTag == func then fs.UpdateTag = getTagFunc(tagstr) - if(fs:IsVisible()) then + if fs:IsVisible() then fs:UpdateTag() end end @@ -962,16 +965,18 @@ oUF.Tags = { end end, RefreshEvents = function(self, tag) - if(not tag) then return end + if not tag then + return + end -- if a tag's name contains magic chars, there's a chance that string.match will fail to -- find the match - tag = '%[' .. tag:gsub('[%^%$%(%)%%%.%*%+%-%?]', '%%%1') .. '%]' + tag = "%[" .. tag:gsub("[%^%$%(%)%%%.%*%+%-%?]", "%%%1") .. "%]" for tagstr in next, tagStringFuncs do - if(strip(tagstr):match(tag)) then + if strip(tagstr):match(tag) then for fs, ts in next, taggedFontStrings do - if(ts == tagstr) then + if ts == tagstr then unregisterEvents(fs) registerEvents(fs, tagstr) end @@ -980,13 +985,17 @@ oUF.Tags = { end end, SetEventUpdateTimer = function(self, timer) - if(not timer) then return end - if(type(timer) ~= 'number') then return end + if not timer then + return + end + if type(timer) ~= "number" then + return + end eventTimerThreshold = math.max(0.05, timer) end, } -oUF:RegisterMetaFunction('Tag', Tag) -oUF:RegisterMetaFunction('Untag', Untag) -oUF:RegisterMetaFunction('UpdateTags', Update) \ No newline at end of file +oUF:RegisterMetaFunction("Tag", Tag) +oUF:RegisterMetaFunction("Untag", Untag) +oUF:RegisterMetaFunction("UpdateTags", Update) diff --git a/KkthnxUI/Libraries/oUF/elements/threatindicator.lua b/KkthnxUI/Libraries/oUF/elements/threatindicator.lua index 4e571eabb..6890763ee 100644 --- a/KkthnxUI/Libraries/oUF/elements/threatindicator.lua +++ b/KkthnxUI/Libraries/oUF/elements/threatindicator.lua @@ -35,7 +35,9 @@ local Private = oUF.Private local unitExists = Private.unitExists local function Update(self, event, unit) - if(unit ~= self.unit) then return end + if unit ~= self.unit then + return + end local element = self.ThreatIndicator --[[ Callback: ThreatIndicator:PreUpdate(unit) @@ -44,15 +46,17 @@ local function Update(self, event, unit) * self - the ThreatIndicator element * unit - the unit for which the update has been triggered (string) --]] - if(element.PreUpdate) then element:PreUpdate(unit) end + if element.PreUpdate then + element:PreUpdate(unit) + end local feedbackUnit = element.feedbackUnit unit = unit or self.unit local status -- BUG: Non-existent '*target' or '*pet' units cause UnitThreatSituation() errors - if(unitExists(unit)) then - if(feedbackUnit and feedbackUnit ~= unit and unitExists(feedbackUnit)) then + if unitExists(unit) then + if feedbackUnit and feedbackUnit ~= unit and unitExists(feedbackUnit) then status = UnitThreatSituation(feedbackUnit, unit) else status = UnitThreatSituation(unit) @@ -60,11 +64,11 @@ local function Update(self, event, unit) end local r, g, b - if(status and status > 0) then + if status and status > 0 then local color = self.colors.threat[status] r, g, b = color[1], color[2], color[3] - if(element.SetVertexColor) then + if element.SetVertexColor then element:SetVertexColor(r, g, b) end @@ -83,7 +87,7 @@ local function Update(self, event, unit) * g - the green color component based on the unit's threat status (number?)[0-1] * b - the blue color component based on the unit's threat status (number?)[0-1] --]] - if(element.PostUpdate) then + if element.PostUpdate then return element:PostUpdate(unit, status, r, g, b) end end @@ -96,23 +100,23 @@ local function Path(self, ...) * event - the event triggering the update (string) * ... - the arguments accompanying the event --]] - return (self.ThreatIndicator.Override or Update) (self, ...) + return (self.ThreatIndicator.Override or Update)(self, ...) end local function ForceUpdate(element) - return Path(element.__owner, 'ForceUpdate', element.__owner.unit) + return Path(element.__owner, "ForceUpdate", element.__owner.unit) end local function Enable(self) local element = self.ThreatIndicator - if(element) then + if element then element.__owner = self element.ForceUpdate = ForceUpdate - self:RegisterEvent('UNIT_THREAT_SITUATION_UPDATE', Path) - self:RegisterEvent('UNIT_THREAT_LIST_UPDATE', Path) + self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", Path) + self:RegisterEvent("UNIT_THREAT_LIST_UPDATE", Path) - if(element:IsObjectType('Texture') and not element:GetTexture()) then + if element:IsObjectType("Texture") and not element:GetTexture() then element:SetTexture([[Interface\RAIDFRAME\UI-RaidFrame-Threat]]) end @@ -122,12 +126,12 @@ end local function Disable(self) local element = self.ThreatIndicator - if(element) then + if element then element:Hide() - self:UnregisterEvent('UNIT_THREAT_SITUATION_UPDATE', Path) - self:UnregisterEvent('UNIT_THREAT_LIST_UPDATE', Path) + self:UnregisterEvent("UNIT_THREAT_SITUATION_UPDATE", Path) + self:UnregisterEvent("UNIT_THREAT_LIST_UPDATE", Path) end end -oUF:AddElement('ThreatIndicator', Path, Enable, Disable) \ No newline at end of file +oUF:AddElement("ThreatIndicator", Path, Enable, Disable) diff --git a/KkthnxUI/Libraries/oUF/events.lua b/KkthnxUI/Libraries/oUF/events.lua index e194a004e..abb41edff 100644 --- a/KkthnxUI/Libraries/oUF/events.lua +++ b/KkthnxUI/Libraries/oUF/events.lua @@ -18,29 +18,29 @@ local isEventRegistered = frame_metatable.__index.IsEventRegistered -- a specific combination of primary and secondary units local secondaryUnits = { UNIT_ENTERED_VEHICLE = { - pet = 'player', + pet = "player", }, UNIT_EXITED_VEHICLE = { - pet = 'player', + pet = "player", }, UNIT_PET = { - pet = 'player', + pet = "player", }, } function Private.UpdateUnits(frame, unit, realUnit) - if(unit == realUnit) then + if unit == realUnit then realUnit = nil end - if(frame.unit ~= unit or frame.realUnit ~= realUnit) then + if frame.unit ~= unit or frame.realUnit ~= realUnit then -- don't let invalid units in, otherwise unit events will end up being -- registered as unitless - if(frame.unitEvents and validateUnit(unit)) then + if frame.unitEvents and validateUnit(unit) then local resetRealUnit = false for event in next, frame.unitEvents do - if(not realUnit and secondaryUnits[event]) then + if not realUnit and secondaryUnits[event] then realUnit = secondaryUnits[event][unit] resetRealUnit = true end @@ -48,11 +48,11 @@ function Private.UpdateUnits(frame, unit, realUnit) local registered, unit1, unit2 = isEventRegistered(frame, event) -- we don't want to re-register unitless/shared events in case -- someone added them by hand to the unitEvents table - if(not registered or unit1 and (unit1 ~= unit or unit2 ~= realUnit)) then + if not registered or unit1 and (unit1 ~= unit or unit2 ~= realUnit) then registerUnitEvent(frame, event, unit, realUnit) end - if(resetRealUnit) then + if resetRealUnit then realUnit = nil resetRealUnit = false end @@ -61,14 +61,14 @@ function Private.UpdateUnits(frame, unit, realUnit) frame.unit = unit frame.realUnit = realUnit - frame.id = unit:match('^.-(%d+)') + frame.id = unit:match("^.-(%d+)") return true end end local function onEvent(self, event, ...) - if(self:IsVisible()) then + if self:IsVisible() then return self[event](self, event, ...) end end @@ -96,40 +96,44 @@ function frame_metatable.__index:RegisterEvent(event, func, unitless) -- Block OnUpdate polled frames from registering events except for -- UNIT_PORTRAIT_UPDATE and UNIT_MODEL_CHANGED which are used for -- portrait updates. - if(self.__eventless and event ~= 'UNIT_PORTRAIT_UPDATE' and event ~= 'UNIT_MODEL_CHANGED') then return end + if self.__eventless and event ~= "UNIT_PORTRAIT_UPDATE" and event ~= "UNIT_MODEL_CHANGED" then + return + end - argcheck(event, 2, 'string') - argcheck(func, 3, 'function') + argcheck(event, 2, "string") + argcheck(func, 3, "function") local curev = self[event] - if(curev) then + if curev then local kind = type(curev) - if(kind == 'function' and curev ~= func) then - self[event] = setmetatable({curev, func}, event_metatable) - elseif(kind == 'table') then + if kind == "function" and curev ~= func then + self[event] = setmetatable({ curev, func }, event_metatable) + elseif kind == "table" then for _, infunc in next, curev do - if(infunc == func) then return end + if infunc == func then + return + end end table.insert(curev, func) end - if(unitless or self.__eventless) then + if unitless or self.__eventless then -- re-register the event in case we have mixed registration registerEvent(self, event) - if(self.unitEvents) then + if self.unitEvents then self.unitEvents[event] = nil end end - elseif(validateEvent(event)) then + elseif validateEvent(event) then self[event] = func - if(not self:GetScript('OnEvent')) then - self:SetScript('OnEvent', onEvent) + if not self:GetScript("OnEvent") then + self:SetScript("OnEvent", onEvent) end - if(unitless or self.__eventless) then + if unitless or self.__eventless then registerEvent(self, event) else self.unitEvents = self.unitEvents or {} @@ -138,8 +142,8 @@ function frame_metatable.__index:RegisterEvent(event, func, unitless) -- UpdateUnits will take care of unit event registration for header -- units in case we don't have a valid unit yet local unit1, unit2 = self.unit - if(unit1 and validateUnit(unit1)) then - if(secondaryUnits[event]) then + if unit1 and validateUnit(unit1) then + if secondaryUnits[event] then unit2 = secondaryUnits[event][unit1] end @@ -147,7 +151,7 @@ function frame_metatable.__index:RegisterEvent(event, func, unitless) -- an event that is unitless assert(isUnitEvent(event, unit1), string.format('Event "%s" is not an unit event', event)) - registerUnitEvent(self, event, unit1, unit2 or '') + registerUnitEvent(self, event, unit1, unit2 or "") end end end @@ -162,30 +166,30 @@ Used to remove a function from the event handler list for a game event. the frame will be unregistered for the event (function) --]] function frame_metatable.__index:UnregisterEvent(event, func) - argcheck(event, 2, 'string') + argcheck(event, 2, "string") local cleanUp = false local curev = self[event] - if(type(curev) == 'table' and func) then + if type(curev) == "table" and func then for k, infunc in next, curev do - if(infunc == func) then + if infunc == func then curev[k] = nil break end end - if(not next(curev)) then + if not next(curev) then cleanUp = true end end - if(cleanUp or curev == func) then + if cleanUp or curev == func then self[event] = nil - if(self.unitEvents) then + if self.unitEvents then self.unitEvents[event] = nil end unregisterEvent(self, event) end -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/oUF/factory.lua b/KkthnxUI/Libraries/oUF/factory.lua index 06697a954..bd5c16257 100644 --- a/KkthnxUI/Libraries/oUF/factory.lua +++ b/KkthnxUI/Libraries/oUF/factory.lua @@ -5,16 +5,18 @@ local Private = oUF.Private local argcheck = Private.argcheck local queue = {} -local factory = CreateFrame('Frame') -factory:SetScript('OnEvent', function(self, event, ...) +local factory = CreateFrame("Frame") +factory:SetScript("OnEvent", function(self, event, ...) return self[event](self, event, ...) end) -factory:RegisterEvent('PLAYER_LOGIN') +factory:RegisterEvent("PLAYER_LOGIN") factory.active = true function factory:PLAYER_LOGIN() - if(not self.active) then return end + if not self.active then + return + end for _, func in next, queue do func(oUF) @@ -32,10 +34,10 @@ queued up to be executed at a later time (upon PLAYER_LOGIN by default). * func - function to be executed or delayed (function) --]] function oUF:Factory(func) - argcheck(func, 2, 'function') + argcheck(func, 2, "function") -- Call the function directly if we're active and logged in. - if(IsLoggedIn() and factory.active) then + if IsLoggedIn() and factory.active then return func(self) else table.insert(queue, func) @@ -68,4 +70,4 @@ this to succeed. --]] function oUF:RunFactoryQueue() factory:PLAYER_LOGIN() -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/oUF/finalize.lua b/KkthnxUI/Libraries/oUF/finalize.lua index bd686c10a..55119b8aa 100644 --- a/KkthnxUI/Libraries/oUF/finalize.lua +++ b/KkthnxUI/Libraries/oUF/finalize.lua @@ -1,4 +1,4 @@ local _, ns = ... -- It's named Private for a reason! -ns.oUF.Private = nil \ No newline at end of file +ns.oUF.Private = nil diff --git a/KkthnxUI/Libraries/oUF/init.lua b/KkthnxUI/Libraries/oUF/init.lua index 8572997d0..3684275cd 100644 --- a/KkthnxUI/Libraries/oUF/init.lua +++ b/KkthnxUI/Libraries/oUF/init.lua @@ -1,3 +1,3 @@ local _, ns = ... ns.oUF = {} -ns.oUF.Private = {} \ No newline at end of file +ns.oUF.Private = {} diff --git a/KkthnxUI/Libraries/oUF/ouf.lua b/KkthnxUI/Libraries/oUF/ouf.lua index e04913515..6fc8d6c63 100644 --- a/KkthnxUI/Libraries/oUF/ouf.lua +++ b/KkthnxUI/Libraries/oUF/ouf.lua @@ -1,8 +1,8 @@ local parent, ns = ... -local global = C_AddOns.GetAddOnMetadata(parent, 'X-oUF') -local _VERSION = '10.1.1' -if(_VERSION:find('project%-version')) then - _VERSION = 'devel' +local global = C_AddOns.GetAddOnMetadata(parent, "X-oUF") +local _VERSION = "10.1.1" +if _VERSION:find("project%-version") then + _VERSION = "devel" end local oUF = ns.oUF @@ -19,137 +19,147 @@ local callback, objects, headers = {}, {}, {} local elements = {} local activeElements = {} -local PetBattleFrameHider = CreateFrame('Frame', (global or parent) .. '_PetBattleFrameHider', UIParent, 'SecureHandlerStateTemplate') +local PetBattleFrameHider = CreateFrame("Frame", (global or parent) .. "_PetBattleFrameHider", UIParent, "SecureHandlerStateTemplate") PetBattleFrameHider:SetAllPoints() -PetBattleFrameHider:SetFrameStrata('LOW') -RegisterStateDriver(PetBattleFrameHider, 'visibility', '[petbattle] hide; show') +PetBattleFrameHider:SetFrameStrata("LOW") +RegisterStateDriver(PetBattleFrameHider, "visibility", "[petbattle] hide; show") local function updateActiveUnit(self, event) -- Calculate units to work with local realUnit, modUnit = SecureButton_GetUnit(self), SecureButton_GetModifiedUnit(self) -- _GetUnit() doesn't rewrite playerpet -> pet like _GetModifiedUnit does. - if(realUnit == 'playerpet') then - realUnit = 'pet' - elseif(realUnit == 'playertarget') then - realUnit = 'target' + if realUnit == "playerpet" then + realUnit = "pet" + elseif realUnit == "playertarget" then + realUnit = "target" end - if(modUnit == 'pet' and realUnit ~= 'pet') then - modUnit = 'vehicle' + if modUnit == "pet" and realUnit ~= "pet" then + modUnit = "vehicle" end - if(not unitExists(modUnit)) then return end + if not unitExists(modUnit) then + return + end -- Change the active unit and run a full update. - if(Private.UpdateUnits(self, modUnit, realUnit)) then - self:UpdateAllElements(event or 'RefreshUnit') + if Private.UpdateUnits(self, modUnit, realUnit) then + self:UpdateAllElements(event or "RefreshUnit") return true end end local function evalUnitAndUpdate(self, event) - if(not updateActiveUnit(self, event)) then + if not updateActiveUnit(self, event) then return self:UpdateAllElements(event) end end local function iterateChildren(...) - for i = 1, select('#', ...) do + for i = 1, select("#", ...) do local obj = select(i, ...) - if(type(obj) == 'table' and obj.isChild) then - updateActiveUnit(obj, 'iterateChildren') + if type(obj) == "table" and obj.isChild then + updateActiveUnit(obj, "iterateChildren") end end end local function onAttributeChanged(self, name, value) - if(name == 'unit' and value) then - if(self.hasChildren) then + if name == "unit" and value then + if self.hasChildren then iterateChildren(self:GetChildren()) end - if(not self:GetAttribute('oUF-onlyProcessChildren')) then - updateActiveUnit(self, 'OnAttributeChanged') + if not self:GetAttribute("oUF-onlyProcessChildren") then + updateActiveUnit(self, "OnAttributeChanged") end end end local frame_metatable = { - __index = CreateFrame('Button') + __index = CreateFrame("Button"), } Private.frame_metatable = frame_metatable -for k, v in next, { - --[[ frame:EnableElement(name, unit) +for k, v in + next, + { + --[[ frame:EnableElement(name, unit) Used to activate an element for the given unit frame. * self - unit frame for which the element should be enabled * 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?) --]] - EnableElement = function(self, name, unit) - argcheck(name, 2, 'string') - argcheck(unit, 3, 'string', 'nil') + EnableElement = function(self, name, unit) + argcheck(name, 2, "string") + argcheck(unit, 3, "string", "nil") - local element = elements[name] - if(not element or self:IsElementEnabled(name)) then return end + local element = elements[name] + if not element or self:IsElementEnabled(name) then + return + end - if(element.enable(self, unit or self.unit)) then - activeElements[self][name] = true + if element.enable(self, unit or self.unit) then + activeElements[self][name] = true - if(element.update) then - table.insert(self.__elements, element.update) + if element.update then + table.insert(self.__elements, element.update) + end end - end - end, + end, - --[[ frame:DisableElement(name) + --[[ frame:DisableElement(name) Used to deactivate an element for the given unit frame. * self - unit frame for which the element should be disabled * name - name of the element to be disabled (string) --]] - DisableElement = function(self, name) - argcheck(name, 2, 'string') - - local enabled = self:IsElementEnabled(name) - if(not enabled) then return end - - local update = elements[name].update - if(update) then - for k, func in next, self.__elements do - if(func == update) then - table.remove(self.__elements, k) - break + DisableElement = function(self, name) + argcheck(name, 2, "string") + + local enabled = self:IsElementEnabled(name) + if not enabled then + return + end + + local update = elements[name].update + if update then + for k, func in next, self.__elements do + if func == update then + table.remove(self.__elements, k) + break + end end end - end - activeElements[self][name] = nil + activeElements[self][name] = nil - return elements[name].disable(self) - end, + return elements[name].disable(self) + end, - --[[ frame:IsElementEnabled(name) + --[[ frame:IsElementEnabled(name) Used to check if an element is enabled on the given frame. * self - unit frame * name - name of the element (string) --]] - IsElementEnabled = function(self, name) - argcheck(name, 2, 'string') + IsElementEnabled = function(self, name) + argcheck(name, 2, "string") - local element = elements[name] - if(not element) then return end + local element = elements[name] + if not element then + return + end - local active = activeElements[self] - return active and active[name] - end, + local active = activeElements[self] + return active and active[name] + end, - --[[ frame:Enable(asState) + --[[ frame:Enable(asState) Used to toggle the visibility of a unit frame based on the existence of its unit. This is a reference to `RegisterUnitWatch`. @@ -157,86 +167,91 @@ for k, v in next, { * 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) --]] - Enable = RegisterUnitWatch, - --[[ frame:Disable() + Enable = RegisterUnitWatch, + --[[ frame:Disable() Used to UnregisterUnitWatch for the given frame and hide it. * self - unit frame --]] - Disable = function(self) - UnregisterUnitWatch(self) - self:Hide() - end, - --[[ frame:IsEnabled() + Disable = function(self) + UnregisterUnitWatch(self) + self:Hide() + end, + --[[ frame:IsEnabled() Used to check if a unit frame is registered with the unit existence monitor. This is a reference to `UnitWatchRegistered`. * self - unit frame --]] - IsEnabled = UnitWatchRegistered, - --[[ frame:UpdateAllElements(event) + IsEnabled = UnitWatchRegistered, + --[[ frame:UpdateAllElements(event) Used to update all enabled elements on the given frame. * self - unit frame * event - event name to pass to the elements' update functions (string) --]] - UpdateAllElements = function(self, event) - local unit = self.unit - if(not unitExists(unit)) then return end + UpdateAllElements = function(self, event) + local unit = self.unit + 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 - --[[ Callback: frame:PreUpdate(event) + if self.PreUpdate then + --[[ Callback: frame:PreUpdate(event) Fired before the frame is updated. * self - the unit frame * event - the event triggering the update (string) --]] - self:PreUpdate(event) - end + self:PreUpdate(event) + end - for _, func in next, self.__elements do - func(self, event, unit) - end + for _, func in next, self.__elements do + func(self, event, unit) + end - if(self.PostUpdate) then - --[[ Callback: frame:PostUpdate(event) + if self.PostUpdate then + --[[ Callback: frame:PostUpdate(event) Fired after the frame is updated. * self - the unit frame * event - the event triggering the update (string) --]] - self:PostUpdate(event) - end - end, -} do + self:PostUpdate(event) + end + end, + } +do frame_metatable.__index[k] = v end local function onShow(self) - evalUnitAndUpdate(self, 'OnShow') + evalUnitAndUpdate(self, "OnShow") end local function updatePet(self, event, unit) local petUnit - if(unit == 'target') then + if unit == "target" then return - elseif(unit == 'player') then - petUnit = 'pet' + elseif unit == "player" then + petUnit = "pet" else -- Convert raid26 -> raidpet26 - petUnit = unit:gsub('^(%a+)(%d+)', '%1pet%2') + petUnit = unit:gsub("^(%a+)(%d+)", "%1pet%2") end - if(self.unit ~= petUnit) then return end + if self.unit ~= petUnit then + return + end evalUnitAndUpdate(self, event) end local function updateRaid(self, event) local unitGUID = UnitGUID(self.unit) - if(unitGUID and unitGUID ~= self.unitGUID) then + if unitGUID and unitGUID ~= self.unitGUID then self.unitGUID = unitGUID self:UpdateAllElements(event) @@ -252,19 +267,19 @@ local eventlessUnits = { } local function isEventlessUnit(unit) - return unit:match('%w+target') or eventlessUnits[unit] + return unit:match("%w+target") or eventlessUnits[unit] end local function initObject(unit, style, styleFunc, header, ...) - local num = select('#', ...) + local num = select("#", ...) for i = 1, num do local object = select(i, ...) - local objectUnit = object:GetAttribute('oUF-guessUnit') or unit - local suffix = object:GetAttribute('unitsuffix') + local objectUnit = object:GetAttribute("oUF-guessUnit") or unit + local suffix = object:GetAttribute("unitsuffix") -- Handle the case where someone has modified the unitsuffix attribute in -- oUF-initialConfigFunction. - if(suffix and not objectUnit:match(suffix)) then + if suffix and not objectUnit:match(suffix) then objectUnit = objectUnit .. suffix end @@ -282,27 +297,27 @@ local function initObject(unit, style, styleFunc, header, ...) -- delay between UNIT_EXITING_VEHICLE and UNIT_EXITED_VEHICLE during -- which a user can go through a loading screen after which the player -- frame will be stuck with the 'vehicle' unit. - object:RegisterEvent('PLAYER_ENTERING_WORLD', evalUnitAndUpdate, true) + object:RegisterEvent("PLAYER_ENTERING_WORLD", evalUnitAndUpdate, true) - if(not isEventlessUnit(objectUnit)) then - object:RegisterEvent('UNIT_ENTERED_VEHICLE', evalUnitAndUpdate) - object:RegisterEvent('UNIT_EXITED_VEHICLE', evalUnitAndUpdate) + if not isEventlessUnit(objectUnit) then + object:RegisterEvent("UNIT_ENTERED_VEHICLE", evalUnitAndUpdate) + object:RegisterEvent("UNIT_EXITED_VEHICLE", evalUnitAndUpdate) -- We don't need to register UNIT_PET for the player unit. We register it -- mainly because UNIT_EXITED_VEHICLE and UNIT_ENTERED_VEHICLE don't always -- have pet information when they fire for party and raid units. - if(objectUnit ~= 'player') then - object:RegisterEvent('UNIT_PET', updatePet) + if objectUnit ~= "player" then + object:RegisterEvent("UNIT_PET", updatePet) end end - if(not header) then + if not header then -- No header means it's a frame created through :Spawn(). - object:SetAttribute('*type1', 'target') - object:SetAttribute('*type2', 'togglemenu') - object:SetAttribute('toggleForVehicle', true) + object:SetAttribute("*type1", "target") + object:SetAttribute("*type2", "togglemenu") + object:SetAttribute("toggleForVehicle", true) - if(isEventlessUnit(objectUnit)) then + if isEventlessUnit(objectUnit) then oUF:HandleEventlessUnit(object) else oUF:HandleUnit(object) @@ -310,17 +325,17 @@ local function initObject(unit, style, styleFunc, header, ...) else -- update the frame when its prev unit is replaced with a new one -- updateRaid relies on UnitGUID to detect the unit change - object:RegisterEvent('GROUP_ROSTER_UPDATE', updateRaid, true) + object:RegisterEvent("GROUP_ROSTER_UPDATE", updateRaid, true) - if(num > 1) then - if(object:GetParent() == header) then + if num > 1 then + if object:GetParent() == header then object.hasChildren = true else object.isChild = true end end - if(suffix == 'target') then + if suffix == "target" then oUF:HandleEventlessUnit(object) end end @@ -329,12 +344,12 @@ local function initObject(unit, style, styleFunc, header, ...) styleFunc(object, objectUnit, not header) - object:HookScript('OnAttributeChanged', onAttributeChanged) + object:HookScript("OnAttributeChanged", onAttributeChanged) -- NAME_PLATE_UNIT_ADDED fires after the frame is shown, so there's no -- need to call UAE multiple times - if(not object.isNamePlate) then - object:SetScript('OnShow', onShow) + if not object.isNamePlate then + object:SetScript("OnShow", onShow) end activeElements[object] = {} @@ -347,7 +362,7 @@ local function initObject(unit, style, styleFunc, header, ...) end -- Make Clique kinda happy - if(not object.isNamePlate) then + if not object.isNamePlate then _G.ClickCastFrames = _G.ClickCastFrames or {} _G.ClickCastFrames[object] = true end @@ -359,12 +374,12 @@ local function walkObject(object, unit) local style = parent.style or style local styleFunc = styles[style] - local header = parent:GetAttribute('oUF-headerType') and parent + local header = parent:GetAttribute("oUF-headerType") and parent -- Check if we should leave the main frame blank. - if(object:GetAttribute('oUF-onlyProcessChildren')) then + if object:GetAttribute("oUF-onlyProcessChildren") then object.hasChildren = true - object:HookScript('OnAttributeChanged', onAttributeChanged) + object:HookScript("OnAttributeChanged", onAttributeChanged) return initObject(unit, style, styleFunc, header, object:GetChildren()) end @@ -389,10 +404,10 @@ Used to make a (table of) function(s) available to all unit frames. * func - function or a table of functions (function or table) --]] function oUF:RegisterMetaFunction(name, func) - argcheck(name, 2, 'string') - argcheck(func, 3, 'function', 'table') + argcheck(name, 2, "string") + argcheck(func, 3, "function", "table") - if(frame_metatable.__index[name]) then + if frame_metatable.__index[name] then return end @@ -407,11 +422,15 @@ Used to register a style with oUF. This will also set the active style if it has * func - function(s) defining the style (function or table) --]] function oUF:RegisterStyle(name, func) - argcheck(name, 2, 'string') - argcheck(func, 3, 'function', 'table') + argcheck(name, 2, "string") + argcheck(func, 3, "function", "table") - if(styles[name]) then return error('Style [%s] already registered.', name) end - if(not style) then style = name end + if styles[name] then + return error("Style [%s] already registered.", name) + end + if not style then + style = name + end styles[name] = func end @@ -423,8 +442,10 @@ Used to set the active style. * name - name of the style (string) --]] function oUF:SetActiveStyle(name) - argcheck(name, 2, 'string') - if(not styles[name]) then return error('Style [%s] does not exist.', name) end + argcheck(name, 2, "string") + if not styles[name] then + return error("Style [%s] does not exist.", name) + end style = name end @@ -457,87 +478,87 @@ end local getCondition do local conditions = { - raid40 = '[@raid26,exists] show;', - raid25 = '[@raid11,exists] show;', - raid10 = '[@raid6,exists] show;', - raid = '[group:raid] show;', - party = '[group:party,nogroup:raid] show;', - solo = '[@player,exists,nogroup:party] show;', + raid40 = "[@raid26,exists] show;", + raid25 = "[@raid11,exists] show;", + raid10 = "[@raid6,exists] show;", + raid = "[group:raid] show;", + party = "[group:party,nogroup:raid] show;", + solo = "[@player,exists,nogroup:party] show;", } function getCondition(...) - local cond = '' + local cond = "" - for i = 1, select('#', ...) do + for i = 1, select("#", ...) do local short = select(i, ...) local condition = conditions[short] - if(condition) then + if condition then cond = cond .. condition end end - return cond .. 'hide' + return cond .. "hide" end end local function generateName(unit, ...) - local name = 'oUF_' .. style:gsub('^oUF_?', ''):gsub('[^%a%d_]+', '') + local name = "oUF_" .. style:gsub("^oUF_?", ""):gsub("[^%a%d_]+", "") local raid, party, groupFilter, unitsuffix - for i = 1, select('#', ...), 2 do + for i = 1, select("#", ...), 2 do local att, val = select(i, ...) - if(att == 'oUF-initialConfigFunction') then - unitsuffix = val:match('unitsuffix[%p%s]+(%a+)') - elseif(att == 'showRaid') then + if att == "oUF-initialConfigFunction" then + unitsuffix = val:match("unitsuffix[%p%s]+(%a+)") + elseif att == "showRaid" then raid = val ~= false and val ~= nil - elseif(att == 'showParty') then + elseif att == "showParty" then party = val ~= false and val ~= nil - elseif(att == 'groupFilter') then + elseif att == "groupFilter" then groupFilter = val end end local append - if(raid) then - if(groupFilter) then - if(type(groupFilter) == 'number' and groupFilter > 0) then - append = 'Raid' .. groupFilter - elseif(groupFilter:match('MAINTANK')) then - append = 'MainTank' - elseif(groupFilter:match('MAINASSIST')) then - append = 'MainAssist' + if raid then + if groupFilter then + if type(groupFilter) == "number" and groupFilter > 0 then + append = "Raid" .. groupFilter + elseif groupFilter:match("MAINTANK") then + append = "MainTank" + elseif groupFilter:match("MAINASSIST") then + append = "MainAssist" else - local _, count = groupFilter:gsub(',', '') - if(count == 0) then - append = 'Raid' .. groupFilter + local _, count = groupFilter:gsub(",", "") + if count == 0 then + append = "Raid" .. groupFilter else - append = 'Raid' + append = "Raid" end end else - append = 'Raid' + append = "Raid" end - elseif(party) then - append = 'Party' - elseif(unit) then - append = unit:gsub('^%l', string.upper) + elseif party then + append = "Party" + elseif unit then + append = unit:gsub("^%l", string.upper) end - if(append) then - name = name .. append .. (unitsuffix or '') + if append then + name = name .. append .. (unitsuffix or "") end -- Change oUF_LilyRaidRaid into oUF_LilyRaid - name = name:gsub('(%u%l+)([%u%l]*)%1', '%1') + name = name:gsub("(%u%l+)([%u%l]*)%1", "%1") -- Change oUF_LilyTargettarget into oUF_LilyTargetTarget - name = name:gsub('t(arget)', 'T%1') - name = name:gsub('p(et)', 'P%1') - name = name:gsub('f(ocus)', 'F%1') + name = name:gsub("t(arget)", "T%1") + name = name:gsub("p(et)", "P%1") + name = name:gsub("f(ocus)", "F%1") local base = name local i = 2 - while(_G[name]) do + while _G[name] do name = base .. i i = i + 1 end @@ -631,25 +652,29 @@ do * oUF-onlyProcessChildren - can be used to force headers to only process children (boolean?) --]] 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 'SecureGroupHeaderTemplate') + template = (template or "SecureGroupHeaderTemplate") - local isPetHeader = template:match('PetHeader') + local isPetHeader = template:match("PetHeader") local name = overrideName or generateName(nil, ...) - local header = CreateFrame('Frame', name, PetBattleFrameHider, template) + local header = CreateFrame("Frame", name, PetBattleFrameHider, template) - header:SetAttribute('template', 'SecureUnitButtonTemplate, SecureHandlerStateTemplate, SecureHandlerEnterLeaveTemplate, PingableUnitFrameTemplate, SecureHandlerShowHideTemplate, SecureHandlerMouseUpDownTemplate') + header:SetAttribute("template", "SecureUnitButtonTemplate, SecureHandlerStateTemplate, SecureHandlerEnterLeaveTemplate, PingableUnitFrameTemplate, SecureHandlerShowHideTemplate, SecureHandlerMouseUpDownTemplate") - if(...) then - if(type(...) == 'table') then + if ... then + if type(...) == "table" then for att, val in next, (...) do header:SetAttribute(att, val) end else - for i = 1, select('#', ...), 2 do + for i = 1, select("#", ...), 2 do local att, val = select(i, ...) - if(not att) then break end + if not att then + break + end header:SetAttribute(att, val) end end @@ -663,54 +688,66 @@ do table.insert(headers, header) -- We set it here so layouts can't directly override it. - header:SetAttribute('initialConfigFunction', initialConfigFunction) - header:SetAttribute('_initialAttributeNames', '_onenter,_onleave,refreshUnitChange,_onstate-vehicleui') - header:SetAttribute('_initialAttribute-_onenter', [[ + header:SetAttribute("initialConfigFunction", initialConfigFunction) + header:SetAttribute("_initialAttributeNames", "_onenter,_onleave,refreshUnitChange,_onstate-vehicleui") + header:SetAttribute( + "_initialAttribute-_onenter", + [[ local snippet = self:GetAttribute('clickcast_onenter') if(snippet) then self:Run(snippet) end - ]]) - header:SetAttribute('_initialAttribute-_onleave', [[ + ]] + ) + header:SetAttribute( + "_initialAttribute-_onleave", + [[ local snippet = self:GetAttribute('clickcast_onleave') if(snippet) then self:Run(snippet) end - ]]) - header:SetAttribute('_initialAttribute-refreshUnitChange', [[ + ]] + ) + header:SetAttribute( + "_initialAttribute-refreshUnitChange", + [[ local unit = self:GetAttribute('unit') if(unit) then RegisterStateDriver(self, 'vehicleui', '[@' .. unit .. ',unithasvehicleui]vehicle; novehicle') else UnregisterStateDriver(self, 'vehicleui') end - ]]) - header:SetAttribute('_initialAttribute-_onstate-vehicleui', [[ + ]] + ) + header:SetAttribute( + "_initialAttribute-_onstate-vehicleui", + [[ local unit = self:GetAttribute('unit') if(newstate == 'vehicle' and unit and UnitPlayerOrPetInRaid(unit) and not UnitTargetsVehicleInRaidUI(unit)) then self:SetAttribute('toggleForVehicle', false) else self:SetAttribute('toggleForVehicle', true) end - ]]) - header:SetAttribute('oUF-headerType', isPetHeader and 'pet' or 'group') + ]] + ) + header:SetAttribute("oUF-headerType", isPetHeader and "pet" or "group") - if(_G.Clique) then - SecureHandlerSetFrameRef(header, 'clickcast_header', _G.Clique.header) + if _G.Clique then + SecureHandlerSetFrameRef(header, "clickcast_header", _G.Clique.header) end - if(header:GetAttribute('showParty')) then - self:DisableBlizzard('party') + if header:GetAttribute("showParty") then + self:DisableBlizzard("party") end - if(visibility) then - local type, list = string.split(' ', visibility, 2) - if(list and type == 'custom') then - RegisterAttributeDriver(header, 'state-visibility', list) + if visibility then + local type, list = string.split(" ", visibility, 2) + if list and type == "custom" then + RegisterAttributeDriver(header, "state-visibility", list) header.visibility = list else - local condition = getCondition(string.split(',', visibility)) - RegisterAttributeDriver(header, 'state-visibility', condition) + local condition = getCondition(string.split(",", visibility)) + RegisterAttributeDriver(header, "state-visibility", condition) header.visibility = condition end end @@ -733,19 +770,23 @@ PingableUnitFrameTemplate is inherited for Ping support. * oUF-enableArenaPrep - can be used to toggle arena prep support. Defaults to true (boolean) --]] function oUF:Spawn(unit, overrideName, noHandle) - argcheck(unit, 2, 'string') - if(not style) then return error('Unable to create frame. No styles have been registered.') end + argcheck(unit, 2, "string") + if not style then + return error("Unable to create frame. No styles have been registered.") + end unit = unit:lower() local name = overrideName or generateName(unit) - local object = CreateFrame('Button', name, PetBattleFrameHider, 'SecureUnitButtonTemplate, PingableUnitFrameTemplate') + local object = CreateFrame("Button", name, PetBattleFrameHider, "SecureUnitButtonTemplate, PingableUnitFrameTemplate") Private.UpdateUnits(object, unit) - if not noHandle then self:DisableBlizzard(unit) end + if not noHandle then + self:DisableBlizzard(unit) + end walkObject(object, unit) - object:SetAttribute('unit', unit) + object:SetAttribute("unit", unit) RegisterUnitWatch(object) return object @@ -764,10 +805,14 @@ Used to create nameplates and apply the currently active style to them. PingableUnitFrameTemplate is inherited for Ping support. --]] function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars) - argcheck(nameplateCallback, 3, 'function', 'nil') - argcheck(nameplateCVars, 4, 'table', 'nil') - if(not style) then return error('Unable to create frame. No styles have been registered.') end - if(_G.oUF_NamePlateDriver) then return error('oUF nameplate driver has already been initialized.') end + argcheck(nameplateCallback, 3, "function", "nil") + argcheck(nameplateCVars, 4, "table", "nil") + if not style then + return error("Unable to create frame. No styles have been registered.") + end + if _G.oUF_NamePlateDriver then + return error("oUF nameplate driver has already been initialized.") + end local style = style local prefix = namePrefix or generateName() @@ -776,49 +821,51 @@ function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars) -- and because forbidden nameplates exist, we have to allow default nameplate -- driver to create, update, and remove Blizz nameplates. -- Disable only not forbidden nameplates. - hooksecurefunc(NamePlateDriverFrame, 'AcquireUnitFrame', self.DisableNamePlate) + hooksecurefunc(NamePlateDriverFrame, "AcquireUnitFrame", self.DisableNamePlate) - local eventHandler = CreateFrame('Frame', 'oUF_NamePlateDriver') - eventHandler:RegisterEvent('NAME_PLATE_UNIT_ADDED') - eventHandler:RegisterEvent('NAME_PLATE_UNIT_REMOVED') - eventHandler:RegisterEvent('PLAYER_TARGET_CHANGED') + local eventHandler = CreateFrame("Frame", "oUF_NamePlateDriver") + eventHandler:RegisterEvent("NAME_PLATE_UNIT_ADDED") + eventHandler:RegisterEvent("NAME_PLATE_UNIT_REMOVED") + eventHandler:RegisterEvent("PLAYER_TARGET_CHANGED") - if(IsLoggedIn()) then - if(nameplateCVars) then + if IsLoggedIn() then + if nameplateCVars then for cvar, value in next, nameplateCVars do SetCVar(cvar, value) end end else - eventHandler:RegisterEvent('PLAYER_LOGIN') + eventHandler:RegisterEvent("PLAYER_LOGIN") end - eventHandler:SetScript('OnEvent', function(_, event, unit) - if(event == 'PLAYER_LOGIN') then - if(nameplateCVars) then + eventHandler:SetScript("OnEvent", function(_, event, unit) + if event == "PLAYER_LOGIN" then + if nameplateCVars then for cvar, value in next, nameplateCVars do SetCVar(cvar, value) end end - elseif(event == 'PLAYER_TARGET_CHANGED') then - local nameplate = C_NamePlate.GetNamePlateForUnit('target') - if(nameplateCallback) then - nameplateCallback(nameplate and nameplate.unitFrame, event, 'target') + elseif event == "PLAYER_TARGET_CHANGED" then + local nameplate = C_NamePlate.GetNamePlateForUnit("target") + if nameplateCallback then + nameplateCallback(nameplate and nameplate.unitFrame, event, "target") end -- UAE is called after the callback to reduce the number of -- ForceUpdate calls layout devs have to do themselves - if(nameplate) then + if nameplate then nameplate.unitFrame:UpdateAllElements(event) end - elseif(event == 'NAME_PLATE_UNIT_ADDED' and unit) then + elseif event == "NAME_PLATE_UNIT_ADDED" and unit then local nameplate = C_NamePlate.GetNamePlateForUnit(unit) - if(not nameplate) then return end + if not nameplate then + return + end - if(not nameplate.unitFrame) then + if not nameplate.unitFrame then nameplate.style = style - nameplate.unitFrame = CreateFrame('Button', prefix..nameplate:GetName(), nameplate, 'PingableUnitFrameTemplate') + nameplate.unitFrame = CreateFrame("Button", prefix .. nameplate:GetName(), nameplate, "PingableUnitFrameTemplate") nameplate.unitFrame:EnableMouse(false) nameplate.unitFrame.isNamePlate = true @@ -829,34 +876,36 @@ function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars) Private.UpdateUnits(nameplate.unitFrame, unit) end - nameplate.unitFrame:SetAttribute('unit', unit) + nameplate.unitFrame:SetAttribute("unit", unit) - if(nameplate.UnitFrame) then - if(nameplate.UnitFrame.WidgetContainer) then + if nameplate.UnitFrame then + if nameplate.UnitFrame.WidgetContainer then nameplate.UnitFrame.WidgetContainer:SetParent(nameplate.unitFrame) nameplate.unitFrame.WidgetContainer = nameplate.UnitFrame.WidgetContainer end - if(nameplate.UnitFrame.SoftTargetFrame) then + if nameplate.UnitFrame.SoftTargetFrame then nameplate.UnitFrame.SoftTargetFrame:SetParent(nameplate.unitFrame) nameplate.unitFrame.SoftTargetFrame = nameplate.UnitFrame.SoftTargetFrame end end - if(nameplateCallback) then + if nameplateCallback then nameplateCallback(nameplate.unitFrame, event, unit) end -- UAE is called after the callback to reduce the number of -- ForceUpdate calls layout devs have to do themselves nameplate.unitFrame:UpdateAllElements(event) - elseif(event == 'NAME_PLATE_UNIT_REMOVED' and unit) then + elseif event == "NAME_PLATE_UNIT_REMOVED" and unit then local nameplate = C_NamePlate.GetNamePlateForUnit(unit) - if(not nameplate) then return end + if not nameplate then + return + end - nameplate.unitFrame:SetAttribute('unit', nil) + nameplate.unitFrame:SetAttribute("unit", nil) - if(nameplateCallback) then + if nameplateCallback then nameplateCallback(nameplate.unitFrame, event, unit) end end @@ -873,16 +922,18 @@ Used to register an element with oUF. * disable - used to disable the element for a given unit frame (function) --]] function oUF:AddElement(name, update, enable, disable) - argcheck(name, 2, 'string') - argcheck(update, 3, 'function', 'nil') - argcheck(enable, 4, 'function') - argcheck(disable, 5, 'function') + argcheck(name, 2, "string") + argcheck(update, 3, "function", "nil") + argcheck(enable, 4, "function") + argcheck(disable, 5, "function") - 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] = { - update = update; - enable = enable; - disable = disable; + update = update, + enable = enable, + disable = disable, } end @@ -896,12 +947,12 @@ Array containing all group headers created by `oUF:SpawnHeader`. --]] oUF.headers = headers -if(global) then - if(parent ~= 'oUF' and global == 'oUF') then +if global then + if parent ~= "oUF" and global == "oUF" then error('%s is doing it wrong and setting its global to "oUF".', parent) - elseif(_G[global]) then + elseif _G[global] then error('%s is setting its global to an existing name "%s".', parent, global) else _G[global] = oUF end -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/oUF/private.lua b/KkthnxUI/Libraries/oUF/private.lua index 7225fb3ea..355040991 100644 --- a/KkthnxUI/Libraries/oUF/private.lua +++ b/KkthnxUI/Libraries/oUF/private.lua @@ -2,23 +2,25 @@ local _, ns = ... local Private = ns.oUF.Private function Private.argcheck(value, num, ...) - assert(type(num) == 'number', "Bad argument #2 to 'argcheck' (number expected, got " .. type(num) .. ')') + assert(type(num) == "number", "Bad argument #2 to 'argcheck' (number expected, got " .. type(num) .. ")") - for i = 1, select('#', ...) do - if(type(value) == select(i, ...)) then return end + for i = 1, select("#", ...) do + if type(value) == select(i, ...) then + return + end end - local types = string.join(', ', ...) - local name = debugstack(2,2,0):match(": in function [`<](.-)['>]") + local types = string.join(", ", ...) + local name = debugstack(2, 2, 0):match(": in function [`<](.-)['>]") error(string.format("Bad argument #%d to '%s' (%s expected, got %s)", num, name, types, type(value)), 3) end function Private.print(...) - print('|cff33ff99oUF:|r', ...) + print("|cff33ff99oUF:|r", ...) end function Private.error(...) - Private.print('|cffff0000Error:|r ' .. string.format(...)) + Private.print("|cffff0000Error:|r " .. string.format(...)) end function Private.nierror(...) @@ -29,29 +31,29 @@ function Private.unitExists(unit) return unit and (UnitExists(unit) or ShowBossFrameWhenUninteractable(unit)) end -local validator = CreateFrame('Frame') +local validator = CreateFrame("Frame") function Private.validateUnit(unit) - local isOK, _ = pcall(validator.RegisterUnitEvent, validator, 'UNIT_HEALTH', unit) - if(isOK) then - _, unit = validator:IsEventRegistered('UNIT_HEALTH') - validator:UnregisterEvent('UNIT_HEALTH') + local isOK, _ = pcall(validator.RegisterUnitEvent, validator, "UNIT_HEALTH", unit) + if isOK then + _, unit = validator:IsEventRegistered("UNIT_HEALTH") + validator:UnregisterEvent("UNIT_HEALTH") return not not unit end end local selectionTypes = { - [ 0] = 0, - [ 1] = 1, - [ 2] = 2, - [ 3] = 3, - [ 4] = 4, - [ 5] = 5, - [ 6] = 6, - [ 7] = 7, - [ 8] = 8, - [ 9] = 9, + [0] = 0, + [1] = 1, + [2] = 2, + [3] = 3, + [4] = 4, + [5] = 5, + [6] = 6, + [7] = 7, + [8] = 8, + [9] = 9, -- [10] = 10, -- unavailable to players -- [11] = 11, -- unavailable to players -- [12] = 12, -- inconsistent due to bugs and its reliance on cvars @@ -59,7 +61,7 @@ local selectionTypes = { } function Private.unitSelectionType(unit, considerHostile) - if(considerHostile and UnitThreatSituation('player', unit)) then + if considerHostile and UnitThreatSituation("player", unit) then return 0 else return selectionTypes[UnitSelectionType(unit, true)] @@ -72,7 +74,7 @@ end function Private.validateEvent(event) local isOK = xpcall(validator.RegisterEvent, Private.nierror, validator, event) - if(isOK) then + if isOK then validator:UnregisterEvent(event) end @@ -81,9 +83,9 @@ end function Private.isUnitEvent(event, unit) local isOK = pcall(validator.RegisterUnitEvent, validator, event, unit) - if(isOK) then + if isOK then validator:UnregisterEvent(event) end return isOK -end \ No newline at end of file +end diff --git a/KkthnxUI/Libraries/oUF/units.lua b/KkthnxUI/Libraries/oUF/units.lua index 285f10b6f..d4d216099 100644 --- a/KkthnxUI/Libraries/oUF/units.lua +++ b/KkthnxUI/Libraries/oUF/units.lua @@ -6,8 +6,8 @@ local unitExists = Private.unitExists local function updateArenaPreparationElements(self, event, elementName, specID) local element = self[elementName] - if(element and self:IsElementEnabled(elementName)) then - if(element.OverrideArenaPreparation) then + if element and self:IsElementEnabled(elementName) then + if element.OverrideArenaPreparation then --[[ Override: Health.OverrideArenaPreparation(self, event, specID) Used to completely override the internal update function for arena preparation. @@ -28,7 +28,7 @@ local function updateArenaPreparationElements(self, event, elementName, specID) element:SetMinMaxValues(0, 1) element:SetValue(1) - if(element.UpdateColorArenaPreparation) then + if element.UpdateColorArenaPreparation then --[[ Override: Health:UpdateColor(specID) Used to completely override the internal function for updating the widget's colors during arena preparation. @@ -48,34 +48,34 @@ local function updateArenaPreparationElements(self, event, elementName, specID) -- this section just replicates the color options available to the Health and Power elements local r, g, b, color, _ -- if(element.colorPower and elementName == 'Power') then - -- FIXME: no idea if we can get power type here without the unit - if(element.colorClass) then + -- FIXME: no idea if we can get power type here without the unit + if element.colorClass then local _, _, _, _, _, class = GetSpecializationInfoByID(specID) color = self.colors.class[class] - elseif(element.colorReaction) then + elseif element.colorReaction then color = self.colors.reaction[2] - elseif(element.colorSmooth) then + elseif element.colorSmooth then _, _, _, _, _, _, r, g, b = unpack(element.smoothGradient or self.colors.smooth) - elseif(element.colorHealth and elementName == 'Health') then + elseif element.colorHealth and elementName == "Health" then color = self.colors.health end - if(color) then + if color then r, g, b = color[1], color[2], color[3] end - if(r or g or b) then + if r or g or b then element:SetStatusBarColor(r, g, b) local bg = element.bg - if(bg) then + if bg then local mu = bg.multiplier or 1 bg:SetVertexColor(r * mu, g * mu, b * mu) end end end - if(element.PostUpdateArenaPreparation) then + if element.PostUpdateArenaPreparation then --[[ Callback: Health:PostUpdateArenaPreparation(event, specID) Called after the element has been updated during arena preparation. @@ -96,99 +96,123 @@ local function updateArenaPreparationElements(self, event, elementName, specID) end local function updateArenaPreparation(self, event) - if(not self:GetAttribute('oUF-enableArenaPrep')) then + if not self:GetAttribute("oUF-enableArenaPrep") then return end - if(event == 'ARENA_OPPONENT_UPDATE' and not self:IsEnabled()) then + if event == "ARENA_OPPONENT_UPDATE" and not self:IsEnabled() then self:Enable() - self:UpdateAllElements('ArenaPreparation') + self:UpdateAllElements("ArenaPreparation") self:UnregisterEvent(event, updateArenaPreparation) -- show elements that don't handle their own visibility - if(self:IsElementEnabled('Auras')) then - if(self.Auras) then self.Auras:Show() end - if(self.Buffs) then self.Buffs:Show() end - if(self.Debuffs) then self.Debuffs:Show() end + if self:IsElementEnabled("Auras") then + if self.Auras then + self.Auras:Show() + end + if self.Buffs then + self.Buffs:Show() + end + if self.Debuffs then + self.Debuffs:Show() + end end - if(self.Portrait and self:IsElementEnabled('Portrait')) then + if self.Portrait and self:IsElementEnabled("Portrait") then self.Portrait:Show() end - elseif(event == 'PLAYER_ENTERING_WORLD' and not UnitExists(self.unit)) then + elseif event == "PLAYER_ENTERING_WORLD" and not UnitExists(self.unit) then -- semi-recursive call for when the player zones into an arena - updateArenaPreparation(self, 'ARENA_PREP_OPPONENT_SPECIALIZATIONS') - elseif(event == 'ARENA_PREP_OPPONENT_SPECIALIZATIONS') then - if(InCombatLockdown()) then + updateArenaPreparation(self, "ARENA_PREP_OPPONENT_SPECIALIZATIONS") + elseif event == "ARENA_PREP_OPPONENT_SPECIALIZATIONS" then + if InCombatLockdown() then -- prevent calling protected functions if entering arena while in combat - self:RegisterEvent('PLAYER_REGEN_ENABLED', updateArenaPreparation, true) + self:RegisterEvent("PLAYER_REGEN_ENABLED", updateArenaPreparation, true) return end - if(self.PreUpdate) then + if self.PreUpdate then self:PreUpdate(event) end local id = tonumber(self.id) - if(not self:IsEnabled() and GetNumArenaOpponentSpecs() < id) then + if not self:IsEnabled() and GetNumArenaOpponentSpecs() < id then -- hide the object if the opponent leaves self:Hide() end local specID = GetArenaOpponentSpec(id) - if(specID) then - if(self:IsEnabled()) then + if specID then + if self:IsEnabled() then -- disable the unit watch so we can forcefully show the object ourselves self:Disable() - self:RegisterEvent('ARENA_OPPONENT_UPDATE', updateArenaPreparation) + self:RegisterEvent("ARENA_OPPONENT_UPDATE", updateArenaPreparation) end -- update Health and Power (if available) with "fake" data - updateArenaPreparationElements(self, event, 'Health', specID) - updateArenaPreparationElements(self, event, 'Power', specID) + updateArenaPreparationElements(self, event, "Health", specID) + updateArenaPreparationElements(self, event, "Power", specID) -- hide all other (relevant) elements (they have no effect during arena prep) - if(self.Auras) then self.Auras:Hide() end - if(self.Buffs) then self.Buffs:Hide() end - if(self.Debuffs) then self.Debuffs:Hide() end - if(self.Castbar) then self.Castbar:Hide() end - if(self.CombatIndicator) then self.CombatIndicator:Hide() end - if(self.GroupRoleIndicator) then self.GroupRoleIndicator:Hide() end - if(self.Portrait) then self.Portrait:Hide() end - if(self.PvPIndicator) then self.PvPIndicator:Hide() end - if(self.RaidTargetIndicator) then self.RaidTargetIndicator:Hide() end + if self.Auras then + self.Auras:Hide() + end + if self.Buffs then + self.Buffs:Hide() + end + if self.Debuffs then + self.Debuffs:Hide() + end + if self.Castbar then + self.Castbar:Hide() + end + if self.CombatIndicator then + self.CombatIndicator:Hide() + end + if self.GroupRoleIndicator then + self.GroupRoleIndicator:Hide() + end + if self.Portrait then + self.Portrait:Hide() + end + if self.PvPIndicator then + self.PvPIndicator:Hide() + end + if self.RaidTargetIndicator then + self.RaidTargetIndicator:Hide() + end self:Show() self:UpdateTags() end - if(self.PostUpdate) then + if self.PostUpdate then self:PostUpdate(event) end - elseif(event == 'PLAYER_REGEN_ENABLED') then + elseif event == "PLAYER_REGEN_ENABLED" then self:UnregisterEvent(event, updateArenaPreparation) - updateArenaPreparation(self, 'ARENA_PREP_OPPONENT_SPECIALIZATIONS') + updateArenaPreparation(self, "ARENA_PREP_OPPONENT_SPECIALIZATIONS") end end -- Handles unit specific actions. function oUF:HandleUnit(object, unit) unit = object.unit or unit - if(unit == 'target') then - object:RegisterEvent('PLAYER_TARGET_CHANGED', object.UpdateAllElements, true) - elseif(unit == 'mouseover') then - object:RegisterEvent('UPDATE_MOUSEOVER_UNIT', object.UpdateAllElements, true) - elseif(unit == 'focus') then - object:RegisterEvent('PLAYER_FOCUS_CHANGED', object.UpdateAllElements, true) - elseif(unit:match('boss%d?$')) then - object:RegisterEvent('INSTANCE_ENCOUNTER_ENGAGE_UNIT', object.UpdateAllElements, true) - object:RegisterEvent('UNIT_TARGETABLE_CHANGED', object.UpdateAllElements) - elseif(unit:match('arena%d?$')) then - object:RegisterEvent('ARENA_OPPONENT_UPDATE', object.UpdateAllElements, true) - object:RegisterEvent('ARENA_PREP_OPPONENT_SPECIALIZATIONS', updateArenaPreparation, true) - object:SetAttribute('oUF-enableArenaPrep', true) + if unit == "target" then + object:RegisterEvent("PLAYER_TARGET_CHANGED", object.UpdateAllElements, true) + elseif unit == "mouseover" then + object:RegisterEvent("UPDATE_MOUSEOVER_UNIT", object.UpdateAllElements, true) + elseif unit == "focus" then + object:RegisterEvent("PLAYER_FOCUS_CHANGED", object.UpdateAllElements, true) + elseif unit:match("boss%d?$") then + object:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT", object.UpdateAllElements, true) + object:RegisterEvent("UNIT_TARGETABLE_CHANGED", object.UpdateAllElements) + elseif unit:match("arena%d?$") then + object:RegisterEvent("ARENA_OPPONENT_UPDATE", object.UpdateAllElements, true) + object:RegisterEvent("ARENA_PREP_OPPONENT_SPECIALIZATIONS", updateArenaPreparation, true) + object:SetAttribute("oUF-enableArenaPrep", true) -- the event handler only fires for visible frames, so we have to hook it for arena prep - object:HookScript('OnEvent', updateArenaPreparation) + object:HookScript("OnEvent", updateArenaPreparation) end end @@ -196,16 +220,16 @@ local eventlessObjects = {} local onUpdates = {} local function createOnUpdate(timer) - if(not onUpdates[timer]) then - local frame = CreateFrame('Frame') + if not onUpdates[timer] then + local frame = CreateFrame("Frame") local objects = eventlessObjects[timer] - frame:SetScript('OnUpdate', function(self, elapsed) + frame:SetScript("OnUpdate", function(self, elapsed) self.elapsed = (self.elapsed or 0) + elapsed - if(self.elapsed > timer) then + if self.elapsed > timer then for _, object in next, objects do - if(object:IsVisible() and object.unit and unitExists(object.unit)) then - object:UpdateAllElements('OnUpdate') + if object:IsVisible() and object.unit and unitExists(object.unit) then + object:UpdateAllElements("OnUpdate") end end @@ -229,15 +253,17 @@ function oUF:HandleEventlessUnit(object) -- Remove it, in case it's already registered with any timer for _, objects in next, eventlessObjects do for i, obj in next, objects do - if(obj == object) then + if obj == object then table.remove(objects, i) break end end end - if(not eventlessObjects[timer]) then eventlessObjects[timer] = {} end + if not eventlessObjects[timer] then + eventlessObjects[timer] = {} + end table.insert(eventlessObjects[timer], object) createOnUpdate(timer) -end \ No newline at end of file +end diff --git a/KkthnxUI/Modules/Automation/Elements/Screenshot.lua b/KkthnxUI/Modules/Automation/Elements/Screenshot.lua index 4d234d91d..03eb6fbc0 100644 --- a/KkthnxUI/Modules/Automation/Elements/Screenshot.lua +++ b/KkthnxUI/Modules/Automation/Elements/Screenshot.lua @@ -8,10 +8,7 @@ local Screenshot = Screenshot -- Achievement screenshot local ScreenShotFrame -local function ScreenShotOnEvent(achievementID, alreadyEarned) - print("achievementID", achievementID) - print("alreadyEarned", alreadyEarned) - +local function ScreenShotOnEvent(_, _, alreadyEarned) if alreadyEarned then return end diff --git a/KkthnxUI/Modules/Miscellaneous/Elements/ExpRep.lua b/KkthnxUI/Modules/Miscellaneous/Elements/ExpRep.lua index 5ee76699b..ea961c2fd 100644 --- a/KkthnxUI/Modules/Miscellaneous/Elements/ExpRep.lua +++ b/KkthnxUI/Modules/Miscellaneous/Elements/ExpRep.lua @@ -312,6 +312,24 @@ local function OnExpBarEnter(self) GameTooltip:AddDoubleLine(reaction, current .. " / " .. currentMax .. " (" .. floor(current / currentMax * 100) .. "%)", 0.6, 0.8, 1, 1, 1, 1) -- Translate "reaction" if necessary end end + + if factionID == 2465 then -- 荒猎团 + local repInfo = C_GossipInfo_GetFriendshipReputation(2463) -- 玛拉斯缪斯 + local rep, name, reaction, threshold, nextThreshold = repInfo.standing, repInfo.name, repInfo.reaction, repInfo.reactionThreshold, repInfo.nextThreshold + if nextThreshold and rep > 0 then + local current = rep - threshold + local currentMax = nextThreshold - threshold + GameTooltip:AddLine(" ") + GameTooltip:AddLine(name, 0, 0.6, 1) + GameTooltip:AddDoubleLine(reaction, current .. " / " .. currentMax .. " (" .. floor(current / currentMax * 100) .. "%)", 0.6, 0.8, 1, 1, 1, 1) + end + elseif factionID == 2574 then -- 梦境守望者 + local currencyInfo = C_CurrencyInfo.GetCurrencyInfo(2649) -- 梦境注能 + local q = currencyInfo.quantity + local m = currencyInfo.maxQuantity + local name = C_CurrencyInfo.GetCurrencyInfo(2777).name + GameTooltip:AddDoubleLine(name, q .. " / " .. m .. " (" .. floor(q / m * 100) .. "%)", 0.6, 0.8, 1, 1, 1, 1) + end end end