hotfix profiles

This commit is contained in:
Sumsebrum 2021-05-17 18:22:31 +02:00
parent 2ad5abaf93
commit 4722bbc9bd
5 changed files with 85 additions and 250 deletions

View File

@ -22,7 +22,7 @@ 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 = "TBC-Classic_v1"
Gladdy.version_minor = "0.3-Beta" Gladdy.version_minor = "0.4-Beta"
Gladdy.version = Gladdy.version_major .. "." .. Gladdy.version_minor Gladdy.version = Gladdy.version_major .. "." .. Gladdy.version_minor
LibStub("AceTimer-3.0"):Embed(Gladdy) LibStub("AceTimer-3.0"):Embed(Gladdy)

View File

@ -1,6 +1,6 @@
## Interface: 20501 ## Interface: 20501
## Title: Gladdy - TBC ## Title: Gladdy - TBC
## Version: 1.0.3-Beta ## Version: 1.0.4-Beta
## Notes: The most powerful arena AddOn for WoW 2.5.1 ## Notes: The most powerful arena AddOn for WoW 2.5.1
## Author: XiconQoo, DnB_Junkee, Knall ## Author: XiconQoo, DnB_Junkee, Knall
## X-Email: contact me on discord Knall#1751 ## X-Email: contact me on discord Knall#1751

View File

@ -18,19 +18,11 @@ local function table_copy(t)
return t2; return t2;
end end
local function applyImport(t)
for k,v in pairs(t) do
if type(v) == "table" then
applyImport(v, Gladdy.dbi.profile[k]);
else
Gladdy.dbi.profile[k] = v;
end
end
end
local ExportImport = Gladdy:NewModule("ExportImport", nil, { local ExportImport = Gladdy:NewModule("ExportImport", nil, {
}) })
local export = AceGUI:Create("Frame") local export = AceGUI:Create("Frame")
export:SetWidth(550) export:SetWidth(550)
export.sizer_se:Hide() export.sizer_se:Hide()
@ -72,7 +64,7 @@ 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)
applyImport(import.deserializedTable) ExportImport:ApplyImport(import.deserializedTable)
Gladdy:UpdateFrame() Gladdy:UpdateFrame()
import:Hide() import:Hide()
end) end)
@ -154,35 +146,10 @@ function ExportImport:GetOptions()
import.statustext:SetTextColor(1,0,0) import.statustext:SetTextColor(1,0,0)
import.eb:SetFocus() import.eb:SetFocus()
import.eb:SetCallback("OnTextChanged", function(widget) import.eb:SetCallback("OnTextChanged", function(widget)
local decoded_string = LibDeflate:DecodeForPrint(widget:GetText()) local deserialized = ExportImport:Decode(widget:GetText(), true)
if not decoded_string then if not deserialized then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED LibDeflate:DecodeForPrint")
import.button.frame:Disable()
return return
end end
local decompress_deflate = LibDeflate:DecompressZlib(decoded_string)
if not decompress_deflate then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED LibDeflate:DecompressZlib")
import.button.frame:Disable()
return
end
local success, deserialized = AceSerializer:Deserialize(decompress_deflate)
if not success then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED AceSerializer:Deserialize")
import.button.frame:Disable()
return
end
local statusOption, error = ExportImport:CheckDeserializedOptions(deserialized, Gladdy.db)
if not statusOption then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText(error)
import.button.frame:Disable()
return
end
import.statustext:SetTextColor(0,1,0) import.statustext:SetTextColor(0,1,0)
import:SetStatusText("SUCCESS") import:SetStatusText("SUCCESS")
import.button.frame:Enable() import.button.frame:Enable()
@ -195,3 +162,56 @@ function ExportImport:GetOptions()
}, },
} }
end end
function ExportImport:ApplyImport(t, table)
if table == nil then
table = Gladdy.dbi.profile
end
for k,v in pairs(t) do
if type(v) == "table" then
ExportImport:ApplyImport(v, table[k])
else
table[k] = v;
end
end
end
function ExportImport:Decode(str, showError)
local decoded_string = LibDeflate:DecodeForPrint(str)
if not decoded_string then
if showError then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED LibDeflate:DecodeForPrint")
import.button.frame:Disable()
end
return nil
end
local decompress_deflate = LibDeflate:DecompressZlib(decoded_string)
if not decompress_deflate then
if showError then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED LibDeflate:DecompressZlib")
import.button.frame:Disable()
end
return nil
end
local success, deserialized = AceSerializer:Deserialize(decompress_deflate)
if not success then
if showError then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText("Invalid Import String FAILED AceSerializer:Deserialize")
import.button.frame:Disable()
end
return nil
end
local statusOption, error = ExportImport:CheckDeserializedOptions(deserialized, Gladdy.db)
if not statusOption then
if showError then
import.statustext:SetTextColor(1,0,0)
import:SetStatusText(error)
import.button.frame:Disable()
end
return nil
end
return deserialized
end

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
# Gladdy - TBC # Gladdy - TBC
### The most powerful arena addon for WoW TBC 2.5.1 ### The most powerful arena addon for WoW TBC 2.5.1
## [v1.0.3-Beta Download Here](https://github.com/XiconQoo/Gladdy-TBC/releases/download/v1.0.3-Beta/Gladdy_TBC-Classic_v1.0.3-Beta.zip) ## [v1.0.4-Beta Download Here](https://github.com/XiconQoo/Gladdy-TBC/releases/download/v1.0.4-Beta/Gladdy_TBC-Classic_v1.0.4-Beta.zip)
###### <a target="_blank" rel="noopener noreferrer" href="https://www.paypal.me/xiconqoo/10"><img src="https://raw.githubusercontent.com/XiconQoo/Gladdy/readme-media/Paypal-Donate.png" height="30" style="margin-top:-30px;position:relative;top:20px;"></a> Please consider donating if you like my work ###### <a target="_blank" rel="noopener noreferrer" href="https://www.paypal.me/xiconqoo/10"><img src="https://raw.githubusercontent.com/XiconQoo/Gladdy/readme-media/Paypal-Donate.png" height="30" style="margin-top:-30px;position:relative;top:20px;"></a> Please consider donating if you like my work
@ -35,5 +35,8 @@ The goal is to make Gladdy highly configurable in it's appearance. Everything ca
### Changes ### Changes
#### v1.0.4-Beta
- XiconProfiles fixed
#### v1.0.0-Beta #### v1.0.0-Beta
- port form 2.4.3 - port form 2.4.3