Skip to content

Commit 9e4e4e2

Browse files
committed
db init default value migration independent
1 parent b4c12ed commit 9e4e4e2

13 files changed

+57
-33
lines changed

CraftSim.toc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## Title: CraftSim
55
## Notes: Calculates the average profit based on your profession stats and other tools for dragonflight gold making
66
## Author: genju
7-
## Version: 16.1.5
7+
## Version: 16.1.6
88
## X-Curse-Project-ID: 705015
99
## X-Wago-ID: 0mNwaPKo
1010
## X-WoWI-ID: 26519

DB/ItemCountDB.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ function CraftSim.DB.ITEM_COUNT:Init()
2020
version = 0,
2121
}
2222
end
23+
24+
CraftSimDB.itemCountDB.data = CraftSimDB.itemCountDB.data or {}
2325
end
2426

2527
function CraftSim.DB.ITEM_COUNT:Migrate()
@@ -33,7 +35,7 @@ function CraftSim.DB.ITEM_COUNT:Migrate()
3335
-- 1 -> 2 (16.1.2 -> 16.1.3)
3436
if CraftSimDB.itemCountDB.version == 1 then
3537
-- remove any crafter entries with colored names...
36-
for crafterUID, _ in pairs(CraftSimDB.itemCountDB.data) do
38+
for crafterUID, _ in pairs(CraftSimDB.itemCountDB.data or {}) do
3739
if string.find(crafterUID, '\124c') then
3840
CraftSimDB.itemCountDB.data[crafterUID] = nil
3941
end

DB/craftQueueDB.lua

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ function CraftSim.DB.CRAFT_QUEUE:Init()
2020
data = {},
2121
}
2222
end
23+
24+
CraftSimDB.craftQueueDB.data = CraftSimDB.craftQueueDB.data or {}
2325
end
2426

2527
function CraftSim.DB.CRAFT_QUEUE:Migrate()

DB/crafterDB.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function CraftSim.DB.CRAFTER:Init()
3535
data = {},
3636
}
3737
end
38+
39+
CraftSimDB.crafterDB.data = CraftSimDB.crafterDB.data or {}
3840
end
3941

4042
function CraftSim.DB.CRAFTER:Migrate()
@@ -87,7 +89,7 @@ function CraftSim.DB.CRAFTER:Migrate()
8789
-- 1 -> 2 (16.1.2 -> 16.1.3)
8890
if CraftSimDB.crafterDB.version == 1 then
8991
-- remove any crafter entries with colored names...
90-
for crafterUID, _ in pairs(CraftSimDB.crafterDB.data) do
92+
for crafterUID, _ in pairs(CraftSimDB.crafterDB.data or {}) do
9193
if string.find(crafterUID, '\124c') then
9294
CraftSimDB.crafterDB.data[crafterUID] = nil
9395
end

DB/customerHistoryDB.lua

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function CraftSim.DB.CUSTOMER_HISTORY:Init()
4646
data = {},
4747
}
4848
end
49+
50+
CraftSimDB.customerHistoryDB.data = CraftSimDB.customerHistoryDB.data or {}
4951
end
5052

5153
function CraftSim.DB.CUSTOMER_HISTORY:Migrate()

DB/itemOptimizedCostsDB.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,24 @@ function CraftSim.DB.ITEM_OPTIMIZED_COSTS:Init()
3131
data = {},
3232
}
3333
end
34+
35+
CraftSimDB.itemOptimizedCostsDB.data = CraftSimDB.itemOptimizedCostsDB.data or {}
3436
end
3537

3638
function CraftSim.DB.ITEM_OPTIMIZED_COSTS:Migrate()
3739
-- 0 -> 1
3840
if CraftSimDB.itemOptimizedCostsDB.version == 0 then
3941
local CraftSimRecipeDataCache = _G["CraftSimRecipeDataCache"]
4042
if CraftSimRecipeDataCache then
41-
CraftSimDB.itemOptimizedCostsDB.data = CraftSimRecipeDataCache["itemOptimizedCostsDataCache"]
43+
CraftSimDB.itemOptimizedCostsDB.data = CraftSimRecipeDataCache["itemOptimizedCostsDataCache"] or {}
4244
end
4345
CraftSimDB.itemOptimizedCostsDB.version = 1
4446
end
4547

4648
-- 1 -> 2 (16.1.2 -> 16.1.3)
4749
if CraftSimDB.itemOptimizedCostsDB.version == 1 then
4850
-- remove any crafter entries with colored names...
49-
for _, data in pairs(CraftSimDB.itemOptimizedCostsDB.data) do
51+
for _, data in pairs(CraftSimDB.itemOptimizedCostsDB.data or {}) do
5052
for crafterUID, _ in pairs(data) do
5153
if string.find(crafterUID, '\124c') then
5254
data[crafterUID] = nil

DB/itemRecipeDB.lua

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ function CraftSim.DB.ITEM_RECIPE:Init()
2626
data = {},
2727
}
2828
end
29+
30+
CraftSimDB.itemRecipeDB.data = CraftSimDB.itemRecipeDB.data or {}
2931
end
3032

