- Repentance, Freezing Trap & Wyvern Sting are now disorients

- import string now ignores errors on deleted options
This commit is contained in:
Sumsebrum 2021-09-14 23:52:13 +02:00
parent b651eb39ce
commit d2884e777a
2 changed files with 74 additions and 25 deletions

View File

@ -193,10 +193,10 @@ Data.spells = {
[18658] = "sleep",
-- Wyvern Sting
[19386] = "sleep",
[24132] = "sleep",
[24133] = "sleep",
[27068] = "sleep",
[19386] = "disorient",
[24132] = "disorient",
[24133] = "disorient",
[27068] = "disorient",
--[[ MISC ]]--
-- Chastise (Maybe this shares DR with Imp HS?)
@ -213,15 +213,15 @@ Data.spells = {
[33042] = "dragonsbreath", -- Dragon's Breath
[33043] = "dragonsbreath", -- Dragon's Breath
-- Repentance
[20066] = "repentance",
[20066] = "disorient",
-- Scatter Shot
[19503] = "scatters",
-- Freezing Trap
[3355] = "freezetrap",
[14308] = "freezetrap",
[14309] = "freezetrap",
[3355] = "disorient",
[14308] = "disorient",
[14309] = "disorient",
-- Improved Conc Shot
[19410] = "impconc",

View File

@ -1,4 +1,4 @@
local type, pairs = type, pairs
local type, pairs, str_match = type, pairs, string.match
local Gladdy = LibStub("Gladdy")
local AceSerializer = LibStub("AceSerializer-3.0")
@ -6,12 +6,23 @@ local L = Gladdy.L
local AceGUI = LibStub("AceGUI-3.0")
local LibDeflate = LibStub:GetLibrary("LibDeflate")
local function table_copy(t)
local function table_copy(t, str)
local t2 = {};
if str == nil then
str = "Gladdy.db"
end
for k,v in pairs(t) do
if type(v) == "table" then
t2[k] = table_copy(v);
if k == "drCategories" then
for key,val in pairs(v) do
--Gladdy:Print("TableCopy", str .. "." .. key)
end
end
t2[k] = table_copy(v, str .. "." .. k);
else
t2[k] = v;
end
end
@ -84,9 +95,27 @@ import:AddChild(importClearButton)
import.clearButton = importClearButton
local deletedOptions = { --TODO backward compatibility Imports on deleted options
growUp = true
growUp = true,
freezetrap = true,
repentance = true
}
local function checkIsDeletedOption(k, str, msg, errorFound, errorMsg)
local isDeleted
for key, _ in pairs(deletedOptions) do
if str_match(k, key) then
isDeleted = true
Gladdy:Warn("found deleted option =", str .. "." .. k)
end
end
if errorFound then
return errorFound, errorMsg
end
if not isDeleted then
return true, msg or str .. "." .. k .. " does not exist"
end
end
function ExportImport:CheckDeserializedOptions(tbl, refTbl, str)
if str == nil and not tbl.version_major_num then
return false, "Version conflict: version_major_num not seen"
@ -98,17 +127,29 @@ function ExportImport:CheckDeserializedOptions(tbl, refTbl, str)
str = "Gladdy.db"
tbl.version_major_num = nil
end
local res, msg
local errorFound, errorMsg
if refTbl == nil then
return false, str .. "does not exist"
else
for k,v in pairs(tbl) do
if refTbl[k] == nil then
--return false, str .. "." .. k .. " does not exist"
else
if type(v) ~= type(refTbl[k]) then
return false, str .. "." .. k .. " type error. Expected " .. type(refTbl[k]) .. " found " .. type(v)
errorFound, errorMsg = checkIsDeletedOption(k, str, nil, errorFound, errorMsg)
elseif type(v) ~= type(refTbl[k]) then
errorFound = true
errorMsg = str .. "." .. k .. " type error. Expected " .. type(refTbl[k]) .. " found " .. type(v)
elseif type(v) == "table" then
ExportImport:CheckDeserializedOptions(v, refTbl[k], str .. "." .. k)
res, msg = ExportImport:CheckDeserializedOptions(v, refTbl[k], str .. "." .. k)
if not res then
errorFound, errorMsg = checkIsDeletedOption(msg, str, msg, errorFound, errorMsg)
end
end
end
end
if errorFound then
return false, errorMsg
end
return true
end
@ -135,8 +176,8 @@ function ExportImport:GetOptions()
export.eb:HighlightText(0, export.eb.editBox:GetNumLetters())
export:SetStatusText("Copy this string to share your configuration with others.")
end,
name = "Export",
desc = "Export your current profile to share with others or your various accounts.",
name = L["Export"],
desc = L["Export your current profile to share with others or your various accounts."],
order = 3,
},
import = {
@ -159,17 +200,25 @@ function ExportImport:GetOptions()
import.deserializedTable = deserialized
end)
end,
name = "Import",
desc = "This will overwrite your current profile!",
name = L["Import"],
desc = L["This will overwrite your current profile!"],
order = 4,
},
}
end
function ExportImport:ApplyImport(t, table)
function ExportImport:ApplyImport(t, table, str)
if str == nil then
str = "Gladdy.db"
end
for k,v in pairs(t) do
if type(v) == "table" then
ExportImport:ApplyImport(v, table[k])
if (table[k] ~= nil) then
ExportImport:ApplyImport(v, table[k], str .. "." .. k)
else
Gladdy:Warn("ApplyImport failed for", str .. "." .. k)
end
else
table[k] = v
end