from retail

This commit is contained in:
NoM0Re
2025-01-25 23:37:36 +01:00
parent 4a326118da
commit 667a2f3f50
34 changed files with 788 additions and 242 deletions
+91 -18
View File
@@ -13,6 +13,7 @@ local GetScreenWidth, GetScreenHeight, CreateFrame, GetAddOnInfo, UnitName
local AceGUI = LibStub("AceGUI-3.0")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local AceConfigRegistry = LibStub("AceConfigRegistry-3.0")
local SharedMedia = LibStub("LibSharedMedia-3.0")
local WeakAuras = WeakAuras
local L = WeakAuras.L
@@ -344,15 +345,33 @@ function OptionsPrivate.CreateFrame()
tipPopupTitle:SetJustifyV("TOP")
local tipPopupLabel = tipPopup:CreateFontString(nil, "BACKGROUND", "GameFontWhite")
local fontPath = SharedMedia:Fetch("font", "Fira Sans Medium")
if (fontPath) then
tipPopupLabel:SetFont(fontPath, 12)
end
tipPopupLabel:SetPoint("TOPLEFT", tipPopupTitle, "BOTTOMLEFT", 0, -6)
tipPopupLabel:SetPoint("TOPRIGHT", tipPopupTitle, "BOTTOMRIGHT", 0, -6)
tipPopupLabel:SetJustifyH("LEFT")
tipPopupLabel:SetJustifyV("TOP")
local tipPopupLabelCJ = tipPopup:CreateFontString(nil, "BACKGROUND", "GameFontWhite")
tipPopupLabelCJ:SetFont("Fonts\\ARKai_T.ttf", 12)
tipPopupLabelCJ:SetPoint("TOPLEFT", tipPopupLabel, "BOTTOMLEFT", 0, 0)
tipPopupLabelCJ:SetPoint("TOPRIGHT", tipPopupLabel, "BOTTOMRIGHT", 0, 0)
tipPopupLabelCJ:SetJustifyH("LEFT")
tipPopupLabelCJ:SetJustifyV("TOP")
local tipPopupLabelK = tipPopup:CreateFontString(nil, "BACKGROUND", "GameFontWhite")
tipPopupLabelK:SetFont("Fonts\\K_Pagetext.TTF", 12)
tipPopupLabelK:SetPoint("TOPLEFT", tipPopupLabelCJ, "BOTTOMLEFT", 0, 0)
tipPopupLabelK:SetPoint("TOPRIGHT", tipPopupLabelCJ, "BOTTOMRIGHT", 0, 0)
tipPopupLabelK:SetJustifyH("LEFT")
tipPopupLabelK:SetJustifyV("TOP")
local urlWidget = CreateFrame("EditBox", nil, tipPopup, "WA_InputBoxTemplate")
urlWidget:SetFont(STANDARD_TEXT_FONT, 12)
urlWidget:SetPoint("TOPLEFT", tipPopupLabel, "BOTTOMLEFT", 6, 0)
urlWidget:SetPoint("TOPRIGHT", tipPopupLabel, "BOTTOMRIGHT", 0, 0)
urlWidget:SetPoint("TOPLEFT", tipPopupLabelK, "BOTTOMLEFT", 6, 0)
urlWidget:SetPoint("TOPRIGHT", tipPopupLabelK, "BOTTOMRIGHT", 0, 0)
urlWidget:SetScript("OnChar", function() urlWidget:SetText(urlWidget.text); urlWidget:HighlightText(); end);
urlWidget:SetScript("OnMouseUp", function() urlWidget:HighlightText(); end);
urlWidget:SetScript("OnEscapePressed", function() tipPopup:Hide() end)
@@ -365,7 +384,8 @@ function OptionsPrivate.CreateFrame()
tipPopupCtrlC:SetJustifyV("TOP")
tipPopupCtrlC:SetText(L["Press Ctrl+C to copy the URL"])
local function ToggleTip(referenceWidget, url, title, description, rightAligned)
local function ToggleTip(referenceWidget, url, title, description, descriptionCJ, descriptionK, rightAligned, width)
width = width or 400
if tipPopup:IsVisible() and urlWidget.text == url then
tipPopup:Hide()
return
@@ -374,64 +394,117 @@ function OptionsPrivate.CreateFrame()
urlWidget:SetText(url)
tipPopupTitle:SetText(title)
tipPopupLabel:SetText(description)
tipPopupLabelCJ:SetText(descriptionCJ)
tipPopupLabelK:SetText(descriptionK)
urlWidget:HighlightText()
tipPopup:SetWidth(400)
tipPopup:SetHeight(26 + tipPopupTitle:GetHeight() + tipPopupLabel:GetHeight() + urlWidget:GetHeight() + tipPopupCtrlC:GetHeight())
tipPopup:ClearAllPoints();
if rightAligned then
tipPopup:SetPoint("BOTTOMRIGHT", referenceWidget, "TOPRIGHT", 6, 4)
else
tipPopup:SetPoint("BOTTOMLEFT", referenceWidget, "TOPLEFT", -6, 4)
end
tipPopup:SetWidth(width)
tipPopup:Show()
tipPopup:SetHeight(26 + tipPopupTitle:GetHeight() + tipPopupLabel:GetHeight() + tipPopupLabelCJ:GetHeight() + tipPopupLabelK:GetHeight()
+ urlWidget:GetHeight() + tipPopupCtrlC:GetHeight())
-- This does somehow fix an issue where the first popup after a game restart doesn't show up.
-- This isn't reproducable after a simple ui reload, so no idea what goes wrong, but with this line here,
-- it seems to work.
tipPopupLabel:GetRect()
tipPopupLabelCJ:GetRect()
tipPopupLabelK:GetRect()
end
OptionsPrivate.ToggleTip = ToggleTip
local addFooter = function(title, texture, url, description, rightAligned)
local addFooter = function(title, texture, url, description, descriptionCJ, descriptionK, rightAligned, width)
local button = AceGUI:Create("WeakAurasToolbarButton")
button:SetText(title)
button:SetTexture(texture)
button:SetCallback("OnClick", function()
ToggleTip(button.frame, url, title, description, rightAligned)
ToggleTip(button.frame, url, title, description, descriptionCJ, descriptionK, rightAligned, width)
end)
button.frame:Show()
return button.frame
end
local function lineWrapDiscordList(list)
local patreonLines = {}
local lineLength = 0
local currentLine = {}
for _, patreon in ipairs(list) do
if lineLength + #patreon + 2 * #currentLine > 130 then
tinsert(patreonLines, table.concat(currentLine, ", ") .. ", ")
currentLine = {}
tinsert(currentLine, patreon)
lineLength = #patreon
else
lineLength = lineLength + #patreon
tinsert(currentLine, patreon)
end
end
if #currentLine > 0 then
tinsert(patreonLines, table.concat(currentLine, ", "))
end
return table.concat(patreonLines, "\n")
end
local thanksList = L["We thank"] .. "\n"
.. L["All maintainers of the libraries we use, especially:"] .. "\n"
.. "" .. L["Ace: Funkeh, Nevcairiel"] .. "\n"
.. "" .. L["LibCompress: Galmok"] .. "\n"
.. "" .. L["LibCustomGlow: Dooez"] .. "\n"
.. "" .. L["LibDeflate: Yoursafety"] .. "\n"
.. "" .. L["LibDispel: Simpy"] .. "\n"
.. "" .. L["LibSerialize: Sanjo"] .. "\n"
.. "" .. L["LibSpecialization: Funkeh"] .. "\n"
.. "" .. L["Our translators (too many to name)"] .. "\n"
.. "" .. L["And our Patreons, Discord Regulars and Subscribers, and Friends of the Addon:"] .. "\n"
thanksList = thanksList .. lineWrapDiscordList(OptionsPrivate.Private.DiscordList)
local thanksListCJ = lineWrapDiscordList(OptionsPrivate.Private.DiscordListCJ)
local thanksListK = lineWrapDiscordList(OptionsPrivate.Private.DiscordListK)
local discordButton = addFooter(L["Join Discord"], [[Interface\AddOns\WeakAuras\Media\Textures\discord.tga]], "https://discord.gg/UXSc7nt",
L["Chat with WeakAuras experts on our Discord server."])
L["Chat with WeakAuras experts on our Discord server."])
discordButton:SetParent(tipFrame)
discordButton:SetPoint("LEFT", tipFrame, "LEFT")
local documentationButton = addFooter(L["Documentation"], [[Interface\AddOns\WeakAuras\Media\Textures\GitHub.tga]], "https://github.com/WeakAuras/WeakAuras2/wiki",
L["Check out our wiki for a large collection of examples and snippets."])
L["Check out our wiki for a large collection of examples and snippets."])
documentationButton:SetParent(tipFrame)
documentationButton:SetPoint("LEFT", discordButton, "RIGHT", 10, 0)
local thanksButton = addFooter(L["Thanks"], [[Interface\AddOns\WeakAuras\Media\Textures\waheart.tga]],
"https://www.patreon.com/WeakAuras", thanksList, thanksListCJ, thanksListK, nil, 800)
thanksButton:SetParent(tipFrame)
thanksButton:SetPoint("LEFT", documentationButton, "RIGHT", 10, 0)
local awesomeWotlkButton
if not WeakAuras.isAwesomeEnabled() then
awesomeWotlkButton = addFooter("Awesome WotLK", [[Interface\AddOns\WeakAuras\Media\Textures\GitHub.tga]], "https://github.com/FrostAtom/awesome_wotlk",
L["Unlock Nameplate anchoring and units in WeakAuras with awesome_wotlk client patch!"])
awesomeWotlkButton = addFooter("Awesome WotLK", [[Interface\AddOns\WeakAuras\Media\Textures\GitHub.tga]], "https://github.com/FrostAtom/awesome_wotlk/releases",
L["Unlock nameplate anchoring & units in WeakAuras with the awesome_wotlk client patch"])
awesomeWotlkButton:SetParent(tipFrame)
awesomeWotlkButton:SetPoint("LEFT", documentationButton, "RIGHT", 10, 0)
awesomeWotlkButton:SetPoint("LEFT", thanksButton, "RIGHT", 10, 0)
end
local reportbugButton = addFooter(L["Found a Bug?"], [[Interface\AddOns\WeakAuras\Media\Textures\bug_report.tga]], "https://github.com/Bunny67/WeakAuras-WotLK/issues/new?assignees=&labels=bug&template=bug_report.md&title=",
L["Report bugs on our issue tracker."], true)
local reportbugButton = addFooter(L["Found a Bug?"], [[Interface\AddOns\WeakAuras\Media\Textures\bug_report.tga]], "https://github.com/NoM0Re/WeakAuras-WotLK/issues",
L["Report bugs on our issue tracker."], nil, nil, true)
reportbugButton:SetParent(tipFrame)
reportbugButton:SetPoint("RIGHT", tipFrame, "RIGHT")
local wagoButton = addFooter(L["Find Auras"], [[Interface\AddOns\WeakAuras\Media\Textures\wago.tga]], "https://wago.io",
L["Browse Wago, the largest collection of auras."], true)
local wagoButton = addFooter(L["Find Auras"], [[Interface\AddOns\WeakAuras\Media\Textures\wago.tga]], "https://wago.io/search/imports/wow/all?q=3.3.5",
L["Browse Wago, the largest collection of auras."], nil, nil, true)
wagoButton:SetParent(tipFrame)
wagoButton:SetPoint("RIGHT", reportbugButton, "LEFT", -10, 0)
local companionButton
if not OptionsPrivate.Private.CompanionData.slugs then
companionButton = addFooter(L["Update Auras"], [[Interface\AddOns\WeakAuras\Media\Textures\wagoupdate_refresh.tga]], "https://weakauras.wtf",
L["Keep your Wago imports up to date with the Companion App."])
L["Keep your Wago imports up to date with the Companion App."])
companionButton:SetParent(tipFrame)
companionButton:SetPoint("RIGHT", wagoButton, "LEFT", -10, 0)
end
@@ -3,7 +3,6 @@ local AddonName, OptionsPrivate = ...
-- Lua APIs
local pairs, type, ipairs = pairs, type, ipairs
local loadstring = loadstring
local gsub = gsub
-- WoW APIs
@@ -182,6 +181,7 @@ local function ConstructTextEditor(frame)
-- The indention lib overrides GetText, but for the line number
-- display we ned the original, so save it here.
local originalGetText = editor.editBox.GetText
local originalSetText = editor.editBox.SetText
set_scheme()
IndentationLib.enable(editor.editBox, color_scheme, WeakAurasSaved.editor_tab_spaces)
@@ -517,7 +517,7 @@ local function ConstructTextEditor(frame)
if self.timeMachine[self.timeMachinePos + 1] then
self.timeMachinePos = self.timeMachinePos + 1
self.skipOnTextChanged = true
self:SetText(self.timeMachine[self.timeMachinePos][1])
originalSetText(self, self.timeMachine[self.timeMachinePos][1])
self:SetCursorPosition(self.timeMachine[self.timeMachinePos][2])
end
elseif IsControlKeyDown() and key == "Y" then
@@ -525,7 +525,7 @@ local function ConstructTextEditor(frame)
if self.timeMachine[self.timeMachinePos - 1] then
self.timeMachinePos = self.timeMachinePos - 1
self.skipOnTextChanged = true
self:SetText(self.timeMachine[self.timeMachinePos][1])
originalSetText(self, self.timeMachine[self.timeMachinePos][1])
self:SetCursorPosition(self.timeMachine[self.timeMachinePos][2])
end
end
@@ -705,15 +705,12 @@ local function ConstructTextEditor(frame)
else
local func, errorString
if (enclose) then
func, errorString = loadstring("return function() " .. str .. "\n end")
func, errorString = OptionsPrivate.Private.LoadFunction("return function() " .. str .. "\n end", true)
else
func, errorString = loadstring("return " .. str)
func, errorString = OptionsPrivate.Private.LoadFunction("return " .. str, true)
end
if not errorString and validator then
local ok, validate = xpcall(func, function(err) errorString = err end)
if ok then
errorString = validator(validate)
end
errorString = validator(func)
end
if errorString then
if self.url then
+48 -21
View File
@@ -739,6 +739,7 @@ local function BuildUidMap(data, children, type)
for _, childUid in ipairs(children) do
self:EnsureUniqueIdOfUnmatched(childUid, IncProgress)
end
coroutine.yield(0.1, "ensure unique uids")
end
uidMap.InsertUnmatchedPhase1 = function(self, otherUidMap, otherUid, IncProgress)
@@ -777,10 +778,10 @@ local function BuildUidMap(data, children, type)
end
else
IncProgress()
coroutine.yield()
coroutine.yield(0.1)
end
end
coroutine.yield()
coroutine.yield(0.1)
end
for uid, otherList in pairs(matchToInsert) do
@@ -800,8 +801,9 @@ local function BuildUidMap(data, children, type)
otherUidMap:SetUIDMatch(otherUid, otherUid) -- Uids are the same!
self:SetUIDMatch(otherUid, otherUid)
IncProgress()
coroutine.yield()
coroutine.yield(0.1)
end
coroutine.yield(0.1)
end
if otherList.after then
@@ -815,11 +817,12 @@ local function BuildUidMap(data, children, type)
otherUidMap:SetUIDMatch(otherUid, otherUid) -- Uids are the same!
self:SetUIDMatch(otherUid, otherUid)
IncProgress()
coroutine.yield()
coroutine.yield(0.1)
end
coroutine.yield(0.1)
end
end
coroutine.yield()
coroutine.yield(0.1)
end
for _, otherUid in ipairs(waitingForMatch) do
@@ -839,7 +842,7 @@ local function BuildUidMap(data, children, type)
otherUidMap:SetUIDMatch(otherUid, otherUid) -- Uids are the same!
self:SetUIDMatch(otherUid, otherUid)
IncProgress()
coroutine.yield()
coroutine.yield(0.1)
end
return #waitingForMatch > 0
@@ -1621,7 +1624,7 @@ local methods = {
end
end,
Import = function(self)
OptionsPrivate.Private.dynFrame:AddAction("import", coroutine.create(function()
OptionsPrivate.Private.Threads:Add("import", coroutine.create(function()
self:ImportImpl()
end))
end,
@@ -1634,27 +1637,34 @@ local methods = {
self.closeButton:Disable()
self.viewCodeButton:Disable()
OptionsPrivate.Private.SetImporting(true)
coroutine.yield(10, "init")
-- Adjust UI
self:ReleaseChildren()
self:AddBasicInformationWidgets(pendingData.data, pendingData.sender)
self:AddProgressWidgets()
local copies = {}
local pendingPickData
if userChoices.mode == "import" then
coroutine.yield(0.1, "start import")
self:InitializeProgress(2 * (#pendingData.children + 1))
EnsureUniqueUid(pendingData.data)
coroutine.yield(0.1, "ensure unique uids")
for i, child in ipairs(pendingData.children) do
EnsureUniqueUid(child)
coroutine.yield(0.1, "ensure unique uids")
end
coroutine.yield(1, "build uid map")
local uidMap = BuildUidMap(pendingData.data, pendingData.children, "new")
local phase2Order = {}
coroutine.yield(1, "start phase 1")
self:ImportPhase1(uidMap, uidMap:GetRootUID(), phase2Order)
self:ImportPhase2(uidMap, phase2Order)
coroutine.yield(1, "start phase 2")
self:ImportPhase2(uidMap, phase2Order, copies)
pendingPickData = {
id = uidMap:GetIdFor(uidMap:GetRootUID())
@@ -1662,9 +1672,10 @@ local methods = {
if #pendingData.children > 0 then
pendingPickData.tabToShow = "group"
end
coroutine.yield(1, "update ui")
OptionsPrivate.SortDisplayButtons()
elseif userChoices.mode == "update" then
coroutine.yield(0.1, "start update")
local onePhaseProgress = matchInfo.oldUidMap:GetTotalCount() + matchInfo.newUidMap:GetTotalCount()
local IncProgress = function() self:IncProgress() end
@@ -1677,9 +1688,9 @@ local methods = {
-- On update, we won't match A_new to A_old, because A_old is outside the matched parent group
-- Thus on import A_new needs to get its own uid
-- On next import, the auras uids won't match either, there's not much we can do about that.
coroutine.yield(0.1, "ensure unique uids")
matchInfo.newUidMap:EnsureUniqueIdOfUnmatched(nil, IncProgress)
self:SetMinimumProgress(1 * onePhaseProgress)
coroutine.yield()
local removeOldGroups = matchInfo.activeCategories.arrangement and userChoices.activeCategories.arrangement
if userChoices.activeCategories.oldchildren or removeOldGroups then
@@ -1709,6 +1720,7 @@ local methods = {
if not userChoices.activeCategories.oldchildren then
-- Keep old children
matchInfo.newUidMap:InsertUnmatchedFrom(matchInfo.oldUidMap, IncProgress)
coroutine.yield(0.1, "keep old children done")
end
self:SetMinimumProgress(4 * onePhaseProgress)
@@ -1775,17 +1787,26 @@ local methods = {
end
end
coroutine.yield(10, "prep done")
local phase2Order = {}
self:UpdatePhase1(structureUidMap, structureUidMap:GetRootUID(), GetPhase1Data, phase2Order)
self:SetMinimumProgress(16 * onePhaseProgress)
coroutine.yield(10, " phase 1 done")
self:UpdatePhase2(structureUidMap, GetPhase2Data, phase2Order, copies)
self:UpdatePhase2(structureUidMap, GetPhase2Data, phase2Order)
self:SetMinimumProgress(26 * onePhaseProgress)
coroutine.yield(10, " phase 2 done")
local renameTries = 0
while(self:RenameAuras(targetNames)) do
-- Try renaming again and again...
renameTries = renameTries + 1
if renameTries % 10 == 0 then
coroutine.yield(0.1, "renaming auras")
end
end
self:SetMaxProgress()
coroutine.yield()
coroutine.yield(0.1, "renaming auras done")
pendingPickData = {
id = OptionsPrivate.Private.GetDataByUID(matchInfo.oldUidMap:GetRootUID()).id
@@ -1796,7 +1817,7 @@ local methods = {
OptionsPrivate.SortDisplayButtons()
end
coroutine.yield(0.1, "winding down")
OptionsPrivate.Private.SetImporting(false)
self.viewCodeButton:Enable()
self.importButton:Enable()
@@ -1809,6 +1830,12 @@ local methods = {
OptionsPrivate.ClearPicks()
WeakAuras.PickDisplay(pendingPickData.id, pendingPickData.tabToShow)
end
OptionsPrivate.Private.Threads:Add("history_update", coroutine.create(function()
for _, copy in ipairs(copies) do
OptionsPrivate.Private.SetHistory(copy.uid, copy.data, copy.source)
coroutine.yield()
end
end), "background")
end,
-- This ensures that the id that we are adding is either
-- same for existing uids
@@ -1930,7 +1957,7 @@ local methods = {
end
end
self:IncProgress()
coroutine.yield()
coroutine.yield(0.1, "remove unmatched old")
return false
end,
RemoveUnmatchedNew = function(self, uidMap, uid, otherMap, removeAuras, removeGroups)
@@ -1966,7 +1993,7 @@ local methods = {
end
end
self:IncProgress()
coroutine.yield()
coroutine.yield(0.1, "remove unmatched new")
return false
end,
UpdatePhase1 = function(self, structureUidMap, uid, GetPhase1Data, phase2Order)
@@ -1980,7 +2007,7 @@ local methods = {
WeakAuras.Add(data)
WeakAuras.NewDisplayButton(data, true)
self:IncProgress10()
coroutine.yield()
coroutine.yield(1, "adding phase 1 data")
local children = structureUidMap:GetChildren(uid)
local parentIsDynamicGroup = data.regionType == "dynamicgroup"
@@ -1990,14 +2017,14 @@ local methods = {
structureUidMap:SetParentIsDynamicGroup(childUid, parentIsDynamicGroup)
end
end,
UpdatePhase2 = function(self, structureUidMap, GetPhase2Data, phase2Order)
UpdatePhase2 = function(self, structureUidMap, GetPhase2Data, phase2Order, copies)
for i = #phase2Order, 1, -1 do
local uid = phase2Order[i]
local data = GetPhase2Data(uid)
data.preferToUpdate = true
data.authorMode = nil
WeakAuras.Add(data)
OptionsPrivate.Private.SetHistory(data.uid, data, "import")
table.insert(copies, {uid = uid, data = CopyTable(data), source = "update"})
local button = OptionsPrivate.GetDisplayButton(data.id)
button:SetData(data)
if (data.parent) then
@@ -2051,14 +2078,14 @@ local methods = {
uidMap:SetParentIsDynamicGroup(childUid, parentIsDynamicGroup)
end
end,
ImportPhase2 = function(self, uidMap, phase2Order)
ImportPhase2 = function(self, uidMap, phase2Order, copies)
for i = #phase2Order, 1, -1 do
local uid = phase2Order[i]
local data = uidMap:GetPhase2Data(uid)
data.preferToUpdate = false
data.authorMode = nil
WeakAuras.Add(data)
OptionsPrivate.Private.SetHistory(data.uid, data, "import")
table.insert(copies, {uid = uid, data = CopyTable(data), source = "import"})
local button = OptionsPrivate.GetDisplayButton(data.id)
button:SetData(data)