From 0f4f16b6f0d643affe368abca0423c47e41ef029 Mon Sep 17 00:00:00 2001 From: Bunny67 Date: Mon, 14 Sep 2020 10:12:22 +0300 Subject: [PATCH] beta --- WeakAuras/Animations.lua | 29 +- WeakAuras/AuraEnvironment.lua | 84 ++- WeakAuras/AuraWarnings.lua | 2 +- WeakAuras/BuffTrigger2.lua | 110 ++- WeakAuras/Conditions.lua | 20 +- WeakAuras/GenericTrigger.lua | 319 ++++----- WeakAuras/History.lua | 16 +- WeakAuras/Init.lua | 18 +- WeakAuras/Modernize.lua | 38 +- WeakAuras/Profiling.lua | 39 +- WeakAuras/Prototypes.lua | 185 +++-- WeakAuras/RegionTypes/AuraBar.lua | 24 +- WeakAuras/RegionTypes/DynamicGroup.lua | 44 +- WeakAuras/RegionTypes/Group.lua | 2 +- WeakAuras/RegionTypes/Icon.lua | 12 +- WeakAuras/RegionTypes/Model.lua | 18 +- WeakAuras/RegionTypes/RegionPrototype.lua | 148 ++-- WeakAuras/RegionTypes/StopMotion.lua | 12 +- WeakAuras/RegionTypes/Text.lua | 16 +- WeakAuras/SubRegionTypes/Glow.lua | 2 +- WeakAuras/SubRegionTypes/SubText.lua | 28 +- WeakAuras/SubRegionTypes/Tick.lua | 2 +- WeakAuras/Transmission.lua | 125 ++-- WeakAuras/Types.lua | 412 +++++------ WeakAuras/WeakAuras.lua | 656 ++++++++---------- .../AceGUIWidget-WeakAurasDisplayButton.lua | 136 ++-- .../AceGUIWidget-WeakAurasExpand.lua | 2 +- .../AceGUIWidget-WeakAurasExpandAnchor.lua | 12 +- .../AceGUIWidget-WeakAurasExpandSmall.lua | 11 +- ...AceGUIWidget-WeakAurasMultiLineEditBox.lua | 2 +- .../AceGUIWidget-WeakAurasSnippetButton.lua | 2 +- WeakAurasOptions/ActionOptions.lua | 85 ++- WeakAurasOptions/AnimationOptions.lua | 94 +-- WeakAurasOptions/AuthorOptions.lua | 90 ++- WeakAurasOptions/BuffTrigger.lua | 80 ++- WeakAurasOptions/BuffTrigger2.lua | 43 +- WeakAurasOptions/Cache.lua | 3 +- WeakAurasOptions/CommonOptions.lua | 114 ++- WeakAurasOptions/ConditionOptions.lua | 130 ++-- WeakAurasOptions/DisplayOptions.lua | 53 +- WeakAurasOptions/ExternalAddons.lua | 49 +- WeakAurasOptions/GenericTrigger.lua | 65 +- WeakAurasOptions/GroupOptions.lua | 8 +- WeakAurasOptions/InformationOptions.lua | 6 +- WeakAurasOptions/LoadOptions.lua | 111 +-- WeakAurasOptions/OptionsFrames/CodeReview.lua | 3 +- .../OptionsFrames/FrameChooser.lua | 17 +- WeakAurasOptions/OptionsFrames/IconPicker.lua | 2 +- .../OptionsFrames/ImportExport.lua | 4 +- .../OptionsFrames/ModelPicker.lua | 2 +- WeakAurasOptions/OptionsFrames/MoverSizer.lua | 24 +- .../OptionsFrames/OptionsFrame.lua | 104 ++- WeakAurasOptions/OptionsFrames/TextEditor.lua | 78 +-- .../OptionsFrames/TexturePicker.lua | 3 +- WeakAurasOptions/RegionOptions/AuraBar.lua | 36 +- .../RegionOptions/DynamicGroup.lua | 38 +- WeakAurasOptions/RegionOptions/Group.lua | 24 +- WeakAurasOptions/RegionOptions/Icon.lua | 34 +- WeakAurasOptions/RegionOptions/Model.lua | 6 +- .../RegionOptions/ProgressTexture.lua | 20 +- WeakAurasOptions/RegionOptions/StopMotion.lua | 8 +- WeakAurasOptions/RegionOptions/Text.lua | 40 +- WeakAurasOptions/RegionOptions/Texture.lua | 8 +- .../SubRegionOptions/BarModel.lua | 11 +- WeakAurasOptions/SubRegionOptions/Border.lua | 11 +- WeakAurasOptions/SubRegionOptions/Glow.lua | 21 +- .../SubRegionOptions/SubRegionCommon.lua | 7 +- WeakAurasOptions/SubRegionOptions/SubText.lua | 57 +- WeakAurasOptions/SubRegionOptions/Tick.lua | 33 +- WeakAurasOptions/TriggerOptions.lua | 43 +- WeakAurasOptions/WeakAurasOptions.lua | 642 +++++++---------- 71 files changed, 2302 insertions(+), 2431 deletions(-) diff --git a/WeakAuras/Animations.lua b/WeakAuras/Animations.lua index fe71514..9e683fa 100644 --- a/WeakAuras/Animations.lua +++ b/WeakAuras/Animations.lua @@ -4,8 +4,7 @@ local AddonName, Private = ... -- Animations local animations = {} local pending_controls = {} -local anim_presets = WeakAuras.anim_presets; -local anim_function_strings = WeakAuras.anim_function_strings; +local anim_function_strings = Private.anim_function_strings; local function noopErrorHandler() end @@ -14,7 +13,7 @@ local frame = WeakAuras.frames["WeakAuras Main Frame"] local updatingAnimations; local last_update = GetTime(); local function UpdateAnimations() - WeakAuras.StartProfileSystem("animations"); + Private.StartProfileSystem("animations"); local errorHandler = WeakAuras.IsOptionsOpen() and noopErrorHandler or geterrorhandler() for groupUid, groupRegion in pairs(pending_controls) do pending_controls[groupUid] = nil; @@ -26,7 +25,7 @@ local function UpdateAnimations() last_update = time; local num = 0; for key, anim in pairs(animations) do - WeakAuras.StartProfileUID(anim.auraUID); + Private.StartProfileUID(anim.auraUID); num = num + 1; local finished = false; if(anim.duration_type == "seconds") then @@ -168,15 +167,15 @@ local function UpdateAnimations() end if(anim.loop) then - WeakAuras.Animate(anim.namespace, anim.auraUID, anim.type, anim.anim, anim.region, anim.inverse, anim.onFinished, anim.loop, anim.region.cloneId); + Private.Animate(anim.namespace, anim.auraUID, anim.type, anim.anim, anim.region, anim.inverse, anim.onFinished, anim.loop, anim.region.cloneId); elseif(anim.onFinished) then anim.onFinished(); end end - WeakAuras.StopProfileUID(anim.auraUID); + Private.StopProfileUID(anim.auraUID); end - WeakAuras.StopProfileSystem("animations"); + Private.StopProfileSystem("animations"); end function Private.RegisterGroupForPositioning(uid, region) @@ -185,14 +184,14 @@ function Private.RegisterGroupForPositioning(uid, region) frame:SetScript("OnUpdate", UpdateAnimations) end -function WeakAuras.Animate(namespace, uid, type, anim, region, inverse, onFinished, loop, cloneId) - local auraDisplayName = WeakAuras.UIDtoID(uid) +function Private.Animate(namespace, uid, type, anim, region, inverse, onFinished, loop, cloneId) + local auraDisplayName = Private.UIDtoID(uid) local key = tostring(region); local valid; if(anim and anim.type == "custom" and (anim.use_translate or anim.use_alpha or (anim.use_scale and region.Scale) or (anim.use_rotate and region.Rotate) or (anim.use_color and region.Color))) then valid = true; - elseif(anim and anim.type == "preset" and anim.preset and anim_presets[anim.preset]) then - anim = anim_presets[anim.preset]; + elseif(anim and anim.type == "preset" and anim.preset and Private.anim_presets[anim.preset]) then + anim = Private.anim_presets[anim.preset]; valid = true; end if(valid) then @@ -316,9 +315,9 @@ function WeakAuras.Animate(namespace, uid, type, anim, region, inverse, onFinish elseif(region.ColorAnim) then region:ColorAnim(nil); end - easeFunc = WeakAuras.anim_ease_functions[anim.easeType or "none"] + easeFunc = Private.anim_ease_functions[anim.easeType or "none"] - duration = WeakAuras.ParseNumber(anim.duration) or 0; + duration = Private.ParseNumber(anim.duration) or 0; progress = 0; if(namespace == "display" and type == "main" and not onFinished and not anim.duration_type == "relative") then local data = Private.GetDataByUID(uid); @@ -387,14 +386,14 @@ function WeakAuras.Animate(namespace, uid, type, anim, region, inverse, onFinish else if(animations[key]) then if(animations[key].type ~= type or loop) then - WeakAuras.CancelAnimation(region, true, true, true, true, true); + Private.CancelAnimation(region, true, true, true, true, true); end end return false; end end -function WeakAuras.CancelAnimation(region, resetPos, resetAlpha, resetScale, resetRotation, resetColor, doOnFinished) +function Private.CancelAnimation(region, resetPos, resetAlpha, resetScale, resetRotation, resetColor, doOnFinished) local key = tostring(region); local anim = animations[key]; diff --git a/WeakAuras/AuraEnvironment.lua b/WeakAuras/AuraEnvironment.lua index 7e58e70..4a115aa 100644 --- a/WeakAuras/AuraEnvironment.lua +++ b/WeakAuras/AuraEnvironment.lua @@ -3,7 +3,6 @@ local AddonName, Private = ... local WeakAuras = WeakAuras local L = WeakAuras.L -local prettyPrint = WeakAuras.prettyPrint local UnitAura = UnitAura -- Unit Aura functions that return info about the first Aura matching the spellName or spellID given on the unit. @@ -55,7 +54,7 @@ local WA_ClassColorName = function(unit) if not class then return name else - local classData = RAID_CLASS_COLORS[class] + local classData = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class] local coloredName = ("|c%s%s|r"):format(classData.colorStr, name) return coloredName end @@ -268,9 +267,9 @@ function Private.ActivateAuraEnvironment(id, cloneId, state, states, onlyConfig) end end -local function blocked() +local function blocked(key) Private.AuraWarnings.UpdateWarning(current_uid, "SandboxForbidden", "error", - L["Forbidden function or table."]) + string.format(L["Forbidden function or table: %s"], key)) end local function MakeReadOnly(input, options) @@ -278,9 +277,11 @@ local function MakeReadOnly(input, options) { __index = function(t, k) if options.blockedFunctions[k] then - return options.blocked + options.blocked(k) + return function() end elseif options.blockedTables[k] then - return options.blocked() + options.blocked(k) + return {} elseif options.override[k] then return options.override[k] else @@ -294,12 +295,79 @@ end local FakeWeakAurasMixin = { blockedFunctions = { + -- Other addons might use these, so before moving them to the Private space, we need + -- to discuss these. But Auras have no purpose for calling these Add = true, + AddMany = true, + AddManyFromAddons = true, + Delete = true, + DeleteOption = true, + GetData = true, + HideOptions = true, Rename = true, - Delete = true + NewAura = true, + OptionsFrame = true, + RegisterAddon = true, + RegisterDisplay = true, + RegisterRegionOptions = true, + RegisterSubRegionOptions = true, + RegisterSubRegionType = true, + RegisterRegionType = true, + RegisterTriggerSystem = true, + RegisterTriggerSystemOptions = true, + ShowOptions = true, + -- Note these shouldn't exist in the WeakAuras namespace, but moving them takes a bit of effort, + -- so for now just block them and clean them up later + CollisionResolved = true, + ClearAndUpdateOptions = true, + CloseCodeReview = true, + CloseImportExport = true, + CreateTemplateView = true, + DeleteOption = true, + DeleteCollapsedData = true, + DisplayToString = true, + FillOptions = true, + FindUnusedId = true, + GetMoverSizerId = true, + GetDisplayButton = true, + Import = true, + NewDisplayButton = true, + NewAura = true, + OpenTriggerTemplate = true, + OpenCodeReview = true, + PickDisplay = true, + RenameCollapsedData = true, + SetMoverSizer = true, + SetImporting = true, + SortDisplayButtons = true, + ShowOptions = true, + ToggleOptions = true, + UpdateDisplayButton = true, + UpdateGroupOrders = true, + UpdateThumbnail = true, + validate = true, + getDefaultGlow = true, + -- Note, I'm too lazy to move these to private because the code needs to deleted... + IsDefinedByAddon = true, + }, blockedTables = { - AuraWarnings = true + AuraWarnings = true, + ModelPaths = true, + regionPrototype = true, + -- Note these shouldn't exist in the WeakAuras namespace, but moving them takes a bit of effort, + -- so for now just block them and clean them up later + data_stub = true, + displayButtons = true, + regionTypes = true, + regionOptions = true, + spellCache = true, + triggerTemplates = true, + frames = true, + loadFrame = true, + unitLoadFrame = true, + importDisplayButtons = true + }, override = { me = UnitName("player"), diff --git a/WeakAuras/AuraWarnings.lua b/WeakAuras/AuraWarnings.lua index 3a39c9a..319b127 100644 --- a/WeakAuras/AuraWarnings.lua +++ b/WeakAuras/AuraWarnings.lua @@ -22,7 +22,7 @@ local function UpdateWarning(uid, key, severity, message, printOnConsole) if printOnConsole then printedWarnings[uid] = printedWarnings[uid] or {} if printedWarnings[uid][key] == nil then - WeakAuras.prettyPrint(string.format(L["Aura '%s': %s"], WeakAuras.UIDtoID(uid), message)) + WeakAuras.prettyPrint(string.format(L["Aura '%s': %s"], Private.UIDtoID(uid), message)) printedWarnings[uid][key] = true end end diff --git a/WeakAuras/BuffTrigger2.lua b/WeakAuras/BuffTrigger2.lua index 267a63d..c9dd477 100644 --- a/WeakAuras/BuffTrigger2.lua +++ b/WeakAuras/BuffTrigger2.lua @@ -16,9 +16,6 @@ Unloads the aura ids, disabling all buff triggers in the aura. UnloadAll() Unloads all auras, disabling all buff triggers. -ScanAll() -Updates all triggers by checking all triggers. - Delete(id) Removes all data for aura id. @@ -92,7 +89,7 @@ local groupScanFuncs = {} local activeGroupScanFuncs = {} --- Mutli Target tracking +-- Multi Target tracking local scanFuncNameMulti = {} local scanFuncSpellIdMulti = {} local cleanupTimerMulti = {} @@ -237,10 +234,10 @@ local function UpdateMatchData(time, matchDataChanged, unit, index, filter, name duration = duration, expirationTime = expirationTime, unitCaster = unitCaster, - casterName = unitCaster and UnitName(unitCaster) or "", + casterName = unitCaster and GetUnitName(unitCaster, false) or "", spellId = spellId, unit = unit, - unitName = UnitName(unit) or "", + unitName = GetUnitName(unit, false) or "", isStealable = isStealable, time = time, lastChanged = time, @@ -290,7 +287,7 @@ local function UpdateMatchData(time, matchDataChanged, unit, index, filter, name changed = true end - local casterName = unitCaster and UnitName(unitCaster) or "" + local casterName = unitCaster and GetUnitName(unitCaster, false) or "" if data.casterName ~= casterName then data.casterName = casterName changed = true @@ -306,7 +303,7 @@ local function UpdateMatchData(time, matchDataChanged, unit, index, filter, name changed = true end - local unitName = UnitName(unit) or "" + local unitName = GetUnitName(unit, false) or "" if data.unitName ~= unitName then data.unitName = unitName changed = true @@ -617,7 +614,7 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, affected = affected, unaffected = unaffected, unit = unit, - unitName = unit and UnitName(unit) or "", + unitName = unit and GetUnitName(unit, false) or "", destName = "", name = fallbackName, icon = fallbackIcon, @@ -669,7 +666,7 @@ local function UpdateStateWithNoMatch(time, triggerStates, triggerInfo, cloneId, changed = true end - local unitName = unit and UnitName(unit) or "" + local unitName = unit and GetUnitName(unit, false) or "" if state.unitName ~= unitName then state.unitName = unitName changed = true @@ -881,7 +878,7 @@ local function TriggerInfoApplies(triggerInfo, unit) if triggerInfo.unit == "group" and triggerInfo.groupSubType == "party" then if IsInRaid() then -- Filter our player/party# while in raid and keep only raid units that are correct - if not WeakAuras.multiUnitUnits.raid[unit] or not UnitIsUnit("player", unit) then + if not Private.multiUnitUnits.raid[unit] or not UnitIsUnit("player", unit) then return false end else @@ -892,11 +889,11 @@ local function TriggerInfoApplies(triggerInfo, unit) end -- Filter our player/party# while in raid - if (triggerInfo.unit == "group" and triggerInfo.groupSubType == "group" and IsInRaid() and not WeakAuras.multiUnitUnits.raid[unit]) then + if (triggerInfo.unit == "group" and triggerInfo.groupSubType == "group" and IsInRaid() and not Private.multiUnitUnits.raid[unit]) then return false end - if triggerInfo.unit == "group" and triggerInfo.groupSubType == "raid" and not WeakAuras.multiUnitUnits.raid[unit] then + if triggerInfo.unit == "group" and triggerInfo.groupSubType == "raid" and not Private.multiUnitUnits.raid[unit] then return false end @@ -917,9 +914,9 @@ local function FormatAffectedUnaffected(triggerInfo, matchedUnits) for unit in GetAllUnits(triggerInfo.unit) do if activeGroupScanFuncs[unit] and activeGroupScanFuncs[unit][triggerInfo] then if matchedUnits[unit] then - affected = affected .. (UnitName(unit) or unit) .. ", " + affected = affected .. (GetUnitName(unit, false) or unit) .. ", " else - unaffected = unaffected .. (UnitName(unit) or unit) .. ", " + unaffected = unaffected .. (GetUnitName(unit, false) or unit) .. ", " end end end @@ -1295,15 +1292,15 @@ end local function UpdateStates(matchDataChanged, time) for id, auraData in pairs(matchDataChanged) do - WeakAuras.StartProfileAura(id) + Private.StartProfileAura(id) local updated = false for triggernum in pairs(auraData) do updated = UpdateTriggerState(time, id, triggernum) or updated end if updated then - WeakAuras.UpdatedTriggerState(id) + Private.UpdatedTriggerState(id) end - WeakAuras.StopProfileAura(id) + Private.StopProfileAura(id) end end @@ -1361,7 +1358,7 @@ end local function ScanAllGroup(time, matchDataChanged) -- We iterate over all raid/player unit ids here because ScanGroupUnit also - -- handles the cases where a unit existance changes. + -- handles the cases where a unit existence changes. for unit in GetAllUnits("group") do ScanGroupUnit(time, matchDataChanged, "group", unit) end @@ -1375,13 +1372,13 @@ end local function ScanUnit(time, arg1) if not arg1 then return end - if (WeakAuras.multiUnitUnits.raid[arg1] and IsInRaid()) then + if (Private.multiUnitUnits.raid[arg1] and IsInRaid()) then ScanGroupUnit(time, matchDataChanged, "group", arg1) - elseif (WeakAuras.multiUnitUnits.party[arg1] and not IsInRaid()) then + elseif (Private.multiUnitUnits.party[arg1] and not IsInRaid()) then ScanGroupUnit(time, matchDataChanged, "group", arg1) - elseif WeakAuras.multiUnitUnits.boss[arg1] then + elseif Private.multiUnitUnits.boss[arg1] then ScanGroupUnit(time, matchDataChanged, "boss", arg1) - elseif WeakAuras.multiUnitUnits.arena[arg1] then + elseif Private.multiUnitUnits.arena[arg1] then ScanGroupUnit(time, matchDataChanged, "arena", arg1) else ScanGroupUnit(time, matchDataChanged, nil, arg1) @@ -1488,7 +1485,7 @@ WeakAuras.frames["WeakAuras Buff2 Frame"] = frame local function EventHandler(frame, event, arg1, arg2, ...) - WeakAuras.StartProfileSystem("bufftrigger2") + Private.StartProfileSystem("bufftrigger2") local deactivatedTriggerInfos = {} local unitsToRemove = {} @@ -1534,7 +1531,7 @@ local function EventHandler(frame, event, arg1, arg2, ...) end end elseif event == "UNIT_FLAGS" or event == "UNIT_NAME_UPDATE" or event == "PLAYER_FLAGS_CHANGED" then - if WeakAuras.multiUnitUnits.group[arg1] then + if Private.multiUnitUnits.group[arg1] then RecheckActiveForUnitType("group", arg1, deactivatedTriggerInfos) end elseif event == "UNIT_ENTERED_VEHICLE" or event == "UNIT_EXITED_VEHICLE" then @@ -1560,7 +1557,7 @@ local function EventHandler(frame, event, arg1, arg2, ...) matchDataUpToDate[unit] = nil end - WeakAuras.StopProfileSystem("bufftrigger2") + Private.StopProfileSystem("bufftrigger2") end frame:RegisterEvent("UNIT_AURA") @@ -1583,42 +1580,15 @@ frame:SetScript("OnUpdate", function() if WeakAuras.IsPaused() then return end - WeakAuras.StartProfileSystem("bufftrigger2") + Private.StartProfileSystem("bufftrigger2") if next(matchDataChanged) then local time = GetTime() UpdateStates(matchDataChanged, time) wipe(matchDataChanged) end - WeakAuras.StopProfileSystem("bufftrigger2") + Private.StopProfileSystem("bufftrigger2") end) -function BuffTrigger.ScanAll() - local units = {} - local time = GetTime() - - for unit in pairs(scanFuncName) do - units[unit] = true - end - - for unit in pairs(scanFuncSpellId) do - units[unit] = true - end - - for unit in pairs(scanFuncGeneral) do - units[unit] = true - end - - for unit in pairs(units) do - if unit == "group" then - ScanAllGroup(time, matchDataChanged) - elseif unit == "boss" then - ScanAllBoss(time, matchDataChanged) - else - ScanGroupUnit(time, matchDataChanged, nil, unit) - end - end -end - local function UnloadAura(scanFuncName, id) for unit, unitData in pairs(scanFuncName) do for debuffType, debuffData in pairs(unitData) do @@ -1909,7 +1879,7 @@ local function createScanFunc(trigger) return false end ]] - ret = ret .. ret2:format(trigger.debuffClass and type(trigger.debuffClass) == "table" and WeakAuras.SerializeTable(trigger.debuffClass) or "{}") + ret = ret .. ret2:format(trigger.debuffClass and type(trigger.debuffClass) == "table" and Private.SerializeTable(trigger.debuffClass) or "{}") end if trigger.ownOnly then @@ -2088,7 +2058,7 @@ function BuffTrigger.Add(data) local remFunc if trigger.unit ~= "multi" and not IsSingleMissing(trigger) and trigger.useRem then - local remFuncStr = WeakAuras.function_strings.count:format(trigger.remOperator or ">=", tonumber(trigger.rem) or 0) + local remFuncStr = Private.function_strings.count:format(trigger.remOperator or ">=", tonumber(trigger.rem) or 0) remFunc = WeakAuras.LoadFunction(remFuncStr) end @@ -2109,15 +2079,15 @@ function BuffTrigger.Add(data) local groupCountFunc if effectiveUseGroupCount then local group_countFuncStr - local count, countType = WeakAuras.ParseNumber(trigger.group_count) + local count, countType = Private.ParseNumber(trigger.group_count) if trigger.group_countOperator and count and countType then if countType == "whole" then - group_countFuncStr = WeakAuras.function_strings.count:format(trigger.group_countOperator, count) + group_countFuncStr = Private.function_strings.count:format(trigger.group_countOperator, count) else - group_countFuncStr = WeakAuras.function_strings.count_fraction:format(trigger.group_countOperator, count) + group_countFuncStr = Private.function_strings.count_fraction:format(trigger.group_countOperator, count) end else - group_countFuncStr = WeakAuras.function_strings.count:format(">", 0) + group_countFuncStr = Private.function_strings.count:format(">", 0) end groupCountFunc = WeakAuras.LoadFunction(group_countFuncStr) end @@ -2125,7 +2095,7 @@ function BuffTrigger.Add(data) local matchCountFunc if HasMatchCount(trigger) and trigger.match_countOperator and trigger.match_count then local count = tonumber(trigger.match_count) - local match_countFuncStr = WeakAuras.function_strings.count:format(trigger.match_countOperator, count) + local match_countFuncStr = Private.function_strings.count:format(trigger.match_countOperator, count) matchCountFunc = WeakAuras.LoadFunction(match_countFuncStr) elseif IsGroupTrigger(trigger) then if trigger.showClones and not trigger.combinePerUnit then @@ -2369,7 +2339,7 @@ function BuffTrigger.GetTriggerConditions(data, triggernum) result["debuffClass"] = { display = L["Debuff Type"], type = "select", - values = WeakAuras.debuff_class_types + values = Private.debuff_class_types } result["unitCaster"] = { @@ -2475,7 +2445,7 @@ function BuffTrigger.GetName(triggerType) end end -function WeakAuras.CanConvertBuffTrigger2(trigger) +function Private.CanConvertBuffTrigger2(trigger) if trigger.type ~= "aura" then return false end @@ -2505,8 +2475,8 @@ function WeakAuras.CanConvertBuffTrigger2(trigger) return true end -function WeakAuras.ConvertBuffTrigger2(trigger) - if not WeakAuras.CanConvertBuffTrigger2(trigger) then +function Private.ConvertBuffTrigger2(trigger) + if not Private.CanConvertBuffTrigger2(trigger) then return end trigger.type = "aura2" @@ -2842,7 +2812,7 @@ local function AugmentMatchDataMultiWith(matchData, unit, name, icon, stacks, de changed = true end - local casterName = UnitName(unitCaster) or "" + local casterName = GetUnitName(unitCaster, false) or "" if matchData.casterName ~= casterName then matchData.casterName = casterName changed = true @@ -2853,7 +2823,7 @@ local function AugmentMatchDataMultiWith(matchData, unit, name, icon, stacks, de changed = true end - local unitName = UnitName(unit) or "" + local unitName = GetUnitName(unit, false) or "" if matchData.unitName ~= unitName then matchData.unitName = unitName changed = true @@ -3023,7 +2993,7 @@ function BuffTrigger.InitMultiAura() end function BuffTrigger.HandleMultiEvent(frame, event, ...) - WeakAuras.StartProfileSystem("bufftrigger2 - multi") + Private.StartProfileSystem("bufftrigger2 - multi") if event == "COMBAT_LOG_EVENT_UNFILTERED" then CombatLog(...) elseif event == "UNIT_TARGET" then @@ -3049,7 +3019,7 @@ function BuffTrigger.HandleMultiEvent(frame, event, ...) end wipe(matchDataMulti) end - WeakAuras.StopProfileSystem("bufftrigger2 - multi") + Private.StopProfileSystem("bufftrigger2 - multi") end function BuffTrigger.GetTriggerDescription(data, triggernum, namestable) diff --git a/WeakAuras/Conditions.lua b/WeakAuras/Conditions.lua index e72e3f0..cd381d7 100644 --- a/WeakAuras/Conditions.lua +++ b/WeakAuras/Conditions.lua @@ -376,7 +376,7 @@ local function CreateActivateCondition(ret, id, condition, conditionNumber, prop return ret; end -function WeakAuras.GetProperties(data) +function Private.GetProperties(data) local properties; local propertiesFunction = WeakAuras.regionTypes[data.regionType] and WeakAuras.regionTypes[data.regionType].properties; if (type(propertiesFunction) == "function") then @@ -390,7 +390,7 @@ function WeakAuras.GetProperties(data) if data.subRegions then local subIndex = {} for index, subRegion in ipairs(data.subRegions) do - local subRegionTypeData = WeakAuras.subRegionTypes[subRegion.type]; + local subRegionTypeData = Private.subRegionTypes[subRegion.type]; local propertiesFunction = subRegionTypeData and subRegionTypeData.properties local subProperties; if (type(propertiesFunction) == "function") then @@ -442,7 +442,7 @@ function Private.LoadConditionPropertyFunctions(data) end return change.value[fullKey] end - local formatters = change.value and WeakAuras.CreateFormatters(change.value.message, getter) + local formatters = change.value and Private.CreateFormatters(change.value.message, getter) WeakAuras.conditionTextFormatters[id] = WeakAuras.conditionTextFormatters[id] or {} WeakAuras.conditionTextFormatters[id][conditionNumber] = WeakAuras.conditionTextFormatters[id][conditionNumber] or {}; WeakAuras.conditionTextFormatters[id][conditionNumber].changes = WeakAuras.conditionTextFormatters[id][conditionNumber].changes or {}; @@ -490,7 +490,7 @@ local globalConditions = } } -function WeakAuras.GetGlobalConditions() +function Private.GetGlobalConditions() return globalConditions; end @@ -502,8 +502,8 @@ local function ConstructConditionFunction(data) local usedProperties = {}; - local allConditionsTemplate = WeakAuras.GetTriggerConditions(data); - allConditionsTemplate[-1] = WeakAuras.GetGlobalConditions(); + local allConditionsTemplate = Private.GetTriggerConditions(data); + allConditionsTemplate[-1] = Private.GetGlobalConditions(); local ret = ""; ret = ret .. "local newActiveConditions = {};\n" @@ -535,7 +535,7 @@ local function ConstructConditionFunction(data) ret = ret .. " WeakAuras.scheduleConditionCheck(recheckTime, id, cloneId);\n" ret = ret .. " end\n" - local properties = WeakAuras.GetProperties(data); + local properties = Private.GetProperties(data); -- Now build a property + change list -- Second Loop deals with conditions that are no longer active @@ -605,7 +605,7 @@ local globalConditionAllState = { local globalConditionState = globalConditionAllState[""]; -function WeakAuras.GetGlobalConditionState() +function Private.GetGlobalConditionState() return globalConditionAllState; end @@ -694,8 +694,8 @@ function Private.RegisterForGlobalConditions(id) local register = {}; if (data.conditions) then - local allConditionsTemplate = WeakAuras.GetTriggerConditions(data); - allConditionsTemplate[-1] = WeakAuras.GetGlobalConditions(); + local allConditionsTemplate = Private.GetTriggerConditions(data); + allConditionsTemplate[-1] = Private.GetGlobalConditions(); for conditionNumber, condition in ipairs(data.conditions) do EvaluateCheckForRegisterForGlobalConditions(id, condition.check, allConditionsTemplate, register); diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index 15603e1..a70ac59 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -21,9 +21,6 @@ Unloads all triggers. UnloadDisplays(id) Unloads all triggers of the display ids. -ScanAll -Resets the trigger state for all triggers. - Modernize(data) Modernizes all generic triggers in data. @@ -71,10 +68,9 @@ local WeakAuras = WeakAuras; local L = WeakAuras.L; local GenericTrigger = {}; -local event_prototypes = WeakAuras.event_prototypes; +local event_prototypes = Private.event_prototypes; local timer = WeakAuras.timer; -local debug = WeakAuras.debug; local events = {} local loaded_events = {} @@ -327,7 +323,7 @@ function ConstructFunction(prototype, trigger, inverse) return ret; end -function WeakAuras.EndEvent(id, triggernum, force, state) +function Private.EndEvent(id, triggernum, force, state) if state then if (state.show ~= false and state.show ~= nil) then state.show = false; @@ -404,7 +400,7 @@ local function callFunctionForActivateEvent(func, trigger, fallback, errorHandle end end -function WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler) +function Private.ActivateEvent(id, triggernum, data, state, errorHandler) local changed = state.changed or false; if (state.show ~= true) then state.show = true; @@ -558,7 +554,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 elseif (ok and returnValue) or optionsEvent then for id, state in pairs(allStates) do if (state.changed) then - if (WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then + if (Private.ActivateEvent(id, triggernum, data, state, errorHandler)) then updateTriggerState = true; end end @@ -568,15 +564,15 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 end elseif (data.statesParameter == "unit") then if optionsEvent then - if WeakAuras.multiUnitUnits[data.trigger.unit] then - arg1 = next(WeakAuras.multiUnitUnits[data.trigger.unit]) + if Private.multiUnitUnits[data.trigger.unit] then + arg1 = next(Private.multiUnitUnits[data.trigger.unit]) else arg1 = data.trigger.unit end end if arg1 then local unit, cloneId - if WeakAuras.multiUnitUnits[data.trigger.unit] then + if Private.multiUnitUnits[data.trigger.unit] then unit = arg1 cloneId = arg1 else @@ -589,7 +585,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 if not ok then errorHandler(returnValue) elseif (ok and returnValue) or optionsEvent then - if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then + if(Private.ActivateEvent(id, triggernum, data, state, errorHandler)) then updateTriggerState = true; end else @@ -603,7 +599,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 if not ok then errorHandler(returnValue) elseif (ok and returnValue) or optionsEvent then - if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then + if(Private.ActivateEvent(id, triggernum, data, state, errorHandler)) then updateTriggerState = true; end else @@ -616,7 +612,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 elseif (ok and returnValue) or optionsEvent then allStates[""] = allStates[""] or {}; local state = allStates[""]; - if(WeakAuras.ActivateEvent(id, triggernum, data, state, errorHandler)) then + if(Private.ActivateEvent(id, triggernum, data, state, errorHandler)) then updateTriggerState = true; end else @@ -632,7 +628,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 elseif (ok and returnValue) or optionsEvent then for id, state in pairs(allStates) do if (state.changed) then - if (WeakAuras.EndEvent(id, triggernum, nil, state)) then + if (Private.EndEvent(id, triggernum, nil, state)) then updateTriggerState = true; end end @@ -642,14 +638,14 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 elseif data.statesParameter == "unit" then if data.untriggerFunc then if arg1 then - local cloneId = WeakAuras.multiUnitUnits[data.trigger.unit] and arg1 or "" + local cloneId = Private.multiUnitUnits[data.trigger.unit] and arg1 or "" local state = allStates[cloneId] if state then local ok, returnValue = pcall(data.untriggerFunc, state, event, arg1, arg2, ...); if not ok then errorHandler(returnValue) elseif ok and returnValue then - if (WeakAuras.EndEvent(id, triggernum, nil, state)) then + if (Private.EndEvent(id, triggernum, nil, state)) then updateTriggerState = true; end end @@ -664,7 +660,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 if not ok then errorHandler(returnValue) elseif (ok and returnValue) then - if (WeakAuras.EndEvent(id, triggernum, nil, state)) then + if (Private.EndEvent(id, triggernum, nil, state)) then updateTriggerState = true; end end @@ -677,7 +673,7 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 elseif (ok and returnValue) then allStates[""] = allStates[""] or {}; local state = allStates[""]; - if(WeakAuras.EndEvent(id, triggernum, nil, state)) then + if(Private.EndEvent(id, triggernum, nil, state)) then updateTriggerState = true; end end @@ -690,40 +686,40 @@ end function WeakAuras.ScanEvents(event, arg1, arg2, ...) local orgEvent = event; - WeakAuras.StartProfileSystem("generictrigger " .. orgEvent ) + Private.StartProfileSystem("generictrigger " .. orgEvent ) local event_list = loaded_events[event]; if (not event_list) then - WeakAuras.StopProfileSystem("generictrigger " .. orgEvent ) + Private.StopProfileSystem("generictrigger " .. orgEvent ) return end if(event == "COMBAT_LOG_EVENT_UNFILTERED") then event_list = event_list[arg2]; if (not event_list) then - WeakAuras.StopProfileSystem("generictrigger " .. orgEvent ) + Private.StopProfileSystem("generictrigger " .. orgEvent ) return; end - WeakAuras.ScanEventsInternal(event_list, event, arg1, arg2, ...); + Private.ScanEventsInternal(event_list, event, arg1, arg2, ...); elseif (event == "COMBAT_LOG_EVENT_UNFILTERED_CUSTOM") then -- This reverts the COMBAT_LOG_EVENT_UNFILTERED_CUSTOM workaround so that custom triggers that check the event argument will work as expected if(event == "COMBAT_LOG_EVENT_UNFILTERED_CUSTOM") then event = "COMBAT_LOG_EVENT_UNFILTERED"; end - WeakAuras.ScanEventsInternal(event_list, event, arg1, arg2, ...); + Private.ScanEventsInternal(event_list, event, arg1, arg2, ...); else - WeakAuras.ScanEventsInternal(event_list, event, arg1, arg2, ...); + Private.ScanEventsInternal(event_list, event, arg1, arg2, ...); end - WeakAuras.StopProfileSystem("generictrigger " .. orgEvent ) + Private.StopProfileSystem("generictrigger " .. orgEvent ) end function WeakAuras.ScanUnitEvents(event, unit, ...) - WeakAuras.StartProfileSystem("generictrigger " .. event .. " " .. unit) + Private.StartProfileSystem("generictrigger " .. event .. " " .. unit) local unit_list = loaded_unit_events[unit] if unit_list then local event_list = unit_list[event] if event_list then for id, triggers in pairs(event_list) do - WeakAuras.StartProfileAura(id); + Private.StartProfileAura(id); Private.ActivateAuraEnvironment(id); local updateTriggerState = false; for triggernum, data in pairs(triggers) do @@ -733,19 +729,19 @@ function WeakAuras.ScanUnitEvents(event, unit, ...) end end if (updateTriggerState) then - WeakAuras.UpdatedTriggerState(id); + Private.UpdatedTriggerState(id); end - WeakAuras.StopProfileAura(id); + Private.StopProfileAura(id); Private.ActivateAuraEnvironment(nil); end end end - WeakAuras.StopProfileSystem("generictrigger " .. event .. " " .. unit) + Private.StopProfileSystem("generictrigger " .. event .. " " .. unit) end -function WeakAuras.ScanEventsInternal(event_list, event, arg1, arg2, ... ) +function Private.ScanEventsInternal(event_list, event, arg1, arg2, ... ) for id, triggers in pairs(event_list) do - WeakAuras.StartProfileAura(id); + Private.StartProfileAura(id); Private.ActivateAuraEnvironment(id); local updateTriggerState = false; for triggernum, data in pairs(triggers) do @@ -755,9 +751,9 @@ function WeakAuras.ScanEventsInternal(event_list, event, arg1, arg2, ... ) end end if (updateTriggerState) then - WeakAuras.UpdatedTriggerState(id); + Private.UpdatedTriggerState(id); end - WeakAuras.StopProfileAura(id); + Private.StopProfileAura(id); Private.ActivateAuraEnvironment(nil); end end @@ -837,19 +833,13 @@ function GenericTrigger.ScanWithFakeEvent(id, fake) end if (updateTriggerState) then - WeakAuras.UpdatedTriggerState(id); + Private.UpdatedTriggerState(id); end Private.ActivateAuraEnvironment(nil); end -function GenericTrigger.ScanAll() - for id, _ in pairs(loaded_auras) do - GenericTrigger.ScanWithFakeEvent(id); - end -end - function HandleEvent(frame, event, arg1, arg2, ...) - WeakAuras.StartProfileSystem("generictrigger " .. event); + Private.StartProfileSystem("generictrigger " .. event); if not(WeakAuras.IsPaused()) then if(event == "COMBAT_LOG_EVENT_UNFILTERED") then WeakAuras.ScanEvents(event, arg1, arg2, ...); @@ -862,38 +852,38 @@ function HandleEvent(frame, event, arg1, arg2, ...) end if (event == "PLAYER_ENTERING_WORLD") then timer:ScheduleTimer(function() - WeakAuras.StartProfileSystem("generictrigger WA_DELAYED_PLAYER_ENTERING_WORLD"); + Private.StartProfileSystem("generictrigger WA_DELAYED_PLAYER_ENTERING_WORLD"); HandleEvent(frame, "WA_DELAYED_PLAYER_ENTERING_WORLD"); - WeakAuras.CheckCooldownReady(); - WeakAuras.StopProfileSystem("generictrigger WA_DELAYED_PLAYER_ENTERING_WORLD"); - WeakAuras.PreShowModels() + Private.CheckCooldownReady(); + Private.StopProfileSystem("generictrigger WA_DELAYED_PLAYER_ENTERING_WORLD"); + Private.PreShowModels() end, 0.8); -- Data not available timer:ScheduleTimer(function() - WeakAuras.PreShowModels() + Private.PreShowModels() end, 4); -- Data not available end - WeakAuras.StopProfileSystem("generictrigger " .. event); + Private.StopProfileSystem("generictrigger " .. event); end function HandleUnitEvent(frame, event, unit, ...) if frame.unit ~= unit then return end - WeakAuras.StartProfileSystem("generictrigger " .. event .. " " .. unit); + Private.StartProfileSystem("generictrigger " .. event .. " " .. unit); if not(WeakAuras.IsPaused()) then if (UnitIsUnit(unit, frame.unit)) then WeakAuras.ScanUnitEvents(event, frame.unit, ...); end end - WeakAuras.StopProfileSystem("generictrigger " .. event .. " " .. unit); + Private.StopProfileSystem("generictrigger " .. event .. " " .. unit); end function GenericTrigger.UnloadAll() wipe(loaded_auras); wipe(loaded_events); wipe(loaded_unit_events); - WeakAuras.UnregisterAllEveryFrameUpdate(); + Private.UnregisterAllEveryFrameUpdate(); end function GenericTrigger.UnloadDisplays(toUnload) @@ -913,7 +903,7 @@ function GenericTrigger.UnloadDisplays(toUnload) auras[id] = nil; end end - WeakAuras.UnregisterEveryFrameUpdate(id); + Private.UnregisterEveryFrameUpdate(id); end end @@ -953,7 +943,7 @@ function GenericTrigger.Rename(oldid, newid) end end - WeakAuras.EveryFrameUpdateRename(oldid, newid) + Private.EveryFrameUpdateRename(oldid, newid) end local function MultiUnitLoop(Func, unit, ...) @@ -1077,9 +1067,9 @@ function GenericTrigger.LoadDisplays(toLoad, loadEvent, ...) end if(register_for_frame_updates) then - WeakAuras.RegisterEveryFrameUpdate(id); + Private.RegisterEveryFrameUpdate(id); else - WeakAuras.UnregisterEveryFrameUpdate(id); + Private.UnregisterEveryFrameUpdate(id); end end @@ -1160,7 +1150,7 @@ function GenericTrigger.Add(data, region) if (not trigger.subeventSuffix) then trigger.subeventSuffix = ""; end - if not(WeakAuras.subevent_actual_prefix_types[trigger.subeventPrefix]) then + if not(Private.subevent_actual_prefix_types[trigger.subeventPrefix]) then trigger.subeventSuffix = ""; end end @@ -1169,8 +1159,6 @@ function GenericTrigger.Add(data, region) triggerFuncStr = ConstructFunction(prototype, trigger); statesParameter = prototype.statesParameter; - WeakAuras.debug(id.." - "..triggernum.." - Trigger", 1); - WeakAuras.debug(triggerFuncStr); triggerFunc = WeakAuras.LoadFunction(triggerFuncStr, id); durationFunc = prototype.durationFunc; @@ -1198,7 +1186,7 @@ function GenericTrigger.Add(data, region) if prototype.timedrequired(trigger) then trigger.unevent = "timed" else - if not(WeakAuras.eventend_types[trigger.unevent]) then + if not(Private.eventend_types[trigger.unevent]) then trigger.unevent = "timed" end end @@ -1206,11 +1194,11 @@ function GenericTrigger.Add(data, region) trigger.unevent = "timed" end elseif prototype.automatic then - if not(WeakAuras.autoeventend_types[trigger.unevent]) then + if not(Private.autoeventend_types[trigger.unevent]) then trigger.unevent = "auto" end else - if not(WeakAuras.eventend_types[trigger.unevent]) then + if not(Private.eventend_types[trigger.unevent]) then trigger.unevent = "timed" end end @@ -1223,8 +1211,6 @@ function GenericTrigger.Add(data, region) end if(untriggerFuncStr) then - WeakAuras.debug(id.." - "..triggernum.." - Untrigger", 1) - WeakAuras.debug(untriggerFuncStr); untriggerFunc = WeakAuras.LoadFunction(untriggerFuncStr, id); end @@ -1309,7 +1295,7 @@ function GenericTrigger.Add(data, region) isCLEU = trueEvent == "CLEU" or trueEvent == "COMBAT_LOG_EVENT_UNFILTERED" elseif isCLEU then local subevent = string.upper(i) - if WeakAuras.IsCLEUSubevent(subevent) then + if Private.IsCLEUSubevent(subevent) then tinsert(trigger_subevents, subevent) hasParam = true end @@ -1406,7 +1392,7 @@ do WeakAuras.frames["Custom Trigger Every Frame Updater"] = update_frame; local updating = false; - function WeakAuras.RegisterEveryFrameUpdate(id) + function Private.RegisterEveryFrameUpdate(id) if not(update_clients[id]) then update_clients[id] = true; update_clients_num = update_clients_num + 1; @@ -1424,12 +1410,12 @@ do end end - function WeakAuras.EveryFrameUpdateRename(oldid, newid) + function Private.EveryFrameUpdateRename(oldid, newid) update_clients[newid] = update_clients[oldid]; update_clients[oldid] = nil; end - function WeakAuras.UnregisterEveryFrameUpdate(id) + function Private.UnregisterEveryFrameUpdate(id) if(update_clients[id]) then update_clients[id] = nil; update_clients_num = update_clients_num - 1; @@ -1440,7 +1426,7 @@ do end end - function WeakAuras.UnregisterAllEveryFrameUpdate() + function Private.UnregisterAllEveryFrameUpdate() if (not update_frame) then return; end @@ -1471,38 +1457,6 @@ local oldPowerTriggers = { ["Shards"] = 7, } -function GenericTrigger.AllAdded() - -- Remove GTFO options if GTFO isn't enabled and there are no saved GTFO auras - local hideGTFO = true; - local hideDBM = true; - - if (GTFO) then - hideGTFO = false; - end - - if (DBM) then - hideDBM = false; - end - - for id, event in pairs(events) do - for triggernum, data in pairs(event) do - if (data.trigger.event == "GTFO") then - hideGTFO = false; - end - if (data.trigger.event == "DBM Announce" or data.trigger.event == "DBM Timer") then - hideDBM = false; - end - end - end - if (hideGTFO) then - WeakAuras.event_types["GTFO"] = nil; - end - if (hideDBM) then - WeakAuras.event_types["DBM Announce"] = nil; - WeakAuras.status_types["DBM Timer"] = nil; - end -end - --############################# --# Support code for triggers # --############################# @@ -1563,7 +1517,7 @@ do end local function swingTimerCLEUCheck(ts, event, sourceGUID, _, _, destGUID, _, _, ...) - WeakAuras.StartProfileSystem("generictrigger swing"); + Private.StartProfileSystem("generictrigger swing"); if(sourceGUID == selfGUID) then if(event == "SWING_DAMAGE" or event == "SWING_MISSED") then local isOffHand = select(event == "SWING_DAMAGE" and 10 or 2, ...); @@ -1621,12 +1575,12 @@ do end end end - WeakAuras.StopProfileSystem("generictrigger swing"); + Private.StopProfileSystem("generictrigger swing"); end local function swingTimerCheck(event, unit, guid, spell) if unit ~= "player" then return end - WeakAuras.StartProfileSystem("generictrigger swing"); + Private.StartProfileSystem("generictrigger swing"); if event == "UNIT_ATTACK_SPEED" then local mainSpeedNew, offSpeedNew = UnitAttackSpeed("player") offSpeedNew = offSpeedNew or 0 @@ -1654,7 +1608,7 @@ do elseif casting and (event == "UNIT_SPELLCAST_INTERRUPTED" or event == "UNIT_SPELLCAST_FAILED") then casting = false elseif event == "UNIT_SPELLCAST_SUCCEEDED" then - if WeakAuras.reset_swing_spells[spell] or casting then + if Private.reset_swing_spells[spell] or casting then if casting then casting = false end @@ -1671,7 +1625,7 @@ do end mainTimer = timer:ScheduleTimer(swingEnd, mainSpeed, "main"); WeakAuras.ScanEvents(event); - elseif WeakAuras.reset_ranged_swing_spells[spell] then + elseif Private.reset_ranged_swing_spells[spell] then local event; local currentTime = GetTime(); local speed = UnitRangedDamage("player"); @@ -1693,7 +1647,7 @@ do lastSwingOff, swingDurationOff = nil, nil WeakAuras.ScanEvents("SWING_TIMER_END") end - WeakAuras.StopProfileSystem("generictrigger swing"); + Private.StopProfileSystem("generictrigger swing"); end function WeakAuras.InitSwingTimer() @@ -1805,7 +1759,7 @@ do self.handles[id] = nil self.expirationTime[id] = nil CheckGCD(); - WeakAuras.CheckSpellCooldown(id, GetRuneDuration()) + Private.CheckSpellCooldown(id, GetRuneDuration()) end, Schedule = function(self, expirationTime, id) if (not self.expirationTime[id] or expirationTime < self.expirationTime[id]) and expirationTime > 0 then @@ -1914,16 +1868,16 @@ do cdReadyFrame:RegisterEvent("SPELLS_CHANGED"); cdReadyFrame:RegisterEvent("PLAYER_ENTERING_WORLD"); cdReadyFrame:SetScript("OnEvent", function(self, event, ...) - WeakAuras.StartProfileSystem("generictrigger cd tracking"); + Private.StartProfileSystem("generictrigger cd tracking"); if not WeakAuras.IsPaused() then if(event == "SPELL_UPDATE_COOLDOWN" or event == "RUNE_POWER_UPDATE" or event == "RUNE_TYPE_UPDATE" or event == "ACTIONBAR_UPDATE_COOLDOWN" or event == "PLAYER_TALENT_UPDATE" or event == "CHARACTER_POINTS_CHANGED") then - WeakAuras.CheckCooldownReady(); + Private.CheckCooldownReady(); elseif(event == "SPELLS_CHANGED") then - WeakAuras.CheckSpellKnown(); - WeakAuras.CheckCooldownReady(); + Private.CheckSpellKnown(); + Private.CheckCooldownReady(); elseif(event == "UNIT_SPELLCAST_SENT") then local unit, name, _ = ...; if(unit == "player") then @@ -1935,10 +1889,10 @@ do end end elseif(event == "UNIT_INVENTORY_CHANGED" or event == "BAG_UPDATE_COOLDOWN" or event == "PLAYER_EQUIPMENT_CHANGED") then - WeakAuras.CheckItemSlotCooldowns(); + Private.CheckItemSlotCooldowns(); end end - WeakAuras.StopProfileSystem("generictrigger cd tracking"); + Private.StopProfileSystem("generictrigger cd tracking"); end); end @@ -2054,7 +2008,7 @@ do WeakAuras.ScanEvents("ITEM_SLOT_COOLDOWN_READY", id); end - function WeakAuras.CheckRuneCooldown() + function Private.CheckRuneCooldown() for id, _ in pairs(runes) do local startTime, duration = GetRuneCooldown(id); startTime = startTime or 0; @@ -2134,7 +2088,7 @@ do return startTimeCooldown, durationCooldown, unifiedCooldownBecauseRune, cooldownBecauseRune, GetSpellCount(id); end - function WeakAuras.CheckSpellKnown() + function Private.CheckSpellKnown() for id, _ in pairs(spells) do local known = WeakAuras.IsSpellKnownIncludingPet(id); if (known ~= spellKnown[id]) then @@ -2144,7 +2098,7 @@ do end end - function WeakAuras.CheckSpellCooldown(id, runeDuration) + function Private.CheckSpellCooldown(id, runeDuration) local startTimeCooldown, durationCooldown, unifiedCooldownBecauseRune, cooldownBecauseRune, spellCount = WeakAuras.GetSpellCooldownUnified(id, runeDuration); local time = GetTime(); @@ -2184,13 +2138,13 @@ do end end - function WeakAuras.CheckSpellCooldows(runeDuration) + function Private.CheckSpellCooldows(runeDuration) for id, _ in pairs(spells) do - WeakAuras.CheckSpellCooldown(id, runeDuration) + Private.CheckSpellCooldown(id, runeDuration) end end - function WeakAuras.CheckItemCooldowns() + function Private.CheckItemCooldowns() for id, _ in pairs(items) do local startTime, duration, enabled = GetItemCooldown(id); if (duration == 0) then @@ -2249,7 +2203,7 @@ do end end - function WeakAuras.CheckItemSlotCooldowns() + function Private.CheckItemSlotCooldowns() for id, itemId in pairs(itemSlots) do local startTime, duration, enable = GetInventoryItemCooldown("player", id); itemSlotsEnable[id] = enable; @@ -2300,12 +2254,12 @@ do end end - function WeakAuras.CheckCooldownReady() + function Private.CheckCooldownReady() CheckGCD(); - WeakAuras.CheckRuneCooldown(); - WeakAuras.CheckSpellCooldows(); - WeakAuras.CheckItemCooldowns(); - WeakAuras.CheckItemSlotCooldowns(); + Private.CheckRuneCooldown(); + Private.CheckSpellCooldows(); + Private.CheckItemCooldowns(); + Private.CheckItemSlotCooldowns(); end function WeakAuras.WatchGCD() @@ -2455,7 +2409,7 @@ function WeakAuras.WatchUnitChange(unit) watchUnitChange:RegisterEvent("PLAYER_ENTERING_WORLD") watchUnitChange:SetScript("OnEvent", function(self, event, unit) - WeakAuras.StartProfileSystem("generictrigger unit change"); + Private.StartProfileSystem("generictrigger unit change"); local inRaid = IsInRaid() for unit, guid in pairs(watchUnitChange.unitChangeGUIDS) do @@ -2463,7 +2417,7 @@ function WeakAuras.WatchUnitChange(unit) if guid ~= newGuid or event == "PLAYER_ENTERING_WORLD" then WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) watchUnitChange.unitChangeGUIDS[unit] = newGuid - elseif WeakAuras.multiUnitUnits.group[unit] then + elseif Private.multiUnitUnits.group[unit] then -- If in raid changed we send a UNIT_CHANGED for the group units if inRaid ~= watchUnitChange.inRaid then WeakAuras.ScanEvents("UNIT_CHANGED_" .. unit, unit) @@ -2471,7 +2425,7 @@ function WeakAuras.WatchUnitChange(unit) end end watchUnitChange.inRaid = inRaid - WeakAuras.StopProfileSystem("generictrigger unit change"); + Private.StopProfileSystem("generictrigger unit change"); end) end watchUnitChange.unitChangeGUIDS = watchUnitChange.unitChangeGUIDS or {} @@ -2715,7 +2669,6 @@ do local scheduled_scans = {} local function doDbmScan(fireTime) - WeakAuras.debug("Performing dbm scan at "..fireTime.." ("..GetTime()..")") scheduled_scans[fireTime] = nil WeakAuras.ScanEvents("DBM_TimerUpdate") end @@ -2913,7 +2866,6 @@ do local scheduled_scans = {} local function doBigWigsScan(fireTime) - WeakAuras.debug("Performing BigWigs scan at "..fireTime.." ("..GetTime()..")") scheduled_scans[fireTime] = nil WeakAuras.ScanEvents("BigWigs_Timer_Update") end @@ -2921,7 +2873,6 @@ do function WeakAuras.ScheduleBigWigsCheck(fireTime) if not scheduled_scans[fireTime] then scheduled_scans[fireTime] = timer:ScheduleTimer(doBigWigsScan, fireTime - GetTime() + 0.1, fireTime) - WeakAuras.debug("Scheduled BigWigs scan at "..fireTime) end end end @@ -2995,7 +2946,7 @@ do end local function tenchUpdate() - WeakAuras.StartProfileSystem("generictrigger"); + Private.StartProfileSystem("generictrigger"); local _, mh_rem, oh_rem _, mh_rem, mh_charges, _, oh_rem, oh_charges = GetWeaponEnchantInfo(); local time = GetTime(); @@ -3022,15 +2973,15 @@ do oh_icon = GetInventoryItemTexture("player", oh) end WeakAuras.ScanEvents("TENCH_UPDATE"); - WeakAuras.StopProfileSystem("generictrigger"); + Private.StopProfileSystem("generictrigger"); end tenchFrame:SetScript("OnEvent", function(self, event, arg1) - WeakAuras.StartProfileSystem("generictrigger"); + Private.StartProfileSystem("generictrigger"); if (event == "UNIT_INVENTORY_CHANGED" and arg1 == "player") then timer:ScheduleTimer(tenchUpdate, 0.1); end - WeakAuras.StopProfileSystem("generictrigger"); + Private.StopProfileSystem("generictrigger"); end); tenchUpdate(); @@ -3056,9 +3007,9 @@ do petFrame:RegisterEvent("UNIT_PET") petFrame:SetScript("OnEvent", function(_, event, unit) if unit ~= "player" then return end - WeakAuras.StartProfileSystem("generictrigger") + Private.StartProfileSystem("generictrigger") WeakAuras.ScanEvents("PET_UPDATE", "pet") - WeakAuras.StopProfileSystem("generictrigger") + Private.StopProfileSystem("generictrigger") end) end end @@ -3072,7 +3023,7 @@ do local isMounted = IsMounted(); local function checkForMounted(self, elaps) - WeakAuras.StartProfileSystem("generictrigger"); + Private.StartProfileSystem("generictrigger"); elapsed = elapsed + elaps if(isMounted ~= IsMounted()) then isMounted = IsMounted(); @@ -3082,7 +3033,7 @@ do if(elapsed > delay) then mountedFrame:SetScript("OnUpdate", nil); end - WeakAuras.StopProfileSystem("generictrigger"); + Private.StopProfileSystem("generictrigger"); end function WeakAuras.WatchForMounts() @@ -3103,13 +3054,13 @@ do local playerMovingFrame = nil local function PlayerMoveSpeedUpdate() - WeakAuras.StartProfileSystem("generictrigger"); + Private.StartProfileSystem("generictrigger"); local speed = GetUnitSpeed("player") if speed ~= playerMovingFrame.speed then playerMovingFrame.speed = speed WeakAuras.ScanEvents("PLAYER_MOVE_SPEED_UPDATE") end - WeakAuras.StopProfileSystem("generictrigger"); + Private.StopProfileSystem("generictrigger"); end function WeakAuras.WatchPlayerMoveSpeed() @@ -3142,18 +3093,18 @@ do local FSPAT = "%s*"..(gsub(gsub(FOREIGN_SERVER_LABEL, "^%s", ""), "[%*()]", "%%%1")).."$" local function nameplateShow(self) - WeakAuras.StartProfileSystem("nameplatetrigger") + Private.StartProfileSystem("nameplatetrigger") local name = gsub(self.nameText:GetText(), FSPAT, "") visibleNameplates[self] = name WeakAuras.ScanEvents("NP_SHOW", self, name) - WeakAuras.StopProfileSystem("nameplatetrigger") + Private.StopProfileSystem("nameplatetrigger") end local function nameplateHide(self) - WeakAuras.StartProfileSystem("nameplatetrigger") + Private.StartProfileSystem("nameplatetrigger") visibleNameplates[self] = nil WeakAuras.ScanEvents("NP_HIDE", self, gsub(self.nameText:GetText(), FSPAT, "")) - WeakAuras.StopProfileSystem("nameplatetrigger") + Private.StopProfileSystem("nameplatetrigger") end local function findNewPlate(...) @@ -3174,9 +3125,9 @@ do if lastUpdate < 1 then return end numChildren = WorldGetNumChildren(WorldFrame) if lastChildern ~= numChildren then - WeakAuras.StartProfileSystem("nameplatetrigger") + Private.StartProfileSystem("nameplatetrigger") findNewPlate(WorldGetChildren(WorldFrame)) - WeakAuras.StopProfileSystem("nameplatetrigger") + Private.StopProfileSystem("nameplatetrigger") lastChildern = numChildren end lastUpdate = 0 @@ -3237,7 +3188,7 @@ do end queuedActionFrame:RegisterEvent("ACTIONBAR_SLOT_CHANGED") queuedActionFrame:SetScript("OnEvent", function(_, _, slotID) - WeakAuras.StartProfileSystem("generictrigger"); + Private.StartProfileSystem("generictrigger"); local spellID = GetActionSpellID(slotID) if spellID then buttonIDList[slotID] = spellID @@ -3246,7 +3197,7 @@ do spellIDList[buttonIDList[slotID]] = nil buttonIDList[slotID] = nil end - WeakAuras.StopProfileSystem("generictrigger"); + Private.StopProfileSystem("generictrigger"); end) end @@ -3259,7 +3210,6 @@ do local scheduled_scans = {}; local function doScan(fireTime, event) - WeakAuras.debug("Performing scan at "..fireTime.." ("..GetTime()..") " .. event); scheduled_scans[event][fireTime] = nil; WeakAuras.ScanEvents(event); end @@ -3267,7 +3217,6 @@ do event = event or "COOLDOWN_REMAINING_CHECK" scheduled_scans[event] = scheduled_scans[event] or {} if not(scheduled_scans[event][fireTime]) then - WeakAuras.debug("Scheduled scan at " .. fireTime .. " for event " .. event); scheduled_scans[event][fireTime] = timer:ScheduleTimer(doScan, fireTime - GetTime() + 0.1, fireTime, event); end end @@ -3277,14 +3226,12 @@ do local scheduled_scans = {}; local function doCastScan(firetime, unit) - WeakAuras.debug("Performing cast scan at "..firetime.." ("..GetTime()..")"); scheduled_scans[unit][firetime] = nil; WeakAuras.ScanEvents("CAST_REMAINING_CHECK", unit); end function WeakAuras.ScheduleCastCheck(fireTime, unit) scheduled_scans[unit] = scheduled_scans[unit] or {} if not(scheduled_scans[unit][fireTime]) then - WeakAuras.debug("Scheduled cast scan at "..fireTime); scheduled_scans[unit][fireTime] = timer:ScheduleTimer(doCastScan, fireTime - GetTime() + 0.1, fireTime, unit); end end @@ -3300,12 +3247,12 @@ function GenericTrigger.CanHaveDuration(data, triggernum) local trigger = data.triggers[triggernum].trigger if (trigger.type == "event" or trigger.type == "status") then - if trigger.event and WeakAuras.event_prototypes[trigger.event] then - if WeakAuras.event_prototypes[trigger.event].durationFunc then - if(type(WeakAuras.event_prototypes[trigger.event].init) == "function") then - WeakAuras.event_prototypes[trigger.event].init(trigger); + if trigger.event and Private.event_prototypes[trigger.event] then + if Private.event_prototypes[trigger.event].durationFunc then + if(type(Private.event_prototypes[trigger.event].init) == "function") then + Private.event_prototypes[trigger.event].init(trigger); end - local current, maximum, custom = WeakAuras.event_prototypes[trigger.event].durationFunc(trigger); + local current, maximum, custom = Private.event_prototypes[trigger.event].durationFunc(trigger); current = type(current) ~= "number" and current or 0 maximum = type(maximum) ~= "number" and maximum or 0 if(custom) then @@ -3313,8 +3260,8 @@ function GenericTrigger.CanHaveDuration(data, triggernum) else return "timed"; end - elseif WeakAuras.event_prototypes[trigger.event].canHaveDuration then - return WeakAuras.event_prototypes[trigger.event].canHaveDuration + elseif Private.event_prototypes[trigger.event].canHaveDuration then + return Private.event_prototypes[trigger.event].canHaveDuration end end if trigger.unevent == "timed" and trigger.duration then @@ -3340,10 +3287,10 @@ function GenericTrigger.GetOverlayInfo(data, triggernum) local trigger = data.triggers[triggernum].trigger - if (trigger.type ~= "custom" and trigger.event and WeakAuras.event_prototypes[trigger.event] and WeakAuras.event_prototypes[trigger.event].overlayFuncs) then + if (trigger.type ~= "custom" and trigger.event and Private.event_prototypes[trigger.event] and Private.event_prototypes[trigger.event].overlayFuncs) then result = {}; local dest = 1; - for i, v in ipairs(WeakAuras.event_prototypes[trigger.event].overlayFuncs) do + for i, v in ipairs(Private.event_prototypes[trigger.event].overlayFuncs) do if (v.enable(trigger)) then result[dest] = v.name; dest = dest + 1; @@ -3407,10 +3354,10 @@ function GenericTrigger.CanHaveAuto(data, triggernum) or trigger.type == "status" ) and trigger.event - and WeakAuras.event_prototypes[trigger.event] + and Private.event_prototypes[trigger.event] and ( - WeakAuras.event_prototypes[trigger.event].iconFunc - or WeakAuras.event_prototypes[trigger.event].canHaveAuto + Private.event_prototypes[trigger.event].iconFunc + or Private.event_prototypes[trigger.event].canHaveAuto ) ) or ( @@ -3435,12 +3382,12 @@ function GenericTrigger.GetNameAndIcon(data, triggernum) local trigger = data.triggers[triggernum].trigger local icon, name if (trigger.type == "event" or trigger.type == "status") then - if(trigger.event and WeakAuras.event_prototypes[trigger.event]) then - if(WeakAuras.event_prototypes[trigger.event].iconFunc) then - icon = WeakAuras.event_prototypes[trigger.event].iconFunc(trigger); + if(trigger.event and Private.event_prototypes[trigger.event]) then + if(Private.event_prototypes[trigger.event].iconFunc) then + icon = Private.event_prototypes[trigger.event].iconFunc(trigger); end - if(WeakAuras.event_prototypes[trigger.event].nameFunc) then - name = WeakAuras.event_prototypes[trigger.event].nameFunc(trigger); + if(Private.event_prototypes[trigger.event].nameFunc) then + name = Private.event_prototypes[trigger.event].nameFunc(trigger); end end end @@ -3455,10 +3402,10 @@ end function GenericTrigger.CanHaveTooltip(data, triggernum) local trigger = data.triggers[triggernum].trigger if (trigger.type == "event" or trigger.type == "status") then - if (trigger.event and WeakAuras.event_prototypes[trigger.event]) then - if(WeakAuras.event_prototypes[trigger.event].hasSpellID) then + if (trigger.event and Private.event_prototypes[trigger.event]) then + if(Private.event_prototypes[trigger.event].hasSpellID) then return "spell"; - elseif(WeakAuras.event_prototypes[trigger.event].hasItemID) then + elseif(Private.event_prototypes[trigger.event].hasItemID) then return "item"; end end @@ -3501,11 +3448,11 @@ function GenericTrigger.SetToolTip(trigger, state) end if (trigger.type == "event" or trigger.type == "status") then - if (trigger.event and WeakAuras.event_prototypes[trigger.event]) then - if(WeakAuras.event_prototypes[trigger.event].hasSpellID) then + if (trigger.event and Private.event_prototypes[trigger.event]) then + if(Private.event_prototypes[trigger.event].hasSpellID) then GameTooltip:SetSpellByID(trigger.spellName); return true - elseif(WeakAuras.event_prototypes[trigger.event].hasItemID) then + elseif(Private.event_prototypes[trigger.event].hasItemID) then GameTooltip:SetHyperlink("item:"..trigger.itemName..":0:0:0:0:0:0:0") return true end @@ -3518,10 +3465,10 @@ function GenericTrigger.GetAdditionalProperties(data, triggernum) local trigger = data.triggers[triggernum].trigger local ret = ""; if (trigger.type == "event" or trigger.type == "status") then - if (trigger.event and WeakAuras.event_prototypes[trigger.event]) then + if (trigger.event and Private.event_prototypes[trigger.event]) then local found = false; local additional = "" - for _, v in pairs(WeakAuras.event_prototypes[trigger.event].args) do + for _, v in pairs(Private.event_prototypes[trigger.event].args) do local enable = true if(type(v.enable) == "function") then enable = v.enable(trigger) @@ -3574,7 +3521,7 @@ function GenericTrigger.GetTriggerConditions(data, triggernum) local trigger = data.triggers[triggernum].trigger if (trigger.type == "event" or trigger.type == "status") then - if (trigger.event and WeakAuras.event_prototypes[trigger.event]) then + if (trigger.event and Private.event_prototypes[trigger.event]) then local result = {}; local canHaveDuration = GenericTrigger.CanHaveDuration(data, triggernum); @@ -3596,15 +3543,15 @@ function GenericTrigger.GetTriggerConditions(data, triggernum) result.total = commonConditions.total; end - if (WeakAuras.event_prototypes[trigger.event].stacksFunc) then + if (Private.event_prototypes[trigger.event].stacksFunc) then result.stacks = commonConditions.stacks; end - if (WeakAuras.event_prototypes[trigger.event].nameFunc) then + if (Private.event_prototypes[trigger.event].nameFunc) then result.name = commonConditions.name; end - for _, v in pairs(WeakAuras.event_prototypes[trigger.event].args) do + for _, v in pairs(Private.event_prototypes[trigger.event].args) do if (v.conditionType and v.name and v.display) then local enable = true; if (v.enable) then @@ -3837,12 +3784,12 @@ function GenericTrigger.GetTriggerDescription(data, triggernum, namestable) local trigger = data.triggers[triggernum].trigger if(trigger.type == "event" or trigger.type == "status") then if(trigger.type == "event") then - tinsert(namestable, {L["Trigger:"], (WeakAuras.event_types[trigger.event] or L["Undefined"])}); + tinsert(namestable, {L["Trigger:"], (Private.event_types[trigger.event] or L["Undefined"])}); else - tinsert(namestable, {L["Trigger:"], (WeakAuras.status_types[trigger.event] or L["Undefined"])}); + tinsert(namestable, {L["Trigger:"], (Private.status_types[trigger.event] or L["Undefined"])}); end if(trigger.event == "Combat Log" and trigger.subeventPrefix and trigger.subeventSuffix) then - tinsert(namestable, {L["Message type:"], (WeakAuras.subevent_prefix_types[trigger.subeventPrefix] or L["Undefined"]).." "..(WeakAuras.subevent_suffix_types[trigger.subeventSuffix] or L["Undefined"])}); + tinsert(namestable, {L["Message type:"], (Private.subevent_prefix_types[trigger.subeventPrefix] or L["Undefined"]).." "..(Private.subevent_suffix_types[trigger.subeventSuffix] or L["Undefined"])}); end else tinsert(namestable, {L["Trigger:"], L["Custom"]}); diff --git a/WeakAuras/History.lua b/WeakAuras/History.lua index c11c57a..0072e53 100644 --- a/WeakAuras/History.lua +++ b/WeakAuras/History.lua @@ -18,7 +18,7 @@ local function loadMigrations() return migrationRepo end -function WeakAuras.CleanArchive(historyCutoff, migrationCutoff) +function Private.CleanArchive(historyCutoff, migrationCutoff) if type(historyCutoff) == "number" then local repo = loadHistory() local cutoffTime = time() - (historyCutoff * 86400) @@ -37,7 +37,7 @@ function WeakAuras.CleanArchive(historyCutoff, migrationCutoff) end end -function WeakAuras.SetHistory(uid, data, source, addon) +function Private.SetHistory(uid, data, source, addon) if uid and data then local repo = loadHistory() data.source = source @@ -47,28 +47,28 @@ function WeakAuras.SetHistory(uid, data, source, addon) end end -function WeakAuras.GetHistory(uid, load) +local function GetHistory(uid, load) return loadHistory():Get(uid, load) end -function WeakAuras.RemoveHistory(uid) +function Private.RemoveHistory(uid) return loadHistory():Drop(uid) end -function WeakAuras.RestoreFromHistory(uid) - local _, histData = WeakAuras.GetHistory(uid, true) +function Private.RestoreFromHistory(uid) + local _, histData = GetHistory(uid, true) if histData then WeakAuras.Add(histData) end end -function WeakAuras.SetMigrationSnapshot(uid, oldData) +function Private.SetMigrationSnapshot(uid, oldData) if type(oldData) == "table" then local repo = loadMigrations() repo:Set(uid, oldData) end end -function WeakAuras.GetMigrationSnapshot(uid) +function Private.GetMigrationSnapshot(uid) return loadMigrations():GetData(uid) end diff --git a/WeakAuras/Init.lua b/WeakAuras/Init.lua index 5dee76c..c4c6ea0 100644 --- a/WeakAuras/Init.lua +++ b/WeakAuras/Init.lua @@ -1,3 +1,4 @@ +local AddonName, Private = ... WeakAuras = {} WeakAuras.L = {} WeakAuras.frames = {} @@ -12,7 +13,6 @@ local buildTime = "20200802154726" WeakAuras.versionString = versionStringFromToc WeakAuras.buildTime = buildTime -WeakAuras.printPrefix = "|cff9900ffWeakAuras:|r " WeakAuras.newFeatureString = "|TInterface\\OptionsFrame\\UI-OptionsFrame-NewFeatureIcon:0|t" WeakAuras.BuildInfo = select(4, GetBuildInfo()) @@ -29,36 +29,36 @@ WeakAuras.prettyPrint = function(msg) end if versionString ~= versionStringFromToc and versionStringFromToc ~= "Dev" then - WeakAuras.prettyPrint("You need to restart your game client to complete the WeakAuras update!") + Private.prettyPrint("You need to restart your game client to complete the WeakAuras update!") end -- Force enable WeakAurasCompanion and Archive because some addon managers interfere with it EnableAddOn("WeakAurasCompanion") EnableAddOn("WeakAurasArchive") ---These function stubs are defined here to reduce the number of errors that occur if WeakAuras.lua fails to compile +-- These function stubs are defined here to reduce the number of errors that occur if WeakAuras.lua fails to compile function WeakAuras.RegisterRegionType() end function WeakAuras.RegisterRegionOptions() end -function WeakAuras.StartProfileSystem() +function Private.StartProfileSystem() end -function WeakAuras.StartProfileAura() +function Private.StartProfileAura() end -function WeakAuras.StopProfileSystem() +function Private.StopProfileSystem() end -function WeakAuras.StopProfileAura() +function Private.StopProfileAura() end -function WeakAuras.StartProfileUID() +function Private.StartProfileUID() end -function WeakAuras.StopProfileUID() +function Private.StopProfileUID() end -- If WeakAuras shuts down due to being installed on the wrong target, keep the bindings from erroring diff --git a/WeakAuras/Modernize.lua b/WeakAuras/Modernize.lua index 9f4a11c..10629a5 100644 --- a/WeakAuras/Modernize.lua +++ b/WeakAuras/Modernize.lua @@ -45,7 +45,7 @@ function Private.Modernize(data) end end - -- Version 5 was introduced July 2018 in BFA + -- Version 5 was introduced July 2018 in BfA if data.internalVersion < 5 then -- this is to fix hybrid sorting if data.sortHybridTable then @@ -62,7 +62,7 @@ function Private.Modernize(data) end end - -- Version 6 was introduced July 30, 2018 in BFA + -- Version 6 was introduced July 30 2018 in BfA if data.internalVersion < 6 then if data.triggers then for triggernum, triggerData in ipairs(data.triggers) do @@ -85,7 +85,7 @@ function Private.Modernize(data) end end - -- Version 7 was introduced September 1, 2018 in BFA + -- Version 7 was introduced September 1 2018 in BfA -- Triggers were cleaned up into a 1-indexed array if data.internalVersion < 7 then @@ -102,8 +102,8 @@ function Private.Modernize(data) data.numTriggers = nil data.triggers.customTriggerLogic = data.customTriggerLogic data.customTriggerLogic = nil - local activeTriggerMode = data.activeTriggerMode or WeakAuras.trigger_modes.first_active - if activeTriggerMode ~= WeakAuras.trigger_modes.first_active then + local activeTriggerMode = data.activeTriggerMode or Private.trigger_modes.first_active + if activeTriggerMode ~= Private.trigger_modes.first_active then activeTriggerMode = activeTriggerMode + 1 end data.triggers.activeTriggerMode = activeTriggerMode @@ -175,7 +175,7 @@ function Private.Modernize(data) end end - -- Version 13 was introduced March 2019 in BFA + -- Version 13 was introduced March 2019 in BfA if data.internalVersion < 13 then if data.regionType == "dynamicgroup" then local selfPoints = { @@ -245,7 +245,7 @@ function Private.Modernize(data) end end - -- Version 14 was introduced March 2019 in BFA + -- Version 14 was introduced March 2019 in BfA if data.internalVersion < 14 then if data.triggers then for triggerId, triggerData in pairs(data.triggers) do @@ -262,7 +262,7 @@ function Private.Modernize(data) end end - -- Version 15 was introduced April 2019 in BFA + -- Version 15 was introduced April 2019 in BfA if data.internalVersion < 15 then if data.triggers then for triggerId, triggerData in ipairs(data.triggers) do @@ -273,7 +273,7 @@ function Private.Modernize(data) end end - -- Version 16 was introduced May 2019 in BFA + -- Version 16 was introduced May 2019 in BfA if data.internalVersion < 16 then -- second conversion: migrate name/realm conditions to tristate if data.load.use_name == false then @@ -286,7 +286,7 @@ function Private.Modernize(data) -- Version 18 was a migration for stance/form trigger, but deleted later because of migration issue - -- Version 20 was introduced July 2019 in BFA + -- Version 20 was introduced July 2019 in BfA if data.internalVersion < 20 then if data.regionType == "icon" then local convertPoint = function(containment, point) @@ -377,7 +377,7 @@ function Private.Modernize(data) end end - -- Version 20 was introduced May 2019 in BFA + -- Version 20 was introduced May 2019 in BfA if data.internalVersion < 20 then if data.regionType == "aurabar" then local orientationToPostion = { @@ -721,7 +721,7 @@ function Private.Modernize(data) local totalPrecision = data.totalPrecision if data.regionType == "text" then local seenSymbols = {} - WeakAuras.ParseTextStr(data.displayText, function(symbol) + Private.ParseTextStr(data.displayText, function(symbol) if not seenSymbols[symbol] then local triggerNum, sym = string.match(symbol, "(.+)%.(.+)") sym = sym or symbol @@ -739,7 +739,7 @@ function Private.Modernize(data) for index, subRegionData in ipairs(data.subRegions) do if subRegionData.type == "subtext" then local seenSymbols = {} - WeakAuras.ParseTextStr(subRegionData.text_text, function(symbol) + Private.ParseTextStr(subRegionData.text_text, function(symbol) if not seenSymbols[symbol] then local triggerNum, sym = string.match(symbol, "(.+)%.(.+)") sym = sym or symbol @@ -759,7 +759,7 @@ function Private.Modernize(data) for _, when in ipairs{ "start", "finish" } do if data.actions[when] then local seenSymbols = {} - WeakAuras.ParseTextStr(data.actions[when].message, function(symbol) + Private.ParseTextStr(data.actions[when].message, function(symbol) if not seenSymbols[symbol] then local triggerNum, sym = string.match(symbol, "(.+)%.(.+)") sym = sym or symbol @@ -780,7 +780,7 @@ function Private.Modernize(data) for changeIndex, change in ipairs(condition.changes) do if change.property == "chat" and change.value then local seenSymbols = {} - WeakAuras.ParseTextStr(change.value.message, function(symbol) + Private.ParseTextStr(change.value.message, function(symbol) if not seenSymbols[symbol] then local triggerNum, sym = string.match(symbol, "(.+)%.(.+)") sym = sym or symbol @@ -804,7 +804,7 @@ function Private.Modernize(data) data.totalPrecision = nil end - -- Introduced in June 2020 in Bfa + -- Introduced in June 2020 in BfA if data.internalVersion < 31 then local allowedNames local ignoredNames @@ -836,7 +836,7 @@ function Private.Modernize(data) data.load.realm = nil end --- Introduced in June 2020 in Bfa + -- Introduced in June 2020 in BfA if data.internalVersion < 32 then local replacements = {} local function repairCheck(replacements, check) @@ -888,7 +888,7 @@ function Private.Modernize(data) end end - -- Introduced in July 2020 in Bfa + -- Introduced in July 2020 in BfA if data.internalVersion < 33 then data.load.use_ignoreNameRealm = data.load.use_namerealmblack data.load.ignoreNameRealm = data.load.namerealmblack @@ -912,7 +912,7 @@ function Private.Modernize(data) end - -- Introduced in July 2020 in Shadolands + -- Introduced in July 2020 in Shadowlands if data.internalVersion < 34 then if data.regionType == 'dynamicgroup' and (data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE") then diff --git a/WeakAuras/Profiling.lua b/WeakAuras/Profiling.lua index 21af269..c121ce0 100644 --- a/WeakAuras/Profiling.lua +++ b/WeakAuras/Profiling.lua @@ -24,9 +24,8 @@ RealTimeProfilingWindow:SetMovable(true) RealTimeProfilingWindow:Hide() WeakAuras.RealTimeProfilingWindow = RealTimeProfilingWindow -WeakAuras.profileData = profileData - -WeakAuras.table_to_string = function(tbl, depth) +local table_to_string +table_to_string = function(tbl, depth) if depth and depth >= 3 then return "{ ... }" end @@ -34,7 +33,7 @@ WeakAuras.table_to_string = function(tbl, depth) for k, v in pairs(tbl) do if type(v) ~= "userdata" then if type(v) == "table" then - v = WeakAuras.table_to_string(v, (depth and depth + 1 or 1)) + v = table_to_string(v, (depth and depth + 1 or 1)) elseif type(v) == "function" then v = "function" elseif type(v) == "string" then @@ -129,7 +128,7 @@ local function CreateProfilePopup() m = m .. "|n" end if type(v) == "table" then - v = WeakAuras.table_to_string(v) + v = table_to_string(v) end popupFrame.originalText = m .. v popupFrame:SetText(popupFrame.originalText) @@ -273,14 +272,14 @@ local function StopProfileAura(id) end local function StartProfileUID(uid) - StartProfiling(profileData.auras, WeakAuras.UIDtoID(uid)) + StartProfiling(profileData.auras, Private.UIDtoID(uid)) end local function StopProfileUID(uid) - StopProfiling(profileData.auras, WeakAuras.UIDtoID(uid)) + StopProfiling(profileData.auras, Private.UIDtoID(uid)) end -function WeakAuras.ProfileRenameAura(oldid, id) +function Private.ProfileRenameAura(oldid, id) profileData.auras[id] = profileData.auras[id] profileData.auras[oldid] = nil end @@ -330,12 +329,12 @@ function WeakAuras.StartProfile(startType) profileData.systems.time.start = debugprofilestop() profileData.systems.time.count = 1 - WeakAuras.StartProfileSystem = StartProfileSystem - WeakAuras.StartProfileAura = StartProfileAura - WeakAuras.StartProfileUID = StartProfileUID - WeakAuras.StopProfileSystem = StopProfileSystem - WeakAuras.StopProfileAura = StopProfileAura - WeakAuras.StopProfileUID = StopProfileUID + Private.StartProfileSystem = StartProfileSystem + Private.StartProfileAura = StartProfileAura + Private.StartProfileUID = StartProfileUID + Private.StopProfileSystem = StopProfileSystem + Private.StopProfileAura = StopProfileAura + Private.StopProfileUID = StopProfileUID end local function doNothing() @@ -352,12 +351,12 @@ function WeakAuras.StopProfile() profileData.systems.time.elapsed = debugprofilestop() - profileData.systems.time.start profileData.systems.time.count = 0 - WeakAuras.StartProfileSystem = doNothing - WeakAuras.StartProfileAura = doNothing - WeakAuras.StartProfileUID = doNothing - WeakAuras.StopProfileSystem = doNothing - WeakAuras.StopProfileAura = doNothing - WeakAuras.StopProfileUID = doNothing + Private.StartProfileSystem = doNothing + Private.StartProfileAura = doNothing + Private.StartProfileUID = doNothing + Private.StopProfileSystem = doNothing + Private.StopProfileAura = doNothing + Private.StopProfileUID = doNothing currentProfileState = nil RealTimeProfilingWindow:UnregisterAllEvents() diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 8216f13..08207c2 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -87,7 +87,7 @@ local constants = { nameRealmFilterDesc = L[" Filter formats: 'Name', 'Name-Realm', '-Realm'. \n\nSupports multiple entries, separated by commas\n"], } -WeakAuras.function_strings = { +Private.function_strings = { count = [[ return function(count) if(count %s %s) then @@ -147,7 +147,7 @@ function WeakAuras.GetHSVTransition(perc, r1, g1, b1, a1, r2, g2, b2, a2) end -WeakAuras.anim_function_strings = { +Private.anim_function_strings = { straight = [[ function(progress, start, delta) return start + (progress * delta) @@ -330,7 +330,7 @@ WeakAuras.anim_function_strings = { ]] }; -WeakAuras.anim_presets = { +Private.anim_presets = { -- Start and Finish slidetop = { type = "custom", @@ -651,20 +651,6 @@ function WeakAuras.IsSpellKnownIncludingPet(spell) end end -local talent_types_specific = {} -local talents_ids = { - DEATHKNIGHT = {{48979,48997,49182,48978,49004,55107,48982,48987,49467,48985,49145,49015,48977,49006,49005,48988,53137,49027,49016,50365,62905,49018,55233,49189,55050,49023,61154,49028}, {49175,49455,49042,55061,49140,49226,50880,49039,51468,51123,49149,49137,49186,49471,49796,55610,49024,49188,50040,49203,50384,65661,54639,51271,49200,49143,50187,49202,49184}, {51745,48962,55129,49036,48963,49588,48965,49013,51459,49158,49146,49219,55620,49194,49220,49223,55666,49224,49208,52143,66799,51052,50391,63560,49032,49222,49217,51099,55090,50117,49206}}, - DRUID = {{16814,57810,16845,35363,16821,16836,16880,57865,16819,16909,16850,33589,5570,57849,33597,16896,33592,24858,48384,33600,48389,33603,48516,50516,33831,48488,48506,48505}, {16934,16858,16947,16998,16929,17002,61336,16942,16966,16972,37116,48409,16940,49377,33872,57878,17003,33853,17007,34297,33851,57873,33859,48483,48492,33917,48532,48432,63503,50334}, {17050,17063,17056,17069,17118,16833,17106,16864,48411,24968,17111,17116,17104,17123,33879,17074,34151,18562,33881,33886,48496,48539,65139,48535,63410,51179,48438}}, - HUNTER = {{19552,19583,35029,19549,19609,24443,19559,53265,19616,19572,19598,19578,19577,19590,34453,19621,34455,19574,34462,53252,34466,53262,34692,53256,56314,53270}, {19407,53620,19426,34482,19421,19485,34950,19454,19434,34948,19464,19416,35100,23989,19461,34475,19507,53234,19506,35104,34485,53228,53215,34490,53221,53241,53209}, {52783,19498,19159,19290,19184,19376,34494,19255,19503,19295,19286,56333,56342,56339,19370,19306,19168,34491,34500,19386,34497,34506,53295,53298,3674,53302,53290,53301}}, - MAGE = {{11210,11222,11237,28574,29441,11213,11247,11242,44397,54646,11252,11255,18462,29447,31569,12043,11232,31574,15058,31571,31579,12042,44394,44378,31584,31589,44404,44400,35578,44425}, {11078,18459,11069,11119,54747,11108,11100,11103,11366,11083,11095,11094,29074,31638,11115,11113,31641,11124,34293,11129,31679,64353,31656,44442,31661,44445,44449,44457}, {11071,11070,31670,11207,11189,29438,11175,11151,12472,11185,16757,11160,11170,11958,11190,31667,55091,11180,44745,11426,31674,31682,44543,44546,31687,44557,44566,44572}}, - PALADIN = {{20205,20224,20237,20257,9453,31821,20210,20234,20254,20244,53660,31822,20216,20359,31825,5923,31833,20473,31828,53551,31837,31842,53671,53569,53556,53563}, {63646,20262,31844,20174,20096,64205,20468,20143,53527,20487,20138,20911,20177,31848,20196,31785,20925,31850,20127,31858,53590,31935,53583,53709,53695,53595}, {20060,20101,25956,20335,20042,9452,20117,20375,26022,9799,32043,31866,20111,31869,20049,31871,53486,20066,31876,31879,53375,53379,35395,53501,53380,53385}}, - PRIEST = {{14522,47586,14523,14747,14749,14531,14521,14751,14748,33167,14520,14750,33201,18551,63574,33186,34908,45234,10060,63504,57470,47535,47507,47509,33206,47516,52795,47540}, {14913,14908,14889,27900,18530,19236,27811,14892,27789,14912,14909,14911,20711,14901,33150,14898,34753,724,33142,64127,33158,63730,63534,34861,47558,47562,47788}, {15270,15337,15259,15318,15275,15260,15392,15273,15407,15274,17322,15257,15487,15286,27839,33213,14910,63625,15473,33221,47569,33191,64044,34914,47580,47573,47585}}, - ROGUE = {{14162,14144,14138,14156,51632,13733,14983,14168,14128,16513,14113,31208,14177,14174,31244,14186,14158,51625,58426,31380,51634,31234,31226,1329,51627,51664,51662}, {13741,13732,13715,14165,13713,13705,13742,14251,13706,13754,13743,13712,18427,13709,13877,13960,30919,31124,31122,13750,31130,5952,35541,51672,32601,51682,51685,51690}, {14179,13958,14057,30892,14076,13975,13981,14278,14171,13983,13976,14079,30894,14185,14082,16511,31221,30902,31211,14183,31228,31216,51692,51698,36554,58414,51708,51713}}, - SHAMAN = {{16039,16035,16038,28996,30160,16040,16164,16089,16086,29062,28999,16041,30664,30672,16578,16166,51483,63370,51466,30675,51474,30706,51480,62097,51490}, {16259,16043,17485,16258,16255,16262,16261,16266,43338,16254,16256,16252,29192,16268,51883,30802,29082,63373,30816,30798,17364,51525,60103,51521,30812,30823,51523,51528,51533}, {16182,16173,16184,29187,16179,16180,16181,55198,16176,16187,16194,29206,16188,30864,16178,30881,16190,51886,51554,30872,30867,51556,974,51560,51562,61295}}, - WARLOCK = {{18827,18174,17810,18179,18213,18182,17804,53754,17783,18288,18218,18094,32381,32385,63108,18223,54037,18271,47195,30060,18220,30054,32477,47198,30108,58435,47201,48181}, {18692,18694,18697,47230,18703,18705,18731,18754,19028,18708,30143,18769,18709,30326,18767,23785,47245,30319,47193,35691,30242,63156,54347,30146,63117,47236,59672}, {17793,17788,18119,63349,17778,18126,17877,17959,18135,17917,17927,34935,17815,18130,30299,17954,17962,30293,18096,30288,54117,47258,30283,47220,47266,50796}}, - WARRIOR = {{12282,16462,12286,12285,12300,12295,12290,12296,16493,12834,12163,56636,12700,12328,12284,12281,20504,12289,46854,29834,12294,46865,12862,64976,35446,46859,29723,29623,29836,46867,46924}, {61216,12321,12320,12324,12322,12329,12323,16487,12318,23584,20502,12317,29590,12292,29888,20500,12319,46908,23881,29721,46910,29759,60970,29801,46913,56927,46917}, {12301,12298,12287,50685,12297,12975,12797,29598,12299,59088,12313,12308,12312,12809,12311,16538,29593,50720,29787,29140,46945,57499,20243,47294,46951,58872,46968}} -} - local function valuesForTalentFunction(trigger) return function() local single_class; @@ -689,27 +675,27 @@ local function valuesForTalentFunction(trigger) end -- If a single specific class was found, load the specific list for it - if single_class and talents_ids[single_class] then - if not talent_types_specific[single_class] then - talent_types_specific[single_class] = {} - for tab = 1, #talents_ids[single_class] do - for num_talent = 1, #talents_ids[single_class][tab] do - local spellName, _, spellIcon = GetSpellInfo(talents_ids[single_class][tab][num_talent]) + if single_class and Private.talents_ids[single_class] then + if not Private.talent_types_specific[single_class] then + Private.talent_types_specific[single_class] = {} + for tab = 1, #Private.talents_ids[single_class] do + for num_talent = 1, #Private.talents_ids[single_class][tab] do + local spellName, _, spellIcon = GetSpellInfo(Private.talents_ids[single_class][tab][num_talent]) local talentId = (tab - 1) * MAX_NUM_TALENTS + num_talent if spellName and spellIcon then - talent_types_specific[single_class][talentId] = ("|T%s:24|t %s"):format(spellIcon, spellName) + Private.talent_types_specific[single_class][talentId] = ("|T%s:24|t %s"):format(spellIcon, spellName) end end end end - return talent_types_specific[single_class]; + return Private.talent_types_specific[single_class]; else - return WeakAuras.talent_types; + return Private.talent_types; end end end -WeakAuras.load_prototype = { +Private.load_prototype = { args = { { name = "combat", @@ -887,8 +873,8 @@ local function AddUnitChangeInternalEvents(triggerUnit, t) WeakAuras.WatchForPetDeath(); tinsert(t, "PET_UPDATE") else - if WeakAuras.multiUnitUnits[triggerUnit] then - for unit in pairs(WeakAuras.multiUnitUnits[triggerUnit]) do + if Private.multiUnitUnits[triggerUnit] then + for unit in pairs(Private.multiUnitUnits[triggerUnit]) do tinsert(t, "UNIT_CHANGED_" .. string.lower(unit)) WeakAuras.WatchUnitChange(unit) end @@ -919,8 +905,8 @@ end local unitHelperFunctions = { UnitChangedForceEvents = function(trigger) local events = {} - if WeakAuras.multiUnitUnits[trigger.unit] then - for unit in pairs(WeakAuras.multiUnitUnits[trigger.unit]) do + if Private.multiUnitUnits[trigger.unit] then + for unit in pairs(Private.multiUnitUnits[trigger.unit]) do tinsert(events, {"UNIT_CHANGED_" .. unit, unit}) end else @@ -946,7 +932,7 @@ local unitHelperFunctions = { end } -WeakAuras.event_prototypes = { +Private.event_prototypes = { ["Combo Points"] = { type = "status", events = { @@ -1033,7 +1019,7 @@ WeakAuras.event_prototypes = { store = true, conditionType = "bool", desc = function() return L["Can be used for e.g. checking if \"boss1target\" is the same as \"player\"."] end, - enable = function(trigger) return not WeakAuras.multiUnitUnits[trigger.unit] end + enable = function(trigger) return not Private.multiUnitUnits[trigger.unit] end }, { name = "name", @@ -1163,6 +1149,115 @@ WeakAuras.event_prototypes = { }, automaticrequired = true }, + ["Experience"] = { + type = "status", + canHaveDuration = false, + events = { + ["events"] = { + "PLAYER_XP_UPDATE", + } + }, + internal_events = {"WA_DELAYED_PLAYER_ENTERING_WORLD"}, + force_events = "PLAYER_XP_UPDATE", + name = L["Player Experience"], + init = function(trigger) + return "" + end, + statesParameter = "one", + args = { + { + name = "level", + display = L["Level"], + required = false, + type = "number", + store = true, + init = [[UnitLevel("player")]], + conditionType = "number", + }, + { + name = "currentXP", + display = L["Current Experience"], + type = "number", + store = true, + init = [[UnitXP("player")]], + conditionType = "number", + }, + { + name = "totalXP", + display = L["Total Experience"], + type = "number", + store = true, + init = [[UnitXPMax("player")]], + conditionType = "number", + }, + { + name = "value", + type = "number", + store = true, + init = "currentXP", + hidden = true, + test = "true", + }, + { + name = "total", + type = "number", + store = true, + init = "totalXP", + hidden = true, + test = "true", + }, + { + name = "progressType", + hidden = true, + init = "'static'", + store = true, + test = "true" + }, + { + name = "percentXP", + display = L["Experience (%)"], + type = "number", + init = "total ~= 0 and (value / total) * 100", + store = true, + conditionType = "number" + }, + { + name = "showRested", + display = L["Show Rested Overlay"], + type = "toggle", + test = "true", + reloadOptions = true, + }, + { + name = "restedXP", + display = L["Rested Experience"], + init = [[GetXPExhaustion() or 0]], + type = "number", + store = true, + conditionType = "number", + }, + { + name = "percentrested", + display = L["Rested Experience (%)"], + init = "total ~= 0 and (restedXP / total) * 100", + type = "number", + store = true, + conditionType = "number", + }, + }, + overlayFuncs = { + { + name = L["Rested"], + func = function(trigger, state) + return "forward", state.restedXP + end, + enable = function(trigger) + return trigger.use_showRested + end + }, + }, + automaticrequired = true + }, ["Health"] = { type = "status", canHaveDuration = true, @@ -3713,10 +3808,10 @@ WeakAuras.event_prototypes = { type = "multiselect", values = function() local class = select(2, UnitClass("player")); - if talent_types_specific[class] then - return talent_types_specific[class]; + if Private.talent_types_specific[class] then + return Private.talent_types_specific[class]; else - return WeakAuras.talent_types; + return Private.talent_types; end end, test = "active", @@ -4472,8 +4567,10 @@ WeakAuras.event_prototypes = { if not(trigger.use_inverse) then startTime, duration = WeakAuras.GetRuneCooldown(trigger.rune); end + startTime = startTime or 0; duration = duration or 0; + return duration, startTime + duration; else return 1, 0; @@ -4842,9 +4939,9 @@ WeakAuras.event_prototypes = { init = "arg", values = function(trigger) if trigger.use_inverse then - return WeakAuras.actual_unit_types_with_specific + return Private.actual_unit_types_with_specific else - return WeakAuras.actual_unit_types_cast + return Private.actual_unit_types_cast end end, test = "true", @@ -5266,7 +5363,7 @@ WeakAuras.event_prototypes = { }, { name = "moveSpeed", - display = L["Continously update Movement Speed"], + display = L["Continuously update Movement Speed"], type = "boolean", test = true, width = WeakAuras.doubleWidth @@ -5758,12 +5855,12 @@ WeakAuras.event_prototypes = { }; -WeakAuras.event_prototypes["DBM Announce"] = nil -WeakAuras.event_prototypes["DBM Timer"] = nil -WeakAuras.event_prototypes["BigWigs Message"] = nil -WeakAuras.event_prototypes["BigWigs Timer"] = nil +Private.event_prototypes["DBM Announce"] = nil +Private.event_prototypes["DBM Timer"] = nil +Private.event_prototypes["BigWigs Message"] = nil +Private.event_prototypes["BigWigs Timer"] = nil -WeakAuras.dynamic_texts = { +Private.dynamic_texts = { ["p"] = { get = function(state) if not state then return nil end diff --git a/WeakAuras/RegionTypes/AuraBar.lua b/WeakAuras/RegionTypes/AuraBar.lua index 1ed3912..6d68506 100644 --- a/WeakAuras/RegionTypes/AuraBar.lua +++ b/WeakAuras/RegionTypes/AuraBar.lua @@ -117,7 +117,7 @@ local properties = { display = L["Orientation"], setter = "SetOrientation", type = "list", - values = WeakAuras.orientation_types + values = Private.orientation_types }, inverse = { display = L["Inverse"], @@ -129,10 +129,9 @@ local properties = { WeakAuras.regionPrototype.AddProperties(properties, default); local function GetProperties(data) - local overlayInfo = WeakAuras.GetOverlayInfo(data); + local overlayInfo = Private.GetOverlayInfo(data); if (overlayInfo and next(overlayInfo)) then - local auraProperties = {}; - WeakAuras.DeepCopy(properties, auraProperties); + local auraProperties = CopyTable(properties) for id, display in ipairs(overlayInfo) do auraProperties["overlays." .. id] = { @@ -758,11 +757,11 @@ local funcs = { selfPoint = selfPoint or "CENTER" - if not WeakAuras.point_types[selfPoint] then + if not Private.point_types[selfPoint] then selfPoint = "CENTER" end - if not WeakAuras.point_types[anchorPoint] then + if not Private.point_types[anchorPoint] then anchorPoint = "CENTER" end @@ -988,7 +987,7 @@ local function modify(parent, region, data) -- Localize local bar, iconFrame, icon = region.bar, region.iconFrame, region.icon; - region.useAuto = data.auto and WeakAuras.CanHaveAuto(data); + region.useAuto = data.auto and Private.CanHaveAuto(data); -- Adjust region size region:SetWidth(data.width); @@ -1012,9 +1011,10 @@ local function modify(parent, region, data) region.desaturateIcon = data.desaturate region.zoom = data.zoom - region.overlays = {}; if (data.overlays) then - WeakAuras.DeepCopy(data.overlays, region.overlays); + region.overlays = CopyTable(data.overlays); + else + region.overlays = {} end -- Update texture settings @@ -1084,16 +1084,16 @@ local function modify(parent, region, data) region:UpdateEffectiveOrientation() -- Update tooltip availability - local tooltipType = WeakAuras.CanHaveTooltip(data); + local tooltipType = Private.CanHaveTooltip(data); if tooltipType and data.useTooltip then -- Create and enable tooltip-hover frame if not region.tooltipFrame then region.tooltipFrame = CreateFrame("frame", nil, region); region.tooltipFrame:SetAllPoints(icon); region.tooltipFrame:SetScript("OnEnter", function() - WeakAuras.ShowMouseoverTooltip(region, region.tooltipFrame); + Private.ShowMouseoverTooltip(region, region.tooltipFrame); end); - region.tooltipFrame:SetScript("OnLeave", WeakAuras.HideTooltip); + region.tooltipFrame:SetScript("OnLeave", Private.HideTooltip); end region.tooltipFrame:EnableMouse(true); diff --git a/WeakAuras/RegionTypes/DynamicGroup.lua b/WeakAuras/RegionTypes/DynamicGroup.lua index 421a4dc..893ac22 100644 --- a/WeakAuras/RegionTypes/DynamicGroup.lua +++ b/WeakAuras/RegionTypes/DynamicGroup.lua @@ -95,7 +95,7 @@ local function releaseControlPoint(self, controlPoint) local regionData = controlPoint.regionData if regionData then if self.parent.anchorPerUnit == "UNITFRAME" then - WeakAuras.dyngroup_unitframe_monitor[regionData] = nil + Private.dyngroup_unitframe_monitor[regionData] = nil end controlPoint.regionData = nil regionData.controlPoint = nil @@ -760,7 +760,7 @@ local function SafeGetPos(region, func) end local function modify(parent, region, data) - WeakAuras.FixGroupChildrenOrderForGroup(data) + Private.FixGroupChildrenOrderForGroup(data) -- Scale region:SetScale(data.scale and data.scale > 0 and data.scale or 1) WeakAuras.regionPrototype.modify(parent, region, data) @@ -854,7 +854,7 @@ local function modify(parent, region, data) local frameStrata = region:GetFrameStrata() childRegion:SetFrameStrata(frameStrata ~= "UNKNOWN" and frameStrata or "BACKGROUND"); else - childRegion:SetFrameStrata(WeakAuras.frame_strata_types[childData.frameStrata]); + childRegion:SetFrameStrata(Private.frame_strata_types[childData.frameStrata]); end return regionData end @@ -877,8 +877,8 @@ local function modify(parent, region, data) function region:ReloadControlledChildren() -- 'forgets' about regions it controls and starts from scratch. Mostly useful when Add()ing the group if not self:IsSuspended() then - WeakAuras.StartProfileSystem("dynamicgroup") - WeakAuras.StartProfileAura(data.id) + Private.StartProfileSystem("dynamicgroup") + Private.StartProfileAura(data.id) self.needToReload = false self.sortedChildren = {} self.controlledChildren = {} @@ -903,8 +903,8 @@ local function modify(parent, region, data) end end end - WeakAuras.StopProfileSystem("dynamicgroup") - WeakAuras.StopProfileAura(data.id) + Private.StopProfileSystem("dynamicgroup") + Private.StopProfileAura(data.id) self:SortUpdatedChildren() else self.needToReload = true @@ -976,8 +976,8 @@ local function modify(parent, region, data) -- Called when the Group is Resume()d -- uses sort data to determine the correct spot if not self:IsSuspended() then - WeakAuras.StartProfileSystem("dynamicgroup") - WeakAuras.StartProfileAura(data.id) + Private.StartProfileSystem("dynamicgroup") + Private.StartProfileAura(data.id) self.needToSort = false local i = 1 while self.sortedChildren[i] do @@ -1006,8 +1006,8 @@ local function modify(parent, region, data) end end self.updatedChildren = {} - WeakAuras.StopProfileSystem("dynamicgroup") - WeakAuras.StopProfileAura(data.id) + Private.StopProfileSystem("dynamicgroup") + Private.StopProfileAura(data.id) self:PositionChildren() else self.needToSort = true @@ -1063,10 +1063,10 @@ local function modify(parent, region, data) controlPoint:SetWidth(regionData.dimensions.width) controlPoint:SetHeight(regionData.dimensions.height) if self.anchorPerUnit == "UNITFRAME" then - WeakAuras.dyngroup_unitframe_monitor[regionData] = frame + Private.dyngroup_unitframe_monitor[regionData] = frame end if animate then - WeakAuras.CancelAnimation(regionData.controlPoint, true) + Private.CancelAnimation(regionData.controlPoint, true) local xPrev = regionData.xOffset or x local yPrev = regionData.yOffset or y local xDelta = xPrev - x @@ -1137,7 +1137,7 @@ local function modify(parent, region, data) } end -- update animated expand & collapse for this child - WeakAuras.Animate("controlPoint", data.uid, "controlPoint", anim, regionData.controlPoint, true) + Private.Animate("controlPoint", data.uid, "controlPoint", anim, regionData.controlPoint, true) end end regionData.xOffset = x @@ -1147,8 +1147,8 @@ local function modify(parent, region, data) end function region:DoPositionChildren() - WeakAuras.StartProfileSystem("dynamicgroup") - WeakAuras.StartProfileAura(data.id) + Private.StartProfileSystem("dynamicgroup") + Private.StartProfileAura(data.id) local handledRegionData = {} @@ -1179,8 +1179,8 @@ local function modify(parent, region, data) end end - WeakAuras.StopProfileSystem("dynamicgroup") - WeakAuras.StopProfileAura(data.id) + Private.StopProfileSystem("dynamicgroup") + Private.StopProfileAura(data.id) self:Resize() end @@ -1190,8 +1190,8 @@ local function modify(parent, region, data) if not self:IsSuspended() then self.needToResize = false -- if self.dynamicAnchor then self:UpdateBorder(); return end - WeakAuras.StartProfileSystem("dynamicgroup") - WeakAuras.StartProfileAura(data.id) + Private.StartProfileSystem("dynamicgroup") + Private.StartProfileAura(data.id) local numVisible, minX, maxX, maxY, minY, minLevel = 0 for active, regionData in ipairs(self.sortedChildren) do if regionData.shown then @@ -1231,8 +1231,8 @@ local function modify(parent, region, data) if WeakAuras.IsOptionsOpen() then WeakAuras.OptionsFrame().moversizer:ReAnchor() end - WeakAuras.StopProfileSystem("dynamicgroup") - WeakAuras.StopProfileAura(data.id) + Private.StopProfileSystem("dynamicgroup") + Private.StopProfileAura(data.id) else self.needToResize = true end diff --git a/WeakAuras/RegionTypes/Group.lua b/WeakAuras/RegionTypes/Group.lua index 220090a..9fc098f 100644 --- a/WeakAuras/RegionTypes/Group.lua +++ b/WeakAuras/RegionTypes/Group.lua @@ -110,7 +110,7 @@ local function modify(parent, region, data) region.try = highest; -- Adjust frame-level sorting - WeakAuras.FixGroupChildrenOrderForGroup(data); + Private.FixGroupChildrenOrderForGroup(data); -- Control children (does not happen with "group") function region:UpdateBorder(childRegion) diff --git a/WeakAuras/RegionTypes/Icon.lua b/WeakAuras/RegionTypes/Icon.lua index 525cdf1..1fe96e7 100644 --- a/WeakAuras/RegionTypes/Icon.lua +++ b/WeakAuras/RegionTypes/Icon.lua @@ -145,11 +145,11 @@ local function AnchorSubRegion(self, subRegion, anchorType, selfPoint, anchorPoi anchorXOffset = anchorXOffset or 0 anchorYOffset = anchorYOffset or 0 - if not WeakAuras.point_types[selfPoint] then + if not Private.point_types[selfPoint] then selfPoint = "CENTER" end - if not WeakAuras.point_types[anchorPoint] then + if not Private.point_types[anchorPoint] then anchorPoint = "CENTER" end @@ -256,7 +256,7 @@ local function modify(parent, region, data) local button, icon, cooldown = region.button, region.icon, region.cooldown; - region.useAuto = data.auto and WeakAuras.CanHaveAuto(data); + region.useAuto = data.auto and Private.CanHaveAuto(data); if MSQ then local masqueId = data.id:lower():gsub(" ", "_"); @@ -331,15 +331,15 @@ local function modify(parent, region, data) region.zoom = data.zoom; region:UpdateSize() - local tooltipType = WeakAuras.CanHaveTooltip(data); + local tooltipType = Private.CanHaveTooltip(data); if(tooltipType and data.useTooltip) then if not region.tooltipFrame then region.tooltipFrame = CreateFrame("frame", nil, region); region.tooltipFrame:SetAllPoints(region); region.tooltipFrame:SetScript("OnEnter", function() - WeakAuras.ShowMouseoverTooltip(region, region); + Private.ShowMouseoverTooltip(region, region); end); - region.tooltipFrame:SetScript("OnLeave", WeakAuras.HideTooltip); + region.tooltipFrame:SetScript("OnLeave", Private.HideTooltip); end region.tooltipFrame:EnableMouse(true); elseif region.tooltipFrame then diff --git a/WeakAuras/RegionTypes/Model.lua b/WeakAuras/RegionTypes/Model.lua index a6bd593..657fa84 100644 --- a/WeakAuras/RegionTypes/Model.lua +++ b/WeakAuras/RegionTypes/Model.lua @@ -120,11 +120,11 @@ local function AcquireModel(region, data) model:RegisterEvent("PLAYER_FOCUS_CHANGED"); end model:SetScript("OnEvent", function(self, event, unitId) - WeakAuras.StartProfileSystem("model"); + Private.StartProfileSystem("model"); if (event ~= "UNIT_MODEL_CHANGED" or UnitIsUnit(unitId, data.model_path)) then WeakAuras.SetModel(model, data.model_path, data.modelIsUnit, data.modelDisplayInfo) end - WeakAuras.StopProfileSystem("model"); + Private.StopProfileSystem("model"); end ); else @@ -138,10 +138,10 @@ local function AcquireModel(region, data) if(data.advance) then local elapsed = 0; model:SetScript("OnUpdate", function(self, elaps) - WeakAuras.StartProfileSystem("model"); + Private.StartProfileSystem("model"); elapsed = elapsed + (elaps * 1000); model:SetSequenceTime(data.sequence, elapsed); - WeakAuras.StopProfileSystem("model"); + Private.StopProfileSystem("model"); end) else model:SetScript("OnUpdate", nil) @@ -263,18 +263,18 @@ end -- Work around for movies and world map hiding all models do - function WeakAuras.PreShowModels(self, event) - WeakAuras.StartProfileSystem("model"); + function Private.PreShowModels(self, event) + Private.StartProfileSystem("model"); for id, data in pairs(WeakAuras.regions) do - WeakAuras.StartProfileAura(id); + Private.StartProfileAura(id); if data.region.toShow then if (data.regionType == "model") then data.region:PreShow(); end end - WeakAuras.StopProfileAura(id); + Private.StopProfileAura(id); end - WeakAuras.StopProfileSystem("model"); + Private.StopProfileSystem("model"); end end diff --git a/WeakAuras/RegionTypes/RegionPrototype.lua b/WeakAuras/RegionTypes/RegionPrototype.lua index 22bb8b5..ac07258 100644 --- a/WeakAuras/RegionTypes/RegionPrototype.lua +++ b/WeakAuras/RegionTypes/RegionPrototype.lua @@ -115,7 +115,7 @@ end local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ceil(GetScreenHeight() / 20) * 20; -function WeakAuras.GetAnchorsForData(parentData, type) +function Private.GetAnchorsForData(parentData, type) local result if not parentData.controlledChildren then if not WeakAuras.regionOptions[parentData.regionType] or not WeakAuras.regionOptions[parentData.regionType].getAnchors then @@ -139,8 +139,8 @@ function WeakAuras.regionPrototype:AnchorSubRegion(subRegion, anchorType, selfPo if anchorType == "point" then local xOffset = anchorXOffset or 0 local yOffset = anchorYOffset or 0 - subRegion:SetPoint(WeakAuras.point_types[selfPoint] and selfPoint or "CENTER", - self, WeakAuras.point_types[anchorPoint] and anchorPoint or "CENTER", + subRegion:SetPoint(Private.point_types[selfPoint] and selfPoint or "CENTER", + self, Private.point_types[anchorPoint] and anchorPoint or "CENTER", xOffset, yOffset) else anchorXOffset = anchorXOffset or 0 @@ -203,46 +203,46 @@ function WeakAuras.regionPrototype.AddProperties(properties, defaultsForRegion) end local function SoundRepeatStop(self) - WeakAuras.StartProfileSystem("sound"); + Private.StartProfileSystem("sound"); if (self.soundRepeatTimer) then WeakAuras.timer:CancelTimer(self.soundRepeatTimer); self.soundRepeatTimer = nil; end - WeakAuras.StopProfileSystem("sound"); + Private.StopProfileSystem("sound"); end local function SoundPlayHelper(self) - WeakAuras.StartProfileSystem("sound"); + Private.StartProfileSystem("sound"); local options = self.soundOptions; if (not options or options.sound_type == "Stop") then - WeakAuras.StopProfileSystem("sound"); + Private.StopProfileSystem("sound"); return; end - if (WeakAuras.IsOptionsOpen() or WeakAuras.SquelchingActions()) then - WeakAuras.StopProfileSystem("sound"); + if (WeakAuras.IsOptionsOpen() or Private.SquelchingActions()) then + Private.StopProfileSystem("sound"); return; end if (options.sound == " custom") then if (options.sound_path) then - PlaySoundFile(options.sound_path, options.sound_channel or "Master"); + pcall(PlaySoundFile, options.sound_path, options.sound_channel or "Master"); end elseif (options.sound == " KitID") then if (options.sound_kit_id) then - PlaySound(options.sound_kit_id, options.sound_channel or "Master"); + pcall(PlaySound, options.sound_kit_id, options.sound_channel or "Master"); end else - PlaySoundFile(options.sound, options.sound_channel or "Master"); + pcall(PlaySoundFile, options.sound, options.sound_channel or "Master"); end - WeakAuras.StopProfileSystem("sound"); + Private.StopProfileSystem("sound"); end local function SoundPlay(self, options) if (not options or WeakAuras.IsOptionsOpen()) then return end - WeakAuras.StartProfileSystem("sound"); + Private.StartProfileSystem("sound"); self:SoundRepeatStop(); self.soundOptions = options; @@ -252,7 +252,7 @@ local function SoundPlay(self, options) if (loop and options.sound_repeat) then self.soundRepeatTimer = WeakAuras.timer:ScheduleRepeatingTimer(SoundPlayHelper, options.sound_repeat, self); end - WeakAuras.StopProfileSystem("sound"); + Private.StopProfileSystem("sound"); end local function SendChat(self, options) @@ -260,7 +260,7 @@ local function SendChat(self, options) return end - WeakAuras.HandleChatAction(options.message_type, options.message, options.message_dest, options.message_channel, options.r, options.g, options.b, self, options.message_custom, nil, options.message_formaters); + Private.HandleChatAction(options.message_type, options.message, options.message_dest, options.message_channel, options.r, options.g, options.b, self, options.message_custom, nil, options.message_formaters); end local function RunCode(self, func) @@ -275,7 +275,7 @@ local function GlowExternal(self, options) if (not options or WeakAuras.IsOptionsOpen()) then return end - WeakAuras.HandleGlowAction(options, self) + Private.HandleGlowAction(options, self) end local function UpdatePosition(self) @@ -423,11 +423,23 @@ local function UpdateRegionHasTimerTick(self) self:UpdateTimerTick() end +local function TimerTickForRegion(region) + Private.StartProfileSystem("timer tick") + Private.StartProfileAura(region.id); + if region.TimerTick then + region:TimerTick(); + end + + region.subRegionEvents:Notify("TimerTick") + Private.StopProfileAura(region.id); + Private.StopProfileSystem("timer tick") +end + local function UpdateTimerTick(self) if self.triggerProvidesTimer and self.regionHasTimer then if not self:GetScript("OnUpdate") then self:SetScript("OnUpdate", function() - WeakAuras.TimerTick(self) + TimerTickForRegion(self) end); end else @@ -536,11 +548,11 @@ function WeakAuras.regionPrototype.modify(parent, region, data) or data.regionType == "dynamicgroup" or data.regionType == "group" then - WeakAuras.AnchorFrame(data, region, parent); + Private.AnchorFrame(data, region, parent); end end - region.startFormatters = WeakAuras.CreateFormatters(data.actions.start.message, function(key, default) + region.startFormatters = Private.CreateFormatters(data.actions.start.message, function(key, default) local fullKey = "message_format_" .. key if data.actions.start[fullKey] == nil then data.actions.start[fullKey] = default @@ -548,7 +560,7 @@ function WeakAuras.regionPrototype.modify(parent, region, data) return data.actions.start[fullKey] end) - region.finishFormatters = WeakAuras.CreateFormatters(data.actions.finish.message, function(key, default) + region.finishFormatters = Private.CreateFormatters(data.actions.finish.message, function(key, default) local fullKey = "message_format_" .. key if data.actions.finish[fullKey] == nil then data.actions.finish[fullKey] = default @@ -561,7 +573,7 @@ function WeakAuras.regionPrototype.modifyFinish(parent, region, data) -- Sync subRegions if region.subRegions then for index, subRegion in pairs(region.subRegions) do - WeakAuras.subRegionTypes[subRegion.type].release(subRegion) + Private.subRegionTypes[subRegion.type].release(subRegion) end wipe(region.subRegions) @@ -571,12 +583,12 @@ function WeakAuras.regionPrototype.modifyFinish(parent, region, data) region.subRegions = region.subRegions or {} local subRegionTypes = {} for index, subRegionData in pairs(data.subRegions) do - if WeakAuras.subRegionTypes[subRegionData.type] then - local subRegion = WeakAuras.subRegionTypes[subRegionData.type].acquire() + if Private.subRegionTypes[subRegionData.type] then + local subRegion = Private.subRegionTypes[subRegionData.type].acquire() subRegion.type = subRegionData.type if subRegion then - WeakAuras.subRegionTypes[subRegionData.type].modify(region, subRegion, data, subRegionData, not subRegionTypes[subRegionData.type]) + Private.subRegionTypes[subRegionData.type].modify(region, subRegion, data, subRegionData, not subRegionTypes[subRegionData.type]) subRegionTypes[subRegionData.type] = true end @@ -587,7 +599,7 @@ function WeakAuras.regionPrototype.modifyFinish(parent, region, data) region:UpdateRegionHasTimerTick() - WeakAuras.ApplyFrameLevel(region) + Private.ApplyFrameLevel(region) end local function SetProgressValue(region, value, total) @@ -597,25 +609,29 @@ local function SetProgressValue(region, value, total) region:SetValue(value - adjustMin, max - adjustMin); end -function WeakAuras.TimerTick(region) - WeakAuras.StartProfileSystem("timer tick") - WeakAuras.StartProfileAura(region.id); - if region.TimerTick then - region:TimerTick(); - end - - region.subRegionEvents:Notify("TimerTick") - WeakAuras.StopProfileAura(region.id); - WeakAuras.StopProfileSystem("timer tick") -end - local regionsForFrameTick = {} local frameForFrameTick = CreateFrame("FRAME"); WeakAuras.frames["Frame Tick Frame"] = frameForFrameTick -function WeakAuras.RegisterForFrameTick(region) +local function FrameTick() + if WeakAuras.IsOptionsOpen() then + return + end + Private.StartProfileSystem("frame tick") + for region in pairs(regionsForFrameTick) do + Private.StartProfileAura(region.id); + if region.FrameTick then + region.FrameTick() + end + region.subRegionEvents:Notify("FrameTick") + Private.StopProfileAura(region.id); + end + Private.StopProfileSystem("frame tick") +end + +local function RegisterForFrameTick(region) -- Check for a Frame Tick function local hasFrameTick = region.FrameTick if not hasFrameTick then @@ -639,30 +655,14 @@ function WeakAuras.RegisterForFrameTick(region) end end -function WeakAuras.UnRegisterForFrameTick(region) +local function UnRegisterForFrameTick(region) regionsForFrameTick[region] = nil if not next(regionsForFrameTick) then frameForFrameTick:SetScript("OnUpdate", nil) end end -function WeakAuras.FrameTick() - if WeakAuras.IsOptionsOpen() then - return - end - WeakAuras.StartProfileSystem("frame tick") - for region in pairs(regionsForFrameTick) do - WeakAuras.StartProfileAura(region.id); - if region.FrameTick then - region.FrameTick() - end - region.subRegionEvents:Notify("FrameTick") - WeakAuras.StopProfileAura(region.id); - end - WeakAuras.StopProfileSystem("frame tick") -end - -local function TimerTick(self) +local function TimerTickForSetDuration(self) local duration = self.duration local adjustMin = self.adjustedMin or 0; @@ -697,7 +697,7 @@ function WeakAuras.regionPrototype.AddSetDurationInfo(region) local adjustMin = region.adjustedMin or 0; region:SetTime((duration ~= 0 and region.adjustedMax or duration) - adjustMin, expirationTime - adjustMin, inverse); - region.TimerTick = TimerTick + region.TimerTick = TimerTickForSetDuration region:UpdateRegionHasTimerTick() end end @@ -714,7 +714,7 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare local inGroup = parentRegionType == "group"; local startMainAnimation = function() - WeakAuras.Animate("display", data.uid, "main", data.animation.main, region, false, nil, true, cloneId); + Private.Animate("display", data.uid, "main", data.animation.main, region, false, nil, true, cloneId); end function region:OptionsClosed() @@ -769,8 +769,8 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare region.toShow = false; region:SetScript("OnUpdate", nil) - WeakAuras.PerformActions(data, "finish", region); - if (not WeakAuras.Animate("display", data.uid, "finish", data.animation.finish, region, false, hideRegion, nil, cloneId)) then + Private.PerformActions(data, "finish", region); + if (not Private.Animate("display", data.uid, "finish", data.animation.finish, region, false, hideRegion, nil, cloneId)) then hideRegion(); end @@ -778,7 +778,7 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare region:SoundRepeatStop(); end - WeakAuras.UnRegisterForFrameTick(region) + UnRegisterForFrameTick(region) end function region:Expand() if (region.toShow) then @@ -792,15 +792,15 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare region.subRegionEvents:Notify("PreShow") region.justCreated = nil; - WeakAuras.ApplyFrameLevel(region) + Private.ApplyFrameLevel(region) region:Show(); - WeakAuras.PerformActions(data, "start", region); - if not(WeakAuras.Animate("display", data.uid, "start", data.animation.start, region, true, startMainAnimation, nil, cloneId)) then + Private.PerformActions(data, "start", region); + if not(Private.Animate("display", data.uid, "start", data.animation.start, region, true, startMainAnimation, nil, cloneId)) then startMainAnimation(); end parent:ActivateChild(data.id, cloneId); - WeakAuras.RegisterForFrameTick(region) + RegisterForFrameTick(region) region:UpdateTimerTick() end elseif not(data.controlledChildren) then @@ -811,8 +811,8 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare region.toShow = false; region:SetScript("OnUpdate", nil) - WeakAuras.PerformActions(data, "finish", region); - if (not WeakAuras.Animate("display", data.uid, "finish", data.animation.finish, region, false, hideRegion, nil, cloneId)) then + Private.PerformActions(data, "finish", region); + if (not Private.Animate("display", data.uid, "finish", data.animation.finish, region, false, hideRegion, nil, cloneId)) then hideRegion(); end @@ -824,14 +824,14 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare region:SoundRepeatStop(); end - WeakAuras.UnRegisterForFrameTick(region) + UnRegisterForFrameTick(region) end function region:Expand() if data.anchorFrameType == "SELECTFRAME" or data.anchorFrameType == "CUSTOM" or data.anchorFrameType == "UNITFRAME" then - WeakAuras.AnchorFrame(data, region, parent); + Private.AnchorFrame(data, region, parent); end if (region.toShow) then @@ -846,10 +846,10 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare region.subRegionEvents:Notify("PreShow") - WeakAuras.ApplyFrameLevel(region) + Private.ApplyFrameLevel(region) region:Show(); - WeakAuras.PerformActions(data, "start", region); - if not(WeakAuras.Animate("display", data.uid, "start", data.animation.start, region, true, startMainAnimation, nil, cloneId)) then + Private.PerformActions(data, "start", region); + if not(Private.Animate("display", data.uid, "start", data.animation.start, region, true, startMainAnimation, nil, cloneId)) then startMainAnimation(); end @@ -857,7 +857,7 @@ function WeakAuras.regionPrototype.AddExpandFunction(data, region, cloneId, pare parent:UpdateBorder(region); end - WeakAuras.RegisterForFrameTick(region) + RegisterForFrameTick(region) region:UpdateTimerTick() end end diff --git a/WeakAuras/RegionTypes/StopMotion.lua b/WeakAuras/RegionTypes/StopMotion.lua index bc199a0..a32c6cb 100644 --- a/WeakAuras/RegionTypes/StopMotion.lua +++ b/WeakAuras/RegionTypes/StopMotion.lua @@ -274,13 +274,13 @@ local function modify(parent, region, data) local function onUpdate() if (not region.startTime) then return end - WeakAuras.StartProfileAura(region.id); - WeakAuras.StartProfileSystem("stopmotion") + Private.StartProfileAura(region.id); + Private.StartProfileSystem("stopmotion") local timeSinceStart = (GetTime() - region.startTime); local newCurrentFrame = floor(timeSinceStart * (data.frameRate or 15)); if (newCurrentFrame == region.currentFrame) then - WeakAuras.StopProfileAura(region.id); - WeakAuras.StopProfileSystem("stopmotion") + Private.StopProfileAura(region.id); + Private.StopProfileSystem("stopmotion") return; end @@ -339,8 +339,8 @@ local function modify(parent, region, data) end region.foreground:SetFrame(data.foregroundTexture, frame); - WeakAuras.StopProfileAura(region.id); - WeakAuras.StopProfileSystem("stopmotion") + Private.StopProfileAura(region.id); + Private.StopProfileSystem("stopmotion") end; region.FrameTick = onUpdate; diff --git a/WeakAuras/RegionTypes/Text.lua b/WeakAuras/RegionTypes/Text.lua index 7143a92..4cdb4cf 100644 --- a/WeakAuras/RegionTypes/Text.lua +++ b/WeakAuras/RegionTypes/Text.lua @@ -75,7 +75,7 @@ local function modify(parent, region, data) WeakAuras.regionPrototype.modify(parent, region, data); local text = region.text; - region.useAuto = WeakAuras.CanHaveAuto(data); + region.useAuto = Private.CanHaveAuto(data); local fontPath = SharedMedia:Fetch("font", data.font); text:SetFont(fontPath, data.fontSize < 33 and data.fontSize or 33, data.outline); @@ -158,7 +158,7 @@ local function modify(parent, region, data) end local UpdateText - if WeakAuras.ContainsAnyPlaceHolders(data.displayText) then + if Private.ContainsAnyPlaceHolders(data.displayText) then local getter = function(key, default) local fullKey = "displayText_format_" .. key if (data[fullKey] == nil) then @@ -166,10 +166,10 @@ local function modify(parent, region, data) end return data[fullKey] end - local formatters = WeakAuras.CreateFormatters(data.displayText, getter) + local formatters = Private.CreateFormatters(data.displayText, getter) UpdateText = function() local textStr = data.displayText; - textStr = WeakAuras.ReplacePlaceHolders(textStr, region, nil, false, formatters); + textStr = Private.ReplacePlaceHolders(textStr, region, nil, false, formatters); if (textStr == nil or textStr == "") then textStr = " "; end @@ -179,7 +179,7 @@ local function modify(parent, region, data) end local customTextFunc = nil - if(WeakAuras.ContainsCustomPlaceHolder(data.displayText) and data.customText) then + if(Private.ContainsCustomPlaceHolder(data.displayText) and data.customText) then customTextFunc = WeakAuras.LoadFunction("return "..data.customText, region.id, "custom text") end @@ -187,7 +187,7 @@ local function modify(parent, region, data) if customTextFunc then if UpdateText then Update = function() - region.values.custom = WeakAuras.RunCustomTextFunc(region, customTextFunc) + region.values.custom = Private.RunCustomTextFunc(region, customTextFunc) UpdateText() end end @@ -196,14 +196,14 @@ local function modify(parent, region, data) end local TimerTick - if WeakAuras.ContainsPlaceHolders(data.displayText, "p") then + if Private.ContainsPlaceHolders(data.displayText, "p") then TimerTick = UpdateText end local FrameTick if customTextFunc and data.customTextUpdate == "update" then FrameTick = function() - region.values.custom = WeakAuras.RunCustomTextFunc(region, customTextFunc) + region.values.custom = Private.RunCustomTextFunc(region, customTextFunc) UpdateText() end end diff --git a/WeakAuras/SubRegionTypes/Glow.lua b/WeakAuras/SubRegionTypes/Glow.lua index 11bd433..b46af7b 100644 --- a/WeakAuras/SubRegionTypes/Glow.lua +++ b/WeakAuras/SubRegionTypes/Glow.lua @@ -44,7 +44,7 @@ local properties = { display =L["Type"], setter = "SetGlowType", type = "list", - values = WeakAuras.glow_types, + values = Private.glow_types, }, useGlowColor = { display = L["Use Custom Color"], diff --git a/WeakAuras/SubRegionTypes/SubText.lua b/WeakAuras/SubRegionTypes/SubText.lua index e8cc9a0..f2be8d9 100644 --- a/WeakAuras/SubRegionTypes/SubText.lua +++ b/WeakAuras/SubRegionTypes/SubText.lua @@ -185,7 +185,7 @@ local function modify(parent, region, parentData, data, first) if first then local containsCustomText = false for index, subRegion in ipairs(parentData.subRegions) do - if subRegion.type == "subtext" and WeakAuras.ContainsCustomPlaceHolder(subRegion.text_text) then + if subRegion.type == "subtext" and Private.ContainsCustomPlaceHolder(subRegion.text_text) then containsCustomText = true break end @@ -200,7 +200,7 @@ local function modify(parent, region, parentData, data, first) end local UpdateText - if data.text_text and WeakAuras.ContainsAnyPlaceHolders(data.text_text) then + if data.text_text and Private.ContainsAnyPlaceHolders(data.text_text) then local getter = function(key, default) local fullKey = "text_text_format_" .. key if data[fullKey] == nil then @@ -208,10 +208,10 @@ local function modify(parent, region, parentData, data, first) end return data[fullKey] end - local formatters = WeakAuras.CreateFormatters(data.text_text, getter) + local formatters = Private.CreateFormatters(data.text_text, getter) UpdateText = function() local textStr = data.text_text or "" - textStr = WeakAuras.ReplacePlaceHolders(textStr, parent, nil, false, formatters) + textStr = Private.ReplacePlaceHolders(textStr, parent, nil, false, formatters) if text:GetFont() then text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr)) @@ -223,12 +223,12 @@ local function modify(parent, region, parentData, data, first) if first and parent.customTextFunc then if UpdateText then Update = function() - parent.values.custom = WeakAuras.RunCustomTextFunc(parent, parent.customTextFunc) + parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc) UpdateText() end else Update = function() - parent.values.custom = WeakAuras.RunCustomTextFunc(parent, parent.customTextFunc) + parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc) end end else @@ -236,25 +236,25 @@ local function modify(parent, region, parentData, data, first) end local TimerTick - if WeakAuras.ContainsPlaceHolders(data.text_text, "p") then + if Private.ContainsPlaceHolders(data.text_text, "p") then TimerTick = UpdateText end local FrameTick if parent.customTextFunc and parentData.customTextUpdate == "update" then if first then - if WeakAuras.ContainsCustomPlaceHolder(data.text_text) then + if Private.ContainsCustomPlaceHolder(data.text_text) then FrameTick = function() - parent.values.custom = WeakAuras.RunCustomTextFunc(parent, parent.customTextFunc) + parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc) UpdateText() end else FrameTick = function() - parent.values.custom = WeakAuras.RunCustomTextFunc(parent, parent.customTextFunc) + parent.values.custom = Private.RunCustomTextFunc(parent, parent.customTextFunc) end end else - if WeakAuras.ContainsCustomPlaceHolder(data.text_text) then + if Private.ContainsCustomPlaceHolder(data.text_text) then FrameTick = UpdateText end end @@ -319,7 +319,7 @@ local function modify(parent, region, parentData, data, first) selfPoint = anchorPoint:sub(7) elseif anchorPoint:sub(1, 6) == "OUTER_" then anchorPoint = anchorPoint:sub(7) - selfPoint = WeakAuras.inverse_point_types[anchorPoint] or "CENTER" + selfPoint = Private.inverse_point_types[anchorPoint] or "CENTER" else selfPoint = "CENTER" end @@ -330,9 +330,9 @@ local function modify(parent, region, parentData, data, first) elseif selfPoint:sub(1, 6) == "INNER_" then selfPoint = selfPoint:sub(7) end - selfPoint = WeakAuras.point_types[selfPoint] and selfPoint or "CENTER" + selfPoint = Private.point_types[selfPoint] and selfPoint or "CENTER" else - selfPoint = WeakAuras.inverse_point_types[data.text_anchorPoint or "CENTER"] or "CENTER" + selfPoint = Private.inverse_point_types[data.text_anchorPoint or "CENTER"] or "CENTER" end end diff --git a/WeakAuras/SubRegionTypes/Tick.lua b/WeakAuras/SubRegionTypes/Tick.lua index b8509cb..f83c7af 100644 --- a/WeakAuras/SubRegionTypes/Tick.lua +++ b/WeakAuras/SubRegionTypes/Tick.lua @@ -40,7 +40,7 @@ local properties = { display = L["Placement Mode"], setter = "SetTickPlacementMode", type = "list", - values = WeakAuras.tick_placement_modes, + values = Private.tick_placement_modes, }, tick_placement = { display = L["Placement"], diff --git a/WeakAuras/Transmission.lua b/WeakAuras/Transmission.lua index cee96a3..063bc9b 100644 --- a/WeakAuras/Transmission.lua +++ b/WeakAuras/Transmission.lua @@ -39,8 +39,6 @@ local versionString = WeakAuras.versionString; local regionOptions = WeakAuras.regionOptions; local regionTypes = WeakAuras.regionTypes; -local event_types = WeakAuras.event_types; -local status_types = WeakAuras.status_types; -- Local functions local decodeB64, GenerateUniqueID @@ -140,9 +138,8 @@ function CompressDisplay(data) end end - local copiedData = {} - WeakAuras.DeepCopy(data, copiedData) - stripNonTransmissableFields(copiedData, WeakAuras.non_transmissable_fields) + local copiedData = CopyTable(data) + stripNonTransmissableFields(copiedData, Private.non_transmissable_fields) copiedData.tocversion = WeakAuras.BuildInfo return copiedData; end @@ -224,11 +221,11 @@ showCodeButton:SetSize(90, 22) local checkButtons, radioButtons, keyToButton, pendingData = {}, {}, {}, {} -for _, key in pairs(WeakAuras.internal_fields) do +for _, key in pairs(Private.internal_fields) do keyToButton[key] = false end -for index,category in pairs(WeakAuras.update_categories) do +for index,category in pairs(Private.update_categories) do local button = CreateFrame("checkButton", "WeakAurasTooltipCheckButton"..index, buttonAnchor, "ChatConfigCheckButtonTemplate") for k, v in pairs(category) do button[k] = v @@ -275,7 +272,7 @@ for index, button in ipairs(radioButtons) do button:SetChecked(button == self) end pendingData.mode = index - WeakAuras.RefreshTooltipButtons() + Private.RefreshTooltipButtons() end) end @@ -285,6 +282,36 @@ end -- Such that all of the display tab settings are in their own subtable setmetatable(keyToButton,{__index = function(_, key) return key and checkButtons.display end,}) +local deleted = {} -- magic value +local function recurseUpdate(data, chunk) + for k,v in pairs(chunk) do + if v == deleted then + data[k] = nil + elseif type(v) == 'table' and type(data[k]) == 'table' then + recurseUpdate(data[k], v) + else + data[k] = v + end + end +end + +local function Update(data, diff) + -- modifies the installed data such that it matches the pending import, sans user-specified options + -- diff is expected to be output generated by diff + if not diff then + WeakAuras.Add(data) + return + end + if data then + WeakAuras.DeleteOption(data) + else + return + end + recurseUpdate(data, diff) + WeakAuras.Add(data) + return data +end + local function install(data, oldData, patch, mode, isParent) -- munch the provided data and add, update, or delete as appropriate -- return the data which the SV knows about afterwards (if there is any) @@ -343,13 +370,13 @@ local function install(data, oldData, patch, mode, isParent) if data.uid and data.uid ~= oldData.uid then oldData.uid = data.uid end - WeakAuras.Update(oldData, patch) + Update(oldData, patch) oldData.preferToUpdate = true installedUID = oldData.uid imported = data end -- if at this point, then some change has been made in the db. Update History to reflect the change - WeakAuras.SetHistory(installedUID, imported, "import") + Private.SetHistory(installedUID, imported, "import") return Private.GetDataByUID(installedUID) end @@ -561,7 +588,7 @@ ItemRefTooltip:HookScript("OnHide", function(self) end) importButton:SetScript("OnClick", function() - WeakAuras.dynFrame:AddAction("import", coroutine.create(importPendingData)) + Private.dynFrame:AddAction("import", coroutine.create(importPendingData)) end) showCodeButton:SetScript("OnClick", function() @@ -725,9 +752,6 @@ function WeakAuras.DisplayToString(id, forChat) v = 1421, -- Version of Transmisson, won't change anymore. s = versionString }; - if(WeakAuras.transmitCache and WeakAuras.transmitCache[id]) then - transmit.i = WeakAuras.transmitCache[id]; - end local firstTrigger = data.triggers[1].trigger if(firstTrigger.type == "aura" and WeakAurasOptionsSaved and WeakAurasOptionsSaved.spellCache) then transmit.a = {}; @@ -792,21 +816,21 @@ local function recurseStringify(data, level, lines) end end -function WeakAuras.DataToString(id) +function Private.DataToString(id) local data = WeakAuras.GetData(id) if data then - return WeakAuras.SerializeTable(data):gsub("|", "||") + return Private.SerializeTable(data):gsub("|", "||") end end -function WeakAuras.SerializeTable(data) +function Private.SerializeTable(data) local lines = {"{"} recurseStringify(data, 1, lines) tinsert(lines, "}") return table.concat(lines, "\n") end -function WeakAuras.RefreshTooltipButtons() +function Private.RefreshTooltipButtons() importButton:Disable() importButton.tooltipText = nil showCodeButton:Enable() @@ -857,7 +881,7 @@ function WeakAuras.RefreshTooltipButtons() local importWidth = WeakAurasTooltipImportButtonText:GetStringWidth() importButton:SetWidth(importWidth + 30) end -buttonAnchor:SetScript("OnEvent", WeakAuras.RefreshTooltipButtons) +buttonAnchor:SetScript("OnEvent", Private.RefreshTooltipButtons) local function SetCheckButtonStates(radioButtonAnchor, activeCategories) if activeCategories then @@ -913,7 +937,7 @@ function ShowTooltip(lines, linesFromTop, activeCategories) if pendingData.newData then local checkButtonAnchor = _G["ItemRefTooltipTextLeft" .. (linesFromTop or 1)] SetCheckButtonStates(checkButtonAnchor, activeCategories) - WeakAuras.RefreshTooltipButtons() + Private.RefreshTooltipButtons() buttonAnchor:Show() else buttonAnchor:Hide() @@ -1113,8 +1137,8 @@ local function scamCheck(codes, data) end end -local internalFields = WeakAuras.internal_fields -local nonTransmissableFields = WeakAuras.non_transmissable_fields +local internalFields = Private.internal_fields +local nonTransmissableFields = Private.non_transmissable_fields local deleted = {} -- magic value local function recurseDiff(ours, theirs) local diff, seen, same = {}, {}, true @@ -1163,7 +1187,7 @@ local function recurseSerial(lines, depth, chunk) end end -function WeakAuras.diff(ours, theirs) +local function diff(ours, theirs) -- generates a diff which WeakAuras.Update can use local debug = false if not ours or not theirs then return end @@ -1229,7 +1253,7 @@ local function findMatch(data, children) return oldParent end -function WeakAuras.MatchInfo(data, children, target) +local function MatchInfo(data, children, target) -- match the parent/single aura (if no children) local oldParent = target or findMatch(data, children) if not oldParent then return nil end @@ -1255,7 +1279,7 @@ function WeakAuras.MatchInfo(data, children, target) info.mode = 2 end info.newData[0] = data - info.diffs[0] = WeakAuras.diff(oldParent, data) + info.diffs[0] = diff(oldParent, data) if info.diffs[0] then info.modified = info.modified + 1 end @@ -1358,7 +1382,7 @@ function WeakAuras.MatchInfo(data, children, target) else lastMatch = oldIndex end - local childDiff = WeakAuras.diff(oldChild, newChild, true) + local childDiff = diff(oldChild, newChild, true) if childDiff then info.modified = info.modified + 1 info.diffs[newIndex] = childDiff @@ -1393,37 +1417,7 @@ function WeakAuras.MatchInfo(data, children, target) return modified and info or false end -local function recurseUpdate(data, chunk) - for k,v in pairs(chunk) do - if v == deleted then - data[k] = nil - elseif type(v) == 'table' and type(data[k]) == 'table' then - recurseUpdate(data[k], v) - else - data[k] = v - end - end -end - -function WeakAuras.Update(data, diff) - -- modifies the installed data such that it matches the pending import, sans user-specified options - -- diff is expected to be output generated by WeakAuras.diff - if not diff then - WeakAuras.Add(data) - return - end - if data then - WeakAuras.DeleteOption(data) - else - return - end - recurseUpdate(data, diff) - WeakAuras.Add(data) - return data -end - - -function WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, import, compressed) +local function ShowDisplayTooltip(data, children, matchInfo, icon, icons, import, compressed) -- since we have new data, wipe the old pending data wipe(pendingData) @@ -1561,12 +1555,12 @@ function WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, im tinsert(tooltip, {2, L["Trigger:"], L["Aura"], 1, 1, 1, 1, 1, 1}); elseif(trigger.type == "event" or trigger.type == "status") then if(trigger.type == "event") then - tinsert(tooltip, {2, L["Trigger:"], (event_types[trigger.event] or L["Undefined"]), 1, 1, 1, 1, 1, 1}); + tinsert(tooltip, {2, L["Trigger:"], (Private.event_types[trigger.event] or L["Undefined"]), 1, 1, 1, 1, 1, 1}); else - tinsert(tooltip, {2, L["Trigger:"], (status_types[trigger.event] or L["Undefined"]), 1, 1, 1, 1, 1, 1}); + tinsert(tooltip, {2, L["Trigger:"], (Private.status_types[trigger.event] or L["Undefined"]), 1, 1, 1, 1, 1, 1}); end if(trigger.event == "Combat Log" and trigger.subeventPrefix and trigger.subeventSuffix) then - tinsert(tooltip, {2, L["Message type:"], (WeakAuras.subevent_prefix_types[trigger.subeventPrefix] or L["Undefined"]).." "..(WeakAuras.subevent_suffix_types[trigger.subeventSuffix] or L["Undefined"]), 1, 1, 1, 1, 1, 1}); + tinsert(tooltip, {2, L["Message type:"], (Private.subevent_prefix_types[trigger.subeventPrefix] or L["Undefined"]).." "..(Private.subevent_suffix_types[trigger.subeventSuffix] or L["Undefined"]), 1, 1, 1, 1, 1, 1}); end else tinsert(tooltip, {2, L["Trigger:"], L["Custom"], 1, 1, 1, 1, 1, 1}); @@ -1584,6 +1578,7 @@ function WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, im if excessChildren <= 0 then tinsert(tooltip, {2, " ", child.id, 1, 1, 1, 1, 1, 1}) end + tocversion = tocversion or child.tocversion end if excessChildren > 0 then tinsert(tooltip, {2, " ", "[...]", 1, 1, 1, 1, 1, 1}) @@ -1632,8 +1627,6 @@ function WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, im local i; if(icon) then i = icon; - elseif(WeakAuras.transmitCache and WeakAuras.transmitCache[data.id]) then - i = WeakAuras.transmitCache[data.id]; end if (i) then thumbnail:SetIcon(i); @@ -1700,8 +1693,8 @@ function WeakAuras.Import(inData, target) end end tooltipLoading = nil; - local matchInfo = WeakAuras.MatchInfo(data, children, target) - WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, "unknown") + local matchInfo = MatchInfo(data, children, target) + ShowDisplayTooltip(data, children, matchInfo, icon, icons, "unknown") return status, msg end @@ -1808,8 +1801,8 @@ Comm:RegisterComm("WeakAuras", function(prefix, message, distribution, sender) WeakAuras.PreAdd(child) end end - local matchInfo = WeakAuras.MatchInfo(data, children) - WeakAuras.ShowDisplayTooltip(data, children, matchInfo, icon, icons, sender, true) + local matchInfo = MatchInfo(data, children) + ShowDisplayTooltip(data, children, matchInfo, icon, icons, sender, true) elseif(received.m == "dR") then --if(WeakAuras.linked[received.d]) then TransmitDisplay(received.d, sender); diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index 3080b2e..cc6856f 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -9,22 +9,31 @@ local LSM = LibStub("LibSharedMedia-3.0"); local wipe, tinsert = wipe, tinsert local GetNumShapeshiftForms, GetShapeshiftFormInfo = GetNumShapeshiftForms, GetShapeshiftFormInfo -WeakAuras.glow_action_types = { +local function WA_GetClassColor(classFilename) + local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[classFilename] + if color and color.colorStr then + return color.colorStr + end + + return "ffffffff" +end + +Private.glow_action_types = { show = L["Show"], hide = L["Hide"] } -WeakAuras.glow_frame_types = { +Private.glow_frame_types = { UNITFRAME = L["Unit Frame"], FRAMESELECTOR = L["Frame Selector"] } -WeakAuras.circular_group_constant_factor_types = { +Private.circular_group_constant_factor_types = { RADIUS = L["Radius"], SPACING = L["Spacing"] } -WeakAuras.frame_strata_types = { +Private.frame_strata_types = { [1] = L["Inherited"], [2] = "BACKGROUND", [3] = "LOW", @@ -36,17 +45,17 @@ WeakAuras.frame_strata_types = { [9] = "TOOLTIP" } -WeakAuras.hostility_types = { +Private.hostility_types = { hostile = L["Hostile"], friendly = L["Friendly"] } -WeakAuras.character_types = { +Private.character_types = { player = L["Player Character"], npc = L["Non-player Character"] } -WeakAuras.group_sort_types = { +Private.group_sort_types = { ascending = L["Ascending"], descending = L["Descending"], hybrid = L["Hybrid"], @@ -54,40 +63,40 @@ WeakAuras.group_sort_types = { custom = L["Custom"] } -WeakAuras.group_hybrid_position_types = { +Private.group_hybrid_position_types = { hybridFirst = L["Marked First"], hybridLast = L["Marked Last"] } -WeakAuras.group_hybrid_sort_types = { +Private.group_hybrid_sort_types = { ascending = L["Ascending"], descending = L["Descending"] } -WeakAuras.precision_types = { +Private.precision_types = { [0] = "12", [1] = "12.3", [2] = "12.34", [3] = "12.345", } -WeakAuras.big_number_types = { +Private.big_number_types = { ["AbbreviateNumbers"] = L["AbbreviateNumbers (Blizzard)"], ["AbbreviateLargeNumbers"] = L["AbbreviateLargeNumbers (Blizzard)"] } -WeakAuras.round_types = { +Private.round_types = { floor = L["Floor"], ceil = L["Ceil"], round = L["Round"] } -WeakAuras.unit_color_types = { +Private.unit_color_types = { none = L["None"], class = L["Class"] } -WeakAuras.unit_realm_name_types = { +Private.unit_realm_name_types = { never = L["Never"], star = L["* Suffix"], differentServer = L["Only if on a different realm"], @@ -114,7 +123,7 @@ local simpleFormatters = { end } -WeakAuras.format_types = { +Private.format_types = { none = { display = L["None"], AddOptions = function() end, @@ -160,7 +169,7 @@ WeakAuras.format_types = { type = "select", name = L["Precision"], width = WeakAuras.normalWidth, - values = WeakAuras.precision_types, + values = Private.precision_types, hidden = hidden }) addOption(symbol .. "_time_dynamic", { @@ -183,7 +192,7 @@ WeakAuras.format_types = { end return function(value, state) - return WeakAuras.dynamic_texts.p.func(value, state, precision) + return Private.dynamic_texts.p.func(value, state, precision) end end }, @@ -195,7 +204,7 @@ WeakAuras.format_types = { type = "select", name = L["Format"], width = WeakAuras.normalWidth, - values = WeakAuras.big_number_types, + values = Private.big_number_types, hidden = hidden }) end, @@ -221,14 +230,14 @@ WeakAuras.format_types = { type = "select", name = L["Precision"], width = WeakAuras.normalWidth, - values = WeakAuras.precision_types, + values = Private.precision_types, hidden = hidden }) addOption(symbol .. "_round_type", { type = "select", name = L["Round Mode"], width = WeakAuras.normalWidth, - values = WeakAuras.round_types, + values = Private.round_types, hidden = hidden, disabled = function() return get(symbol .. "_decimal_precision") ~= 0 @@ -255,14 +264,14 @@ WeakAuras.format_types = { type = "select", name = L["Color"], width = WeakAuras.normalWidth, - values = WeakAuras.unit_color_types, + values = Private.unit_color_types, hidden = hidden, }) addOption(symbol .. "_realm_name", { type = "select", name = L["Realm Name"], width = WeakAuras.normalWidth, - values = WeakAuras.unit_realm_name_types, + values = Private.unit_realm_name_types, hidden = hidden, }) addOption(symbol .. "_abbreviate", { @@ -383,14 +392,14 @@ WeakAuras.format_types = { type = "select", name = L["Color"], width = WeakAuras.normalWidth, - values = WeakAuras.unit_color_types, + values = Private.unit_color_types, hidden = hidden, }) addOption(symbol .. "_realm_name", { type = "select", name = L["Realm Name"], width = WeakAuras.normalWidth, - values = WeakAuras.unit_realm_name_types, + values = Private.unit_realm_name_types, hidden = hidden, }) addOption(symbol .. "_abbreviate", { @@ -534,14 +543,14 @@ WeakAuras.format_types = { type = "select", name = L["Precision"], width = WeakAuras.normalWidth, - values = WeakAuras.precision_types, + values = Private.precision_types, hidden = hidden }) addOption(symbol .. "_round_type", { type = "select", name = L["Round Mode"], width = WeakAuras.normalWidth, - values = WeakAuras.round_types, + values = Private.round_types, hidden = hidden, disabled = function() return get(symbol .. "_decimal_precision") ~= 0 @@ -606,11 +615,11 @@ WeakAuras.format_types = { } } -WeakAuras.format_types_display = {} -for k, v in pairs(WeakAuras.format_types) do WeakAuras.format_types_display[k] = v.display end +Private.format_types_display = {} +for k, v in pairs(Private.format_types) do Private.format_types_display[k] = v.display end -WeakAuras.sound_channel_types = { +Private.sound_channel_types = { Master = L["Master"], SFX = ENABLE_SOUNDFX, Ambience = ENABLE_AMBIENCE, @@ -618,44 +627,44 @@ WeakAuras.sound_channel_types = { Dialog = ENABLE_DIALOG } -WeakAuras.sound_condition_types = { +Private.sound_condition_types = { Play = L["Play"], Loop = L["Loop"], Stop = L["Stop"] } -WeakAuras.trigger_require_types = { +Private.trigger_require_types = { any = L["Any Triggers"], all = L["All Triggers"], custom = L["Custom Function"] } -WeakAuras.trigger_require_types_one = { +Private.trigger_require_types_one = { any = L["Trigger 1"], custom = L["Custom Function"] } -WeakAuras.trigger_modes = { +Private.trigger_modes = { ["first_active"] = -10, } -WeakAuras.debuff_types = { +Private.debuff_types = { HELPFUL = L["Buff"], HARMFUL = L["Debuff"] } -WeakAuras.tooltip_count = { +Private.tooltip_count = { [1] = L["First"], [2] = L["Second"], [3] = L["Third"] } -WeakAuras.aura_types = { +Private.aura_types = { BUFF = L["Buff"], DEBUFF = L["Debuff"] } -WeakAuras.debuff_class_types = { +Private.debuff_class_types = { magic = L["Magic"], curse = L["Curse"], disease = L["Disease"], @@ -664,7 +673,7 @@ WeakAuras.debuff_class_types = { none = L["None"] } -WeakAuras.unit_types = { +Private.unit_types = { player = L["Player"], target = L["Target"], focus = L["Focus"], @@ -674,7 +683,7 @@ WeakAuras.unit_types = { multi = L["Multi-target"] } -WeakAuras.unit_types_bufftrigger_2 = { +Private.unit_types_bufftrigger_2 = { player = L["Player"], target = L["Target"], focus = L["Focus"], @@ -688,7 +697,7 @@ WeakAuras.unit_types_bufftrigger_2 = { multi = L["Multi-target"] } -WeakAuras.actual_unit_types_with_specific = { +Private.actual_unit_types_with_specific = { player = L["Player"], target = L["Target"], focus = L["Focus"], @@ -696,7 +705,7 @@ WeakAuras.actual_unit_types_with_specific = { member = L["Specific Unit"] } -WeakAuras.actual_unit_types_cast = { +Private.actual_unit_types_cast = { player = L["Player"], target = L["Target"], focus = L["Focus"], @@ -709,28 +718,28 @@ WeakAuras.actual_unit_types_cast = { member = L["Specific Unit"], } -WeakAuras.actual_unit_types = { +Private.actual_unit_types = { -- TODO player = L["Player"], target = L["Target"], focus = L["Focus"], pet = L["Pet"] } -WeakAuras.threat_unit_types = { +Private.threat_unit_types = { target = L["Target"], focus = L["Focus"], member = L["Specific Unit"], none = L["At Least One Enemy"] } -WeakAuras.unit_types_range_check = { +Private.unit_types_range_check = { target = L["Target"], focus = L["Focus"], pet = L["Pet"], member = L["Specific Unit"] } -WeakAuras.unit_threat_situation_types = { +Private.unit_threat_situation_types = { [-1] = L["Not On Threat Table"], [0] = "|cFFB0B0B0"..L["Lower Than Tank"], [1] = "|cFFFFFF77"..L["Higher Than Tank"], @@ -739,29 +748,24 @@ WeakAuras.unit_threat_situation_types = { } WeakAuras.class_types = {} -WeakAuras.class_color_types = {} -local C_S_O, R_C_C, L_C_N_M, F_C_C_C = _G.CLASS_SORT_ORDER, RAID_CLASS_COLORS--[[_G.RAID_CLASS_COLORS]], _G.LOCALIZED_CLASS_NAMES_MALE, _G.FONT_COLOR_CODE_CLOSE -do - for i,eClass in ipairs(C_S_O) do - WeakAuras.class_color_types[eClass] = "|c"..R_C_C[eClass].colorStr - WeakAuras.class_types[eClass] = WeakAuras.class_color_types[eClass]..L_C_N_M[eClass]..F_C_C_C - end +for i, class in ipairs(CLASS_SORT_ORDER) do + WeakAuras.class_types[class] = string.format("|c%s%s|r", WA_GetClassColor(class), LOCALIZED_CLASS_NAMES_MALE[class]) end -WeakAuras.faction_group = { +Private.faction_group = { Alliance = L["Alliance"], Horde = L["Horde"], Neutral = L["Neutral"] } -WeakAuras.form_types = {}; +Private.form_types = {}; local function update_forms() - wipe(WeakAuras.form_types); - WeakAuras.form_types[0] = "0 - "..L["Humanoid"] + wipe(Private.form_types); + Private.form_types[0] = "0 - "..L["Humanoid"] for i = 1, GetNumShapeshiftForms() do local _, name = GetShapeshiftFormInfo(i); if(name) then - WeakAuras.form_types[i] = i.." - "..name + Private.form_types[i] = i.." - "..name end end end @@ -770,27 +774,27 @@ form_frame:RegisterEvent("UPDATE_SHAPESHIFT_FORMS") form_frame:RegisterEvent("PLAYER_LOGIN") form_frame:SetScript("OnEvent", update_forms); -WeakAuras.blend_types = { +Private.blend_types = { ADD = L["Glow"], BLEND = L["Opaque"] } -WeakAuras.slant_mode = { +Private.slant_mode = { INSIDE = L["Keep Inside"], EXTEND = L["Extend Outside"] } -WeakAuras.text_check_types = { +Private.text_check_types = { update = L["Every Frame"], event = L["Trigger Update"] } -WeakAuras.check_types = { +Private.check_types = { update = L["Every Frame"], event = L["Event(s)"] } -WeakAuras.point_types = { +Private.point_types = { BOTTOMLEFT = L["Bottom Left"], BOTTOM = L["Bottom"], BOTTOMRIGHT = L["Bottom Right"], @@ -802,27 +806,27 @@ WeakAuras.point_types = { CENTER = L["Center"] } -WeakAuras.default_types_for_anchor = {} -for k, v in pairs(WeakAuras.point_types) do - WeakAuras.default_types_for_anchor[k] = { +Private.default_types_for_anchor = {} +for k, v in pairs(Private.point_types) do + Private.default_types_for_anchor[k] = { display = v, type = "point" } end -WeakAuras.default_types_for_anchor["ALL"] = { +Private.default_types_for_anchor["ALL"] = { display = L["Whole Area"], type = "area" } -WeakAuras.aurabar_anchor_areas = { +Private.aurabar_anchor_areas = { icon = L["Icon"], fg = L["Foreground"], bg = L["Background"], bar = L["Bar"], } -WeakAuras.inverse_point_types = { +Private.inverse_point_types = { BOTTOMLEFT = "TOPRIGHT", BOTTOM = "TOP", BOTTOMRIGHT = "TOPLEFT", @@ -834,7 +838,7 @@ WeakAuras.inverse_point_types = { CENTER = "CENTER" } -WeakAuras.anchor_frame_types = { +Private.anchor_frame_types = { SCREEN = L["Screen/Parent Group"], MOUSE = L["Mouse Cursor"], SELECTFRAME = L["Select Frame"], @@ -842,38 +846,38 @@ WeakAuras.anchor_frame_types = { CUSTOM = L["Custom"] } -WeakAuras.anchor_frame_types_group = { +Private.anchor_frame_types_group = { SCREEN = L["Screen/Parent Group"], MOUSE = L["Mouse Cursor"], SELECTFRAME = L["Select Frame"], CUSTOM = L["Custom"] } -WeakAuras.spark_rotation_types = { +Private.spark_rotation_types = { AUTO = L["Automatic Rotation"], MANUAL = L["Manual Rotation"] } -WeakAuras.spark_hide_types = { +Private.spark_hide_types = { NEVER = L["Never"], FULL = L["Full"], EMPTY = L["Empty"], BOTH = L["Full/Empty"] } -WeakAuras.tick_placement_modes = { +Private.tick_placement_modes = { AtValue = L["At Value"], AtMissingValue = L["At missing Value"], AtPercent = L["At Percent"], ValueOffset = L["Offset from progress"] } -WeakAuras.containment_types = { +Private.containment_types = { -- TODO OUTSIDE = L["Outside"], INSIDE = L["Inside"] } -WeakAuras.font_flags = { +Private.font_flags = { None = L["None"], MONOCHROME = L["Monochrome"], OUTLINE = L["Outline"], @@ -882,31 +886,31 @@ WeakAuras.font_flags = { ["MONOCHROME|THICKOUTLINE"] = L["Monochrome Thick Outline"] } -WeakAuras.text_automatic_width = { +Private.text_automatic_width = { Auto = L["Automatic"], Fixed = L["Fixed"] } -WeakAuras.text_word_wrap = { +Private.text_word_wrap = { WordWrap = L["Wrap"], Elide = L["Elide"] } -WeakAuras.event_types = {}; -for name, prototype in pairs(WeakAuras.event_prototypes) do +Private.event_types = {}; +for name, prototype in pairs(Private.event_prototypes) do if(prototype.type == "event") then - WeakAuras.event_types[name] = prototype.name; + Private.event_types[name] = prototype.name; end end -WeakAuras.status_types = {}; -for name, prototype in pairs(WeakAuras.event_prototypes) do +Private.status_types = {}; +for name, prototype in pairs(Private.event_prototypes) do if(prototype.type == "status") then - WeakAuras.status_types[name] = prototype.name; + Private.status_types[name] = prototype.name; end end -WeakAuras.subevent_prefix_types = { +Private.subevent_prefix_types = { SWING = L["Swing"], RANGE = L["Range"], SPELL = L["Spell"], @@ -924,7 +928,7 @@ WeakAuras.subevent_prefix_types = { ENCHANT_REMOVED = L["Enchant Removed"] } -WeakAuras.subevent_actual_prefix_types = { +Private.subevent_actual_prefix_types = { SWING = L["Swing"], RANGE = L["Range"], SPELL = L["Spell"], @@ -933,7 +937,7 @@ WeakAuras.subevent_actual_prefix_types = { ENVIRONMENTAL = L["Environmental"] } -WeakAuras.subevent_suffix_types = { +Private.subevent_suffix_types = { _DAMAGE = L["Damage"], _MISSED = L["Missed"], _HEAL = L["Heal"], @@ -963,7 +967,7 @@ WeakAuras.subevent_suffix_types = { _RESURRECT = L["Resurrect"] } -WeakAuras.power_types = { +Private.power_types = { [0] = MANA, [1] = RAGE, [2] = FOCUS, @@ -972,7 +976,7 @@ WeakAuras.power_types = { [6] = RUNIC_POWER, } -WeakAuras.miss_types = { +Private.miss_types = { ABSORB = L["Absorb"], BLOCK = L["Block"], DEFLECT = L["Deflect"], @@ -985,7 +989,7 @@ WeakAuras.miss_types = { RESIST = L["Resist"] } -WeakAuras.environmental_types = { +Private.environmental_types = { Drowning = STRING_ENVIRONMENTAL_DAMAGE_DROWNING, Falling = STRING_ENVIRONMENTAL_DAMAGE_FALLING, Fatigue = STRING_ENVIRONMENTAL_DAMAGE_FATIGUE, @@ -994,18 +998,18 @@ WeakAuras.environmental_types = { Slime = STRING_ENVIRONMENTAL_DAMAGE_SLIME } -WeakAuras.combatlog_flags_check_type = { +Private.combatlog_flags_check_type = { InGroup = L["In Group"], NotInGroup = L["Not in Group"] } -WeakAuras.combatlog_flags_check_reaction = { +Private.combatlog_flags_check_reaction = { Hostile = L["Hostile"], Neutral = L["Neutral"], Friendly = L["Friendly"] } -WeakAuras.combatlog_flags_check_object_type = { +Private.combatlog_flags_check_object_type = { Object = L["Object"], Guardian = L["Guardian"], Pet = L["Pet"], @@ -1013,7 +1017,7 @@ WeakAuras.combatlog_flags_check_object_type = { Player = L["Player"] } -WeakAuras.combatlog_raid_mark_check_type = { +Private.combatlog_raid_mark_check_type = { [0] = RAID_TARGET_NONE, "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcon_1:14|t " .. RAID_TARGET_1, -- Star "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcon_2:14|t " .. RAID_TARGET_2, -- Circle @@ -1026,14 +1030,14 @@ WeakAuras.combatlog_raid_mark_check_type = { L["Any"] } -WeakAuras.orientation_types = { +Private.orientation_types = { HORIZONTAL_INVERSE = L["Left to Right"], HORIZONTAL = L["Right to Left"], VERTICAL = L["Bottom to Top"], VERTICAL_INVERSE = L["Top to Bottom"] } -WeakAuras.orientation_with_circle_types = { +Private.orientation_with_circle_types = { HORIZONTAL_INVERSE = L["Left to Right"], HORIZONTAL = L["Right to Left"], VERTICAL = L["Bottom to Top"], @@ -1042,22 +1046,22 @@ WeakAuras.orientation_with_circle_types = { ANTICLOCKWISE = L["Anticlockwise"] } -WeakAuras.talent_types = {} +Private.talent_types = {} for tab = 1, 5 do for num_talent = 1, MAX_NUM_TALENTS do local talentId = (tab - 1)*MAX_NUM_TALENTS+num_talent - WeakAuras.talent_types[talentId] = L["Tab "]..tab.." - "..num_talent + Private.talent_types[talentId] = L["Tab "]..tab.." - "..num_talent end end -WeakAuras.totem_types = { +Private.totem_types = { [1] = L["Fire"], [2] = L["Earth"], [3] = L["Water"], [4] = L["Air"] } -WeakAuras.texture_types = { +Private.texture_types = { ["Blizzard Alerts"] = { ["Interface\\AddOns\\WeakAuras\\Media\\SpellActivationOverlays\\arcane_missiles"] = "Arcane Missiles", ["Interface\\AddOns\\WeakAuras\\Media\\SpellActivationOverlays\\arcane_missiles_1"] = "Arcane Missiles 1", @@ -1404,7 +1408,7 @@ WeakAuras.texture_types = { } local PowerAurasPath = "Interface\\Addons\\WeakAuras\\PowerAurasMedia\\Auras\\" -WeakAuras.texture_types["PowerAuras Heads-Up"] = { +Private.texture_types["PowerAuras Heads-Up"] = { [PowerAurasPath.."Aura1"] = "Runed Text", [PowerAurasPath.."Aura2"] = "Runed Text On Ring", [PowerAurasPath.."Aura3"] = "Power Waves", @@ -1421,7 +1425,7 @@ WeakAuras.texture_types["PowerAuras Heads-Up"] = { [PowerAurasPath.."Aura28"] = "Flourished Text", [PowerAurasPath.."Aura33"] = "Droplet Highlights" } -WeakAuras.texture_types["PowerAuras Icons"] = { +Private.texture_types["PowerAuras Icons"] = { [PowerAurasPath.."Aura8"] = "Rune", [PowerAurasPath.."Aura9"] = "Stylized Ghost", [PowerAurasPath.."Aura10"] = "Skull and Crossbones", @@ -1497,7 +1501,7 @@ WeakAuras.texture_types["PowerAuras Icons"] = { [PowerAurasPath.."Aura142"] = "Ornate Ring", [PowerAurasPath.."Aura143"] = "Ghostly Skull" } -WeakAuras.texture_types["PowerAuras Separated"] = { +Private.texture_types["PowerAuras Separated"] = { [PowerAurasPath.."Aura46"] = "8-Part Ring 1", [PowerAurasPath.."Aura47"] = "8-Part Ring 2", [PowerAurasPath.."Aura55"] = "Skull on Gear 1", @@ -1546,7 +1550,8 @@ WeakAuras.texture_types["PowerAuras Separated"] = { [PowerAurasPath.."Aura144"] = "Taijitu Bottom", [PowerAurasPath.."Aura145"] = "Taijitu Top" } -WeakAuras.texture_types["PowerAuras Words"] = { + +Private.texture_types["PowerAuras Words"] = { [PowerAurasPath.."Aura20"] = "Power", [PowerAurasPath.."Aura37"] = "Slow", [PowerAurasPath.."Aura38"] = "Stun", @@ -1560,7 +1565,7 @@ WeakAuras.texture_types["PowerAuras Words"] = { ["Interface\\AddOns\\WeakAuras\\Media\\Textures\\interrupt"] = "Interrupt" } -WeakAuras.operator_types = { +Private.operator_types = { ["=="] = "=", ["~="] = "!=", [">"] = ">", @@ -1569,69 +1574,69 @@ WeakAuras.operator_types = { ["<="] = "<=" } -WeakAuras.equality_operator_types = { +Private.equality_operator_types = { ["=="] = "=", ["~="] = "!=" } -WeakAuras.operator_types_without_equal = { +Private.operator_types_without_equal = { [">="] = ">=", ["<="] = "<=" } -WeakAuras.string_operator_types = { +Private.string_operator_types = { ["=="] = L["Is Exactly"], ["find('%s')"] = L["Contains"], ["match('%s')"] = L["Matches (Pattern)"] } -WeakAuras.weapon_types = { +Private.weapon_types = { ["main"] = MAINHANDSLOT, ["off"] = SECONDARYHANDSLOT } -WeakAuras.swing_types = { +Private.swing_types = { ["main"] = MAINHANDSLOT, ["off"] = SECONDARYHANDSLOT, ["ranged"] = RANGEDSLOT } -WeakAuras.rune_specific_types = { +Private.rune_specific_types = { [1] = L["Blood Rune #1"], [2] = L["Blood Rune #2"], [3] = L["Unholy Rune #1"], [4] = L["Unholy Rune #2"], [5] = L["Frost Rune #1"], [6] = L["Frost Rune #2"] -}; +} -WeakAuras.custom_trigger_types = { +Private.custom_trigger_types = { ["event"] = L["Event"], ["status"] = L["Status"], ["stateupdate"] = L["Trigger State Updater (Advanced)"] } -WeakAuras.eventend_types = { +Private.eventend_types = { ["timed"] = L["Timed"], ["custom"] = L["Custom"] } -WeakAuras.autoeventend_types = { +Private.autoeventend_types = { ["auto"] = L["Automatic"], ["custom"] = L["Custom"] } -WeakAuras.timedeventend_types = { +Private.timedeventend_types = { ["timed"] = L["Timed"], } -WeakAuras.justify_types = { +Private.justify_types = { ["LEFT"] = L["Left"], ["CENTER"] = L["Center"], ["RIGHT"] = L["Right"] } -WeakAuras.grow_types = { +Private.grow_types = { ["LEFT"] = L["Left"], ["RIGHT"] = L["Right"], ["UP"] = L["Up"], @@ -1646,7 +1651,7 @@ WeakAuras.grow_types = { -- horizontal types: R (right), L (left) -- vertical types: U (up), D (down) -WeakAuras.grid_types = { +Private.grid_types = { RU = L["Right, then Up"], UR = L["Up, then Right"], LU = L["Left, then Up"], @@ -1657,48 +1662,48 @@ WeakAuras.grid_types = { DL = L["Down, then Left"], } -WeakAuras.text_rotate_types = { +Private.text_rotate_types = { ["LEFT"] = L["Left"], ["NONE"] = L["None"], ["RIGHT"] = L["Right"] } -WeakAuras.align_types = { +Private.align_types = { ["LEFT"] = L["Left"], ["CENTER"] = L["Center"], ["RIGHT"] = L["Right"] } -WeakAuras.rotated_align_types = { +Private.rotated_align_types = { ["LEFT"] = L["Top"], ["CENTER"] = L["Center"], ["RIGHT"] = L["Bottom"] } -WeakAuras.icon_side_types = { +Private.icon_side_types = { ["LEFT"] = L["Left"], ["RIGHT"] = L["Right"] } -WeakAuras.rotated_icon_side_types = { +Private.rotated_icon_side_types = { ["LEFT"] = L["Top"], ["RIGHT"] = L["Bottom"] } -WeakAuras.anim_types = { +Private.anim_types = { none = L["None"], preset = L["Preset"], custom = L["Custom"] } -WeakAuras.anim_ease_types = { +Private.anim_ease_types = { none = L["None"], easeIn = L["Ease In"], easeOut = L["Ease Out"], easeOutIn = L["Ease In and Out"] } -WeakAuras.anim_ease_functions = { +Private.anim_ease_functions = { none = function(percent) return percent end, easeIn = function(percent, power) return percent ^ power; @@ -1714,7 +1719,7 @@ WeakAuras.anim_ease_functions = { end } -WeakAuras.anim_translate_types = { +Private.anim_translate_types = { straightTranslate = L["Normal"], circle = L["Circle"], spiral = L["Spiral"], @@ -1725,7 +1730,7 @@ WeakAuras.anim_translate_types = { custom = L["Custom Function"] } -WeakAuras.anim_scale_types = { +Private.anim_scale_types = { straightScale = L["Normal"], pulse = L["Pulse"], fauxspin = L["Spin"], @@ -1733,21 +1738,21 @@ WeakAuras.anim_scale_types = { custom = L["Custom Function"] } -WeakAuras.anim_alpha_types = { +Private.anim_alpha_types = { straight = L["Normal"], alphaPulse = L["Pulse"], hide = L["Hide"], custom = L["Custom Function"] } -WeakAuras.anim_rotate_types = { +Private.anim_rotate_types = { straight = L["Normal"], backandforth = L["Back and Forth"], wobble = L["Wobble"], custom = L["Custom Function"] } -WeakAuras.anim_color_types = { +Private.anim_color_types = { straightColor = L["Legacy RGB Gradient"], straightHSV = L["Gradient"], pulseColor = L["Legacy RGB Gradient Pulse"], @@ -1755,7 +1760,7 @@ WeakAuras.anim_color_types = { custom = L["Custom Function"] } -WeakAuras.instance_types = { +Private.instance_types = { none = L["No Instance"], party = L["5 Man Dungeon"], ten = L["10 Man Raid"], @@ -1766,19 +1771,19 @@ WeakAuras.instance_types = { arena = L["Arena"] } -WeakAuras.group_types = { +Private.group_types = { solo = L["Not in Group"], group = L["In Group"], raid = L["In Raid"] } -WeakAuras.difficulty_types = { +Private.difficulty_types = { none = L["None"], normal = PLAYER_DIFFICULTY1, heroic = PLAYER_DIFFICULTY2 } -WeakAuras.classification_types = { +Private.classification_types = { worldboss = L["World Boss"], rareelite = L["Rare Elite"], elite = L["Elite"], @@ -1787,7 +1792,7 @@ WeakAuras.classification_types = { trivial = L["Trivial (Low Level)"] } -WeakAuras.anim_start_preset_types = { +Private.anim_start_preset_types = { slidetop = L["Slide from Top"], slideleft = L["Slide from Left"], slideright = L["Slide from Right"], @@ -1800,7 +1805,7 @@ WeakAuras.anim_start_preset_types = { starShakeDecay = L["Star Shake"], } -WeakAuras.anim_main_preset_types = { +Private.anim_main_preset_types = { shake = L["Shake"], spin = L["Spin"], flip = L["Flip"], @@ -1814,7 +1819,7 @@ WeakAuras.anim_main_preset_types = { bounce = L["Bounce"] } -WeakAuras.anim_finish_preset_types = { +Private.anim_finish_preset_types = { slidetop = L["Slide to Top"], slideleft = L["Slide to Left"], slideright = L["Slide to Right"], @@ -1827,7 +1832,7 @@ WeakAuras.anim_finish_preset_types = { starShakeDecay = L["Star Shake"], }; -WeakAuras.chat_message_types = { +Private.chat_message_types = { CHAT_MSG_BATTLEGROUND = L["Battleground"], CHAT_MSG_BG_SYSTEM_NEUTRAL = L["BG-System Neutral"], CHAT_MSG_BG_SYSTEM_ALLIANCE = L["BG-System Alliance"], @@ -1853,7 +1858,7 @@ WeakAuras.chat_message_types = { CHAT_MSG_SYSTEM = L["System"] } -WeakAuras.send_chat_message_types = { +Private.send_chat_message_types = { WHISPER = L["Whisper"], CHANNEL = L["Channel"], SAY = L["Say"], @@ -1870,18 +1875,18 @@ WeakAuras.send_chat_message_types = { PRINT = L["Chat Frame"] } -WeakAuras.group_aura_name_info_types = { +Private.group_aura_name_info_types = { aura = L["Aura Name"], players = L["Player(s) Affected"], nonplayers = L["Player(s) Not Affected"] } -WeakAuras.group_aura_stack_info_types = { +Private.group_aura_stack_info_types = { count = L["Number Affected"], stack = L["Aura Stack"] } -WeakAuras.cast_types = { +Private.cast_types = { cast = L["Cast"], channel = L["Channel (Spell)"] } @@ -1984,20 +1989,20 @@ LSM:Register("sound", "Wicked Female Laugh", PowerAurasSoundPath.."wlaugh.ogg") LSM:Register("sound", "Wolf Howl", PowerAurasSoundPath.."wolf5.ogg") LSM:Register("sound", "Yeehaw", PowerAurasSoundPath.."yeehaw.ogg") -WeakAuras.sound_types = { +Private.sound_types = { [" custom"] = " " .. L["Custom"], [" KitID"] = " " .. L["Sound by Kit ID"] } for name, path in next, LSM:HashTable("sound") do - WeakAuras.sound_types[path] = name + Private.sound_types[path] = name end LSM.RegisterCallback(WeakAuras, "LibSharedMedia_Registered", function(_, mediatype, key) if mediatype == "sound" then local path = LSM:Fetch(mediatype, key) if path then - WeakAuras.sound_types[path] = key + Private.sound_types[path] = key end end end) @@ -2008,66 +2013,65 @@ LSM:Register("font", "Fira Mono Medium", "Interface\\Addons\\WeakAuras\\Media\\F -- register plain white border LSM:Register("border", "Square Full White", [[Interface\AddOns\WeakAuras\Media\Textures\Square_FullWhite.tga]]) -WeakAuras.duration_types = { +Private.duration_types = { seconds = L["Seconds"], relative = L["Relative"] } -WeakAuras.duration_types_no_choice = { +Private.duration_types_no_choice = { seconds = L["Seconds"] } -WeakAuras.gtfo_types = { +Private.gtfo_types = { [1] = L["High Damage"], [2] = L["Low Damage"], [3] = L["Fail Alert"], [4] = L["Friendly Fire"] } -WeakAuras.pet_behavior_types = { +Private.pet_behavior_types = { aggressive = PET_MODE_AGGRESSIVE, passive = PET_MODE_PASSIVE, defensive = PET_MODE_DEFENSIVE } -WeakAuras.cooldown_progress_behavior_types = { +Private.cooldown_progress_behavior_types = { showOnCooldown = L["On Cooldown"], showOnReady = L["Not on Cooldown"], showAlways = L["Always"] } -WeakAuras.cooldown_types = { +Private.cooldown_types = { auto = L["Auto"], charges = L["Charges"], cooldown = L["Cooldown"] } -WeakAuras.bufftrigger_progress_behavior_types = { +Private.bufftrigger_progress_behavior_types = { showOnActive = L["Buffed/Debuffed"], showOnMissing = L["Missing"], showAlways= L["Always"] } -WeakAuras.bufftrigger_2_progress_behavior_types = { +Private.bufftrigger_2_progress_behavior_types = { showOnActive = L["Aura(s) Found"], showOnMissing = L["Aura(s) Missing"], showAlways = L["Always"], showOnMatches = L["Match Count"] } -WeakAuras.bufftrigger_2_preferred_match_types = -{ +Private.bufftrigger_2_preferred_match_types = { showLowest = L["Least remaining time"], showHighest = L["Most remaining time"] } -WeakAuras.bufftrigger_2_per_unit_mode = { +Private.bufftrigger_2_per_unit_mode = { affected = L["Affected"], unaffected = L["Unaffected"], all = L["All"] } -WeakAuras.item_slot_types = { +Private.item_slot_types = { [0] = AMMOSLOT, [1] = HEADSLOT, [2] = NECKSLOT, @@ -2089,28 +2093,28 @@ WeakAuras.item_slot_types = { [19] = TABARDSLOT } -WeakAuras.charges_change_type = { +Private.charges_change_type = { GAINED = L["Gained"], LOST = L["Lost"], CHANGED = L["Changed"] } -WeakAuras.charges_change_condition_type = { +Private.charges_change_condition_type = { GAINED = L["Gained"], LOST = L["Lost"] } -WeakAuras.combat_event_type = { +Private.combat_event_type = { PLAYER_REGEN_ENABLED = L["Leaving"], PLAYER_REGEN_DISABLED = L["Entering"] } -WeakAuras.bool_types = { +Private.bool_types = { [0] = L["False"], [1] = L["True"] } -WeakAuras.update_categories = { +Private.update_categories = { { name = "anchor", fields = { @@ -2226,7 +2230,7 @@ WeakAuras.update_categories = { -- fields that are handled as special cases when importing -- mismatch of internal fields is not counted as a difference -WeakAuras.internal_fields = { +Private.internal_fields = { uid = true, internalVersion = true, sortHybridTable = true, @@ -2235,7 +2239,7 @@ WeakAuras.internal_fields = { -- fields that are not included in exported data -- these represent information which is only meaningful inside the db, -- or are represented in other ways in exported -WeakAuras.non_transmissable_fields = { +Private.non_transmissable_fields = { controlledChildren = true, parent = true, authorMode = true, @@ -2245,7 +2249,7 @@ WeakAuras.non_transmissable_fields = { } WeakAuras.data_stub = { - -- note: this is the minimal data stub which prevents false positives in WeakAuras.diff upon reimporting an aura. + -- note: this is the minimal data stub which prevents false positives in diff upon reimporting an aura. -- pending a refactor of other code which adds unnecessary fields, it is possible to shrink it triggers = { { @@ -2303,7 +2307,7 @@ WeakAuras.data_stub = { authorOptions = {}, } -WeakAuras.author_option_classes = { +Private.author_option_classes = { toggle = "simple", input = "simple", number = "simple", @@ -2317,7 +2321,7 @@ WeakAuras.author_option_classes = { group = "group" } -WeakAuras.author_option_types = { +Private.author_option_types = { toggle = L["Toggle"], input = L["String"], number = L["Number"], @@ -2331,7 +2335,7 @@ WeakAuras.author_option_types = { group = L["Option Group"], } -WeakAuras.author_option_fields = { +Private.author_option_fields = { common = { type = true, name = true, @@ -2399,44 +2403,44 @@ WeakAuras.author_option_fields = { } } -WeakAuras.array_entry_name_types = { +Private.array_entry_name_types = { [-1] = L["Fixed Names"], [0] = L["Entry Order"], -- the rest is auto-populated with indices which are valid entry name sources } -WeakAuras.name_source_option_types = { +Private.name_source_option_types = { -- option types which can be used to generate entry names on arrays input = true, number = true, range = true, } -WeakAuras.group_limit_types = { +Private.group_limit_types = { none = L["Unlimited"], max = L["Limited"], fixed = L["Fixed Size"], } -WeakAuras.group_option_types = { +Private.group_option_types = { simple = L["Simple"], array = L["Array"], } -WeakAuras.glow_types = { +Private.glow_types = { ACShine = L["Autocast Shine"], Pixel = L["Pixel Glow"], buttonOverlay = L["Action Button Glow"], } -WeakAuras.font_sizes = { +Private.font_sizes = { small = L["Small"], medium = L["Medium"], large = L["Large"], } -- unitIds registerable with RegisterUnitEvent -WeakAuras.baseUnitId = { +Private.baseUnitId = { ["player"] = true, ["target"] = true, ["pet"] = true, @@ -2444,7 +2448,7 @@ WeakAuras.baseUnitId = { ["vehicle"] = true } -WeakAuras.multiUnitId = { +Private.multiUnitId = { ["boss"] = true, ["arena"] = true, ["group"] = true, @@ -2452,7 +2456,7 @@ WeakAuras.multiUnitId = { ["raid"] = true, } -WeakAuras.multiUnitUnits = { +Private.multiUnitUnits = { ["boss"] = {}, ["arena"] = {}, ["group"] = {}, @@ -2460,34 +2464,34 @@ WeakAuras.multiUnitUnits = { ["raid"] = {} } -WeakAuras.multiUnitUnits.group["player"] = true -WeakAuras.multiUnitUnits.party["player"] = true +Private.multiUnitUnits.group["player"] = true +Private.multiUnitUnits.party["player"] = true for i = 1, 4 do - WeakAuras.baseUnitId["party"..i] = true - WeakAuras.baseUnitId["partypet"..i] = true - WeakAuras.multiUnitUnits.group["party"..i] = true - WeakAuras.multiUnitUnits.party["party"..i] = true + Private.baseUnitId["party"..i] = true + Private.baseUnitId["partypet"..i] = true + Private.multiUnitUnits.group["party"..i] = true + Private.multiUnitUnits.party["party"..i] = true end for i = 1, MAX_BOSS_FRAMES do - WeakAuras.baseUnitId["boss"..i] = true - WeakAuras.multiUnitUnits.boss["boss"..i] = true + Private.baseUnitId["boss"..i] = true + Private.multiUnitUnits.boss["boss"..i] = true end for i = 1, 5 do - WeakAuras.baseUnitId["arena"..i] = true - WeakAuras.multiUnitUnits.arena["arena"..i] = true + Private.baseUnitId["arena"..i] = true + Private.multiUnitUnits.arena["arena"..i] = true end for i = 1, 40 do - WeakAuras.baseUnitId["raid"..i] = true - WeakAuras.baseUnitId["raidpet"..i] = true - WeakAuras.multiUnitUnits.group["raid"..i] = true - WeakAuras.multiUnitUnits.raid["raid"..i] = true + Private.baseUnitId["raid"..i] = true + Private.baseUnitId["raidpet"..i] = true + Private.multiUnitUnits.group["raid"..i] = true + Private.multiUnitUnits.raid["raid"..i] = true end -WeakAuras.dbm_types = { +Private.dbm_types = { [1] = L["Add"], [2] = L["AOE"], [3] = L["Targeted"], @@ -2497,14 +2501,14 @@ WeakAuras.dbm_types = { [7] = L["Important"] } -WeakAuras.weapon_enchant_types = { +Private.weapon_enchant_types = { showOnActive = L["Enchant Found"], showOnMissing = L["Enchant Missing"], showAlways = L["Always"], } -WeakAuras.reset_swing_spells = {} -WeakAuras.reset_ranged_swing_spells = { +Private.reset_swing_spells = {} +Private.reset_ranged_swing_spells = { [2480] = true, -- Shoot Bow [7919] = true, -- Shoot Crossbow [7918] = true, -- Shoot Gun @@ -2547,6 +2551,20 @@ if WeakAuras.IsClassic() then 20549, -- War Stomp } for i, spellid in ipairs(reset_swing_spell_list) do - WeakAuras.reset_swing_spells[spellid] = true + Private.reset_swing_spells[spellid] = true end end + +Private.talent_types_specific = {} +Private.talents_ids = { + DEATHKNIGHT = {{48979,48997,49182,48978,49004,55107,48982,48987,49467,48985,49145,49015,48977,49006,49005,48988,53137,49027,49016,50365,62905,49018,55233,49189,55050,49023,61154,49028}, {49175,49455,49042,55061,49140,49226,50880,49039,51468,51123,49149,49137,49186,49471,49796,55610,49024,49188,50040,49203,50384,65661,54639,51271,49200,49143,50187,49202,49184}, {51745,48962,55129,49036,48963,49588,48965,49013,51459,49158,49146,49219,55620,49194,49220,49223,55666,49224,49208,52143,66799,51052,50391,63560,49032,49222,49217,51099,55090,50117,49206}}, + DRUID = {{16814,57810,16845,35363,16821,16836,16880,57865,16819,16909,16850,33589,5570,57849,33597,16896,33592,24858,48384,33600,48389,33603,48516,50516,33831,48488,48506,48505}, {16934,16858,16947,16998,16929,17002,61336,16942,16966,16972,37116,48409,16940,49377,33872,57878,17003,33853,17007,34297,33851,57873,33859,48483,48492,33917,48532,48432,63503,50334}, {17050,17063,17056,17069,17118,16833,17106,16864,48411,24968,17111,17116,17104,17123,33879,17074,34151,18562,33881,33886,48496,48539,65139,48535,63410,51179,48438}}, + HUNTER = {{19552,19583,35029,19549,19609,24443,19559,53265,19616,19572,19598,19578,19577,19590,34453,19621,34455,19574,34462,53252,34466,53262,34692,53256,56314,53270}, {19407,53620,19426,34482,19421,19485,34950,19454,19434,34948,19464,19416,35100,23989,19461,34475,19507,53234,19506,35104,34485,53228,53215,34490,53221,53241,53209}, {52783,19498,19159,19290,19184,19376,34494,19255,19503,19295,19286,56333,56342,56339,19370,19306,19168,34491,34500,19386,34497,34506,53295,53298,3674,53302,53290,53301}}, + MAGE = {{11210,11222,11237,28574,29441,11213,11247,11242,44397,54646,11252,11255,18462,29447,31569,12043,11232,31574,15058,31571,31579,12042,44394,44378,31584,31589,44404,44400,35578,44425}, {11078,18459,11069,11119,54747,11108,11100,11103,11366,11083,11095,11094,29074,31638,11115,11113,31641,11124,34293,11129,31679,64353,31656,44442,31661,44445,44449,44457}, {11071,11070,31670,11207,11189,29438,11175,11151,12472,11185,16757,11160,11170,11958,11190,31667,55091,11180,44745,11426,31674,31682,44543,44546,31687,44557,44566,44572}}, + PALADIN = {{20205,20224,20237,20257,9453,31821,20210,20234,20254,20244,53660,31822,20216,20359,31825,5923,31833,20473,31828,53551,31837,31842,53671,53569,53556,53563}, {63646,20262,31844,20174,20096,64205,20468,20143,53527,20487,20138,20911,20177,31848,20196,31785,20925,31850,20127,31858,53590,31935,53583,53709,53695,53595}, {20060,20101,25956,20335,20042,9452,20117,20375,26022,9799,32043,31866,20111,31869,20049,31871,53486,20066,31876,31879,53375,53379,35395,53501,53380,53385}}, + PRIEST = {{14522,47586,14523,14747,14749,14531,14521,14751,14748,33167,14520,14750,33201,18551,63574,33186,34908,45234,10060,63504,57470,47535,47507,47509,33206,47516,52795,47540}, {14913,14908,14889,27900,18530,19236,27811,14892,27789,14912,14909,14911,20711,14901,33150,14898,34753,724,33142,64127,33158,63730,63534,34861,47558,47562,47788}, {15270,15337,15259,15318,15275,15260,15392,15273,15407,15274,17322,15257,15487,15286,27839,33213,14910,63625,15473,33221,47569,33191,64044,34914,47580,47573,47585}}, + ROGUE = {{14162,14144,14138,14156,51632,13733,14983,14168,14128,16513,14113,31208,14177,14174,31244,14186,14158,51625,58426,31380,51634,31234,31226,1329,51627,51664,51662}, {13741,13732,13715,14165,13713,13705,13742,14251,13706,13754,13743,13712,18427,13709,13877,13960,30919,31124,31122,13750,31130,5952,35541,51672,32601,51682,51685,51690}, {14179,13958,14057,30892,14076,13975,13981,14278,14171,13983,13976,14079,30894,14185,14082,16511,31221,30902,31211,14183,31228,31216,51692,51698,36554,58414,51708,51713}}, + SHAMAN = {{16039,16035,16038,28996,30160,16040,16164,16089,16086,29062,28999,16041,30664,30672,16578,16166,51483,63370,51466,30675,51474,30706,51480,62097,51490}, {16259,16043,17485,16258,16255,16262,16261,16266,43338,16254,16256,16252,29192,16268,51883,30802,29082,63373,30816,30798,17364,51525,60103,51521,30812,30823,51523,51528,51533}, {16182,16173,16184,29187,16179,16180,16181,55198,16176,16187,16194,29206,16188,30864,16178,30881,16190,51886,51554,30872,30867,51556,974,51560,51562,61295}}, + WARLOCK = {{18827,18174,17810,18179,18213,18182,17804,53754,17783,18288,18218,18094,32381,32385,63108,18223,54037,18271,47195,30060,18220,30054,32477,47198,30108,58435,47201,48181}, {18692,18694,18697,47230,18703,18705,18731,18754,19028,18708,30143,18769,18709,30326,18767,23785,47245,30319,47193,35691,30242,63156,54347,30146,63117,47236,59672}, {17793,17788,18119,63349,17778,18126,17877,17959,18135,17917,17927,34935,17815,18130,30299,17954,17962,30293,18096,30288,54117,47258,30283,47220,47266,50796}}, + WARRIOR = {{12282,16462,12286,12285,12300,12295,12290,12296,16493,12834,12163,56636,12700,12328,12284,12281,20504,12289,46854,29834,12294,46865,12862,64976,35446,46859,29723,29623,29836,46867,46924}, {61216,12321,12320,12324,12322,12329,12323,16487,12318,23584,20502,12317,29590,12292,29888,20500,12319,46908,23881,29721,46910,29759,60970,29801,46913,56927,46917}, {12301,12298,12287,50685,12297,12975,12797,29598,12299,59088,12313,12308,12312,12809,12311,16538,29593,50720,29787,29140,46945,57499,20243,47294,46951,58872,46968}} +} diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index 90644db..8daea9a 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -48,7 +48,7 @@ end function Private.LoadOptions(msg) if not(IsAddOnLoaded("WeakAurasOptions")) then if not WeakAuras.IsLoginFinished() then - prettyPrint(WeakAuras.LoginMessage()) + prettyPrint(Private.LoginMessage()) loginQueue[#loginQueue + 1] = WeakAuras.OpenOptions elseif InCombatLockdown() then -- inform the user and queue ooc @@ -69,7 +69,7 @@ function Private.LoadOptions(msg) end function WeakAuras.OpenOptions(msg) - if WeakAuras.NeedToRepairDatabase() then + if Private.NeedToRepairDatabase() then StaticPopup_Show("WEAKAURAS_CONFIRM_REPAIR", nil, nil, {reason = "downgrade"}) elseif (WeakAuras.IsLoginFinished() and Private.LoadOptions(msg)) then WeakAuras.ToggleOptions(msg, Private); @@ -117,7 +117,7 @@ function SlashCmdList.WEAKAURAS(input) end if not WeakAuras.IsCorrectVersion() then return end -function WeakAuras.ApplyToDataOrChildData(data, func, ...) +function Private.ApplyToDataOrChildData(data, func, ...) if data.controlledChildren then for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId) @@ -152,12 +152,12 @@ local db; local registeredFromAddons; -- List of addons that registered displays -WeakAuras.addons = {}; -local addons = WeakAuras.addons; +Private.addons = {}; +local addons = Private.addons; -- used if an addon tries to register a display under an id that the user already has a display with that id -WeakAuras.collisions = {}; -local collisions = WeakAuras.collisions; +Private.collisions = {}; +local collisions = Private.collisions; -- While true no events are handled. E.g. WeakAuras is paused while the Options dialog is open local paused = true; @@ -179,8 +179,8 @@ WeakAuras.regions = {}; local regions = WeakAuras.regions; -- keyed on id, contains bool indicating whether the aura is loaded -WeakAuras.loaded = {}; -local loaded = WeakAuras.loaded; +Private.loaded = {}; +local loaded = Private.loaded; -- contains regions for clones WeakAuras.clones = {}; @@ -193,22 +193,22 @@ local clonePool = {} WeakAuras.regionTypes = {}; local regionTypes = WeakAuras.regionTypes; -WeakAuras.subRegionTypes = {} -local subRegionTypes = WeakAuras.subRegionTypes +Private.subRegionTypes = {} +local subRegionTypes = Private.subRegionTypes -- One table per regionType, see RegisterRegionOptions WeakAuras.regionOptions = {}; local regionOptions = WeakAuras.regionOptions; -WeakAuras.subRegionOptions = {} -local subRegionOptions = WeakAuras.subRegionOptions +Private.subRegionOptions = {} +local subRegionOptions = Private.subRegionOptions -- Maps from trigger type to trigger system -WeakAuras.triggerTypes = {}; -local triggerTypes = WeakAuras.triggerTypes; +Private.triggerTypes = {}; +local triggerTypes = Private.triggerTypes; --- Maps from trigger type to a functin that can create options for the trigger -WeakAuras.triggerTypesOptions = {}; +-- Maps from trigger type to a function that can create options for the trigger +Private.triggerTypesOptions = {}; -- Trigger State, updated by trigger systems, then applied to regions by UpdatedTriggerState -- keyed on id, triggernum, cloneid @@ -272,7 +272,7 @@ WeakAuras.conditionTextFormatters = {} -- keyed on UID not on id! WeakAuras.conditionHelpers = {} -local load_prototype = WeakAuras.load_prototype; +local load_prototype = Private.load_prototype; local levelColors = { [0] = "|cFFFFFFFF", @@ -281,15 +281,6 @@ local levelColors = { [3] = "|cFFFF4040" }; -function WeakAuras.debug(msg, level) - if(db.debug) then - level = (level and levelColors[level] and level) or 2; - msg = (type(msg) == "string" and msg) or (msg and "Invalid debug message of type "..type(msg)) or "Debug message not specified"; - DEFAULT_CHAT_FRAME:AddMessage(levelColors[level]..msg); - end -end -local debug = WeakAuras.debug; - function WeakAuras.validate(input, default) for field, defaultValue in pairs(default) do if(type(defaultValue) == "table" and type(input[field]) ~= "table") then @@ -478,7 +469,7 @@ function WeakAuras.IsOptionsOpen() return false; end -function WeakAuras.ParseNumber(numString) +function Private.ParseNumber(numString) if not(numString and type(numString) == "string") then if(type(numString) == "number") then return numString, "notastring"; @@ -520,7 +511,7 @@ end -- Used for the load function, could be simplified a bit -- It used to be also used for the generic trigger system -function WeakAuras.ConstructFunction(prototype, trigger, skipOptional) +local function ConstructFunction(prototype, trigger, skipOptional) local input = {"event"}; local required = {}; local tests = {}; @@ -713,6 +704,9 @@ local function LoadCustomActionFunctions(data) end function WeakAuras.CountWagoUpdates() + if not (WeakAurasCompanion and WeakAurasCompanion.slugs) then + return 0 + end local WeakAurasSaved = WeakAurasSaved local updatedSlugs, updatedSlugsCount = {}, 0 for id, aura in pairs(WeakAurasSaved.displays) do @@ -844,7 +838,7 @@ Broker_WeakAuras = LDB:NewDataObject("WeakAuras", { do -- Archive stuff local Archivist = select(2, ...).Archivist - function WeakAuras.OpenArchive() + local function OpenArchive() if Archivist:IsInitialized() then return Archivist else @@ -860,7 +854,7 @@ do -- Archive stuff end function WeakAuras.LoadFromArchive(storeType, storeID) - local Archivist = WeakAuras.OpenArchive() + local Archivist = OpenArchive() return Archivist:Load(storeType, storeID) end end @@ -871,13 +865,13 @@ function WeakAuras.IsLoginFinished() return loginFinished end -function WeakAuras.LoginMessage() +function Private.LoginMessage() return loginMessage end -function WeakAuras.Login(initialTime, takeNewSnapshots) +function Private.Login(initialTime, takeNewSnapshots) local loginThread = coroutine.create(function() - WeakAuras.Pause(); + Private.Pause(); if db.history then local histRepo = WeakAuras.LoadFromArchive("Repository", "history") @@ -909,19 +903,11 @@ function WeakAuras.Login(initialTime, takeNewSnapshots) WeakAuras.AddManyFromAddons(from_files); WeakAuras.RegisterDisplay = WeakAuras.AddFromAddon; coroutine.yield(); - WeakAuras.ResolveCollisions(function() registeredFromAddons = true; end); + Private.ResolveCollisions(function() registeredFromAddons = true; end); coroutine.yield(); - for _, triggerSystem in pairs(triggerSystems) do - if (triggerSystem.AllAdded) then - triggerSystem.AllAdded(); - coroutine.yield(); - end - end - - coroutine.yield(); - WeakAuras.RegisterLoadEvents(); - WeakAuras.Resume(); + Private.RegisterLoadEvents(); + Private.Resume(); coroutine.yield(); local nextCallback = loginQueue[1]; @@ -937,7 +923,7 @@ function WeakAuras.Login(initialTime, takeNewSnapshots) end loginFinished = true - WeakAuras.ResumeAllDynamicGroups(); + Private.ResumeAllDynamicGroups(); end) if initialTime then @@ -950,7 +936,7 @@ function WeakAuras.Login(initialTime, takeNewSnapshots) finishTime = debugprofilestop() end if coroutine.status(loginThread) ~= 'dead' then - WeakAuras.dynFrame:AddAction('login', loginThread) + Private.dynFrame:AddAction('login', loginThread) end if not ok then loginMessage = L["WeakAuras has encountered an error during the login process. Please report this issue at https://github.com/WeakAuras/Weakauras2/issues/new."] @@ -958,7 +944,7 @@ function WeakAuras.Login(initialTime, takeNewSnapshots) geterrorhandler()(msg .. '\n' .. debugstack(loginThread)) end else - WeakAuras.dynFrame:AddAction('login', loginThread) + Private.dynFrame:AddAction('login', loginThread) end end @@ -990,14 +976,14 @@ loadedFrame:SetScript("OnEvent", function(self, event, addon) db.displays = db.displays or {}; db.registered = db.registered or {}; - WeakAuras.SyncParentChildRelationships(); + Private.SyncParentChildRelationships(); local isFirstUIDValidation = db.dbVersion == nil or db.dbVersion < 26; - WeakAuras.ValidateUniqueDataIds(isFirstUIDValidation); + Private.ValidateUniqueDataIds(isFirstUIDValidation); if db.lastArchiveClear == nil then db.lastArchiveClear = time(); elseif db.lastArchiveClear < time() - 86400 then - WeakAuras.CleanArchive(db.historyCutoff, db.migrationCutoff); + Private.CleanArchive(db.historyCutoff, db.migrationCutoff); end db.minimap = db.minimap or { hide = false }; LDBIcon:Register("WeakAuras", Broker_WeakAuras, db.minimap); @@ -1019,7 +1005,7 @@ loadedFrame:SetScript("OnEvent", function(self, event, addon) end if dbIsValid then -- run login thread for up to 15 seconds, then defer to dynFrame - WeakAuras.Login(15000, takeNewSnapshots) + Private.Login(15000, takeNewSnapshots) else -- db isn't valid. Request permission to run repair tool before logging in StaticPopup_Show("WEAKAURAS_CONFIRM_REPAIR", nil, nil, {reason = "downgrade"}) @@ -1055,7 +1041,7 @@ end); function WeakAuras.SetImporting(b) importing = b; - WeakAuras.RefreshTooltipButtons() + Private.RefreshTooltipButtons() end function WeakAuras.IsImporting() @@ -1066,7 +1052,7 @@ function WeakAuras.IsPaused() return paused; end -function WeakAuras.Pause() +function Private.Pause() -- Forcibly hide all displays, and clear all trigger information (it will be restored on .Resume() due to forced events) for id, region in pairs(regions) do region.region:Collapse(); -- ticket 366 @@ -1081,29 +1067,19 @@ function WeakAuras.Pause() paused = true; end -function WeakAuras.Resume() - paused = false; - WeakAuras.ScanAll(); - for _, regionData in pairs(regions) do - if regionData.region.Resume then - regionData.region:Resume(true) - end - end -end - function WeakAuras.Toggle() if(paused) then - WeakAuras.Resume(); + Private.Resume(); else - WeakAuras.Pause(); + Private.Pause(); end end -function WeakAuras.SquelchingActions() +function Private.SquelchingActions() return squelch_actions; end -function WeakAuras.PauseAllDynamicGroups() +function Private.PauseAllDynamicGroups() for id, region in pairs(regions) do if (region.region.Suspend) then region.region:Suspend(); @@ -1111,7 +1087,7 @@ function WeakAuras.PauseAllDynamicGroups() end end -function WeakAuras.ResumeAllDynamicGroups() +function Private.ResumeAllDynamicGroups() for id, region in pairs(regions) do if (region.region.Resume) then region.region:Resume(); @@ -1119,29 +1095,12 @@ function WeakAuras.ResumeAllDynamicGroups() end end -function WeakAuras.ScanAll() - WeakAuras.PauseAllDynamicGroups(); - - for id, region in pairs(regions) do - region.region:Collapse(); - end - - for id, cloneList in pairs(clones) do - for cloneId, clone in pairs(cloneList) do - clone:Collapse(); - end - end - - WeakAuras.ResumeAllDynamicGroups(); - WeakAuras.ReloadAll(); -end - local pausedOptionsProcessing = false; -function WeakAuras.pauseOptionsProcessing(enable) +function Private.pauseOptionsProcessing(enable) pausedOptionsProcessing = enable; end -function WeakAuras.IsOptionsProcessingPaused() +function Private.IsOptionsProcessingPaused() return pausedOptionsProcessing; end @@ -1202,7 +1161,7 @@ end local toLoad = {} local toUnload = {}; local function scanForLoadsImpl(toCheck, event, arg1, ...) - if (WeakAuras.IsOptionsProcessingPaused()) then + if (Private.IsOptionsProcessingPaused()) then return; end @@ -1261,9 +1220,9 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...) end if(changed > 0 and not paused) then - WeakAuras.LoadDisplays(toLoad, event, arg1, ...); - WeakAuras.UnloadDisplays(toUnload, event, arg1, ...); - WeakAuras.FinishLoadUnload(); + Private.LoadDisplays(toLoad, event, arg1, ...); + Private.UnloadDisplays(toUnload, event, arg1, ...); + Private.FinishLoadUnload(); end for id, data in pairs(db.displays) do @@ -1284,14 +1243,13 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...) end - if (WeakAuras.afterScanForLoads) then -- Hook for Options - WeakAuras.afterScanForLoads(); - end + Private.callbacks:Fire("ScanForLoads") + wipe(toLoad); wipe(toUnload) end -function WeakAuras.ScanForLoads(toCheck, event, arg1, ...) +function Private.ScanForLoads(toCheck, event, arg1, ...) if not WeakAuras.IsLoginFinished() then return end @@ -1327,34 +1285,29 @@ unitLoadFrame:RegisterEvent("UNIT_FLAGS"); unitLoadFrame:RegisterEvent("UNIT_ENTERED_VEHICLE"); unitLoadFrame:RegisterEvent("UNIT_EXITED_VEHICLE"); -function WeakAuras.RegisterLoadEvents() +function Private.RegisterLoadEvents() loadFrame:SetScript("OnEvent", function(frame, ...) - WeakAuras.StartProfileSystem("load"); - WeakAuras.ScanForLoads(nil, ...) - WeakAuras.StopProfileSystem("load"); + Private.StartProfileSystem("load"); + Private.ScanForLoads(nil, ...) + Private.StopProfileSystem("load"); end); unitLoadFrame:SetScript("OnEvent", function(frame, e, arg1, ...) - WeakAuras.StartProfileSystem("load"); + Private.StartProfileSystem("load"); if (arg1 == "player") then - WeakAuras.ScanForLoads(nil, e, arg1, ...) + Private.ScanForLoads(nil, e, arg1, ...) end - WeakAuras.StopProfileSystem("load"); + Private.StopProfileSystem("load"); end); end -function WeakAuras.ReloadAll() - WeakAuras.UnloadAll(); - scanForLoadsImpl(); -end - -function WeakAuras.UnloadAll() +local function UnloadAll() -- Even though auras are collapsed, their finish animation can be running for id in pairs(loaded) do - WeakAuras.CancelAnimation(WeakAuras.regions[id].region, true, true, true, true, true, true) + Private.CancelAnimation(WeakAuras.regions[id].region, true, true, true, true, true, true) if clones[id] then for cloneId, region in pairs(clones[id]) do - WeakAuras.CancelAnimation(region, true, true, true, true, true, true) + Private.CancelAnimation(region, true, true, true, true, true, true) end end end @@ -1386,7 +1339,34 @@ function WeakAuras.UnloadAll() wipe(loaded); end -function WeakAuras.LoadDisplays(toLoad, ...) +function Private.Resume() + paused = false; + + Private.PauseAllDynamicGroups(); + + for id, region in pairs(regions) do + region.region:Collapse(); + end + + for id, cloneList in pairs(clones) do + for cloneId, clone in pairs(cloneList) do + clone:Collapse(); + end + end + + Private.ResumeAllDynamicGroups(); + + UnloadAll(); + scanForLoadsImpl(); + + for _, regionData in pairs(regions) do + if regionData.region.Resume then + regionData.region:Resume(true) + end + end +end + +function Private.LoadDisplays(toLoad, ...) for id in pairs(toLoad) do Private.RegisterForGlobalConditions(id); triggerState[id].triggers = {}; @@ -1400,17 +1380,17 @@ function WeakAuras.LoadDisplays(toLoad, ...) end end -function WeakAuras.UnloadDisplays(toUnload, ...) +function Private.UnloadDisplays(toUnload, ...) for _, triggerSystem in pairs(triggerSystems) do triggerSystem.UnloadDisplays(toUnload, ...); end for id in pairs(toUnload) do -- Even though auras are collapsed, their finish animation can be running - WeakAuras.CancelAnimation(WeakAuras.regions[id].region, true, true, true, true, true, true) + Private.CancelAnimation(WeakAuras.regions[id].region, true, true, true, true, true, true) if clones[id] then for cloneId, region in pairs(clones[id]) do - WeakAuras.CancelAnimation(region, true, true, true, true, true, true) + Private.CancelAnimation(region, true, true, true, true, true, true) end end @@ -1436,11 +1416,11 @@ function WeakAuras.UnloadDisplays(toUnload, ...) Private.UnloadConditions(id) WeakAuras.regions[id].region:Collapse(); - WeakAuras.CollapseAllClones(id); + Private.CollapseAllClones(id); end end -function WeakAuras.FinishLoadUnload() +function Private.FinishLoadUnload() for _, triggerSystem in pairs(triggerSystems) do triggerSystem.FinishLoadUnload(); end @@ -1456,7 +1436,7 @@ function Private.GetDataByUID(uid) return WeakAuras.GetData(UIDtoID[uid]) end -function WeakAuras.UIDtoID(uid) +function Private.UIDtoID(uid) return UIDtoID[uid] end @@ -1490,13 +1470,13 @@ function WeakAuras.Delete(data) regions[id].region:Collapse() - WeakAuras.CollapseAllClones(id); + Private.CollapseAllClones(id); - WeakAuras.CancelAnimation(WeakAuras.regions[id].region, true, true, true, true, true, true) + Private.CancelAnimation(WeakAuras.regions[id].region, true, true, true, true, true, true) if clones[id] then for cloneId, region in pairs(clones[id]) do - WeakAuras.CancelAnimation(region, true, true, true, true, true, true) + Private.CancelAnimation(region, true, true, true, true, true, true) end end @@ -1534,20 +1514,22 @@ function WeakAuras.Delete(data) Private.DeleteAuraEnvironment(id) triggerState[id] = nil; - if (WeakAuras.mouseFrame) then - WeakAuras.mouseFrame:delete(id); + if (Private.mouseFrame) then + Private.mouseFrame:delete(id); end Private.customActionsFunctions[id] = nil; WeakAuras.customConditionsFunctions[id] = nil; WeakAuras.conditionTextFormatters[id] = nil - WeakAuras.frameLevels[id] = nil; + Private.frameLevels[id] = nil; WeakAuras.conditionHelpers[data.uid] = nil WeakAuras.DeleteCollapsedData(id) + Private.RemoveHistory(data.uid) + Private.callbacks:Fire("Delete", data.uid) end @@ -1629,8 +1611,8 @@ function WeakAuras.Rename(data, newid) end end - if (WeakAuras.mouseFrame) then - WeakAuras.mouseFrame:rename(oldid, newid); + if (Private.mouseFrame) then + Private.mouseFrame:rename(oldid, newid); end Private.customActionsFunctions[newid] = Private.customActionsFunctions[oldid]; @@ -1642,10 +1624,10 @@ function WeakAuras.Rename(data, newid) WeakAuras.conditionTextFormatters[newid] = WeakAuras.conditionTextFormatters[oldid] WeakAuras.conditionTextFormatters[oldid] = nil - WeakAuras.frameLevels[newid] = WeakAuras.frameLevels[oldid]; - WeakAuras.frameLevels[oldid] = nil; + Private.frameLevels[newid] = Private.frameLevels[oldid]; + Private.frameLevels[oldid] = nil; - WeakAuras.ProfileRenameAura(oldid, newid); + Private.ProfileRenameAura(oldid, newid); WeakAuras.RenameCollapsedData(oldid, newid) @@ -1653,22 +1635,21 @@ function WeakAuras.Rename(data, newid) WeakAuras.Add(data) end -function WeakAuras.Convert(data, newType) +function Private.Convert(data, newType) local id = data.id; regions[id].region:SetScript("OnUpdate", nil); regions[id].region:Hide(); - WeakAuras.EndEvent(id, 0, true); + Private.EndEvent(id, 0, true); - WeakAuras.FakeStatesFor(id, false) + Private.FakeStatesFor(id, false) regions[id].region = nil; regions[id] = nil; data.regionType = newType; WeakAuras.Add(data); - WeakAuras.ResetCollapsed(id) - WeakAuras.FakeStatesFor(id, true) + Private.FakeStatesFor(id, true) local parentRegion = WeakAuras.GetRegion(data.parent) if parentRegion and parentRegion.ReloadControlledChildren then @@ -1676,20 +1657,6 @@ function WeakAuras.Convert(data, newType) end end -function WeakAuras.DeepCopy(source, dest) - local function recurse(source, dest) - for i,v in pairs(source) do - if(type(v) == "table") then - dest[i] = type(dest[i]) == "table" and dest[i] or {}; - recurse(v, dest[i]); - else - dest[i] = v; - end - end - end - recurse(source, dest); -end - function WeakAuras.RegisterAddon(addon, displayName, description, icon) if(addons[addon]) then addons[addon].displayName = displayName; @@ -1739,11 +1706,11 @@ function WeakAuras.CollisionResolved(addon, data, force) WeakAuras.AddFromAddon(addon, data, force); end -function WeakAuras.IsDefinedByAddon(id) +function Private.IsDefinedByAddon(id) return db.registered[id]; end -function WeakAuras.ResolveCollisions(onFinished) +function Private.ResolveCollisions(onFinished) local num = 0; for id, _ in pairs(collisions) do num = num + 1; @@ -1847,40 +1814,15 @@ function WeakAuras.ResolveCollisions(onFinished) end end -StaticPopupDialogs["WEAKAURAS_CONFIRM_REPAIR"] = { - text = "", - button1 = L["Repair"], - button2 = L["Cancel"], - OnAccept = function(self) - WeakAuras.RepairDatabase() - end, - OnShow = function(self) - if self.data.reason == "user" then - self.text:SetText(L["Manual Repair Confirmation Dialog"]:format(WeakAuras.LastUpgrade())) - else - self.text:SetText(L["Automatic Repair Confirmation Dialog"]:format(WeakAuras.LastUpgrade())) - end - end, - OnCancel = function(self) - if self.data.reason ~= "user" then - WeakAuras.Login() - end - end, - whileDead = true, - showAlert = true, - timeout = 0, - preferredindex = STATICPOPUP_NUMDIALOGS -} - -function WeakAuras.LastUpgrade() +local function LastUpgrade() return db.lastUpgrade and date(nil, db.lastUpgrade) or "unknown" end -function WeakAuras.NeedToRepairDatabase() +function Private.NeedToRepairDatabase() return db.dbVersion and db.dbVersion > WeakAuras.InternalVersion() end -function WeakAuras.RepairDatabase(loginAfter) +local function RepairDatabase(loginAfter) local coro = coroutine.create(function() WeakAuras.SetImporting(true) -- set db version to current code version @@ -1889,7 +1831,7 @@ function WeakAuras.RepairDatabase(loginAfter) local newDB = WeakAuras.Mixin({}, db.displays) coroutine.yield() for id, data in pairs(db.displays) do - local snapshot = WeakAuras.GetMigrationSnapshot(data.uid) + local snapshot = Private.GetMigrationSnapshot(data.uid) if snapshot then newDB[id] = nil newDB[snapshot.id] = snapshot @@ -1899,12 +1841,37 @@ function WeakAuras.RepairDatabase(loginAfter) db.displays = newDB WeakAuras.SetImporting(false) -- finally, login - WeakAuras.Login() + Private.Login() end) - WeakAuras.dynFrame:AddAction("repair", coro) + Private.dynFrame:AddAction("repair", coro) end -function WeakAuras.ValidateUniqueDataIds(silent) +StaticPopupDialogs["WEAKAURAS_CONFIRM_REPAIR"] = { + text = "", + button1 = L["Repair"], + button2 = L["Cancel"], + OnAccept = function(self) + RepairDatabase() + end, + OnShow = function(self) + if self.data.reason == "user" then + self.text:SetText(L["Manual Repair Confirmation Dialog"]:format(LastUpgrade())) + else + self.text:SetText(L["Automatic Repair Confirmation Dialog"]:format(LastUpgrade())) + end + end, + OnCancel = function(self) + if self.data.reason ~= "user" then + Private.Login() + end + end, + whileDead = true, + showAlert = true, + timeout = 0, + preferredindex = STATICPOPUP_NUMDIALOGS +} + +function Private.ValidateUniqueDataIds(silent) -- ensure that there are no duplicated uids anywhere in the database local seenUIDs = {} for _, data in pairs(db.displays) do @@ -1931,7 +1898,7 @@ function WeakAuras.ValidateUniqueDataIds(silent) end end -function WeakAuras.SyncParentChildRelationships(silent) +function Private.SyncParentChildRelationships(silent) -- 1. Find all auras where data.parent ~= nil or data.controlledChildren ~= nil -- If an aura has both, then remove data.parent -- If an aura has data.parent which doesn't exist, then remove data.parent @@ -2070,13 +2037,13 @@ end local function customOptionIsValid(option) if not option.type then return false - elseif WeakAuras.author_option_classes[option.type] == "simple" then + elseif Private.author_option_classes[option.type] == "simple" then if not option.key or not option.name or not option.default == nil then return false end - elseif WeakAuras.author_option_classes[option.type] == "group" then + elseif Private.author_option_classes[option.type] == "group" then if not option.key or not option.name or not option.default == nil @@ -2094,10 +2061,10 @@ local function validateUserConfig(data, options, config) prettyPrint(data.id .. " Custom Option #" .. index .. " in " .. data.id .. " has been detected as corrupt, and has been deleted.") corruptOptions[index] = true else - local optionClass = WeakAuras.author_option_classes[option.type] + local optionClass = Private.author_option_classes[option.type] if optionClass == "simple" then if not option.key then - option.key = WeakAuras.GenerateUniqeID() + option.key = WeakAuras.GenerateUniqueID() end authorOptionKeys[option.key] = index if config[option.key] == nil then @@ -2234,7 +2201,7 @@ local function removeSpellNames(data) end local oldDataStub = { - -- note: this is the minimal data stub which prevents false positives in WeakAuras.diff upon reimporting an aura. + -- note: this is the minimal data stub which prevents false positives in diff upon reimporting an aura. -- pending a refactor of other code which adds unnecessary fields, it is possible to shrink it trigger = { type = "aura", @@ -2282,7 +2249,7 @@ local oldDataStub = { } local oldDataStub2 = { - -- note: this is the minimal data stub which prevents false positives in WeakAuras.diff upon reimporting an aura. + -- note: this is the minimal data stub which prevents false positives in diff upon reimporting an aura. -- pending a refactor of other code which adds unnecessary fields, it is possible to shrink it triggers = { { @@ -2354,10 +2321,10 @@ function WeakAuras.PreAdd(data) local result = {} for index, subRegionData in ipairs(data.subRegions) do local subType = subRegionData.type - if subType and WeakAuras.subRegionTypes[subType] then + if subType and Private.subRegionTypes[subType] then -- If it is not supported, then drop it - if WeakAuras.subRegionTypes[subType].supports(data.regionType) then - local default = WeakAuras.subRegionTypes[subType].default + if Private.subRegionTypes[subType].supports(data.regionType) then + local default = Private.subRegionTypes[subType].default if type(default) == "function" then default = default(data.regionType) end @@ -2404,8 +2371,8 @@ local function pAdd(data, simpleChange) if simpleChange then db.displays[id] = data - WeakAuras.SetRegion(data) - WeakAuras.UpdatedTriggerState(id) + Private.SetRegion(data) + Private.UpdatedTriggerState(id) else if (data.controlledChildren) then Private.ClearAuraEnvironment(id); @@ -2413,16 +2380,16 @@ local function pAdd(data, simpleChange) Private.ClearAuraEnvironment(data.parent); end db.displays[id] = data; - WeakAuras.SetRegion(data); + Private.SetRegion(data); else local visible if (WeakAuras.IsOptionsOpen()) then - visible = WeakAuras.FakeStatesFor(id, false) + visible = Private.FakeStatesFor(id, false) else if (WeakAuras.regions[id] and WeakAuras.regions[id].region) then WeakAuras.regions[id].region:Collapse() else - WeakAuras.CollapseAllClones(id) + Private.CollapseAllClones(id) end end @@ -2434,14 +2401,14 @@ local function pAdd(data, simpleChange) db.displays[id] = data; if (not data.triggers.activeTriggerMode or data.triggers.activeTriggerMode > #data.triggers) then - data.triggers.activeTriggerMode = WeakAuras.trigger_modes.first_active; + data.triggers.activeTriggerMode = Private.trigger_modes.first_active; end for _, triggerSystem in pairs(triggerSystems) do triggerSystem.Add(data); end - local loadFuncStr, events = WeakAuras.ConstructFunction(load_prototype, data.load); + local loadFuncStr, events = ConstructFunction(load_prototype, data.load); for event, eventData in pairs(loadEvents) do eventData[id] = nil end @@ -2452,7 +2419,7 @@ local function pAdd(data, simpleChange) loadEvents["SCAN_ALL"] = loadEvents["SCAN_ALL"] or {} loadEvents["SCAN_ALL"][id] = true - local loadForOptionsFuncStr = WeakAuras.ConstructFunction(load_prototype, data.load, true); + local loadForOptionsFuncStr = ConstructFunction(load_prototype, data.load, true); local loadFunc = WeakAuras.LoadFunction(loadFuncStr, id, "load"); local loadForOptionsFunc = WeakAuras.LoadFunction(loadForOptionsFuncStr, id, "options load"); local triggerLogicFunc; @@ -2463,8 +2430,6 @@ local function pAdd(data, simpleChange) Private.LoadConditionPropertyFunctions(data); Private.LoadConditionFunction(data) - debug(id.." - Load", 1); - debug(loadFuncStr); loadFuncs[id] = loadFunc; loadFuncsForOptions[id] = loadForOptionsFunc; @@ -2481,12 +2446,12 @@ local function pAdd(data, simpleChange) timers[id] = nil; end - local region = WeakAuras.SetRegion(data); + local region = Private.SetRegion(data); triggerState[id] = { disjunctive = data.triggers.disjunctive or "all", numTriggers = #data.triggers, - activeTriggerMode = data.triggers.activeTriggerMode or WeakAuras.trigger_modes.first_active, + activeTriggerMode = data.triggers.activeTriggerMode or Private.trigger_modes.first_active, triggerLogicFunc = triggerLogicFunc, triggers = {}, triggerCount = 0, @@ -2494,11 +2459,11 @@ local function pAdd(data, simpleChange) }; if (WeakAuras.IsOptionsOpen()) then - WeakAuras.FakeStatesFor(id, visible) + Private.FakeStatesFor(id, visible) end if not(paused) then - WeakAuras.ScanForLoads({[id] = true}); + Private.ScanForLoads({[id] = true}); end end end @@ -2510,7 +2475,7 @@ function WeakAuras.Add(data, takeSnapshot, simpleChange) snapshot = CopyTable(data) end if takeSnapshot then - WeakAuras.SetMigrationSnapshot(data.uid, snapshot) + Private.SetMigrationSnapshot(data.uid, snapshot) end local ok, ret = pcall(WeakAuras.PreAdd, data) if not ok then @@ -2520,10 +2485,10 @@ function WeakAuras.Add(data, takeSnapshot, simpleChange) end end -function WeakAuras.SetRegion(data, cloneId) +function Private.SetRegion(data, cloneId) local regionType = data.regionType; if not(regionType) then - error("Improper arguments to WeakAuras.SetRegion - regionType not defined"); + error("Improper arguments to Private.SetRegion - regionType not defined"); else if(not regionTypes[regionType]) then regionType = "fallback"; @@ -2532,7 +2497,7 @@ function WeakAuras.SetRegion(data, cloneId) local id = data.id; if not(id) then - error("Improper arguments to WeakAuras.SetRegion - id not defined"); + error("Improper arguments to Private.SetRegion - id not defined"); else local region; if(cloneId) then @@ -2584,7 +2549,7 @@ function WeakAuras.SetRegion(data, cloneId) end end local loginFinished = WeakAuras.IsLoginFinished(); - local anim_cancelled = loginFinished and WeakAuras.CancelAnimation(region, true, true, true, true, true, true); + local anim_cancelled = loginFinished and Private.CancelAnimation(region, true, true, true, true, true, true); regionTypes[regionType].modify(parent, region, data); WeakAuras.regionPrototype.AddSetDurationInfo(region); @@ -2595,7 +2560,7 @@ function WeakAuras.SetRegion(data, cloneId) data.animation.start = data.animation.start or {type = "none"}; data.animation.main = data.animation.main or {type = "none"}; data.animation.finish = data.animation.finish or {type = "none"}; - if(WeakAuras.CanHaveDuration(data)) then + if(Private.CanHaveDuration(data)) then data.animation.start.duration_type = data.animation.start.duration_type or "seconds"; data.animation.main.duration_type = data.animation.main.duration_type or "seconds"; data.animation.finish.duration_type = data.animation.finish.duration_type or "seconds"; @@ -2609,18 +2574,18 @@ function WeakAuras.SetRegion(data, cloneId) clonePool[regionType] = clonePool[regionType] or {}; end if(anim_cancelled) then - WeakAuras.Animate("display", data.uid, "main", data.animation.main, region, false, nil, true, cloneId); + Private.Animate("display", data.uid, "main", data.animation.main, region, false, nil, true, cloneId); end return region; end end end -function WeakAuras.EnsureClone(id, cloneId) +local function EnsureClone(id, cloneId) clones[id] = clones[id] or {}; if not(clones[id][cloneId]) then local data = WeakAuras.GetData(id); - WeakAuras.SetRegion(data, cloneId); + Private.SetRegion(data, cloneId); clones[id][cloneId].justCreated = true; end return clones[id][cloneId]; @@ -2628,12 +2593,12 @@ end function WeakAuras.GetRegion(id, cloneId) if(cloneId and cloneId ~= "") then - return WeakAuras.EnsureClone(id, cloneId); + return EnsureClone(id, cloneId); end return WeakAuras.regions[id] and WeakAuras.regions[id].region; end -function WeakAuras.CollapseAllClones(id, triggernum) +function Private.CollapseAllClones(id, triggernum) if(clones[id]) then for i,v in pairs(clones[id]) do v:Collapse(); @@ -2671,10 +2636,10 @@ function Private.ReleaseClone(id, cloneId, regionType) clonePool[regionType][#clonePool[regionType] + 1] = region; end -function WeakAuras.HandleChatAction(message_type, message, message_dest, message_channel, r, g, b, region, customFunc, when, formatters) +function Private.HandleChatAction(message_type, message, message_dest, message_channel, r, g, b, region, customFunc, when, formatters) local useHiddenStates = when == "finish" if (message:find('%%')) then - message = WeakAuras.ReplacePlaceHolders(message, region, customFunc, useHiddenStates, formatters); + message = Private.ReplacePlaceHolders(message, region, customFunc, useHiddenStates, formatters); end if(message_type == "PRINT") then DEFAULT_CHAT_FRAME:AddMessage(message, r or 1, g or 1, b or 1); @@ -2759,7 +2724,7 @@ end local glow_frame_monitor local anchor_unitframe_monitor -WeakAuras.dyngroup_unitframe_monitor = {} +Private.dyngroup_unitframe_monitor = {} do local function frame_monitor_callback(event, frame, unit) local new_frame @@ -2801,12 +2766,12 @@ do new_frame = WeakAuras.GetUnitFrame(unit) or WeakAuras.HiddenFrames end if new_frame and new_frame ~= data.frame then - WeakAuras.AnchorFrame(data.data, region, data.parent) + Private.AnchorFrame(data.data, region, data.parent) end end end end - for regionData, data_frame in pairs(WeakAuras.dyngroup_unitframe_monitor) do + for regionData, data_frame in pairs(Private.dyngroup_unitframe_monitor) do if regionData.region and regionData.region.state and regionData.region.state.unit == unit and (data_frame ~= frame) == update_frame then @@ -2828,7 +2793,7 @@ do LGF.RegisterCallback("WeakAuras", "FRAME_UNIT_REMOVED", frame_monitor_callback) end -function WeakAuras.HandleGlowAction(actions, region) +function Private.HandleGlowAction(actions, region) if actions.glow_action and ( (actions.glow_frame_type == "UNITFRAME" and region.state.unit) @@ -2889,7 +2854,7 @@ function WeakAuras.HandleGlowAction(actions, region) end end -function WeakAuras.PerformActions(data, when, region) +function Private.PerformActions(data, when, region) if (paused or WeakAuras.IsOptionsOpen()) then return; end; @@ -2907,7 +2872,7 @@ function WeakAuras.PerformActions(data, when, region) if(actions.do_message and actions.message_type and actions.message) then local customFunc = Private.customActionsFunctions[data.id][when .. "_message"]; - WeakAuras.HandleChatAction(actions.message_type, actions.message, actions.message_dest, actions.message_channel, actions.r, actions.g, actions.b, region, customFunc, when, formatters); + Private.HandleChatAction(actions.message_type, actions.message, actions.message_dest, actions.message_channel, actions.r, actions.g, actions.b, region, customFunc, when, formatters); end if(actions.do_sound and actions.sound) then @@ -2927,7 +2892,7 @@ function WeakAuras.PerformActions(data, when, region) -- Apply start glow actions even if squelch_actions is true, but don't apply finish glow actions if actions.do_glow then - WeakAuras.HandleGlowAction(actions, region) + Private.HandleGlowAction(actions, region) end -- remove all glows on finish @@ -2946,7 +2911,7 @@ function WeakAuras.GetData(id) return id and db.displays[id]; end -function WeakAuras.GetTriggerSystem(data, triggernum) +local function GetTriggerSystem(data, triggernum) local triggerType = data.triggers[triggernum] and data.triggers[triggernum].trigger.type return triggerType and triggerTypes[triggerType] end @@ -3001,7 +2966,7 @@ local function wrapTriggerSystemFunction(functionName, mode) end return result; else -- triggernum >= 1 - local triggerSystem = WeakAuras.GetTriggerSystem(data, triggernum); + local triggerSystem = GetTriggerSystem(data, triggernum); if (not triggerSystem) then return false end @@ -3011,19 +2976,19 @@ local function wrapTriggerSystemFunction(functionName, mode) return func; end -WeakAuras.CanHaveDuration = wrapTriggerSystemFunction("CanHaveDuration", "firstValue"); -WeakAuras.CanHaveAuto = wrapTriggerSystemFunction("CanHaveAuto", "or"); -WeakAuras.CanHaveClones = wrapTriggerSystemFunction("CanHaveClones", "or"); -WeakAuras.CanHaveTooltip = wrapTriggerSystemFunction("CanHaveTooltip", "or"); -WeakAuras.GetNameAndIcon = wrapTriggerSystemFunction("GetNameAndIcon", "nameAndIcon"); -WeakAuras.GetTriggerDescription = wrapTriggerSystemFunction("GetTriggerDescription", "call"); +Private.CanHaveDuration = wrapTriggerSystemFunction("CanHaveDuration", "firstValue"); +Private.CanHaveAuto = wrapTriggerSystemFunction("CanHaveAuto", "or"); +Private.CanHaveClones = wrapTriggerSystemFunction("CanHaveClones", "or"); +Private.CanHaveTooltip = wrapTriggerSystemFunction("CanHaveTooltip", "or"); +Private.GetNameAndIcon = wrapTriggerSystemFunction("GetNameAndIcon", "nameAndIcon"); +Private.GetTriggerDescription = wrapTriggerSystemFunction("GetTriggerDescription", "call"); local wrappedGetOverlayInfo = wrapTriggerSystemFunction("GetOverlayInfo", "table"); -WeakAuras.GetAdditionalProperties = function(data, triggernum, ...) +Private.GetAdditionalProperties = function(data, triggernum, ...) local additionalProperties = "" for i = 1, #data.triggers do - local triggerSystem = WeakAuras.GetTriggerSystem(data, i); + local triggerSystem = GetTriggerSystem(data, i); if (triggerSystem) then local add = triggerSystem.GetAdditionalProperties(data, i) if (add and add ~= "") then @@ -3044,7 +3009,7 @@ WeakAuras.GetAdditionalProperties = function(data, triggernum, ...) return additionalProperties end -function WeakAuras.GetOverlayInfo(data, triggernum) +function Private.GetOverlayInfo(data, triggernum) local overlayInfo; if (data.controlledChildren) then overlayInfo = {}; @@ -3063,10 +3028,10 @@ function WeakAuras.GetOverlayInfo(data, triggernum) return overlayInfo; end -function WeakAuras.GetTriggerConditions(data) +function Private.GetTriggerConditions(data) local conditions = {}; for i = 1, #data.triggers do - local triggerSystem = WeakAuras.GetTriggerSystem(data, i); + local triggerSystem = GetTriggerSystem(data, i); if (triggerSystem) then conditions[i] = triggerSystem.GetTriggerConditions(data, i); conditions[i] = conditions[i] or {}; @@ -3082,7 +3047,7 @@ function WeakAuras.GetTriggerConditions(data) return conditions; end -function WeakAuras.CreateFallbackState(id, triggernum) +local function CreateFallbackState(id, triggernum) fallbacksStates[id] = fallbacksStates[id] or {}; fallbacksStates[id][triggernum] = fallbacksStates[id][triggernum] or {}; @@ -3091,7 +3056,7 @@ function WeakAuras.CreateFallbackState(id, triggernum) local state = states[""]; local data = db.displays[id]; - local triggerSystem = WeakAuras.GetTriggerSystem(data, triggernum); + local triggerSystem = GetTriggerSystem(data, triggernum); if (triggerSystem) then triggerSystem.CreateFallbackState(data, triggernum, state) state.trigger = data.triggers[triggernum].trigger @@ -3109,31 +3074,15 @@ function WeakAuras.CreateFallbackState(id, triggernum) return states; end -function WeakAuras.CanShowNameInfo(data) - if(data.regionType == "aurabar" or data.regionType == "icon" or data.regionType == "text") then - return true; - else - return false; - end -end - -function WeakAuras.CanShowStackInfo(data) - if(data.regionType == "aurabar" or data.regionType == "icon" or data.regionType == "text") then - return true; - else - return false; - end -end - local currentTooltipRegion; local currentTooltipOwner; -function WeakAuras.UpdateMouseoverTooltip(region) +local function UpdateMouseoverTooltip(region) if(region == currentTooltipRegion) then - WeakAuras.ShowMouseoverTooltip(currentTooltipRegion, currentTooltipOwner); + Private.ShowMouseoverTooltip(currentTooltipRegion, currentTooltipOwner); end end -function WeakAuras.ShowMouseoverTooltip(region, owner) +function Private.ShowMouseoverTooltip(region, owner) currentTooltipRegion = region; currentTooltipOwner = owner; @@ -3159,7 +3108,7 @@ function WeakAuras.ShowMouseoverTooltip(region, owner) end end -function WeakAuras.HideTooltip() +function Private.HideTooltip() currentTooltipRegion = nil; currentTooltipOwner = nil; GameTooltip:Hide(); @@ -3235,7 +3184,7 @@ function WeakAuras.ProfileDisplays(all) end end -function WeakAuras.ValueFromPath(data, path) +function Private.ValueFromPath(data, path) if not data then return nil end @@ -3246,11 +3195,11 @@ function WeakAuras.ValueFromPath(data, path) for i=2,#path do reducedPath[i-1] = path[i]; end - return WeakAuras.ValueFromPath(data[path[1]], reducedPath); + return Private.ValueFromPath(data[path[1]], reducedPath); end end -function WeakAuras.ValueToPath(data, path, value) +function Private.ValueToPath(data, path, value) if not data then return end @@ -3261,40 +3210,40 @@ function WeakAuras.ValueToPath(data, path, value) for i=2,#path do reducedPath[i-1] = path[i]; end - WeakAuras.ValueToPath(data[path[1]], reducedPath, value); + Private.ValueToPath(data[path[1]], reducedPath, value); end end -function WeakAuras.FixGroupChildrenOrderForGroup(data) +Private.frameLevels = {}; +local function SetFrameLevel(id, frameLevel) + if (Private.frameLevels[id] == frameLevel) then + return; + end + if (WeakAuras.regions[id] and WeakAuras.regions[id].region) then + Private.ApplyFrameLevel(WeakAuras.regions[id].region, frameLevel) + end + if (clones[id]) then + for i,v in pairs(clones[id]) do + Private.ApplyFrameLevel(v, frameLevel) + end + end + Private.frameLevels[id] = frameLevel; +end + +function Private.FixGroupChildrenOrderForGroup(data) local frameLevel = 5; for i=1, #data.controlledChildren do - WeakAuras.SetFrameLevel(data.controlledChildren[i], frameLevel); + SetFrameLevel(data.controlledChildren[i], frameLevel); frameLevel = frameLevel + 4; end end -WeakAuras.frameLevels = {}; -function WeakAuras.SetFrameLevel(id, frameLevel) - if (WeakAuras.frameLevels[id] == frameLevel) then - return; - end - if (WeakAuras.regions[id] and WeakAuras.regions[id].region) then - WeakAuras.ApplyFrameLevel(WeakAuras.regions[id].region, frameLevel) - end - if (clones[id]) then - for i,v in pairs(clones[id]) do - WeakAuras.ApplyFrameLevel(v, frameLevel) - end - end - WeakAuras.frameLevels[id] = frameLevel; +local function GetFrameLevelFor(id) + return Private.frameLevels[id] or 5; end -function WeakAuras.GetFrameLevelFor(id) - return WeakAuras.frameLevels[id] or 5; -end - -function WeakAuras.ApplyFrameLevel(region, frameLevel) - frameLevel = frameLevel or WeakAuras.GetFrameLevelFor(region.id) +function Private.ApplyFrameLevel(region, frameLevel) + frameLevel = frameLevel or GetFrameLevelFor(region.id) region:SetFrameLevel(frameLevel) if region.subRegions then for index, subRegion in pairs(region.subRegions) do @@ -3373,30 +3322,7 @@ do end); end -WeakAuras.dynFrame = dynFrame; - -function WeakAuras.SetDynamicIconCache(name, spellId, icon) - db.dynamicIconCache[name] = db.dynamicIconCache[name] or {}; - db.dynamicIconCache[name][spellId] = icon; -end - -function WeakAuras.GetDynamicIconCache(name) - if (db.dynamicIconCache[name]) then - local fallback = nil; - for spellId, icon in pairs(db.dynamicIconCache[name]) do - fallback = icon; - if (type(spellId) == "number" and IsSpellKnown(spellId)) then -- TODO save this information? - return db.dynamicIconCache[name][spellId]; - end - end - return fallback; - end - - if WeakAuras.spellCache then - return WeakAuras.spellCache.GetIcon(name); - end - return nil; -end +Private.dynFrame = dynFrame; function WeakAuras.RegisterTriggerSystem(types, triggerSystem) for _, v in ipairs(types) do @@ -3407,13 +3333,13 @@ end function WeakAuras.RegisterTriggerSystemOptions(types, func) for _, v in ipairs(types) do - WeakAuras.triggerTypesOptions[v] = func; + Private.triggerTypesOptions[v] = func; end end function WeakAuras.GetTriggerStateForTrigger(id, triggernum) if (triggernum == -1) then - return WeakAuras.GetGlobalConditionState(); + return Private.GetGlobalConditionState(); end triggerState[id][triggernum] = triggerState[id][triggernum] or {} return triggerState[id][triggernum]; @@ -3442,12 +3368,12 @@ do end end if changed then - WeakAuras.UpdatedTriggerState(id) + Private.UpdatedTriggerState(id) end end end - function WeakAuras.SetFakeStates() + function Private.SetFakeStates() if UpdateFakeTimesHandle then return end @@ -3458,26 +3384,26 @@ do changed = Private.SetAllStatesHidden(id, triggernum) or changed end if changed then - WeakAuras.UpdatedTriggerState(id) + Private.UpdatedTriggerState(id) end end UpdateFakeTimesHandle = timer:ScheduleRepeatingTimer(UpdateFakeTimers, 1) end - function WeakAuras.ClearFakeStates() + function Private.ClearFakeStates() timer:CancelTimer(UpdateFakeTimesHandle) for id in pairs(triggerState) do - WeakAuras.FakeStatesFor(id, false) + Private.FakeStatesFor(id, false) end end - function WeakAuras.FakeStatesFor(id, visible) + function Private.FakeStatesFor(id, visible) if visibleFakeStates[id] == visible then return visibleFakeStates[id] end if visible then visibleFakeStates[id] = true - WeakAuras.UpdateFakeStatesFor(id) + Private.UpdateFakeStatesFor(id) else visibleFakeStates[id] = false if triggerState[id] then @@ -3486,25 +3412,25 @@ do changed = Private.SetAllStatesHidden(id, triggernum) or changed end if changed then - WeakAuras.UpdatedTriggerState(id) + Private.UpdatedTriggerState(id) end end end return not visibleFakeStates[id] end - function WeakAuras.UpdateFakeStatesFor(id) + function Private.UpdateFakeStatesFor(id) if (WeakAuras.IsOptionsOpen() and visibleFakeStates[id]) then local data = WeakAuras.GetData(id) if (data) then for triggernum, trigger in ipairs(data.triggers) do Private.SetAllStatesHidden(id, triggernum) - local triggerSystem = WeakAuras.GetTriggerSystem(data, triggernum) + local triggerSystem = GetTriggerSystem(data, triggernum) if triggerSystem and triggerSystem.CreateFakeStates then triggerSystem.CreateFakeStates(id, triggernum) end end - WeakAuras.UpdatedTriggerState(id) + Private.UpdatedTriggerState(id) if WeakAuras.GetMoverSizerId() == id then WeakAuras.SetMoverSizer(id) end @@ -3533,7 +3459,7 @@ local function startStopTimers(id, cloneId, triggernum, state) if (state.show ~= false and state.show ~= nil) then state.show = false; state.changed = true; - WeakAuras.UpdatedTriggerState(id); + Private.UpdatedTriggerState(id); end end, state.expirationTime - GetTime()); @@ -3569,7 +3495,7 @@ local function ApplyStateToRegion(id, cloneId, region, parent) region.subRegionEvents:Notify("Update", region.state, region.states) - WeakAuras.UpdateMouseoverTooltip(region); + UpdateMouseoverTooltip(region); region:Expand(); if parent and parent.ActivateChild then parent:ActivateChild(id, cloneId) @@ -3665,7 +3591,7 @@ local function ApplyStatesToRegions(id, activeTrigger, states) end end -function WeakAuras.UpdatedTriggerState(id) +function Private.UpdatedTriggerState(id) if (not triggerState[id]) then return; end @@ -3700,7 +3626,7 @@ function WeakAuras.UpdatedTriggerState(id) -- Figure out which subtrigger is active, and if it changed local newActiveTrigger = triggerState[id].activeTriggerMode; - if (newActiveTrigger == WeakAuras.trigger_modes.first_active) then + if (newActiveTrigger == Private.trigger_modes.first_active) then -- Mode is first active trigger, so find a active trigger for i = 1, triggerState[id].numTriggers do if (triggerState[id].triggers[i]) then @@ -3717,7 +3643,7 @@ function WeakAuras.UpdatedTriggerState(id) local activeTriggerState = WeakAuras.GetTriggerStateForTrigger(id, newActiveTrigger); if (not next(activeTriggerState)) then if (show) then - activeTriggerState = WeakAuras.CreateFallbackState(id, newActiveTrigger) + activeTriggerState = CreateFallbackState(id, newActiveTrigger) else activeTriggerState = emptyState; end @@ -3730,7 +3656,7 @@ function WeakAuras.UpdatedTriggerState(id) end end if (needsFallback) then - activeTriggerState = WeakAuras.CreateFallbackState(id, newActiveTrigger); + activeTriggerState = CreateFallbackState(id, newActiveTrigger); end end @@ -3768,18 +3694,18 @@ function WeakAuras.UpdatedTriggerState(id) end end -function WeakAuras.RunCustomTextFunc(region, customFunc) +function Private.RunCustomTextFunc(region, customFunc) if not customFunc then return nil end local state = region.state Private.ActivateAuraEnvironment(region.id, region.cloneId, region.state, region.states); - local progress = WeakAuras.dynamic_texts.p.func(WeakAuras.dynamic_texts.p.get(state), state, 1) - local dur = WeakAuras.dynamic_texts.t.func( WeakAuras.dynamic_texts.t.get(state), state, 1) - local name = WeakAuras.dynamic_texts.n.func(WeakAuras.dynamic_texts.n.get(state)) - local icon = WeakAuras.dynamic_texts.i.func(WeakAuras.dynamic_texts.i.get(state)) - local stacks = WeakAuras.dynamic_texts.s.func(WeakAuras.dynamic_texts.s.get(state)) + local progress = Private.dynamic_texts.p.func(Private.dynamic_texts.p.get(state), state, 1) + local dur = Private.dynamic_texts.t.func(Private.dynamic_texts.t.get(state), state, 1) + local name = Private.dynamic_texts.n.func(Private.dynamic_texts.n.get(state)) + local icon = Private.dynamic_texts.i.func(Private.dynamic_texts.i.get(state)) + local stacks = Private.dynamic_texts.s.func(Private.dynamic_texts.s.get(state)) local expirationTime local duration @@ -3810,7 +3736,7 @@ local function ReplaceValuePlaceHolders(textStr, region, customFunc, state, form if string.sub(textStr, 1, 1) == "c" then local custom if customFunc then - custom = WeakAuras.RunCustomTextFunc(region, customFunc) + custom = Private.RunCustomTextFunc(region, customFunc) else custom = region.values.custom end @@ -3820,7 +3746,7 @@ local function ReplaceValuePlaceHolders(textStr, region, customFunc, state, form value = WeakAuras.EnsureString(custom[index]) end else - local variable = WeakAuras.dynamic_texts[textStr]; + local variable = Private.dynamic_texts[textStr]; if (not variable) then return nil; end @@ -3919,13 +3845,13 @@ local function ContainsPlaceHolders(textStr, symbolFunc) return false end -function WeakAuras.ContainsCustomPlaceHolder(textStr) +function Private.ContainsCustomPlaceHolder(textStr) return ContainsPlaceHolders(textStr, function(symbol) return string.match(symbol, "^c%d*$") end) end -function WeakAuras.ContainsPlaceHolders(textStr, toCheck) +function Private.ContainsPlaceHolders(textStr, toCheck) return ContainsPlaceHolders(textStr, function(symbol) if symbol:len() == 1 and toCheck:find(symbol, 1, true) then return true @@ -3943,7 +3869,7 @@ function WeakAuras.ContainsPlaceHolders(textStr, toCheck) end) end -function WeakAuras.ContainsAnyPlaceHolders(textStr) +function Private.ContainsAnyPlaceHolders(textStr) return ContainsPlaceHolders(textStr, function(symbol) return true end) end @@ -3982,7 +3908,7 @@ local function ValueForSymbol(symbol, region, customFunc, regionState, regionSta end end -function WeakAuras.ReplacePlaceHolders(textStr, region, customFunc, useHiddenStates, formatters) +function Private.ReplacePlaceHolders(textStr, region, customFunc, useHiddenStates, formatters) local regionValues = region.values; local regionState = region.state or {}; local regionStates = region.states or {}; @@ -4063,7 +3989,7 @@ function WeakAuras.ReplacePlaceHolders(textStr, region, customFunc, useHiddenSta return textStr; end -function WeakAuras.ParseTextStr(textStr, symbolCallback) +function Private.ParseTextStr(textStr, symbolCallback) if not textStr then return end @@ -4110,10 +4036,10 @@ function WeakAuras.ParseTextStr(textStr, symbolCallback) end end -function WeakAuras.CreateFormatters(input, getter) +function Private.CreateFormatters(input, getter) local seenSymbols = {} local formatters = {} - WeakAuras.ParseTextStr(input, function(symbol) + Private.ParseTextStr(input, function(symbol) if not seenSymbols[symbol] then local triggerNum, sym = string.match(symbol, "(.+)%.(.+)") sym = sym or symbol @@ -4122,8 +4048,8 @@ function WeakAuras.CreateFormatters(input, getter) else local default = (sym == "p" or sym == "t") and "timed" or "none" local selectedFormat = getter(symbol .. "_format", default) - if (WeakAuras.format_types[selectedFormat]) then - formatters[symbol] = WeakAuras.format_types[selectedFormat].CreateFormatter(symbol, getter) + if (Private.format_types[selectedFormat]) then + formatters[symbol] = Private.format_types[selectedFormat].CreateFormatter(symbol, getter) end end end @@ -4319,7 +4245,7 @@ local function ensureMouseFrame() mouseFrame:OptionsClosed(); end - WeakAuras.mouseFrame = mouseFrame; + Private.mouseFrame = mouseFrame; end local postPonedAnchors = {}; @@ -4338,7 +4264,7 @@ local function tryAnchorAgain() if (data.parent and regions[data.parent]) then parent = regions[data.parent].region; end - WeakAuras.AnchorFrame(data, region, parent); + Private.AnchorFrame(data, region, parent); end end end @@ -4410,13 +4336,13 @@ local function GetAnchorFrame(data, region, parent) end if (anchorFrameType == "CUSTOM" and region.customAnchorFunc) then - WeakAuras.StartProfileSystem("custom region anchor") - WeakAuras.StartProfileAura(region.id) + Private.StartProfileSystem("custom region anchor") + Private.StartProfileAura(region.id) Private.ActivateAuraEnvironment(region.id, region.cloneId, region.state) local ok, frame = xpcall(region.customAnchorFunc, geterrorhandler()) Private.ActivateAuraEnvironment() - WeakAuras.StopProfileSystem("custom region anchor") - WeakAuras.StopProfileAura(region.id) + Private.StopProfileSystem("custom region anchor") + Private.StopProfileAura(region.id) if ok and frame then return frame elseif WeakAuras.IsOptionsOpen() then @@ -4431,13 +4357,13 @@ end local anchorFrameDeferred = {} -function WeakAuras.AnchorFrame(data, region, parent) +function Private.AnchorFrame(data, region, parent) if data.anchorFrameType == "CUSTOM" and (data.regionType == "group" or data.regionType == "dynamicgroup") and not WeakAuras.IsLoginFinished() and not anchorFrameDeferred[data.id] then - loginQueue[#loginQueue + 1] = {WeakAuras.AnchorFrame, {data, region, parent}} + loginQueue[#loginQueue + 1] = {Private.AnchorFrame, {data, region, parent}} anchorFrameDeferred[data.id] = true else local anchorParent = GetAnchorFrame(data, region, parent); @@ -4472,9 +4398,9 @@ function WeakAuras.AnchorFrame(data, region, parent) local frameStrata = region:GetParent():GetFrameStrata() region:SetFrameStrata(frameStrata ~= "UNKNOWN" and frameStrata or "BACKGROUND"); else - region:SetFrameStrata(WeakAuras.frame_strata_types[data.frameStrata]); + region:SetFrameStrata(Private.frame_strata_types[data.frameStrata]); end - WeakAuras.ApplyFrameLevel(region) + Private.ApplyFrameLevel(region) anchorFrameDeferred[data.id] = nil end end @@ -4492,22 +4418,22 @@ end function WeakAuras.SetModel(frame, model_path, isUnit, isDisplayInfo) if isDisplayInfo then - frame:SetDisplayInfo(tonumber(model_path)) + pcall(frame.SetDisplayInfo, frame, tonumber(model_path)) elseif isUnit then - frame:SetUnit(model_path) + pcall(frame.SetUnit, frame, model_path) else - frame:SetModel(model_path) + pcall(frame.SetModel, frame, model_path) end end -function WeakAuras.IsCLEUSubevent(subevent) - if WeakAuras.subevent_prefix_types[subevent] then +function Private.IsCLEUSubevent(subevent) + if Private.subevent_prefix_types[subevent] then return true else - for prefix in pairs(WeakAuras.subevent_prefix_types) do + for prefix in pairs(Private.subevent_prefix_types) do if subevent:match(prefix) then local suffix = subevent:sub(#prefix + 1) - if WeakAuras.subevent_suffix_types[suffix] then + if Private.subevent_suffix_types[suffix] then return true end end @@ -4556,7 +4482,7 @@ function WeakAuras.ReplaceRaidMarkerSymbols(txt) end end -function WeakAuras.ReplaceLocalizedRaidMarkers(txt) +function Private.ReplaceLocalizedRaidMarkers(txt) local start = 1 while true do diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua index 5e1053c..2b53390 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasDisplayButton.lua @@ -50,32 +50,25 @@ local function copyAuraPart(source, destination, part) end end if (part == "trigger" or all) and not IsRegionAGroup(source) then - destination.triggers = {}; - WeakAuras.DeepCopy(source.triggers, destination.triggers); + destination.triggers = CopyTable(source.triggers); end if (part == "condition" or all) and not IsRegionAGroup(source) then - destination.conditions = {}; - WeakAuras.DeepCopy(source.conditions, destination.conditions); + destination.conditions = CopyTable(source.conditions); end if (part == "load" or all) and not IsRegionAGroup(source) then - destination.load = {}; - WeakAuras.DeepCopy(source.load, destination.load); + destination.load = CopyTable(source.load); end if (part == "action" or all) and not IsRegionAGroup(source) then - destination.actions = {}; - WeakAuras.DeepCopy(source.actions, destination.actions); + destination.actions = CopyTable(source.actions); end if (part == "animation" or all) and not IsRegionAGroup(source) then - destination.animation = {}; - WeakAuras.DeepCopy(source.animation, destination.animation); + destination.animation = CopyTable(source.animation); end if (part == "authorOptions" or all) and not IsRegionAGroup(source) then - destination.authorOptions = {}; - WeakAuras.DeepCopy(source.authorOptions, destination.authorOptions); + destination.authorOptions = CopyTable(source.authorOptions); end if (part == "config" or all) and not IsRegionAGroup(source) then - destination.config = {}; - WeakAuras.DeepCopy(source.config, destination.config); + destination.config = CopyTable(source.config); end end @@ -83,8 +76,7 @@ end local function CopyToClipboard(part, description) clipboard.part = part; clipboard.pasteText = description; - clipboard.source = {}; - WeakAuras.DeepCopy(clipboard.current, clipboard.source); + clipboard.source = CopyTable(clipboard.current); end clipboard.pasteMenuEntry = { @@ -106,7 +98,7 @@ clipboard.pasteMenuEntry = { end WeakAuras.FillOptions() - WeakAuras.ScanForLoads({[clipboard.current.id] = true}); + OptionsPrivate.Private.ScanForLoads({[clipboard.current.id] = true}); WeakAuras.SortDisplayButtons(); WeakAuras.PickDisplay(clipboard.current.id); WeakAuras.UpdateDisplayButton(clipboard.current.id); @@ -466,7 +458,7 @@ local function GetDropTarget() end local function Show_DropIndicator(id) - local indicator = WeakAuras.DropIndicator() + local indicator = OptionsPrivate.DropIndicator() local source = WeakAuras.GetDisplayButton(id) local target, pos if source then @@ -517,10 +509,10 @@ local methods = { function self.callbacks.OnClickNormal(_, mouseButton) if(IsControlKeyDown() and not data.controlledChildren) then - if (WeakAuras.IsDisplayPicked(data.id)) then - WeakAuras.ClearPick(data.id); + if (OptionsPrivate.IsDisplayPicked(data.id)) then + OptionsPrivate.ClearPick(data.id); else - WeakAuras.PickDisplayMultiple(data.id); + OptionsPrivate.PickDisplayMultiple(data.id); end self:ReloadTooltip(); elseif(IsShiftKeyDown()) then @@ -537,23 +529,23 @@ local methods = { editbox:Insert("[WeakAuras: "..fullName.." - "..data.id.."]"); elseif not data.controlledChildren then -- select all buttons between 1st select and current - WeakAuras.PickDisplayMultipleShift(data.id) + OptionsPrivate.PickDisplayMultipleShift(data.id) end else if(mouseButton == "RightButton") then Hide_Tooltip(); - if(WeakAuras.IsDisplayPicked(data.id) and WeakAuras.IsPickedMultiple()) then - EasyMenu(WeakAuras.MultipleDisplayTooltipMenu(), WeakAuras_DropDownMenu, self.frame, 0, 0, "MENU"); + if(OptionsPrivate.IsDisplayPicked(data.id) and OptionsPrivate.IsPickedMultiple()) then + EasyMenu(OptionsPrivate.MultipleDisplayTooltipMenu(), WeakAuras_DropDownMenu, self.frame, 0, 0, "MENU"); else UpdateClipboardMenuEntry(data); EasyMenu(self.menu, WeakAuras_DropDownMenu, self.frame, 0, 0, "MENU"); - if not(WeakAuras.IsDisplayPicked(data.id)) then + if not(OptionsPrivate.IsDisplayPicked(data.id)) then WeakAuras.PickDisplay(data.id); end end else - if (WeakAuras.IsDisplayPicked(data.id)) then - WeakAuras.ClearPicks(); + if (OptionsPrivate.IsDisplayPicked(data.id)) then + OptionsPrivate.ClearPicks(); else WeakAuras.PickDisplay(data.id); end @@ -602,46 +594,46 @@ local methods = { WeakAuras.Add(data); WeakAuras.ClearAndUpdateOptions(data.id) self.callbacks.UpdateExpandButton(); - WeakAuras.SetGrouping(); + OptionsPrivate.SetGrouping(); WeakAuras.UpdateDisplayButton(data); WeakAuras.ClearAndUpdateOptions(data.id); WeakAuras.FillOptions(); WeakAuras.UpdateGroupOrders(data); WeakAuras.SortDisplayButtons(); self:ReloadTooltip(); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end function self.callbacks.OnClickGroupingSelf() - WeakAuras.SetGrouping(); + OptionsPrivate.SetGrouping(); self:ReloadTooltip(); end function self.callbacks.OnGroupClick() - WeakAuras.SetGrouping(data); + OptionsPrivate.SetGrouping(data); end function self.callbacks.OnDeleteClick() if (WeakAuras.IsImporting()) then return end; local toDelete = {data} local parents = data.parent and {[data.parent] = true} - WeakAuras.ConfirmDelete(toDelete, parents) + OptionsPrivate.ConfirmDelete(toDelete, parents) end function self.callbacks.OnDuplicateClick() if (WeakAuras.IsImporting()) then return end; if data.controlledChildren then - local new_idGroup = WeakAuras.DuplicateAura(data) + local new_idGroup = OptionsPrivate.DuplicateAura(data) for index, childId in pairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId) - WeakAuras.DuplicateAura(childData, new_idGroup) + OptionsPrivate.DuplicateAura(childData, new_idGroup) end WeakAuras.SortDisplayButtons() - WeakAuras.PickAndEditDisplay(new_idGroup) + OptionsPrivate.PickAndEditDisplay(new_idGroup) else - local new_id = WeakAuras.DuplicateAura(data) + local new_id = OptionsPrivate.DuplicateAura(data) WeakAuras.SortDisplayButtons() - WeakAuras.PickAndEditDisplay(new_id) + OptionsPrivate.PickAndEditDisplay(new_id) end end @@ -660,11 +652,11 @@ local methods = { end end tinsert(toDelete, data) - WeakAuras.ConfirmDelete(toDelete); + OptionsPrivate.ConfirmDelete(toDelete); end function self.callbacks.OnUngroupClick() - WeakAuras.Ungroup(data); + OptionsPrivate.Ungroup(data); end function self.callbacks.OnUpGroupClick() @@ -693,8 +685,8 @@ local methods = { WeakAuras.SortDisplayButtons(); local updata = {duration = 0.15, type = "custom", use_translate = true, x = 0, y = -32}; local downdata = {duration = 0.15, type = "custom", use_translate = true, x = 0, y = 32}; - WeakAuras.Animate("button", WeakAuras.GetData(parentData.controlledChildren[index-1]).uid, "main", updata, self.frame, true, function() WeakAuras.SortDisplayButtons() end); - WeakAuras.Animate("button", WeakAuras.GetData(parentData.controlledChildren[index]).uid, "main", downdata, otherbutton.frame, true, function() WeakAuras.SortDisplayButtons() end); + OptionsPrivate.Private.Animate("button", WeakAuras.GetData(parentData.controlledChildren[index-1]).uid, "main", updata, self.frame, true, function() WeakAuras.SortDisplayButtons() end); + OptionsPrivate.Private.Animate("button", WeakAuras.GetData(parentData.controlledChildren[index]).uid, "main", downdata, otherbutton.frame, true, function() WeakAuras.SortDisplayButtons() end); WeakAuras.UpdateDisplayButton(parentData); WeakAuras.FillOptions() end @@ -732,8 +724,8 @@ local methods = { WeakAuras.SortDisplayButtons() local updata = {duration = 0.15, type = "custom", use_translate = true, x = 0, y = -32}; local downdata = {duration = 0.15, type = "custom", use_translate = true, x = 0, y = 32}; - WeakAuras.Animate("button", WeakAuras.GetData(parentData.controlledChildren[index+1]).uid, "main", downdata, self.frame, true, function() WeakAuras.SortDisplayButtons() end); - WeakAuras.Animate("button", WeakAuras.GetData(parentData.controlledChildren[index]).uid, "main", updata, otherbutton.frame, true, function() WeakAuras.SortDisplayButtons() end); + OptionsPrivate.Private.Animate("button", WeakAuras.GetData(parentData.controlledChildren[index+1]).uid, "main", downdata, self.frame, true, function() WeakAuras.SortDisplayButtons() end); + OptionsPrivate.Private.Animate("button", WeakAuras.GetData(parentData.controlledChildren[index]).uid, "main", updata, otherbutton.frame, true, function() WeakAuras.SortDisplayButtons() end); WeakAuras.UpdateDisplayButton(parentData); WeakAuras.FillOptions() end @@ -746,7 +738,7 @@ local methods = { end function self.callbacks.OnViewClick() - WeakAuras.PauseAllDynamicGroups(); + OptionsPrivate.Private.PauseAllDynamicGroups(); if(self.view.func() == 2) then for index, childId in ipairs(data.controlledChildren) do @@ -758,7 +750,7 @@ local methods = { end end - WeakAuras.ResumeAllDynamicGroups(); + OptionsPrivate.Private.ResumeAllDynamicGroups(); end function self.callbacks.ViewTest() @@ -807,26 +799,26 @@ local methods = { local oldid = data.id; if not(newid == oldid) then WeakAuras.Rename(data, newid); - WeakAuras.HandleRename(data, oldid, newid) + OptionsPrivate.HandleRename(data, oldid, newid) end end function self.callbacks.OnDragStart() if WeakAuras.IsImporting() or self:IsGroup() then return end; - if #WeakAuras.tempGroup.controlledChildren == 0 then + if #OptionsPrivate.tempGroup.controlledChildren == 0 then WeakAuras.PickDisplay(data.id); end - WeakAuras.SetDragging(data); + OptionsPrivate.SetDragging(data); end function self.callbacks.OnDragStop() if not self.dragging then return end - WeakAuras.SetDragging(data, true) + OptionsPrivate.SetDragging(data, true) end function self.callbacks.OnKeyDown(self, key) if (key == "ESCAPE") then - WeakAuras.SetDragging(); + OptionsPrivate.SetDragging(); end end @@ -906,7 +898,7 @@ local methods = { text = regionData.displayName, notCheckable = true, func = function() - WeakAuras.ConvertDisplay(data, regionType); + OptionsPrivate.ConvertDisplay(data, regionType); WeakAuras_DropDownMenu:Hide(); end }); @@ -929,12 +921,12 @@ local methods = { tinsert(self.menu, { text = L["Export to string..."], notCheckable = true, - func = function() WeakAuras.ExportToString(data.id) end + func = function() OptionsPrivate.ExportToString(data.id) end }); tinsert(self.menu, { text = L["Export to Lua table..."], notCheckable = true, - func = function() WeakAuras.ExportToTable(data.id) end + func = function() OptionsPrivate.ExportToTable(data.id) end }); if WeakAurasCompanion then @@ -1060,14 +1052,14 @@ local methods = { namestable[1] = L["No Children"]; end else - WeakAuras.GetTriggerDescription(data, -1, namestable) + OptionsPrivate.Private.GetTriggerDescription(data, -1, namestable) end - if(WeakAuras.CanHaveClones(data)) then + if(OptionsPrivate.Private.CanHaveClones(data)) then tinsert(namestable, {" ", "|cFF00FF00"..L["Auto-cloning enabled"]}) end - if(WeakAuras.IsDefinedByAddon(data.id)) then + if(OptionsPrivate.Private.IsDefinedByAddon(data.id)) then tinsert(namestable, " "); - tinsert(namestable, {" ", "|cFF00FFFF"..L["Addon"]..": "..WeakAuras.IsDefinedByAddon(data.id)}); + tinsert(namestable, {" ", "|cFF00FFFF"..L["Addon"]..": "..OptionsPrivate.Private.IsDefinedByAddon(data.id)}); end local hasDescription = data.desc and data.desc ~= ""; @@ -1102,8 +1094,8 @@ local methods = { self:SetDescription({data.id, displayName}, unpack(namestable)); end, ["ReloadTooltip"] = function(self)if( - WeakAuras.IsPickedMultiple() and WeakAuras.IsDisplayPicked(self.data.id)) then - Show_Long_Tooltip(self.frame, WeakAuras.MultipleDisplayTooltipDesc()); + OptionsPrivate.IsPickedMultiple() and OptionsPrivate.IsDisplayPicked(self.data.id)) then + Show_Long_Tooltip(self.frame, OptionsPrivate.MultipleDisplayTooltipDesc()); else Show_Long_Tooltip(self.frame, self.frame.description); end @@ -1250,7 +1242,7 @@ local methods = { end) Show_DropIndicator(id) end - WeakAuras.UpdateButtonsScroll() + OptionsPrivate.UpdateButtonsScroll() end, ["Drop"] = function(self, reset) Show_DropIndicator() @@ -1281,7 +1273,7 @@ local methods = { -- exit if we have no target or only want to reset self.multi = nil if reset or not target then - return WeakAuras.UpdateButtonsScroll() + return OptionsPrivate.UpdateButtonsScroll() end local action = GetAction(target, area, self) if action then @@ -1370,7 +1362,7 @@ local methods = { end, ["Expand"] = function(self, reloadTooltip) self.expand:Enable(); - WeakAuras.SetCollapsed(self.data.id, "displayButton", "", false) + OptionsPrivate.SetCollapsed(self.data.id, "displayButton", "", false) self.expand:SetNormalTexture("Interface\\BUTTONS\\UI-MinusButton-Up.blp"); self.expand:SetPushedTexture("Interface\\BUTTONS\\UI-MinusButton-Down.blp"); self.expand.title = L["Collapse"]; @@ -1384,7 +1376,7 @@ local methods = { end, ["Collapse"] = function(self, reloadTooltip) self.expand:Enable(); - WeakAuras.SetCollapsed(self.data.id, "displayButton", "", true) + OptionsPrivate.SetCollapsed(self.data.id, "displayButton", "", true) self.expand:SetNormalTexture("Interface\\BUTTONS\\UI-PlusButton-Up.blp"); self.expand:SetPushedTexture("Interface\\BUTTONS\\UI-PlusButton-Down.blp"); self.expand.title = L["Expand"]; @@ -1400,7 +1392,7 @@ local methods = { self.expand.func = func; end, ["GetExpanded"] = function(self) - return not WeakAuras.IsCollapsed(self.data.id, "displayButton", "", true) + return not OptionsPrivate.IsCollapsed(self.data.id, "displayButton", "", true) end, ["DisableExpand"] = function(self) self.expand:Disable(); @@ -1798,8 +1790,8 @@ local function Constructor() button.description = {}; button:SetScript("OnEnter", function() - if(WeakAuras.IsPickedMultiple() and WeakAuras.IsDisplayPicked(button.id)) then - Show_Long_Tooltip(button, WeakAuras.MultipleDisplayTooltipDesc()); + if(OptionsPrivate.IsPickedMultiple() and OptionsPrivate.IsDisplayPicked(button.id)) then + Show_Long_Tooltip(button, OptionsPrivate.MultipleDisplayTooltipDesc()); else if not(button.terribleCodeOrganizationHackTable.IsGroupingOrCopying()) then button.terribleCodeOrganizationHackTable.SetNormalTooltip(); @@ -1831,9 +1823,9 @@ local function Constructor() if(priority >= self.visibility) then self.visibility = priority; if(self.region and self.region.Expand) then - WeakAuras.FakeStatesFor(self.region.id, true) - if (WeakAuras.mouseFrame) then - WeakAuras.mouseFrame:expand(self.region.id); + OptionsPrivate.Private.FakeStatesFor(self.region.id, true) + if (OptionsPrivate.Private.mouseFrame) then + OptionsPrivate.Private.mouseFrame:expand(self.region.id); end end end @@ -1848,9 +1840,9 @@ local function Constructor() if(priority >= self.visibility) then self.visibility = 0; if(self.region and self.region.Collapse) then - WeakAuras.FakeStatesFor(self.region.id, false) - if (WeakAuras.mouseFrame) then - WeakAuras.mouseFrame:collapse(self.region.id); + OptionsPrivate.Private.FakeStatesFor(self.region.id, false) + if (OptionsPrivate.Private.mouseFrame) then + OptionsPrivate.Private.mouseFrame:collapse(self.region.id); end end end diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpand.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpand.lua index c8b453a..ac9ee6e 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpand.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpand.lua @@ -3,7 +3,7 @@ Button Widget for our Expand button -------------------------------------------------------------------------------]] if not WeakAuras.IsCorrectVersion() then return end -local Type, Version = "WeakAurasExpand", 1 +local Type, Version = "WeakAurasExpand", 2 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpandAnchor.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpandAnchor.lua index e5862f2..8f2b5d9 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpandAnchor.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpandAnchor.lua @@ -1,7 +1,9 @@ --[[----------------------------------------------------------------------------- Anchor for a Expandable section -------------------------------------------------------------------------------]] -local Type, Version = "WeakAurasExpandAnchor", 1 +if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... +local Type, Version = "WeakAurasExpandAnchor", 2 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end @@ -27,8 +29,8 @@ local function OnFrameShow(frame) local self = frame.obj local option = self.userdata.option if option and option.arg and option.arg.expanderName then - WeakAuras.expanderAnchors[option.arg.expanderName] = self - local otherWidget = WeakAuras.expanderButtons[option.arg.expanderName] + OptionsPrivate.expanderAnchors[option.arg.expanderName] = self + local otherWidget = OptionsPrivate.expanderButtons[option.arg.expanderName] if otherWidget then otherWidget:SetAnchor(self) end @@ -39,9 +41,9 @@ local function OnFrameHide(frame) local self = frame.obj local option = self.userdata.option if option and option.arg and option.arg.expanderName then - WeakAuras.expanderAnchors[option.arg.expanderName] = nil + OptionsPrivate.expanderAnchors[option.arg.expanderName] = nil - local otherWidget = WeakAuras.expanderButtons[option.arg.expanderName] + local otherWidget = OptionsPrivate.expanderButtons[option.arg.expanderName] if otherWidget then otherWidget:SetAnchor(nil) end diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpandSmall.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpandSmall.lua index 0eaa169..5593e51 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpandSmall.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasExpandSmall.lua @@ -2,8 +2,9 @@ Button Widget for our Expand button -------------------------------------------------------------------------------]] if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... -local Type, Version = "WeakAurasExpandSmall", 1 +local Type, Version = "WeakAurasExpandSmall", 2 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end @@ -144,9 +145,9 @@ local function OnFrameShow(frame) local self = frame.obj local option = self.userdata.option if option and option.arg and option.arg.expanderName then - WeakAuras.expanderButtons[option.arg.expanderName] = self + OptionsPrivate.expanderButtons[option.arg.expanderName] = self - local otherWidget = WeakAuras.expanderAnchors[option.arg.expanderName] + local otherWidget = OptionsPrivate.expanderAnchors[option.arg.expanderName] if otherWidget then self:SetAnchor(otherWidget) end @@ -157,9 +158,9 @@ local function OnFrameHide(frame) local self = frame.obj local option = self.userdata.option if option and option.arg and option.arg.expanderName then - WeakAuras.expanderButtons[option.arg.expanderName] = nil + OptionsPrivate.expanderButtons[option.arg.expanderName] = nil - local otherWidget = WeakAuras.expanderAnchors[option.arg.expanderName] + local otherWidget = OptionsPrivate.expanderAnchors[option.arg.expanderName] if otherWidget then self:SetAnchor(nil) end diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasMultiLineEditBox.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasMultiLineEditBox.lua index 1410832..e179ab2 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasMultiLineEditBox.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasMultiLineEditBox.lua @@ -1,6 +1,6 @@ if not WeakAuras.IsCorrectVersion() then return end -local Type, Version = "WeakAurasMultiLineEditBox", 34 +local Type, Version = "WeakAurasMultiLineEditBox", 35 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasSnippetButton.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasSnippetButton.lua index d655886..74ae0cb 100644 --- a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasSnippetButton.lua +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasSnippetButton.lua @@ -234,4 +234,4 @@ local function Constructor() return AceGUI:RegisterAsWidget(widget) end -AceGUI:RegisterWidgetType(Type, Constructor, Version) \ No newline at end of file +AceGUI:RegisterWidgetType(Type, Constructor, Version) diff --git a/WeakAurasOptions/ActionOptions.lua b/WeakAurasOptions/ActionOptions.lua index 9dbd2c2..46f1039 100644 --- a/WeakAurasOptions/ActionOptions.lua +++ b/WeakAurasOptions/ActionOptions.lua @@ -3,19 +3,16 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L -local removeFuncs = WeakAuras.commonOptions.removeFuncs -local replaceNameDescFuncs = WeakAuras.commonOptions.replaceNameDescFuncs -local replaceImageFuncs = WeakAuras.commonOptions.replaceImageFuncs -local replaceValuesFuncs = WeakAuras.commonOptions.replaceValuesFuncs -local disabledAll = WeakAuras.commonOptions.CreateDisabledAll("action") -local hiddenAll = WeakAuras.commonOptions.CreateHiddenAll("action") -local getAll = WeakAuras.commonOptions.CreateGetAll("action") -local setAll = WeakAuras.commonOptions.CreateSetAll("action", getAll) +local removeFuncs = OptionsPrivate.commonOptions.removeFuncs +local replaceNameDescFuncs = OptionsPrivate.commonOptions.replaceNameDescFuncs +local replaceImageFuncs = OptionsPrivate.commonOptions.replaceImageFuncs +local replaceValuesFuncs = OptionsPrivate.commonOptions.replaceValuesFuncs +local disabledAll = OptionsPrivate.commonOptions.CreateDisabledAll("action") +local hiddenAll = OptionsPrivate.commonOptions.CreateHiddenAll("action") +local getAll = OptionsPrivate.commonOptions.CreateGetAll("action") +local setAll = OptionsPrivate.commonOptions.CreateSetAll("action", getAll) -local send_chat_message_types = WeakAuras.send_chat_message_types; -local sound_types = WeakAuras.sound_types; - -function WeakAuras.GetActionOptions(data) +function OptionsPrivate.GetActionOptions(data) local action = { type = "group", name = L["Actions"], @@ -93,7 +90,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Message Type"], order = 2, - values = send_chat_message_types, + values = OptionsPrivate.Private.send_chat_message_types, disabled = function() return not data.actions.start.do_message end, control = "WeakAurasSortedDropdown" }, @@ -135,7 +132,7 @@ function WeakAuras.GetActionOptions(data) order = 4, disabled = function() return not data.actions.start.do_message end, desc = function() - return L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(data) + return L["Dynamic text tooltip"] .. OptionsPrivate.Private.GetAdditionalProperties(data) end, }, -- texteditor added later @@ -172,7 +169,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Sound"], order = 8.4, - values = sound_types, + values = OptionsPrivate.Private.sound_types, disabled = function() return not data.actions.start.do_sound end, control = "WeakAurasSortedDropdown" }, @@ -181,7 +178,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Sound Channel"], order = 8.5, - values = WeakAuras.sound_channel_types, + values = OptionsPrivate.Private.sound_channel_types, disabled = function() return not data.actions.start.do_sound end, get = function() return data.actions.start.sound_channel or "Master" end }, @@ -212,7 +209,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Glow Action"], order = 10.2, - values = WeakAuras.glow_action_types, + values = OptionsPrivate.Private.glow_action_types, disabled = function() return not data.actions.start.do_glow end }, start_glow_frame_type = { @@ -248,7 +245,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Glow Type"], order = 10.4, - values = WeakAuras.glow_types, + values = OptionsPrivate.Private.glow_types, hidden = function() return not data.actions.start.do_glow or data.actions.start.glow_action ~= "show" @@ -274,9 +271,9 @@ function WeakAuras.GetActionOptions(data) func = function() if(data.controlledChildren and data.controlledChildren[1]) then WeakAuras.PickDisplay(data.controlledChildren[1]); - WeakAuras.StartFrameChooser(WeakAuras.GetData(data.controlledChildren[1]), {"actions", "start", "glow_frame"}); + OptionsPrivate.StartFrameChooser(WeakAuras.GetData(data.controlledChildren[1]), {"actions", "start", "glow_frame"}); else - WeakAuras.StartFrameChooser(data, {"actions", "start", "glow_frame"}); + OptionsPrivate.StartFrameChooser(data, {"actions", "start", "glow_frame"}); end end }, @@ -465,7 +462,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Message Type"], order = 22, - values = send_chat_message_types, + values = OptionsPrivate.Private.send_chat_message_types, disabled = function() return not data.actions.finish.do_message end, control = "WeakAurasSortedDropdown" }, @@ -507,7 +504,7 @@ function WeakAuras.GetActionOptions(data) order = 24, disabled = function() return not data.actions.finish.do_message end, desc = function() - return L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(data) + return L["Dynamic text tooltip"] .. OptionsPrivate.Private.GetAdditionalProperties(data) end, }, -- texteditor added below @@ -522,7 +519,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Sound"], order = 28.1, - values = sound_types, + values = OptionsPrivate.Private.sound_types, disabled = function() return not data.actions.finish.do_sound end, control = "WeakAurasSortedDropdown" }, @@ -531,7 +528,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Sound Channel"], order = 28.5, - values = WeakAuras.sound_channel_types, + values = OptionsPrivate.Private.sound_channel_types, disabled = function() return not data.actions.finish.do_sound end, get = function() return data.actions.finish.sound_channel or "Master" end }, @@ -562,7 +559,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Glow Action"], order = 30.2, - values = WeakAuras.glow_action_types, + values = OptionsPrivate.Private.glow_action_types, disabled = function() return not data.actions.finish.do_glow end }, finish_glow_frame_type = { @@ -598,7 +595,7 @@ function WeakAuras.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Glow Type"], order = 30.4, - values = WeakAuras.glow_types, + values = OptionsPrivate.Private.glow_types, hidden = function() return not data.actions.finish.do_glow or data.actions.finish.glow_action ~= "show" @@ -624,9 +621,9 @@ function WeakAuras.GetActionOptions(data) func = function() if(data.controlledChildren and data.controlledChildren[1]) then WeakAuras.PickDisplay(data.controlledChildren[1]); - WeakAuras.StartFrameChooser(WeakAuras.GetData(data.controlledChildren[1]), {"actions", "finish", "glow_frame"}); + OptionsPrivate.StartFrameChooser(WeakAuras.GetData(data.controlledChildren[1]), {"actions", "finish", "glow_frame"}); else - WeakAuras.StartFrameChooser(data, {"actions", "finish", "glow_frame"}); + OptionsPrivate.StartFrameChooser(data, {"actions", "finish", "glow_frame"}); end end }, @@ -810,18 +807,18 @@ function WeakAuras.GetActionOptions(data) -- Text format option helpers - WeakAuras.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "init", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-init", + OptionsPrivate.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "init", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-init", 0.011, function() return not data.actions.init.do_custom end, {"actions", "init", "custom"}, true); - WeakAuras.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "start_message", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#chat-message---custom-code", - 5, function() return not (data.actions.start.do_message and WeakAuras.ContainsCustomPlaceHolder(data.actions.start.message)) end, {"actions", "start", "message_custom"}, false); + OptionsPrivate.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "start_message", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#chat-message---custom-code", + 5, function() return not (data.actions.start.do_message and OptionsPrivate.Private.ContainsCustomPlaceHolder(data.actions.start.message)) end, {"actions", "start", "message_custom"}, false); local startHidden = function() - return WeakAuras.IsCollapsed("format_option", "actions", "start_message", true) + return OptionsPrivate.IsCollapsed("format_option", "actions", "start_message", true) end local startSetHidden = function(hidden) - WeakAuras.SetCollapsed("format_option", "actions", "start_message", hidden) + OptionsPrivate.SetCollapsed("format_option", "actions", "start_message", hidden) end local startGet = function(key) @@ -863,25 +860,25 @@ function WeakAuras.GetActionOptions(data) local startGet = function(key) return childData.actions.start["message_format_" .. key] end - WeakAuras.AddTextFormatOption(childData.actions and childData.actions.start.message, true, startGet, startAddOption, startHidden, startSetHidden) + OptionsPrivate.AddTextFormatOption(childData.actions and childData.actions.start.message, true, startGet, startAddOption, startHidden, startSetHidden) end else - WeakAuras.AddTextFormatOption(data.actions and data.actions.start.message, true, startGet, startAddOption, startHidden, startSetHidden) + OptionsPrivate.AddTextFormatOption(data.actions and data.actions.start.message, true, startGet, startAddOption, startHidden, startSetHidden) end - WeakAuras.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "start", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-show", + OptionsPrivate.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "start", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-show", 13, function() return not data.actions.start.do_custom end, {"actions", "start", "custom"}, true); - WeakAuras.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "finish_message", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#chat-message---custom-code", - 25, function() return not (data.actions.finish.do_message and WeakAuras.ContainsCustomPlaceHolder(data.actions.finish.message)) end, {"actions", "finish", "message_custom"}, false); + OptionsPrivate.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "finish_message", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#chat-message---custom-code", + 25, function() return not (data.actions.finish.do_message and OptionsPrivate.Private.ContainsCustomPlaceHolder(data.actions.finish.message)) end, {"actions", "finish", "message_custom"}, false); local finishHidden = function() - return WeakAuras.IsCollapsed("format_option", "actions", "finish_message", true) + return OptionsPrivate.IsCollapsed("format_option", "actions", "finish_message", true) end local finishSetHidden = function(hidden) - WeakAuras.SetCollapsed("format_option", "actions", "finish_message", hidden) + OptionsPrivate.SetCollapsed("format_option", "actions", "finish_message", hidden) end local finishGet = function(key) @@ -922,13 +919,13 @@ function WeakAuras.GetActionOptions(data) local finishGet = function(key) return childData.actions.finish["message_format_" .. key] end - WeakAuras.AddTextFormatOption(childData.actions and childData.actions.finish.message, true, finishGet, finishAddOption, finishHidden, finishSetHidden) + OptionsPrivate.AddTextFormatOption(childData.actions and childData.actions.finish.message, true, finishGet, finishAddOption, finishHidden, finishSetHidden) end else - WeakAuras.AddTextFormatOption(data.actions and data.actions.finish.message, true, finishGet, finishAddOption, finishHidden, finishSetHidden) + OptionsPrivate.AddTextFormatOption(data.actions and data.actions.finish.message, true, finishGet, finishAddOption, finishHidden, finishSetHidden) end - WeakAuras.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "finish", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-hide", + OptionsPrivate.commonOptions.AddCodeOption(action.args, data, L["Custom Code"], "finish", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#on-hide", 32, function() return not data.actions.finish.do_custom end, {"actions", "finish", "custom"}, true); if data.controlledChildren then @@ -943,7 +940,7 @@ function WeakAuras.GetActionOptions(data) if(type(data.id) == "string") then WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end end action.hidden = function(info, ...) return hiddenAll(data, info, ...); end; diff --git a/WeakAurasOptions/AnimationOptions.lua b/WeakAurasOptions/AnimationOptions.lua index 0a283b6..b127167 100644 --- a/WeakAurasOptions/AnimationOptions.lua +++ b/WeakAurasOptions/AnimationOptions.lua @@ -3,27 +3,14 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L -local removeFuncs = WeakAuras.commonOptions.removeFuncs -local replaceNameDescFuncs = WeakAuras.commonOptions.replaceNameDescFuncs -local replaceImageFuncs = WeakAuras.commonOptions.replaceImageFuncs -local replaceValuesFuncs = WeakAuras.commonOptions.replaceValuesFuncs -local disabledAll = WeakAuras.commonOptions.CreateDisabledAll("animation") -local hiddenAll = WeakAuras.commonOptions.CreateHiddenAll("animation") -local getAll = WeakAuras.commonOptions.CreateGetAll("animation") -local setAll = WeakAuras.commonOptions.CreateSetAll("animation", getAll) - -local anim_types = WeakAuras.anim_types; -local anim_translate_types = WeakAuras.anim_translate_types; -local anim_scale_types = WeakAuras.anim_scale_types; -local anim_alpha_types = WeakAuras.anim_alpha_types; -local anim_rotate_types = WeakAuras.anim_rotate_types; -local anim_color_types = WeakAuras.anim_color_types; -local anim_start_preset_types = WeakAuras.anim_start_preset_types; -local anim_main_preset_types = WeakAuras.anim_main_preset_types; -local anim_finish_preset_types = WeakAuras.anim_finish_preset_types; -local duration_types = WeakAuras.duration_types; -local duration_types_no_choice = WeakAuras.duration_types_no_choice; -local anim_ease_types = WeakAuras.anim_ease_types; +local removeFuncs = OptionsPrivate.commonOptions.removeFuncs +local replaceNameDescFuncs = OptionsPrivate.commonOptions.replaceNameDescFuncs +local replaceImageFuncs = OptionsPrivate.commonOptions.replaceImageFuncs +local replaceValuesFuncs = OptionsPrivate.commonOptions.replaceValuesFuncs +local disabledAll = OptionsPrivate.commonOptions.CreateDisabledAll("animation") +local hiddenAll = OptionsPrivate.commonOptions.CreateHiddenAll("animation") +local getAll = OptionsPrivate.commonOptions.CreateGetAll("animation") +local setAll = OptionsPrivate.commonOptions.CreateSetAll("animation", getAll) local function filterAnimPresetTypes(intable, id) local ret = {}; @@ -32,7 +19,7 @@ local function filterAnimPresetTypes(intable, id) local data = WeakAuras.GetData(id); if(region and regionType and data) then for key, value in pairs(intable) do - local preset = WeakAuras.anim_presets[key]; + local preset = OptionsPrivate.Private.anim_presets[key]; if(preset) then if(regionType == "group" or regionType == "dynamicgroup") then local valid = true; @@ -56,7 +43,20 @@ local function filterAnimPresetTypes(intable, id) return ret; end -function WeakAuras.GetAnimationOptions(data) +function OptionsPrivate.GetAnimationOptions(data) + local anim_types = OptionsPrivate.Private.anim_types + local anim_translate_types = OptionsPrivate.Private.anim_translate_types; + local anim_scale_types = OptionsPrivate.Private.anim_scale_types; + local anim_alpha_types = OptionsPrivate.Private.anim_alpha_types; + local anim_rotate_types = OptionsPrivate.Private.anim_rotate_types; + local anim_color_types = OptionsPrivate.Private.anim_color_types; + local anim_start_preset_types = OptionsPrivate.Private.anim_start_preset_types; + local anim_main_preset_types = OptionsPrivate.Private.anim_main_preset_types; + local anim_finish_preset_types = OptionsPrivate.Private.anim_finish_preset_types; + local duration_types = OptionsPrivate.Private.duration_types; + local duration_types_no_choice = OptionsPrivate.Private.duration_types_no_choice; + local anim_ease_types = OptionsPrivate.Private.anim_ease_types; + local id = data.id local animation = { type = "group", @@ -85,10 +85,10 @@ function WeakAuras.GetAnimationOptions(data) data.animation[field] = data.animation[field] or {}; data.animation[field][value] = v; if(field == "main") then - WeakAuras.Animate("display", data.uid, "main", data.animation.main, WeakAuras.regions[id].region, false, nil, true); + OptionsPrivate.Private.Animate("display", data.uid, "main", data.animation.main, WeakAuras.regions[id].region, false, nil, true); if(WeakAuras.clones[id]) then for cloneId, cloneRegion in pairs(WeakAuras.clones[id]) do - WeakAuras.Animate("display", data.uid, "main", data.animation.main, cloneRegion, false, nil, true, cloneId); + OptionsPrivate.Private.Animate("display", data.uid, "main", data.animation.main, cloneRegion, false, nil, true, cloneId); end end end @@ -154,7 +154,7 @@ function WeakAuras.GetAnimationOptions(data) order = 33, values = duration_types_no_choice, disabled = true, - hidden = function() return data.animation.start.type ~= "custom" or WeakAuras.CanHaveDuration(data) end, + hidden = function() return data.animation.start.type ~= "custom" or OptionsPrivate.Private.CanHaveDuration(data) end, get = function() return "seconds" end }, start_duration_type = { @@ -163,7 +163,7 @@ function WeakAuras.GetAnimationOptions(data) name = L["Time in"], order = 33, values = duration_types, - hidden = function() return data.animation.start.type ~= "custom" or not WeakAuras.CanHaveDuration(data) end + hidden = function() return data.animation.start.type ~= "custom" or not OptionsPrivate.Private.CanHaveDuration(data) end }, start_duration = { type = "input", @@ -400,7 +400,7 @@ function WeakAuras.GetAnimationOptions(data) order = 53, values = duration_types_no_choice, disabled = true, - hidden = function() return data.animation.main.type ~= "custom" or WeakAuras.CanHaveDuration(data) end, + hidden = function() return data.animation.main.type ~= "custom" or OptionsPrivate.Private.CanHaveDuration(data) end, get = function() return "seconds" end }, main_duration_type = { @@ -409,7 +409,7 @@ function WeakAuras.GetAnimationOptions(data) name = L["Time in"], order = 53, values = duration_types, - hidden = function() return data.animation.main.type ~= "custom" or not WeakAuras.CanHaveDuration(data) end + hidden = function() return data.animation.main.type ~= "custom" or not OptionsPrivate.Private.CanHaveDuration(data) end }, main_duration = { type = "input", @@ -843,10 +843,10 @@ function WeakAuras.GetAnimationOptions(data) } local function extraSetFunction() - WeakAuras.Animate("display", data.uid, "main", data.animation.main, WeakAuras.regions[id].region, false, nil, true); + OptionsPrivate.Private.Animate("display", data.uid, "main", data.animation.main, WeakAuras.regions[id].region, false, nil, true); if(WeakAuras.clones[id]) then for cloneId, cloneRegion in pairs(WeakAuras.clones[id]) do - WeakAuras.Animate("display", data.uid, "main", data.animation.main, cloneRegion, false, nil, true, cloneId); + OptionsPrivate.Private.Animate("display", data.uid, "main", data.animation.main, cloneRegion, false, nil, true, cloneId); end end end @@ -855,93 +855,93 @@ function WeakAuras.GetAnimationOptions(data) local function hideStartAlphaFunc() return data.animation.start.type ~= "custom" or data.animation.start.alphaType ~= "custom" or not data.animation.start.use_alpha end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_alphaFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#alpha-opacity", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_alphaFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#alpha-opacity", 35.3, hideStartAlphaFunc, {"animation", "start", "alphaFunc"}, false); local function hideStartTranslate() return data.animation.start.type ~= "custom" or data.animation.start.translateType ~= "custom" or not data.animation.start.use_translate end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_translateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#translate-position", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_translateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#translate-position", 39.3, hideStartTranslate, {"animation", "start", "translateFunc"}, false); local function hideStartScale() return data.animation.start.type ~= "custom" or data.animation.start.scaleType ~= "custom" or not (data.animation.start.use_scale and WeakAuras.regions[id].region.Scale) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_scaleFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#scale-size", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_scaleFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#scale-size", 43.3, hideStartScale, {"animation", "start", "scaleFunc"}, false); local function hideStartRotateFunc() return data.animation.start.type ~= "custom" or data.animation.start.rotateType ~= "custom" or not (data.animation.start.use_rotate and WeakAuras.regions[id].region.Rotate) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_rotateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#rotate", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_rotateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#rotate", 47.3, hideStartRotateFunc, {"animation", "start", "rotateFunc"}, false); local function hideStartColorFunc() return data.animation.start.type ~= "custom" or data.animation.start.colorType ~= "custom" or not (data.animation.start.use_color and WeakAuras.regions[id].region.Color) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_colorFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#color", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "start_colorFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#color", 48.7, hideStartColorFunc, {"animation", "start", "colorFunc"}, false); -- Text Editors for "main" local function hideMainAlphaFunc() return data.animation.main.type ~= "custom" or data.animation.main.alphaType ~= "custom" or not data.animation.main.use_alpha end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_alphaFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#alpha-opacity", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_alphaFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#alpha-opacity", 55.3, hideMainAlphaFunc, {"animation", "main", "alphaFunc"}, false, nil, extraSetFunction); local function hideMainTranslate() return data.animation.main.type ~= "custom" or data.animation.main.translateType ~= "custom" or not data.animation.main.use_translate end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_translateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#translate-position", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_translateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#translate-position", 59.3, hideMainTranslate, {"animation", "main", "translateFunc"}, false, nil, extraSetFunction); local function hideMainScale() return data.animation.main.type ~= "custom" or data.animation.main.scaleType ~= "custom" or not (data.animation.main.use_scale and WeakAuras.regions[id].region.Scale) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_scaleFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#scale-sizes", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_scaleFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#scale-sizes", 63.3, hideMainScale, {"animation", "main", "scaleFunc"}, false, nil, extraSetFunction); local function hideMainRotateFunc() return data.animation.main.type ~= "custom" or data.animation.main.rotateType ~= "custom" or not (data.animation.main.use_rotate and WeakAuras.regions[id].region.Rotate) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_rotateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#rotate", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_rotateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#rotate", 67.3, hideMainRotateFunc, {"animation", "main", "rotateFunc"}, false, nil, extraSetFunction); local function hideMainColorFunc() return data.animation.main.type ~= "custom" or data.animation.main.colorType ~= "custom" or not (data.animation.main.use_color and WeakAuras.regions[id].region.Color) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_colorFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#color", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "main_colorFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#color", 68.7, hideMainColorFunc, {"animation", "main", "colorFunc"}, false, nil, extraSetFunction); -- Text Editors for "finish" local function hideFinishAlphaFunc() return data.animation.finish.type ~= "custom" or data.animation.finish.alphaType ~= "custom" or not data.animation.finish.use_alpha end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_alphaFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#alpha-opacity", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_alphaFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#alpha-opacity", 75.3, hideFinishAlphaFunc, {"animation", "finish", "alphaFunc"}, false); local function hideFinishTranslate() return data.animation.finish.type ~= "custom" or data.animation.finish.translateType ~= "custom" or not data.animation.finish.use_translate end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_translateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#translate-position", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_translateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#translate-position", 79.3, hideFinishTranslate, {"animation", "finish", "translateFunc"}, false); local function hideFinishScale() return data.animation.finish.type ~= "custom" or data.animation.finish.scaleType ~= "custom" or not (data.animation.finish.use_scale and WeakAuras.regions[id].region.Scale) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_scaleFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#scale-size", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_scaleFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#scale-size", 83.3, hideFinishScale, {"animation", "finish", "scaleFunc"}, false); local function hideFinishRotateFunc() return data.animation.finish.type ~= "custom" or data.animation.finish.rotateType ~= "custom" or not (data.animation.finish.use_rotate and WeakAuras.regions[id].region.Rotate) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_rotateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#rotate", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_rotateFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#rotate", 87.3, hideFinishRotateFunc, {"animation", "finish", "rotateFunc"}, false); local function hideFinishColorFunc() return data.animation.finish.type ~= "custom" or data.animation.finish.colorType ~= "custom" or not (data.animation.finish.use_color and WeakAuras.regions[id].region.Color) end - WeakAuras.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_colorFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#color", + OptionsPrivate.commonOptions.AddCodeOption(animation.args, data, L["Custom Function"], "finish_colorFunc", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#color", 88.7, hideFinishColorFunc, {"animation", "finish", "colorFunc"}, false); if(data.controlledChildren) then @@ -956,7 +956,7 @@ function WeakAuras.GetAnimationOptions(data) if(type(data.id) == "string") then WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end end animation.hidden = function(info, ...) return hiddenAll(data, info, ...); end; diff --git a/WeakAurasOptions/AuthorOptions.lua b/WeakAurasOptions/AuthorOptions.lua index d71c62e..5d10487 100644 --- a/WeakAurasOptions/AuthorOptions.lua +++ b/WeakAurasOptions/AuthorOptions.lua @@ -68,8 +68,6 @@ local tinsert, tremove, tconcat = table.insert, table.remove, table.concat local conflictBlue = "|cFF4080FF" local conflict = {} -- magic value -local optionClasses = WeakAuras.author_option_classes - local function atLeastOneSet(references, key) for id, optionData in pairs(references) do local childOption = optionData.options[optionData.index] @@ -539,7 +537,7 @@ typeControlAdders = { name = name(option, "default", L["Default"]), desc = desc(option, "default"), order = order(), - values = WeakAuras.bool_types, + values = OptionsPrivate.Private.bool_types, get = function() if option.default == nil then return @@ -740,7 +738,7 @@ typeControlAdders = { name = name(option, "fontSize", L["Font Size"]), desc = desc(option, "fontSize"), order = order(), - values = WeakAuras.font_sizes, + values = OptionsPrivate.Private.font_sizes, get = get(option, "fontSize"), set = set(data, option, "fontSize") } @@ -1111,7 +1109,7 @@ typeControlAdders = { name = name(option, "groupType", L["Group Type"]), order = order(), width = WeakAuras.doubleWidth, - values = WeakAuras.group_option_types, + values = OptionsPrivate.Private.group_option_types, get = get(option, "groupType"), set = function(_, value) for id, optionData in pairs(option.references) do @@ -1144,7 +1142,7 @@ typeControlAdders = { local childOption = optionData.options[optionData.index] local childData = optionData.data childOption.collapse = value - WeakAuras.SetCollapsed(id, "config", optionData.path, value) + OptionsPrivate.SetCollapsed(id, "config", optionData.path, value) WeakAuras.Add(childData) end WeakAuras.ClearAndUpdateOptions(data.id, true) @@ -1158,7 +1156,7 @@ typeControlAdders = { desc = desc(option, "limitType", L["Determines how many entries can be in the table."]), order = order(), width = WeakAuras.normalWidth, - values = WeakAuras.group_limit_types, + values = OptionsPrivate.Private.group_limit_types, get = get(option, "limitType"), set = function(_, value) for id, optionData in pairs(option.references) do @@ -1220,8 +1218,8 @@ typeControlAdders = { return option.nameSource == -1 end, } - local nameSources = CopyTable(WeakAuras.array_entry_name_types) - local validNameSourceTypes = WeakAuras.name_source_option_types + local nameSources = CopyTable(OptionsPrivate.Private.array_entry_name_types) + local validNameSourceTypes = OptionsPrivate.Private.name_source_option_types if option.limitType ~= "fixed" then nameSources[-1] = nil end @@ -1320,7 +1318,7 @@ typeControlAdders = { width = 1, useDesc = false, } - WeakAuras.SetCollapsed(id, "author", path, false) + OptionsPrivate.SetCollapsed(id, "author", path, false) WeakAuras.Add(childData) end WeakAuras.ClearAndUpdateOptions(data.id, true) @@ -1349,7 +1347,7 @@ local function up(data, options, index) local optionID = optionData.index local childData = optionData.data local childOptions = optionData.options - WeakAuras.MoveCollapseDataUp(id, "author", path) + OptionsPrivate.MoveCollapseDataUp(id, "author", path) childOptions[optionID], childOptions[optionID - 1] = childOptions[optionID - 1], childOptions[optionID] WeakAuras.Add(childData) end @@ -1372,7 +1370,7 @@ local function down(data, options, index) local optionID = optionData.index local childData = optionData.data local childOptions = optionData.options - WeakAuras.MoveCollapseDataUp(id, "author", path) + OptionsPrivate.MoveCollapseDataDown(id, "author", path) childOptions[optionID], childOptions[optionID + 1] = childOptions[optionID + 1], childOptions[optionID] WeakAuras.Add(childData) end @@ -1389,7 +1387,7 @@ local function duplicate(data, options, index) local childData = optionData.data local path = optionData.path path[#path] = path[#path] + 1 -- this data is being regenerated very soon - WeakAuras.InsertCollapsed(id, "author", optionData.path, false) + OptionsPrivate.InsertCollapsed(id, "author", optionData.path, false) local newOption = CopyTable(childOptions[optionID]) if newOption.key then local existingKeys = {} @@ -1436,7 +1434,7 @@ function addAuthorModeOption(options, args, data, order, prefix, i) local collapsed = false for id, optionData in pairs(option.references) do - if WeakAuras.IsCollapsed(id, "author", optionData.path, true) then + if OptionsPrivate.IsCollapsed(id, "author", optionData.path, true) then collapsed = true break end @@ -1450,18 +1448,18 @@ function addAuthorModeOption(options, args, data, order, prefix, i) end local optionBelow = options[i + 1] - local isAboveGroup = optionBelow and optionClasses[optionBelow.type] == "group" + local isAboveGroup = optionBelow and OptionsPrivate.Private.author_option_classes[optionBelow.type] == "group" if isAboveGroup then buttonWidth = buttonWidth + 0.15 end local optionAbove = options[i - 1] - local isBelowGroup = optionAbove and optionClasses[optionAbove.type] == "group" + local isBelowGroup = optionAbove and OptionsPrivate.Private.author_option_classes[optionAbove.type] == "group" if isBelowGroup then buttonWidth = buttonWidth + 0.15 end - local optionClass = optionClasses[option.type] - local optionName = optionClass == "noninteractive" and WeakAuras.author_option_types[option.type] + local optionClass = OptionsPrivate.Private.author_option_classes[option.type] + local optionName = optionClass == "noninteractive" and OptionsPrivate.Private.author_option_types[option.type] or option.name args[prefix .. "collapse"] = { @@ -1471,7 +1469,7 @@ function addAuthorModeOption(options, args, data, order, prefix, i) width = WeakAuras.doubleWidth - buttonWidth, func = function() for id, optionData in pairs(option.references) do - WeakAuras.SetCollapsed(id, "author", optionData.path, not collapsed) + OptionsPrivate.SetCollapsed(id, "author", optionData.path, not collapsed) end WeakAuras.ClearAndUpdateOptions(data.id, true) end, @@ -1493,11 +1491,11 @@ function addAuthorModeOption(options, args, data, order, prefix, i) local groupData = optionAbove.references[id] if groupData then local childGroup = groupData.options[groupData.index] - local childCollapsed = WeakAuras.IsCollapsed(id, "author", optionData.path, true) - WeakAuras.RemoveCollapsed(id, "author", optionData.path) + local childCollapsed = OptionsPrivate.IsCollapsed(id, "author", optionData.path, true) + OptionsPrivate.RemoveCollapsed(id, "author", optionData.path) local newPath = groupData.path tinsert(newPath, #childGroup.subOptions + 1) - WeakAuras.InsertCollapsed(id, "author", newPath, childCollapsed) + OptionsPrivate.InsertCollapsed(id, "author", newPath, childCollapsed) local childOption = tremove(optionData.options, optionData.index) local childData = optionData.data tinsert(childGroup.subOptions, childOption) @@ -1522,11 +1520,11 @@ function addAuthorModeOption(options, args, data, order, prefix, i) local groupData = optionBelow.references[id] if groupData then local childGroup = groupData.options[groupData.index] - local childCollapsed = WeakAuras.IsCollapsed(id, "author", optionData.path, true) - WeakAuras.RemoveCollapsed(id, "author", optionData.path) + local childCollapsed = OptionsPrivate.IsCollapsed(id, "author", optionData.path, true) + OptionsPrivate.RemoveCollapsed(id, "author", optionData.path) local newPath = groupData.path tinsert(newPath, 1) - WeakAuras.InsertCollapsed(id, "author", newPath, childCollapsed) + OptionsPrivate.InsertCollapsed(id, "author", newPath, childCollapsed) local childOption = tremove(optionData.options, optionData.index) local childData = optionData.data tinsert(childGroup.subOptions, 1, childOption) @@ -1553,11 +1551,11 @@ function addAuthorModeOption(options, args, data, order, prefix, i) local parent = optionData.parent local parentOptions = parent and parent.references[id].options or optionData.data.authorOptions local childOption = tremove(optionData.options, optionData.index) - local childCollapsed = WeakAuras.IsCollapsed(id, "author", optionData.path, true) - WeakAuras.RemoveCollapsed(id, "author", optionData.path) + local childCollapsed = OptionsPrivate.IsCollapsed(id, "author", optionData.path, true) + OptionsPrivate.RemoveCollapsed(id, "author", optionData.path) tinsert(parentOptions, path[#path - 1], childOption) path[#path] = nil - WeakAuras.InsertCollapsed(id, "author", path) + OptionsPrivate.InsertCollapsed(id, "author", path) WeakAuras.Add(optionData.data) end WeakAuras.ClearAndUpdateOptions(data.id, true) @@ -1579,12 +1577,12 @@ function addAuthorModeOption(options, args, data, order, prefix, i) local parent = optionData.parent local parentOptions = parent and parent.references[id].options or optionData.data.authorOptions local childOption = tremove(optionData.options, optionData.index) - local childCollapsed = WeakAuras.IsCollapsed(id, "author", optionData.path, true) - WeakAuras.RemoveCollapsed(id, "author", optionData.path) + local childCollapsed = OptionsPrivate.IsCollapsed(id, "author", optionData.path, true) + OptionsPrivate.RemoveCollapsed(id, "author", optionData.path) tinsert(parentOptions, path[#path - 1] + 1, childOption) path[#path] = nil path[#path] = path[#path] + 1 - WeakAuras.InsertCollapsed(id, "author", path) + OptionsPrivate.InsertCollapsed(id, "author", path) WeakAuras.Add(optionData.data) end WeakAuras.ClearAndUpdateOptions(data.id, true) @@ -1645,7 +1643,7 @@ function addAuthorModeOption(options, args, data, order, prefix, i) local optionIndex = optionData.index local childData = optionData.data local parentOption = optionData.parent - WeakAuras.RemoveCollapsed(id, "author", optionData.path) + OptionsPrivate.RemoveCollapsed(id, "author", optionData.path) tremove(childOptions, optionIndex) if parentOption and parentOption.groupType == "array" then local dereferencedParent = parentOption.references[id] @@ -1671,15 +1669,15 @@ function addAuthorModeOption(options, args, data, order, prefix, i) name = L["Option Type"], desc = descType(option), order = order(), - values = WeakAuras.author_option_types, + values = OptionsPrivate.Private.author_option_types, get = get(option, "type"), set = function(_, value) if value == option.type then return end - local author_option_fields = WeakAuras.author_option_fields + local author_option_fields = OptionsPrivate.Private.author_option_fields local commonFields, newFields = author_option_fields.common, author_option_fields[value] - local newClass = optionClasses[value] + local newClass = OptionsPrivate.Private.author_option_classes[value] for id, optionData in pairs(option.references) do local childOption = optionData.options[optionData.index] local childData = optionData.data @@ -1723,7 +1721,7 @@ function addAuthorModeOption(options, args, data, order, prefix, i) childOption.key = newKey end end - if parentOption and parentOption.groupType == "array" and not WeakAuras.array_entry_name_types[value] then + if parentOption and parentOption.groupType == "array" and not OptionsPrivate.Private.array_entry_name_types[value] then local dereferencedParent = parentOption.references[id] if dereferencedParent.nameSource == optionData.index then dereferencedParent.nameSource = 0 @@ -1839,7 +1837,7 @@ end local function addUserModeOption(options, args, data, order, prefix, i) local option = options[i] local optionType = option.type - local optionClass = optionClasses[optionType] + local optionClass = OptionsPrivate.Private.author_option_classes[optionType] local userOption if optionClass == "simple" then @@ -1867,7 +1865,7 @@ local function addUserModeOption(options, args, data, order, prefix, i) defaultCollapsed = option.collapse end for id, optionData in pairs(option.references) do - if WeakAuras.IsCollapsed(id, "config", optionData.path, defaultCollapsed) then + if OptionsPrivate.IsCollapsed(id, "config", optionData.path, defaultCollapsed) then collapsed = true break end @@ -1879,7 +1877,7 @@ local function addUserModeOption(options, args, data, order, prefix, i) width = WeakAuras.doubleWidth, func = function() for id, optionData in pairs(option.references) do - WeakAuras.SetCollapsed(id, "config", optionData.path, not collapsed) + OptionsPrivate.SetCollapsed(id, "config", optionData.path, not collapsed) end WeakAuras.ClearAndUpdateOptions(data.id, true) end, @@ -2405,7 +2403,7 @@ local function valuesAreEqual(t1, t2) end local function allChoicesAreDefault(option, config, id, path) - local optionClass = optionClasses[option.type] + local optionClass = OptionsPrivate.Private.author_option_classes[option.type] if optionClass == "simple" then return valuesAreEqual(option.default, config[option.key]) elseif optionClass == "group" then @@ -2432,7 +2430,7 @@ local function allChoicesAreDefault(option, config, id, path) path[#path] = nil end if option.useCollapse then - local isCollapsed = WeakAuras.IsCollapsed(id, "config", path, option.collapse) + local isCollapsed = OptionsPrivate.IsCollapsed(id, "config", path, option.collapse) if isCollapsed ~= option.collapse then return false end @@ -2449,7 +2447,7 @@ local function createorder(startorder) end end -function WeakAuras.GetAuthorOptions(data) +function OptionsPrivate.GetAuthorOptions(data) -- initialize the process local authorOptions = { type = "group", @@ -2519,7 +2517,7 @@ function WeakAuras.GetAuthorOptions(data) width = 1, useDesc = false, } - WeakAuras.SetCollapsed(childData.id, "author", i, false) + OptionsPrivate.SetCollapsed(childData.id, "author", i, false) WeakAuras.Add(childData) end else @@ -2532,7 +2530,7 @@ function WeakAuras.GetAuthorOptions(data) width = 1, useDesc = false, } - WeakAuras.SetCollapsed(data.id, "author", i, false) + OptionsPrivate.SetCollapsed(data.id, "author", i, false) WeakAuras.Add(data) end WeakAuras.ClearAndUpdateOptions(data.id, true) @@ -2557,13 +2555,13 @@ function WeakAuras.GetAuthorOptions(data) if data.controlledChildren then for _, id in pairs(data.controlledChildren) do local childData = WeakAuras.GetData(id) - WeakAuras.ResetCollapsed(id, "config") + OptionsPrivate.ResetCollapsed(id, "config") childData.config = {} -- config validation in Add() will set all the needed keys to their defaults WeakAuras.Add(childData) end else data.config = {} - WeakAuras.ResetCollapsed(data.id, "config") + OptionsPrivate.ResetCollapsed(data.id, "config") WeakAuras.Add(data) end WeakAuras.ClearAndUpdateOptions(data.id, true) diff --git a/WeakAurasOptions/BuffTrigger.lua b/WeakAurasOptions/BuffTrigger.lua index 46076a6..7fc47fc 100644 --- a/WeakAurasOptions/BuffTrigger.lua +++ b/WeakAurasOptions/BuffTrigger.lua @@ -3,14 +3,6 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L; -local operator_types = WeakAuras.operator_types; -local debuff_types = WeakAuras.debuff_types; -local tooltip_count = WeakAuras.tooltip_count; -local unit_types = WeakAuras.unit_types; -local actual_unit_types_with_specific = WeakAuras.actual_unit_types_with_specific; -local group_aura_name_info_types = WeakAuras.group_aura_name_info_types; -local group_aura_stack_info_types = WeakAuras.group_aura_stack_info_types; - local function getAuraMatchesLabel(name) local ids = WeakAuras.spellCache.GetSpellsMatching(name) if(ids) then @@ -58,6 +50,22 @@ end local noop = function() end +local function CanShowNameInfo(data) + if(data.regionType == "aurabar" or data.regionType == "icon" or data.regionType == "text") then + return true; + else + return false; + end +end + +local function CanShowStackInfo(data) + if(data.regionType == "aurabar" or data.regionType == "icon" or data.regionType == "text") then + return true; + else + return false; + end +end + local function GetBuffTriggerOptions(data, triggernum) local trigger = data.triggers[triggernum].trigger trigger.names = trigger.names or {} @@ -82,10 +90,10 @@ local function GetBuffTriggerOptions(data, triggernum) width = WeakAuras.doubleWidth - 0.8, order = 8.2, name = function() - if (not WeakAuras.CanConvertBuffTrigger2) then + if (not OptionsPrivate.Private.CanConvertBuffTrigger2) then return ""; end - local _, err = WeakAuras.CanConvertBuffTrigger2(trigger); + local _, err = OptionsPrivate.Private.CanConvertBuffTrigger2(trigger); return err or ""; end, }, @@ -107,20 +115,20 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Convert to New Aura Trigger"], order = 8.5, disabled = function() - if (not WeakAuras.CanConvertBuffTrigger2) then + if (not OptionsPrivate.Private.CanConvertBuffTrigger2) then return true; end - if (not WeakAuras.CanConvertBuffTrigger2(trigger)) then + if (not OptionsPrivate.Private.CanConvertBuffTrigger2(trigger)) then return true; end return false; end, desc = function() - local _, err = WeakAuras.CanConvertBuffTrigger2(trigger); + local _, err = OptionsPrivate.Private.CanConvertBuffTrigger2(trigger); return err or "" end, func = function() - WeakAuras.ConvertBuffTrigger2(trigger); + OptionsPrivate.Private.ConvertBuffTrigger2(trigger); WeakAuras.Add(data); WeakAuras.UpdateDisplayButton(data) WeakAuras.ClearAndUpdateOptions(data.id); @@ -173,7 +181,7 @@ local function GetBuffTriggerOptions(data, triggernum) order = 11, disabled = function() return not trigger.use_name end, hidden = function() return not (trigger.type == "aura" and trigger.fullscan); end, - values = WeakAuras.string_operator_types, + values = OptionsPrivate.Private.string_operator_types, set = noop }, name = { @@ -200,7 +208,7 @@ local function GetBuffTriggerOptions(data, triggernum) order = 14, disabled = function() return not trigger.use_tooltip end, hidden = function() return not (trigger.type == "aura" and trigger.fullscan and trigger.unit ~= "multi"); end, - values = WeakAuras.string_operator_types, + values = OptionsPrivate.Private.string_operator_types, set = noop }, tooltip = { @@ -263,7 +271,7 @@ local function GetBuffTriggerOptions(data, triggernum) order = 20, disabled = function() return not trigger.use_debuffClass end, hidden = function() return not (trigger.type == "aura" and trigger.fullscan); end, - values = WeakAuras.debuff_class_types, + values = OptionsPrivate.Private.debuff_class_types, set = noop }, multiuse_name = { @@ -579,9 +587,9 @@ local function GetBuffTriggerOptions(data, triggernum) order = 41, values = function() if(trigger.fullscan) then - return actual_unit_types_with_specific; + return OptionsPrivate.Private.actual_unit_types_with_specific; else - return unit_types; + return OptionsPrivate.Private.unit_types; end end, hidden = function() return not (trigger.type == "aura"); end, @@ -627,7 +635,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 46, width = WeakAuras.halfWidth, - values = operator_types, + values = OptionsPrivate.Private.operator_types, hidden = function() return not (trigger.type == "aura" and trigger.unit == "group"); end, get = function() return trigger.group_countOperator; end, set = noop @@ -636,7 +644,7 @@ local function GetBuffTriggerOptions(data, triggernum) type = "input", name = L["Count"], desc = function() - local groupType = unit_types[trigger.unit or "group"] or "|cFFFF0000error|r"; + local groupType = OptionsPrivate.Private.unit_types[trigger.unit or "group"] or "|cFFFF0000error|r"; return L["Group aura count description"]:format(groupType, groupType, groupType, groupType, groupType, groupType, groupType); end, order = 47, @@ -667,15 +675,15 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Name Info"], order = 47.5, hidden = function() return not (trigger.type == "aura" and trigger.unit == "group" and not trigger.groupclone); end, - disabled = function() return not WeakAuras.CanShowNameInfo(data); end, + disabled = function() return not CanShowNameInfo(data); end, get = function() - if(WeakAuras.CanShowNameInfo(data)) then + if(CanShowNameInfo(data)) then return trigger.name_info; else return nil; end end, - values = group_aura_name_info_types, + values = OptionsPrivate.Private.group_aura_name_info_types, set = noop }, stack_info = { @@ -684,15 +692,15 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Stack Info"], order = 47.6, hidden = function() return not (trigger.type == "aura" and trigger.unit == "group" and not trigger.groupclone); end, - disabled = function() return not WeakAuras.CanShowStackInfo(data); end, + disabled = function() return not CanShowStackInfo(data); end, get = function() - if(WeakAuras.CanShowStackInfo(data)) then + if(CanShowStackInfo(data)) then return trigger.stack_info; else return nil; end end, - values = group_aura_stack_info_types, + values = OptionsPrivate.Private.group_aura_stack_info_types, set = noop }, hideAlone = { @@ -718,7 +726,7 @@ local function GetBuffTriggerOptions(data, triggernum) width = WeakAuras.normalWidth, name = L["Aura Type"], order = 51, - values = debuff_types, + values = OptionsPrivate.Private.debuff_types, hidden = function() return not (trigger.type == "aura"); end, set = noop }, @@ -732,7 +740,7 @@ local function GetBuffTriggerOptions(data, triggernum) }, subcountCount = { type = "select", - values = tooltip_count, + values = OptionsPrivate.Private.tooltip_count, width = WeakAuras.doubleWidth, name = L["Use nth value from tooltip:"], hidden = function() return not (trigger.type == "aura" and trigger.fullscan and trigger.subcount) end, @@ -752,7 +760,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 57, width = WeakAuras.halfWidth, - values = operator_types, + values = OptionsPrivate.Private.operator_types, disabled = function() return not trigger.useRem; end, hidden = function() return not (trigger.type == "aura" and trigger.unit ~= "multi"); end, get = function() return trigger.useRem and trigger.remOperator or nil end, @@ -782,7 +790,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 62, width = WeakAuras.halfWidth, - values = operator_types, + values = OptionsPrivate.Private.operator_types, disabled = function() return not trigger.useCount; end, hidden = function() return not (trigger.type == "aura" and trigger.unit ~= "multi"); end, get = function() return trigger.useCount and trigger.countOperator or nil end, @@ -840,7 +848,7 @@ local function GetBuffTriggerOptions(data, triggernum) type = "select", width = WeakAuras.normalWidth, name = "", - values = WeakAuras.bufftrigger_progress_behavior_types, + values = OptionsPrivate.Private.bufftrigger_progress_behavior_types, order = 71.1, get = function() return trigger.buffShowOn end, hidden = function() @@ -869,15 +877,15 @@ local function GetBuffTriggerOptions(data, triggernum) name = "", hidden = function() -- For those that update without restarting - return not WeakAuras.CanConvertBuffTrigger2 + return not OptionsPrivate.Private.CanConvertBuffTrigger2 end, }, }; - WeakAuras.commonOptions.AddCommonTriggerOptions(aura_options, data, triggernum) - WeakAuras.commonOptions.AddTriggerGetterSetter(aura_options, data, triggernum) - WeakAuras.AddTriggerMetaFunctions(aura_options, data, triggernum) + OptionsPrivate.commonOptions.AddCommonTriggerOptions(aura_options, data, triggernum) + OptionsPrivate.commonOptions.AddTriggerGetterSetter(aura_options, data, triggernum) + OptionsPrivate.AddTriggerMetaFunctions(aura_options, data, triggernum) return { ["trigger." .. triggernum .. ".legacy_aura_options"] = aura_options diff --git a/WeakAurasOptions/BuffTrigger2.lua b/WeakAurasOptions/BuffTrigger2.lua index bc5338e..6161679 100644 --- a/WeakAurasOptions/BuffTrigger2.lua +++ b/WeakAurasOptions/BuffTrigger2.lua @@ -3,9 +3,6 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L -local operator_types = WeakAuras.operator_types -local debuff_types = WeakAuras.debuff_types - local function getAuraMatchesLabel(name) local ids = WeakAuras.spellCache.GetSpellsMatching(name) if ids then @@ -217,7 +214,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Unit"], order = 10.1, values = function() - return WeakAuras.unit_types_bufftrigger_2 + return OptionsPrivate.Private.unit_types_bufftrigger_2 end, hidden = function() return not trigger.type == "aura2" end }, @@ -261,7 +258,7 @@ local function GetBuffTriggerOptions(data, triggernum) width = WeakAuras.normalWidth, name = L["Aura Type"], order = 11.1, - values = debuff_types, + values = OptionsPrivate.Private.debuff_types, hidden = function() return not trigger.type == "aura2" end }, use_debuffClass = { @@ -281,7 +278,7 @@ local function GetBuffTriggerOptions(data, triggernum) and not IsSingleMissing(trigger) and trigger.use_debuffClass) end, - values = WeakAuras.debuff_class_types, + values = OptionsPrivate.Private.debuff_class_types, }, debuffClassSpace = { type = "description", @@ -371,7 +368,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 55.1, hidden = function() return not (trigger.type == "aura2" and trigger.unit ~= "multi" and trigger.useNamePattern) end, - values = WeakAuras.string_operator_types + values = OptionsPrivate.Private.string_operator_types }, namePattern_name = { type = "input", @@ -392,7 +389,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 60.1, width = WeakAuras.halfWidth, - values = operator_types, + values = OptionsPrivate.Private.operator_types, disabled = function() return not trigger.useStacks end, hidden = function() return not (trigger.type == "aura2" and trigger.unit ~= "multi" and not IsSingleMissing(trigger) and trigger.useStacks) end, get = function() return trigger.useStacks and trigger.stacksOperator or nil end @@ -425,7 +422,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 61.1, width = WeakAuras.halfWidth, - values = operator_types, + values = OptionsPrivate.Private.operator_types, disabled = function() return not trigger.useRem end, hidden = function() return not (trigger.type == "aura2" and trigger.unit ~= "multi" and not IsSingleMissing(trigger) and trigger.useRem) end, get = function() return trigger.useRem and trigger.remOperator or nil end @@ -458,7 +455,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 61.5, width = WeakAuras.halfWidth, - values = operator_types, + values = OptionsPrivate.Private.operator_types, disabled = function() return not trigger.useTotal end, hidden = function() return not (trigger.type == "aura2" and trigger.unit ~= "multi" and not IsSingleMissing(trigger) and trigger.useTotal) end, get = function() return trigger.useTotal and trigger.totalOperator or nil end @@ -508,7 +505,7 @@ local function GetBuffTriggerOptions(data, triggernum) order = 62.3, disabled = function() return not trigger.use_tooltip end, hidden = function() return not (trigger.type == "aura2" and trigger.unit ~= "multi" and not IsSingleMissing(trigger) and trigger.use_tooltip and trigger.fetchTooltip) end, - values = WeakAuras.string_operator_types + values = OptionsPrivate.Private.string_operator_types }, tooltip = { type = "input", @@ -531,7 +528,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Tooltip Value #"], order = 63.2, hidden = function() return not (trigger.type == "aura2" and trigger.unit ~= "multi" and not IsSingleMissing(trigger) and trigger.use_tooltipValue and trigger.fetchTooltip) end, - values = WeakAuras.tooltip_count + values = OptionsPrivate.Private.tooltip_count }, use_tooltipValueSpace = { type = "description", @@ -546,7 +543,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 63.3, hidden = function() return not (trigger.type == "aura2" and trigger.unit ~= "multi" and not IsSingleMissing(trigger) and trigger.use_tooltipValue and trigger.fetchTooltip) end, - values = WeakAuras.operator_types + values = OptionsPrivate.Private.operator_types }, tooltipValue = { type = "input", @@ -735,13 +732,13 @@ local function GetBuffTriggerOptions(data, triggernum) if (trigger.unit == "multi") then return L["Compare against the number of units affected."] else - local groupType = WeakAuras.unit_types_bufftrigger_2[trigger.unit or "group"] or "|cFFFF0000Error|r" + local groupType = OptionsPrivate.Private.unit_types_bufftrigger_2[trigger.unit or "group"] or "|cFFFF0000Error|r" return L["Group aura count description"]:format(groupType, groupType, groupType, groupType, groupType, groupType, groupType) end end, order = 70.2, width = WeakAuras.halfWidth, - values = operator_types, + values = OptionsPrivate.Private.operator_types, hidden = function() return not (trigger.type == "aura2" and IsGroupTrigger(trigger) and trigger.useGroup_count) end, get = function() return trigger.group_countOperator end }, @@ -752,7 +749,7 @@ local function GetBuffTriggerOptions(data, triggernum) if (trigger.unit == "multi") then return L["Compare against the number of units affected."] else - local groupType = WeakAuras.unit_types_bufftrigger_2[trigger.unit or "group"] or "|cFFFF0000Error|r" + local groupType = OptionsPrivate.Private.unit_types_bufftrigger_2[trigger.unit or "group"] or "|cFFFF0000Error|r" return L["Group aura count description"]:format(groupType, groupType, groupType, groupType, groupType, groupType, groupType) end end, @@ -774,7 +771,7 @@ local function GetBuffTriggerOptions(data, triggernum) type = "select", width = WeakAuras.normalWidth, name = L["Show On"], - values = WeakAuras.bufftrigger_2_progress_behavior_types, + values = OptionsPrivate.Private.bufftrigger_2_progress_behavior_types, order = 71.1, hidden = function() return not (trigger.type == "aura2" and not IsGroupTrigger(trigger)) end, get = function() @@ -809,7 +806,7 @@ local function GetBuffTriggerOptions(data, triggernum) name = L["Operator"], order = 71.4, width = WeakAuras.halfWidth, - values = operator_types, + values = OptionsPrivate.Private.operator_types, hidden = function() return not (trigger.type == "aura2" and HasMatchCount(trigger)) end, desc = L["Counts the number of matches over all units."] }, @@ -856,7 +853,7 @@ local function GetBuffTriggerOptions(data, triggernum) perUnitMode = { type = "select", name = L["Show Matches for"], - values = WeakAuras.bufftrigger_2_per_unit_mode, + values = OptionsPrivate.Private.bufftrigger_2_per_unit_mode, order = 72.4, width = WeakAuras.normalWidth, hidden = function() @@ -891,7 +888,7 @@ local function GetBuffTriggerOptions(data, triggernum) combineMode = { type = "select", name = L["Preferred Match"], - values = WeakAuras.bufftrigger_2_preferred_match_types, + values = OptionsPrivate.Private.bufftrigger_2_preferred_match_types, order = 72.6, width = WeakAuras.normalWidth, hidden = function() @@ -948,9 +945,9 @@ local function GetBuffTriggerOptions(data, triggernum) true, true, "ignorespellid", 42, "useIgnoreExactSpellId", "ignoreAuraSpellids", L["Ignored Spell ID"], L["Enter a Spell ID"]) - WeakAuras.commonOptions.AddCommonTriggerOptions(aura_options, data, triggernum) - WeakAuras.commonOptions.AddTriggerGetterSetter(aura_options, data, triggernum) - WeakAuras.AddTriggerMetaFunctions(aura_options, data, triggernum) + OptionsPrivate.commonOptions.AddCommonTriggerOptions(aura_options, data, triggernum) + OptionsPrivate.commonOptions.AddTriggerGetterSetter(aura_options, data, triggernum) + OptionsPrivate.AddTriggerMetaFunctions(aura_options, data, triggernum) return { diff --git a/WeakAurasOptions/Cache.lua b/WeakAurasOptions/Cache.lua index fb463e6..2d47bcd 100644 --- a/WeakAurasOptions/Cache.lua +++ b/WeakAurasOptions/Cache.lua @@ -15,7 +15,6 @@ WeakAuras.spellCache = spellCache local cache local metaData local bestIcon = {} -local dynFrame = WeakAuras.dynFrame -- Builds a cache of name/icon pairs from existing spell data -- This is a rather slow operation, so it's only done once, and the result is subsequently saved @@ -76,7 +75,7 @@ function spellCache.Build() metaData.needsRebuild = false end) - dynFrame:AddAction("spellCache", co) + OptionsPrivate.Private.dynFrame:AddAction("spellCache", co) end function spellCache.GetIcon(name) diff --git a/WeakAurasOptions/CommonOptions.lua b/WeakAurasOptions/CommonOptions.lua index 93deb18..6cf88ac 100644 --- a/WeakAurasOptions/CommonOptions.lua +++ b/WeakAurasOptions/CommonOptions.lua @@ -3,7 +3,6 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L local regionOptions = WeakAuras.regionOptions -local point_types = WeakAuras.point_types; local parsePrefix = function(input, data, create) local subRegionIndex, property = string.match(input, "^sub%.(%d+)%..-%.(.+)") @@ -67,15 +66,15 @@ local function addCollapsibleHeader(options, key, input, order, isGroupTab) width = titleWidth, func = function(info, button, secondCall) if not nooptions and not secondCall then - local isCollapsed = WeakAuras.IsCollapsed("collapse", "region", key, false) - WeakAuras.SetCollapsed("collapse", "region", key, not isCollapsed) + local isCollapsed = OptionsPrivate.IsCollapsed("collapse", "region", key, false) + OptionsPrivate.SetCollapsed("collapse", "region", key, not isCollapsed) end end, image = function() if nooptions then return "Interface\\AddOns\\WeakAuras\\Media\\Textures\\bullet1", 18, 18 else - local isCollapsed = WeakAuras.IsCollapsed("collapse", "region", key, false) + local isCollapsed = OptionsPrivate.IsCollapsed("collapse", "region", key, false) return isCollapsed and "Interface\\AddOns\\WeakAuras\\Media\\Textures\\expand" or "Interface\\AddOns\\WeakAuras\\Media\\Textures\\collapse", 18, 18 end end, @@ -175,18 +174,17 @@ local function addCollapsibleHeader(options, key, input, order, isGroupTab) if hiddenFunc then return function() - return hiddenFunc() or WeakAuras.IsCollapsed("collapse", "region", key, false) + return hiddenFunc() or OptionsPrivate.IsCollapsed("collapse", "region", key, false) end else return function() - return WeakAuras.IsCollapsed("collapse", "region", key, false) + return OptionsPrivate.IsCollapsed("collapse", "region", key, false) end end end local function copyOptionTable(input, orderAdjustment, collapsedFunc) - local resultOption = {}; - WeakAuras.DeepCopy(input, resultOption); + local resultOption = CopyTable(input); resultOption.order = orderAdjustment + resultOption.order; if collapsedFunc then local oldHidden = resultOption.hidden; @@ -315,7 +313,7 @@ local function CreateHiddenAll(subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOptions = WeakAuras.EnsureOptions(childData, subOption) + local childOptions = OptionsPrivate.EnsureOptions(childData, subOption) local childOption = childOptions; local childOptionTable = {[0] = childOption}; for i=1,#info do @@ -352,7 +350,7 @@ local function CreateDisabledAll(subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOptions = WeakAuras.EnsureOptions(childData, subOption); + local childOptions = OptionsPrivate.EnsureOptions(childData, subOption); local childOption = childOptions; local childOptionTable = {[0] = childOption}; for i=1,#info do @@ -422,7 +420,7 @@ local function replaceNameDescFuncs(intable, data, subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local values = getValueFor(WeakAuras.EnsureOptions(childData, subOption), info, "values"); + local values = getValueFor(OptionsPrivate.EnsureOptions(childData, subOption), info, "values"); if (values) then if (type(values) == "function") then values = values(info); @@ -458,7 +456,7 @@ local function replaceNameDescFuncs(intable, data, subOption) for index, childId in ipairs(data.controlledChildren) do if isToggle == nil then local childData = WeakAuras.GetData(childId) - local childOption = getChildOption(WeakAuras.EnsureOptions(childData, subOption), info) + local childOption = getChildOption(OptionsPrivate.EnsureOptions(childData, subOption), info) isToggle = childOption and childOption.type == "toggle" end @@ -466,7 +464,7 @@ local function replaceNameDescFuncs(intable, data, subOption) local regionType = regionPrefix(info[#info]); if(childData and (not regionType or childData.regionType == regionType or regionType == "sub")) then - local childOptions = WeakAuras.EnsureOptions(childData, subOption) + local childOptions = OptionsPrivate.EnsureOptions(childData, subOption) local get = getValueFor(childOptions, info, "get"); if (combinedKeys) then for key, _ in pairs(combinedKeys) do @@ -513,7 +511,7 @@ local function replaceNameDescFuncs(intable, data, subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOption = getChildOption(WeakAuras.EnsureOptions(childData, subOption), info); + local childOption = getChildOption(OptionsPrivate.EnsureOptions(childData, subOption), info); if (childOption) then local name; if(type(childOption.name) == "function") then @@ -552,7 +550,7 @@ local function replaceNameDescFuncs(intable, data, subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOption = getChildOption(WeakAuras.EnsureOptions(childData, subOption), info); + local childOption = getChildOption(OptionsPrivate.EnsureOptions(childData, subOption), info); if (childOption) then local desc; if(type(childOption.desc) == "function") then @@ -600,7 +598,7 @@ local function replaceNameDescFuncs(intable, data, subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOptions = WeakAuras.EnsureOptions(childData, subOption) + local childOptions = OptionsPrivate.EnsureOptions(childData, subOption) local childOption = childOptions; local childOptionTable = {[0] = childOption}; for i=1,#info do @@ -683,7 +681,7 @@ local function replaceImageFuncs(intable, data, subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOption = WeakAuras.EnsureOptions(childData, subOption) + local childOption = OptionsPrivate.EnsureOptions(childData, subOption) if not(childOption) then return "error" end @@ -725,7 +723,7 @@ local function replaceValuesFuncs(intable, data, subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOption = WeakAuras.EnsureOptions(childData, subOption) + local childOption = OptionsPrivate.EnsureOptions(childData, subOption) if not(childOption) then return "error" end @@ -828,14 +826,14 @@ local function CreateGetAll(subOption) for index, childId in ipairs(data.controlledChildren) do if isToggle == nil then local childData = WeakAuras.GetData(childId) - local childOptions = getChildOption(WeakAuras.EnsureOptions(childData, subOption), info) + local childOptions = getChildOption(OptionsPrivate.EnsureOptions(childData, subOption), info) isToggle = childOptions and childOptions.type == "toggle" end local childData = WeakAuras.GetData(childId); if(childData) then - local childOptions = WeakAuras.EnsureOptions(childData, subOption) + local childOptions = OptionsPrivate.EnsureOptions(childData, subOption) local childOption = childOptions; local childOptionTable = {[0] = childOption}; for i=1,#info do @@ -875,13 +873,13 @@ end local function CreateSetAll(subOption, getAll) return function(data, info, ...) - WeakAuras.pauseOptionsProcessing(true); - WeakAuras.PauseAllDynamicGroups() + OptionsPrivate.Private.pauseOptionsProcessing(true); + OptionsPrivate.Private.PauseAllDynamicGroups() local before = getAll(data, info, ...) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOptions = WeakAuras.EnsureOptions(childData, subOption) + local childOptions = OptionsPrivate.EnsureOptions(childData, subOption) local childOption = childOptions; local childOptionTable = {[0] = childOption}; for i=1,#info do @@ -904,11 +902,11 @@ local function CreateSetAll(subOption, getAll) end end - WeakAuras.ResumeAllDynamicGroups() - WeakAuras.pauseOptionsProcessing(false); - WeakAuras.ScanForLoads(); + OptionsPrivate.Private.ResumeAllDynamicGroups() + OptionsPrivate.Private.pauseOptionsProcessing(false); + OptionsPrivate.Private.ScanForLoads(); WeakAuras.SortDisplayButtons(); - WeakAuras.UpdateOptions() + OptionsPrivate.UpdateOptions() end end @@ -918,7 +916,7 @@ local function CreateExecuteAll(subOption) for index, childId in ipairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId); if(childData) then - local childOptions = WeakAuras.EnsureOptions(childData, subOption) + local childOptions = OptionsPrivate.EnsureOptions(childData, subOption) local childOption = childOptions; local childOptionTable = {[0] = childOption}; for i=1,#info do @@ -985,7 +983,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint) data.xOffset = v; WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); if(data.parent) then local parentData = WeakAuras.GetData(data.parent); if(parentData) then @@ -1007,7 +1005,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint) data.yOffset = v; WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); if(data.parent) then local parentData = WeakAuras.GetData(data.parent); if(parentData) then @@ -1022,7 +1020,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint) name = L["Anchor"], order = 70, hidden = IsParentDynamicGroup, - values = point_types, + values = OptionsPrivate.Private.point_types, disabled = disableSelfPoint, }, anchorFrameType = { @@ -1031,7 +1029,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint) name = L["Anchored To"], order = 72, hidden = IsParentDynamicGroup, - values = (data.regionType == "group" or data.regionType == "dynamicgroup") and WeakAuras.anchor_frame_types_group or WeakAuras.anchor_frame_types, + values = (data.regionType == "group" or data.regionType == "dynamicgroup") and OptionsPrivate.Private.anchor_frame_types_group or OptionsPrivate.Private.anchor_frame_types, }, -- Input field to select frame to anchor on anchorFrameFrame = { @@ -1059,7 +1057,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint) return not (data.anchorFrameType == "SELECTFRAME") end, func = function() - WeakAuras.StartFrameChooser(data, {"anchorFrameFrame"}); + OptionsPrivate.StartFrameChooser(data, {"anchorFrameFrame"}); end }, anchorPoint = { @@ -1085,7 +1083,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint) return data.anchorFrameType == "MOUSE"; end end, - values = point_types + values = OptionsPrivate.Private.point_types }, anchorPointGroup = { type = "select", @@ -1123,7 +1121,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint) width = WeakAuras.normalWidth, name = L["Frame Strata"], order = 78, - values = WeakAuras.frame_strata_types + values = OptionsPrivate.Private.frame_strata_types }, anchorFrameSpace = { type = "execute", @@ -1136,7 +1134,7 @@ local function PositionOptions(id, data, _, hideWidthHeight, disableSelfPoint) end }, }; - WeakAuras.commonOptions.AddCodeOption(positionOptions, data, L["Custom Anchor"], "custom_anchor", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-anchor-function", + OptionsPrivate.commonOptions.AddCodeOption(positionOptions, data, L["Custom Anchor"], "custom_anchor", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-anchor-function", 72.1, function() return not(data.anchorFrameType == "CUSTOM" and not IsParentDynamicGroup()) end, {"customAnchor"}, nil, nil, nil, nil, nil, true) return positionOptions; end @@ -1264,7 +1262,7 @@ local function AddCodeOption(args, data, name, prefix, url, order, hiddenFunc, p tinsert(extraFunctions, 1, { buttonLabel = L["Expand"], func = function(info) - WeakAuras.OpenTextEditor(WeakAuras.GetPickedDisplay(), path, encloseInFunction, multipath, reloadOptions, setOnParent, url) + OptionsPrivate.OpenTextEditor(OptionsPrivate.GetPickedDisplay(), path, encloseInFunction, multipath, reloadOptions, setOnParent, url) end }); @@ -1293,7 +1291,7 @@ local function AddCodeOption(args, data, name, prefix, url, order, hiddenFunc, p extraSetFunction(); end if (reloadOptions) then - WeakAuras.ClearOptions(data.id) + OptionsPrivate.ClearOptions(data.id) end end, get = function(info) @@ -1355,7 +1353,7 @@ local function AddCommonTriggerOptions(options, data, triggernum) local trigger = data.triggers[triggernum].trigger local trigger_types = {}; - for type, triggerSystem in pairs(WeakAuras.triggerTypes) do + for type, triggerSystem in pairs(OptionsPrivate.Private.triggerTypes) do trigger_types[type] = triggerSystem.GetName(type); end @@ -1379,7 +1377,7 @@ local function AddCommonTriggerOptions(options, data, triggernum) end, set = function(info, v) trigger.type = v; - local prototype = trigger.event and WeakAuras.event_prototypes[trigger.event]; + local prototype = trigger.event and OptionsPrivate.Private.event_prototypes[trigger.event]; if v == "status" and (not prototype or prototype.type == "event") then trigger.event = "Cooldown Progress (Spell)" elseif v == "event" and (not prototype or prototype.type == "status") then @@ -1447,23 +1445,23 @@ local function AddTriggerGetterSetter(options, data, triggernum) end -WeakAuras.commonOptions = {} -WeakAuras.commonOptions.parsePrefix = parsePrefix -WeakAuras.commonOptions.flattenRegionOptions = flattenRegionOptions -WeakAuras.commonOptions.fixMetaOrders = fixMetaOrders -WeakAuras.commonOptions.removeFuncs = removeFuncs -WeakAuras.commonOptions.CreateHiddenAll = CreateHiddenAll -WeakAuras.commonOptions.CreateDisabledAll = CreateDisabledAll -WeakAuras.commonOptions.replaceNameDescFuncs = replaceNameDescFuncs -WeakAuras.commonOptions.replaceImageFuncs = replaceImageFuncs -WeakAuras.commonOptions.replaceValuesFuncs = replaceValuesFuncs -WeakAuras.commonOptions.CreateGetAll = CreateGetAll -WeakAuras.commonOptions.CreateSetAll = CreateSetAll -WeakAuras.commonOptions.CreateExecuteAll = CreateExecuteAll +OptionsPrivate.commonOptions = {} +OptionsPrivate.commonOptions.parsePrefix = parsePrefix +OptionsPrivate.commonOptions.flattenRegionOptions = flattenRegionOptions +OptionsPrivate.commonOptions.fixMetaOrders = fixMetaOrders +OptionsPrivate.commonOptions.removeFuncs = removeFuncs +OptionsPrivate.commonOptions.CreateHiddenAll = CreateHiddenAll +OptionsPrivate.commonOptions.CreateDisabledAll = CreateDisabledAll +OptionsPrivate.commonOptions.replaceNameDescFuncs = replaceNameDescFuncs +OptionsPrivate.commonOptions.replaceImageFuncs = replaceImageFuncs +OptionsPrivate.commonOptions.replaceValuesFuncs = replaceValuesFuncs +OptionsPrivate.commonOptions.CreateGetAll = CreateGetAll +OptionsPrivate.commonOptions.CreateSetAll = CreateSetAll +OptionsPrivate.commonOptions.CreateExecuteAll = CreateExecuteAll -WeakAuras.commonOptions.PositionOptions = PositionOptions -WeakAuras.commonOptions.BorderOptions = BorderOptions -WeakAuras.commonOptions.AddCodeOption = AddCodeOption +OptionsPrivate.commonOptions.PositionOptions = PositionOptions +OptionsPrivate.commonOptions.BorderOptions = BorderOptions +OptionsPrivate.commonOptions.AddCodeOption = AddCodeOption -WeakAuras.commonOptions.AddCommonTriggerOptions = AddCommonTriggerOptions -WeakAuras.commonOptions.AddTriggerGetterSetter = AddTriggerGetterSetter +OptionsPrivate.commonOptions.AddCommonTriggerOptions = AddCommonTriggerOptions +OptionsPrivate.commonOptions.AddTriggerGetterSetter = AddTriggerGetterSetter diff --git a/WeakAurasOptions/ConditionOptions.lua b/WeakAurasOptions/ConditionOptions.lua index d0bd7bd..909aa3a 100644 --- a/WeakAurasOptions/ConditionOptions.lua +++ b/WeakAurasOptions/ConditionOptions.lua @@ -249,8 +249,7 @@ local function addControlsForChange(args, order, data, conditionVariable, condit local change = {}; change.property = conditions[i].changes[j].property; if (type(conditions[i].changes[j].value) == "table") then - change.value = {}; - WeakAuras.DeepCopy(conditions[i].changes[j].value, change.value) + change.value = CopyTable(conditions[i].changes[j].value) else change.value = conditions[i].changes[j].value; end @@ -501,9 +500,9 @@ local function addControlsForChange(args, order, data, conditionVariable, condit args["condition" .. i .. "value" .. j .. "sound_type"] = { type = "select", width = WeakAuras.normalWidth, - values = WeakAuras.sound_condition_types, + values = OptionsPrivate.Private.sound_condition_types, name = blueIfNoValue2(data, conditions[i].changes[j], "value", "sound_type", L["Differences"]), - desc = descIfNoValue2(data, conditions[i].changes[j], "value", "sound_type", propertyType, WeakAuras.sound_condition_types), + desc = descIfNoValue2(data, conditions[i].changes[j], "value", "sound_type", propertyType, OptionsPrivate.Private.sound_condition_types), order = order, get = function() return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.sound_type; @@ -530,9 +529,9 @@ local function addControlsForChange(args, order, data, conditionVariable, condit args["condition" .. i .. "value" .. j .. "sound"] = { type = "select", width = WeakAuras.normalWidth, - values = WeakAuras.sound_types, + values = OptionsPrivate.Private.sound_types, name = blueIfNoValue2(data, conditions[i].changes[j], "value", "sound", L["Differences"]), - desc = descIfNoValue2(data, conditions[i].changes[j], "value", "sound", propertyType, WeakAuras.sound_types), + desc = descIfNoValue2(data, conditions[i].changes[j], "value", "sound", propertyType, OptionsPrivate.Private.sound_types), order = order, get = function() return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.sound; @@ -546,9 +545,9 @@ local function addControlsForChange(args, order, data, conditionVariable, condit args["condition" .. i .. "value" .. j .. "sound_channel"] = { type = "select", width = WeakAuras.normalWidth, - values = WeakAuras.sound_channel_types, + values = OptionsPrivate.Private.sound_channel_types, name = blueIfNoValue2(data, conditions[i].changes[j], "value", "sound_channel", L["Sound Channel"], L["Sound Channel"]), - desc = descIfNoValue2(data, conditions[i].changes[j], "value", "sound_channel", propertyType, WeakAuras.sound_channel_types), + desc = descIfNoValue2(data, conditions[i].changes[j], "value", "sound_channel", propertyType, OptionsPrivate.Private.sound_channel_types), order = order, get = function() return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.sound_channel; @@ -633,9 +632,9 @@ local function addControlsForChange(args, order, data, conditionVariable, condit args["condition" .. i .. "value" .. j .. "message type"] = { type = "select", width = WeakAuras.normalWidth, - values = WeakAuras.send_chat_message_types, + values = OptionsPrivate.Private.send_chat_message_types, name = blueIfNoValue2(data, conditions[i].changes[j], "value", "message_type", L["Differences"]), - desc = descIfNoValue2(data, conditions[i].changes[j], "value", "message_type", propertyType, WeakAuras.send_chat_message_types), + desc = descIfNoValue2(data, conditions[i].changes[j], "value", "message_type", propertyType, OptionsPrivate.Private.send_chat_message_types), order = order, get = function() return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.message_type; @@ -677,8 +676,8 @@ local function addControlsForChange(args, order, data, conditionVariable, condit order = order + 1; local descMessage = descIfNoValue2(data, conditions[i].changes[j], "value", "message", propertyType); - if (not descMessage and data ~= WeakAuras.tempGroup) then - descMessage = L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(data) + if (not descMessage and data ~= OptionsPrivate.tempGroup) then + descMessage = L["Dynamic text tooltip"] .. OptionsPrivate.Private.GetAdditionalProperties(data) end local message_getter = function() @@ -728,21 +727,21 @@ local function addControlsForChange(args, order, data, conditionVariable, condit local hasTextFormatOption local hidden = function() - return WeakAuras.IsCollapsed("format_option", "conditions", i .. "#" .. j , true) + return OptionsPrivate.IsCollapsed("format_option", "conditions", i .. "#" .. j , true) end local setHidden = function(hidden) - WeakAuras.SetCollapsed("format_option", "conditions", i .. "#" .. j, hidden) + OptionsPrivate.SetCollapsed("format_option", "conditions", i .. "#" .. j, hidden) end if data.controlledChildren then for id, reference in pairs(conditions[i].changes[j].references) do local input = reference.value and reference.value.message - hasTextFormatOption = WeakAuras.AddTextFormatOption(input, true, formatGet, addOption, hidden, setHidden) + hasTextFormatOption = OptionsPrivate.AddTextFormatOption(input, true, formatGet, addOption, hidden, setHidden) end else local input = type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value["message"] - hasTextFormatOption = WeakAuras.AddTextFormatOption(input, true, formatGet, addOption, hidden, setHidden) + hasTextFormatOption = OptionsPrivate.AddTextFormatOption(input, true, formatGet, addOption, hidden, setHidden) end if hasTextFormatOption then @@ -757,7 +756,7 @@ local function addControlsForChange(args, order, data, conditionVariable, condit local function customHidden() local message = type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.message; if (not message) then return true; end - return not WeakAuras.ContainsCustomPlaceHolder(message); + return not OptionsPrivate.Private.ContainsCustomPlaceHolder(message); end args["condition" .. i .. "value" .. j .. "custom"] = { @@ -786,9 +785,9 @@ local function addControlsForChange(args, order, data, conditionVariable, condit local changeIndex = reference.changeIndex; multipath[id] = {"conditions", conditionIndex, "changes", changeIndex, "value", "custom"}; end - WeakAuras.OpenTextEditor(data, multipath, nil, true, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-check"); + OptionsPrivate.OpenTextEditor(data, multipath, nil, true, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-check"); else - WeakAuras.OpenTextEditor(data, {"conditions", i, "changes", j, "value", "custom"}, nil, nil, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-check"); + OptionsPrivate.OpenTextEditor(data, {"conditions", i, "changes", j, "value", "custom"}, nil, nil, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-check"); end end } @@ -815,7 +814,7 @@ local function addControlsForChange(args, order, data, conditionVariable, condit if (not message) then return true; end - if (not WeakAuras.ContainsPlaceHolders(message, "c")) then + if (not OptionsPrivate.Private.ContainsPlaceHolders(message, "c")) then return true; end @@ -865,10 +864,10 @@ local function addControlsForChange(args, order, data, conditionVariable, condit childData.conditions[conditionIndex].changes[changeIndex].value = childData.conditions[conditionIndex].changes[changeIndex].value or {}; multipath[id] = {"conditions", conditionIndex, "changes", changeIndex, "value", "custom"}; end - WeakAuras.OpenTextEditor(data, multipath, true, true, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#run-custom-code"); + OptionsPrivate.OpenTextEditor(data, multipath, true, true, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#run-custom-code"); else data.conditions[i].changes[j].value = data.conditions[i].changes[j].value or {}; - WeakAuras.OpenTextEditor(data, {"conditions", i, "changes", j, "value", "custom"}, true, nil, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#run-custom-code"); + OptionsPrivate.OpenTextEditor(data, {"conditions", i, "changes", j, "value", "custom"}, true, nil, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#run-custom-code"); end end } @@ -932,15 +931,15 @@ local function addControlsForChange(args, order, data, conditionVariable, condit return false end - local glowTypesExcepButtonOverlay = CopyTable(WeakAuras.glow_types) + local glowTypesExcepButtonOverlay = CopyTable(OptionsPrivate.Private.glow_types) glowTypesExcepButtonOverlay["buttonOverlay"] = nil args["condition" .. i .. "value" .. j .. "glow_action"] = { type = "select", - values = WeakAuras.glow_action_types, + values = OptionsPrivate.Private.glow_action_types, width = WeakAuras.normalWidth, name = blueIfNoValue2(data, conditions[i].changes[j], "value", "glow_action", L["Glow Action"], L["Glow Action"]), - desc = descIfNoValue2(data, conditions[i].changes[j], "value", "glow_action", propertyType, WeakAuras.glow_action_types), + desc = descIfNoValue2(data, conditions[i].changes[j], "value", "glow_action", propertyType, OptionsPrivate.Private.glow_action_types), order = order, get = function() return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.glow_action; @@ -950,7 +949,7 @@ local function addControlsForChange(args, order, data, conditionVariable, condit order = order + 1 args["condition" .. i .. "value" .. j .. "glow_frame_type"] = { type = "select", - values = WeakAuras.glow_frame_types, + values = OptionsPrivate.Private.glow_frame_types, width = WeakAuras.normalWidth, name = blueIfNoValue2(data, conditions[i].changes[j], "value", "glow_frame_type", L["Glow Frame Type"], L["Glow Frame Type"]), desc = descIfNoValue2(data, conditions[i].changes[j], "value", "glow_frame_type", propertyType, { @@ -961,23 +960,23 @@ local function addControlsForChange(args, order, data, conditionVariable, condit get = function() return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.glow_frame_type; end, - hidden = function() return not anyGlowExternal("glow_action", WeakAuras.glow_action_types) end, + hidden = function() return not anyGlowExternal("glow_action", OptionsPrivate.Private.glow_action_types) end, set = setValueComplex("glow_frame_type") } order = order + 1 args["condition" .. i .. "value" .. j .. "glow_type"] = { type = "select", - values = WeakAuras.glow_types, + values = OptionsPrivate.Private.glow_types, width = WeakAuras.normalWidth, name = blueIfNoValue2(data, conditions[i].changes[j], "value", "glow_type", L["Glow Type"], L["Glow Type"]), - desc = descIfNoValue2(data, conditions[i].changes[j], "value", "glow_type", propertyType, WeakAuras.glow_types), + desc = descIfNoValue2(data, conditions[i].changes[j], "value", "glow_type", propertyType, OptionsPrivate.Private.glow_types), order = order, get = function() return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.glow_type; end, set = setValueComplex("glow_type"), hidden = function() - return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_frame_type", WeakAuras.glow_frame_types)) + return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_frame_type", OptionsPrivate.Private.glow_frame_types)) end } order = order + 1 @@ -1003,7 +1002,7 @@ local function addControlsForChange(args, order, data, conditionVariable, condit desc = descIfNoValue2(data, conditions[i].changes[j], "value", "glow_frame", propertyType), order = order, func = function() - WeakAuras.StartFrameChooser(data, {"conditions", i, "changes", j, "value", "glow_frame"}); + OptionsPrivate.StartFrameChooser(data, {"conditions", i, "changes", j, "value", "glow_frame"}); end, hidden = function() return not anyGlowExternal("glow_frame_type", "FRAMESELECTOR") @@ -1021,7 +1020,7 @@ local function addControlsForChange(args, order, data, conditionVariable, condit end, set = setValueComplex("use_glow_color"), hidden = function() - return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", WeakAuras.glow_types)) + return not (anyGlowExternal("glow_action", "show") and anyGlowExternal("glow_type", OptionsPrivate.Private.glow_types)) end } order = order + 1 @@ -1040,8 +1039,8 @@ local function addControlsForChange(args, order, data, conditionVariable, condit set = setValueColorComplex("glow_color"), hidden = function() return not (anyGlowExternal("glow_action", "show") - and anyGlowExternal("glow_frame_type", WeakAuras.glow_frame_types) - and anyGlowExternal("glow_type", WeakAuras.glow_types)) + and anyGlowExternal("glow_frame_type", OptionsPrivate.Private.glow_frame_types) + and anyGlowExternal("glow_type", OptionsPrivate.Private.glow_types)) end, disabled = function() return not anyGlowExternal("use_glow_color", true) end } @@ -1368,8 +1367,7 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit local copy = {}; copy.property = change.property; if (type(change.value) == "table") then - copy.value = {}; - WeakAuras.DeepCopy(change.value, copy.value); + copy.value = CopyTable(change.value); else copy.value = change.value; end @@ -1510,11 +1508,11 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit end if (currentConditionTemplate.type == "number" or currentConditionTemplate.type == "timer") then - local opTypes = WeakAuras.operator_types + local opTypes = OptionsPrivate.Private.operator_types if currentConditionTemplate.operator_types == "without_equal" then - opTypes = WeakAuras.operator_types_without_equal + opTypes = OptionsPrivate.Private.operator_types_without_equal elseif currentConditionTemplate.operator_types == "only_equal" then - opTypes = WeakAuras.equality_operator_types + opTypes = OptionsPrivate.Private.equality_operator_types end args["condition" .. i .. tostring(path) .. "_op"] = { @@ -1552,7 +1550,7 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit type = "select", width = WeakAuras.normalWidth, order = order, - values = WeakAuras.equality_operator_types, + values = OptionsPrivate.Private.equality_operator_types, get = function() return check.op; end, @@ -1615,7 +1613,7 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit name = blueIfNoValue(data, conditions[i].check, "value", L["Differences"]), desc = descIfNoValue(data, conditions[i].check, "value", currentConditionTemplate.type), order = order, - values = WeakAuras.bool_types, + values = OptionsPrivate.Private.bool_types, get = function() return check and check.value; end, @@ -1630,7 +1628,7 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit type = "select", width = WeakAuras.normalWidth, order = order, - values = WeakAuras.string_operator_types, + values = OptionsPrivate.Private.string_operator_types, get = function() return check and check.op; end, @@ -1699,7 +1697,7 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit end tinsert(multipath[id], "value") end - WeakAuras.OpenTextEditor(data, multipath, nil, true, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-check"); + OptionsPrivate.OpenTextEditor(data, multipath, nil, true, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-check"); else for i, v in ipairs(path) do print(i, v) @@ -1712,7 +1710,7 @@ local function addControlsForIfLine(args, order, data, conditionVariable, condit end tinsert(fullPath, "value") - WeakAuras.OpenTextEditor(data, fullPath, nil, nil, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-check"); + OptionsPrivate.OpenTextEditor(data, fullPath, nil, nil, nil, nil, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-check"); end end } @@ -1772,13 +1770,13 @@ local function addControlsForCondition(args, order, data, conditionVariable, con if data.controlledChildren then for id, reference in pairs(conditions[i].check.references) do local index = reference.conditionIndex; - if WeakAuras.IsCollapsed(id, "condition", index, false) then + if OptionsPrivate.IsCollapsed(id, "condition", index, false) then collapsed = true; break; end end else - collapsed = WeakAuras.IsCollapsed(data.id, "condition", i, false); + collapsed = OptionsPrivate.IsCollapsed(data.id, "condition", i, false); end args["condition" .. i .. "header"] = { @@ -1790,10 +1788,10 @@ local function addControlsForCondition(args, order, data, conditionVariable, con if data.controlledChildren then for id, reference in pairs(conditions[i].check.references) do local index = reference.conditionIndex - WeakAuras.SetCollapsed(id, "condition", index, not collapsed); + OptionsPrivate.SetCollapsed(id, "condition", index, not collapsed); end else - WeakAuras.SetCollapsed(data.id, "condition", i, not collapsed); + OptionsPrivate.SetCollapsed(data.id, "condition", i, not collapsed); end WeakAuras.ClearAndUpdateOptions(data.id, true) end, @@ -2041,8 +2039,7 @@ local function mergeConditionTemplates(allConditionTemplates, auraConditionsTemp allConditionTemplates[triggernum] = allConditionTemplates[triggernum] or {}; for conditionName in pairs(auraTemplatesForTrigger) do if not allConditionTemplates[triggernum][conditionName] then - allConditionTemplates[triggernum][conditionName] = {}; - WeakAuras.DeepCopy(auraTemplatesForTrigger[conditionName], allConditionTemplates[triggernum][conditionName]); + allConditionTemplates[triggernum][conditionName] = CopyTable(auraTemplatesForTrigger[conditionName]); else if (allConditionTemplates[triggernum][conditionName].type ~= auraTemplatesForTrigger[conditionName].type) then -- Two different trigger types have a condition of the same name, with incompatible types @@ -2126,11 +2123,11 @@ local function createConditionTemplates(data) local data = WeakAuras.GetData(id); numTriggers = max(numTriggers, #data.triggers); - local auraConditionsTemplate = WeakAuras.GetTriggerConditions(data); + local auraConditionsTemplate = OptionsPrivate.Private.GetTriggerConditions(data); mergeConditionTemplates(allConditionTemplates, auraConditionsTemplate, numTriggers) end else - allConditionTemplates = WeakAuras.GetTriggerConditions(data); + allConditionTemplates = OptionsPrivate.Private.GetTriggerConditions(data); numTriggers = #data.triggers; end @@ -2144,13 +2141,12 @@ local function createConditionTemplates(data) type = "combination" } } - allConditionTemplates[-1] = WeakAuras.GetGlobalConditions(); + allConditionTemplates[-1] = OptionsPrivate.Private.GetGlobalConditions(); local conditionTemplates = createConditionTemplatesValueList(allConditionTemplates, numTriggers); if (data.controlledChildren) then - conditionTemplates.displayWithCopy = {}; - WeakAuras.DeepCopy(conditionTemplates.display, conditionTemplates.displayWithCopy); + conditionTemplates.displayWithCopy = CopyTable(conditionTemplates.display); conditionTemplates.displayWithCopy[9998] = "•" .. L["Copy to all auras"] .. "•"; conditionTemplates.indexToTrigger[9998] = "COPY"; @@ -2168,7 +2164,7 @@ local function buildAllPotentialProperties(data, category) if (data.controlledChildren) then for _, id in ipairs(data.controlledChildren) do local auradata = WeakAuras.GetData(id); - local regionProperties = WeakAuras.GetProperties(auradata); + local regionProperties = OptionsPrivate.Private.GetProperties(auradata); if (regionProperties) then for k, v in pairs(regionProperties) do if (v.category == category) then @@ -2186,15 +2182,14 @@ local function buildAllPotentialProperties(data, category) end end else - allProperties.propertyMap[k] = {}; - WeakAuras.DeepCopy(v, allProperties.propertyMap[k]) + allProperties.propertyMap[k] = CopyTable(v) end end end end end else - local regionProperties = WeakAuras.GetProperties(data); + local regionProperties = OptionsPrivate.Private.GetProperties(data); if (regionProperties) then for k, v in pairs(regionProperties) do if (v.category == category) then @@ -2231,8 +2226,7 @@ local function buildAllPotentialProperties(data, category) allProperties.indexToProperty[9999] = "DELETE"; if (data.controlledChildren) then - allProperties.displayWithCopy = {}; - WeakAuras.DeepCopy(allProperties.display, allProperties.displayWithCopy); + allProperties.displayWithCopy = CopyTable(allProperties.display); allProperties.displayWithCopy[9998] = "•" .. L["Copy to all auras"] .. "•"; allProperties.indexToProperty[9998] = "COPY"; @@ -2346,7 +2340,7 @@ local function SubPropertiesForChange(change) local getter = function(key) return change.value["message_format_" .. key] end - WeakAuras.AddTextFormatOption(input, false, getter, function(key) + OptionsPrivate.AddTextFormatOption(input, false, getter, function(key) tinsert(result, "message_format_" .. key) end) end @@ -2426,8 +2420,7 @@ local function mergeCondition(all, aura, id, conditionIndex, allProperties) for changeIndex, change in ipairs(aura.changes) do local matchIndex = findMatchingProperty(all.changes, change, id); if (not matchIndex) then - local copy = {}; - WeakAuras.DeepCopy(change, copy); + local copy = CopyTable(change); local propertyType = change.property and allProperties.propertyMap[change.property] and allProperties.propertyMap[change.property].type; if (propertyType == "chat" or propertyType == "sound" or propertyType == "customcode" or propertyType == "glowexternal") then @@ -2463,8 +2456,7 @@ local function mergeConditions(all, aura, id, allConditionTemplates, propertyTyp for conditionIndex, condition in ipairs(aura) do local match = findMatchingCondition(all, condition, currentInsertPoint, allConditionTemplates); if (not match) then - local copy = {}; - WeakAuras.DeepCopy(condition, copy); + local copy = CopyTable(condition); copy.check.samevalue = true; copy.check.sameop = true; copy.check.references = {}; @@ -2504,7 +2496,7 @@ local function mergeConditions(all, aura, id, allConditionTemplates, propertyTyp end end -function WeakAuras.GetConditionOptions(data) +function OptionsPrivate.GetConditionOptions(data) local options = { type = "group", name = L["Conditions"], @@ -2557,7 +2549,7 @@ function WeakAuras.GetConditionOptions(data) aura[conditionVariable][#aura[conditionVariable]].changes = {}; aura[conditionVariable][#aura[conditionVariable]].changes[1] = {} aura[conditionVariable][#aura[conditionVariable]].category = category; - WeakAuras.SetCollapsed(id, "condition", #aura[conditionVariable], false); + OptionsPrivate.SetCollapsed(id, "condition", #aura[conditionVariable], false); WeakAuras.Add(aura); end WeakAuras.ClearAndUpdateOptions(data.id, true) @@ -2567,7 +2559,7 @@ function WeakAuras.GetConditionOptions(data) conditions[#conditions].changes = {}; conditions[#conditions].changes[1] = {} conditions[#conditions].category = category; - WeakAuras.SetCollapsed(data.id, "condition", #conditions, false); + OptionsPrivate.SetCollapsed(data.id, "condition", #conditions, false); WeakAuras.Add(data); WeakAuras.ClearAndUpdateOptions(data.id, true) end diff --git a/WeakAurasOptions/DisplayOptions.lua b/WeakAurasOptions/DisplayOptions.lua index d1d3ff6..b190bf4 100644 --- a/WeakAurasOptions/DisplayOptions.lua +++ b/WeakAurasOptions/DisplayOptions.lua @@ -1,26 +1,25 @@ if not WeakAuras.IsCorrectVersion() then return end local AddonName, OptionsPrivate = ... - local L = WeakAuras.L local regionOptions = WeakAuras.regionOptions -local flattenRegionOptions = WeakAuras.commonOptions.flattenRegionOptions -local fixMetaOrders = WeakAuras.commonOptions.fixMetaOrders -local parsePrefix = WeakAuras.commonOptions.parsePrefix -local removeFuncs = WeakAuras.commonOptions.removeFuncs -local replaceNameDescFuncs = WeakAuras.commonOptions.replaceNameDescFuncs -local replaceImageFuncs = WeakAuras.commonOptions.replaceImageFuncs -local replaceValuesFuncs = WeakAuras.commonOptions.replaceValuesFuncs -local disabledAll = WeakAuras.commonOptions.CreateDisabledAll("region") -local hiddenAll = WeakAuras.commonOptions.CreateHiddenAll("region") -local getAll = WeakAuras.commonOptions.CreateGetAll("region") -local setAll = WeakAuras.commonOptions.CreateSetAll("region", getAll) +local flattenRegionOptions = OptionsPrivate.commonOptions.flattenRegionOptions +local fixMetaOrders = OptionsPrivate.commonOptions.fixMetaOrders +local parsePrefix = OptionsPrivate.commonOptions.parsePrefix +local removeFuncs = OptionsPrivate.commonOptions.removeFuncs +local replaceNameDescFuncs = OptionsPrivate.commonOptions.replaceNameDescFuncs +local replaceImageFuncs = OptionsPrivate.commonOptions.replaceImageFuncs +local replaceValuesFuncs = OptionsPrivate.commonOptions.replaceValuesFuncs +local disabledAll = OptionsPrivate.commonOptions.CreateDisabledAll("region") +local hiddenAll = OptionsPrivate.commonOptions.CreateHiddenAll("region") +local getAll = OptionsPrivate.commonOptions.CreateGetAll("region") +local setAll = OptionsPrivate.commonOptions.CreateSetAll("region", getAll) local function AddSubRegionImpl(data, subRegionName) data.subRegions = data.subRegions or {} - if WeakAuras.subRegionTypes[subRegionName] and WeakAuras.subRegionTypes[subRegionName] then - if WeakAuras.subRegionTypes[subRegionName].supports(data.regionType) then - local default = WeakAuras.subRegionTypes[subRegionName].default + if OptionsPrivate.Private.subRegionTypes[subRegionName] and OptionsPrivate.Private.subRegionTypes[subRegionName] then + if OptionsPrivate.Private.subRegionTypes[subRegionName].supports(data.regionType) then + local default = OptionsPrivate.Private.subRegionTypes[subRegionName].default local subRegionData = type(default) == "function" and default(data.regionType) or CopyTable(default) subRegionData.type = subRegionName tinsert(data.subRegions, subRegionData) @@ -31,7 +30,7 @@ local function AddSubRegionImpl(data, subRegionName) end local function AddSubRegion(data, subRegionName) - if (WeakAuras.ApplyToDataOrChildData(data, AddSubRegionImpl, subRegionName)) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(data, AddSubRegionImpl, subRegionName)) then WeakAuras.ClearAndUpdateOptions(data.id) end end @@ -48,7 +47,7 @@ local function AddOptionsForSupportedSubRegion(regionOption, data, supported) result.__title = L["Add Extra Elements"] result.__topLine = true for subRegionType in pairs(supported) do - if WeakAuras.subRegionTypes[subRegionType].supportsAdd then + if OptionsPrivate.Private.subRegionTypes[subRegionType].supportsAdd then hasSubRegions = true result[subRegionType .. "space"] = { type = "description", @@ -60,7 +59,7 @@ local function AddOptionsForSupportedSubRegion(regionOption, data, supported) result[subRegionType] = { type = "execute", width = WeakAuras.normalWidth, - name = string.format(L["Add %s"], WeakAuras.subRegionTypes[subRegionType].displayName), + name = string.format(L["Add %s"], OptionsPrivate.Private.subRegionTypes[subRegionType].displayName), order = order, func = function() AddSubRegion(data, subRegionType) @@ -84,7 +83,7 @@ local function union(table1, table2) return meta; end -function WeakAuras.GetDisplayOptions(data) +function OptionsPrivate.GetDisplayOptions(data) local id = data.id if not data.controlledChildren then @@ -100,10 +99,10 @@ function WeakAuras.GetDisplayOptions(data) local subIndex = {} for index, subRegionData in ipairs(data.subRegions) do local subRegionType = subRegionData.type - if WeakAuras.subRegionOptions[subRegionType] then + if OptionsPrivate.Private.subRegionOptions[subRegionType] then hasSubElements = true subIndex[subRegionType] = subIndex[subRegionType] and subIndex[subRegionType] + 1 or 1 - local options, common = WeakAuras.subRegionOptions[subRegionType].create(data, subRegionData, index, subIndex[subRegionType]) + local options, common = OptionsPrivate.Private.subRegionOptions[subRegionType].create(data, subRegionData, index, subIndex[subRegionType]) options.__order = 200 + index regionOption["sub." .. index .. "." .. subRegionType] = options commonOption[subRegionType] = common @@ -119,7 +118,7 @@ function WeakAuras.GetDisplayOptions(data) end local supported = {} - for subRegionName, subRegionType in pairs(WeakAuras.subRegionTypes) do + for subRegionName, subRegionType in pairs(OptionsPrivate.Private.subRegionTypes) do if subRegionType.supports(data.regionType) then supported[subRegionName] = true end @@ -189,7 +188,7 @@ function WeakAuras.GetDisplayOptions(data) WeakAuras.Add(parentData); end end - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end, args = options }; @@ -227,7 +226,7 @@ function WeakAuras.GetDisplayOptions(data) }, } end - for subRegionName, subRegionType in pairs(WeakAuras.subRegionTypes) do + for subRegionName, subRegionType in pairs(OptionsPrivate.Private.subRegionTypes) do if subRegionType.supports(childData.regionType) then supportedSubRegions[subRegionName] = true end @@ -238,13 +237,13 @@ function WeakAuras.GetDisplayOptions(data) for index, subRegionData in ipairs(childData.subRegions) do local subRegionType = subRegionData.type local alreadyHandled = handledSubRegionTypes[index] and handledSubRegionTypes[index][subRegionType] - if WeakAuras.subRegionOptions[subRegionType] and not alreadyHandled then + if OptionsPrivate.Private.subRegionOptions[subRegionType] and not alreadyHandled then handledSubRegionTypes[index] = handledSubRegionTypes[index] or {} handledSubRegionTypes[index][subRegionType] = true hasSubElements = true subIndex[subRegionType] = subIndex[subRegionType] and subIndex[subRegionType] + 1 or 1 - local options, common = WeakAuras.subRegionOptions[subRegionType].create(data, nil, index, subIndex[subRegionType]) + local options, common = OptionsPrivate.Private.subRegionOptions[subRegionType].create(data, nil, index, subIndex[subRegionType]) options.__order = 200 + index allOptions["sub." .. index .. "." .. subRegionType] = options @@ -295,7 +294,7 @@ function WeakAuras.GetDisplayOptions(data) if(type(data.id) == "string") then WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end end region.hidden = function(info, ...) return hiddenAll(data, info, ...); end; diff --git a/WeakAurasOptions/ExternalAddons.lua b/WeakAurasOptions/ExternalAddons.lua index 1d18dae..8224f72 100644 --- a/WeakAurasOptions/ExternalAddons.lua +++ b/WeakAurasOptions/ExternalAddons.lua @@ -7,18 +7,16 @@ local pairs = pairs local AceGUI = LibStub("AceGUI-3.0") -local collisions = WeakAuras.collisions local displayButtons = WeakAuras.displayButtons -local savedVars = WeakAuras.savedVars local importAddonButtons = {} local importDisplayButtons = {} WeakAuras.importDisplayButtons = importDisplayButtons -function WeakAuras.CreateImportButtons() +function OptionsPrivate.CreateImportButtons() wipe(importAddonButtons); wipe(importDisplayButtons); - for addonName, addonData in pairs(WeakAuras.addons) do + for addonName, addonData in pairs(OptionsPrivate.Private) do local addonButton = AceGUI:Create("WeakAurasImportButton"); importAddonButtons[addonName] = addonButton; addonButton:SetTitle(addonData.displayName); @@ -56,7 +54,7 @@ function WeakAuras.CreateImportButtons() end end end - WeakAuras.ResolveCollisions(function() + OptionsPrivate.Private.ResolveCollisions(function() for groupId, dataFromAddon in pairs(addonData.displays) do if(dataFromAddon.controlledChildren) then local data = WeakAuras.GetData(groupId); @@ -75,7 +73,7 @@ function WeakAuras.CreateImportButtons() end end - WeakAuras.ScanForLoads(); + OptionsPrivate.Private.ScanForLoads(); WeakAuras.SortDisplayButtons(); end); end); @@ -83,7 +81,7 @@ function WeakAuras.CreateImportButtons() local function UpdateAddonChecked() local shouldBeChecked = true; for id, data in pairs(addonData.displays) do - if not(WeakAuras.IsDefinedByAddon(id)) then + if not(OptionsPrivate.Private.IsDefinedByAddon(id)) then shouldBeChecked = false; break; end @@ -106,7 +104,7 @@ function WeakAuras.CreateImportButtons() local function UpdateGroupChecked() local shouldBeChecked = true; for index, childId in pairs(data.controlledChildren) do - if not(WeakAuras.IsDefinedByAddon(childId)) then + if not(OptionsPrivate.Private.IsDefinedByAddon(childId)) then shouldBeChecked = false; break; end @@ -121,7 +119,7 @@ function WeakAuras.CreateImportButtons() local childButton = AceGUI:Create("WeakAurasImportButton"); importDisplayButtons[childId] = childButton; - local data = WeakAuras.addons[addonName].displays[childId]; + local data = OptionsPrivate.Private[addonName].displays[childId]; childButton:SetTitle(childId); childButton:SetDescription(data.desc); @@ -134,14 +132,14 @@ function WeakAuras.CreateImportButtons() else WeakAuras.DisableAddonDisplay(childId); end - WeakAuras.ResolveCollisions(function() - WeakAuras.ScanForLoads(); + OptionsPrivate.Private.ResolveCollisions(function() + OptionsPrivate.Private.ScanForLoads(); WeakAuras.SortDisplayButtons(); UpdateGroupChecked(); end); end); childButton.updateChecked = UpdateGroupChecked; - childButton.checkbox:SetChecked(WeakAuras.IsDefinedByAddon(childId)); + childButton.checkbox:SetChecked(OptionsPrivate.Private.IsDefinedByAddon(childId)); end groupButton:SetClick(function() @@ -160,7 +158,7 @@ function WeakAuras.CreateImportButtons() WeakAuras.DisableAddonDisplay(childId); end end - WeakAuras.ResolveCollisions(function() + OptionsPrivate.Private.ResolveCollisions(function() local data = WeakAuras.GetData(id); if(data) then for index, childId in pairs(data.controlledChildren) do @@ -175,7 +173,7 @@ function WeakAuras.CreateImportButtons() WeakAuras.ClearAndUpdateOptions(data.id); end - WeakAuras.ScanForLoads(); + OptionsPrivate.Private.ScanForLoads(); WeakAuras.SortDisplayButtons(); UpdateAddonChecked(); end); @@ -204,13 +202,13 @@ function WeakAuras.CreateImportButtons() else WeakAuras.DisableAddonDisplay(id); end - WeakAuras.ResolveCollisions(function() + OptionsPrivate.Private.ResolveCollisions(function() WeakAuras.SortDisplayButtons() UpdateAddonChecked(); end); end); displayButton.updateChecked = UpdateAddonChecked; - displayButton.checkbox:SetChecked(WeakAuras.IsDefinedByAddon(id)); + displayButton.checkbox:SetChecked(OptionsPrivate.Private.IsDefinedByAddon(id)); end end @@ -229,7 +227,7 @@ function WeakAuras.SortImportButtons(newContainer) container = newContainer or container; wipe(container.children); local toSort = {}; - for addon, addonData in pairs(WeakAuras.addons) do + for addon, addonData in pairs(OptionsPrivate.Private) do container:AddChild(importAddonButtons[addon]); wipe(toSort); for id, data in pairs(addonData.displays) do @@ -262,29 +260,28 @@ function WeakAuras.SortImportButtons(newContainer) end function WeakAuras.EnableAddonDisplay(id) - local db = savedVars.db + local db = OptionsPrivate.savedVars.db if not(db.registered[id]) then local addon, data; - for addonName, addonData in pairs(WeakAuras.addons) do + for addonName, addonData in pairs(OptionsPrivate.Private) do if(addonData.displays[id]) then addon = addonName; - data = {} - WeakAuras.DeepCopy(addonData.displays[id], data); + data = CopyTable(addonData.displays[id]); break; end end if(db.displays[id]) then -- ID collision - collisions[id] = {addon, data}; + OptionsPrivate.Private.collisions[id] = {addon, data}; else db.registered[id] = addon; if(data.controlledChildren) then wipe(data.controlledChildren); end WeakAuras.Add(data); - WeakAuras.SyncParentChildRelationships(true); - WeakAuras.AddDisplayButton(data); + OptionsPrivate.Private.SyncParentChildRelationships(true); + OptionsPrivate.AddDisplayButton(data); end end end @@ -297,7 +294,7 @@ end function WeakAuras.DisableAddonDisplay(id) local frame = WeakAuras.OptionsFrame() - local db = savedVars.db + local db = OptionsPrivate.savedVars.db db.registered[id] = false; local data = WeakAuras.GetData(id); if(data) then @@ -320,7 +317,7 @@ function WeakAuras.DisableAddonDisplay(id) end WeakAuras.Delete(data); - WeakAuras.SyncParentChildRelationships(true); + OptionsPrivate.Private.SyncParentChildRelationships(true); frame.buttonsScroll:DeleteChild(displayButtons[id]); displayButtons[id] = nil; diff --git a/WeakAurasOptions/GenericTrigger.lua b/WeakAurasOptions/GenericTrigger.lua index 1b0bdcb..a5bae2f 100644 --- a/WeakAurasOptions/GenericTrigger.lua +++ b/WeakAurasOptions/GenericTrigger.lua @@ -3,15 +3,6 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L; -local event_types = WeakAuras.event_types; -local status_types = WeakAuras.status_types; -local check_types = WeakAuras.check_types; -local subevent_prefix_types = WeakAuras.subevent_prefix_types; -local subevent_actual_prefix_types = WeakAuras.subevent_actual_prefix_types; -local subevent_suffix_types = WeakAuras.subevent_suffix_types; -local custom_trigger_types = WeakAuras.custom_trigger_types; -local eventend_types = WeakAuras.eventend_types; - local function GetCustomTriggerOptions(data, triggernum) local id = data.id; local trigger = data.triggers[triggernum].trigger @@ -38,7 +29,7 @@ local function GetCustomTriggerOptions(data, triggernum) name = L["Event Type"], order = 7, width = WeakAuras.doubleWidth, - values = custom_trigger_types, + values = OptionsPrivate.Private.custom_trigger_types, hidden = function() return not (trigger.type == "custom") end, get = function(info) return trigger.custom_type @@ -55,7 +46,7 @@ local function GetCustomTriggerOptions(data, triggernum) name = L["Check On..."], width = WeakAuras.doubleWidth / 3, order = 8, - values = check_types, + values = OptionsPrivate.Private.check_types, hidden = function() return not (trigger.type == "custom" and (trigger.custom_type == "status" or trigger.custom_type == "stateupdate") and trigger.check ~= "update") @@ -72,7 +63,7 @@ local function GetCustomTriggerOptions(data, triggernum) name = L["Check On..."], order = 9, width = WeakAuras.doubleWidth, - values = check_types, + values = OptionsPrivate.Private.check_types, hidden = function() return not (trigger.type == "custom" and (trigger.custom_type == "status" or trigger.custom_type == "stateupdate") and trigger.check == "update") @@ -125,12 +116,12 @@ local function GetCustomTriggerOptions(data, triggernum) trueEvent = string.upper(i) elseif trueEvent == "CLEU" or trueEvent == "COMBAT_LOG_EVENT_UNFILTERED" then local subevent = string.upper(i) - if not WeakAuras.IsCLEUSubevent(subevent) then + if not OptionsPrivate.Private.IsCLEUSubevent(subevent) then return "|cFFFF0000"..L["%s is not a valid SubEvent for COMBAT_LOG_EVENT_UNFILTERED"]:format(subevent) end elseif trueEvent:match("^UNIT_") then local unit = string.lower(i) - if not WeakAuras.baseUnitId[unit] and not WeakAuras.multiUnitId[unit] then + if not OptionsPrivate.Private.baseUnitId[unit] and not OptionsPrivate.Private.multiUnitId[unit] then return "|cFFFF0000"..L["Unit %s is not a valid unit for RegisterUnitEvent"]:format(unit) end end @@ -156,12 +147,12 @@ local function GetCustomTriggerOptions(data, triggernum) if not trueEvent then trueEvent = string.upper(i) elseif trueEvent == "CLEU" or trueEvent == "COMBAT_LOG_EVENT_UNFILTERED" then - if not WeakAuras.IsCLEUSubevent(string.upper(i)) then + if not OptionsPrivate.Private.IsCLEUSubevent(string.upper(i)) then return false end elseif trueEvent:match("^UNIT_") then local unit = string.lower(i) - if not WeakAuras.baseUnitId[unit] then + if not OptionsPrivate.Private.baseUnitId[unit] then return false end end @@ -177,7 +168,7 @@ local function GetCustomTriggerOptions(data, triggernum) name = L["Hide"], order = 12, hidden = function() return not (trigger.type == "custom" and trigger.custom_type == "event" and trigger.custom_hide ~= "custom") end, - values = eventend_types, + values = OptionsPrivate.Private.eventend_types, get = function() trigger.custom_hide = trigger.custom_hide or "timed"; return trigger.custom_hide end, set = function(info, v) trigger.custom_hide = v; @@ -191,7 +182,7 @@ local function GetCustomTriggerOptions(data, triggernum) order = 12, width = WeakAuras.doubleWidth, hidden = function() return not (trigger.type == "custom" and trigger.custom_type == "event" and trigger.custom_hide == "custom") end, - values = eventend_types, + values = OptionsPrivate.Private.eventend_types, get = function() return trigger.custom_hide end, set = function(info, v) trigger.custom_hide = v; @@ -275,21 +266,21 @@ local function GetCustomTriggerOptions(data, triggernum) local function hideCustomTrigger() return not (trigger.type == "custom") end - WeakAuras.commonOptions.AddCodeOption(customOptions, data, L["Custom Trigger"], "custom_trigger", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-trigger", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, L["Custom Trigger"], "custom_trigger", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-trigger", 10, hideCustomTrigger, appendToTriggerPath("custom"), false, true, extraSetFunction, nil, true); local function hideCustomVariables() return not (trigger.type == "custom" and trigger.custom_type == "stateupdate"); end - WeakAuras.commonOptions.AddCodeOption(customOptions, data, L["Custom Variables"], "custom_variables", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-variables", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, L["Custom Variables"], "custom_variables", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-variables", 11, hideCustomVariables, appendToTriggerPath("customVariables"), false, true, extraSetFunctionReload, nil, true); local function hideCustomUntrigger() return not (trigger.type == "custom" and (trigger.custom_type == "status" or (trigger.custom_type == "event" and trigger.custom_hide == "custom"))) end - WeakAuras.commonOptions.AddCodeOption(customOptions, data, L["Custom Untrigger"], "custom_untrigger", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-untrigger", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, L["Custom Untrigger"], "custom_untrigger", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-untrigger", 14, hideCustomUntrigger, appendToUntriggerPath("custom"), false, true, extraSetFunction); local function hideCustomDuration() @@ -297,7 +288,7 @@ local function GetCustomTriggerOptions(data, triggernum) and (trigger.custom_type == "status" or (trigger.custom_type == "event" and (trigger.custom_hide ~= "timed" or trigger.dynamicDuration)))) end - WeakAuras.commonOptions.AddCodeOption(customOptions, data, L["Duration Info"], "custom_duration", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#duration-info", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, L["Duration Info"], "custom_duration", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#duration-info", 16, hideCustomDuration, appendToTriggerPath("customDuration"), false, true, extraSetFunctionReload); local function hideIfTriggerStateUpdate() @@ -328,17 +319,17 @@ local function GetCustomTriggerOptions(data, triggernum) } } - WeakAuras.commonOptions.AddCodeOption(customOptions, data, string.format(L["Overlay %s Info"], i), "custom_overlay" .. i, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#overlay-info", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, string.format(L["Overlay %s Info"], i), "custom_overlay" .. i, "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#overlay-info", 17 + i / 10, hideOverlay, appendToTriggerPath("customOverlay" .. i), false, true, extraSetFunctionReload, extraFunctions); end - WeakAuras.commonOptions.AddCodeOption(customOptions, data, L["Name Info"], "custom_name", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#name-info", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, L["Name Info"], "custom_name", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#name-info", 18, hideIfTriggerStateUpdate, appendToTriggerPath("customName"), false, true, extraSetFunctionReload); - WeakAuras.commonOptions.AddCodeOption(customOptions, data, L["Icon Info"], "custom_icon", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#icon-info", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, L["Icon Info"], "custom_icon", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#icon-info", 20, hideIfTriggerStateUpdate, appendToTriggerPath("customIcon"), false, true, extraSetFunction); - WeakAuras.commonOptions.AddCodeOption(customOptions, data, L["Texture Info"], "custom_texture", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#texture-info", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, L["Texture Info"], "custom_texture", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#texture-info", 22, hideIfTriggerStateUpdate, appendToTriggerPath("customTexture"), false, true, extraSetFunction); - WeakAuras.commonOptions.AddCodeOption(customOptions, data, L["Stack Info"], "custom_stacks", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#stack-info", + OptionsPrivate.commonOptions.AddCodeOption(customOptions, data, L["Stack Info"], "custom_stacks", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#stack-info", 23, hideIfTriggerStateUpdate, appendToTriggerPath("customStacks"), false, true, extraSetFunctionReload); return customOptions; @@ -365,9 +356,9 @@ local function GetGenericTriggerOptions(data, triggernum) values = function() local type= trigger.type; if(type == "event") then - return event_types; + return OptionsPrivate.Private.event_types; elseif(type == "status") then - return status_types; + return OptionsPrivate.Private.status_types; end end, get = function(info) @@ -375,7 +366,7 @@ local function GetGenericTriggerOptions(data, triggernum) end, set = function(info, v) trigger.event = v - local prototype = WeakAuras.event_prototypes[v]; + local prototype = OptionsPrivate.Private.event_prototypes[v]; if(prototype) then if(prototype.automaticrequired) then trigger.unevent = "auto"; @@ -391,8 +382,8 @@ local function GetGenericTriggerOptions(data, triggernum) }, } - WeakAuras.commonOptions.AddCommonTriggerOptions(options, data, triggernum) - WeakAuras.AddTriggerMetaFunctions(options, data, triggernum) + OptionsPrivate.commonOptions.AddCommonTriggerOptions(options, data, triggernum) + OptionsPrivate.AddTriggerMetaFunctions(options, data, triggernum) local combatLogOptions = { @@ -401,7 +392,7 @@ local function GetGenericTriggerOptions(data, triggernum) name = L["Message Prefix"], width = WeakAuras.normalWidth, order = 8, - values = subevent_prefix_types, + values = OptionsPrivate.Private.subevent_prefix_types, control = "WeakAurasSortedDropdown", hidden = function() return not (trigger.type == "event" and trigger.event == "Combat Log"); end, get = function(info) @@ -417,9 +408,9 @@ local function GetGenericTriggerOptions(data, triggernum) width = WeakAuras.normalWidth, name = L["Message Suffix"], order = 9, - values = subevent_suffix_types, + values = OptionsPrivate.Private.subevent_suffix_types, control = "WeakAurasSortedDropdown", - hidden = function() return not (trigger.type == "event" and trigger.event == "Combat Log" and subevent_actual_prefix_types[trigger.subeventPrefix]); end, + hidden = function() return not (trigger.type == "event" and trigger.event == "Combat Log" and OptionsPrivate.Private.subevent_actual_prefix_types[trigger.subeventPrefix]); end, get = function(info) return trigger.subeventSuffix end, @@ -441,8 +432,8 @@ local function GetGenericTriggerOptions(data, triggernum) elseif (triggerType == "status" or triggerType == "event") then local prototypeOptions; local trigger, untrigger = data.triggers[triggernum].trigger, data.triggers[triggernum].untrigger; - if(WeakAuras.event_prototypes[trigger.event]) then - prototypeOptions = WeakAuras.ConstructOptions(WeakAuras.event_prototypes[trigger.event], data, 10, triggernum); + if(OptionsPrivate.Private.event_prototypes[trigger.event]) then + prototypeOptions = OptionsPrivate.ConstructOptions(OptionsPrivate.Private.event_prototypes[trigger.event], data, 10, triggernum); if (trigger.event == "Combat Log") then WeakAuras.Mixin(prototypeOptions, combatLogOptions); end diff --git a/WeakAurasOptions/GroupOptions.lua b/WeakAurasOptions/GroupOptions.lua index f35dbed..7289d45 100644 --- a/WeakAurasOptions/GroupOptions.lua +++ b/WeakAurasOptions/GroupOptions.lua @@ -3,10 +3,10 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L local regionOptions = WeakAuras.regionOptions; -local parsePrefix = WeakAuras.commonOptions.parsePrefix -local flattenRegionOptions = WeakAuras.commonOptions.flattenRegionOptions +local parsePrefix = OptionsPrivate.commonOptions.parsePrefix +local flattenRegionOptions = OptionsPrivate.commonOptions.flattenRegionOptions -function WeakAuras.GetGroupOptions(data) +function OptionsPrivate.GetGroupOptions(data) local regionOption; local id = data.id if (regionOptions[data.regionType]) then @@ -54,7 +54,7 @@ function WeakAuras.GetGroupOptions(data) end WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end, hidden = function() return false end, disabled = function() return false end, diff --git a/WeakAurasOptions/InformationOptions.lua b/WeakAurasOptions/InformationOptions.lua index 6499943..408f3fb 100644 --- a/WeakAurasOptions/InformationOptions.lua +++ b/WeakAurasOptions/InformationOptions.lua @@ -3,7 +3,7 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L -function WeakAuras.GetInformationOptions(data) +function OptionsPrivate.GetInformationOptions(data) local isGroup = data.controlledChildren local isTmpGroup = type(data.id) == "table" @@ -35,7 +35,7 @@ function WeakAuras.GetInformationOptions(data) if data.id ~= newid and not WeakAuras.GetData(newid) then local oldid = data.id WeakAuras.Rename(data, newid); - WeakAuras.HandleRename(data, oldid, newid) + OptionsPrivate.HandleRename(data, oldid, newid) end end } @@ -85,7 +85,7 @@ function WeakAuras.GetInformationOptions(data) local childData = WeakAuras.GetData(childId) childData.url = v WeakAuras.Add(childData) - WeakAuras.ClearOptions(childData.id) + OptionsPrivate.ClearOptions(childData.id) end end diff --git a/WeakAurasOptions/LoadOptions.lua b/WeakAurasOptions/LoadOptions.lua index 154db06..faeb1e1 100644 --- a/WeakAurasOptions/LoadOptions.lua +++ b/WeakAurasOptions/LoadOptions.lua @@ -3,23 +3,16 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L -local removeFuncs = WeakAuras.commonOptions.removeFuncs -local replaceNameDescFuncs = WeakAuras.commonOptions.replaceNameDescFuncs -local replaceImageFuncs = WeakAuras.commonOptions.replaceImageFuncs -local replaceValuesFuncs = WeakAuras.commonOptions.replaceValuesFuncs -local disabledAll = WeakAuras.commonOptions.CreateDisabledAll("load") -local hiddenAll = WeakAuras.commonOptions.CreateHiddenAll("load") -local getAll = WeakAuras.commonOptions.CreateGetAll("load") -local setAll = WeakAuras.commonOptions.CreateSetAll("load", getAll) +local removeFuncs = OptionsPrivate.commonOptions.removeFuncs +local replaceNameDescFuncs = OptionsPrivate.commonOptions.replaceNameDescFuncs +local replaceImageFuncs = OptionsPrivate.commonOptions.replaceImageFuncs +local replaceValuesFuncs = OptionsPrivate.commonOptions.replaceValuesFuncs +local disabledAll = OptionsPrivate.commonOptions.CreateDisabledAll("load") +local hiddenAll = OptionsPrivate.commonOptions.CreateHiddenAll("load") +local getAll = OptionsPrivate.commonOptions.CreateGetAll("load") +local setAll = OptionsPrivate.commonOptions.CreateSetAll("load", getAll) -local operator_types = WeakAuras.operator_types; -local operator_types_without_equal = WeakAuras.operator_types_without_equal; -local string_operator_types = WeakAuras.string_operator_types; local ValidateNumeric = WeakAuras.ValidateNumeric; -local eventend_types = WeakAuras.eventend_types; -local timedeventend_types = WeakAuras.timedeventend_types; -local autoeventend_types = WeakAuras.autoeventend_types; - local spellCache = WeakAuras.spellCache; @@ -73,7 +66,7 @@ local function CorrectItemName(input) end -- Also used by the GenericTrigger -function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, triggertype, unevent) +function OptionsPrivate.ConstructOptions(prototype, data, startorder, triggernum, triggertype, unevent) local trigger, untrigger; if(data.controlledChildren) then trigger, untrigger = {}, {}; @@ -118,15 +111,15 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri name = type(arg.display) == "function" and arg.display(trigger) or arg.display, order = order, image = function() - local collapsed = WeakAuras.IsCollapsed("trigger", name, "", true) + local collapsed = OptionsPrivate.IsCollapsed("trigger", name, "", true) return collapsed and "collapsed" or "expanded" end, imageWidth = 15, imageHeight = 15, func = function(info, button, secondCall) if not secondCall then - local collapsed = WeakAuras.IsCollapsed("trigger", name, "", true) - WeakAuras.SetCollapsed("trigger", name, "", not collapsed) + local collapsed = OptionsPrivate.IsCollapsed("trigger", name, "", true) + OptionsPrivate.SetCollapsed("trigger", name, "", not collapsed) end end, arg = { @@ -137,7 +130,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri isCollapsedFunctions = isCollapsedFunctions or {}; isCollapsedFunctions[name] = function() - return WeakAuras.IsCollapsed("trigger", name, "", true); + return OptionsPrivate.IsCollapsed("trigger", name, "", true); end elseif(name and not arg.hidden) then local realname = name; @@ -187,7 +180,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -236,7 +229,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -284,7 +277,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -315,7 +308,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri name = L["Operator"], order = order, hidden = hidden, - values = arg.operator_types == "without_equal" and operator_types_without_equal or operator_types, + values = arg.operator_types == "without_equal" and OptionsPrivate.Private.operator_types_without_equal or OptionsPrivate.Private.operator_types, disabled = function() return not trigger["use_"..realname]; end, get = function() return trigger["use_"..realname] and trigger[realname.."_operator"] or nil; end, set = function(info, v) @@ -324,7 +317,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -338,7 +331,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.SortDisplayButtons(); end elseif(arg.required and triggertype == "untrigger") then @@ -363,7 +356,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -377,7 +370,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.SortDisplayButtons(); end elseif(arg.required and triggertype == "untrigger") then @@ -400,7 +393,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -423,7 +416,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.SortDisplayButtons(); end elseif(arg.required and triggertype == "untrigger") then @@ -438,7 +431,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri name = L["Operator"], order = order, hidden = hidden, - values = string_operator_types, + values = OptionsPrivate.Private.string_operator_types, disabled = function() return not trigger["use_"..realname]; end, get = function() return trigger["use_"..realname] and trigger[realname.."_operator"] or nil; end, set = function(info, v) @@ -447,7 +440,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -461,7 +454,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.SortDisplayButtons(); end elseif(arg.required and triggertype == "untrigger") then @@ -484,7 +477,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -498,7 +491,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.SortDisplayButtons(); end elseif(arg.required and triggertype == "untrigger") then @@ -521,7 +514,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri set = function(info, v) trigger["use_exact_"..realname] = v; WeakAuras.Add(data); - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -616,7 +609,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -629,7 +622,11 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if(type(arg.values) == "function") then values = arg.values(trigger); else - values = WeakAuras[arg.values]; + if OptionsPrivate.Private[arg.values] then + values = OptionsPrivate.Private[arg.values] + else + values = WeakAuras[arg.values]; + end end options[name] = { type = "select", @@ -667,7 +664,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -691,7 +688,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -745,7 +742,11 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if(type(arg.values) == "function") then values = arg.values(trigger); else - values = WeakAuras[arg.values]; + if OptionsPrivate.Private[arg.values] then + values = OptionsPrivate.Private[arg.values] + else + values = WeakAuras[arg.values]; + end end options[name] = { type = "select", @@ -766,7 +767,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -780,7 +781,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -812,7 +813,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -834,7 +835,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri if (reloadOptions) then WeakAuras.ClearAndUpdateOptions(data.id) end - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.UpdateThumbnail(data); WeakAuras.UpdateDisplayButton(data); WeakAuras.SortDisplayButtons(); @@ -887,7 +888,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri end if(unevent == "custom") then - local unevent_options = WeakAuras.ConstructOptions(prototype, data, order, triggernum, "untrigger"); + local unevent_options = OptionsPrivate.ConstructOptions(prototype, data, order, triggernum, "untrigger"); options = union(options, unevent_options); end if (prototype.timedrequired) then @@ -895,18 +896,18 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri local func = prototype.timedrequired options.unevent.values = function() if func(trigger) then - return timedeventend_types + return OptionsPrivate.Private.timedeventend_types else - return eventend_types + return OptionsPrivate.Private.eventend_types end end else - options.unevent.values = timedeventend_types; + options.unevent.values = OptionsPrivate.Private.timedeventend_types; end elseif (prototype.automatic) then - options.unevent.values = autoeventend_types; + options.unevent.values = OptionsPrivate.Private.autoeventend_types; else - options.unevent.values = eventend_types; + options.unevent.values = OptionsPrivate.Private.eventend_types; end end @@ -926,7 +927,7 @@ function WeakAuras.ConstructOptions(prototype, data, startorder, triggernum, tri return options; end -function WeakAuras.GetLoadOptions(data) +function OptionsPrivate.GetLoadOptions(data) local load = { type = "group", name = L["Load"], @@ -936,13 +937,13 @@ function WeakAuras.GetLoadOptions(data) data.load[info[#info]] = (v ~= "" and v) or nil; WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ScanForLoads({[data.id] = true}); + OptionsPrivate.Private.ScanForLoads({[data.id] = true}); WeakAuras.SortDisplayButtons(); end, args = {} } - load.args = WeakAuras.ConstructOptions(WeakAuras.load_prototype, data, 10, nil, "load"); + load.args = OptionsPrivate.ConstructOptions(OptionsPrivate.Private.load_prototype, data, 10, nil, "load"); if(data.controlledChildren) then removeFuncs(load); @@ -956,7 +957,7 @@ function WeakAuras.GetLoadOptions(data) if(type(data.id) == "string") then WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end end load.hidden = function(info, ...) return hiddenAll(data, info, ...); end; diff --git a/WeakAurasOptions/OptionsFrames/CodeReview.lua b/WeakAurasOptions/OptionsFrames/CodeReview.lua index 8b3ccfa..4e44c0b 100644 --- a/WeakAurasOptions/OptionsFrames/CodeReview.lua +++ b/WeakAurasOptions/OptionsFrames/CodeReview.lua @@ -1,4 +1,5 @@ if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... -- Lua APIs local pairs = pairs @@ -117,7 +118,7 @@ local function ConstructCodeReview(frame) return group end -function WeakAuras.CodeReview(frame) +function OptionsPrivate.CodeReview(frame) codeReview = codeReview or ConstructCodeReview(frame) return codeReview end diff --git a/WeakAurasOptions/OptionsFrames/FrameChooser.lua b/WeakAurasOptions/OptionsFrames/FrameChooser.lua index 4cdeaa5..c83ebbf 100644 --- a/WeakAurasOptions/OptionsFrames/FrameChooser.lua +++ b/WeakAurasOptions/OptionsFrames/FrameChooser.lua @@ -13,15 +13,12 @@ local AceConfigDialog = LibStub("AceConfigDialog-3.0") local WeakAuras = WeakAuras local L = WeakAuras.L -local valueFromPath = WeakAuras.ValueFromPath -local valueToPath = WeakAuras.ValueToPath - local frameChooserFrame local frameChooserBox local oldFocus local oldFocusName -function WeakAuras.StartFrameChooser(data, path) +function OptionsPrivate.StartFrameChooser(data, path) local frame = WeakAuras.OptionsFrame(); if not(frameChooserFrame) then frameChooserFrame = CreateFrame("frame"); @@ -35,15 +32,15 @@ function WeakAuras.StartFrameChooser(data, path) frameChooserBox:SetBackdropBorderColor(0, 1, 0); frameChooserBox:Hide(); end - local givenValue = valueFromPath(data, path); + local givenValue = OptionsPrivate.Private.ValueFromPath(data, path); frameChooserFrame:SetScript("OnUpdate", function() if(IsMouseButtonDown("RightButton")) then - valueToPath(data, path, givenValue); - WeakAuras.StopFrameChooser(data); + OptionsPrivate.Private.ValueToPath(data, path, givenValue); + OptionsPrivate.StopFrameChooser(data); WeakAuras.FillOptions() elseif(IsMouseButtonDown("LeftButton") and oldFocusName) then - WeakAuras.StopFrameChooser(data); + OptionsPrivate.StopFrameChooser(data); else SetCursor("CAST_CURSOR"); @@ -76,7 +73,7 @@ function WeakAuras.StartFrameChooser(data, path) end if(focusName ~= oldFocusName) then - valueToPath(data, path, focusName); + OptionsPrivate.Private.ValueToPath(data, path, focusName); oldFocusName = focusName; WeakAuras.FillOptions() end @@ -91,7 +88,7 @@ function WeakAuras.StartFrameChooser(data, path) end); end -function WeakAuras.StopFrameChooser(data) +function OptionsPrivate.StopFrameChooser(data) if(frameChooserFrame) then frameChooserFrame:SetScript("OnUpdate", nil); frameChooserBox:Hide(); diff --git a/WeakAurasOptions/OptionsFrames/IconPicker.lua b/WeakAurasOptions/OptionsFrames/IconPicker.lua index f8ee213..09c8bde 100644 --- a/WeakAurasOptions/OptionsFrames/IconPicker.lua +++ b/WeakAurasOptions/OptionsFrames/IconPicker.lua @@ -202,7 +202,7 @@ local function ConstructIconPicker(frame) return group end -function WeakAuras.IconPicker(frame) +function OptionsPrivate.IconPicker(frame) iconPicker = iconPicker or ConstructIconPicker(frame) return iconPicker end diff --git a/WeakAurasOptions/OptionsFrames/ImportExport.lua b/WeakAurasOptions/OptionsFrames/ImportExport.lua index 5e93668..ec6fecd 100644 --- a/WeakAurasOptions/OptionsFrames/ImportExport.lua +++ b/WeakAurasOptions/OptionsFrames/ImportExport.lua @@ -52,7 +52,7 @@ local function ConstructImportExport(frame) if(mode == "export") then displayStr = WeakAuras.DisplayToString(id, true); elseif(mode == "table") then - displayStr = WeakAuras.DataToString(id); + displayStr = OptionsPrivate.Private.DataToString(id); end input.editBox:SetScript("OnEscapePressed", function() group:Close(); end); input.editBox:SetScript("OnChar", function() input:SetText(displayStr); input.editBox:HighlightText(); end); @@ -92,7 +92,7 @@ local function ConstructImportExport(frame) return group end -function WeakAuras.ImportExport(frame) +function OptionsPrivate.ImportExport(frame) importexport = importexport or ConstructImportExport(frame) return importexport end diff --git a/WeakAurasOptions/OptionsFrames/ModelPicker.lua b/WeakAurasOptions/OptionsFrames/ModelPicker.lua index e605252..9160846 100644 --- a/WeakAurasOptions/OptionsFrames/ModelPicker.lua +++ b/WeakAurasOptions/OptionsFrames/ModelPicker.lua @@ -204,7 +204,7 @@ local function ConstructModelPicker(frame) return group end -function WeakAuras.ModelPicker(frame) +function OptionsPrivate.ModelPicker(frame) modelPicker = modelPicker or ConstructModelPicker(frame) return modelPicker end diff --git a/WeakAurasOptions/OptionsFrames/MoverSizer.lua b/WeakAurasOptions/OptionsFrames/MoverSizer.lua index a660be2..fa4c023 100644 --- a/WeakAurasOptions/OptionsFrames/MoverSizer.lua +++ b/WeakAurasOptions/OptionsFrames/MoverSizer.lua @@ -14,8 +14,6 @@ local WeakAuras = WeakAuras local moversizer local mover -local savedVars = WeakAuras.savedVars - local function EnsureTexture(self, texture) if texture then return texture @@ -45,7 +43,7 @@ local function moveOnePxl(direction) end WeakAuras.Add(data, nil, true) WeakAuras.UpdateThumbnail(data) - WeakAuras.ResetMoverSizer() + OptionsPrivate.ResetMoverSizer() if data.parent then local parentData = WeakAuras.GetData(data.parent) if parentData then @@ -494,14 +492,14 @@ local function ConstructMoverSizer(parent) frame:ScaleCorners(region:GetWidth(), region:GetHeight()) local regionStrata = region:GetFrameStrata() if regionStrata then - local strata = math.min(tIndexOf(WeakAuras.frame_strata_types, regionStrata) + 1, 9) - frame:SetFrameStrata(WeakAuras.frame_strata_types[strata]) - mover:SetFrameStrata(WeakAuras.frame_strata_types[strata]) + local strata = math.min(tIndexOf(OptionsPrivate.Private.frame_strata_types, regionStrata) + 1, 9) + frame:SetFrameStrata(OptionsPrivate.Private.frame_strata_types[strata]) + mover:SetFrameStrata(OptionsPrivate.Private.frame_strata_types[strata]) end - local db = savedVars.db + local db = OptionsPrivate.savedVars.db mover.startMoving = function() - WeakAuras.CancelAnimation(region, true, true, true, true, true) + OptionsPrivate.Private.CancelAnimation(region, true, true, true, true, true) mover:ClearAllPoints() if data.regionType == "group" then mover:SetPoint(mover.selfPoint, region, mover.anchorPoint, region.blx * scale, region.bly * scale) @@ -617,7 +615,7 @@ local function ConstructMoverSizer(parent) end end WeakAuras.FillOptions() - WeakAuras.Animate("display", data.uid, "main", data.animation.main, WeakAuras.regions[data.id].region, false, nil, true) + OptionsPrivate.Private.Animate("display", data.uid, "main", data.animation.main, WeakAuras.regions[data.id].region, false, nil, true) -- hide alignment lines frame.lineY:Hide() frame.lineX:Hide() @@ -639,7 +637,7 @@ local function ConstructMoverSizer(parent) if region:IsResizable() then frame.startSizing = function(point) mover.isMoving = true - WeakAuras.CancelAnimation(region, true, true, true, true, true) + OptionsPrivate.Private.CancelAnimation(region, true, true, true, true, true) local rSelfPoint, rAnchor, rAnchorPoint, rXOffset, rYOffset = region:GetPoint(1) region:StartSizing(point) frame.text:ClearAllPoints() @@ -737,7 +735,7 @@ local function ConstructMoverSizer(parent) frame.text:Hide() frame:SetScript("OnUpdate", nil) WeakAuras.FillOptions() - WeakAuras.Animate("display", data.uid, "main", data.animation.main, WeakAuras.regions[data.id].region, false, nil, true) + OptionsPrivate.Private.Animate("display", data.uid, "main", data.animation.main, WeakAuras.regions[data.id].region, false, nil, true) -- hide alignment lines frame.lineY:Hide() frame.lineX:Hide() @@ -835,7 +833,7 @@ local function ConstructMoverSizer(parent) self.alignCurrentAlpha = newAlpha end - local db = savedVars.db + local db = OptionsPrivate.savedVars.db local region = self.moving.region local data = self.moving.data if not self.isMoving then @@ -974,7 +972,7 @@ local function ConstructMoverSizer(parent) return frame, mover end -function WeakAuras.MoverSizer(parent) +function OptionsPrivate.MoverSizer(parent) if not moversizer or not mover then moversizer, mover = ConstructMoverSizer(parent) end diff --git a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua index e8b4d18..68d57c4 100644 --- a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua +++ b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua @@ -18,12 +18,10 @@ local WeakAuras = WeakAuras local L = WeakAuras.L local displayButtons = WeakAuras.displayButtons -local loaded = WeakAuras.loaded local regionOptions = WeakAuras.regionOptions -local savedVars = WeakAuras.savedVars -local tempGroup = WeakAuras.tempGroup +local tempGroup = OptionsPrivate.tempGroup local prettyPrint = WeakAuras.prettyPrint -local aceOptions = WeakAuras.aceOptions +local aceOptions = {} local function CreateDecoration(frame) local deco = CreateFrame("Frame", nil, frame) @@ -135,11 +133,11 @@ local defaultHeight = 665 local minWidth = 750 local minHeight = 240 -function WeakAuras.CreateFrame() +function OptionsPrivate.CreateFrame() local WeakAuras_DropDownMenu = CreateFrame("frame", "WeakAuras_DropDownMenu", nil, "UIDropDownMenuTemplate") local frame - local db = savedVars.db - local odb = savedVars.odb + local db = OptionsPrivate.savedVars.db + local odb = OptionsPrivate.savedVars.odb -------- Mostly Copied from AceGUIContainer-Frame-------- frame = CreateFrame("FRAME", "WeakAurasOptions", UIParent) tinsert(UISpecialFrames, frame:GetName()) @@ -173,15 +171,10 @@ function WeakAuras.CreateFrame() frame:Hide() frame:SetScript("OnHide", function() - WeakAuras.ClearFakeStates() - WeakAuras.SetDragging() + OptionsPrivate.Private.ClearFakeStates() + OptionsPrivate.SetDragging() - local tutFrame = WeakAuras.TutorialsFrame and WeakAuras.TutorialsFrame() - if tutFrame and tutFrame:IsVisible() then - tutFrame:Hide() - end - - WeakAuras.PauseAllDynamicGroups() + OptionsPrivate.Private.PauseAllDynamicGroups() for id, data in pairs(WeakAuras.regions) do data.region:Collapse() @@ -194,12 +187,11 @@ function WeakAuras.CreateFrame() end end - WeakAuras.ResumeAllDynamicGroups() - WeakAuras.ReloadAll() - WeakAuras.Resume() + OptionsPrivate.Private.ResumeAllDynamicGroups() + OptionsPrivate.Private.Resume() - if WeakAuras.mouseFrame then - WeakAuras.mouseFrame:OptionsClosed() + if OptionsPrivate.Private.mouseFrame then + OptionsPrivate.Private.mouseFrame:OptionsClosed() end end) @@ -537,14 +529,14 @@ function WeakAuras.CreateFrame() container.content:SetPoint("BOTTOMRIGHT", 0, 0) frame.container = container - frame.texturePicker = WeakAuras.TexturePicker(frame) - frame.iconPicker = WeakAuras.IconPicker(frame) - frame.modelPicker = WeakAuras.ModelPicker(frame) - frame.importexport = WeakAuras.ImportExport(frame) - frame.texteditor = WeakAuras.TextEditor(frame) - frame.codereview = WeakAuras.CodeReview(frame) + frame.texturePicker = OptionsPrivate.TexturePicker(frame) + frame.iconPicker = OptionsPrivate.IconPicker(frame) + frame.modelPicker = OptionsPrivate.ModelPicker(frame) + frame.importexport = OptionsPrivate.ImportExport(frame) + frame.texteditor = OptionsPrivate.TextEditor(frame) + frame.codereview = OptionsPrivate.CodeReview(frame) - frame.moversizer, frame.mover = WeakAuras.MoverSizer(frame) + frame.moversizer, frame.mover = OptionsPrivate.MoverSizer(frame) -- filter line local filterInput = CreateFrame("editbox", "WeakAurasFilterInput", frame, "InputBoxTemplate") @@ -609,7 +601,7 @@ function WeakAuras.CreateFrame() local importButton = AceGUI:Create("WeakAurasToolbarButton") importButton:SetText(L["Import"]) importButton:SetTexture("Interface\\AddOns\\WeakAuras\\Media\\Textures\\importsmall") - importButton:SetCallback("OnClick", WeakAuras.ImportFromString) + importButton:SetCallback("OnClick", OptionsPrivate.ImportFromString) toolbarContainer:AddChild(importButton) local magnetButton = AceGUI:Create("WeakAurasToolbarButton") @@ -701,7 +693,7 @@ function WeakAuras.CreateFrame() local numAddons = 0 - for addon, addonData in pairs(WeakAuras.addons) do + for addon, addonData in pairs(OptionsPrivate.Private) do numAddons = numAddons + 1 end @@ -733,26 +725,26 @@ function WeakAuras.CreateFrame() loadedButton:SetExpandDescription(L["Expand all loaded displays"]) loadedButton:SetCollapseDescription(L["Collapse all loaded displays"]) loadedButton:SetViewClick(function() - WeakAuras.PauseAllDynamicGroups() + OptionsPrivate.Private.PauseAllDynamicGroups() if loadedButton.view.func() == 2 then for id, child in pairs(displayButtons) do - if loaded[id] ~= nil then + if OptionsPrivate.Private.loaded[id] ~= nil then child:PriorityHide(2) end end else for id, child in pairs(displayButtons) do - if loaded[id] ~= nil then + if OptionsPrivate.Private.loaded[id] ~= nil then child:PriorityShow(2) end end end - WeakAuras.ResumeAllDynamicGroups() + OptionsPrivate.Private.ResumeAllDynamicGroups() end) loadedButton:SetViewTest(function() local none, all = true, true for id, child in pairs(displayButtons) do - if loaded[id] ~= nil then + if OptionsPrivate.Private.loaded[id] ~= nil then if child:GetVisibility() ~= 2 then all = false end @@ -794,13 +786,13 @@ function WeakAuras.CreateFrame() unloadedButton:SetViewClick(function() if unloadedButton.view.func() == 2 then for id, child in pairs(displayButtons) do - if loaded[id] == nil then + if OptionsPrivate.Private.loaded[id] == nil then child:PriorityHide(2) end end else for id, child in pairs(displayButtons) do - if loaded[id] == nil then + if OptionsPrivate.Private.loaded[id] == nil then child:PriorityShow(2) end end @@ -809,7 +801,7 @@ function WeakAuras.CreateFrame() unloadedButton:SetViewTest(function() local none, all = true, true for id, child in pairs(displayButtons) do - if loaded[id] == nil then + if OptionsPrivate.Private.loaded[id] == nil then if child:GetVisibility() ~= 2 then all = false end @@ -893,25 +885,21 @@ function WeakAuras.CreateFrame() end end - frame.GetSubOptions = function(self, id, tab) - return aceOptions[id] and aceOptions[id][tab] - end - frame.EnsureOptions = function(self, data, tab) local id = data.id aceOptions[id] = aceOptions[id] or {} if not aceOptions[id][tab] then local optionsGenerator = { - group = WeakAuras.GetGroupOptions, - region = WeakAuras.GetDisplayOptions, - trigger = WeakAuras.GetTriggerOptions, - conditions = WeakAuras.GetConditionOptions, - load = WeakAuras.GetLoadOptions, - action = WeakAuras.GetActionOptions, - animation = WeakAuras.GetAnimationOptions, - authorOptions = WeakAuras.GetAuthorOptions, - information = WeakAuras.GetInformationOptions, + group = OptionsPrivate.GetGroupOptions, + region = OptionsPrivate.GetDisplayOptions, + trigger = OptionsPrivate.GetTriggerOptions, + conditions = OptionsPrivate.GetConditionOptions, + load = OptionsPrivate.GetLoadOptions, + action = OptionsPrivate.GetActionOptions, + animation = OptionsPrivate.GetAnimationOptions, + authorOptions = OptionsPrivate.GetAuthorOptions, + information = OptionsPrivate.GetInformationOptions, } if optionsGenerator[tab] then aceOptions[id][tab] = optionsGenerator[tab](data) @@ -996,7 +984,7 @@ function WeakAuras.CreateFrame() end frame.ClearPicks = function(self, noHide) - WeakAuras.PauseAllDynamicGroups() + OptionsPrivate.Private.PauseAllDynamicGroups() frame.pickedDisplay = nil frame.pickedOption = nil @@ -1013,7 +1001,7 @@ function WeakAuras.CreateFrame() container:ReleaseChildren() self.moversizer:Hide() - WeakAuras.ResumeAllDynamicGroups() + OptionsPrivate.Private.ResumeAllDynamicGroups() end local function GetTarget(pickedDisplay) @@ -1154,7 +1142,7 @@ function WeakAuras.CreateFrame() importButton:SetIcon(frame.importThumbnail) importButton:SetDescription(L["Import a display from an encoded string"]) - importButton:SetClick(WeakAuras.ImportFromString) + importButton:SetClick(OptionsPrivate.ImportFromString) containerScroll:AddChild(importButton) end @@ -1177,7 +1165,7 @@ function WeakAuras.CreateFrame() container:SetLayout("fill") container:AddChild(containerScroll) - WeakAuras.CreateImportButtons() + OptionsPrivate.CreateImportButtons() WeakAuras.SortImportButtons(containerScroll) else error("An options button other than New or Addons was selected... but there are no other options buttons!") @@ -1199,7 +1187,7 @@ function WeakAuras.CreateFrame() displayButtons[data.parent]:Expand() end end - if loaded[id] ~= nil then + if OptionsPrivate.Private.loaded[id] ~= nil then -- Under loaded if not loadedButton:GetExpanded() then loadedButton:Expand() @@ -1260,17 +1248,17 @@ function WeakAuras.CreateFrame() if type(self.pickedDisplay) == "string" then if WeakAuras.GetData(self.pickedDisplay).controlledChildren then wasGroup = true - elseif not WeakAuras.IsDisplayPicked(id) then + elseif not OptionsPrivate.IsDisplayPicked(id) then tinsert(tempGroup.controlledChildren, self.pickedDisplay) end end if wasGroup then self:PickDisplay(id) - elseif not WeakAuras.IsDisplayPicked(id) then + elseif not OptionsPrivate.IsDisplayPicked(id) then self.pickedDisplay = tempGroup displayButtons[id]:Pick() tinsert(tempGroup.controlledChildren, id) - WeakAuras.ClearOptions(tempGroup.id) + OptionsPrivate.ClearOptions(tempGroup.id) self:FillOptions() end end diff --git a/WeakAurasOptions/OptionsFrames/TextEditor.lua b/WeakAurasOptions/OptionsFrames/TextEditor.lua index 2a43a74..e5adce3 100644 --- a/WeakAurasOptions/OptionsFrames/TextEditor.lua +++ b/WeakAurasOptions/OptionsFrames/TextEditor.lua @@ -17,9 +17,6 @@ local L = WeakAuras.L local textEditor -local valueFromPath = WeakAuras.ValueFromPath -local valueToPath = WeakAuras.ValueToPath - local editor_themes = { ["Standard"] = { ["Table"] = "|c00ff3333", @@ -149,36 +146,6 @@ end]=] }, } -local function settings_dropdown_initialize(frame, level, menu) - for k, v in pairs(editor_themes) do - local item = { - text = k, - isNotRadio = false, - checked = function() - return WeakAurasSaved.editor_theme == k - end, - func = function() - WeakAurasSaved.editor_theme = k - set_scheme() - WeakAuras.editor.editBox:SetText(WeakAuras.editor.editBox:GetText()) - end - } - UIDropDownMenu_AddButton(item) - end - UIDropDownMenu_AddButton( - { - text = L["Bracket Matching"], - isNotRadio = true, - checked = function() - return WeakAurasSaved.editor_bracket_matching - end, - func = function() - WeakAurasSaved.editor_bracket_matching = not WeakAurasSaved.editor_bracket_matching - end - } - ) -end - local function ConstructTextEditor(frame) local group = AceGUI:Create("InlineGroup") group.frame:SetParent(frame) @@ -260,6 +227,36 @@ local function ConstructTextEditor(frame) urlText:SetPoint("RIGHT", settings_frame, "LEFT") local dropdown = CreateFrame("Frame", "SettingsMenuFrame", settings_frame, "UIDropDownMenuTemplate") + + local function settings_dropdown_initialize(frame, level, menu) + for k, v in pairs(editor_themes) do + local item = { + text = k, + isNotRadio = false, + checked = function() + return WeakAurasSaved.editor_theme == k + end, + func = function() + WeakAurasSaved.editor_theme = k + set_scheme() + editor.editBox:SetText(editor.editBox:GetText()) + end + } + UIDropDownMenu_AddButton(item) + end + UIDropDownMenu_AddButton( + { + text = L["Bracket Matching"], + isNotRadio = true, + checked = function() + return WeakAurasSaved.editor_bracket_matching + end, + func = function() + WeakAurasSaved.editor_bracket_matching = not WeakAurasSaved.editor_bracket_matching + end + } + ) + end UIDropDownMenu_Initialize(dropdown, settings_dropdown_initialize, "MENU") settings_frame:SetScript( @@ -331,8 +328,8 @@ local function ConstructTextEditor(frame) button:SetCallback( "OnClick", function() - WeakAuras.editor.editBox:Insert(snippet.snippet) - WeakAuras.editor:SetFocus() + editor.editBox:Insert(snippet.snippet) + editor:SetFocus() end ) button.deleteButton:SetScript( @@ -635,7 +632,7 @@ local function ConstructTextEditor(frame) local combinedText = "" for index, childId in pairs(data.controlledChildren) do local childData = WeakAuras.GetData(childId) - local text = valueFromPath(childData, multipath and path[childId] or path) + local text = OptionsPrivate.Private.ValueFromPath(childData, multipath and path[childId] or path) if text then if not (singleText) then singleText = text @@ -661,7 +658,7 @@ local function ConstructTextEditor(frame) editor.combinedText = true end else - editor:SetText(valueFromPath(data, path) or "") + editor:SetText(OptionsPrivate.Private.ValueFromPath(data, path) or "") end editor:SetFocus() end @@ -716,11 +713,11 @@ local function ConstructTextEditor(frame) for index, childId in pairs(self.data.controlledChildren) do local text = editor.combinedText and (textById[childId] or "") or editor:GetText() local childData = WeakAuras.GetData(childId) - valueToPath(childData, self.multipath and self.path[childId] or self.path, text) + OptionsPrivate.Private.ValueToPath(childData, self.multipath and self.path[childId] or self.path, text) WeakAuras.Add(childData) end else - valueToPath(self.data, self.path, editor:GetText()) + OptionsPrivate.Private.ValueToPath(self.data, self.path, editor:GetText()) WeakAuras.Add(self.data) end if (self.reloadOptions) then @@ -742,12 +739,11 @@ local function ConstructTextEditor(frame) frame:UpdateFrameVisible() WeakAuras.FillOptions() end - WeakAuras.editor = editor return group end -function WeakAuras.TextEditor(frame) +function OptionsPrivate.TextEditor(frame) textEditor = textEditor or ConstructTextEditor(frame) return textEditor end diff --git a/WeakAurasOptions/OptionsFrames/TexturePicker.lua b/WeakAurasOptions/OptionsFrames/TexturePicker.lua index 22ee4b5..4e73c7b 100644 --- a/WeakAurasOptions/OptionsFrames/TexturePicker.lua +++ b/WeakAurasOptions/OptionsFrames/TexturePicker.lua @@ -221,7 +221,6 @@ local function ConstructTexturePicker(frame) else _, givenPath = next(self.givenPath); end - WeakAuras.debug(givenPath, 3); for categoryName, category in pairs(self.textures) do if not(picked) then for texturePath, textureName in pairs(category) do @@ -279,7 +278,7 @@ local function ConstructTexturePicker(frame) return group end -function WeakAuras.TexturePicker(frame) +function OptionsPrivate.TexturePicker(frame) texturePicker = texturePicker or ConstructTexturePicker(frame) return texturePicker end diff --git a/WeakAurasOptions/RegionOptions/AuraBar.lua b/WeakAurasOptions/RegionOptions/AuraBar.lua index 78b8223..9f74b1b 100644 --- a/WeakAurasOptions/RegionOptions/AuraBar.lua +++ b/WeakAurasOptions/RegionOptions/AuraBar.lua @@ -24,7 +24,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Orientation"], order = 25, - values = WeakAuras.orientation_types, + values = OptionsPrivate.Private.orientation_types, set = function(info, v) if( ( @@ -58,7 +58,7 @@ local function createOptions(id, data) data.orientation = v; WeakAuras.Add(data); WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, inverse = { @@ -71,7 +71,7 @@ local function createOptions(id, data) type = "toggle", width = WeakAuras.normalWidth, name = L["Tooltip on Mouseover"], - hidden = function() return not WeakAuras.CanHaveTooltip(data) end, + hidden = function() return not OptionsPrivate.Private.CanHaveTooltip(data) end, order = 38 }, bar_header = { @@ -120,15 +120,15 @@ local function createOptions(id, data) name = L["Auto"], desc = L["Choose whether the displayed icon is automatic or defined manually"], order = 40.3, - disabled = function() return not WeakAuras.CanHaveAuto(data); end, - get = function() return WeakAuras.CanHaveAuto(data) and data.auto end, + disabled = function() return not OptionsPrivate.Private.CanHaveAuto(data); end, + get = function() return OptionsPrivate.Private.CanHaveAuto(data) and data.auto end, hidden = function() return not data.icon end, }, displayIcon = { type = "input", width = WeakAuras.normalWidth, name = L["Display Icon"], - hidden = function() return WeakAuras.CanHaveAuto(data) and data.auto or not data.icon; end, + hidden = function() return OptionsPrivate.Private.CanHaveAuto(data) and data.auto or not data.icon; end, disabled = function() return not data.icon end, order = 40.4, get = function() @@ -144,16 +144,16 @@ local function createOptions(id, data) type = "execute", width = WeakAuras.normalWidth, name = L["Choose"], - hidden = function() return WeakAuras.CanHaveAuto(data) and data.auto or not data.icon; end, + hidden = function() return OptionsPrivate.Private.CanHaveAuto(data) and data.auto or not data.icon; end, disabled = function() return not data.icon end, order = 40.5, - func = function() WeakAuras.OpenIconPicker(data, "displayIcon"); end + func = function() OptionsPrivate.OpenIconPicker(data, "displayIcon"); end }, icon_side = { type = "select", width = WeakAuras.normalWidth, name = L["Icon Position"], - values = WeakAuras.icon_side_types, + values = OptionsPrivate.Private.icon_side_types, hidden = function() return data.orientation:find("VERTICAL") or not data.icon end, order = 40.6, }, @@ -161,7 +161,7 @@ local function createOptions(id, data) type = "select", width = WeakAuras.normalWidth, name = L["Icon Position"], - values = WeakAuras.rotated_icon_side_types, + values = OptionsPrivate.Private.rotated_icon_side_types, hidden = function() return data.orientation:find("HORIZONTAL") or not data.icon end, order = 40.7, get = function() @@ -241,7 +241,7 @@ local function createOptions(id, data) width = WeakAuras.halfWidth, order = 44.3, func = function() - WeakAuras.OpenTexturePicker(data, data, "sparkTexture", WeakAuras.texture_types); + OptionsPrivate.OpenTexturePicker(data, data, "sparkTexture", OptionsPrivate.Private.texture_types); end, disabled = function() return not data.spark end, hidden = function() return not data.spark end, @@ -260,7 +260,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Blend Mode"], order = 44.5, - values = WeakAuras.blend_types, + values = OptionsPrivate.Private.blend_types, disabled = function() return not data.spark end, hidden = function() return not data.spark end, }, @@ -311,7 +311,7 @@ local function createOptions(id, data) sparkRotationMode = { type = "select", width = WeakAuras.normalWidth, - values = WeakAuras.spark_rotation_types, + values = OptionsPrivate.Private.spark_rotation_types, name = L["Rotation Mode"], order = 45, disabled = function() return not data.spark end, @@ -339,7 +339,7 @@ local function createOptions(id, data) sparkHidden = { type = "select", width = WeakAuras.normalWidth, - values = WeakAuras.spark_hide_types, + values = OptionsPrivate.Private.spark_hide_types, name = L["Hide on"], order = 45.3, disabled = function() return not data.spark end, @@ -354,7 +354,7 @@ local function createOptions(id, data) options = WeakAuras.regionPrototype.AddAdjustedDurationOptions(options, data, 36.5); - local overlayInfo = WeakAuras.GetOverlayInfo(data); + local overlayInfo = OptionsPrivate.Private.GetOverlayInfo(data); if (overlayInfo and next(overlayInfo)) then options["overlayheader"] = { type = "header", @@ -397,7 +397,7 @@ local function createOptions(id, data) return { aurabar = options, - position = WeakAuras.commonOptions.PositionOptions(id, data), + position = OptionsPrivate.commonOptions.PositionOptions(id, data), }; end @@ -734,12 +734,12 @@ local function subCreateOptions(parentData, data, index, subIndex) __title = L["Foreground"], __order = 1, __up = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionUp, index, "aurabar_bar")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionUp, index, "aurabar_bar")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __down = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionDown, index, "aurabar_bar")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionDown, index, "aurabar_bar")) then WeakAuras.ClearAndUpdateOptions(parentData.id, parentData) end end, diff --git a/WeakAurasOptions/RegionOptions/DynamicGroup.lua b/WeakAurasOptions/RegionOptions/DynamicGroup.lua index 67580d7..bda3b7f 100644 --- a/WeakAurasOptions/RegionOptions/DynamicGroup.lua +++ b/WeakAurasOptions/RegionOptions/DynamicGroup.lua @@ -98,7 +98,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Choose"], order = 0.51, - func = function() WeakAuras.OpenIconPicker(data, "groupIcon", true) end + func = function() OptionsPrivate.OpenIconPicker(data, "groupIcon", true) end }, -- grow options grow = { @@ -106,7 +106,7 @@ local function createOptions(id, data) width = WeakAuras.doubleWidth, name = L["Grow"], order = 1, - values = WeakAuras.grow_types, + values = OptionsPrivate.Private.grow_types, set = function(info, v) data.grow = v local selfPoint = selfPoints[data.grow] or selfPoints.default @@ -116,7 +116,7 @@ local function createOptions(id, data) data.selfPoint = selfPoint WeakAuras.Add(data) WeakAuras.ClearAndUpdateOptions(data.id) - WeakAuras.ResetMoverSizer() + OptionsPrivate.ResetMoverSizer() end, }, useAnchorPerUnit = { @@ -150,7 +150,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Align"], order = 2, - values = WeakAuras.align_types, + values = OptionsPrivate.Private.align_types, set = function(info, v) data.align = v local selfPoint = selfPoints[data.grow] or selfPoints.default @@ -160,7 +160,7 @@ local function createOptions(id, data) data.selfPoint = selfPoint WeakAuras.Add(data) WeakAuras.ClearAndUpdateOptions(data.id) - WeakAuras.ResetMoverSizer() + OptionsPrivate.ResetMoverSizer() end, hidden = function() return (data.grow == "CUSTOM" or data.grow == "LEFT" or data.grow == "RIGHT" or data.grow == "HORIZONTAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "GRID") end, disabled = function() return data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" end @@ -170,7 +170,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Align"], order = 3, - values = WeakAuras.rotated_align_types, + values = OptionsPrivate.Private.rotated_align_types, hidden = function() return (data.grow == "CUSTOM" or data.grow == "UP" or data.grow == "DOWN" or data.grow == "VERTICAL" or data.grow == "CIRCLE" or data.grow == "COUNTERCIRCLE" or data.grow == "GRID") end, get = function() return data.align; end, set = function(info, v) @@ -182,7 +182,7 @@ local function createOptions(id, data) data.selfPoint = selfPoint WeakAuras.Add(data) WeakAuras.ClearAndUpdateOptions(data.id) - WeakAuras.ResetMoverSizer() + OptionsPrivate.ResetMoverSizer() end, }, -- circle grow options @@ -191,7 +191,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Constant Factor"], order = 4, - values = WeakAuras.circular_group_constant_factor_types, + values = OptionsPrivate.Private.circular_group_constant_factor_types, hidden = function() return data.grow ~= "CIRCLE" and data.grow ~= "COUNTERCIRCLE" end }, rotation = { @@ -238,13 +238,13 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Grid direction"], order = 8, - values = WeakAuras.grid_types, + values = OptionsPrivate.Private.grid_types, hidden = function() return data.grow ~= "GRID" end, set = function(info, value) data.selfPoint = gridSelfPoints[value] data.gridType = value WeakAuras.Add(data) - WeakAuras.ResetMoverSizer() + OptionsPrivate.ResetMoverSizer() end, }, gridWidth = { @@ -321,7 +321,7 @@ local function createOptions(id, data) width = WeakAuras.doubleWidth, name = L["Sort"], order = 20, - values = WeakAuras.group_sort_types + values = OptionsPrivate.Private.group_sort_types }, -- custom sort option added below hybridPosition = { @@ -329,7 +329,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Hybrid Position"], order = 21, - values = WeakAuras.group_hybrid_position_types, + values = OptionsPrivate.Private.group_hybrid_position_types, hidden = function() return not(data.sort == "hybrid") end, }, hybridSortMode = { @@ -337,7 +337,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Hybrid Sort Mode"], order = 22, - values = WeakAuras.group_hybrid_sort_types, + values = OptionsPrivate.Private.group_hybrid_sort_types, hidden = function() return not(data.sort == "hybrid") end, }, sortHybrid = { @@ -409,7 +409,7 @@ local function createOptions(id, data) data.yOffset = data.yOffset/(1-change) data.scale = v WeakAuras.Add(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, endHeader = { @@ -419,23 +419,23 @@ local function createOptions(id, data) }, }; - WeakAuras.commonOptions.AddCodeOption(options, data, L["Custom Grow"], "custom_grow", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#grow", + OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Grow"], "custom_grow", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#grow", 2, function() return data.grow ~= "CUSTOM" end, {"customGrow"}, nil, nil, nil, nil, nil, true) - WeakAuras.commonOptions.AddCodeOption(options, data, L["Custom Sort"], "custom_sort", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-sort", + OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Sort"], "custom_sort", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-sort", 21, function() return data.sort ~= "custom" end, {"customSort"}, nil, nil, nil, nil, nil, true) - WeakAuras.commonOptions.AddCodeOption(options, data, L["Custom Anchor"], "custom_anchor_per_unit", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#group-by-frame", + OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Anchor"], "custom_anchor_per_unit", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#group-by-frame", 1.7, function() return not(data.grow ~= "CUSTOM" and data.useAnchorPerUnit and data.anchorPerUnit == "CUSTOM") end, {"customAnchorPerUnit"}, nil, nil, nil, nil, nil, true) local borderHideFunc = function() return data.useAnchorPerUnit or data.grow == "CUSTOM" end local disableSelfPoint = function() return data.grow ~= "CUSTOM" and data.grow ~= "GRID" and not data.useAnchorPerUnit end - for k, v in pairs(WeakAuras.commonOptions.BorderOptions(id, data, nil, borderHideFunc, 70)) do + for k, v in pairs(OptionsPrivate.commonOptions.BorderOptions(id, data, nil, borderHideFunc, 70)) do options[k] = v end return { dynamicgroup = options, - position = WeakAuras.commonOptions.PositionOptions(id, data, nil, true, disableSelfPoint), + position = OptionsPrivate.commonOptions.PositionOptions(id, data, nil, true, disableSelfPoint), }; end diff --git a/WeakAurasOptions/RegionOptions/Group.lua b/WeakAurasOptions/RegionOptions/Group.lua index f482d25..4bc39a1 100644 --- a/WeakAurasOptions/RegionOptions/Group.lua +++ b/WeakAurasOptions/RegionOptions/Group.lua @@ -80,14 +80,14 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Choose"], order = 0.51, - func = function() WeakAuras.OpenIconPicker(data, "groupIcon", true) end + func = function() OptionsPrivate.OpenIconPicker(data, "groupIcon", true) end }, align_h = { type = "select", width = WeakAuras.normalWidth, name = L["Horizontal Align"], order = 10, - values = WeakAuras.align_types, + values = OptionsPrivate.Private.align_types, get = function() if(#data.controlledChildren < 1) then return nil; @@ -145,7 +145,7 @@ local function createOptions(id, data) end end WeakAuras.Add(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, align_v = { @@ -153,7 +153,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Vertical Align"], order = 15, - values = WeakAuras.rotated_align_types, + values = OptionsPrivate.Private.rotated_align_types, get = function() if(#data.controlledChildren < 1) then return nil; @@ -211,7 +211,7 @@ local function createOptions(id, data) end end WeakAuras.Add(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, distribute_h = { @@ -294,7 +294,7 @@ local function createOptions(id, data) end WeakAuras.Add(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, distribute_v = { @@ -377,7 +377,7 @@ local function createOptions(id, data) end WeakAuras.Add(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, space_h = { @@ -460,7 +460,7 @@ local function createOptions(id, data) end WeakAuras.Add(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, space_v = { @@ -543,7 +543,7 @@ local function createOptions(id, data) end WeakAuras.Add(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, scale = { @@ -564,7 +564,7 @@ local function createOptions(id, data) data.yOffset = data.yOffset/(1-change) data.scale = v WeakAuras.Add(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end }, endHeader = { @@ -574,13 +574,13 @@ local function createOptions(id, data) }, }; - for k, v in pairs(WeakAuras.commonOptions.BorderOptions(id, data, nil, nil, 70)) do + for k, v in pairs(OptionsPrivate.commonOptions.BorderOptions(id, data, nil, nil, 70)) do options[k] = v end return { group = options, - position = WeakAuras.commonOptions.PositionOptions(id, data, nil, true, true), + position = OptionsPrivate.commonOptions.PositionOptions(id, data, nil, true, true), }; end diff --git a/WeakAurasOptions/RegionOptions/Icon.lua b/WeakAurasOptions/RegionOptions/Icon.lua index 34c7a61..534b4d6 100644 --- a/WeakAurasOptions/RegionOptions/Icon.lua +++ b/WeakAurasOptions/RegionOptions/Icon.lua @@ -6,7 +6,7 @@ local L = WeakAuras.L local function createOptions(id, data) local hiddenIconExtra = function() - return WeakAuras.IsCollapsed("icon", "icon", "iconextra", true); + return OptionsPrivate.IsCollapsed("icon", "icon", "iconextra", true); end local indentWidth = 0.15 @@ -25,14 +25,14 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Automatic Icon"], order = 2, - disabled = function() return not WeakAuras.CanHaveAuto(data); end, - get = function() return WeakAuras.CanHaveAuto(data) and data.auto; end + disabled = function() return not OptionsPrivate.Private.CanHaveAuto(data); end, + get = function() return OptionsPrivate.Private.CanHaveAuto(data) and data.auto; end }, displayIcon = { type = "input", width = WeakAuras.normalWidth, name = L["Display Icon"], - hidden = function() return WeakAuras.CanHaveAuto(data) and data.auto; end, + hidden = function() return OptionsPrivate.Private.CanHaveAuto(data) and data.auto; end, order = 3, get = function() return data.displayIcon and tostring(data.displayIcon) or ""; @@ -47,9 +47,9 @@ local function createOptions(id, data) type = "execute", width = WeakAuras.normalWidth, name = L["Choose"], - hidden = function() return WeakAuras.CanHaveAuto(data) and data.auto; end, + hidden = function() return OptionsPrivate.Private.CanHaveAuto(data) and data.auto; end, order = 4, - func = function() WeakAuras.OpenIconPicker(data, "displayIcon"); end + func = function() OptionsPrivate.OpenIconPicker(data, "displayIcon"); end }, desaturate = { type = "toggle", @@ -61,7 +61,7 @@ local function createOptions(id, data) type = "toggle", width = WeakAuras.normalWidth, name = L["Tooltip on Mouseover"], - hidden = function() return not WeakAuras.CanHaveTooltip(data) end, + hidden = function() return not OptionsPrivate.Private.CanHaveTooltip(data) end, order = 6 }, iconExtraDescription = { @@ -94,14 +94,14 @@ local function createOptions(id, data) width = WeakAuras.doubleWidth, order = 7, image = function() - local collapsed = WeakAuras.IsCollapsed("icon", "icon", "iconextra", true); + local collapsed = OptionsPrivate.IsCollapsed("icon", "icon", "iconextra", true); return collapsed and "collapsed" or "expanded" end, imageWidth = 15, imageHeight = 15, func = function(info, button) - local collapsed = WeakAuras.IsCollapsed("icon", "icon", "iconextra", true); - WeakAuras.SetCollapsed("icon", "icon", "iconextra", not collapsed); + local collapsed = OptionsPrivate.IsCollapsed("icon", "icon", "iconextra", true); + OptionsPrivate.SetCollapsed("icon", "icon", "iconextra", not collapsed); end, arg = { expanderName = "icon" @@ -183,16 +183,16 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Show Cooldown"], order = 11.1, - disabled = function() return not WeakAuras.CanHaveDuration(data); end, - get = function() return WeakAuras.CanHaveDuration(data) and data.cooldown; end + disabled = function() return not OptionsPrivate.Private.CanHaveDuration(data); end, + get = function() return OptionsPrivate.Private.CanHaveDuration(data) and data.cooldown; end }, inverse = { type = "toggle", width = WeakAuras.normalWidth, name = L["Inverse"], order = 11.2, - disabled = function() return not (WeakAuras.CanHaveDuration(data) and data.cooldown); end, - get = function() return data.inverse and WeakAuras.CanHaveDuration(data) and data.cooldown; end, + disabled = function() return not (OptionsPrivate.Private.CanHaveDuration(data) and data.cooldown); end, + get = function() return data.inverse and OptionsPrivate.Private.CanHaveDuration(data) and data.cooldown; end, hidden = function() return not data.cooldown end }, cooldownEdge = { @@ -200,7 +200,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Cooldown Edge"], order = 11.3, - disabled = function() return not WeakAuras.CanHaveDuration(data) end, + disabled = function() return not OptionsPrivate.Private.CanHaveDuration(data) end, hidden = function() return not data.cooldown end, }, endHeader = { @@ -212,7 +212,7 @@ local function createOptions(id, data) return { icon = options, - position = WeakAuras.commonOptions.PositionOptions(id, data), + position = OptionsPrivate.commonOptions.PositionOptions(id, data), }; end @@ -236,7 +236,7 @@ local function modifyThumbnail(parent, frame, data) end if data then - local name, icon = WeakAuras.GetNameAndIcon(data); + local name, icon = OptionsPrivate.Private.GetNameAndIcon(data); frame:SetIcon(icon) end end diff --git a/WeakAurasOptions/RegionOptions/Model.lua b/WeakAurasOptions/RegionOptions/Model.lua index 67aee09..20cb8e2 100644 --- a/WeakAurasOptions/RegionOptions/Model.lua +++ b/WeakAurasOptions/RegionOptions/Model.lua @@ -31,7 +31,7 @@ local function createOptions(id, data) name = L["Choose"], order = 2, func = function() - WeakAuras.OpenModelPicker(data); + OptionsPrivate.OpenModelPicker(data); end, hidden = function() return data.modelIsUnit end }, @@ -116,13 +116,13 @@ local function createOptions(id, data) } end - for k, v in pairs(WeakAuras.commonOptions.BorderOptions(id, data, nil, nil, 70)) do + for k, v in pairs(OptionsPrivate.commonOptions.BorderOptions(id, data, nil, nil, 70)) do options[k] = v end return { model = options, - position = WeakAuras.commonOptions.PositionOptions(id, data, nil, nil, nil), + position = OptionsPrivate.commonOptions.PositionOptions(id, data, nil, nil, nil), }; end diff --git a/WeakAurasOptions/RegionOptions/ProgressTexture.lua b/WeakAurasOptions/RegionOptions/ProgressTexture.lua index bed13a1..d306256 100644 --- a/WeakAurasOptions/RegionOptions/ProgressTexture.lua +++ b/WeakAurasOptions/RegionOptions/ProgressTexture.lua @@ -34,7 +34,7 @@ local function createOptions(id, data) width = WeakAuras.halfWidth, order = 12, func = function() - WeakAuras.OpenTexturePicker(data, data, "foregroundTexture", WeakAuras.texture_types); + OptionsPrivate.OpenTexturePicker(data, data, "foregroundTexture", OptionsPrivate.Private.texture_types); end }, sameTexture = { @@ -49,7 +49,7 @@ local function createOptions(id, data) width = WeakAuras.halfWidth, order = 17, func = function() - WeakAuras.OpenTexturePicker(data, data, "backgroundTexture", WeakAuras.texture_types); + OptionsPrivate.OpenTexturePicker(data, data, "backgroundTexture", OptionsPrivate.Private.texture_types); end, disabled = function() return data.sameTexture; end }, @@ -70,7 +70,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Blend Mode"], order = 20, - values = WeakAuras.blend_types + values = OptionsPrivate.Private.blend_types }, backgroundOffset = { type = "range", @@ -86,7 +86,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Orientation"], order = 35, - values = WeakAuras.orientation_with_circle_types + values = OptionsPrivate.Private.orientation_with_circle_types }, compress = { type = "toggle", @@ -175,7 +175,7 @@ local function createOptions(id, data) WeakAuras.Add(parentData); end end - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end, }, crop_y = { @@ -198,7 +198,7 @@ local function createOptions(id, data) WeakAuras.Add(parentData); end end - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end, }, rotation = { @@ -250,7 +250,7 @@ local function createOptions(id, data) name = L["Slant Mode"], order = 55.5, hidden = function() return not data.slanted or data.orientation == "CLOCKWISE" or data.orientation == "ANTICLOCKWISE" end, - values = WeakAuras.slant_mode + values = OptionsPrivate.Private.slant_mode }, spacer = { type = "header", @@ -265,7 +265,7 @@ local function createOptions(id, data) }; options = WeakAuras.regionPrototype.AddAdjustedDurationOptions(options, data, 57); - local overlayInfo = WeakAuras.GetOverlayInfo(data); + local overlayInfo = OptionsPrivate.Private.GetOverlayInfo(data); if (overlayInfo and next(overlayInfo)) then options["overlayheader"] = { type = "header", @@ -307,7 +307,7 @@ local function createOptions(id, data) return { progresstexture = options, - position = WeakAuras.commonOptions.PositionOptions(id, data), + position = OptionsPrivate.commonOptions.PositionOptions(id, data), }; end @@ -773,7 +773,7 @@ local templates = { } local function GetAnchors(data) - return WeakAuras.default_types_for_anchor + return OptionsPrivate.Private.default_types_for_anchor end WeakAuras.RegisterRegionOptions("progresstexture", createOptions, createIcon, L["Progress Texture"], createThumbnail, modifyThumbnail, L["Shows a texture that changes based on duration"], templates, GetAnchors); diff --git a/WeakAurasOptions/RegionOptions/StopMotion.lua b/WeakAurasOptions/RegionOptions/StopMotion.lua index a6b6a91..14bacba 100644 --- a/WeakAurasOptions/RegionOptions/StopMotion.lua +++ b/WeakAurasOptions/RegionOptions/StopMotion.lua @@ -68,7 +68,7 @@ local function createOptions(id, data) name = L["Choose"], order = 12, func = function() - WeakAuras.OpenTexturePicker(data, data, "foregroundTexture", texture_types, setTextureFunc); + OptionsPrivate.OpenTexturePicker(data, data, "foregroundTexture", texture_types, setTextureFunc); end }, sameTexture = { @@ -203,7 +203,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Blend Mode"], order = 20, - values = WeakAuras.blend_types + values = OptionsPrivate.Private.blend_types }, animationType = { type = "select", @@ -283,10 +283,10 @@ local function createOptions(id, data) }, }; - if WeakAuras.commonOptions then + if OptionsPrivate.commonOptions then return { stopmotion = options, - position = WeakAuras.commonOptions.PositionOptions(id, data, 2), + position = OptionsPrivate.commonOptions.PositionOptions(id, data, 2), }; else return { diff --git a/WeakAurasOptions/RegionOptions/Text.lua b/WeakAurasOptions/RegionOptions/Text.lua index 67dfcf1..3dba9e2 100644 --- a/WeakAurasOptions/RegionOptions/Text.lua +++ b/WeakAurasOptions/RegionOptions/Text.lua @@ -8,7 +8,7 @@ local screenWidth, screenHeight = math.ceil(GetScreenWidth() / 20) * 20, math.ce local indentWidth = 0.15 local hiddenFontExtra = function() - return WeakAuras.IsCollapsed("text", "text", "fontflags", true) + return OptionsPrivate.IsCollapsed("text", "text", "fontflags", true) end local function createOptions(id, data) @@ -19,7 +19,7 @@ local function createOptions(id, data) type = "input", width = WeakAuras.doubleWidth, desc = function() - return L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(data) + return L["Dynamic text tooltip"] .. OptionsPrivate.Private.GetAdditionalProperties(data) end, multiline = true, name = L["Display Text"], @@ -28,19 +28,19 @@ local function createOptions(id, data) return data.displayText; end, set = function(info, v) - data.displayText = WeakAuras.ReplaceLocalizedRaidMarkers(v); + data.displayText = OptionsPrivate.Private.ReplaceLocalizedRaidMarkers(v); WeakAuras.Add(data); WeakAuras.ClearAndUpdateOptions(data.id) WeakAuras.UpdateThumbnail(data); - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); end, }, customTextUpdate = { type = "select", width = WeakAuras.doubleWidth, - hidden = function() return not WeakAuras.ContainsCustomPlaceHolder(data.displayText); end, + hidden = function() return not OptionsPrivate.Private.ContainsCustomPlaceHolder(data.displayText); end, name = L["Update Custom Text On..."], - values = WeakAuras.text_check_types, + values = OptionsPrivate.Private.text_check_types, order = 36 }, -- code editor added below @@ -76,7 +76,7 @@ local function createOptions(id, data) type = "execute", control = "WeakAurasExpandSmall", name = function() - local textFlags = WeakAuras.font_flags[data.outline] + local textFlags = OptionsPrivate.Private.font_flags[data.outline] local color = format("%02x%02x%02x%02x", data.shadowColor[4] * 255, data.shadowColor[1] * 255, data.shadowColor[2] * 255, data.shadowColor[3]*255) @@ -106,11 +106,11 @@ local function createOptions(id, data) return secondline end, func = function(info, button) - local collapsed = WeakAuras.IsCollapsed("text", "text", "fontflags", true) - WeakAuras.SetCollapsed("text", "text", "fontflags", not collapsed) + local collapsed = OptionsPrivate.IsCollapsed("text", "text", "fontflags", true) + OptionsPrivate.SetCollapsed("text", "text", "fontflags", not collapsed) end, image = function() - local collapsed = WeakAuras.IsCollapsed("text", "text", "fontflags", true) + local collapsed = OptionsPrivate.IsCollapsed("text", "text", "fontflags", true) return collapsed and "collapsed" or "expanded" end, imageWidth = 15, @@ -132,7 +132,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth - indentWidth, name = L["Outline"], order = 48.2, - values = WeakAuras.font_flags, + values = OptionsPrivate.Private.font_flags, hidden = hiddenFontExtra }, shadowColor = { @@ -184,7 +184,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth - indentWidth, name = L["Justify"], order = 48.8, - values = WeakAuras.justify_types, + values = OptionsPrivate.Private.justify_types, hidden = hiddenFontExtra, }, text_font_space55 = { @@ -207,7 +207,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth - indentWidth, name = L["Width"], order = 49, - values = WeakAuras.text_automatic_width, + values = OptionsPrivate.Private.text_automatic_width, hidden = hiddenFontExtra, }, fixedWidth = { @@ -232,7 +232,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth - indentWidth, name = L["Overflow"], order = 49.4, - values = WeakAuras.text_word_wrap, + values = OptionsPrivate.Private.text_word_wrap, hidden = function() return hiddenFontExtra() or data.automaticWidth ~= "Fixed" end }, @@ -254,17 +254,17 @@ local function createOptions(id, data) }, }; - WeakAuras.commonOptions.AddCodeOption(options, data, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-text", - 37, function() return not WeakAuras.ContainsCustomPlaceHolder(data.displayText) end, {"customText"}, false); + OptionsPrivate.commonOptions.AddCodeOption(options, data, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-text", + 37, function() return not OptionsPrivate.Private.ContainsCustomPlaceHolder(data.displayText) end, {"customText"}, false); -- Add Text Format Options local input = data.displayText local hidden = function() - return WeakAuras.IsCollapsed("format_option", "text", "displayText", true) + return OptionsPrivate.IsCollapsed("format_option", "text", "displayText", true) end local setHidden = function(hidden) - WeakAuras.SetCollapsed("format_option", "text", "displayText", hidden) + OptionsPrivate.SetCollapsed("format_option", "text", "displayText", hidden) end local get = function(key) @@ -286,7 +286,7 @@ local function createOptions(id, data) options["displayText_format_" .. key] = option end - WeakAuras.AddTextFormatOption(input, true, get, addOption, hidden, setHidden) + OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden) addOption("footer", { type = "description", name = "", @@ -296,7 +296,7 @@ local function createOptions(id, data) return { text = options; - position = WeakAuras.commonOptions.PositionOptions(id, data, nil, true); + position = OptionsPrivate.commonOptions.PositionOptions(id, data, nil, true); }; end diff --git a/WeakAurasOptions/RegionOptions/Texture.lua b/WeakAurasOptions/RegionOptions/Texture.lua index 3e8281b..e53a028 100644 --- a/WeakAurasOptions/RegionOptions/Texture.lua +++ b/WeakAurasOptions/RegionOptions/Texture.lua @@ -32,7 +32,7 @@ local function createOptions(id, data) width = WeakAuras.halfWidth, order = 7, func = function() - WeakAuras.OpenTexturePicker(data, data, "texture", WeakAuras.texture_types); + OptionsPrivate.OpenTexturePicker(data, data, "texture", OptionsPrivate.Private.texture_types); end }, color = { @@ -47,7 +47,7 @@ local function createOptions(id, data) width = WeakAuras.normalWidth, name = L["Blend Mode"], order = 12, - values = WeakAuras.blend_types + values = OptionsPrivate.Private.blend_types }, mirror = { type = "toggle", @@ -101,7 +101,7 @@ local function createOptions(id, data) return { texture = options, - position = WeakAuras.commonOptions.PositionOptions(id, data), + position = OptionsPrivate.commonOptions.PositionOptions(id, data), }; end @@ -230,7 +230,7 @@ local templates = { } local function GetAnchors(data) - return WeakAuras.default_types_for_anchor + return OptionsPrivate.Private.default_types_for_anchor end WeakAuras.RegisterRegionOptions("texture", createOptions, createIcon, L["Texture"], createThumbnail, modifyThumbnail, L["Shows a custom texture"], templates, GetAnchors); diff --git a/WeakAurasOptions/SubRegionOptions/BarModel.lua b/WeakAurasOptions/SubRegionOptions/BarModel.lua index 0d4cf60..868a07a 100644 --- a/WeakAurasOptions/SubRegionOptions/BarModel.lua +++ b/WeakAurasOptions/SubRegionOptions/BarModel.lua @@ -1,4 +1,5 @@ if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... local SharedMedia = LibStub("LibSharedMedia-3.0"); local L = WeakAuras.L; @@ -8,22 +9,22 @@ local function createOptions(parentData, data, index, subIndex) __title = L["Model %s"]:format(subIndex), __order = 1, __up = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionUp, index, "subbarmodel")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionUp, index, "subbarmodel")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __down = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionDown, index, "subbarmodel")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionDown, index, "subbarmodel")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __duplicate = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DuplicateSubRegion, index, "subbarmodel")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.DuplicateSubRegion, index, "subbarmodel")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __delete = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subbarmodel")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subbarmodel")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, @@ -45,7 +46,7 @@ local function createOptions(parentData, data, index, subIndex) name = L["Choose"], order = 11, func = function() - WeakAuras.OpenModelPicker(data, parentData); + OptionsPrivate.OpenModelPicker(data, parentData); end, }, bar_model_clip = { diff --git a/WeakAurasOptions/SubRegionOptions/Border.lua b/WeakAurasOptions/SubRegionOptions/Border.lua index f6e4384..4b9d749 100644 --- a/WeakAurasOptions/SubRegionOptions/Border.lua +++ b/WeakAurasOptions/SubRegionOptions/Border.lua @@ -1,4 +1,5 @@ if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... local SharedMedia = LibStub("LibSharedMedia-3.0"); local L = WeakAuras.L; @@ -10,22 +11,22 @@ local function createOptions(parentData, data, index, subIndex) __title = L["Border %s"]:format(subIndex), __order = 1, __up = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionUp, index, "subborder")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionUp, index, "subborder")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __down = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionDown, index, "subborder")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionDown, index, "subborder")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __duplicate = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DuplicateSubRegion, index, "subtext")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.DuplicateSubRegion, index, "subtext")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __delete = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subborder")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subborder")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, @@ -73,7 +74,7 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.normalWidth, name = L["Border Anchor"], order = 7, - values = WeakAuras.aurabar_anchor_areas, + values = OptionsPrivate.Private.aurabar_anchor_areas, hidden = function() return parentData.regionType ~= "aurabar" end } } diff --git a/WeakAurasOptions/SubRegionOptions/Glow.lua b/WeakAurasOptions/SubRegionOptions/Glow.lua index 220b728..7444fe6 100644 --- a/WeakAurasOptions/SubRegionOptions/Glow.lua +++ b/WeakAurasOptions/SubRegionOptions/Glow.lua @@ -1,4 +1,5 @@ if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... local SharedMedia = LibStub("LibSharedMedia-3.0"); local L = WeakAuras.L; @@ -12,29 +13,29 @@ local indentWidth = 0.15 local function createOptions(parentData, data, index, subIndex) local hiddenGlowExtra = function() - return WeakAuras.IsCollapsed("glow", "glow", "glowextra" .. index, true); + return OptionsPrivate.IsCollapsed("glow", "glow", "glowextra" .. index, true); end local options = { __title = L["Glow %s"]:format(subIndex), __order = 1, __up = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionUp, index, "subglow")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionUp, index, "subglow")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __down = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionDown, index, "subglow")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionDown, index, "subglow")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __duplicate = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DuplicateSubRegion, index, "subglow")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.DuplicateSubRegion, index, "subglow")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __delete = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subglow")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subglow")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, @@ -49,14 +50,14 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.normalWidth, name = L["Type"], order = 2, - values = WeakAuras.glow_types, + values = OptionsPrivate.Private.glow_types, }, glow_anchor = { type = "select", width = WeakAuras.normalWidth, name = L["Glow Anchor"], order = 3, - values = WeakAuras.aurabar_anchor_areas, + values = OptionsPrivate.Private.aurabar_anchor_areas, hidden = function() return parentData.regionType ~= "aurabar" end }, glowExtraDescription = { @@ -107,14 +108,14 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.doubleWidth, order = 4, image = function() - local collapsed = WeakAuras.IsCollapsed("glow", "glow", "glowextra" .. index, true); + local collapsed = OptionsPrivate.IsCollapsed("glow", "glow", "glowextra" .. index, true); return collapsed and "collapsed" or "expanded" end, imageWidth = 15, imageHeight = 15, func = function(info, button) - local collapsed = WeakAuras.IsCollapsed("glow", "glow", "glowextra" .. index, true); - WeakAuras.SetCollapsed("glow", "glow", "glowextra" .. index, not collapsed); + local collapsed = OptionsPrivate.IsCollapsed("glow", "glow", "glowextra" .. index, true); + OptionsPrivate.SetCollapsed("glow", "glow", "glowextra" .. index, not collapsed); end, arg = { expanderName = "glow" .. index .. "#" .. subIndex diff --git a/WeakAurasOptions/SubRegionOptions/SubRegionCommon.lua b/WeakAurasOptions/SubRegionOptions/SubRegionCommon.lua index 888112a..ec113d8 100644 --- a/WeakAurasOptions/SubRegionOptions/SubRegionCommon.lua +++ b/WeakAurasOptions/SubRegionOptions/SubRegionCommon.lua @@ -1,4 +1,5 @@ if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... -- Magic constant local deleteCondition = {} @@ -44,7 +45,7 @@ function WeakAuras.DeleteSubRegion(data, index, regionType) end end -function WeakAuras.MoveSubRegionUp(data, index, regionType) +function OptionsPrivate.MoveSubRegionUp(data, index, regionType) if not data.subRegions or index <= 1 then return end @@ -63,7 +64,7 @@ function WeakAuras.MoveSubRegionUp(data, index, regionType) end end -function WeakAuras.MoveSubRegionDown(data, index, regionType) +function OptionsPrivate.MoveSubRegionDown(data, index, regionType) if not data.subRegions then return end @@ -82,7 +83,7 @@ function WeakAuras.MoveSubRegionDown(data, index, regionType) end end -function WeakAuras.DuplicateSubRegion(data, index, regionType) +function OptionsPrivate.DuplicateSubRegion(data, index, regionType) if not data.subRegions then return end diff --git a/WeakAurasOptions/SubRegionOptions/SubText.lua b/WeakAurasOptions/SubRegionOptions/SubText.lua index 9c89602..4d069bf 100644 --- a/WeakAurasOptions/SubRegionOptions/SubText.lua +++ b/WeakAurasOptions/SubRegionOptions/SubText.lua @@ -1,4 +1,5 @@ if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... local SharedMedia = LibStub("LibSharedMedia-3.0") local L = WeakAuras.L @@ -22,7 +23,7 @@ local function createOptions(parentData, data, index, subIndex) -- The toggles for font flags is intentionally not keyed on the id -- So that all auras share the state of that toggle local hiddenFontExtra = function() - return WeakAuras.IsCollapsed("subtext", "subtext", "fontflags" .. index, true) + return OptionsPrivate.IsCollapsed("subtext", "subtext", "fontflags" .. index, true) end local indentWidth = 0.15 @@ -31,22 +32,22 @@ local function createOptions(parentData, data, index, subIndex) __title = L["Text %s"]:format(subIndex), __order = 1, __up = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionUp, index, "subtext")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionUp, index, "subtext")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __down = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionDown, index, "subtext")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionDown, index, "subtext")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __duplicate = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DuplicateSubRegion, index, "subtext")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.DuplicateSubRegion, index, "subtext")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __delete = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subtext")) then + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subtext")) then WeakAuras.ClearAndUpdateOptions(parentData.id) end end, @@ -67,12 +68,12 @@ local function createOptions(parentData, data, index, subIndex) type = "input", width = WeakAuras.normalWidth, desc = function() - return L["Dynamic text tooltip"] .. WeakAuras.GetAdditionalProperties(parentData) + return L["Dynamic text tooltip"] .. OptionsPrivate.Private.GetAdditionalProperties(parentData) end, name = L["Display Text"], order = 11, set = function(info, v) - data.text_text = WeakAuras.ReplaceLocalizedRaidMarkers(v) + data.text_text = OptionsPrivate.Private.ReplaceLocalizedRaidMarkers(v) WeakAuras.Add(parentData) WeakAuras.ClearAndUpdateOptions(parentData.id) end @@ -98,7 +99,7 @@ local function createOptions(parentData, data, index, subIndex) type = "execute", control = "WeakAurasExpandSmall", name = function() - local textFlags = WeakAuras.font_flags[data.text_fontType] + local textFlags = OptionsPrivate.Private.font_flags[data.text_fontType] local color = format("%02x%02x%02x%02x", data.text_shadowColor[4] * 255, data.text_shadowColor[1] * 255, data.text_shadowColor[2] * 255, data.text_shadowColor[3]*255) @@ -130,11 +131,11 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.doubleWidth, order = 44, func = function(info, button) - local collapsed = WeakAuras.IsCollapsed("subtext", "subtext", "fontflags" .. index, true) - WeakAuras.SetCollapsed("subtext", "subtext", "fontflags" .. index, not collapsed) + local collapsed = OptionsPrivate.IsCollapsed("subtext", "subtext", "fontflags" .. index, true) + OptionsPrivate.SetCollapsed("subtext", "subtext", "fontflags" .. index, not collapsed) end, image = function() - local collapsed = WeakAuras.IsCollapsed("subtext", "subtext", "fontflags" .. index, true) + local collapsed = OptionsPrivate.IsCollapsed("subtext", "subtext", "fontflags" .. index, true) return collapsed and "collapsed" or "expanded" end, imageWidth = 15, @@ -157,7 +158,7 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.normalWidth - indentWidth, name = L["Outline"], order = 46, - values = WeakAuras.font_flags, + values = OptionsPrivate.Private.font_flags, hidden = hiddenFontExtra }, text_shadowColor = { @@ -208,7 +209,7 @@ local function createOptions(parentData, data, index, subIndex) type = "select", width = WeakAuras.normalWidth - indentWidth, name = L["Alignment"], - values = WeakAuras.justify_types, + values = OptionsPrivate.Private.justify_types, order = 50, hidden = hiddenFontExtra }, @@ -224,7 +225,7 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.normalWidth - indentWidth, name = L["Width"], order = 51.5, - values = WeakAuras.text_automatic_width, + values = OptionsPrivate.Private.text_automatic_width, hidden = hiddenFontExtra }, text_font_space6 = { @@ -256,7 +257,7 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.normalWidth, name = L["Overflow"], order = 54, - values = WeakAuras.text_word_wrap, + values = OptionsPrivate.Private.text_word_wrap, hidden = function() return hiddenFontExtra() or data.text_automaticWidth ~= "Fixed" end }, @@ -282,10 +283,10 @@ local function createOptions(parentData, data, index, subIndex) anchors = {} for index, childId in ipairs(parentData.controlledChildren) do local childData = WeakAuras.GetData(childId) - WeakAuras.Mixin(anchors, WeakAuras.GetAnchorsForData(childData, "point")) + WeakAuras.Mixin(anchors, OptionsPrivate.Private.GetAnchorsForData(childData, "point")) end else - anchors = WeakAuras.GetAnchorsForData(parentData, "point") + anchors = OptionsPrivate.Private.GetAnchorsForData(parentData, "point") end -- Anchor Options options.text_anchorsDescription = { @@ -319,14 +320,14 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.doubleWidth, order = 60, image = function() - local collapsed = WeakAuras.IsCollapsed("subregion", "text_anchors", tostring(index), true) + local collapsed = OptionsPrivate.IsCollapsed("subregion", "text_anchors", tostring(index), true) return collapsed and "collapsed" or "expanded" end, imageWidth = 15, imageHeight = 15, func = function(info, button) - local collapsed = WeakAuras.IsCollapsed("subregion", "text_anchors", tostring(index), true) - WeakAuras.SetCollapsed("subregion", "text_anchors", tostring(index), not collapsed) + local collapsed = OptionsPrivate.IsCollapsed("subregion", "text_anchors", tostring(index), true) + OptionsPrivate.SetCollapsed("subregion", "text_anchors", tostring(index), not collapsed) end, arg = { expanderName = "subtext_anchor" .. index .. "#" .. subIndex @@ -335,7 +336,7 @@ local function createOptions(parentData, data, index, subIndex) local hiddenFunction = function() - return WeakAuras.IsCollapsed("subregion", "text_anchors", tostring(index), true) + return OptionsPrivate.IsCollapsed("subregion", "text_anchors", tostring(index), true) end options.text_anchor_space = { @@ -414,7 +415,7 @@ local function createOptions(parentData, data, index, subIndex) end for index, subRegion in ipairs(parentData.subRegions) do - if subRegion.type == "subtext" and WeakAuras.ContainsCustomPlaceHolder(subRegion.text_text) then + if subRegion.type == "subtext" and OptionsPrivate.Private.ContainsCustomPlaceHolder(subRegion.text_text) then return false end end @@ -429,7 +430,7 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.doubleWidth, hidden = hideCustomTextOption, name = L["Update Custom Text On..."], - values = WeakAuras.text_check_types, + values = OptionsPrivate.Private.text_check_types, order = 3, get = function() return parentData.customTextUpdate or "event" end, set = function(info, v) @@ -440,16 +441,16 @@ local function createOptions(parentData, data, index, subIndex) }, } - WeakAuras.commonOptions.AddCodeOption(commonTextOptions, parentData, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-text", + OptionsPrivate.commonOptions.AddCodeOption(commonTextOptions, parentData, L["Custom Function"], "customText", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-text", 4, hideCustomTextOption, {"customText"}, false) -- Add Text Format Options local hidden = function() - return WeakAuras.IsCollapsed("format_option", "text", "text_text", true) + return OptionsPrivate.IsCollapsed("format_option", "text", "text_text", true) end local setHidden = function(hidden) - WeakAuras.SetCollapsed("format_option", "text", "text_text", hidden) + OptionsPrivate.SetCollapsed("format_option", "text", "text_text", hidden) end local order = 12 @@ -478,7 +479,7 @@ local function createOptions(parentData, data, index, subIndex) return childData["text_text_format_" .. key] end local input = childData["text_text"] - WeakAuras.AddTextFormatOption(input, true, get, addOption, hidden, setHidden) + OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden) end end end @@ -487,7 +488,7 @@ local function createOptions(parentData, data, index, subIndex) return data["text_text_format_" .. key] end local input = data["text_text"] - WeakAuras.AddTextFormatOption(input, true, get, addOption, hidden, setHidden) + OptionsPrivate.AddTextFormatOption(input, true, get, addOption, hidden, setHidden) end addOption("footer", { diff --git a/WeakAurasOptions/SubRegionOptions/Tick.lua b/WeakAurasOptions/SubRegionOptions/Tick.lua index f404d76..d2abc8a 100644 --- a/WeakAurasOptions/SubRegionOptions/Tick.lua +++ b/WeakAurasOptions/SubRegionOptions/Tick.lua @@ -1,4 +1,5 @@ if not WeakAuras.IsCorrectVersion() then return end +local AddonName, OptionsPrivate = ... local SharedMedia = LibStub("LibSharedMedia-3.0"); local L = WeakAuras.L; @@ -7,29 +8,29 @@ local indentWidth = WeakAuras.normalWidth * 0.06 local function createOptions(parentData, data, index, subIndex) local hiddentickextras = function() - return WeakAuras.IsCollapsed("subtext", "subtext", "tickextras" .. index, true) + return OptionsPrivate.IsCollapsed("subtext", "subtext", "tickextras" .. index, true) end local options = { __title = L["Tick %s"]:format(subIndex), __order = 1, __up = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionUp, index, "subtick")) then - WeakAuras.ReloadOptions2(parentData.id, parentData) + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionUp, index, "subtick")) then + WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __down = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.MoveSubRegionDown, index, "subtick")) then - WeakAuras.ReloadOptions2(parentData.id, parentData) + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.MoveSubRegionDown, index, "subtick")) then + WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __duplicate = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DuplicateSubRegion, index, "subtick")) then - WeakAuras.ReloadOptions2(parentData.id, parentData) + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, OptionsPrivate.DuplicateSubRegion, index, "subtick")) then + WeakAuras.ClearAndUpdateOptions(parentData.id) end end, __delete = function() - if (WeakAuras.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subtick")) then - WeakAuras.ReloadOptions2(parentData.id, parentData) + if (OptionsPrivate.Private.ApplyToDataOrChildData(parentData, WeakAuras.DeleteSubRegion, index, "subtick")) then + WeakAuras.ClearAndUpdateOptions(parentData.id) end end, tick_visible = { @@ -50,7 +51,7 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.normalWidth, name = L["Tick Mode"], order = 3, - values = WeakAuras.tick_placement_modes, + values = OptionsPrivate.Private.tick_placement_modes, }, tick_placement = { type = "input", @@ -83,7 +84,7 @@ local function createOptions(parentData, data, index, subIndex) local texturetext = "" if data.use_texture then local desaturatetext = data.tick_desaturate and L["|cFFFF0000desaturated|r "] or "" - local blendtext = WeakAuras.blend_types[data.tick_blend_mode] + local blendtext = OptionsPrivate.Private.blend_types[data.tick_blend_mode] local rotationtext = data.tick_rotation ~= 0 and L[" rotated |cFFFF0000%s|r degrees"]:format(data.tick_rotation) or "" local mirrortext = data.tick_mirror and L[" and |cFFFF0000mirrored|r"] or "" texturetext = L["%s|cFFFF0000custom|r texture with |cFFFF0000%s|r blend mode%s%s"]:format(desaturatetext, blendtext, rotationtext, mirrortext) @@ -103,11 +104,11 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.doubleWidth, order = 6, func = function(info, button) - local collapsed = WeakAuras.IsCollapsed("subtext", "subtext", "tickextras" .. index, true) - WeakAuras.SetCollapsed("subtext", "subtext", "tickextras" .. index, not collapsed) + local collapsed = OptionsPrivate.IsCollapsed("subtext", "subtext", "tickextras" .. index, true) + OptionsPrivate.SetCollapsed("subtext", "subtext", "tickextras" .. index, not collapsed) end, image = function() - local collapsed = WeakAuras.IsCollapsed("subtext", "subtext", "tickextras" .. index, true) + local collapsed = OptionsPrivate.IsCollapsed("subtext", "subtext", "tickextras" .. index, true) return collapsed and "collapsed" or "expanded" end, imageWidth = 15, @@ -147,7 +148,7 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.normalWidth, name = L["Blend Mode"], order = 10, - values = WeakAuras.blend_types, + values = OptionsPrivate.Private.blend_types, disabled = function() return not data.use_texture end, hidden = hiddentickextras, }, @@ -172,7 +173,7 @@ local function createOptions(parentData, data, index, subIndex) width = WeakAuras.normalWidth, order = 13, func = function() - WeakAuras.OpenTexturePicker(data, "tick_texture", WeakAuras.texture_types); + OptionsPrivate.OpenTexturePicker(data, "tick_texture", OptionsPrivate.Private.texture_types); end, disabled = function() return not data.use_texture end, hidden = hiddentickextras, diff --git a/WeakAurasOptions/TriggerOptions.lua b/WeakAurasOptions/TriggerOptions.lua index 224514c..4f3561d 100644 --- a/WeakAurasOptions/TriggerOptions.lua +++ b/WeakAurasOptions/TriggerOptions.lua @@ -3,20 +3,19 @@ local AddonName, OptionsPrivate = ... local L = WeakAuras.L -local removeFuncs = WeakAuras.commonOptions.removeFuncs -local replaceNameDescFuncs = WeakAuras.commonOptions.replaceNameDescFuncs -local replaceImageFuncs = WeakAuras.commonOptions.replaceImageFuncs -local replaceValuesFuncs = WeakAuras.commonOptions.replaceValuesFuncs -local disabledAll = WeakAuras.commonOptions.CreateDisabledAll("trigger") -local hiddenAll = WeakAuras.commonOptions.CreateHiddenAll("trigger") -local getAll = WeakAuras.commonOptions.CreateGetAll("trigger") -local setAll = WeakAuras.commonOptions.CreateSetAll("trigger", getAll) -local executeAll = WeakAuras.commonOptions.CreateExecuteAll("trigger") +local removeFuncs = OptionsPrivate.commonOptions.removeFuncs +local replaceNameDescFuncs = OptionsPrivate.commonOptions.replaceNameDescFuncs +local replaceImageFuncs = OptionsPrivate.commonOptions.replaceImageFuncs +local replaceValuesFuncs = OptionsPrivate.commonOptions.replaceValuesFuncs +local disabledAll = OptionsPrivate.commonOptions.CreateDisabledAll("trigger") +local hiddenAll = OptionsPrivate.commonOptions.CreateHiddenAll("trigger") +local getAll = OptionsPrivate.commonOptions.CreateGetAll("trigger") +local setAll = OptionsPrivate.commonOptions.CreateSetAll("trigger", getAll) +local executeAll = OptionsPrivate.commonOptions.CreateExecuteAll("trigger") -local flattenRegionOptions = WeakAuras.commonOptions.flattenRegionOptions -local fixMetaOrders = WeakAuras.commonOptions.fixMetaOrders +local flattenRegionOptions = OptionsPrivate.commonOptions.flattenRegionOptions +local fixMetaOrders = OptionsPrivate.commonOptions.fixMetaOrders -local subevent_actual_prefix_types = WeakAuras.subevent_actual_prefix_types; local spellCache = WeakAuras.spellCache local function union(table1, table2) @@ -43,9 +42,9 @@ local function GetGlobalOptions(data) order = 2, values = function() if #data.triggers > 1 then - return WeakAuras.trigger_require_types; + return OptionsPrivate.Private.trigger_require_types; else - return WeakAuras.trigger_require_types_one; + return OptionsPrivate.Private.trigger_require_types_one; end end, get = function() @@ -68,14 +67,14 @@ local function GetGlobalOptions(data) order = 2.3, values = function() local vals = {}; - vals[WeakAuras.trigger_modes.first_active] = L["Dynamic information from first active trigger"]; + vals[OptionsPrivate.Private.trigger_modes.first_active] = L["Dynamic information from first active trigger"]; for i = 1, #data.triggers do vals[i] = L["Dynamic information from Trigger %i"]:format(i); end return vals; end, get = function() - return data.triggers.activeTriggerMode or WeakAuras.trigger_modes.first_active; + return data.triggers.activeTriggerMode or OptionsPrivate.Private.trigger_modes.first_active; end, set = function(info, v) data.triggers.activeTriggerMode = v; @@ -90,7 +89,7 @@ local function GetGlobalOptions(data) local function hideTriggerCombiner() return not (data.triggers.disjunctive == "custom") end - WeakAuras.commonOptions.AddCodeOption(globalTriggerOptions, data, L["Custom"], "custom_trigger_combination", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-activation", + OptionsPrivate.commonOptions.AddCodeOption(globalTriggerOptions, data, L["Custom"], "custom_trigger_combination", "https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Code-Blocks#custom-activation", 2.4, hideTriggerCombiner, {"triggers", "customTriggerLogic"}, false); return { @@ -103,13 +102,13 @@ local function AddOptions(allOptions, data) local triggerOptions = {} for index, trigger in ipairs(data.triggers) do - local triggerSystemOptionsFunction = trigger.trigger.type and WeakAuras.triggerTypesOptions[trigger.trigger.type] + local triggerSystemOptionsFunction = trigger.trigger.type and OptionsPrivate.Private.triggerTypesOptions[trigger.trigger.type] if (triggerSystemOptionsFunction) then triggerOptions = union(triggerOptions, triggerSystemOptionsFunction(data, index)) else local options = {}; - WeakAuras.commonOptions.AddCommonTriggerOptions(options, data, index) - WeakAuras.AddTriggerMetaFunctions(options, data, index) + OptionsPrivate.commonOptions.AddCommonTriggerOptions(options, data, index) + OptionsPrivate.AddTriggerMetaFunctions(options, data, index) triggerOptions = union(triggerOptions, { ["trigger." .. index .. ".unknown"] = options }) @@ -119,7 +118,7 @@ local function AddOptions(allOptions, data) return union(allOptions, triggerOptions) end -function WeakAuras.GetTriggerOptions(data) +function OptionsPrivate.GetTriggerOptions(data) local allOptions = {} if data.controlledChildren then for index, childId in pairs(data.controlledChildren) do @@ -223,7 +222,7 @@ local function moveTriggerDownImpl(data, i) return true; end -function WeakAuras.AddTriggerMetaFunctions(options, data, triggernum) +function OptionsPrivate.AddTriggerMetaFunctions(options, data, triggernum) options.__title = L["Trigger %s"]:format(triggernum) options.__order = triggernum * 10 options.__add = function() diff --git a/WeakAurasOptions/WeakAurasOptions.lua b/WeakAurasOptions/WeakAurasOptions.lua index 24cf715..430a966 100644 --- a/WeakAurasOptions/WeakAurasOptions.lua +++ b/WeakAurasOptions/WeakAurasOptions.lua @@ -18,22 +18,15 @@ local WeakAuras = WeakAuras local L = WeakAuras.L local ADDON_NAME = "WeakAurasOptions"; -local dynFrame = WeakAuras.dynFrame; -WeakAuras.transmitCache = {}; - local displayButtons = {}; WeakAuras.displayButtons = displayButtons; -local aceOptions = {} -WeakAuras.aceOptions = aceOptions - -local loaded = WeakAuras.loaded; local spellCache = WeakAuras.spellCache; local savedVars = {}; -WeakAuras.savedVars = savedVars; +OptionsPrivate.savedVars = savedVars; -WeakAuras.expanderAnchors = {} -WeakAuras.expanderButtons = {} +OptionsPrivate.expanderAnchors = {} +OptionsPrivate.expanderButtons = {} local tempGroup = { id = {"tempGroup"}, @@ -48,9 +41,9 @@ local tempGroup = { xOffset = 0, yOffset = 0 }; -WeakAuras.tempGroup = tempGroup; +OptionsPrivate.tempGroup = tempGroup; -function WeakAuras.DuplicateAura(data, newParent) +function OptionsPrivate.DuplicateAura(data, newParent) local base_id = data.id .. " " local num = 2 @@ -68,8 +61,7 @@ function WeakAuras.DuplicateAura(data, newParent) num = num + 1 end - local newData = {} - WeakAuras.DeepCopy(data, newData) + local newData = CopyTable(data) newData.id = new_id newData.parent = nil newData.uid = WeakAuras.GenerateUniqueID() @@ -102,7 +94,7 @@ function WeakAuras.DuplicateAura(data, newParent) local button = WeakAuras.GetDisplayButton(parentData.id) button.callbacks.UpdateExpandButton() WeakAuras.UpdateDisplayButton(parentData) - WeakAuras.ClearOptions(parentData.id) + OptionsPrivate.ClearOptions(parentData.id) end end return newData.id @@ -164,7 +156,7 @@ AceGUI:RegisterLayout("ButtonsScrollLayout", function(content, children, skipLay end end) -function WeakAuras.MultipleDisplayTooltipDesc() +function OptionsPrivate.MultipleDisplayTooltipDesc() local desc = {{L["Multiple Displays"], L["Temporary Group"]}}; for index, id in pairs(tempGroup.controlledChildren) do desc[index + 1] = {" ", id}; @@ -226,7 +218,7 @@ loadedFrame:SetScript("OnEvent", function(self, event, addon) end end); -function WeakAuras.MultipleDisplayTooltipMenu() +function OptionsPrivate.MultipleDisplayTooltipMenu() local frame = frame; local menu = { { @@ -246,7 +238,7 @@ function WeakAuras.MultipleDisplayTooltipMenu() childData.parent = data.id; WeakAuras.Add(data); WeakAuras.Add(childData); - WeakAuras.ClearOptions(childData.id) + OptionsPrivate.ClearOptions(childData.id) end for index, id in pairs(data.controlledChildren) do @@ -311,10 +303,10 @@ function WeakAuras.MultipleDisplayTooltipMenu() for index, id in ipairs(toDuplicate) do local childData = WeakAuras.GetData(id); - duplicated[index] = WeakAuras.DuplicateAura(childData); + duplicated[index] = OptionsPrivate.DuplicateAura(childData); end - WeakAuras.ClearPicks(); + OptionsPrivate.ClearPicks(); frame:PickDisplayBatch(duplicated); end }, @@ -336,7 +328,7 @@ function WeakAuras.MultipleDisplayTooltipMenu() parents[childData.parent] = true; end end - WeakAuras.ConfirmDelete(toDelete, parents) + OptionsPrivate.ConfirmDelete(toDelete, parents) end }, { @@ -387,8 +379,8 @@ function WeakAuras.DeleteOption(data, massDelete) end end - WeakAuras.CollapseAllClones(id); - WeakAuras.ClearOptions(id) + OptionsPrivate.Private.CollapseAllClones(id); + OptionsPrivate.ClearOptions(id) frame:ClearPicks(); WeakAuras.Delete(data); @@ -456,7 +448,7 @@ StaticPopupDialogs["WEAKAURAS_CONFIRM_DELETE"] = { preferredindex = STATICPOPUP_NUMDIALOGS, } -function WeakAuras.ConfirmDelete(toDelete, parents) +function OptionsPrivate.ConfirmDelete(toDelete, parents) if toDelete then local warningForm = L["You are about to delete %d aura(s). |cFFFF0000This cannot be undone!|r Would you like to continue?"] StaticPopupDialogs["WEAKAURAS_CONFIRM_DELETE"].text = warningForm:format(#toDelete) @@ -472,6 +464,16 @@ function WeakAuras.OptionsFrame() end end +local function AfterScanForLoads() + if(frame) then + if (frame:IsVisible()) then + WeakAuras.SortDisplayButtons(nil, true); + else + frame.needsSort = true; + end + end +end + function WeakAuras.ToggleOptions(msg, Private) if not Private then return @@ -479,15 +481,15 @@ function WeakAuras.ToggleOptions(msg, Private) if not OptionsPrivate.Private then OptionsPrivate.Private = Private OptionsPrivate.Private:RegisterCallback("AuraWarningsUpdated", function(event, uid) - local id = WeakAuras.UIDtoID(uid) + local id = OptionsPrivate.Private.UIDtoID(uid) if displayButtons[id] then -- The button does not yet exists if a new aura is created displayButtons[id]:UpdateWarning() end end) + OptionsPrivate.Private:RegisterCallback("ScanForLoads", AfterScanForLoads) end - if(frame and frame:IsVisible()) then WeakAuras.HideOptions(); elseif (InCombatLockdown()) then @@ -498,27 +500,183 @@ function WeakAuras.ToggleOptions(msg, Private) end end -function WeakAuras.UpdateCloneConfig(data) - if(WeakAuras.CanHaveClones(data)) then - local cloneRegion = WeakAuras.EnsureClone(data.id, 1); - cloneRegion:Expand(); - - cloneRegion = WeakAuras.EnsureClone(data.id, 2); - cloneRegion:Expand(); +function WeakAuras.HideOptions() + if(frame) then + frame:Hide() end end +function WeakAuras.IsOptionsOpen() + if(frame and frame:IsVisible()) then + return true; + else + return false; + end +end + +local function EnsureDisplayButton(data) + local id = data.id; + if not(displayButtons[id]) then + displayButtons[id] = AceGUI:Create("WeakAurasDisplayButton"); + if(displayButtons[id]) then + displayButtons[id]:SetData(data); + displayButtons[id]:Initialize(); + displayButtons[id]:UpdateWarning() + else + print("|cFF8800FFWeakAuras|r: Error creating button for", id); + end + end +end + +local function GetSortedOptionsLists() + local loadedSorted, unloadedSorted = {}, {}; + local to_sort = {}; + for id, data in pairs(db.displays) do + if(data.parent) then + -- Do nothing; children will be added later + elseif(OptionsPrivate.Private.loaded[id]) then + tinsert(to_sort, id); + end + end + table.sort(to_sort, function(a, b) return a < b end); + for _, id in ipairs(to_sort) do + tinsert(loadedSorted, id); + local data = WeakAuras.GetData(id); + local controlledChildren = data.controlledChildren; + if(controlledChildren) then + for _, childId in pairs(controlledChildren) do + tinsert(loadedSorted, childId); + end + end + end + + wipe(to_sort); + for id, data in pairs(db.displays) do + if(data.parent) then + -- Do nothing; children will be added later + elseif not(OptionsPrivate.Private.loaded[id]) then + tinsert(to_sort, id); + end + end + table.sort(to_sort, function(a, b) return a < b end); + for _, id in ipairs(to_sort) do + tinsert(unloadedSorted, id); + local data = WeakAuras.GetData(id); + local controlledChildren = data.controlledChildren; + if(controlledChildren) then + for _, childId in pairs(controlledChildren) do + tinsert(unloadedSorted, childId); + end + end + end + + return loadedSorted, unloadedSorted; +end + +local function LayoutDisplayButtons(msg) + local total = 0; + for _,_ in pairs(db.displays) do + total = total + 1; + end + + local loadedSorted, unloadedSorted = GetSortedOptionsLists(); + + frame:SetLoadProgressVisible(true) + --frame.buttonsScroll:AddChild(frame.newButton); + --if(frame.addonsButton) then + -- frame.buttonsScroll:AddChild(frame.addonsButton); + --end + frame.buttonsScroll:AddChild(frame.loadedButton); + frame.buttonsScroll:AddChild(frame.unloadedButton); + + local func2 = function() + local num = frame.loadProgressNum or 0; + for index, id in pairs(unloadedSorted) do + local data = WeakAuras.GetData(id); + if(data) then + EnsureDisplayButton(data); + WeakAuras.UpdateDisplayButton(data); + + frame.buttonsScroll:AddChild(displayButtons[data.id]); + + if (num % 50 == 0) then + frame.buttonsScroll:ResumeLayout() + frame.buttonsScroll:PerformLayout() + frame.buttonsScroll:PauseLayout() + end + + num = num + 1; + end + frame.loadProgress:SetText(L["Creating buttons: "]..num.."/"..total); + frame.loadProgressNum = num; + coroutine.yield(); + end + + frame.buttonsScroll:ResumeLayout() + frame.buttonsScroll:PerformLayout() + WeakAuras.SortDisplayButtons(msg); + + OptionsPrivate.Private.PauseAllDynamicGroups(); + if (WeakAuras.IsOptionsOpen()) then + for id, button in pairs(displayButtons) do + if(OptionsPrivate.Private.loaded[id] ~= nil) then + button:PriorityShow(1); + end + if WeakAurasCompanion and not button.data.parent then + -- initialize update icons on top level buttons + button:RefreshUpdate() + end + end + end + OptionsPrivate.Private.ResumeAllDynamicGroups(); + + frame:SetLoadProgressVisible(false) + end + + local func1 = function() + local num = frame.loadProgressNum or 0; + frame.buttonsScroll:PauseLayout() + for index, id in pairs(loadedSorted) do + local data = WeakAuras.GetData(id); + if(data) then + EnsureDisplayButton(data); + WeakAuras.UpdateDisplayButton(data); + + local button = displayButtons[data.id] + frame.buttonsScroll:AddChild(button); + num = num + 1; + end + + if (num % 50 == 0) then + frame.buttonsScroll:ResumeLayout() + frame.buttonsScroll:PerformLayout() + frame.buttonsScroll:PauseLayout() + end + + frame.loadProgress:SetText(L["Creating buttons: "]..num.."/"..total); + frame.loadProgressNum = num; + coroutine.yield(); + end + + local co2 = coroutine.create(func2); + OptionsPrivate.Private.dynFrame:AddAction("LayoutDisplayButtons2", co2); + end + + local co1 = coroutine.create(func1); + OptionsPrivate.Private.dynFrame:AddAction("LayoutDisplayButtons1", co1); +end + function WeakAuras.ShowOptions(msg) local firstLoad = not(frame); - WeakAuras.Pause(); - WeakAuras.SetFakeStates() + OptionsPrivate.Private.Pause(); + OptionsPrivate.Private.SetFakeStates() WeakAuras.spellCache.Build() if (firstLoad) then - frame = WeakAuras.CreateFrame(); + frame = OptionsPrivate.CreateFrame(); frame.buttonsScroll.frame:Show(); - WeakAuras.LayoutDisplayButtons(msg); + LayoutDisplayButtons(msg); end frame.buttonsScroll.frame:Show(); @@ -529,23 +687,27 @@ function WeakAuras.ShowOptions(msg) frame:Show(); - if (WeakAuras.mouseFrame) then - WeakAuras.mouseFrame:OptionsOpened(); + if (OptionsPrivate.Private.mouseFrame) then + OptionsPrivate.Private.mouseFrame:OptionsOpened(); + end + + if (OptionsPrivate.Private.personalRessourceDisplayFrame) then + OptionsPrivate.Private.personalRessourceDisplayFrame:OptionsOpened(); end if not(firstLoad) then -- Show what was last shown - WeakAuras.PauseAllDynamicGroups(); + OptionsPrivate.Private.PauseAllDynamicGroups(); for id, button in pairs(displayButtons) do if (button:GetVisibility() > 0) then button:PriorityShow(button:GetVisibility()); end end - WeakAuras.ResumeAllDynamicGroups(); + OptionsPrivate.Private.ResumeAllDynamicGroups(); end if (frame.pickedDisplay) then - if (WeakAuras.IsPickedMultiple()) then + if (OptionsPrivate.IsPickedMultiple()) then local children = {} for k,v in pairs(tempGroup.controlledChildren) do children[k] = v @@ -566,166 +728,7 @@ function WeakAuras.ShowOptions(msg) frame:ShowTip() end -function WeakAuras.HideOptions() - if(frame) then - frame:Hide() - end -end - -function WeakAuras.IsOptionsOpen() - if(frame and frame:IsVisible()) then - return true; - else - return false; - end -end - -function WeakAuras.GetSortedOptionsLists() - local loadedSorted, unloadedSorted = {}, {}; - local to_sort = {}; - for id, data in pairs(db.displays) do - if(data.parent) then - -- Do nothing; children will be added later - elseif(loaded[id]) then - tinsert(to_sort, id); - end - end - table.sort(to_sort, function(a, b) return a < b end); - for _, id in ipairs(to_sort) do - tinsert(loadedSorted, id); - local data = WeakAuras.GetData(id); - local controlledChildren = data.controlledChildren; - if(controlledChildren) then - for _, childId in pairs(controlledChildren) do - tinsert(loadedSorted, childId); - end - end - end - - wipe(to_sort); - for id, data in pairs(db.displays) do - if(data.parent) then - -- Do nothing; children will be added later - elseif not(loaded[id]) then - tinsert(to_sort, id); - end - end - table.sort(to_sort, function(a, b) return a < b end); - for _, id in ipairs(to_sort) do - tinsert(unloadedSorted, id); - local data = WeakAuras.GetData(id); - local controlledChildren = data.controlledChildren; - if(controlledChildren) then - for _, childId in pairs(controlledChildren) do - tinsert(unloadedSorted, childId); - end - end - end - - return loadedSorted, unloadedSorted; -end - -function WeakAuras.LayoutDisplayButtons(msg) - local total = 0; - for _,_ in pairs(db.displays) do - total = total + 1; - end - - local loadedSorted, unloadedSorted = WeakAuras.GetSortedOptionsLists(); - - frame:SetLoadProgressVisible(true) - --frame.buttonsScroll:AddChild(frame.newButton); - --if(frame.addonsButton) then - -- frame.buttonsScroll:AddChild(frame.addonsButton); - --end - frame.buttonsScroll:AddChild(frame.loadedButton); - frame.buttonsScroll:AddChild(frame.unloadedButton); - - local func2 = function() - local num = frame.loadProgressNum or 0; - for index, id in pairs(unloadedSorted) do - local data = WeakAuras.GetData(id); - if(data) then - WeakAuras.EnsureDisplayButton(data); - WeakAuras.UpdateDisplayButton(data); - - frame.buttonsScroll:AddChild(displayButtons[data.id]); - if(WeakAuras.regions[data.id].region.SetStacks) then - WeakAuras.regions[data.id].region:SetStacks(1); - end - - if (num % 50 == 0) then - frame.buttonsScroll:ResumeLayout() - frame.buttonsScroll:PerformLayout() - frame.buttonsScroll:PauseLayout() - end - - num = num + 1; - end - frame.loadProgress:SetText(L["Creating buttons: "]..num.."/"..total); - frame.loadProgressNum = num; - coroutine.yield(); - end - - frame.buttonsScroll:ResumeLayout() - frame.buttonsScroll:PerformLayout() - WeakAuras.SortDisplayButtons(msg); - - WeakAuras.PauseAllDynamicGroups(); - if (WeakAuras.IsOptionsOpen()) then - for id, button in pairs(displayButtons) do - if(loaded[id] ~= nil) then - button:PriorityShow(1); - end - if WeakAurasCompanion and not button.data.parent then - -- initialize update icons on top level buttons - button:RefreshUpdate() - end - end - end - WeakAuras.ResumeAllDynamicGroups(); - - frame:SetLoadProgressVisible(false) - end - - local func1 = function() - local num = frame.loadProgressNum or 0; - frame.buttonsScroll:PauseLayout() - for index, id in pairs(loadedSorted) do - local data = WeakAuras.GetData(id); - if(data) then - WeakAuras.EnsureDisplayButton(data); - WeakAuras.UpdateDisplayButton(data); - - local button = displayButtons[data.id] - frame.buttonsScroll:AddChild(button); - if(WeakAuras.regions[data.id].region.SetStacks) then - WeakAuras.regions[data.id].region:SetStacks(1); - end - - num = num + 1; - end - - if (num % 50 == 0) then - frame.buttonsScroll:ResumeLayout() - frame.buttonsScroll:PerformLayout() - frame.buttonsScroll:PauseLayout() - end - - frame.loadProgress:SetText(L["Creating buttons: "]..num.."/"..total); - frame.loadProgressNum = num; - coroutine.yield(); - end - - local co2 = coroutine.create(func2); - dynFrame:AddAction("LayoutDisplayButtons2", co2); - end - - local co1 = coroutine.create(func1); - dynFrame:AddAction("LayoutDisplayButtons1", co1); -end - -function WeakAuras.UpdateOptions() +function OptionsPrivate.UpdateOptions() frame:UpdateOptions() end @@ -733,7 +736,7 @@ function WeakAuras.ClearAndUpdateOptions(id, clearChildren) frame:ClearAndUpdateOptions(id, clearChildren) end -function WeakAuras.ClearOptions(id) +function OptionsPrivate.ClearOptions(id) frame:ClearOptions(id) end @@ -741,53 +744,27 @@ function WeakAuras.FillOptions() frame:FillOptions() end -function WeakAuras.GetSubOptions(id, subOption) - return frame:GetSubOptions(id, subOption) -end - -function WeakAuras.EnsureOptions(data, subOption) +function OptionsPrivate.EnsureOptions(data, subOption) return frame:EnsureOptions(data, subOption) end -function WeakAuras.GetPickedDisplay() +function OptionsPrivate.GetPickedDisplay() return frame:GetPickedDisplay() end -function WeakAuras.GetSpellTooltipText(id) - local tooltip = WeakAuras.GetHiddenTooltip(); - tooltip:SetSpellByID(id); - local lines = { tooltip:GetRegions() }; - local i = 1; - local tooltipText = ""; - while(lines[i]) do - if(lines[i]:GetObjectType() == "FontString") then - if(lines[i]:GetText()) then - if(tooltipText == "") then - tooltipText = lines[i]:GetText(); - else - tooltipText = tooltipText.." - "..lines[i]:GetText(); - end - end - end - i = i + 1; - end - tooltipText = tooltipText or L["No tooltip text"]; - return tooltipText; -end - -function WeakAuras.OpenTextEditor(...) +function OptionsPrivate.OpenTextEditor(...) frame.texteditor:Open(...); end -function WeakAuras.ExportToString(id) +function OptionsPrivate.ExportToString(id) frame.importexport:Open("export", id); end -function WeakAuras.ExportToTable(id) +function OptionsPrivate.ExportToTable(id) frame.importexport:Open("table", id); end -function WeakAuras.ImportFromString() +function OptionsPrivate.ImportFromString() frame.importexport:Open("import"); end @@ -796,15 +773,15 @@ function WeakAuras.CloseImportExport() frame.importexport:Close(); end -function WeakAuras.ConvertDisplay(data, newType) +function OptionsPrivate.ConvertDisplay(data, newType) local id = data.id; local visibility = displayButtons[id]:GetVisibility(); displayButtons[id]:PriorityHide(0); WeakAuras.regions[id].region:Collapse(); - WeakAuras.CollapseAllClones(id); + OptionsPrivate.Private.CollapseAllClones(id); - WeakAuras.Convert(data, newType); + OptionsPrivate.Private.Convert(data, newType); displayButtons[id]:SetViewRegion(WeakAuras.regions[id].region); displayButtons[id]:Initialize(); displayButtons[id]:PriorityShow(visibility); @@ -812,14 +789,14 @@ function WeakAuras.ConvertDisplay(data, newType) frame:FillOptions(); WeakAuras.UpdateDisplayButton(data); WeakAuras.SetMoverSizer(id) - WeakAuras.ResetMoverSizer(); + OptionsPrivate.ResetMoverSizer(); WeakAuras.SortDisplayButtons() end function WeakAuras.NewDisplayButton(data) local id = data.id; - WeakAuras.ScanForLoads({[id] = true}); - WeakAuras.EnsureDisplayButton(db.displays[id]); + OptionsPrivate.Private.ScanForLoads({[id] = true}); + EnsureDisplayButton(db.displays[id]); WeakAuras.UpdateDisplayButton(db.displays[id]); frame.buttonsScroll:AddChild(displayButtons[id]); WeakAuras.SortDisplayButtons(); @@ -835,14 +812,14 @@ function WeakAuras.UpdateGroupOrders(data) end end -function WeakAuras.UpdateButtonsScroll() - if WeakAuras.IsOptionsProcessingPaused() then return end +function OptionsPrivate.UpdateButtonsScroll() + if OptionsPrivate.Private.IsOptionsProcessingPaused() then return end frame.buttonsScroll:DoLayout() end local previousFilter; function WeakAuras.SortDisplayButtons(filter, overrideReset, id) - if (WeakAuras.IsOptionsProcessingPaused()) then + if (OptionsPrivate.Private.IsOptionsProcessingPaused()) then return; end local recenter = false; @@ -891,8 +868,8 @@ function WeakAuras.SortDisplayButtons(filter, overrideReset, id) local group = child:GetGroup(); if(group) then -- In a Group - if(loaded[group]) then - if(loaded[id]) then + if(OptionsPrivate.Private.loaded[group]) then + if(OptionsPrivate.Private.loaded[id]) then child:EnableLoaded(); else child:DisableLoaded(); @@ -903,8 +880,8 @@ function WeakAuras.SortDisplayButtons(filter, overrideReset, id) end else -- Top Level - if(loaded[id] ~= nil) then - if(loaded[id]) then + if(OptionsPrivate.Private.loaded[id] ~= nil) then + if(OptionsPrivate.Private.loaded[id]) then child:EnableLoaded(); else child:DisableLoaded(); @@ -962,8 +939,8 @@ function WeakAuras.SortDisplayButtons(filter, overrideReset, id) ) then local group = child:GetGroup(); if(group) then - if not(loaded[group]) then - if(loaded[id]) then + if not(OptionsPrivate.Private.loaded[group]) then + if(OptionsPrivate.Private.loaded[id]) then child:EnableLoaded(); else child:DisableLoaded(); @@ -973,7 +950,7 @@ function WeakAuras.SortDisplayButtons(filter, overrideReset, id) tinsert(children[group], id); end else - if(loaded[id] == nil) then + if(OptionsPrivate.Private.loaded[id] == nil) then child:DisableLoaded(); visible[id] = true tinsert(to_sort, child); @@ -1022,17 +999,7 @@ function WeakAuras.SortDisplayButtons(filter, overrideReset, id) end end -WeakAuras.afterScanForLoads = function() - if(frame) then - if (frame:IsVisible()) then - WeakAuras.SortDisplayButtons(nil, true); - else - frame.needsSort = true; - end - end -end - -function WeakAuras.IsPickedMultiple() +function OptionsPrivate.IsPickedMultiple() if(frame.pickedDisplay == tempGroup) then return true; else @@ -1040,7 +1007,7 @@ function WeakAuras.IsPickedMultiple() end end -function WeakAuras.IsDisplayPicked(id) +function OptionsPrivate.IsDisplayPicked(id) if(frame.pickedDisplay == tempGroup) then for index, childId in pairs(tempGroup.controlledChildren) do if(id == childId) then @@ -1055,32 +1022,32 @@ end function WeakAuras.PickDisplay(id, tab, noHide) frame:PickDisplay(id, tab, noHide) - WeakAuras.UpdateButtonsScroll() + OptionsPrivate.UpdateButtonsScroll() end -function WeakAuras.PickAndEditDisplay(id) +function OptionsPrivate.PickAndEditDisplay(id) frame:PickDisplay(id); displayButtons[id].callbacks.OnRenameClick(); - WeakAuras.UpdateButtonsScroll() + OptionsPrivate.UpdateButtonsScroll() end -function WeakAuras.ClearPick(id) +function OptionsPrivate.ClearPick(id) frame:ClearPick(id); end -function WeakAuras.ClearPicks() +function OptionsPrivate.ClearPicks() frame:ClearPicks(); end -function WeakAuras.PickDisplayMultiple(id) +function OptionsPrivate.PickDisplayMultiple(id) frame:PickDisplayMultiple(id); end -function WeakAuras.PickDisplayMultipleShift(target) +function OptionsPrivate.PickDisplayMultipleShift(target) if (frame.pickedDisplay) then -- get first aura selected local first; - if (WeakAuras.IsPickedMultiple()) then + if (OptionsPrivate.IsPickedMultiple()) then first = tempGroup.controlledChildren[#tempGroup.controlledChildren]; else first = frame.pickedDisplay; @@ -1147,8 +1114,8 @@ function WeakAuras.GetDisplayButton(id) end end -function WeakAuras.AddDisplayButton(data) - WeakAuras.EnsureDisplayButton(data); +function OptionsPrivate.AddDisplayButton(data) + EnsureDisplayButton(data); WeakAuras.UpdateDisplayButton(data); frame.buttonsScroll:AddChild(displayButtons[data.id]); if(WeakAuras.regions[data.id] and WeakAuras.regions[data.id].region.SetStacks) then @@ -1156,21 +1123,7 @@ function WeakAuras.AddDisplayButton(data) end end -function WeakAuras.EnsureDisplayButton(data) - local id = data.id; - if not(displayButtons[id]) then - displayButtons[id] = AceGUI:Create("WeakAurasDisplayButton"); - if(displayButtons[id]) then - displayButtons[id]:SetData(data); - displayButtons[id]:Initialize(); - displayButtons[id]:UpdateWarning() - else - print("|cFF8800FFWeakAuras|r: Error creating button for", id); - end - end -end - -function WeakAuras.SetGrouping(data) +function OptionsPrivate.SetGrouping(data) if (frame.pickedDisplay == tempGroup and #tempGroup.controlledChildren > 0 and data) then local children = {}; -- set grouping for selected buttons @@ -1192,7 +1145,7 @@ function WeakAuras.SetGrouping(data) end end -function WeakAuras.Ungroup(data) +function OptionsPrivate.Ungroup(data) if (frame.pickedDisplay == tempGroup and #tempGroup.controlledChildren > 0) then for index, childId in ipairs(tempGroup.controlledChildren) do local button = WeakAuras.GetDisplayButton(childId); @@ -1205,7 +1158,7 @@ function WeakAuras.Ungroup(data) WeakAuras.FillOptions() end -function WeakAuras.SetDragging(data, drop) +function OptionsPrivate.SetDragging(data, drop) WeakAuras_DropDownMenu:Hide() if (frame.pickedDisplay == tempGroup and #tempGroup.controlledChildren > 0) then local children = {}; @@ -1230,7 +1183,7 @@ function WeakAuras.SetDragging(data, drop) end end -function WeakAuras.DropIndicator() +function OptionsPrivate.DropIndicator() local indicator = frame.dropIndicator if not indicator then indicator = CreateFrame("Frame", "WeakAuras_DropIndicator") @@ -1274,15 +1227,15 @@ function WeakAuras.UpdateThumbnail(data) button:UpdateThumbnail() end -function WeakAuras.OpenTexturePicker(data, parentData, field, textures, stopMotion) +function OptionsPrivate.OpenTexturePicker(data, parentData, field, textures, stopMotion) frame.texturePicker:Open(data, parentData, field, textures, stopMotion); end -function WeakAuras.OpenIconPicker(data, field, groupIcon) +function OptionsPrivate.OpenIconPicker(data, field, groupIcon) frame.iconPicker:Open(data, field, groupIcon); end -function WeakAuras.OpenModelPicker(data, field, parentData) +function OptionsPrivate.OpenModelPicker(data, field, parentData) if not(IsAddOnLoaded("WeakAurasModelPaths")) then local loaded, reason = LoadAddOn("WeakAurasModelPaths"); if not(loaded) then @@ -1317,7 +1270,7 @@ function WeakAuras.OpenTriggerTemplate(data, targetId) frame.newView:Open(data); end -function WeakAuras.ResetMoverSizer() +function OptionsPrivate.ResetMoverSizer() if(frame and frame.mover and frame.moversizer and frame.mover.moving.region and frame.mover.moving.data) then frame.moversizer:SetToRegion(frame.mover.moving.region, frame.mover.moving.data); end @@ -1340,63 +1293,9 @@ function WeakAuras.GetMoverSizerId() return frame.moversizer:GetCurrentId() end -function WeakAuras.ShowCloneDialog(data) - if( - not( - data.parent - and WeakAuras.GetData(data.parent) - and WeakAuras.GetData(data.parent).regionType == "dynamicgroup" - ) - and not(odb.preventCloneDialog) - ) then - StaticPopupDialogs["WEAKAURAS_CLONE_OPTION_ENABLED"] = { - text = L["Clone option enabled dialog"], - button1 = L["Yes"], - button2 = L["No"], - button3 = L["Never"], - OnAccept = function() - local parentData = { - id = WeakAuras.FindUnusedId(data.id.." Group"), - regionType = "dynamicgroup", - }; - WeakAuras.Add(parentData); - WeakAuras.NewDisplayButton(parentData); - - tinsert(parentData.controlledChildren, data.id); - data.parent = parentData.id; - WeakAuras.Add(parentData); - WeakAuras.Add(data); - - local button = WeakAuras.GetDisplayButton(data.id); - button:SetGroup(parentData.id, true); - button:SetGroupOrder(1, #parentData.controlledChildren); - - local parentButton = WeakAuras.GetDisplayButton(parentData.id); - parentButton.callbacks.UpdateExpandButton(); - WeakAuras.UpdateDisplayButton(parentData); - WeakAuras.ClearAndUpdateOptions(parentData.id); - WeakAuras.SortDisplayButtons(); - parentButton:Expand(); - end, - OnCancel = function() - -- do nothing - end, - OnAlt = function() - odb.preventCloneDialog = true - end, - hideOnEscape = true, - whileDead = true, - timeout = 0, - preferredindex = STATICPOPUP_NUMDIALOGS - }; - - StaticPopup_Show("WEAKAURAS_CLONE_OPTION_ENABLED"); - end -end - local function AddDefaultSubRegions(data) data.subRegions = data.subRegions or {} - for type, subRegionData in pairs(WeakAuras.subRegionTypes) do + for type, subRegionData in pairs(OptionsPrivate.Private.subRegionTypes) do if subRegionData.addDefaultsForNewAura then subRegionData.addDefaultsForNewAura(data) end @@ -1409,9 +1308,9 @@ function WeakAuras.NewAura(sourceData, regionType, targetId) end local new_id = WeakAuras.FindUnusedId("New") local data = {id = new_id, regionType = regionType, uid = WeakAuras.GenerateUniqueID()} - WeakAuras.DeepCopy(WeakAuras.data_stub, data); + WeakAuras.Mixin(data, WeakAuras.data_stub); if (sourceData) then - WeakAuras.DeepCopy(sourceData, data); + WeakAuras.Mixin(data, sourceData) end data.internalVersion = WeakAuras.InternalVersion(); WeakAuras.validate(data, WeakAuras.regionTypes[regionType].default); @@ -1443,17 +1342,17 @@ function WeakAuras.NewAura(sourceData, regionType, targetId) WeakAuras.Add(group.data); WeakAuras.NewDisplayButton(data); WeakAuras.UpdateGroupOrders(group.data); - WeakAuras.ClearOptions(group.data.id); + OptionsPrivate.ClearOptions(group.data.id); WeakAuras.UpdateDisplayButton(group.data); group.callbacks.UpdateExpandButton(); group:Expand(); group:ReloadTooltip(); - WeakAuras.PickAndEditDisplay(data.id); + OptionsPrivate.PickAndEditDisplay(data.id); else -- move source into the top-level list WeakAuras.Add(data); WeakAuras.NewDisplayButton(data); - WeakAuras.PickAndEditDisplay(data.id); + OptionsPrivate.PickAndEditDisplay(data.id); end else error("Calling 'WeakAuras.NewAura' with invalid groupId. Reload your UI to fix the display list.") @@ -1462,14 +1361,13 @@ function WeakAuras.NewAura(sourceData, regionType, targetId) -- move source into the top-level list WeakAuras.Add(data); WeakAuras.NewDisplayButton(data); - WeakAuras.PickAndEditDisplay(data.id); + OptionsPrivate.PickAndEditDisplay(data.id); end end local collapsedOptions = {} local collapsed = {} -- magic value -WeakAuras.collapsedOptions = collapsedOptions -function WeakAuras.ResetCollapsed(id, namespace) +function OptionsPrivate.ResetCollapsed(id, namespace) if id then if namespace and collapsedOptions[id] then collapsedOptions[id][namespace] = nil @@ -1479,7 +1377,7 @@ function WeakAuras.ResetCollapsed(id, namespace) end end -function WeakAuras.IsCollapsed(id, namespace, path, default) +function OptionsPrivate.IsCollapsed(id, namespace, path, default) local tmp = collapsedOptions[id] if tmp == nil then return default end @@ -1503,7 +1401,7 @@ function WeakAuras.IsCollapsed(id, namespace, path, default) end end -function WeakAuras.SetCollapsed(id, namespace, path, v) +function OptionsPrivate.SetCollapsed(id, namespace, path, v) collapsedOptions[id] = collapsedOptions[id] or {} collapsedOptions[id][namespace] = collapsedOptions[id][namespace] or {} if type(path) ~= "table" then @@ -1519,7 +1417,7 @@ function WeakAuras.SetCollapsed(id, namespace, path, v) end end -function WeakAuras.MoveCollapseDataUp(id, namespace, path) +function OptionsPrivate.MoveCollapseDataUp(id, namespace, path) collapsedOptions[id] = collapsedOptions[id] or {} collapsedOptions[id][namespace] = collapsedOptions[id][namespace] or {} if type(path) ~= "table" then @@ -1535,7 +1433,7 @@ function WeakAuras.MoveCollapseDataUp(id, namespace, path) end end -function WeakAuras.MoveCollapseDataDown(id, namespace, path) +function OptionsPrivate.MoveCollapseDataDown(id, namespace, path) collapsedOptions[id] = collapsedOptions[id] or {} collapsedOptions[id][namespace] = collapsedOptions[id][namespace] or {} if type(path) ~= "table" then @@ -1551,7 +1449,7 @@ function WeakAuras.MoveCollapseDataDown(id, namespace, path) end end -function WeakAuras.RemoveCollapsed(id, namespace, path) +function OptionsPrivate.RemoveCollapsed(id, namespace, path) local data = collapsedOptions[id] and collapsedOptions[id][namespace] if not data then return @@ -1580,7 +1478,7 @@ function WeakAuras.RemoveCollapsed(id, namespace, path) end end -function WeakAuras.InsertCollapsed(id, namespace, path, value) +function OptionsPrivate.InsertCollapsed(id, namespace, path, value) local data = collapsedOptions[id] and collapsedOptions[id][namespace] if not data then return @@ -1622,7 +1520,7 @@ function WeakAuras.DeleteCollapsedData(id) collapsedOptions[id] = nil end -function WeakAuras.AddTextFormatOption(input, withHeader, get, addOption, hidden, setHidden) +function OptionsPrivate.AddTextFormatOption(input, withHeader, get, addOption, hidden, setHidden) local headerOption if withHeader then headerOption = { @@ -1649,7 +1547,7 @@ function WeakAuras.AddTextFormatOption(input, withHeader, get, addOption, hidden local seenSymbols = {} - WeakAuras.ParseTextStr(input, function(symbol) + OptionsPrivate.Private.ParseTextStr(input, function(symbol) if not seenSymbols[symbol] then local triggerNum, sym = string.match(symbol, "(.+)%.(.+)") sym = sym or symbol @@ -1667,14 +1565,14 @@ function WeakAuras.AddTextFormatOption(input, withHeader, get, addOption, hidden type = "select", name = L["Format"], width = WeakAuras.normalWidth, - values = WeakAuras.format_types_display, + values = OptionsPrivate.Private.format_types_display, hidden = hidden, reloadOptions = true }) local selectedFormat = get(symbol .. "_format") - if (WeakAuras.format_types[selectedFormat]) then - WeakAuras.format_types[selectedFormat].AddOptions(symbol, hidden, addOption, get) + if (OptionsPrivate.Private.format_types[selectedFormat]) then + OptionsPrivate.Private.format_types[selectedFormat].AddOptions(symbol, hidden, addOption, get) end seenSymbols[symbol] = true end @@ -1702,11 +1600,11 @@ function WeakAuras.AddTextFormatOption(input, withHeader, get, addOption, hidden return next(seenSymbols) ~= nil end -function WeakAuras.HandleRename(data, oldid, newid) +function OptionsPrivate.HandleRename(data, oldid, newid) WeakAuras.displayButtons[newid] = WeakAuras.displayButtons[oldid]; WeakAuras.displayButtons[newid]:SetData(data) WeakAuras.displayButtons[oldid] = nil; - WeakAuras.ClearOptions(oldid) + OptionsPrivate.ClearOptions(oldid) WeakAuras.displayButtons[newid]:SetTitle(newid); @@ -1716,7 +1614,7 @@ function WeakAuras.HandleRename(data, oldid, newid) end end - WeakAuras.SetGrouping() + OptionsPrivate.SetGrouping() WeakAuras.SortDisplayButtons() WeakAuras.PickDisplay(newid) end