3133
function CraftSim.DB.ITEM_RECIPE:Migrate()

DB/multicraftPreloadDB.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ function CraftSim.DB.MULTICRAFT_PRELOAD:Init()
2020
data = {},
2121
}
2222
end
23+
24+
CraftSimDB.multicraftPreloadDB.data = CraftSimDB.multicraftPreloadDB.data or {}
2325
end
2426

2527
function CraftSim.DB.MULTICRAFT_PRELOAD:Migrate()
2628
-- 0 -> 1
2729
if CraftSimDB.multicraftPreloadDB.version == 0 then
2830
local CraftSimRecipeDataCache = _G["CraftSimRecipeDataCache"]
2931
if CraftSimRecipeDataCache then
30-
CraftSimDB.multicraftPreloadDB.data = CraftSimRecipeDataCache["postLoadedMulticraftInformationProfessions"]
32+
CraftSimDB.multicraftPreloadDB.data = CraftSimRecipeDataCache["postLoadedMulticraftInformationProfessions"] or
33+
{}
3134
end
3235
CraftSimDB.multicraftPreloadDB.version = 1
3336
end

DB/optionsDB.lua

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ function CraftSim.DB.OPTIONS:Init()
2020
version = 0,
2121
}
2222
end
23+
24+
CraftSimDB.optionsDB.data = CraftSimDB.optionsDB.data or {}
2325
end
2426

2527
function CraftSim.DB.OPTIONS:Migrate()

DB/priceOverrideDB.lua

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ function CraftSim.DB.PRICE_OVERRIDE:Init()
3131
},
3232
}
3333
end
34+
35+
CraftSimDB.priceOverrideDB.data = CraftSimDB.priceOverrideDB.data or {}
36+
CraftSimDB.priceOverrideDB.data.globalOverrides = CraftSimDB.priceOverrideDB.data.globalOverrides or {}
37+
CraftSimDB.priceOverrideDB.data.recipeResultOverrides = CraftSimDB.priceOverrideDB.data.recipeResultOverrides or {}
3438
end
3539

3640
function CraftSim.DB.PRICE_OVERRIDE:Migrate()

DB/recipeSubCrafterDB.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@ function CraftSim.DB.RECIPE_SUB_CRAFTER:Init()
2020
data = {},
2121
}
2222
end
23+
CraftSimDB.recipeSubCrafterDB.data = CraftSimDB.recipeSubCrafterDB.data or {}
2324
end
2425

2526
function CraftSim.DB.RECIPE_SUB_CRAFTER:Migrate()
2627
-- 0 -> 1
2728
if CraftSimDB.recipeSubCrafterDB.version == 0 then
2829
local CraftSimRecipeDataCache = _G["CraftSimRecipeDataCache"]
2930
if CraftSimRecipeDataCache then
30-
CraftSimDB.recipeSubCrafterDB.data = CraftSimRecipeDataCache["subRecipeCrafterCache"]
31+
CraftSimDB.recipeSubCrafterDB.data = CraftSimRecipeDataCache["subRecipeCrafterCache"] or {}
3132
end
3233
CraftSimDB.recipeSubCrafterDB.version = 1
3334
end
3435

3536
-- 1 -> 2 (16.1.2 -> 16.1.3)
3637
if CraftSimDB.recipeSubCrafterDB.version == 1 then
3738
-- remove any crafter entries with colored names...
38-
for itemID, crafterUID in pairs(CraftSimDB.recipeSubCrafterDB.data) do
39+
for itemID, crafterUID in pairs(CraftSimDB.recipeSubCrafterDB.data or {}) do
3940
if string.find(crafterUID, '\124c') then
4041
CraftSimDB.recipeSubCrafterDB.data[itemID] = nil
4142
end

Data/News.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ function CraftSim.NEWS:GET_NEWS(itemMap)
1515
local news = {
1616
f.bb(" Hello and thank you for using CraftSim!\n"),
1717
f.bb(" ( You are awesome! )"),
18-
newP("16.1.5"),
18+
newP("16.1.6"),
1919
f.P .. "A lot of internal code optimizations to",
2020
f.a .. "prepare for TWW testing/updates",
2121
f.s .. "Added a command to reset craftsim's database",
2222
f.a .. "'/craftsim resetdb'",
2323
f.p .. "Fixed Simulation Mode Module Window opacity",
24-
f.p .. "DB Migration fixes",
24+
f.p .. "DB Migration fixes",
2525
f.p .. "Fixed errors with npc professions",
2626
f.p .. "Contribution thanks:",
2727
f.a .. "- " .. f.bb("https://github.com/rowaasr13"),
@@ -127,4 +127,4 @@ function CraftSim.NEWS:ShowNews(force)
127127
infoFrame.originalY = CraftSim.CONST.infoBoxSizeY
128128
infoFrame.showInfo(newsText)
129129
end)
130-
end
130+
end

