Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Commit bdbee1e

Browse files
committed
Milestone 10 final patch
1 parent 73f2f60 commit bdbee1e

3 files changed

Lines changed: 65 additions & 26 deletions

File tree

Core/MultiBotHandler.lua

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,23 @@ MultiBot.SetSavedMainBarValue = function(key, value)
184184
return setSavedMainBarValue(key, value)
185185
end
186186

187-
local function getLayoutProfileStore()
188-
if not (MultiBot.Store and MultiBot.Store.EnsureUIChildStore) then
187+
local function getLayoutProfileStore(createIfMissing)
188+
if not MultiBot.Store then
189189
return nil
190190
end
191-
return MultiBot.Store.EnsureUIChildStore("layout")
191+
192+
if createIfMissing then
193+
if type(MultiBot.Store.EnsureUIChildStore) == "function" then
194+
return MultiBot.Store.EnsureUIChildStore("layout")
195+
end
196+
return nil
197+
end
198+
199+
if type(MultiBot.Store.GetUIChildStore) == "function" then
200+
return MultiBot.Store.GetUIChildStore("layout")
201+
end
202+
203+
return nil
192204
end
193205

194206
local function migrateLegacyLayoutStateIfNeeded(profileStore)
@@ -215,23 +227,31 @@ end
215227

216228
local function getSavedLayoutValue(key)
217229
local legacy = getLegacyStateStore(false)
218-
local profileStore = getLayoutProfileStore()
230+
local profileStore = getLayoutProfileStore(false)
219231
if profileStore then
220232
migrateLegacyLayoutStateIfNeeded(profileStore)
221233
end
222234

223235
local value = profileStore and profileStore[key] or (legacy and legacy[key])
224-
if profileStore and value == nil and MultiBot.ShouldSyncLegacyState(LAYOUT_MIGRATION_KEY, LAYOUT_MIGRATION_VERSION) then
236+
if value == nil and MultiBot.ShouldSyncLegacyState(LAYOUT_MIGRATION_KEY, LAYOUT_MIGRATION_VERSION) then
225237
value = legacy and legacy[key]
226238
if value ~= nil then
227-
profileStore[key] = value
239+
if not profileStore then
240+
profileStore = getLayoutProfileStore(true)
241+
if profileStore then
242+
migrateLegacyLayoutStateIfNeeded(profileStore)
243+
end
244+
end
245+
if profileStore then
246+
profileStore[key] = value
247+
end
228248
end
229249
end
230250
return value
231251
end
232252

233253
local function setSavedLayoutValue(key, value)
234-
local profileStore = getLayoutProfileStore()
254+
local profileStore = getLayoutProfileStore(true)
235255
if profileStore then
236256
migrateLegacyLayoutStateIfNeeded(profileStore)
237257
profileStore[key] = value

UI/MultiBotAceUI.lua

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,23 @@ function AceUI.RegisterWindowEscapeClose(window, namePrefix)
8585
table.insert(UISpecialFrames, frameName)
8686
end
8787

88-
local function getUiProfileStore()
89-
if MultiBot.Store and MultiBot.Store.EnsureUIStore then
90-
return MultiBot.Store.EnsureUIStore()
88+
local function getUiProfileStore(createIfMissing)
89+
if MultiBot.Store then
90+
if createIfMissing and type(MultiBot.Store.EnsureUIStore) == "function" then
91+
return MultiBot.Store.EnsureUIStore()
92+
end
93+
if not createIfMissing and type(MultiBot.Store.GetUIStore) == "function" then
94+
return MultiBot.Store.GetUIStore()
95+
end
9196
end
9297

9398
local profile = MultiBot.db and MultiBot.db.profile
9499
if not profile then
95100
return nil
96101
end
102+
if not createIfMissing then
103+
return type(profile.ui) == "table" and profile.ui or nil
104+
end
97105
profile.ui = profile.ui or {}
98106
return profile.ui
99107
end
@@ -103,14 +111,9 @@ function AceUI.BindWindowPosition(window, persistenceKey)
103111
return
104112
end
105113

106-
local uiStore = getUiProfileStore()
107-
if not uiStore then
108-
return
109-
end
110-
111-
uiStore.popupPositions = uiStore.popupPositions or {}
112-
local positions = uiStore.popupPositions
113-
local saved = positions[persistenceKey]
114+
local uiStore = getUiProfileStore(false)
115+
local positions = (uiStore and type(uiStore.popupPositions) == "table") and uiStore.popupPositions or nil
116+
local saved = positions and positions[persistenceKey]
114117
if saved and saved.point then
115118
window.frame:ClearAllPoints()
116119
window.frame:SetPoint(saved.point, UIParent, saved.point, saved.x or 0, saved.y or 0)
@@ -124,7 +127,12 @@ function AceUI.BindWindowPosition(window, persistenceKey)
124127
window.frame:HookScript("OnDragStop", function(frame)
125128
local point, _, _, x, y = frame:GetPoint(1)
126129
if point then
127-
positions[persistenceKey] = { point = point, x = x or 0, y = y or 0 }
130+
local writableUiStore = getUiProfileStore(true)
131+
if not writableUiStore then
132+
return
133+
end
134+
writableUiStore.popupPositions = writableUiStore.popupPositions or {}
135+
writableUiStore.popupPositions[persistenceKey] = { point = point, x = x or 0, y = y or 0 }
128136
end
129137
end)
130138
end

UI/MultiBotTalentFrame.lua

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ local function bindTalentFramePosition(window, persistenceKey)
6161
end
6262

6363
local positions = nil
64-
if MultiBot.Store and MultiBot.Store.EnsureUIChildStore then
65-
positions = MultiBot.Store.EnsureUIChildStore("popupPositions")
64+
if MultiBot.Store and MultiBot.Store.GetUIChildStore then
65+
positions = MultiBot.Store.GetUIChildStore("popupPositions")
6666
end
6767

6868
if not positions then
@@ -71,12 +71,10 @@ local function bindTalentFramePosition(window, persistenceKey)
7171
return
7272
end
7373

74-
profile.ui = profile.ui or {}
75-
profile.ui.popupPositions = profile.ui.popupPositions or {}
76-
positions = profile.ui.popupPositions
74+
positions = profile.ui and profile.ui.popupPositions
7775
end
7876

79-
local saved = positions[persistenceKey]
77+
local saved = positions and positions[persistenceKey]
8078
if saved and saved.point then
8179
window.frame:ClearAllPoints()
8280
window.frame:SetPoint(saved.point, UIParent, saved.point, saved.x or 0, saved.y or 0)
@@ -90,7 +88,20 @@ local function bindTalentFramePosition(window, persistenceKey)
9088
window.frame:HookScript("OnDragStop", function(frame)
9189
local point, _, _, x, y = frame:GetPoint(1)
9290
if point then
93-
positions[persistenceKey] = { point = point, x = x or 0, y = y or 0 }
91+
local writablePositions = nil
92+
if MultiBot.Store and MultiBot.Store.EnsureUIChildStore then
93+
writablePositions = MultiBot.Store.EnsureUIChildStore("popupPositions")
94+
else
95+
local profile = MultiBot.db and MultiBot.db.profile
96+
if profile then
97+
profile.ui = profile.ui or {}
98+
profile.ui.popupPositions = profile.ui.popupPositions or {}
99+
writablePositions = profile.ui.popupPositions
100+
end
101+
end
102+
if writablePositions then
103+
writablePositions[persistenceKey] = { point = point, x = x or 0, y = y or 0 }
104+
end
94105
end
95106
end)
96107
end

0 commit comments

Comments
 (0)