Skip to content

Commit 4b1d7eb

Browse files
committed
Shared/Character
* Updated how we save per character / shared
1 parent 425a8a3 commit 4b1d7eb

6 files changed

Lines changed: 65 additions & 37 deletions

File tree

Core.lua

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,22 @@ function MR:SetWindowLayoutValue(key, value)
11521152
end
11531153
end
11541154

1155+
function MR:GetManagedWindowOpen(key)
1156+
if not key then
1157+
return false
1158+
end
1159+
1160+
return self:GetWindowLayoutValue(key) == true
1161+
end
1162+
1163+
function MR:SetManagedWindowOpen(key, value)
1164+
if not key then
1165+
return
1166+
end
1167+
1168+
self:SetWindowLayoutValue(key, value and true or false)
1169+
end
1170+
11551171
function MR:GetHeaderColor(modKey)
11561172
if self.db.profile.headerColors and self.db.profile.headerColors[modKey] then
11571173
return self.db.profile.headerColors[modKey]
@@ -1897,9 +1913,9 @@ function MR:PersistManagedWindowState(state)
18971913
if not self.db or not state then return end
18981914

18991915
self.db.char.panelOpen = state.panel and true or false
1900-
self.db.profile.renownOpen = state.renown and true or false
1901-
self.db.profile.raresOpen = state.rares and true or false
1902-
self.db.profile.gatheringLocOpen = state.gathering and true or false
1916+
self:SetManagedWindowOpen("renownOpen", state.renown)
1917+
self:SetManagedWindowOpen("raresOpen", state.rares)
1918+
self:SetManagedWindowOpen("gatheringLocOpen", state.gathering)
19031919
end
19041920

19051921
function MR:SetManagedWindowRestoreState(state)
@@ -2105,7 +2121,7 @@ function MR:OnEnteringWorld()
21052121

21062122
if not self.db.profile.firstSeen then
21072123
self.db.char.panelOpen = false
2108-
self.db.profile.renownOpen = false
2124+
self:SetManagedWindowOpen("renownOpen", false)
21092125
end
21102126

21112127
if not self.frame then
@@ -2132,13 +2148,13 @@ function MR:OnEnteringWorld()
21322148
}, 1, "OnRenownUpdate")
21332149
end
21342150
if not shouldHideFrames and not temporarilyHidden then
2135-
if self.db.profile.renownOpen and self.EnsureRenownShown then
2151+
if self:GetManagedWindowOpen("renownOpen") and self.EnsureRenownShown then
21362152
self:EnsureRenownShown()
21372153
end
2138-
if self.db.profile.raresOpen and self.EnsureRaresShown then
2154+
if self:GetManagedWindowOpen("raresOpen") and self.EnsureRaresShown then
21392155
self:EnsureRaresShown()
21402156
end
2141-
if self.db.profile.gatheringLocOpen and self.EnsureGatheringLocationsShown then
2157+
if self:GetManagedWindowOpen("gatheringLocOpen") and self.EnsureGatheringLocationsShown then
21422158
self:EnsureGatheringLocationsShown()
21432159
end
21442160
end

Modules/ProfessionKnowledge.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ local function BuildGatheringLocationsFrame(isRetry)
466466

467467
local closeBtn = CloseButton(titleBar, function()
468468
frame:Hide()
469-
if MR.db then MR.db.profile.gatheringLocOpen = false end
469+
if MR.SetManagedWindowOpen then MR:SetManagedWindowOpen("gatheringLocOpen", false) end
470470
end)
471471

