comparison Core.lua @ 139:c229c759a125 v65

Update to support multiple setups per spec.
author yellowfive
date Mon, 05 Nov 2018 16:06:00 -0800
parents 6dc0e8e9f960
children 55823e37403b
comparison
equal deleted inserted replaced
138:45e467335a1b 139:c229c759a125
40 40
41 -- initialize the database 41 -- initialize the database
42 local function initializeDb() 42 local function initializeDb()
43 43
44 local defaults = { 44 local defaults = {
45 char = { 45 char = {
46 LastVersion = 0, -- used to clean out old stuff
46 FirstUse = true, -- true if this is first time use, gets cleared after seeing the export help splash window 47 FirstUse = true, -- true if this is first time use, gets cleared after seeing the export help splash window
47 Talents = {}, -- for each spec, selected talents 48 Talents = {}, -- for each spec, selected talents
48 Equipped = {}, -- for each spec, slot id to item info 49 Equipped = {}, -- for each spec, slot id to item info
49 BagItems = {}, -- list of item info for bags 50 BagItems = {}, -- list of item info for bags
50 BankItems = {}, -- list of item info for bank 51 BankItems = {}, -- list of item info for bank
51 BagItemsAndCounts = {}, -- used mainly for the shopping list 52 BagItemsAndCounts = {}, -- used mainly for the shopping list
52 BankItemsAndCounts = {}, -- used mainly for the shopping list 53 BankItemsAndCounts = {}, -- used mainly for the shopping list
53 GearSets = {}, -- imported gear sets 54 GearSetups = {}, -- imported gear sets
54 ExtraEnchantData = {}, -- enchant id to enchant display information and material information 55 ExtraEnchantData = {}, -- enchant id to enchant display information and material information
55 Logging = { -- character logging settings 56 Logging = { -- character logging settings
56 Enabled = false, -- whether logging is currently on or not 57 Enabled = false, -- whether logging is currently on or not
57 LastZone = nil, -- last zone the player was in 58 LastZone = nil, -- last zone the player was in
58 LastDiff = nil, -- last difficulty for the last zone the player was in 59 LastDiff = nil, -- last difficulty for the last zone the player was in
75 Auto = {} -- for each instanceId, for each difficultyId, true if auto-logging enabled 76 Auto = {} -- for each instanceId, for each difficultyId, true if auto-logging enabled
76 } 77 }
77 }, 78 },
78 global = { 79 global = {
79 Region = nil, -- region that this user is in, all characters on the same account should be the same region 80 Region = nil, -- region that this user is in, all characters on the same account should be the same region
80 Shopping = {}, -- shopping list data stored globally for access on any character 81 Shopping2 = {}, -- shopping list data stored globally for access on any character
81 Logging = { -- a lot of log data is stored globally for simplicity, can only be raiding with one character at a time 82 Logging = { -- a lot of log data is stored globally for simplicity, can only be raiding with one character at a time
82 Wipes = {}, -- times that a wipe was called 83 Wipes = {}, -- times that a wipe was called
83 PlayerData = {}, -- player data gathered at fight start 84 PlayerData = {}, -- player data gathered at fight start
84 PlayerExtras = {} -- player extra data like auras, gathered at fight start 85 PlayerExtras = {} -- player extra data like auras, gathered at fight start
85 } 86 }
120 byDiff[difficultyId] = true 121 byDiff[difficultyId] = true
121 end 122 end
122 end 123 end
123 end 124 end
124 125
126 -- upgrade old gear set info to new format
127 if Amr.db.char.GearSets then
128 Amr.db.char.GearSets = nil
129 end
130
131 if not Amr.db.char.GearSetups then
132 Amr.db.char.GearSetups = {}
133 end
134
135 if Amr.db.global.Shopping then
136 Amr.db.global.Shopping = nil
137 end
125 138
126 Amr.db.RegisterCallback(Amr, "OnProfileChanged", "RefreshConfig") 139 Amr.db.RegisterCallback(Amr, "OnProfileChanged", "RefreshConfig")
127 Amr.db.RegisterCallback(Amr, "OnProfileCopied", "RefreshConfig") 140 Amr.db.RegisterCallback(Amr, "OnProfileCopied", "RefreshConfig")
128 Amr.db.RegisterCallback(Amr, "OnProfileReset", "RefreshConfig") 141 Amr.db.RegisterCallback(Amr, "OnProfileReset", "RefreshConfig")
129 end 142 end
135 Amr:RegisterChatCommand("amr", "SlashCommand") 148 Amr:RegisterChatCommand("amr", "SlashCommand")
136 149
137 _icon:Register(Amr.ADDON_NAME, _amrLDB, self.db.profile.minimap) 150 _icon:Register(Amr.ADDON_NAME, _amrLDB, self.db.profile.minimap)
138 151
139 -- listen for inter-addon communication 152 -- listen for inter-addon communication
140 self:RegisterComm(Amr.ChatPrefix, "OnCommReceived") 153 self:RegisterComm(Amr.ChatPrefix, "OnCommReceived")
141 end 154 end
142 155
143 local _enteredWorld = false 156 local _enteredWorld = false
144 local _pendingInit = false 157 local _pendingInit = false
158
159 -- upgrade some stuff from old to new formats
160 local function upgradeFromOld()
161
162 local currentVersion = tonumber(GetAddOnMetadata(Amr.ADDON_NAME, "Version"))
163 if Amr.db.char.LastVersion < 65 then
164 for i = 1,GetNumSpecializations() do
165 local _, specName = GetSpecializationInfo(i)
166 if specName then
167 print("AMR " .. specName)
168 local setid = C_EquipmentSet.GetEquipmentSetID("AMR " .. specName)
169 if setid then
170 C_EquipmentSet.DeleteEquipmentSet(setid)
171 end
172 end
173 end
174 end
175 Amr.db.char.LastVersion = currentVersion
176
177 end
145 178
146 local function finishInitialize() 179 local function finishInitialize()
147 180
148 -- record region, the only thing that we still can't get from the log file 181 -- record region, the only thing that we still can't get from the log file
149 Amr.db.global.Region = Amr.RegionNames[GetCurrentRegion()] 182 Amr.db.global.Region = Amr.RegionNames[GetCurrentRegion()]
153 Amr.Wait(5, function() 186 Amr.Wait(5, function()
154 Amr:InitializeVersions() 187 Amr:InitializeVersions()
155 Amr:InitializeGear() 188 Amr:InitializeGear()
156 Amr:InitializeExport() 189 Amr:InitializeExport()
157 Amr:InitializeCombatLog() 190 Amr:InitializeCombatLog()
191
192 upgradeFromOld()
158 end) 193 end)
159 end 194 end
160 195
161 local function onPlayerEnteringWorld() 196 local function onPlayerEnteringWorld()
162 197