Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion WagoUI/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ end

function init()
addon:RegisterErrorHandledFunctions()
addon:SetupWagoData()
if addon.SetupWagoData then
addon:SetupWagoData()
end
addon:CreateCopyHelper()
local mainFrame = addon:CreateMainFrame()
addon:CreateIntroFrame(mainFrame)
Expand Down
14 changes: 9 additions & 5 deletions WagoUI/modules/wagoData.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---@class WagoUI
local addon = select(2, ...)
local LAP = LibStub:GetLibrary("LibAddonProfiles")
local LAP = LibStub and LibStub:GetLibrary("LibAddonProfiles", true)
local db

--- We want to get the latest imported profile for a character and module.
Expand Down Expand Up @@ -75,7 +75,7 @@ function addon:SetupWagoData()
if type(moduleData) == "string" then
newIntroImportState[resolution][moduleName] = {}
local profileData = source.profiles[resolution][moduleName]
local lap = LAP:GetModule(moduleName)
local lap = LAP and LAP:GetModule(moduleName)
if profileData and lap then
if lap:needsInitialization() then
lap:openConfig()
Expand Down Expand Up @@ -119,7 +119,7 @@ function addon:SetupWagoData()
elseif moduleName == "WeakAuras" or moduleName == "Echo Raid Tools" then
for groupId in pairs(moduleData) do
local profile = source.profiles[resolution][moduleName] and source.profiles[resolution][moduleName][groupId]
local lap = LAP:GetModule(moduleName)
local lap = LAP and LAP:GetModule(moduleName)
if profile and lap then
tinsert(
addon.wagoData[resolution],
Expand Down Expand Up @@ -165,7 +165,9 @@ function addon:SetActivePack(packId)
db.selectedWagoData = packId
addon:RefreshResolutionDropdown()
addon:SetUIPackDropdownToPack(packId)
addon:SetupWagoData()
if addon.SetupWagoData then
addon:SetupWagoData()
end
addon:UpdateRegisteredDataConsumers()
end

Expand Down Expand Up @@ -195,7 +197,9 @@ function addon:GetResolutionsForDropdown()
label = addon:GetResolutionString(key, "displayNameShort"),
onclick = function()
db.selectedWagoDataResolution = key
addon:SetupWagoData()
if addon.SetupWagoData then
addon:SetupWagoData()
end
addon:UpdateRegisteredDataConsumers()
end
}
Expand Down
16 changes: 10 additions & 6 deletions WagoUI/wagoFrames/altFrame/altFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local addon = select(2, ...)
local DF = _G["DetailsFramework"]
local LWF = LibStub("LibWagoFramework")
local L = addon.L
local LAP = LibStub:GetLibrary("LibAddonProfiles")
local LAP = LibStub and LibStub:GetLibrary("LibAddonProfiles", true)

---@type string | nil
local currentSelectedCharacter = nil
Expand All @@ -24,7 +24,8 @@ local function setAllProfilesAsync()
-- Keys that need to be retrieved from WagoUI db need to also be stored in WagoUI db again
-- This is needed when the user "chains" characters
addon:GetImportedProfilesTarget()
for _, lapModule in pairs(LAP:GetAllModules()) do
if LAP then
for _, lapModule in pairs(LAP:GetAllModules()) do
if lapModule:isLoaded() and lapModule:isUpdated() then
local profileAssignments = lapModule.getProfileAssignments and lapModule:getProfileAssignments()
if profileAssignments then
Expand All @@ -44,7 +45,7 @@ local function setAllProfilesAsync()
addon:StoreImportedProfileData(updatedAt, lapModule.moduleName, profileKey)
end
end
elseif LAP:CanEnableAnyAddOn(lapModule.addonNames) then
elseif LAP and LAP:CanEnableAnyAddOn(lapModule.addonNames) then
-- check if we have imported via WagoUI on that character and the module is not loaded
-- we need to load the addon, reload UI and continue setting the profile
local profileKey, updatedAt = addon:GetLatestImportedProfile(currentSelectedCharacter, lapModule.moduleName)
Expand All @@ -55,6 +56,7 @@ local function setAllProfilesAsync()
end
coroutine.yield()
end
end
end

function addon:ContinueSetAllProfiles()
Expand All @@ -69,7 +71,7 @@ function addon:ContinueSetAllProfiles()
function()
for _, data in ipairs(addon.dbC.needLoad) do
---@type LibAddonProfilesModule
local lap = LAP:GetModule(data.moduleName)
local lap = LAP and LAP:GetModule(data.moduleName)
local profileKeys = lap.getProfileKeys and lap:getProfileKeys()
if profileKeys and data.profileKey and profileKeys[data.profileKey] then
lap:setProfile(data.profileKey)
Expand Down Expand Up @@ -179,8 +181,10 @@ function addon:CreateAltFrame(f)
if #needLoad > 0 then
addon.dbC.needLoad = needLoad
for _, data in ipairs(needLoad) do
local lap = LAP:GetModule(data.moduleName)
LAP:EnableAddOns(lap.addonNames)
local lap = LAP and LAP:GetModule(data.moduleName)
if lap and LAP then
LAP:EnableAddOns(lap.addonNames)
end
end
header:SetText(L["altFrameHeader4"])
else
Expand Down
2 changes: 1 addition & 1 deletion WagoUI/wagoFrames/components/profileList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local DF = _G["DetailsFramework"]
local options_dropdown_template = DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
local db
local L = addon.L
local LAP = LibStub:GetLibrary("LibAddonProfiles")
local LAP = LibStub and LibStub:GetLibrary("LibAddonProfiles", true)

local widths = {
options = 60,
Expand Down
4 changes: 3 additions & 1 deletion WagoUI/wagoFrames/introFrame/directProfilesPage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ local function createPage()
for _, data in pairs(addon.db.introImportState[res]) do
data.checked = value
end
addon:SetupWagoData()
if addon.SetupWagoData then
addon:SetupWagoData()
end
addon:UpdateRegisteredDataConsumers()
end,
checkboxDefaultValue
Expand Down