Util/Frames.lua

+24-22
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local CraftSimAddonName = select(1, ...)
55
---@class CraftSim.FRAME
66
CraftSim.FRAME = {}
77

8+
local GGUI = CraftSim.GGUI
89
local GUTIL = CraftSim.GUTIL
910

1011
CraftSim.FRAME.frames = {}
@@ -56,30 +57,30 @@ function CraftSim.FRAME:InitTabSystem(tabs)
5657
end
5758

5859
function CraftSim.FRAME:RestoreModulePositions()
59-
local controlPanel = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CONTROL_PANEL)
60-
local recipeScanFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.RECIPE_SCAN)
61-
local craftResultsFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CRAFT_RESULTS)
62-
local customerServiceFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CUSTOMER_SERVICE)
63-
local customerHistoryFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CUSTOMER_HISTORY)
64-
local priceOverrideFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.PRICE_OVERRIDE)
65-
local priceOverrideFrameWO = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES,
60+
local controlPanel = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CONTROL_PANEL)
61+
local recipeScanFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.RECIPE_SCAN)
62+
local craftResultsFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CRAFT_RESULTS)
63+
local customerServiceFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CUSTOMER_SERVICE)
64+
local customerHistoryFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.CUSTOMER_HISTORY)
65+
local priceOverrideFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.PRICE_OVERRIDE)
66+
local priceOverrideFrameWO = GGUI:GetFrame(CraftSim.INIT.FRAMES,
6667
CraftSim.CONST.FRAMES.PRICE_OVERRIDE_WORK_ORDER)
67-
local specInfoFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.SPEC_INFO)
68-
local specInfoFrameWO = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.SPEC_INFO_WO)
69-
local averageProfitFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.AVERAGE_PROFIT)
70-
local averageProfitFrameWO = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES,
68+
local specInfoFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.SPEC_INFO)
69+
local specInfoFrameWO = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.SPEC_INFO_WO)
70+
local averageProfitFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.AVERAGE_PROFIT)
71+
local averageProfitFrameWO = GGUI:GetFrame(CraftSim.INIT.FRAMES,
7172
CraftSim.CONST.FRAMES.AVERAGE_PROFIT_WO)
72-
local topgearFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.TOP_GEAR)
73-
local topgearFrameWO = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.TOP_GEAR_WORK_ORDER)
74-
local materialOptimizationFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES,
73+
local topgearFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.TOP_GEAR)
74+
local topgearFrameWO = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.TOP_GEAR_WORK_ORDER)
75+
local materialOptimizationFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES,
7576
CraftSim.CONST.FRAMES.REAGENT_OPTIMIZATION)
76-
local materialOptimizationFrameWO = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES,
77+
local materialOptimizationFrameWO = GGUI:GetFrame(CraftSim.INIT.FRAMES,
7778
CraftSim.CONST.FRAMES.REAGENT_OPTIMIZATION_WORK_ORDER)
78-
local debugFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.DEBUG)
79-
local infoFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.INFO)
80-
local livePreviewFrame = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.LIVE_PREVIEW)
81-
local specsim = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.SPEC_SIM)
82-
local specsimWO = CraftSim.GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.SPEC_INFO_WO)
79+
local debugFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.DEBUG)
80+
local infoFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.INFO)
81+
local livePreviewFrame = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.LIVE_PREVIEW)
82+
local specsim = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.SPEC_SIM)
83+
local specsimWO = GGUI:GetFrame(CraftSim.INIT.FRAMES, CraftSim.CONST.FRAMES.SPEC_INFO_WO)
8384

8485
specsim:RestoreSavedConfig(UIParent)
8586
specsimWO:RestoreSavedConfig(UIParent)
@@ -262,7 +263,7 @@ function CraftSim.FRAME:InitOneTimeNoteFrame()
262263

263264
local f = GUTIL:GetFormatter()
264265

265-
local frame = CraftSim.GGUI.Frame({
266+
local frame = GGUI.Frame({
266267
parent = UIParent,
267268
anchorParent = UIParent,
268269
sizeX = 500,
@@ -276,6 +277,7 @@ function CraftSim.FRAME:InitOneTimeNoteFrame()
276277
backdropOptions = CraftSim.CONST.DEFAULT_BACKDROP_OPTIONS,
277278
frameTable = CraftSim.INIT.FRAMES,
278279
frameConfigTable = CraftSimGGUIConfig,
280+
frameStrata = "FULLSCREEN",
279281
})
280282

281283
frame.content.discordBox = CraftSim.FRAME:CreateInput(
@@ -307,7 +309,7 @@ function CraftSim.FRAME:InitOneTimeNoteFrame()
307309
frame:Show()
308310
end
309311

310-
CraftSim.GGUI:EnableHyperLinksForFrameAndChilds(frame.content)
312+
GGUI:EnableHyperLinksForFrameAndChilds(frame.content)
311313
frame:Hide()
312314
end
313315

0 commit comments

Comments
 (0)