From b431a368ab84c25d6ac81b8c24d1f478281ff056 Mon Sep 17 00:00:00 2001 From: wutname1 Date: Thu, 15 Aug 2024 21:36:54 -0500 Subject: [PATCH] MANY Blizz API call updates that were updated to retail versions --- .vscode/settings.json | 169 ++-------- Core/Framework.lua | 12 +- Core/Handlers/BugWindow.lua | 2 +- Core/Handlers/SetupWizard.lua | 2 +- Core/Skins/Ace3.lua | 2 +- Core/oUF.lua | 35 --- Modules/Artwork/BlizzMovers.lua | 4 +- Modules/AutoSell.lua | 2 +- Modules/AutoTurnIn.lua | 110 +++++-- Modules/BarHandlers/Bartender4.lua | 4 +- Modules/Chatbox.lua | 2 +- Modules/Minimap.lua | 2 +- Modules/Objectives.lua | 37 ++- Modules/Tooltips.lua | 25 +- Modules/UnitFrames/Handlers/Auras.lua | 9 +- SpartanUI_Vanilla.toc | 2 +- libs/StdUi/StdUiConfig.lua | 102 +++--- libs/bug-grabber/BugGrabber.lua | 278 ++++++----------- libs/bug-grabber/embedding.txt | 2 +- libs/oUF/oUF.lua | 428 ++++++++++++-------------- 20 files changed, 495 insertions(+), 734 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5c3d6890..ead8d360 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -293,17 +293,14 @@ "RegisterAsWidget", "RAID", "SlashCmdList", - "seterrorhandler", "OnHyperlinkLeave", "OnHyperlinkEnter", "SUI_Art_Minimal_Base", - "IsInRaid", "CUSTOM_CLASS_COLORS", "OPEN_ALL_MAIL_BUTTON", "OpenAllMailMixin", "oUF", "RegisterAttributeDriver", - "CreateFrame", "UIParent", "QuestFrame", "GossipFrame", @@ -311,12 +308,10 @@ "WOW_PROJECT_MAINLINE", "WOW_PROJECT_BURNING_CRUSADE_CLASSIC", "WOW_PROJECT_CLASSIC", - "GetBuildInfo", "_", "AceGUIWidgetLSMlists", "UnregisterUnitWatch", "RegisterUnitWatch", - "InCombatLockdown", "MultiCastActionBarFrame", "MinimapCompassTexture", "WOW_PROJECT_WRATH_CLASSIC", @@ -367,160 +362,17 @@ "DebuffTypeColor", "Settings", "BossButtonHolder", - "GetScreenHeight", - "min", - "IsInInstance", - "IsInGroup", - "tinsert", - "hooksecurefunc", - "format", - "GetAddOnEnableState", - "strsub", - "strfind", - "strlen", - "floor", - "UnitName", - "GetItemInfo", - "strlower", - "strrep", - "UnitFactionGroup", "SetCVar", "GetCVar", - "IsAltKeyDown", - "gsub", - "GetAddOnInfo", - "UnitClass", - "strmatch", "Mixin", - "UnitHealth", - "UnitHealthMax", - "UnitIsDeadOrGhost", - "UnitPower", - "UnitPowerMax", - "UnitLevel", - "UnitClassification", - "UnitIsPlayer", - "GetSpellInfo", - "UnitExists", - "GetTitleName", - "C_NamePlate", - "UnitIsAFK", - "UnitIsDND", - "GetSpecialization", - "GetCurrentTitle", - "GetSpecializationInfo", - "MoveViewRightStop", - "MoveViewRightStart", - "strsplit", - "IsAddOnLoaded", - "max", "GetNumFactions", - "GetXPExhaustion", "GetWatchedFactionInfo", - "UnitHonorLevel", - "UnitHonor", - "UnitHonorMax", - "C_AzeriteItem", "GetFactionInfo", - "GetMaxPlayerLevel", - "UnitXP", - "UnitXPMax", - "C_GossipInfo", - "C_Reputation", "Item", - "C_MajorFactions", - "C_Container", - "RepairAllItems", - "C_EquipmentSet", - "GetRepairAllCost", - "CanGuildBankRepair", - "CanMerchantRepair", - "SelectAvailableQuest", - "SelectActiveQuest", - "GetQuestReward", - "GetNumQuestChoices", - "GetDetailedItemLevelInfo", - "GetItemCount", - "GetNumActiveQuests", - "GetNumAvailableQuests", - "CompleteQuest", - "GetQuestItemLink", - "GetRewardText", - "GetQuestID", - "AcceptQuest", - "IsQuestCompletable", - "GetInventorySlotInfo", - "GetInventoryItemLink", - "GetActiveTitle", - "GetAvailableQuestInfo", - "GetTitleText", - "GetObjectiveText", - "C_CampaignInfo", - "Enum", - "C_Timer", - "Ambiguate", - "date", - "strtrim", - "GetNumGuildMembers", - "tremove", - "IsShiftKeyDown", - "GetGuildRosterInfo", - "UnitIsFriend", - "C_FriendList", - "LoggingCombat", - "GetInstanceInfo", - "GetItemQualityColor", - "GetItemInfoInstant", - "GetInventoryItemID", - "C_LFGList", - "C_ChallengeMode", - "CombatLogGetCurrentEventInfo", "GetSpellLink", - "SendChatMessage", - "UnitGUID", "SetCVarBitfield", - "mod", - "GetInboxHeaderInfo", - "TakeInboxMoney", - "TakeInboxItem", - "GetInboxInvoiceInfo", - "C_Map", - "C_SuperTrack", "GetMouseFocus", - "C_CVar", "Round", - "IsControlKeyDown", - "UnitNameplateShowsWidgetsOnly", - "UnitIsUnit", - "UnitReaction", - "C_TalkingHead", - "GetNumGroupMembers", - "GetGuildInfo", - "UnitRealmRelationship", - "UnitPVPName", - "UnitCreatureType", - "UnitRace", - "wipe", - "C_Item", - "C_PaperDollInfo", - "IsCorruptedItem", - "NotifyInspect", - "UnitBattlePetLevel", - "UnitIsWildBattlePet", - "UnitIsBattlePetCompanion", - "C_PetJournal", - "C_AzeriteEmpoweredItem", - "UnitHasVehicleUI", - "GetRealmName", - "IsSpellKnown", - "UnitIsEnemy", - "UnitPlayerControlled", - "UnitIsPVPFreeForAll", - "UnitIsPVP", - "C_PvP", - "C_MountJournal", - "UnitAura", - "GetTime", "AddonCompartmentFrame", "CopyTable", "HideUIPanel", @@ -529,7 +381,6 @@ "SecureButton_GetUnit", "SecureButton_GetModifiedUnit", "SecureHandlerSetFrameRef", - "IsLoggedIn", "FramerateFrame", "AchievementMicroButton", "SplashFrameMixin", @@ -548,7 +399,9 @@ "ComboFrame", "TargetFrameToT", "MAX_PARTY_MEMBERS", - "MAX_ARENA_ENEMIES" + "MAX_ARENA_ENEMIES", + "RAID_CLASS_COLORS", + "ShowUIPanel" ], "Lua.workspace.ignoreDir": [".vscode", "libs/*"], "Lua.diagnostics.enable": true, @@ -562,5 +415,19 @@ }, "todo-tree.tree.showBadges": true, "todo-tree.tree.showCountsInTree": true, - "todo-tree.tree.disableCompactFolders": false + "todo-tree.tree.disableCompactFolders": false, + "Lua.runtime.builtin": { + "basic": "disable", + "debug": "disable", + "io": "disable", + "math": "disable", + "os": "disable", + "package": "disable", + "string": "disable", + "table": "disable", + "utf8": "disable" + }, + "Lua.workspace.library": [ + "~\\.vscode\\extensions\\ketho.wow-api-0.17.4\\Annotations" + ] } diff --git a/Core/Framework.lua b/Core/Framework.lua index ccc5f113..333841cb 100644 --- a/Core/Framework.lua +++ b/Core/Framework.lua @@ -7,9 +7,9 @@ local type, pairs, unpack = type, pairs, unpack local _G = _G SUI.L = LibStub('AceLocale-3.0'):GetLocale('SpartanUI', true) ---@type SUIL SUI.AutoOpenErrors = true -SUI.Version = GetAddOnMetadata('SpartanUI', 'Version') or 0 -SUI.BuildNum = GetAddOnMetadata('SpartanUI', 'X-Build') or 0 -SUI.Bartender4Version = (GetAddOnMetadata('Bartender4', 'Version') or 0) +SUI.Version = C_AddOns.GetAddOnMetadata('SpartanUI', 'Version') or 0 +SUI.BuildNum = C_AddOns.GetAddOnMetadata('SpartanUI', 'X-Build') or 0 +SUI.Bartender4Version = (C_AddOns.GetAddOnMetadata('Bartender4', 'Version') or 0) SUI.IsDF = select(4, GetBuildInfo()) >= 100000 ---@type boolean SUI.IsRetail = (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) ---@type boolean SUI.IsClassic = (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) ---@type boolean @@ -1278,7 +1278,7 @@ function SUI:OnInitialize() end local function Version() - SUI:Print(SUI.L['Version'] .. ' ' .. GetAddOnMetadata('SpartanUI', 'Version')) + SUI:Print(SUI.L['Version'] .. ' ' .. C_AddOns.GetAddOnMetadata('SpartanUI', 'Version')) SUI:Print(string.format('%s build %s', wowVersion, SUI.BuildNum)) if SUI.Bartender4Version ~= 0 then SUI:Print(SUI.L['Bartender4 version'] .. ' ' .. SUI.Bartender4Version) end end @@ -1679,7 +1679,7 @@ end --------------- Misc Backend --------------- function SUI:IsAddonEnabled(addon) - return GetAddOnEnableState(UnitName('player'), addon) == 2 + return C_AddOns.GetAddOnEnableState(UnitName('player'), addon) == 2 end function SUI:IsAddonDisabled(addon) @@ -1695,7 +1695,7 @@ function SUI:GetiLVL(itemLink) local scanningTooltip = CreateFrame('GameTooltip', 'AutoTurnInTooltip', nil, 'GameTooltipTemplate') local itemLevelPattern = ITEM_LEVEL:gsub('%%d', '(%%d+)') - local itemQuality = select(3, GetItemInfo(itemLink)) + local itemQuality = select(3, C_Item.GetItemInfo(itemLink)) -- if a heirloom return a huge number so we dont replace it. if itemQuality == 7 then return math.huge end diff --git a/Core/Handlers/BugWindow.lua b/Core/Handlers/BugWindow.lua index 91830361..8b44aeb3 100644 --- a/Core/Handlers/BugWindow.lua +++ b/Core/Handlers/BugWindow.lua @@ -226,7 +226,7 @@ local createBugWindow = function() -- Create window Items window.editBox = StdUi:MultiLineBox(window, 480, 320, '') - window.SubTitle = StdUi:Label(window, 'Error handler ' .. (GetAddOnMetadata('SpartanUI', 'Version') or ''), 10, nil, nil, 15) + window.SubTitle = StdUi:Label(window, 'Error handler ' .. (C_AddOns.GetAddOnMetadata('SpartanUI', 'Version') or ''), 10, nil, nil, 15) window.SubTitle:SetPoint('BOTTOM', window.Title, 'BOTTOMRIGHT', 0, -1) window.sessionLabel = StdUi:Label(window, '', 10, nil, 180, 20) diff --git a/Core/Handlers/SetupWizard.lua b/Core/Handlers/SetupWizard.lua index 845f671f..75336fd9 100644 --- a/Core/Handlers/SetupWizard.lua +++ b/Core/Handlers/SetupWizard.lua @@ -360,7 +360,7 @@ local function WelcomePage() WelcomePage.Helm:SetPoint('CENTER', 0, 45) WelcomePage.Helm:SetAlpha(0.6) - if not select(4, GetAddOnInfo('Bartender4')) then + if not select(4, C_AddOns.GetAddOnInfo('Bartender4')) then module.window.BT4Warning = StdUi:Label(module.window, L['Bartender4 not detected! Please download and install Bartender4.'], 25, nil, module.window:GetWidth(), 40) module.window.BT4Warning:SetTextColor(1, 0.18, 0.18, 1) StdUi:GlueAbove(module.window.BT4Warning, module.window, 0, 20) diff --git a/Core/Skins/Ace3.lua b/Core/Skins/Ace3.lua index 8d8dd30c..5112a300 100644 --- a/Core/Skins/Ace3.lua +++ b/Core/Skins/Ace3.lua @@ -280,7 +280,7 @@ local function attemptSkin() local AceGUI = LibStub('AceGUI-3.0', true) if AceGUI and (AceGUI.RegisterAsContainer ~= RegisterAsContainer or AceGUI.RegisterAsWidget ~= RegisterAsWidget) then - if select(4, GetAddOnInfo('ElvUI')) then return end + if select(4, C_AddOns.GetAddOnInfo('ElvUI')) then return end SkinAce3() end end diff --git a/Core/oUF.lua b/Core/oUF.lua index effec8d9..17778084 100644 --- a/Core/oUF.lua +++ b/Core/oUF.lua @@ -3,41 +3,6 @@ local SUI = SUI local unpack = unpack -------------- oUF Functions ------------------------------------ -function SUI:HotsListing() - local _, classFileName = UnitClass('player') - local LifebloomSpellId = select(7, GetSpellInfo('Lifebloom')) - if classFileName == 'DRUID' then - return { - 774, -- Rejuvenation - LifebloomSpellId, -- Lifebloom - 8936, -- Regrowth - -- 48438, -- Wild Growth - -- 155777, -- Germination - -- 102351, -- Cenarion Ward - -- 102342 -- Ironbark - } - elseif classFileName == 'PRIEST' then - if SUI.IsClassic then - return { - 139, -- Renew - 17, -- sheild - } - else - return { - 139, -- Renew - 17, -- sheild - 33076, -- Prayer of Mending - } - end - elseif classFileName == 'MONK' then - return { - 119611, -- Renewing Mist - 227345, -- Enveloping Mist - } - end - return {} -end - local function getCurrentUnitHP(unitid) local aCurrentHP = 0 local aMaxHP = 0 diff --git a/Modules/Artwork/BlizzMovers.lua b/Modules/Artwork/BlizzMovers.lua index 9a03ca90..851d9482 100644 --- a/Modules/Artwork/BlizzMovers.lua +++ b/Modules/Artwork/BlizzMovers.lua @@ -80,7 +80,7 @@ local function TalkingHead() TalkingHeadFrame:SetPoint('CENTER', THUIHolder, 'CENTER', 0, 0) end) end - if IsAddOnLoaded('Blizzard_TalkingHeadUI') then + if C_AddOns.IsAddOnLoaded('Blizzard_TalkingHeadUI') then SetupTalkingHead() else --We want the mover to be available immediately, so we load it ourselves @@ -207,7 +207,7 @@ local function WidgetPowerBarContainer() hooksecurefunc(_G['UIWidgetPowerBarContainerFrame'], 'SetPoint', ResetPosition) end - if not IsAddOnLoaded('SimplePowerBar') then + if not C_AddOns.IsAddOnLoaded('SimplePowerBar') then AttachToHolder(_G['PlayerPowerBarAlt'], holder) hooksecurefunc(_G['PlayerPowerBarAlt'], 'SetPoint', ResetPosition) end diff --git a/Modules/AutoSell.lua b/Modules/AutoSell.lua index 67ab07a9..948ba04a 100644 --- a/Modules/AutoSell.lua +++ b/Modules/AutoSell.lua @@ -5,7 +5,7 @@ module.description = 'Auto sells junk and more' ---------------------------------------------------------------------------------------------------- local GetContainerNumSlots = (C_Container and C_Container.GetContainerNumSlots) or GetContainerNumSlots local GetContainerItemInfo = (C_Container and C_Container.GetContainerItemInfo) or GetContainerItemInfo -local GetItemInfo = C_Item.GetItemInfo or GetItemInfo +local GetItemInfo = C_Item.GetItemInfo local UseContainerItem = (C_Container and C_Container.UseContainerItem) or UseContainerItem local frame = CreateFrame('Frame') diff --git a/Modules/AutoTurnIn.lua b/Modules/AutoTurnIn.lua index fa7f6315..ceea089c 100644 --- a/Modules/AutoTurnIn.lua +++ b/Modules/AutoTurnIn.lua @@ -1,15 +1,9 @@ local SUI, L, StdUi = SUI, SUI.L, SUI.StdUi ---@class SUI.Module.AutoTurnIn : SUI.Module -local module = SUI:NewModule('Module_AutoTurnIn') +local module = SUI:NewModule('AutoTurnIn') module.DisplayName = L['Auto turn in'] module.description = 'Auto accept and turn in quests' ---------------------------------------------------------------------------------------------------- -local SelectAvailableQuest = SelectAvailableQuest -local SelectActiveQuest = SelectActiveQuest -local GetGossipActiveQuests = C_GossipInfo.GetActiveQuests -local SelectGossipOption = C_GossipInfo.SelectOption -local GetGossipAvailableQuests = C_GossipInfo.GetAvailableQuests -local GetGossipOptions = C_GossipInfo.GetOptions local DB ---@type AutoTurnInDB local GlobalDB ---@type AutoTurnInGlobalDB local Blacklist = { @@ -329,8 +323,8 @@ end function module:EquipItem(ItemToEquip) if InCombatLockdown() then return end - local EquipItemName = GetItemInfo(ItemToEquip) - local EquipILvl = GetDetailedItemLevelInfo(ItemToEquip) + local EquipItemName = C_Item.GetItemInfo(ItemToEquip) + local EquipILvl = C_Item.GetDetailedItemLevelInfo(ItemToEquip) local ItemFound = false -- Make sure it is in the bags @@ -339,8 +333,8 @@ function module:EquipItem(ItemToEquip) for slot = 1, GetContainerNumSlots(bag), 1 do local link = GetContainerItemLink(bag, slot) if link then - local slotItemName = GetItemInfo(link) - local SlotILvl = GetDetailedItemLevelInfo(link) + local slotItemName = C_Item.GetItemInfo(link) + local SlotILvl = C_Item.GetDetailedItemLevelInfo(link) if (slotItemName == EquipItemName) and (SlotILvl == EquipILvl) then if IsMerchantOpen then SUI:Print(L['Unable to equip'] .. ' ' .. link) @@ -403,7 +397,7 @@ function module.QUEST_COMPLETE() local link = GetQuestItemLink('choice', i) debug(link) if link == nil then return end - local itemName, _, _, _, _, _, _, _, itemEquipLoc, _, itemSellPrice = GetItemInfo(link) + local itemName, _, _, _, _, _, _, _, itemEquipLoc, _, itemSellPrice = C_Item.GetItemInfo(link) local QuestItemTrueiLVL = SUI:GetiLVL(link) or 0 -- Check the items value @@ -492,7 +486,8 @@ function module.QUEST_COMPLETE() end function module:GetItemAmount(isCurrency, item) - local amount = isCurrency and select(2, GetCurrencyInfo(item)) or GetItemCount(item, nil, true) + local currency = C_CurrencyInfo.GetCurrencyInfo(item) + local amount = isCurrency and (currency.quantity or C_Item.GetItemCount(item, nil, true)) return amount and amount or 0 end @@ -728,7 +723,7 @@ function module.QUEST_GREETING() debug(numAvailableQuests) for i = 1, numActiveQuests do local isComplete = select(2, GetActiveTitle(i)) - if isComplete then SelectActiveQuest(i) end + if isComplete then C_GossipInfo.SelectActiveQuest(i) end end for i = 1, numAvailableQuests do @@ -741,11 +736,11 @@ function module.QUEST_GREETING() if (trivialORAllowed and isRepeatableORAllowed) and (not module.Blacklist.isBlacklisted(questID)) and questID ~= 0 then debug('selecting ' .. i .. ' questId ' .. questID) ---@diagnostic disable-next-line: redundant-parameter - SelectAvailableQuest(i) + C_GossipInfo.SelectAvailableQuest(i) end else ---@diagnostic disable-next-line: redundant-parameter - SelectAvailableQuest(i) + C_GossipInfo.SelectAvailableQuest(i) end end end @@ -753,11 +748,11 @@ end function module.GOSSIP_SHOW() if (not DB.AutoGossip) or (IsAltKeyDown()) then return end - module:VarArgForActiveQuests(GetGossipActiveQuests()) - module:VarArgForAvailableQuests(GetGossipAvailableQuests()) + module:VarArgForActiveQuests(C_GossipInfo.GetActiveQuests()) + module:VarArgForAvailableQuests(C_GossipInfo.GetAvailableQuests()) debug('------ [Debugging Gossip] ------') - local options = GetGossipOptions() + local options = C_GossipInfo.GetOptions() debug('Number of Options ' .. #options) for _, gossip in pairs(options) do debug('---Start Option Info---') @@ -793,15 +788,15 @@ function module.GOSSIP_SHOW() end TempBlackList[gossip.name] = true debug(gossip.name .. '---BLACKLISTED') - SelectGossipOption(gossip.gossipOptionID) + C_GossipInfo.SelectOption(gossip.gossipOptionID) if DB.ChatText then SUI:Print('Selecting: ' .. gossip.name) end return end end - module:VarArgForActiveQuests(GetGossipActiveQuests()) - module:VarArgForAvailableQuests(GetGossipAvailableQuests()) + module:VarArgForActiveQuests(C_GossipInfo.GetActiveQuests()) + module:VarArgForAvailableQuests(C_GossipInfo.GetAvailableQuests()) end function module.QUEST_PROGRESS() @@ -827,6 +822,15 @@ function module:OnEnable() lastEvent = event local QuestID = GetQuestID() + if QuestID ~= 0 and C_CampaignInfo then + local CampaignId = C_CampaignInfo.GetCampaignID(QuestID) + debug(C_CampaignInfo.GetCurrentChapterID(CampaignId)) + debug(C_CampaignInfo.IsCampaignQuest(QuestID)) + if C_CampaignInfo.IsCampaignQuest(QuestID) and not DB.DoCampainQuests and C_CampaignInfo.GetCurrentChapterID(CampaignId) ~= nil then + SUI:Print(L['Current quest is a campaign quest, pausing AutoTurnIn']) + return + end + end if IsAltKeyDown() then SUI:Print('Canceling Override key held disabled') @@ -860,6 +864,68 @@ function module:OnEnable() ATI_Container:RegisterEvent('QUEST_COMPLETE') -- quest turn in screen ATI_Container:RegisterEvent('MERCHANT_SHOW') ATI_Container:RegisterEvent('MERCHANT_CLOSED') + + local IsCollapsed = true + + for _, v in ipairs({ 'QuestFrame', 'GossipFrame' }) do + local OptionsPopdown = StdUi:Panel(_G[v], 330, 20) + OptionsPopdown:SetScale(0.95) + OptionsPopdown:SetPoint('TOP', _G[v], 'BOTTOM', 0, -2) + OptionsPopdown.title = StdUi:Label(OptionsPopdown, '|cffffffffSpartan|cffe21f1fUI|r AutoTurnIn', 12) + OptionsPopdown.title:SetPoint('CENTER') + + -- OptionsPopdown.CloseButton = StdUi:Button(OptionsPopdown, 15, 15, 'X') + OptionsPopdown.minimizeButton = StdUi:Button(OptionsPopdown, 15, 15, '-') + + StdUi:GlueRight(OptionsPopdown.minimizeButton, OptionsPopdown, -5, 0, true) + -- StdUi:GlueRight(OptionsPopdown.CloseButton, OptionsPopdown, -5, 0, true) + -- StdUi:GlueLeft(OptionsPopdown.minimizeButton, OptionsPopdown.CloseButton, -2, 0) + + OptionsPopdown.minimizeButton:SetScript('OnClick', function() + if OptionsPopdown.Panel:IsVisible() then + OptionsPopdown.Panel:Hide() + IsCollapsed = true + else + OptionsPopdown.Panel:Show() + IsCollapsed = false + end + end) + OptionsPopdown:HookScript('OnShow', function() + if IsCollapsed then + OptionsPopdown.Panel:Hide() + else + OptionsPopdown.Panel:Show() + end + end) + + local Panel = StdUi:Panel(OptionsPopdown, OptionsPopdown:GetWidth(), 62) + Panel:SetPoint('TOP', OptionsPopdown, 'BOTTOM', 0, -1) + Panel:Hide() + local options = {} + options.DoCampainQuests = StdUi:Checkbox(Panel, L['Accept/Complete Campaign Quests'], nil, 20) + options.AcceptGeneralQuests = StdUi:Checkbox(Panel, L['Accept quests'], nil, 20) + options.TurnInEnabled = StdUi:Checkbox(Panel, L['Turn in completed quests'], nil, 20) + options.AutoGossip = StdUi:Checkbox(Panel, L['Auto gossip'], nil, 20) + options.AutoGossipSafeMode = StdUi:Checkbox(Panel, L['Auto gossip safe mode'], nil, 20) + for setting, Checkbox in pairs(options) do + Checkbox:SetChecked(DB[setting]) + Checkbox:HookScript('OnClick', function() + DB[setting] = Checkbox:GetChecked() + if Checkbox:GetChecked() then OnEvent(nil, lastEvent) end + end) + end + + StdUi:GlueTop(options.DoCampainQuests, Panel, 5, -2, 'LEFT') + + StdUi:GlueBelow(options.AcceptGeneralQuests, options.DoCampainQuests, 0, 2, 'LEFT') + StdUi:GlueRight(options.TurnInEnabled, options.AcceptGeneralQuests, 0, 0) + + StdUi:GlueBelow(options.AutoGossip, options.AcceptGeneralQuests, 0, 2, 'LEFT') + StdUi:GlueRight(options.AutoGossipSafeMode, options.AutoGossip, 0, 0) + + OptionsPopdown.Panel = Panel + OptionsPopdown.Panel.options = options + end end function module:OnDisable() diff --git a/Modules/BarHandlers/Bartender4.lua b/Modules/BarHandlers/Bartender4.lua index 079447cf..b274f953 100644 --- a/Modules/BarHandlers/Bartender4.lua +++ b/Modules/BarHandlers/Bartender4.lua @@ -162,7 +162,7 @@ local FrameList = { -- Creates the SUI BT4 Profile local function SetupProfile() --Exit if Bartender4 is not loaded - if not select(4, GetAddOnInfo('Bartender4')) then return end + if not select(4, C_AddOns.GetAddOnInfo('Bartender4')) then return end --Flag the SUI.DB that we are making changes BartenderChangesActive = true @@ -467,7 +467,7 @@ local function OnEnable() AddMovers() -- Eventually this will not be needed until then port this over. - if not select(4, GetAddOnInfo('Bartender4')) and not SUI.DB.BT4Warned then + if not select(4, C_AddOns.GetAddOnInfo('Bartender4')) and not SUI.DB.BT4Warned then local cnt = 1 local BT4Warning = CreateFrame('Frame') BT4Warning:SetScript('OnEvent', function() diff --git a/Modules/Chatbox.lua b/Modules/Chatbox.lua index be8d40b1..41f7324c 100644 --- a/Modules/Chatbox.lua +++ b/Modules/Chatbox.lua @@ -243,7 +243,7 @@ function module:OnInitialize() if SUI:IsModuleDisabled(module) then return end local ChatAddons = { 'Chatter', 'BasicChatMods', 'Prat-3.0' } for _, addonName in pairs(ChatAddons) do - local enabled = select(4, GetAddOnInfo(addonName)) + local enabled = select(4, C_AddOns.GetAddOnInfo(addonName)) if enabled then SUI:Print('Chat module disabling ' .. addonName .. ' Detected') module.override = true diff --git a/Modules/Minimap.lua b/Modules/Minimap.lua index 4da73bac..f7bccc5c 100644 --- a/Modules/Minimap.lua +++ b/Modules/Minimap.lua @@ -366,7 +366,7 @@ function module:SetupButton(btn, force) if not UserSettings.SUIMapChangesActive then table.insert(IgnoredFrames, self:GetName()) end end) btn:HookScript('OnShow', function(self, event, ...) - for i = 1, table.getn(IgnoredFrames) do + for i = 1, #IgnoredFrames do if IgnoredFrames[i] == btn:GetName() then table.remove(IgnoredFrames, i) end end end) diff --git a/Modules/Objectives.lua b/Modules/Objectives.lua index 78e649ad..12222994 100644 --- a/Modules/Objectives.lua +++ b/Modules/Objectives.lua @@ -103,14 +103,35 @@ local ObjTrackerUpdate = function(_, event) end end else - if HideObjs and _G[frameName]:GetAlpha() == 1 then - _G[frameName].FadeOut:Play() - _G[frameName]:Hide() - if _G[frameName].HeaderMenu then _G[frameName].HeaderMenu.MinimizeButton:Hide() end - elseif _G[frameName]:GetAlpha() == 0 and not HideObjs then - if _G[frameName].HeaderMenu then _G[frameName].HeaderMenu.MinimizeButton:Show() end - _G[frameName].FadeOut:Stop() - _G[frameName].FadeIn:Play() + local frame = _G[frameName] + if not frame then return end + + if not frame.FadeOut then + frame.FadeOut = frame:CreateAnimationGroup() + local fadeOut = frame.FadeOut:CreateAnimation('Alpha') + fadeOut:SetFromAlpha(1) + fadeOut:SetToAlpha(0) + fadeOut:SetDuration(0.2) + fadeOut:SetSmoothing('OUT') + end + + if not frame.FadeIn then + frame.FadeIn = frame:CreateAnimationGroup() + local fadeIn = frame.FadeIn:CreateAnimation('Alpha') + fadeIn:SetFromAlpha(0) + fadeIn:SetToAlpha(1) + fadeIn:SetDuration(0.2) + fadeIn:SetSmoothing('OUT') + end + + if HideObjs and frame:GetAlpha() == 1 then + frame.FadeOut:Play() + frame:Hide() + if frame.HeaderMenu then frame.HeaderMenu.MinimizeButton:Hide() end + elseif frame:GetAlpha() == 0 and not HideObjs then + if frame.HeaderMenu then frame.HeaderMenu.MinimizeButton:Show() end + frame.FadeOut:Stop() + frame.FadeIn:Play() end end end diff --git a/Modules/Tooltips.lua b/Modules/Tooltips.lua index cc7bda85..a91d4ca8 100644 --- a/Modules/Tooltips.lua +++ b/Modules/Tooltips.lua @@ -215,32 +215,13 @@ local TooltipSetItem = function(tooltip, tooltipData) end if itemLink then - local quality = select(3, GetItemInfo(itemLink)) + local quality = select(3, C_Item.GetItemInfo(itemLink)) local style = { bgFile = 'Interface/Tooltips/UI-Tooltip-Background', } - if SUI.IsRetail then - if C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItemByID(itemLink) or C_AzeriteItem.IsAzeriteItemByID(itemLink) then - style = { - bgFile = 'Interface/Tooltips/UI-Tooltip-Background-Azerite', - overlayAtlasTop = 'AzeriteTooltip-Topper', - overlayAtlasTopScale = 0.75, - overlayAtlasTopYOffset = 1, - overlayAtlasBottom = 'AzeriteTooltip-Bottom', - overlayAtlasBottomYOffset = 2, - } - elseif IsCorruptedItem(itemLink) then - style = { - bgFile = 'Interface/Tooltips/UI-Tooltip-Background-Corrupted', - overlayAtlasTop = 'Nzoth-tooltip-topper', - overlayAtlasTopScale = 0.75, - overlayAtlasTopYOffset = -2, - } - end - end if SUI.IsClassic and module.DB.VendorPrices then - local _, _, _, _, _, _, _, itemStackCount, _, _, itemSellPrice = GetItemInfo(itemLink) + local _, _, _, _, _, _, _, itemStackCount, _, _, itemSellPrice = C_Item.GetItemInfo(itemLink) if itemSellPrice then SetTooltipMoney(tooltip, itemSellPrice, 'STATIC', L['Vendors for:']) local itemUnderMouse = GetMouseFocus() @@ -264,7 +245,7 @@ local TooltipSetItem = function(tooltip, tooltipData) GameTooltip:SetBackdropColor(unpack(module.DB.Color)) if quality and tooltip.SetBorderColor then - local r, g, b = GetItemQualityColor(quality) + local r, g, b = C_Item.GetItemQualityColor(quality) r, g, b = (r * 0.5), (g * 0.5), (b * 0.5) tooltip:SetBorderColor(r, g, b) end diff --git a/Modules/UnitFrames/Handlers/Auras.lua b/Modules/UnitFrames/Handlers/Auras.lua index 227dadf0..40d1a699 100644 --- a/Modules/UnitFrames/Handlers/Auras.lua +++ b/Modules/UnitFrames/Handlers/Auras.lua @@ -255,7 +255,10 @@ end ---@param button any ---@param index integer function Auras.PostUpdateAura(element, unit, button, index) - local _, _, _, _, duration, expiration, owner, canStealOrPurge = UnitAura(unit, index, button.filter) + local auraData = C_UnitAuras.GetAuraDataByIndex(unit, index, button.filter) + if not auraData then return end + + local duration, expiration = auraData.duration, auraData.expirationTime if duration and duration > 0 then button.expiration = expiration - GetTime() else @@ -263,9 +266,9 @@ function Auras.PostUpdateAura(element, unit, button, index) end if button.SetBackdrop then - if unit == 'target' and canStealOrPurge then + if unit == 'target' and auraData.isStealable then button:SetBackdropColor(0, 1 / 2, 1 / 2) - elseif owner ~= 'player' then + elseif auraData.sourceUnit ~= 'player' then button:SetBackdropColor(0, 0, 0) end end diff --git a/SpartanUI_Vanilla.toc b/SpartanUI_Vanilla.toc index 8d4b13a9..354a192a 100644 --- a/SpartanUI_Vanilla.toc +++ b/SpartanUI_Vanilla.toc @@ -1,4 +1,4 @@ -## Interface: 11404 +## Interface: 11503 ## Title: Spartan|cffe21f1fUI ## Notes: User Interface combining elegant artwork with well designed features. ## Version: @project-version@ diff --git a/libs/StdUi/StdUiConfig.lua b/libs/StdUi/StdUiConfig.lua index 22203254..e0a6df25 100644 --- a/libs/StdUi/StdUiConfig.lua +++ b/libs/StdUi/StdUiConfig.lua @@ -1,95 +1,89 @@ --- @class StdUi -local StdUi = LibStub and LibStub('StdUi', true); -if not StdUi then - return -end - -local module, version = 'Config', 4; -if not StdUi:UpgradeNeeded(module, version) then - return -end +local StdUi = LibStub and LibStub('StdUi', true) +if not StdUi then return end -local IsAddOnLoaded = IsAddOnLoaded; +local module, version = 'Config', 4 +if not StdUi:UpgradeNeeded(module, version) then return end -StdUi.config = {}; +StdUi.config = {} function StdUi:ResetConfig() - local font, fontSize = GameFontNormal:GetFont(); - local _, largeFontSize = GameFontNormalLarge:GetFont(); + local font, fontSize = GameFontNormal:GetFont() + local _, largeFontSize = GameFontNormalLarge:GetFont() self.config = { - font = { - family = font, - size = fontSize, + font = { + family = font, + size = fontSize, titleSize = largeFontSize, - effect = '', - strata = 'OVERLAY', - color = { - normal = { r = 1, g = 1, b = 1, a = 1 }, + effect = '', + strata = 'OVERLAY', + color = { + normal = { r = 1, g = 1, b = 1, a = 1 }, disabled = { r = 0.55, g = 0.55, b = 0.55, a = 1 }, - header = { r = 1, g = 0.9, b = 0, a = 1 }, - } + header = { r = 1, g = 0.9, b = 0, a = 1 }, + }, }, - backdrop = { - texture = [[Interface\Buttons\WHITE8X8]], - panel = { r = 0.0588, g = 0.0588, b = 0, a = 0.8 }, - slider = { r = 0.15, g = 0.15, b = 0.15, a = 1 }, + backdrop = { + texture = [[Interface\Buttons\WHITE8X8]], + panel = { r = 0.0588, g = 0.0588, b = 0, a = 0.8 }, + slider = { r = 0.15, g = 0.15, b = 0.15, a = 1 }, - highlight = { r = 0.40, g = 0.40, b = 0, a = 0.5 }, - button = { r = 0.20, g = 0.20, b = 0.20, a = 1 }, + highlight = { r = 0.40, g = 0.40, b = 0, a = 0.5 }, + button = { r = 0.20, g = 0.20, b = 0.20, a = 1 }, buttonDisabled = { r = 0.15, g = 0.15, b = 0.15, a = 1 }, - border = { r = 0.00, g = 0.00, b = 0.00, a = 1 }, - borderDisabled = { r = 0.40, g = 0.40, b = 0.40, a = 1 } + border = { r = 0.00, g = 0.00, b = 0.00, a = 1 }, + borderDisabled = { r = 0.40, g = 0.40, b = 0.40, a = 1 }, }, progressBar = { color = { r = 1, g = 0.9, b = 0, a = 0.5 }, }, - highlight = { + highlight = { color = { r = 1, g = 0.9, b = 0, a = 0.4 }, - blank = { r = 0, g = 0, b = 0, a = 0 } + blank = { r = 0, g = 0, b = 0, a = 0 }, }, - dialog = { - width = 400, + dialog = { + width = 400, height = 100, button = { - width = 100, + width = 100, height = 20, - margin = 5 - } + margin = 5, + }, }, - tooltip = { - padding = 10 + tooltip = { + padding = 10, }, resizeHandle = { width = 10, height = 10, texture = { - normal = "Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up", - highlight = "Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up", - pushed = "Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down" - } - } - }; + normal = 'Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up', + highlight = 'Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up', + pushed = 'Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down', + }, + }, + } - if IsAddOnLoaded('ElvUI') then - local eb = ElvUI[1].media.backdropfadecolor; - self.config.backdrop.panel = { r = eb[1], g = eb[2], b = eb[3], a = eb[4] }; + if C_AddOns.IsAddOnLoaded('ElvUI') then + local eb = ElvUI[1].media.backdropfadecolor + self.config.backdrop.panel = { r = eb[1], g = eb[2], b = eb[3], a = eb[4] } end end -StdUi:ResetConfig(); +StdUi:ResetConfig() function StdUi:SetDefaultFont(font, size, effect, strata) - self.config.font.family = font; - self.config.font.size = size; - self.config.font.effect = effect; - self.config.font.strata = strata; + self.config.font.family = font + self.config.font.size = size + self.config.font.effect = effect + self.config.font.strata = strata end -StdUi:RegisterModule(module, version); +StdUi:RegisterModule(module, version) diff --git a/libs/bug-grabber/BugGrabber.lua b/libs/bug-grabber/BugGrabber.lua index e9d26faa..c7928a4a 100644 --- a/libs/bug-grabber/BugGrabber.lua +++ b/libs/bug-grabber/BugGrabber.lua @@ -1,18 +1,17 @@ +---@diagnostic disable: deprecated local _G = _G local type, table, next, tostring, tonumber, print = type, table, next, tostring, tonumber, print -local debuglocals, debugstack, wipe, IsEncounterInProgress, GetTime = - debuglocals, - debugstack, - table.wipe, - IsEncounterInProgress, - GetTime +local debuglocals, debugstack, wipe, IsEncounterInProgress, GetTime = debuglocals, debugstack, table.wipe, IsEncounterInProgress, GetTime +local GetAddOnMetadata = C_AddOns.GetAddOnMetadata +local DisableAddOn = C_AddOns.DisableAddOn or DisableAddOn +local GetAddOnInfo = C_AddOns.GetAddOnInfo or GetAddOnInfo +local IsAddOnLoaded = C_AddOns.IsAddOnLoaded or IsAddOnLoaded +local GetNumAddOns = C_AddOns.GetNumAddOns or GetNumAddOns ----------------------------------------------------------------------- -- Check if we already exist in the global space -- If we do - bail out early, there's no version checks. -if _G.BugGrabber then - return -end +if _G.BugGrabber then return end ----------------------------------------------------------------------- -- If we're embedded we create a .BugGrabber object on the addons @@ -21,17 +20,13 @@ end local bugGrabberParentAddon, parentAddonTable = ... local STANDALONE_NAME = '!BugGrabber' if bugGrabberParentAddon ~= STANDALONE_NAME then - local tbl = {STANDALONE_NAME, '!Swatter', '!ImprovedErrorFrame'} + local tbl = { STANDALONE_NAME, '!Swatter', '!ImprovedErrorFrame' } for i = 1, 3 do local _, _, _, enabled = GetAddOnInfo(tbl[i]) - if enabled then - return - end -- Bail out + if enabled then return end -- Bail out end end -if not parentAddonTable.BugGrabber then - parentAddonTable.BugGrabber = {} -end +if not parentAddonTable.BugGrabber then parentAddonTable.BugGrabber = {} end local addon = parentAddonTable.BugGrabber local real_seterrorhandler = seterrorhandler @@ -60,7 +55,7 @@ local L = { NO_DISPLAY_2 = '|cffffff00The standard display is called BugSack, and can probably be found on the same site where you found !BugGrabber.|r', NO_DISPLAY_STOP = "|cffffff00If you don't want to be reminded about this again, run /stopnag.|r", STOP_NAG = '|cffffff00!BugGrabber will not nag about missing a display addon again until next patch.|r', - USAGE = '|cffffff00Usage: /buggrabber <1-%d>.|r' + USAGE = '|cffffff00Usage: /buggrabber <1-%d>.|r', } ----------------------------------------------------------------------- @@ -102,15 +97,11 @@ local tableToString = 'table: %s' local function setupCallbacks() if not callbacks and LibStub and LibStub('CallbackHandler-1.0', true) then callbacks = LibStub('CallbackHandler-1.0'):New(addon) - function callbacks:OnUsed(target, eventname) - if eventname == 'BugGrabber_BugGrabbed' then - isBugGrabbedRegistered = true - end + function callbacks:OnUsed(_, eventname) + if eventname == 'BugGrabber_BugGrabbed' then isBugGrabbedRegistered = true end end - function callbacks:OnUnused(target, eventname) - if eventname == 'BugGrabber_BugGrabbed' then - isBugGrabbedRegistered = nil - end + function callbacks:OnUnused(_, eventname) + if eventname == 'BugGrabber_BugGrabbed' then isBugGrabbedRegistered = nil end end setupCallbacks = nil end @@ -118,12 +109,8 @@ end addon.setupCallbacks = setupCallbacks -- make it accessible from the outside for add-ons relying on BugGrabber events so they can make BugGrabber.RegisterCallback appear when they need it (CallbackHandler-1.0 is not embedded in BugGrabber) local function triggerEvent(...) - if not callbacks then - setupCallbacks() - end - if callbacks then - callbacks:Fire(...) - end + if not callbacks then setupCallbacks() end + if callbacks then callbacks:Fire(...) end end ----------------------------------------------------------------------- @@ -153,12 +140,8 @@ local function printErrorObject(err) end if not found then print(err.message) - if err.stack then - print(err.stack) - end - if err.locals then - print(err.locals) - end + if err.stack then print(err.stack) end + if err.locals then print(err.locals) end end end @@ -167,9 +150,7 @@ end -- local function slashHandler(index) - if not db then - return - end + if not db then return end index = tonumber(index) local err = type(index) == 'number' and db[index] or nil if not index or not err or type(err) ~= 'table' or (type(err.message) ~= 'string' and type(err.message) ~= 'table') then @@ -183,7 +164,7 @@ end -- Error catching -- -local findVersions -- Function set below +local findVersions -- Function set below do local function scanObject(o) local version, revision = nil, nil @@ -196,64 +177,48 @@ do revision = v end end - if version and revision then - break - end + if version and revision then break end end return version, revision end - local matchCache = - setmetatable( - {}, - { - __index = function(self, object) - if type(object) ~= 'string' or #object < 3 then - return - end - local found = nil - -- First see if it's a library - if LibStub then - local _, minor = LibStub(object, true) - found = minor - end - -- Then see if we can get some addon metadata - if not found and IsAddOnLoaded(object) then - found = GetAddOnMetadata(object, 'X-Curse-Packaged-Version') - if not found then - found = GetAddOnMetadata(object, 'Version') - end - end - -- Perhaps it's a global object? - if not found then - local o = _G[object] or _G[object:upper()] - if type(o) == 'table' then - local v, r = scanObject(o) - if v or r then - found = tostring(v) .. '.' .. tostring(r) - end - elseif o then - found = o - end - end - if not found then - found = _G[object:upper() .. '_VERSION'] - end - if type(found) == 'string' or type(found) == 'number' then - self[object] = found - return found + local matchCache = setmetatable({}, { + __index = function(self, object) + if type(object) ~= 'string' or #object < 3 then return end + local found = nil + -- First see if it's a library + if LibStub then + local _, minor = LibStub(object, true) + found = minor + end + -- Then see if we can get some addon metadata + if not found and IsAddOnLoaded(object) then + found = GetAddOnMetadata(object, 'X-Curse-Packaged-Version') + if not found then found = GetAddOnMetadata(object, 'Version') end + end + -- Perhaps it's a global object? + if not found then + local o = _G[object] or _G[object:upper()] + if type(o) == 'table' then + local v, r = scanObject(o) + if v or r then found = tostring(v) .. '.' .. tostring(r) end + elseif o then + found = o end end - } - ) + if not found then found = _G[object:upper() .. '_VERSION'] end + if type(found) == 'string' or type(found) == 'number' then + self[object] = found + return found + end + end, + }) local tmp = {} local function replacer(start, object, tail) -- Have we matched this object before on the same line? -- (another pattern could re-match a previous match...) - if tmp[object] then - return - end + if tmp[object] then return end local found = matchCache[object] if found then tmp[object] = true @@ -265,12 +230,10 @@ do '(\\)([^\\]+)(%.lua)', -- \Anything-except-backslashes.lua '^()([^\\]+)(\\)', -- Start-of-the-line-until-first-backslash\ '()(%a+%-%d%.?%d?)()', -- Anything-#.#, where .# is optional - '()(Lib%u%a+%-?%d?%.?%d?)()' -- LibXanything-#.#, where X is any capital letter and -#.# is optional + '()(Lib%u%a+%-?%d?%.?%d?)()', -- LibXanything-#.#, where X is any capital letter and -#.# is optional } function findVersions(line) - if not line or line:find('FrameXML\\') then - return line - end + if not line or line:find('FrameXML\\') then return line end for i = 1, 4 do line = line:gsub(matchers[i], replacer) end @@ -282,7 +245,6 @@ end -- Error handler local grabError do - local tmp = {} local msgsAllowed = BUGGRABBER_ERRORS_PER_SEC_BEFORE_THROTTLE local msgsAllowedLastTime = GetTime() local lastWarningTime = 0 @@ -304,9 +266,7 @@ do return end paused = false - if msgsAllowed > BUGGRABBER_ERRORS_PER_SEC_BEFORE_THROTTLE then - msgsAllowed = BUGGRABBER_ERRORS_PER_SEC_BEFORE_THROTTLE - end + if msgsAllowed > BUGGRABBER_ERRORS_PER_SEC_BEFORE_THROTTLE then msgsAllowed = BUGGRABBER_ERRORS_PER_SEC_BEFORE_THROTTLE end msgsAllowed = msgsAllowed - 1 -- Grab it -- @@ -343,32 +303,31 @@ do message = sanitizedMessage, session = addon:GetSessionId(), time = date('%Y/%m/%d %H:%M:%S'), - counter = 1 + counter = 1, } else local stack = debugstack(3) + local tbl = {} -- Scan for version numbers in the stack - for line in stack:gmatch('(.-)\n') do - tmp[#tmp + 1] = findVersions(line) + if stack then + for line in stack:gmatch('(.-)\n') do + tbl[#tbl + 1] = findVersions(line) + end end local inCombat = IsEncounterInProgress() -- debuglocals can be slow sometimes (200ms+) errorObject = { message = sanitizedMessage, - stack = table.concat(tmp, '\n'), + stack = stack and table.concat(tbl, '\n') or 'Debugstack was nil.', locals = inCombat and 'Skipped (In Encounter)' or debuglocals(3), session = addon:GetSessionId(), time = date('%Y/%m/%d %H:%M:%S'), - counter = 1 + counter = 1, } - - wipe(tmp) end end - if not isBugGrabbedRegistered then - print(L.ERROR_DETECTED:format(addon:GetChatLink(errorObject))) - end + if not isBugGrabbedRegistered then print(L.ERROR_DETECTED:format(addon:GetChatLink(errorObject))) end addon:StoreError(errorObject) @@ -384,9 +343,7 @@ function addon:StoreError(errorObject) if db then db[#db + 1] = errorObject -- Save only the last MAX_BUGGRABBER_ERRORS errors (otherwise the SV gets too big) - if #db > MAX_BUGGRABBER_ERRORS then - table.remove(db, 1) - end + if #db > MAX_BUGGRABBER_ERRORS then table.remove(db, 1) end else loadErrors[#loadErrors + 1] = errorObject end @@ -420,18 +377,14 @@ do end function addon:GetErrorByPlayerAndID(player, id) - if player == playerName then - return addon:GetErrorByID(id) - end + if player == playerName then return addon:GetErrorByID(id) end print(L.ERROR_UNABLE) end function addon:GetErrorByID(id) local errorId = tableToString:format(id) - for i, err in next, db do - if tostring(err) == errorId then - return err - end + for _, err in next, db do + if tostring(err) == errorId then return err end end end @@ -439,9 +392,7 @@ function addon:GetErrorID(errorObject) return tostring(errorObject):sub(8) end function addon:Reset() - if BugGrabberDB then - wipe(BugGrabberDB.errors) - end + if BugGrabberDB then wipe(BugGrabberDB.errors) end end function addon:GetDB() return db or loadErrors @@ -455,9 +406,7 @@ end function addon:HandleBugLink(player, id) local errorObject = addon:GetErrorByPlayerAndID(player, id) - if errorObject then - printErrorObject(errorObject) - end + if errorObject then printErrorObject(errorObject) end end ----------------------------------------------------------------------- @@ -466,16 +415,10 @@ end local function initDatabase() -- Persist defaults and make sure we have sane SavedVariables - if type(BugGrabberDB) ~= 'table' then - BugGrabberDB = {} - end + if type(BugGrabberDB) ~= 'table' then BugGrabberDB = {} end local sv = BugGrabberDB - if type(sv.session) ~= 'number' then - sv.session = 0 - end - if type(sv.errors) ~= 'table' then - sv.errors = {} - end + if type(sv.session) ~= 'number' then sv.session = 0 end + if type(sv.errors) ~= 'table' then sv.errors = {} end -- From now on we can persist errors. Create a new session. sv.session = sv.session + 1 @@ -489,7 +432,7 @@ local function initDatabase() -- If there were any load errors, we need to iterate them and -- insert the relevant ones into our SV DB. - for i, err in next, loadErrors do + for _, err in next, loadErrors do err.session = sv.session -- Update the session ID directly local exists = fetchFromDatabase(db, err.message) addon:StoreError(exists or err) @@ -498,9 +441,7 @@ local function initDatabase() if type(sv.lastSanitation) ~= 'number' or sv.lastSanitation ~= 3 then for i, v in next, db do - if type(v.message) == 'table' then - table.remove(db, i) - end + if type(v.message) == 'table' then table.remove(db, i) end end sv.lastSanitation = 3 end @@ -508,18 +449,14 @@ local function initDatabase() -- load locales if type(addon.LoadTranslations) == 'function' then local locale = GetLocale() - if locale ~= 'enUS' and locale ~= 'enGB' then - addon:LoadTranslations(locale, L) - end + if locale ~= 'enUS' and locale ~= 'enGB' then addon:LoadTranslations(locale, L) end addon.LoadTranslations = nil end -- Only warn about missing display if we're running standalone. if not displayObjectName and bugGrabberParentAddon == STANDALONE_NAME then local _, _, _, currentInterface = GetBuildInfo() - if type(currentInterface) ~= 'number' then - currentInterface = 0 - end + if type(currentInterface) ~= 'number' then currentInterface = 0 end if not sv.stopnag or sv.stopnag < currentInterface then print(L.NO_DISPLAY_1) print(L.NO_DISPLAY_2) @@ -538,19 +475,15 @@ end local events = {} do local frame = CreateFrame('Frame') - frame:SetScript( - 'OnEvent', - function(_, event, ...) - events[event](events, event, ...) - end - ) + frame:SetScript('OnEvent', function(_, event, ...) + events[event](events, event, ...) + end) frame:RegisterEvent('ADDON_LOADED') frame:RegisterEvent('PLAYER_LOGIN') frame:RegisterEvent('ADDON_ACTION_BLOCKED') frame:RegisterEvent('ADDON_ACTION_FORBIDDEN') frame:RegisterEvent('LUA_WARNING') - local function noop() - end -- Prevent abusive addons + local function noop() end -- Prevent abusive addons frame.RegisterEvent = noop frame.UnregisterEvent = noop frame.SetScript = noop @@ -567,51 +500,37 @@ do OnError = function(msg, _, stack) grabError(tostring(msg) .. tostring(stack)) end, - isFake = true + isFake = true, } end local swatterDisabled = nil function events:ADDON_LOADED(_, msg) - if not callbacks then - setupCallbacks() - end - if msg == 'Stubby' then - createSwatter() - end + if not callbacks then setupCallbacks() end + if msg == 'Stubby' then createSwatter() end if initDatabase then -- If we're running embedded, just init as soon as possible, -- but if we are running separately we init when !BugGrabber -- loads so that our SVs are available. - if bugGrabberParentAddon ~= STANDALONE_NAME or msg == bugGrabberParentAddon then - initDatabase() - end + if bugGrabberParentAddon ~= STANDALONE_NAME or msg == bugGrabberParentAddon then initDatabase() end end if not swatterDisabled and _G.Swatter and not _G.Swatter.isFake then swatterDisabled = true - if bugGrabberParentAddon == STANDALONE_NAME then - print(L.ADDON_DISABLED:format('Swatter', 'Swatter', 'Swatter')) - end + if bugGrabberParentAddon == STANDALONE_NAME then print(L.ADDON_DISABLED:format('Swatter', 'Swatter', 'Swatter')) end DisableAddOn('!Swatter') SlashCmdList.SWATTER = nil SLASH_SWATTER1, SLASH_SWATTER2 = nil, nil for _, v in next, Swatter do if type(v) == 'table' then - if v.UnregisterAllEvents then - v:UnregisterAllEvents() - end - if v.Hide then - v:Hide() - end + if v.UnregisterAllEvents then v:UnregisterAllEvents() end + if v.Hide then v:Hide() end end end Swatter = nil local _, _, _, enabled = GetAddOnInfo('Stubby') - if enabled then - createSwatter() - end + if enabled then createSwatter() end real_seterrorhandler(grabError) end @@ -619,9 +538,7 @@ do end function events:PLAYER_LOGIN() - if not callbacks then - setupCallbacks() - end + if not callbacks then setupCallbacks() end real_seterrorhandler(grabError) end do @@ -638,23 +555,16 @@ events.ADDON_ACTION_BLOCKED = events.ADDON_ACTION_FORBIDDEN function events:LUA_WARNING(_, warnType, warningText) -- Temporary hack for the few dropdown libraries that exist that were designed poorly -- Hopefully we will see a rewrite of dropdowns soon - if warnType == 0 and warningText:find('DropDown', nil, true) then - return - end + if warnType == 0 and warningText:find('DropDown', nil, true) then return end grabError(warningText, true) end UIParent:UnregisterEvent('LUA_WARNING') real_seterrorhandler(grabError) -function seterrorhandler --[[ noop ]]() +function seterrorhandler() --[[ noop ]] end -- Set up slash command SlashCmdList.BugGrabber = slashHandler SLASH_BugGrabber1 = '/buggrabber' -BugGrabber = - setmetatable( - {}, - {__index = addon, __newindex = function() - end, __metatable = false} -) +BugGrabber = setmetatable({}, { __index = addon, __newindex = function() end, __metatable = false }) diff --git a/libs/bug-grabber/embedding.txt b/libs/bug-grabber/embedding.txt index 4d5d69e5..5bc42821 100644 --- a/libs/bug-grabber/embedding.txt +++ b/libs/bug-grabber/embedding.txt @@ -28,7 +28,7 @@ errors as you see fit. or not there is - you should not do /anything/ or even register for the callbacks. For now you can use the following code to check; -local name, _, _, enabled = GetAddOnInfo("BugSack") +local name, _, _, enabled = C_AddOns.GetAddOnInfo("BugSack") if name and enabled then -- Don't do anything! end diff --git a/libs/oUF/oUF.lua b/libs/oUF/oUF.lua index e16c2d1a..09d9aebb 100644 --- a/libs/oUF/oUF.lua +++ b/libs/oUF/oUF.lua @@ -1,5 +1,5 @@ local parent, ns = ... -local GetAddOnMetadata = (C_AddOns and C_AddOns.GetAddOnMetadata) or GetAddOnMetadata +local GetAddOnMetadata = C_AddOns.GetAddOnMetadata local global = GetAddOnMetadata(parent, 'X-oUF') local _VERSION = 'devel' @@ -56,20 +56,18 @@ local function updateActiveUnit(self, event) local realUnit, modUnit = SecureButton_GetUnit(self), SecureButton_GetModifiedUnit(self) -- _GetUnit() doesn't rewrite playerpet -> pet like _GetModifiedUnit does. - if(realUnit == 'playerpet') then + if realUnit == 'playerpet' then realUnit = 'pet' - elseif(realUnit == 'playertarget') then + elseif realUnit == 'playertarget' then realUnit = 'target' end - if(modUnit == 'pet' and realUnit ~= 'pet') then - modUnit = 'vehicle' - end + 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 + if Private.UpdateUnits(self, modUnit, realUnit) then self:UpdateAllElements(event or 'RefreshUnit') return true @@ -77,121 +75,113 @@ local function updateActiveUnit(self, event) end local function evalUnitAndUpdate(self, event) - if(not updateActiveUnit(self, event)) then - return self:UpdateAllElements(event) - end + if not updateActiveUnit(self, event) then return self:UpdateAllElements(event) end end local function iterateChildren(...) for i = 1, select('#', ...) do local obj = select(i, ...) - if(type(obj) == 'table' and obj.isChild) then - updateActiveUnit(obj, 'iterateChildren') - end + 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 - iterateChildren(self:GetChildren()) - end + if name == 'unit' and value then + if self.hasChildren then iterateChildren(self:GetChildren()) end - if(not self:GetAttribute('oUF-onlyProcessChildren')) then - updateActiveUnit(self, 'OnAttributeChanged') - end + 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 - tinsert(self.__elements, element.update) + if element.update then tinsert(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 - tremove(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 + tremove(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:SetEnabled(enabled, asState) + --[[ frame:SetEnabled(enabled, asState) * self - unit frame * enabled - on or off * 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) --]] - SetEnabled = function(self, enabled, asState) - if enabled then - RegisterUnitWatch(self, asState) - else - UnregisterUnitWatch(self) - self:Hide() - end - end, + SetEnabled = function(self, enabled, asState) + if enabled then + RegisterUnitWatch(self, asState) + else + UnregisterUnitWatch(self) + self:Hide() + end + 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`. @@ -199,60 +189,61 @@ 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 @@ -262,23 +253,23 @@ end local function updatePet(self, event, unit) local petUnit - if(unit == 'target') then + if unit == 'target' then return - elseif(unit == 'player') then + elseif unit == 'player' then petUnit = 'pet' else -- Convert raid26 -> raidpet26 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) @@ -290,7 +281,7 @@ end local eventlessUnits = { boss6 = true, boss7 = true, - boss8 = true + boss8 = true, } local function isEventlessUnit(unit) @@ -306,9 +297,7 @@ local function initObject(unit, style, styleFunc, header, ...) -- Handle the case where someone has modified the unitsuffix attribute in -- oUF-initialConfigFunction. - if(suffix and not objectUnit:match(suffix)) then - objectUnit = objectUnit .. suffix - end + if suffix and not objectUnit:match(suffix) then objectUnit = objectUnit .. suffix end object.__elements = {} object.style = style @@ -318,9 +307,7 @@ local function initObject(unit, style, styleFunc, header, ...) tinsert(objects, object) -- add the mixin for pings - if PingableType_UnitFrameMixin then - Mixin(object, PingableType_UnitFrameMixin) - end + if PingableType_UnitFrameMixin then Mixin(object, PingableType_UnitFrameMixin) end -- We have to force update the frames when PEW fires. -- It's also important to evaluate units before running an update @@ -331,19 +318,17 @@ local function initObject(unit, style, styleFunc, header, ...) -- frame will be stuck with the 'vehicle' unit. object:RegisterEvent('PLAYER_ENTERING_WORLD', evalUnitAndUpdate, true) - if(not isEventlessUnit(objectUnit)) then + 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) - end + 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') @@ -358,7 +343,7 @@ local function initObject(unit, style, styleFunc, header, ...) --]] object:SetAttribute('ping-receiver', true) - if(isEventlessUnit(objectUnit)) then + if isEventlessUnit(objectUnit) then oUF:HandleEventlessUnit(object) else oUF:HandleUnit(object) @@ -368,17 +353,15 @@ local function initObject(unit, style, styleFunc, header, ...) -- updateRaid relies on UnitGUID to detect the unit change 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 - oUF:HandleEventlessUnit(object) - end + if suffix == 'target' then oUF:HandleEventlessUnit(object) end end Private.UpdateUnits(object, objectUnit) @@ -389,7 +372,7 @@ local function initObject(unit, style, styleFunc, header, ...) -- 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 + if not object.isNamePlate then object:SetScript('OnShow', onShow) -- Make Clique kinda happy @@ -416,7 +399,7 @@ local function walkObject(object, unit) 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) return initObject(unit, style, styleFunc, header, object:GetChildren()) @@ -446,9 +429,7 @@ function oUF:RegisterMetaFunction(name, func) argcheck(name, 2, 'string') argcheck(func, 3, 'function', 'table') - if(frame_metatable.__index[name]) then - return - end + if frame_metatable.__index[name] then return end frame_metatable.__index[name] = func end @@ -464,8 +445,8 @@ function oUF:RegisterStyle(name, func) 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 @@ -478,7 +459,7 @@ Used to set the active style. --]] function oUF:SetActiveStyle(name) argcheck(name, 2, 'string') - if(not styles[name]) then return error('Style [%s] does not exist.', name) end + if not styles[name] then return error('Style [%s] does not exist.', name) end style = name end @@ -526,9 +507,7 @@ do local short = select(i, ...) local condition = conditions[short] - if(condition) then - cond = cond .. condition - end + if condition then cond = cond .. condition end end return cond .. 'hide' @@ -541,29 +520,29 @@ local function generateName(unit, ...) local raid, party, groupFilter, unitsuffix for i = 1, select('#', ...), 2 do local att, val = select(i, ...) - if(att == 'oUF-initialConfigFunction') then + if att == 'oUF-initialConfigFunction' then unitsuffix = val:match('unitsuffix[%p%s]+(%a+)') - elseif(att == 'showRaid') then + 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 + if raid then + if groupFilter then + if type(groupFilter) == 'number' and groupFilter > 0 then append = 'Raid' .. groupFilter - elseif(groupFilter:match('MAINTANK')) then + elseif groupFilter:match('MAINTANK') then append = 'MainTank' - elseif(groupFilter:match('MAINASSIST')) then + elseif groupFilter:match('MAINASSIST') then append = 'MainAssist' else local _, count = groupFilter:gsub(',', '') - if(count == 0) then + if count == 0 then append = 'Raid' .. groupFilter else append = 'Raid' @@ -572,15 +551,13 @@ local function generateName(unit, ...) else append = 'Raid' end - elseif(party) then + elseif party then append = 'Party' - elseif(unit) then + elseif unit then append = unit:gsub('^%l', strupper) end - if(append) then - name = name .. append .. (unitsuffix or '') - end + if append then name = name .. append .. (unitsuffix or '') end -- Change oUF_LilyRaidRaid into oUF_LilyRaid name = name:gsub('(%u%l+)([%u%l]*)%1', '%1') @@ -591,7 +568,7 @@ local function generateName(unit, ...) local base = name local i = 2 - while(_G[name]) do + while _G[name] do name = base .. i i = i + 1 end @@ -687,7 +664,7 @@ 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') @@ -698,7 +675,7 @@ do header:SetAttribute('template', 'SecureUnitButtonTemplate, SecureHandlerStateTemplate, SecureHandlerEnterLeaveTemplate') 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 @@ -712,47 +689,55 @@ do -- 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( + '_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') - if(_G.Clique) then - SecureHandlerSetFrameRef(header, 'clickcast_header', _G.Clique.header) - end + if _G.Clique then SecureHandlerSetFrameRef(header, 'clickcast_header', _G.Clique.header) end - if(header:GetAttribute('showParty')) then - self:DisableBlizzard('party') - end + if header:GetAttribute('showParty') then self:DisableBlizzard('party') end - if(visibility) then + if visibility then local which, list = strsplit(' ', visibility, 2) - if(list and which == 'custom') then + if list and which == 'custom' then RegisterAttributeDriver(header, 'state-visibility', list) header.visibility = list else @@ -780,7 +765,7 @@ oUF implements some of its own attributes. These can be supplied by the layout, --]] function oUF:Spawn(unit, overrideName, overrideTemplate) -- ElvUI adds overrideTemplate argcheck(unit, 2, 'string') - if(not style) then return error('Unable to create frame. No styles have been registered.') end + if not style then return error('Unable to create frame. No styles have been registered.') end unit = unit:lower() @@ -810,8 +795,8 @@ Used to create nameplates and apply the currently active style to them. 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 + 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() @@ -830,8 +815,8 @@ function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars) eventHandler:RegisterEvent('UNIT_FACTION') eventHandler:RegisterEvent('UNIT_HEALTH') - if(IsLoggedIn()) then - if(nameplateCVars) then + if IsLoggedIn() then + if nameplateCVars then for cvar, value in next, nameplateCVars do SetCVar(cvar, value) end @@ -841,40 +826,34 @@ function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars) end eventHandler:SetScript('OnEvent', function(_, event, unit) - if(event == 'PLAYER_LOGIN') then - if(nameplateCVars) then + 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 + elseif event == 'PLAYER_TARGET_CHANGED' then local nameplate = GetNamePlateForUnit('target') local unitFrame = nameplate and nameplate.unitFrame - if(nameplateCallback) then - nameplateCallback(unitFrame, event, 'target') - end + if nameplateCallback then nameplateCallback(unitFrame, event, 'target') end -- UAE is called after the callback to reduce the number of -- ForceUpdate calls layout devs have to do themselves - if unitFrame and unitFrame.UpdateAllElements then - nameplate.unitFrame:UpdateAllElements(event) - end - elseif((event == 'UNIT_FACTION' or event == 'UNIT_HEALTH' or event == 'UNIT_MAXHEALTH') and unit) then + if unitFrame and unitFrame.UpdateAllElements then nameplate.unitFrame:UpdateAllElements(event) end + elseif (event == 'UNIT_FACTION' or event == 'UNIT_HEALTH' or event == 'UNIT_MAXHEALTH') and unit then local nameplate = GetNamePlateForUnit(unit) - if(not nameplate) then return end + if not nameplate then return end - if(nameplateCallback) then - nameplateCallback(nameplate.unitFrame, event, unit) - end - elseif(event == 'NAME_PLATE_UNIT_ADDED' and unit) then + if nameplateCallback then nameplateCallback(nameplate.unitFrame, event, unit) end + elseif event == 'NAME_PLATE_UNIT_ADDED' and unit then local 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) + nameplate.unitFrame = CreateFrame('Button', prefix .. nameplate:GetName(), nameplate) nameplate.unitFrame:EnableMouse(false) nameplate.unitFrame.isNamePlate = true @@ -887,24 +866,18 @@ function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars) nameplate.unitFrame:SetAttribute('unit', unit) - if(nameplateCallback) then - nameplateCallback(nameplate.unitFrame, event, unit) - end + 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 - if nameplate.unitFrame.UpdateAllElements then - nameplate.unitFrame:UpdateAllElements(event) - end - elseif(event == 'NAME_PLATE_UNIT_REMOVED' and unit) then + if nameplate.unitFrame.UpdateAllElements then nameplate.unitFrame:UpdateAllElements(event) end + elseif event == 'NAME_PLATE_UNIT_REMOVED' and unit then local nameplate = GetNamePlateForUnit(unit) - if(not nameplate) then return end + if not nameplate then return end nameplate.unitFrame:SetAttribute('unit', nil) - if(nameplateCallback) then - nameplateCallback(nameplate.unitFrame, event, unit) - end + if nameplateCallback then nameplateCallback(nameplate.unitFrame, event, unit) end end end) end @@ -924,11 +897,11 @@ function oUF:AddElement(name, update, enable, disable) 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 @@ -950,10 +923,10 @@ 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 @@ -975,9 +948,7 @@ do -- ShouldSkipAuraUpdate by Blizzard (implemented and heavily modified by Simp eventFrame:RegisterEvent('PLAYER_ENTERING_WORLD') eventFrame:RegisterEvent('PLAYER_LEAVING_WORLD') - if oUF.isRetail then - eventFrame:RegisterUnitEvent('PLAYER_SPECIALIZATION_CHANGED', 'player') - end + if oUF.isRetail then eventFrame:RegisterUnitEvent('PLAYER_SPECIALIZATION_CHANGED', 'player') end eventFrame:SetScript('OnEvent', function(_, event) if event == 'PLAYER_ENTERING_WORLD' then @@ -1001,7 +972,7 @@ do -- ShouldSkipAuraUpdate by Blizzard (implemented and heavily modified by Simp if not hasValidPlayer then -- Don't cache the info if the player is not valid since we didn't get a valid result return VisibilityInfo(spellId) else - cachedVisibility[spellId] = {VisibilityInfo(spellId)} + cachedVisibility[spellId] = { VisibilityInfo(spellId) } end end @@ -1014,17 +985,13 @@ do -- ShouldSkipAuraUpdate by Blizzard (implemented and heavily modified by Simp end local AlwaysAllow = { -- spells could get stuck but it's very rare, this table is for that - [335904] = true -- Doom Winds: Unable to gain effects of Doom Winds + [335904] = true, -- Doom Winds: Unable to gain effects of Doom Winds } local function AuraIsPriority(spellId) - if AlwaysAllow[spellId] then - return true - end + if AlwaysAllow[spellId] then return true end - if cachedPriority[spellId] == nil then - cachedPriority[spellId] = SpellIsPriorityAura(spellId) - end + if cachedPriority[spellId] == nil then cachedPriority[spellId] = SpellIsPriorityAura(spellId) end return cachedPriority[spellId] end @@ -1046,9 +1013,7 @@ do -- ShouldSkipAuraUpdate by Blizzard (implemented and heavily modified by Simp return false elseif updatedAuras and relevantFunc then for _, auraInfo in ipairs(updatedAuras) do - if relevantFunc(frame, event, unit, auraInfo, ...) then - return false - end + if relevantFunc(frame, event, unit, auraInfo, ...) then return false end end return true @@ -1080,9 +1045,7 @@ do -- Event Pooler by Simpy if instant and funcs then if event == 'UNIT_AURA' and oUF.isRetail then local fullUpdate, updatedAuras = ... - if not oUF:ShouldSkipAuraUpdate(frame, event, arg1, fullUpdate, updatedAuras) then - pooler.run(funcs, frame, event, arg1, fullUpdate, updatedAuras) - end + if not oUF:ShouldSkipAuraUpdate(frame, event, arg1, fullUpdate, updatedAuras) then pooler.run(funcs, frame, event, arg1, fullUpdate, updatedAuras) end else pooler.run(funcs, frame, event, arg1, ...) end @@ -1099,9 +1062,7 @@ do -- Event Pooler by Simpy end end - if allowUnit then - pooler.run(funcs, frame, event, allowUnit) - end + if allowUnit then pooler.run(funcs, frame, event, allowUnit) end else local count = #data local args = count and data[count] @@ -1109,7 +1070,6 @@ do -- Event Pooler by Simpy -- if count > 1 then print(frame:GetDebugName(), event, count, unpack(args)) end pooler.run(funcs, frame, event, unpack(args)) end - end wipe(data) @@ -1137,11 +1097,9 @@ do -- Event Pooler by Simpy elseif arg1 ~= nil then -- require arg1, no unitless local pooled = pool[frame] if pooled then - if not pooled.data[event] then - pooled.data[event] = {} - end + if not pooled.data[event] then pooled.data[event] = {} end - tinsert(pooled.data[event], {arg1, ...}) + tinsert(pooled.data[event], { arg1, ... }) end end @@ -1166,9 +1124,9 @@ do -- Event Pooler by Simpy if not pooler.events[event] then pooler.events[event] = {} - pooler.events[event][frame] = {functions={},data={}} + pooler.events[event][frame] = { functions = {}, data = {} } elseif not pooler.events[event][frame] then - pooler.events[event][frame] = {functions={},data={}} + pooler.events[event][frame] = { functions = {}, data = {} } end frame:RegisterEvent(event, pooler.tracker) @@ -1183,9 +1141,7 @@ do -- Event Pooler by Simpy local pooled = pool[frame] if pooled then for i, funct in ipairs(pooled.functions) do - if funct == func then - tremove(pooled.functions, i) - end + if funct == func then tremove(pooled.functions, i) end end if not next(pooled.functions) then @@ -1193,9 +1149,7 @@ do -- Event Pooler by Simpy pooled.data = nil -- clear data end - if not next(pooled) then - pool[frame] = nil - end + if not next(pooled) then pool[frame] = nil end end if not next(pool) then