fix: v1.4.4 - AceGUI pool fixes, event handling nil checks, QuestieLearner serialization, l10n format fixes
This commit is contained in:
@@ -558,10 +558,13 @@ do
|
||||
end
|
||||
end)
|
||||
|
||||
local border = CreateFrame("Frame", nil, frame, "DialogBorderOpaqueTemplate")
|
||||
local template = DialogBorderOpaqueTemplate and "DialogBorderOpaqueTemplate" or nil
|
||||
local border = CreateFrame("Frame", nil, frame, template)
|
||||
border:SetAllPoints(frame)
|
||||
frame:SetFixedFrameStrata(true)
|
||||
frame:SetFixedFrameLevel(true)
|
||||
if frame.SetFixedFrameStrata then
|
||||
frame:SetFixedFrameStrata(true)
|
||||
frame:SetFixedFrameLevel(true)
|
||||
end
|
||||
|
||||
local text = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
|
||||
text:SetSize(290, 0)
|
||||
@@ -574,11 +577,14 @@ do
|
||||
button:SetNormalFontObject(GameFontNormal)
|
||||
button:SetHighlightFontObject(GameFontHighlight)
|
||||
button:SetNormalTexture(130763) -- "Interface\\Buttons\\UI-DialogBox-Button-Up"
|
||||
button:GetNormalTexture():SetTexCoord(0.0, 1.0, 0.0, 0.71875)
|
||||
local normalTex = button:GetNormalTexture()
|
||||
if normalTex then normalTex:SetTexCoord(0.0, 1.0, 0.0, 0.71875) end
|
||||
button:SetPushedTexture(130761) -- "Interface\\Buttons\\UI-DialogBox-Button-Down"
|
||||
button:GetPushedTexture():SetTexCoord(0.0, 1.0, 0.0, 0.71875)
|
||||
local pushedTex = button:GetPushedTexture()
|
||||
if pushedTex then pushedTex:SetTexCoord(0.0, 1.0, 0.0, 0.71875) end
|
||||
button:SetHighlightTexture(130762) -- "Interface\\Buttons\\UI-DialogBox-Button-Highlight"
|
||||
button:GetHighlightTexture():SetTexCoord(0.0, 1.0, 0.0, 0.71875)
|
||||
local highlightTex = button:GetHighlightTexture()
|
||||
if highlightTex then highlightTex:SetTexCoord(0.0, 1.0, 0.0, 0.71875) end
|
||||
button:SetText(newText)
|
||||
return button
|
||||
end
|
||||
|
||||
@@ -138,6 +138,8 @@ end
|
||||
function AceGUI:Create(widgetType)
|
||||
if WidgetRegistry[widgetType] then
|
||||
local widget = newWidget(widgetType)
|
||||
|
||||
if not widget then return end
|
||||
|
||||
if rawget(widget, "Acquire") then
|
||||
widget.OnAcquire = widget.Acquire
|
||||
@@ -170,6 +172,7 @@ end
|
||||
-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well.
|
||||
-- @param widget The widget to release
|
||||
function AceGUI:Release(widget)
|
||||
if not widget then return end
|
||||
if widget.isQueuedForRelease then return end
|
||||
widget.isQueuedForRelease = true
|
||||
safecall(widget.PauseLayout, widget)
|
||||
@@ -296,6 +299,7 @@ do
|
||||
end
|
||||
|
||||
WidgetBase.Fire = function(self, name, ...)
|
||||
if not self or not self.type or not self.events then return end
|
||||
if self.events[name] then
|
||||
local success, ret = safecall(self.events[name], self, name, ...)
|
||||
if success then
|
||||
@@ -412,14 +416,19 @@ do
|
||||
local WidgetContainerBase = AceGUI.WidgetContainerBase
|
||||
|
||||
WidgetContainerBase.PauseLayout = function(self)
|
||||
self.LayoutPaused = true
|
||||
if self then
|
||||
self.LayoutPaused = true
|
||||
end
|
||||
end
|
||||
|
||||
WidgetContainerBase.ResumeLayout = function(self)
|
||||
self.LayoutPaused = nil
|
||||
if self then
|
||||
self.LayoutPaused = nil
|
||||
end
|
||||
end
|
||||
|
||||
WidgetContainerBase.PerformLayout = function(self)
|
||||
if not self then return end
|
||||
if self.LayoutPaused then
|
||||
return
|
||||
end
|
||||
@@ -428,7 +437,9 @@ do
|
||||
|
||||
--call this function to layout, makes sure layed out objects get a frame to get sizes etc
|
||||
WidgetContainerBase.DoLayout = function(self)
|
||||
self:PerformLayout()
|
||||
if self then
|
||||
self:PerformLayout()
|
||||
end
|
||||
-- if not self.parent then
|
||||
-- self.frame:SetScript("OnUpdate", LayoutOnUpdate)
|
||||
-- end
|
||||
@@ -471,7 +482,9 @@ do
|
||||
end
|
||||
|
||||
WidgetContainerBase.SetLayout = function(self, Layout)
|
||||
self.LayoutFunc = AceGUI:GetLayout(Layout)
|
||||
if self then
|
||||
self.LayoutFunc = AceGUI:GetLayout(Layout)
|
||||
end
|
||||
end
|
||||
|
||||
WidgetContainerBase.SetAutoAdjustHeight = function(self, adjust)
|
||||
@@ -617,6 +630,7 @@ end
|
||||
-- Very simple Layout, Children are stacked on top of each other down the left side
|
||||
AceGUI:RegisterLayout("List",
|
||||
function(content, children)
|
||||
if not content then return end
|
||||
local height = 0
|
||||
local width = content.width or content:GetWidth() or 0
|
||||
for i = 1, #children do
|
||||
@@ -654,6 +668,7 @@ AceGUI:RegisterLayout("List",
|
||||
-- A single control fills the whole content area
|
||||
AceGUI:RegisterLayout("Fill",
|
||||
function(content, children)
|
||||
if not content then return end
|
||||
if children[1] then
|
||||
children[1]:SetWidth(content:GetWidth() or 0)
|
||||
children[1]:SetHeight(content:GetHeight() or 0)
|
||||
@@ -674,6 +689,7 @@ end
|
||||
AceGUI:RegisterLayout("Flow",
|
||||
function(content, children)
|
||||
if layoutrecursionblock then return end
|
||||
if not content then return end
|
||||
--used height so far
|
||||
local height = 0
|
||||
--width used in the current row
|
||||
@@ -852,6 +868,7 @@ Cell:
|
||||
]]
|
||||
AceGUI:RegisterLayout("Table",
|
||||
function (content, children)
|
||||
if not content then return end
|
||||
local obj = content.obj
|
||||
obj:PauseLayout()
|
||||
|
||||
|
||||
@@ -187,7 +187,12 @@ local function Constructor()
|
||||
|
||||
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
|
||||
scrollbg:SetAllPoints(scrollbar)
|
||||
scrollbg:SetColorTexture(0, 0, 0, 0.4)
|
||||
if scrollbg.SetColorTexture then
|
||||
scrollbg:SetColorTexture(0, 0, 0, 0.4)
|
||||
else
|
||||
scrollbg:SetTexture(0, 0, 0)
|
||||
scrollbg:SetVertexColor(0, 0, 0, 0.4)
|
||||
end
|
||||
|
||||
--Container Support
|
||||
local content = CreateFrame("Frame", nil, scrollframe)
|
||||
|
||||
@@ -679,7 +679,12 @@ local function Constructor()
|
||||
|
||||
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
|
||||
scrollbg:SetAllPoints(scrollbar)
|
||||
scrollbg:SetColorTexture(0,0,0,0.4)
|
||||
if scrollbg.SetColorTexture then
|
||||
scrollbg:SetColorTexture(0,0,0,0.4)
|
||||
else
|
||||
scrollbg:SetTexture(0, 0, 0)
|
||||
scrollbg:SetVertexColor(0, 0, 0, 0.4)
|
||||
end
|
||||
|
||||
local border = CreateFrame("Frame", nil, frame, BackdropTemplateMixin and "BackdropTemplate" or nil)
|
||||
border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT")
|
||||
|
||||
@@ -143,7 +143,12 @@ local function Constructor()
|
||||
colorSwatch.background = texture
|
||||
texture:SetWidth(16)
|
||||
texture:SetHeight(16)
|
||||
texture:SetColorTexture(1, 1, 1)
|
||||
if texture.SetColorTexture then
|
||||
texture:SetColorTexture(1, 1, 1)
|
||||
else
|
||||
texture:SetTexture(1, 1, 1)
|
||||
texture:SetVertexColor(1, 1, 1, 1)
|
||||
end
|
||||
texture:SetPoint("CENTER", colorSwatch)
|
||||
texture:Show()
|
||||
|
||||
|
||||
@@ -455,7 +455,12 @@ do
|
||||
|
||||
local line = self.frame:CreateTexture(nil, "OVERLAY")
|
||||
line:SetHeight(1)
|
||||
line:SetColorTexture(.5, .5, .5)
|
||||
if line.SetColorTexture then
|
||||
line:SetColorTexture(0.5, 0.5, 0.5)
|
||||
else
|
||||
line:SetTexture(0.5, 0.5, 0.5)
|
||||
line:SetVertexColor(0.5, 0.5, 0.5, 1)
|
||||
end
|
||||
line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
|
||||
line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
|
||||
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
--- **AceSerializer-3.0** Serializes and deserializes Lua tables into strings.
|
||||
-- Can serialize any Lua table (including nested tables) into a string,
|
||||
-- and deserialize that string back into a table.
|
||||
-- @class file
|
||||
-- @name AceSerializer-3.0
|
||||
-- @release $Id: AceSerializer-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $
|
||||
local MAJOR, MINOR = "AceSerializer-3.0", 3
|
||||
|
||||
local AceSerializer, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
if not AceSerializer then return end
|
||||
|
||||
-- Lua APIs
|
||||
local assert, error, pcall = assert, error, pcall
|
||||
local type, tostring, tonumber = type, tostring, tonumber
|
||||
local strfind, strsub, strjoin, strlen = string.find, string.sub, string.join, string.len
|
||||
local max, min = math.max, math.min
|
||||
|
||||
-- quick-and-dirty nil value serializer, used to sanitize the tables before serializing
|
||||
local function SerializeValue(v, res, n)
|
||||
-- nil
|
||||
if v == nil then
|
||||
res[n+1] = "n"
|
||||
return n+1
|
||||
end
|
||||
|
||||
-- boolean
|
||||
if type(v) == "boolean" then
|
||||
res[n+1] = v and "t" or "f"
|
||||
return n+1
|
||||
end
|
||||
|
||||
-- number
|
||||
if type(v) == "number" then
|
||||
-- force 4-decimal numbers, others as-is
|
||||
local str = tostring(v)
|
||||
if strfind(str, "[^0-9%.]") then
|
||||
res[n+1] = str
|
||||
else
|
||||
res[n+1] = format("%.4f", v)
|
||||
end
|
||||
return n+1
|
||||
end
|
||||
|
||||
-- string
|
||||
if type(v) == "string" then
|
||||
res[n+1] = format("%q", v)
|
||||
return n+1
|
||||
end
|
||||
|
||||
-- table
|
||||
if type(v) == "table" then
|
||||
res[n+1] = "{"
|
||||
local n2 = n+2
|
||||
for k, val in pairs(v) do
|
||||
n2 = SerializeValue(k, res, n2)
|
||||
res[n2+1] = "="
|
||||
n2 = n2 + 2
|
||||
n2 = SerializeValue(val, res, n2)
|
||||
res[n2+1] = ","
|
||||
n2 = n2 + 1
|
||||
end
|
||||
res[n2] = "}"
|
||||
return n2
|
||||
end
|
||||
|
||||
-- anything else (we don't know how to serialize)
|
||||
error(format("Cannot serialize a value of type %s", type(v)))
|
||||
end
|
||||
|
||||
local function Serialize(t)
|
||||
if type(t) ~= "table" then
|
||||
error("Usage: AceSerializer:Serialize(tbl): tbl must be a table, got " .. type(t), 2)
|
||||
end
|
||||
local s = {}
|
||||
SerializeValue(t, s, 0)
|
||||
return strjoin("", s)
|
||||
end
|
||||
|
||||
AceSerializer.Serialize = Serialize
|
||||
|
||||
local function Deserialize(s)
|
||||
if type(s) ~= "string" then
|
||||
error("Usage: AceSerializer:Deserialize(str): str must be a string, got " .. type(s), 2)
|
||||
end
|
||||
|
||||
local stack = {}
|
||||
local n = strlen(s)
|
||||
local pos = 1
|
||||
|
||||
-- read a value
|
||||
local function ReadValue()
|
||||
-- skip whitespace
|
||||
while pos <= n and strfind(strsub(s, pos, pos), "%s") do
|
||||
pos = pos + 1
|
||||
end
|
||||
|
||||
if pos > n then error("Empty string") end
|
||||
|
||||
local c = strsub(s, pos, pos)
|
||||
pos = pos + 1
|
||||
|
||||
if c == "n" then
|
||||
return nil
|
||||
elseif c == "t" then
|
||||
return true
|
||||
elseif c == "f" then
|
||||
return false
|
||||
elseif c == "{" then
|
||||
local tbl = {}
|
||||
local numkey = 0
|
||||
local key
|
||||
while pos <= n do
|
||||
-- skip whitespace
|
||||
while pos <= n and strfind(strsub(s, pos, pos), "%s") do
|
||||
pos = pos + 1
|
||||
end
|
||||
if pos > n then error("Missing closing brace") end
|
||||
if strsub(s, pos, pos) == "}" then
|
||||
pos = pos + 1
|
||||
break
|
||||
end
|
||||
-- read key (non-number key)
|
||||
if strsub(s, pos, pos) ~= "[" then
|
||||
-- assume it's a string key
|
||||
key = ReadValue()
|
||||
else
|
||||
pos = pos + 1
|
||||
key = ReadValue()
|
||||
if strsub(s, pos, pos) ~= "]" then error("Missing ]") end
|
||||
pos = pos + 1
|
||||
end
|
||||
-- skip whitespace and =
|
||||
while pos <= n and strfind(strsub(s, pos, pos), "[=%s]") do
|
||||
pos = pos + 1
|
||||
end
|
||||
local val = ReadValue()
|
||||
if key then
|
||||
tbl[key] = val
|
||||
else
|
||||
numkey = numkey + 1
|
||||
tbl[numkey] = val
|
||||
end
|
||||
-- skip whitespace and comma
|
||||
while pos <= n and strfind(strsub(s, pos, pos), "[,%s]") do
|
||||
pos = pos + 1
|
||||
end
|
||||
end
|
||||
return tbl
|
||||
elseif c == "\"" then
|
||||
local i = pos
|
||||
repeat
|
||||
if i > n then error("Unterminated string") end
|
||||
until strfind(strsub(s, i, i), "[^\"]") or i == n
|
||||
local str = strsub(s, pos, i-1)
|
||||
pos = i + 1
|
||||
return str
|
||||
else
|
||||
-- number or error
|
||||
local numstr = ""
|
||||
while pos <= n and strfind(strsub(s, pos, pos), "[0-9%.%-]") do
|
||||
numstr = numstr .. strsub(s, pos, pos)
|
||||
pos = pos + 1
|
||||
end
|
||||
if numstr == "" then
|
||||
error("Invalid number at position " .. pos)
|
||||
end
|
||||
return tonumber(numstr)
|
||||
end
|
||||
end
|
||||
|
||||
local value = ReadValue()
|
||||
-- skip whitespace
|
||||
while pos <= n and strfind(strsub(s, pos, pos), "%s") do
|
||||
pos = pos + 1
|
||||
end
|
||||
if pos <= n then
|
||||
error("Trailing characters after serialized table: " .. strsub(s, pos))
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
AceSerializer.Deserialize = Deserialize
|
||||
|
||||
-- http://lua-users.org/wiki/Base64EncoderAndDecoder
|
||||
local b64 = {
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"abcdefghijklmnopqrstuvwxyz",
|
||||
"0123456789+/",
|
||||
}
|
||||
|
||||
local function EncodeString(str)
|
||||
local encoded = ""
|
||||
for i = 1, strlen(str), 3 do
|
||||
local b1, b2, b3 = strbyte(str, i, i+2)
|
||||
if not b3 then
|
||||
b3 = 0
|
||||
end
|
||||
if not b2 then
|
||||
b2 = 0
|
||||
end
|
||||
local n = b1 * 256 + b2 * 256 + b3
|
||||
local e1, e2, e3, e4 = (n/4)%64, (n/4)%64, (n/4)%64, n%64
|
||||
encoded = encoded .. strsub(b64[1], e1, e1) .. strsub(b64[1], e2, e2) .. strsub(b64[3], e3, e3) .. strsub(b64[3], e4, e4)
|
||||
end
|
||||
--[[
|
||||
-- fix padding at the end to be lua-friendly
|
||||
if mod(len(str),3)==1 then
|
||||
encoded = strsub(encoded, 1, -4) .. "=="
|
||||
elseif mod(len(str),3)==2 then
|
||||
encoded = strsub(encoded, 1, -2) .. "="
|
||||
end
|
||||
]]
|
||||
return encoded
|
||||
end
|
||||
|
||||
local function DecodeString(str)
|
||||
local decoded = ""
|
||||
str = gsub(str, "%s", "")
|
||||
local len = strlen(str)
|
||||
local i = 1
|
||||
while i <= len do
|
||||
local e1, e2, e3, e4 = strfind(str, "(.)(.)(.?)(.?)", i)
|
||||
if not e1 then error("Invalid string") end
|
||||
local n = (strfind(b64[1], e1) - 1) * 64 + (strfind(b64[1], e2) - 1)
|
||||
n = n * 64 + (strfind(b64[3], e3) - 1)
|
||||
n = n * 64 + (strfind(b64[3], e4) - 1)
|
||||
decoded = decoded .. strchar(n/256, n%256)
|
||||
if e4 == "=" then
|
||||
decoded = strsub(decoded, 1, -2)
|
||||
elseif e3 == "=" then
|
||||
decoded = strsub(decoded, 1, -3)
|
||||
end
|
||||
i = e4 + 1
|
||||
end
|
||||
return decoded
|
||||
end
|
||||
|
||||
function AceSerializer:SerializeForPrint(val)
|
||||
return EncodeString(Serialize(val))
|
||||
end
|
||||
|
||||
function AceSerializer:DeserializeFromPrint(str)
|
||||
local success, val = pcall(Deserialize, DecodeString(str))
|
||||
if success then
|
||||
return val
|
||||
end
|
||||
return nil, "Invalid serialization string"
|
||||
end
|
||||
|
||||
AceSerializer.embeds = AceSerializer.embeds or {}
|
||||
|
||||
local function Embed(target)
|
||||
for method, func in pairs(AceSerializer) do
|
||||
if type(func) == "function" and method ~= "Embed" and method ~= "embeds" then
|
||||
target[method] = func
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AceSerializer:Embed(target)
|
||||
Embed(target)
|
||||
target.embeds = AceSerializer.embeds
|
||||
AceSerializer.embeds[target] = true
|
||||
return target
|
||||
end
|
||||
|
||||
for target, v in pairs(AceSerializer.embeds) do
|
||||
Embed(target)
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
|
||||
<Script file="AceSerializer-3.0.lua" />
|
||||
</Ui>
|
||||
Reference in New Issue
Block a user