472472
local gearBtn = HeaderIconButton(
@@ -1058,21 +1058,21 @@ end
10581058
local function ToggleGatheringLocations()
10591059
if not gatheringLocationsFrame then
10601060
gatheringLocationsFrame = BuildGatheringLocationsFrame()
1061-
if MR.db then MR.db.profile.gatheringLocOpen = true end
1061+
if MR.SetManagedWindowOpen then MR:SetManagedWindowOpen("gatheringLocOpen", true) end
10621062
elseif gatheringLocationsFrame:IsShown() then
10631063
gatheringLocationsFrame:Hide()
1064-
if MR.db then MR.db.profile.gatheringLocOpen = false end
1064+
if MR.SetManagedWindowOpen then MR:SetManagedWindowOpen("gatheringLocOpen", false) end
10651065
else
10661066
gatheringLocationsFrame:Show()
1067-
if MR.db then MR.db.profile.gatheringLocOpen = true end
1067+
if MR.SetManagedWindowOpen then MR:SetManagedWindowOpen("gatheringLocOpen", true) end
10681068
end
10691069
end
10701070

10711071
MR.ToggleGatheringLocations = ToggleGatheringLocations
10721072

10731073
function MR:ShowGatheringLocations()
10741074
if not gatheringLocationsFrame then gatheringLocationsFrame = BuildGatheringLocationsFrame() else gatheringLocationsFrame:Show() end
1075-
if self.db then self.db.profile.gatheringLocOpen = true end
1075+
if self.SetManagedWindowOpen then self:SetManagedWindowOpen("gatheringLocOpen", true) end
10761076
end
10771077

10781078
function MR:EnsureGatheringLocationsShown()
@@ -1090,7 +1090,7 @@ end
10901090
function MR:HideGatheringLocations(persistState)
10911091
if gatheringLocationsFrame then gatheringLocationsFrame:Hide() end
10921092
if gatheringCfgFrame then gatheringCfgFrame:Hide() end
1093-
if persistState ~= false and self.db then self.db.profile.gatheringLocOpen = false end
1093+
if persistState ~= false and self.db then self:SetManagedWindowOpen("gatheringLocOpen", false) end
10941094
end
10951095

10961096
function MR:RepopulateGatheringConfig()
@@ -1107,7 +1107,7 @@ eventFrame:SetScript("OnEvent", function(_, event, addonName)
11071107
if event == "ADDON_LOADED" and addonName == "MidnightRoutine" then
11081108
if MR.db then
11091109
gatheringMinimized = MR.db.profile.gatheringMinimized or false
1110-
if MR.db.profile.gatheringLocOpen then MR:ShowGatheringLocations() end
1110+
if MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("gatheringLocOpen") then MR:ShowGatheringLocations() end
11111111
end
11121112
eventFrame:UnregisterEvent("ADDON_LOADED")
11131113
end

Modules/Rares.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ BuildRaresFrame = function()
346346
local closeBtn = CloseButton(titleBar, function()
347347
f:Hide()
348348
if raresCfgFrame then raresCfgFrame:Hide() end
349-
if MR.db then MR.db.profile.raresOpen = false end
349+
if MR.SetManagedWindowOpen then MR:SetManagedWindowOpen("raresOpen", false) end
350350
end)
351351

352352
local gearBtn = HeaderIconButton(
@@ -1197,7 +1197,7 @@ function MR:ToggleRares()
11971197
else
11981198
raresFrame:Show()
11991199
MR.raresFrame = raresFrame
1200-
if self.db then self.db.profile.raresOpen = true end
1200+
if self.SetManagedWindowOpen then self:SetManagedWindowOpen("raresOpen", true) end
12011201
raresFrame:SetScale((MR.db and MR.db.profile.raresScale) or 1.0)
12021202
lastZoneKey = GetCurrentZoneKey()
12031203
self:SyncAllRareKills()
@@ -1209,7 +1209,7 @@ function MR:HideRares(persistState)
12091209
if raresFrame then raresFrame:Hide() end
12101210
if raresCfgFrame then raresCfgFrame:Hide() end
12111211
if persistState ~= false and self.db then
1212-
self.db.profile.raresOpen = false
1212+
self:SetManagedWindowOpen("raresOpen", false)
12131213
end
12141214
end
12151215

@@ -1230,7 +1230,7 @@ function MR:EnsureRaresShown()
12301230
lastZoneKey = GetCurrentZoneKey()
12311231
self:SyncAllRareKills()
12321232
RefreshRaresFrame()
1233-
if self.db then self.db.profile.raresOpen = true end
1233+
if self.SetManagedWindowOpen then self:SetManagedWindowOpen("raresOpen", true) end
12341234
end
12351235
end
12361236

Modules/Renown.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ local function BuildRenownFrame()
287287
local closeBtn = CloseButton(titleBar, function()
288288
f:Hide()
289289
if renownCfgFrame then renownCfgFrame:Hide() end
290-
if MR.db then MR.db.profile.renownOpen = false end
290+
if MR.SetManagedWindowOpen then MR:SetManagedWindowOpen("renownOpen", false) end
291291
end)
292292

293293
local gearBtn = HeaderIconButton(
@@ -1112,7 +1112,7 @@ function MR:ToggleRenown()
11121112
else
11131113
renownFrame:Show()
11141114
MR.renownFrame = renownFrame
1115-
if self.db then self.db.profile.renownOpen = true end
1115+
if self.SetManagedWindowOpen then self:SetManagedWindowOpen("renownOpen", true) end
11161116
RefreshRenownFrame()
11171117
end
11181118
end
@@ -1121,7 +1121,7 @@ function MR:HideRenown(persistState)
11211121
if renownFrame then renownFrame:Hide() end
11221122
if renownCfgFrame then renownCfgFrame:Hide() end
11231123
if persistState ~= false and self.db then
1124-
self.db.profile.renownOpen = false
1124+
self:SetManagedWindowOpen("renownOpen", false)
11251125
end
11261126
end
11271127

@@ -1132,7 +1132,7 @@ function MR:EnsureRenownShown()
11321132
if not renownFrame:IsShown() then
11331133
renownFrame:Show()
11341134
MR.renownFrame = renownFrame
1135-
if self.db then self.db.profile.renownOpen = true end
1135+
if self.SetManagedWindowOpen then self:SetManagedWindowOpen("renownOpen", true) end
11361136
end
11371137
RefreshRenownFrame()
11381138
end

UI.lua

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3598,23 +3598,29 @@ function MR:PopulateConfigFrame(f)
35983598
end, "#2ae7c6")
35993599

36003600
Checkbox(L["Config_OpenRenown"],
3601-
function() return MR.db and MR.db.profile.renownOpen end,
3601+
function() return MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("renownOpen") end,
36023602
function(v)
3603-
MR.db.profile.renownOpen = v
3603+
if MR.SetManagedWindowOpen then
3604+
MR:SetManagedWindowOpen("renownOpen", v)
3605+
end
36043606
if MR.ToggleRenown then MR:ToggleRenown() end
36053607
end, "#d9b82e")
36063608

36073609
Checkbox(L["Config_OpenRares"],
3608-
function() return MR.db and MR.db.profile.raresOpen end,
3610+
function() return MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("raresOpen") end,
36093611
function(v)
3610-
MR.db.profile.raresOpen = v
3612+
if MR.SetManagedWindowOpen then
3613+
MR:SetManagedWindowOpen("raresOpen", v)
3614+
end
36113615
if MR.ToggleRares then MR:ToggleRares() end
36123616
end, "#e05050")
36133617

36143618
Checkbox(L["Profession_Knowledge"],
3615-
function() return MR.db and MR.db.profile.gatheringLocOpen end,
3619+
function() return MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("gatheringLocOpen") end,
36163620
function(v)
3617-
MR.db.profile.gatheringLocOpen = v
3621+
if MR.SetManagedWindowOpen then
3622+
MR:SetManagedWindowOpen("gatheringLocOpen", v)
3623+
end
36183624
if MR.ToggleGatheringLocations then MR:ToggleGatheringLocations() end
36193625
end, "#c9853f")
36203626

WelcomeScreen.lua

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ local function BuildWelcomeScreen()
3535
pendingEnabled[mod.key] = MR:IsModuleEnabled(mod.key)
3636
end
3737

38-
pendingRenown = MR.db and MR.db.profile.renownOpen or false
39-
pendingRares = MR.db and MR.db.profile.raresOpen or false
40-
pendingGathering = MR.db and MR.db.profile.gatheringLocOpen or false
38+
pendingRenown = MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("renownOpen") or false
39+
pendingRares = MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("raresOpen") or false
40+
pendingGathering = MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("gatheringLocOpen") or false
4141

4242
local f = StyledFrame(UIParent, nil, "FULLSCREEN_DIALOG", 200)
4343
f:SetSize(310, 10)
@@ -335,28 +335,34 @@ local function BuildWelcomeScreen()
335335
return
336336
end
337337

338-
local prevRenown = MR.db.profile.renownOpen
339-
local prevRares = MR.db.profile.raresOpen
340-
local prevGathering = MR.db.profile.gatheringLocOpen
338+
local prevRenown = MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("renownOpen") or false
339+
local prevRares = MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("raresOpen") or false
340+
local prevGathering = MR.GetManagedWindowOpen and MR:GetManagedWindowOpen("gatheringLocOpen") or false
341341

342342
if pendingRenown ~= prevRenown then
343-
MR.db.profile.renownOpen = pendingRenown
343+
if MR.SetManagedWindowOpen then
344+
MR:SetManagedWindowOpen("renownOpen", pendingRenown)
345+
end
344346
if pendingRenown and MR.ToggleRenown then
345347
MR:ToggleRenown()
346348
elseif not pendingRenown and MR.HideRenown then
347349
MR:HideRenown(false)
348350
end
349351
end
350352
if pendingRares ~= prevRares then
351-
MR.db.profile.raresOpen = pendingRares
353+
if MR.SetManagedWindowOpen then
354+
MR:SetManagedWindowOpen("raresOpen", pendingRares)
355+
end
352356
if pendingRares and MR.ToggleRares then
353357
MR:ToggleRares()
354358
elseif not pendingRares and MR.HideRares then
355359
MR:HideRares(false)
356360
end
357361
end
358362
if pendingGathering ~= prevGathering then
359-
MR.db.profile.gatheringLocOpen = pendingGathering
363+
if MR.SetManagedWindowOpen then
364+
MR:SetManagedWindowOpen("gatheringLocOpen", pendingGathering)
365+
end
360366
if pendingGathering and MR.ToggleGatheringLocations then
361367
MR:ToggleGatheringLocations()
362368
elseif not pendingGathering and MR.HideGatheringLocations then

0 commit comments

Comments
 (0)