-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDB.lua
More file actions
executable file
·136 lines (107 loc) · 3.73 KB
/
DB.lua
File metadata and controls
executable file
·136 lines (107 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
-- DB
-- access to Bliz's persisted data facility
-------------------------------------------------------------------------------
-- Module Loading
--
-- Bliz's SavedVariables don't like my Wormhole magic, so, I've isolated them here
-- there is no call to Wormhole() so we're in the global namespace, NOT in the Ufo !
-------------------------------------------------------------------------------
---@class DB
local DB = {}
---@type Ufo
local ADDON_NAME, Ufo = ...
Ufo.DB = DB
local L10N = Ufo.L10N
---@alias SpecId number
---@alias FlyoutId string
---@alias Placements table<BtnSlotIndex,FlyoutId>
---@alias PlacementsForAllSpecs table<SpecId,Placements>
-------------------------------------------------------------------------------
-- Flyouts
-------------------------------------------------------------------------------
function DB:initializeFlyouts()
if not UFO_SV_ACCOUNT then
UFO_SV_ACCOUNT = { flyouts={}, n=0, orderedFlyoutIds={} }
end
end
-- the set of flyouts is shared between all toons on the account
function DB:getFlyoutDefs()
return UFO_SV_ACCOUNT.flyouts
end
function DB:getOrderedFlyoutIds()
return UFO_SV_ACCOUNT.orderedFlyoutIds
end
function DB:nextN()
UFO_SV_ACCOUNT.n = (UFO_SV_ACCOUNT.n or 0) + 1
return UFO_SV_ACCOUNT.n
end
-------------------------------------------------------------------------------
-- Placements
-------------------------------------------------------------------------------
function DB:initializePlacements()
if not UFO_SV_TOON then
UFO_SV_TOON = { placementsForAllSpecs = {} }
end
end
-- the placement of flyouts on the action bars is stored separately for each toon
---@return PlacementsForAllSpecs
function DB:getAllSpecsPlacementsConfig()
---@type PlacementsForAllSpecs
return UFO_SV_TOON.placementsForAllSpecs
end
function DB:snapshotSave()
local placements = Ufo.Spec:getCurrentSpecPlacementConfig()
if Ufo.isEmpty(placements) then
Ufo.zebug.error:print("Current config is empty. ABORT snapshot")
return
end
UFO_SV_ACCOUNT.placementsDefaultSnapshot = placements
Ufo.msgUser(Ufo.L10N.SAVED_SNAPSHOT)
end
function DB:snapshotLoad()
local placements = UFO_SV_ACCOUNT.placementsDefaultSnapshot
if Ufo.isEmpty(placements) then
Ufo.zebug.error:print("Snapshot is empty. ABORT load snapshot")
return
end
Ufo.Spec:replaceCurrentSpecPlacementConfig(placements)
Ufo.GermCommander:initializeAllSlots("Load_Snapshot")
Ufo.msgUser(Ufo.L10N.LOADED_SNAPSHOT)
end
function DB:isThereUhSnapshot()
local placements = UFO_SV_ACCOUNT.placementsDefaultSnapshot
return not Ufo.isEmpty(placements)
end
function DB:isNoSnapshot()
return not DB:isThereUhSnapshot()
end
function DB:canHazPet(arg)
local specId = GetSpecialization()
if UFO_SV_TOON.canHazPet == nil then
UFO_SV_TOON.canHazPet = {}
end
if arg ~= nil then
UFO_SV_TOON.canHazPet[specId] = arg and true or false
end
return UFO_SV_TOON.canHazPet[specId] or false
end
-------------------------------------------------------------------------------
-- Config Opts
-------------------------------------------------------------------------------
function DB:initializeOptsMemory()
if not UFO_SV_ACCOUNT.opts then
UFO_SV_ACCOUNT.opts = Ufo.Config:getOptionDefaults()
end
---@type Config
local Config = Ufo.Config
Config.opts = UFO_SV_ACCOUNT.opts
Config.optDefaults = Config:getOptionDefaults()
-- new opt introduced by UFO v10.1.7.a
if not Config.opts.clickers then
Config.opts.clickers = Config.optDefaults.clickers
end
-- new opt introduced by UFO 11.2.0
if not Config.opts.bonusModifierKeys then
Config.opts.bonusModifierKeys = {}
end
end