Port XML templates to Lua, update AceGUI/AceConfig, fix $parent nil frame issues on our game version

This commit is contained in:
NoM0Re
2025-07-29 18:02:22 +02:00
committed by GitHub
parent dce683db43
commit 9d0cc562b9
48 changed files with 1235 additions and 1128 deletions
@@ -27,7 +27,6 @@ local function ConstructIconPicker(frame)
local scroll = AceGUI:Create("ScrollFrame");
scroll:SetLayout("flow");
--scroll.frame:SetClipsChildren(true);
group:AddChild(scroll);
local function iconPickerFill(subname, doSort)
@@ -100,8 +99,12 @@ local function ConstructIconPicker(frame)
end
end
local input = CreateFrame("Editbox", "WeakAurasIconFilterInput", group.frame, "WA_InputBoxTemplate");
input:SetScript("OnTextChanged", function(...) iconPickerFill(input:GetText(), false); end);
local input = CreateFrame("EditBox", "WeakAurasFilterInput", group.frame)
WeakAuras.XMLTemplates["SearchBoxTemplate"](input)
input:SetScript("OnTextChanged", function(self)
WA_SearchBoxTemplate_OnTextChanged(self)
iconPickerFill(input:GetText(), false)
end);
input:SetScript("OnEnterPressed", function(...) iconPickerFill(input:GetText(), true); end);
input:SetScript("OnEscapePressed", function(...) input:SetText(""); iconPickerFill(input:GetText(), true); end);
input:SetWidth(200);
+5 -60
View File
@@ -57,66 +57,11 @@ local function ConstructModelPicker(frame)
group.frame:Hide();
group:SetLayout("flow");
local filterInput = CreateFrame("EditBox", "WeakAurasModelFilterInput", group.frame, "WA_InputBoxTemplate")
filterInput:SetAutoFocus(false)
filterInput:SetTextInsets(16, 20, 0, 0)
filterInput.Instructions = filterInput:CreateFontString(nil, "ARTWORK", "GameFontDisableSmall")
filterInput.Instructions:SetText(SEARCH)
filterInput.Instructions:SetPoint("TOPLEFT", filterInput, "TOPLEFT", 16, 0)
filterInput.Instructions:SetPoint("BOTTOMRIGHT", filterInput, "BOTTOMRIGHT", -20, 0)
filterInput.Instructions:SetTextColor(0.35, 0.35, 0.35)
filterInput.Instructions:SetJustifyH("LEFT")
filterInput.Instructions:SetJustifyV("MIDDLE")
filterInput.searchIcon = filterInput:CreateTexture(nil, "OVERLAY")
filterInput.searchIcon:SetTexture("Interface\\Common\\UI-Searchbox-Icon")
filterInput.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
filterInput.searchIcon:SetSize(14, 14)
filterInput.searchIcon:SetPoint("LEFT", 0, -2)
filterInput.clearButton = CreateFrame("Button", nil, filterInput)
filterInput.clearButton:SetSize(14, 14)
filterInput.clearButton:SetPoint("RIGHT", -3, 0)
filterInput.clearButton.texture = filterInput.clearButton:CreateTexture()
filterInput.clearButton.texture:SetTexture("Interface\\FriendsFrame\\ClearBroadcastIcon")
filterInput.clearButton.texture:SetAlpha(0.5)
filterInput.clearButton.texture:SetSize(17, 17)
filterInput.clearButton.texture:SetPoint("CENTER", 0, 0)
filterInput.clearButton:SetScript("OnEnter", function(self) self.texture:SetAlpha(1.0) end)
filterInput.clearButton:SetScript("OnLeave", function(self) self.texture:SetAlpha(0.5) end)
filterInput.clearButton:SetScript("OnMouseDown", function(self) if self:IsEnabled() then self.texture:SetPoint("CENTER", 1, -1) end end)
filterInput.clearButton:SetScript("OnMouseUp", function(self) self.texture:SetPoint("CENTER") end)
filterInput.clearButton:SetScript("OnClick", function(self)
local editBox = self:GetParent()
editBox:SetText("")
editBox:ClearFocus()
end)
filterInput:SetScript("OnEditFocusLost", function(self)
if self:GetText() == "" then
self.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
self.clearButton:Hide()
end
end)
filterInput:SetScript("OnEditFocusGained", function(self)
self.searchIcon:SetVertexColor(1.0, 1.0, 1.0)
self.clearButton:Show()
end)
filterInput:HookScript("OnTextChanged", function(self)
if not self:HasFocus() and self:GetText() == "" then
self.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
self.clearButton:Hide()
else
self.searchIcon:SetVertexColor(1.0, 1.0, 1.0)
self.clearButton:Show()
end
if self:GetText() == "" then
self.Instructions:Show()
else
self.Instructions:Hide()
end
local filterInput = CreateFrame("EditBox", "WeakAurasFilterInput", nil)
WeakAuras.XMLTemplates["SearchBoxTemplate"](filterInput)
filterInput:SetParent(group.frame)
filterInput:SetScript("OnTextChanged", function(self)
WA_SearchBoxTemplate_OnTextChanged(self)
local filterText = filterInput:GetText()
RecurseSetFilter(group.modelTree.tree, filterText)
group.modelTree.filter = filterText ~= nil and filterText ~= ""
+13 -65
View File
@@ -96,7 +96,8 @@ function OptionsPrivate.CreateFrame()
local db = OptionsPrivate.savedVars.db
local odb = OptionsPrivate.savedVars.odb
frame = CreateFrame("Frame", "WeakAurasOptions", UIParent, "WA_PortraitFrameTemplate")
frame = CreateFrame("Frame", "WeakAurasOptions", UIParent)
WeakAuras.XMLTemplates["PortraitFrameTemplate"](frame)
function OptionsPrivate.SetTitle(title)
local text = "WeakAuras " .. WeakAuras.versionString
@@ -312,7 +313,8 @@ function OptionsPrivate.CreateFrame()
end
end
local minimizebutton = CreateFrame("Button", nil, frame, "WA_MaximizeMinimizeButtonFrameTemplate")
local minimizebutton = CreateFrame("Button", nil, frame)
WeakAuras.XMLTemplates["MaximizeMinimizeButtonFrameTemplate"](minimizebutton)
minimizebutton:SetPoint("RIGHT", frame.CloseButton, "LEFT", 0, 0)
minimizebutton:SetOnMaximizedCallback(function()
frame.minimized = false
@@ -386,7 +388,8 @@ function OptionsPrivate.CreateFrame()
tipPopupLabelK:SetJustifyH("LEFT")
tipPopupLabelK:SetJustifyV("TOP")
local urlWidget = CreateFrame("EditBox", nil, tipPopup, "WA_InputBoxTemplate")
local urlWidget = CreateFrame("EditBox", nil, tipPopup)
WeakAuras.XMLTemplates["InputBoxTemplate"](urlWidget)
urlWidget:SetFont(STANDARD_TEXT_FONT, 12)
urlWidget:SetPoint("TOPLEFT", tipPopupLabelK, "BOTTOMLEFT", 6, 0)
urlWidget:SetPoint("TOPRIGHT", tipPopupLabelK, "BOTTOMRIGHT", 0, 0)
@@ -570,66 +573,10 @@ function OptionsPrivate.CreateFrame()
frame.moversizer, frame.mover = OptionsPrivate.MoverSizer(frame)
-- filter line
local filterInput = CreateFrame("EditBox", "WeakAurasFilterInput", frame, "WA_InputBoxTemplate")
filterInput:SetAutoFocus(false)
filterInput:SetTextInsets(16, 20, 0, 0)
filterInput.Instructions = filterInput:CreateFontString(nil, "ARTWORK", "GameFontDisableSmall")
filterInput.Instructions:SetText(SEARCH)
filterInput.Instructions:SetPoint("TOPLEFT", filterInput, "TOPLEFT", 16, 0)
filterInput.Instructions:SetPoint("BOTTOMRIGHT", filterInput, "BOTTOMRIGHT", -20, 0)
filterInput.Instructions:SetTextColor(0.35, 0.35, 0.35)
filterInput.Instructions:SetJustifyH("LEFT")
filterInput.Instructions:SetJustifyV("MIDDLE")
filterInput.searchIcon = filterInput:CreateTexture(nil, "OVERLAY")
filterInput.searchIcon:SetTexture("Interface\\Common\\UI-Searchbox-Icon")
filterInput.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
filterInput.searchIcon:SetSize(14, 14)
filterInput.searchIcon:SetPoint("LEFT", 0, -2)
filterInput.clearButton = CreateFrame("Button", nil, filterInput)
filterInput.clearButton:SetSize(14, 14)
filterInput.clearButton:SetPoint("RIGHT", -3, 0)
filterInput.clearButton.texture = filterInput.clearButton:CreateTexture()
filterInput.clearButton.texture:SetTexture("Interface\\FriendsFrame\\ClearBroadcastIcon")
filterInput.clearButton.texture:SetAlpha(0.5)
filterInput.clearButton.texture:SetSize(17, 17)
filterInput.clearButton.texture:SetPoint("CENTER", 0, 0)
filterInput.clearButton:SetScript("OnEnter", function(self) self.texture:SetAlpha(1.0) end)
filterInput.clearButton:SetScript("OnLeave", function(self) self.texture:SetAlpha(0.5) end)
filterInput.clearButton:SetScript("OnMouseDown", function(self) if self:IsEnabled() then self.texture:SetPoint("CENTER", 1, -1) end end)
filterInput.clearButton:SetScript("OnMouseUp", function(self) self.texture:SetPoint("CENTER") end)
filterInput.clearButton:SetScript("OnClick", function(self)
local editBox = self:GetParent()
editBox:SetText("")
editBox:ClearFocus()
end)
filterInput:SetScript("OnEditFocusLost", function(self)
if self:GetText() == "" then
self.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
self.clearButton:Hide()
end
end)
filterInput:SetScript("OnEditFocusGained", function(self)
self.searchIcon:SetVertexColor(1.0, 1.0, 1.0)
self.clearButton:Show()
end)
filterInput:HookScript("OnTextChanged", function(self)
if not self:HasFocus() and self:GetText() == "" then
self.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
self.clearButton:Hide()
else
self.searchIcon:SetVertexColor(1.0, 1.0, 1.0)
self.clearButton:Show()
end
if self:GetText() == "" then
self.Instructions:Show()
else
self.Instructions:Hide()
end
local filterInput = CreateFrame("EditBox", "WeakAurasFilterInput", frame)
WeakAuras.XMLTemplates["SearchBoxTemplate"](filterInput)
filterInput:SetScript("OnTextChanged", function(self)
WA_SearchBoxTemplate_OnTextChanged(self)
OptionsPrivate.SortDisplayButtons(filterInput:GetText())
end)
filterInput:SetHeight(15)
@@ -1032,7 +979,8 @@ function OptionsPrivate.CreateFrame()
sidegroup.frame:Show()
sidegroup:SetLayout("flow")
local dynamicTextCodesFrame = CreateFrame("Frame", "WeakAurasTextReplacements", sidegroup.frame, "WA_PortraitFrameTemplate")
local dynamicTextCodesFrame = CreateFrame("Frame", "WeakAurasTextReplacements", sidegroup.frame)
WeakAuras.XMLTemplates["PortraitFrameTemplate"](dynamicTextCodesFrame)
dynamicTextCodesFrame:HidePortrait()
dynamicTextCodesFrame:SetPoint("TOPLEFT", sidegroup.frame, "TOPRIGHT", 20, 0)
dynamicTextCodesFrame:SetPoint("BOTTOMLEFT", sidegroup.frame, "BOTTOMRIGHT", 20, 0)
@@ -1408,7 +1356,7 @@ function OptionsPrivate.CreateFrame()
containerScroll:SetLayout("flow")
border:AddChild(containerScroll)
local _, _, _, enabled = GetAddOnInfo("WeakAurasTemplates")
local enabled = select(4, GetAddOnInfo("WeakAurasTemplates"))
if enabled then
local simpleLabel = AceGUI:Create("Label")
simpleLabel:SetFont(STANDARD_TEXT_FONT, 24, "OUTLINE")
+10 -64
View File
@@ -420,7 +420,8 @@ local function ConstructTextEditor(frame)
local apiSearchFrame
-- Make sidebar for snippets
local snippetsFrame = CreateFrame("Frame", "WeakAurasSnippets", group.frame, "WA_PortraitFrameTemplate")
local snippetsFrame = CreateFrame("Frame", "WeakAurasSnippets", group.frame)
WeakAuras.XMLTemplates["PortraitFrameTemplate"](snippetsFrame)
snippetsFrame:HidePortrait()
snippetsFrame:SetPoint("TOPLEFT", group.frame, "TOPRIGHT", 20, 0)
snippetsFrame:SetPoint("BOTTOMLEFT", group.frame, "BOTTOMRIGHT", 20, 0)
@@ -505,7 +506,8 @@ local function ConstructTextEditor(frame)
apiSearchButton:RegisterForClicks("LeftButtonUp")
-- Make sidebar for apiSearch
apiSearchFrame = CreateFrame("Frame", "WeakAurasAPISearchFrame", group.frame, "WA_PortraitFrameTemplate")
apiSearchFrame = CreateFrame("Frame", "WeakAurasAPISearchFrame", group.frame)
WeakAuras.XMLTemplates["PortraitFrameTemplate"](apiSearchFrame)
apiSearchFrame:HidePortrait()
apiSearchFrame:SetWidth(350)
@@ -514,54 +516,11 @@ local function ConstructTextEditor(frame)
local APISearchCTimer
-- filter line
local filterInput = CreateFrame("EditBox", "WeakAurasAPISearchFilterInput", apiSearchFrame, "WA_InputBoxTemplate")
filterInput:SetAutoFocus(false)
filterInput:SetTextInsets(16, 20, 0, 0)
filterInput.Instructions = filterInput:CreateFontString(nil, "ARTWORK", "GameFontDisableSmall")
filterInput.Instructions:SetText(SEARCH)
filterInput.Instructions:SetPoint("TOPLEFT", filterInput, "TOPLEFT", 16, 0)
filterInput.Instructions:SetPoint("BOTTOMRIGHT", filterInput, "BOTTOMRIGHT", -20, 0)
filterInput.Instructions:SetTextColor(0.35, 0.35, 0.35)
filterInput.Instructions:SetJustifyH("LEFT")
filterInput.Instructions:SetJustifyV("MIDDLE")
filterInput.searchIcon = filterInput:CreateTexture(nil, "OVERLAY")
filterInput.searchIcon:SetTexture("Interface\\Common\\UI-Searchbox-Icon")
filterInput.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
filterInput.searchIcon:SetSize(14, 14)
filterInput.searchIcon:SetPoint("LEFT", 0, -2)
filterInput.clearButton = CreateFrame("Button", nil, filterInput)
filterInput.clearButton:SetSize(14, 14)
filterInput.clearButton:SetPoint("RIGHT", -3, 0)
filterInput.clearButton.texture = filterInput.clearButton:CreateTexture()
filterInput.clearButton.texture:SetTexture("Interface\\FriendsFrame\\ClearBroadcastIcon")
filterInput.clearButton.texture:SetAlpha(0.5)
filterInput.clearButton.texture:SetSize(17, 17)
filterInput.clearButton.texture:SetPoint("CENTER", 0, 0)
filterInput.clearButton:SetScript("OnEnter", function(self) self.texture:SetAlpha(1.0) end)
filterInput.clearButton:SetScript("OnLeave", function(self) self.texture:SetAlpha(0.5) end)
filterInput.clearButton:SetScript("OnMouseDown", function(self) if self:IsEnabled() then self.texture:SetPoint("CENTER", 1, -1) end end)
filterInput.clearButton:SetScript("OnMouseUp", function(self) self.texture:SetPoint("CENTER") end)
filterInput.clearButton:SetScript("OnClick", function(self)
local editBox = self:GetParent()
editBox:SetText("")
editBox:ClearFocus()
end)
filterInput:SetScript("OnEditFocusLost", function(self)
if self:GetText() == "" then
self.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
self.clearButton:Hide()
end
end)
filterInput:SetScript("OnEditFocusGained", function(self)
self.searchIcon:SetVertexColor(1.0, 1.0, 1.0)
self.clearButton:Show()
end)
local filterInput = CreateFrame("EditBox", "WeakAurasAPISearchFilterInput", apiSearchFrame)
WeakAuras.XMLTemplates["SearchBoxTemplate"](filterInput)
filterInput:SetFrameLevel(5)
filterInput:SetScript("OnTextChanged", function(self)
WA_SearchBoxTemplate_OnTextChanged(self)
if APISearchCTimer and WeakAuras.timer:TimeLeft(APISearchCTimer) then
WeakAuras.timer:CancelTimer(APISearchCTimer)
end
@@ -572,20 +531,6 @@ local function ConstructTextEditor(frame)
APISearchTextChangeDelay
)
end)
filterInput:HookScript("OnTextChanged", function(self)
if not self:HasFocus() and self:GetText() == "" then
self.searchIcon:SetVertexColor(0.6, 0.6, 0.6)
self.clearButton:Hide()
else
self.searchIcon:SetVertexColor(1.0, 1.0, 1.0)
self.clearButton:Show()
end
if self:GetText() == "" then
self.Instructions:Show()
else
self.Instructions:Hide()
end
end)
filterInput:SetHeight(15)
filterInput:SetPoint("TOPLEFT", apiSearchFrame, "TOPLEFT", 17, -30)
filterInput:SetPoint("TOPRIGHT", apiSearchFrame, "TOPRIGHT", -10, -30)
@@ -890,7 +835,8 @@ local function ConstructTextEditor(frame)
editorError:SetPoint("RIGHT", settings_frame, "LEFT")
group.editorError = editorError
local editorLine = CreateFrame("EditBox", nil, group.frame, "WA_InputBoxTemplate")
local editorLine = CreateFrame("EditBox", nil, group.frame)
WeakAuras.XMLTemplates["InputBoxTemplate"](editorLine)
-- Set script on enter pressed..
editorLine:SetPoint("RIGHT", snippetsButton, "LEFT", -10, 0)
editorLine:SetFont(STANDARD_TEXT_FONT, 10)