ExportImport, VersionCheck & XiconProfiles fix
This commit is contained in:
parent
edb5608a38
commit
fd5183cf5d
12
Gladdy.lua
12
Gladdy.lua
@ -11,6 +11,9 @@ local IsAddOnLoaded = IsAddOnLoaded
|
|||||||
local IsInInstance = IsInInstance
|
local IsInInstance = IsInInstance
|
||||||
local GetBattlefieldStatus = GetBattlefieldStatus
|
local GetBattlefieldStatus = GetBattlefieldStatus
|
||||||
local IsActiveBattlefieldArena = IsActiveBattlefieldArena
|
local IsActiveBattlefieldArena = IsActiveBattlefieldArena
|
||||||
|
local RELEASE_TYPES = { alpha = "Alpha", beta = "Beta", release = "Release"}
|
||||||
|
local PREFIX = "TBC-Classic_v"
|
||||||
|
local VERSION_REGEX = PREFIX .. "(%d+%.%d+)%-(%a)"
|
||||||
|
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
@ -21,9 +24,12 @@ local IsActiveBattlefieldArena = IsActiveBattlefieldArena
|
|||||||
local MAJOR, MINOR = "Gladdy", 4
|
local MAJOR, MINOR = "Gladdy", 4
|
||||||
local Gladdy = LibStub:NewLibrary(MAJOR, MINOR)
|
local Gladdy = LibStub:NewLibrary(MAJOR, MINOR)
|
||||||
local L
|
local L
|
||||||
Gladdy.version_major = "TBC-Classic_v1"
|
Gladdy.version_major_num = 1
|
||||||
Gladdy.version_minor = "0.4-Beta"
|
Gladdy.version_minor_num = 0.04
|
||||||
Gladdy.version = Gladdy.version_major .. "." .. Gladdy.version_minor
|
Gladdy.version_num = Gladdy.version_major_num + Gladdy.version_minor_num
|
||||||
|
Gladdy.version_releaseType = RELEASE_TYPES.beta
|
||||||
|
Gladdy.version = PREFIX .. Gladdy.version_num .. "-" .. Gladdy.version_releaseType
|
||||||
|
Gladdy.VERSION_REGEX = VERSION_REGEX
|
||||||
|
|
||||||
LibStub("AceTimer-3.0"):Embed(Gladdy)
|
LibStub("AceTimer-3.0"):Embed(Gladdy)
|
||||||
LibStub("AceComm-3.0"):Embed(Gladdy)
|
LibStub("AceComm-3.0"):Embed(Gladdy)
|
||||||
|
@ -64,9 +64,11 @@ importButton:SetText("Import\n(this will overwrite your current profile!)")
|
|||||||
importButton:SetWidth(200)
|
importButton:SetWidth(200)
|
||||||
importButton:SetHeight(50)
|
importButton:SetHeight(50)
|
||||||
importButton:SetCallback("OnClick", function(widget)
|
importButton:SetCallback("OnClick", function(widget)
|
||||||
ExportImport:ApplyImport(import.deserializedTable)
|
ExportImport:ApplyImport(import.deserializedTable, Gladdy.db)
|
||||||
Gladdy:UpdateFrame()
|
|
||||||
import:Hide()
|
import:Hide()
|
||||||
|
Gladdy:Reset()
|
||||||
|
Gladdy:HideFrame()
|
||||||
|
Gladdy:ToggleFrame(3)
|
||||||
end)
|
end)
|
||||||
import:AddChild(importButton)
|
import:AddChild(importButton)
|
||||||
import.button = importButton
|
import.button = importButton
|
||||||
@ -84,25 +86,24 @@ import:AddChild(importClearButton)
|
|||||||
import.clearButton = importClearButton
|
import.clearButton = importClearButton
|
||||||
|
|
||||||
function ExportImport:CheckDeserializedOptions(tbl, refTbl, str)
|
function ExportImport:CheckDeserializedOptions(tbl, refTbl, str)
|
||||||
if str == nil and not tbl.version_major then
|
if str == nil and not tbl.version_major_num then
|
||||||
return false, "Version conflict: version_major not seen"
|
return false, "Version conflict: version_major_num not seen"
|
||||||
end
|
end
|
||||||
if str == nil and tbl.version_major ~= Gladdy.version_major then
|
if str == nil and tbl.version_major_num ~= Gladdy.version_major_num then
|
||||||
return false, "Version conflict: " .. tbl.version_major .. " ~= " .. Gladdy.version_major
|
return false, "Version conflict: " .. tbl.version_major_num .. " ~= " .. Gladdy.version_major_num
|
||||||
end
|
end
|
||||||
if str == nil then
|
if str == nil then
|
||||||
str = "Gladdy.db"
|
str = "Gladdy.db"
|
||||||
tbl.version_major = nil
|
tbl.version_major_num = nil
|
||||||
end
|
end
|
||||||
if type(tbl) == "table" then
|
for k,v in pairs(tbl) do
|
||||||
for k,v in pairs(tbl) do
|
if refTbl[k] == nil then
|
||||||
if refTbl[k] ~= nil then
|
return false, str .. "." .. k .. " does not exist"
|
||||||
if type(v) ~= type(refTbl[k]) then
|
else
|
||||||
return false, str .. "." .. k .. " type error. Expected " .. type(refTbl[k]) .. " found " .. type(v)
|
if type(v) ~= type(refTbl[k]) then
|
||||||
end
|
return false, str .. "." .. k .. " type error. Expected " .. type(refTbl[k]) .. " found " .. type(v)
|
||||||
|
elseif type(v) == "table" then
|
||||||
ExportImport:CheckDeserializedOptions(v, refTbl[k], str .. "." .. k)
|
ExportImport:CheckDeserializedOptions(v, refTbl[k], str .. "." .. k)
|
||||||
else
|
|
||||||
return false, str .. "." .. k .. " does not exist"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -122,7 +123,7 @@ function ExportImport:GetOptions()
|
|||||||
type = "execute",
|
type = "execute",
|
||||||
func = function()
|
func = function()
|
||||||
local db = table_copy(Gladdy.db)
|
local db = table_copy(Gladdy.db)
|
||||||
db.version_major = Gladdy.version_major
|
db.version_major_num = Gladdy.version_major_num
|
||||||
dump = AceSerializer:Serialize(db)
|
dump = AceSerializer:Serialize(db)
|
||||||
local compress_deflate = LibDeflate:CompressZlib(dump)
|
local compress_deflate = LibDeflate:CompressZlib(dump)
|
||||||
printable_compressed = LibDeflate:EncodeForPrint(compress_deflate)
|
printable_compressed = LibDeflate:EncodeForPrint(compress_deflate)
|
||||||
@ -164,14 +165,11 @@ function ExportImport:GetOptions()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ExportImport:ApplyImport(t, table)
|
function ExportImport:ApplyImport(t, table)
|
||||||
if table == nil then
|
|
||||||
table = Gladdy.dbi.profile
|
|
||||||
end
|
|
||||||
for k,v in pairs(t) do
|
for k,v in pairs(t) do
|
||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
ExportImport:ApplyImport(v, table[k])
|
ExportImport:ApplyImport(v, table[k])
|
||||||
else
|
else
|
||||||
table[k] = v;
|
table[k] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -204,7 +202,7 @@ function ExportImport:Decode(str, showError)
|
|||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local statusOption, error = ExportImport:CheckDeserializedOptions(deserialized, Gladdy.db)
|
local statusOption, error = ExportImport:CheckDeserializedOptions(deserialized, Gladdy.defaults.profile)
|
||||||
if not statusOption then
|
if not statusOption then
|
||||||
if showError then
|
if showError then
|
||||||
import.statustext:SetTextColor(1,0,0)
|
import.statustext:SetTextColor(1,0,0)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
local str_match, tonumber, tostring = string.match, tonumber, tostring
|
||||||
|
|
||||||
local UnitName = UnitName
|
local UnitName = UnitName
|
||||||
|
|
||||||
local Gladdy = LibStub("Gladdy")
|
local Gladdy = LibStub("Gladdy")
|
||||||
@ -24,19 +26,20 @@ end
|
|||||||
function VersionCheck:Test(unit)
|
function VersionCheck:Test(unit)
|
||||||
if unit == "arena1" then
|
if unit == "arena1" then
|
||||||
self:RegisterComm("GladdyVCheck", VersionCheck.OnCommReceived)
|
self:RegisterComm("GladdyVCheck", VersionCheck.OnCommReceived)
|
||||||
self:SendCommMessage("GladdyVCheck", Gladdy.version, "RAID", self.playerName)
|
self:SendCommMessage("GladdyVCheck", tostring(Gladdy.version_num), "RAID", self.playerName)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function VersionCheck.OnCommReceived(prefix, message, distribution, sender)
|
function VersionCheck.OnCommReceived(prefix, message, distribution, sender)
|
||||||
if sender ~= VersionCheck.playerName then
|
if sender ~= VersionCheck.playerName then
|
||||||
local addonVersion = Gladdy.version
|
local addonVersion = Gladdy.version_num
|
||||||
if (message == addonVersion) then
|
message = tonumber(message)
|
||||||
|
if message and message <= Gladdy.version_num then
|
||||||
--Gladdy:Print("Version", "\"".. addonVersion.."\"", "is up to date")
|
--Gladdy:Print("Version", "\"".. addonVersion.."\"", "is up to date")
|
||||||
else
|
else
|
||||||
Gladdy:Warn("Current version", "\"".. addonVersion.."\"", "is outdated. Most recent version is", "\"".. message.."\"")
|
Gladdy:Warn("Current version", "\"".. addonVersion.."\"", "is outdated. Most recent version is", "\"".. message.."\"")
|
||||||
Gladdy:Warn("Please download the latest Gladdy version at:")
|
Gladdy:Warn("Please download the latest Gladdy version at:")
|
||||||
Gladdy:Warn("https://github.com/XiconQoo/Gladdy")
|
Gladdy:Warn("https://github.com/XiconQoo/Gladdy-TBC")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user