From 8e66a08c64b5c55242f63ba3a0764d8db1e1f9c3 Mon Sep 17 00:00:00 2001 From: Ade <923+ade@noreply.octowow.st> Date: Thu, 8 Oct 2026 06:07:28 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui_panel.lua | 220 +++++++++++++++++++++++++++++++++++++++++ ui_profs.lua | 94 ++++++++++++++++++ ui_show.lua | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 588 insertions(+) create mode 100644 ui_panel.lua create mode 100644 ui_profs.lua create mode 100644 ui_show.lua diff --git a/ui_panel.lua b/ui_panel.lua new file mode 100644 index 0000000..08cac86 --- /dev/null +++ b/ui_panel.lua @@ -0,0 +1,220 @@ +-- Ade Alts: ui_panel +local AA = AdeAlts + +-- main panel ---------------------------------------------------------- +AA.P = CreateFrame("Frame", nil, AA.M) +AA.P:SetWidth(558) +AA.P:SetHeight(350) +AA.P:SetPoint("TOPLEFT", AA.M, "TOPLEFT", 210, -66) +AA.SkinFrame(AA.P, 0.6) + +AA.hIcon = AA.P:CreateTexture(nil, "ARTWORK") +AA.hIcon:SetWidth(36) +AA.hIcon:SetHeight(36) +AA.hIcon:SetPoint("TOPLEFT", AA.P, "TOPLEFT", 10, -8) +AA.hName = AA.P:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") +AA.hName:SetPoint("TOPLEFT", AA.hIcon, "TOPRIGHT", 8, -2) +AA.hInfo = AA.P:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") +AA.hInfo:SetPoint("TOPLEFT", AA.hName, "BOTTOMLEFT", 0, -3) +AA.hGold = AA.P:CreateFontString(nil, "OVERLAY", "GameFontHighlight") +AA.hGold:SetPoint("TOPRIGHT", AA.P, "TOPRIGHT", -12, -10) +AA.hGold:SetJustifyH("RIGHT") +AA.hAge = AA.P:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") +AA.hAge:SetPoint("TOPRIGHT", AA.P, "TOPRIGHT", -12, -28) +AA.hAge:SetJustifyH("RIGHT") +AA.hProf = AA.P:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") +AA.hProf:SetPoint("TOPLEFT", AA.hInfo, "BOTTOMLEFT", 0, -3) +AA.hProf:SetJustifyH("LEFT") +AA.hdr = { AA.hIcon, AA.hName, AA.hInfo, AA.hGold, AA.hAge, AA.hProf } + +AA.tabs = {} +local function MakeTab(key, label, x) + local b = CreateFrame("Button", "AdeAltsTab" .. key, AA.P, "UIPanelButtonTemplate") + b:SetWidth(110) + b:SetHeight(20) + b:SetPoint("TOPLEFT", AA.P, "TOPLEFT", x, -58) + b:SetText(label) + b.key = key + b:SetScript("OnClick", function() + AA.view = this.key + AA.db.view = AA.view + AA.RefreshManager() + end) + AA.tabs[key] = b + table.insert(AA.hdr, b) +end +MakeTab("bags", "Bags & Bank", 8) +MakeTab("equip", "Equipment", 122) +MakeTab("profs", "Professions", 236) + +local function UpdateGrid(B) + local n = table.getn(B.list) + FauxScrollFrame_Update(B.sf, math.ceil(n / AA.COLS), AA.GROWS, AA.CELL) + local off = FauxScrollFrame_GetOffset(B.sf) + for r = 1, AA.GROWS do + for c = 1, AA.COLS do + local b = B.cells[(r - 1) * AA.COLS + c] + local e = B.list[(off + r - 1) * AA.COLS + c] + if b then + if e then + b.itemId = e[1] + b.icon:SetTexture(AA.ItemTex(e[1])) + if e[2] > 1 then b.count:SetText(tostring(e[2])) else b.count:SetText("") end + local qr, qg, qb = AA.ItemColor(e[1]) + b:SetBackdropBorderColor(qr, qg, qb, 1) + b:Show() + else + b.itemId = nil + b:Hide() + end + end + end + end +end + +function AA.AddCell(B) + local b = CreateFrame("Button", nil, B) + b:SetWidth(AA.CELL - 2) + b:SetHeight(AA.CELL - 2) + b:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + tile = true, tileSize = 8, edgeSize = 8, + insets = { left = 2, right = 2, top = 2, bottom = 2 }, + }) + b:SetBackdropColor(0.05, 0.05, 0.05, 0.9) + b.icon = b:CreateTexture(nil, "ARTWORK") + b.icon:SetPoint("TOPLEFT", b, "TOPLEFT", 3, -3) + b.icon:SetPoint("BOTTOMRIGHT", b, "BOTTOMRIGHT", -3, 3) + b.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) + b.count = b:CreateFontString(nil, "OVERLAY", "NumberFontNormal") + b.count:SetPoint("BOTTOMRIGHT", b, "BOTTOMRIGHT", -3, 3) + b:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") + b.box = B + b:EnableMouseWheel(true) + b:SetScript("OnMouseWheel", function() AA.ScrollWheel(this.box.sf, AA.CELL) end) + b:SetScript("OnEnter", function() AA.ItemTip(this) end) + b:SetScript("OnLeave", function() GameTooltip:Hide() end) + b:Hide() + table.insert(B.cells, b) +end + +local function MakeBox(ttl, scrollName) + local B = CreateFrame("Frame", nil, AA.P) + B:SetWidth(270) + B:SetHeight(298) + B:SetPoint("TOPLEFT", AA.P, "TOPLEFT", 6, -84) + AA.SkinFrame(B, 0.5) + B.title = B:CreateFontString(nil, "OVERLAY", "GameFontNormal") + B.title:SetPoint("TOPLEFT", B, "TOPLEFT", 10, -7) + B.title:SetText(ttl) + B.note = B:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") + B.note:SetPoint("TOPRIGHT", B, "TOPRIGHT", -10, -9) + B.empty = B:CreateFontString(nil, "OVERLAY", "GameFontDisable") + B.empty:SetPoint("CENTER", B, "CENTER", 0, 0) + B.empty:SetWidth(220) + B.empty:Hide() + B.list = {} + B.cells = {} + B.sf = CreateFrame("ScrollFrame", scrollName, B, "FauxScrollFrameTemplate") + B.sf:SetPoint("TOPLEFT", B, "TOPLEFT", 0, -24) + B.sf:SetPoint("BOTTOMRIGHT", B, "BOTTOMRIGHT", -26, 4) + B.sf:SetScript("OnVerticalScroll", function() + FauxScrollFrame_OnVerticalScroll(AA.CELL, function() UpdateGrid(B) end) + end) + B:EnableMouseWheel(true) + B:SetScript("OnMouseWheel", function() AA.ScrollWheel(this.sf, AA.CELL) end) + return B +end + +AA.BI = MakeBox("Inventory", "AdeAltsInvScroll") +AA.BB = MakeBox("Bank", "AdeAltsBankScroll") + +function AA.SetBoxList(B, list) + B.list = list or {} + AA.ResetScroll(B.sf) + UpdateGrid(B) +end + +-- search results ------------------------------------------------------ +AA.S = CreateFrame("Frame", nil, AA.P) +AA.S:SetWidth(546) +AA.S:SetHeight(338) +AA.S:SetPoint("TOPLEFT", AA.P, "TOPLEFT", 6, -6) +AA.SkinFrame(AA.S, 0.5) +AA.S:Hide() + +AA.stitle = AA.S:CreateFontString(nil, "OVERLAY", "GameFontNormal") +AA.stitle:SetPoint("TOPLEFT", AA.S, "TOPLEFT", 10, -8) + +AA.resList = {} +AA.resRows = {} +AA.ssf = CreateFrame("ScrollFrame", "AdeAltsSearchScroll", AA.S, "FauxScrollFrameTemplate") +AA.ssf:SetPoint("TOPLEFT", AA.S, "TOPLEFT", 0, -26) +AA.ssf:SetPoint("BOTTOMRIGHT", AA.S, "BOTTOMRIGHT", -26, 4) +AA.ssf:SetScript("OnVerticalScroll", function() FauxScrollFrame_OnVerticalScroll(AA.SROWH, AA.UpdateResults) end) +AA.S:EnableMouseWheel(true) +AA.S:SetScript("OnMouseWheel", function() AA.ScrollWheel(AA.ssf, AA.SROWH) end) + +function AA.MakeResRow() + local r = CreateFrame("Button", nil, AA.S) + r:SetHeight(AA.SROWH - 2) + r:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") + r.icon = r:CreateTexture(nil, "ARTWORK") + r.icon:SetWidth(18) + r.icon:SetHeight(18) + r.icon:SetPoint("LEFT", r, "LEFT", 2, 0) + r.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) + r.name = r:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") + r.name:SetPoint("LEFT", r.icon, "RIGHT", 6, 0) + r.name:SetJustifyH("LEFT") + r.cnt = r:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + r.cnt:SetWidth(50) + r.cnt:SetJustifyH("RIGHT") + r.who = r:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") + r.who:SetWidth(130) + r.who:SetJustifyH("LEFT") + r.where = r:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") + r.where:SetWidth(90) + r.where:SetJustifyH("LEFT") + r:EnableMouseWheel(true) + r:SetScript("OnMouseWheel", function() AA.ScrollWheel(AA.ssf, AA.SROWH) end) + r:SetScript("OnEnter", function() AA.ItemTip(this) end) + r:SetScript("OnLeave", function() GameTooltip:Hide() end) + r:Hide() + table.insert(AA.resRows, r) +end + +AA.UpdateResults = function() + FauxScrollFrame_Update(AA.ssf, table.getn(AA.resList), AA.SROWS, AA.SROWH) + local off = FauxScrollFrame_GetOffset(AA.ssf) + for i = 1, AA.SROWS do + local r = AA.resRows[i] + local e = AA.resList[off + i] + if r then + if e and e.recipe then + r.itemId = nil + r.icon:SetTexture("Interface\\Icons\\INV_Scroll_03") + r.name:SetText(e.name) + r.name:SetTextColor(0.4, 0.8, 1) + r.cnt:SetText("recipe") + r.who:SetText("|cff" .. AA.ClassHex(e.char.class) .. e.char.name .. "|r") + r.where:SetText(e.where) + r:Show() + elseif e then + r.itemId = e.id + r.icon:SetTexture(AA.ItemTex(e.id)) + r.name:SetText(e.name) + r.name:SetTextColor(AA.ItemColor(e.id)) + r.cnt:SetText("x" .. e.n) + r.who:SetText("|cff" .. AA.ClassHex(e.char.class) .. e.char.name .. "|r") + r.where:SetText(e.where) + r:Show() + else + r.itemId = nil + r:Hide() + end + end + end +end + diff --git a/ui_profs.lua b/ui_profs.lua new file mode 100644 index 0000000..d5fcadb --- /dev/null +++ b/ui_profs.lua @@ -0,0 +1,94 @@ +-- Ade Alts: ui_profs +local AA = AdeAlts + +-- professions view ---------------------------------------------------- +AA.PS = CreateFrame("Frame", nil, AA.P) +AA.PS:SetPoint("TOPLEFT", AA.P, "TOPLEFT", 6, -84) +AA.PS:SetWidth(230) +AA.PS:SetHeight(300) +AA.SkinFrame(AA.PS, 0.5) +AA.PS:Hide() +AA.PS.title = AA.PS:CreateFontString(nil, "OVERLAY", "GameFontNormal") +AA.PS.title:SetPoint("TOPLEFT", AA.PS, "TOPLEFT", 10, -7) +AA.PS.title:SetText("Professions") +AA.PS.empty = AA.PS:CreateFontString(nil, "OVERLAY", "GameFontDisable") +AA.PS.empty:SetPoint("CENTER", AA.PS, "CENTER", 0, 0) +AA.PS.empty:SetWidth(200) +AA.PS.empty:Hide() +AA.PS.rows = {} +for i = 1, 8 do + local r = CreateFrame("Button", nil, AA.PS) + r:SetHeight(36) + r:SetPoint("TOPLEFT", AA.PS, "TOPLEFT", 8, -28 - (i - 1) * 36) + r:SetPoint("TOPRIGHT", AA.PS, "TOPRIGHT", -8, -28 - (i - 1) * 36) + r.sel = r:CreateTexture(nil, "BACKGROUND") + r.sel:SetAllPoints(r) + r.sel:SetTexture(0.2, 0.5, 0.9, 0.35) + r.sel:Hide() + r:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") + r.name = r:CreateFontString(nil, "OVERLAY", "GameFontNormal") + r.name:SetPoint("TOPLEFT", r, "TOPLEFT", 6, -4) + r.rank = r:CreateFontString(nil, "OVERLAY", "GameFontNormal") + r.rank:SetPoint("TOPRIGHT", r, "TOPRIGHT", -6, -4) + r.rank:SetJustifyH("RIGHT") + r.sub = r:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") + r.sub:SetPoint("TOPLEFT", r.name, "BOTTOMLEFT", 0, -2) + r:SetScript("OnClick", function() + AA.profSel = this.prof + AA.RefreshManager() + end) + r:Hide() + AA.PS.rows[i] = r +end + +AA.PR = CreateFrame("Frame", nil, AA.P) +AA.PR:SetPoint("TOPLEFT", AA.P, "TOPLEFT", 242, -84) +AA.PR:SetWidth(304) +AA.PR:SetHeight(300) +AA.SkinFrame(AA.PR, 0.5) +AA.PR:Hide() +AA.PR.title = AA.PR:CreateFontString(nil, "OVERLAY", "GameFontNormal") +AA.PR.title:SetPoint("TOPLEFT", AA.PR, "TOPLEFT", 10, -7) +AA.PR.note = AA.PR:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") +AA.PR.note:SetPoint("TOPRIGHT", AA.PR, "TOPRIGHT", -10, -9) +AA.PR.empty = AA.PR:CreateFontString(nil, "OVERLAY", "GameFontDisable") +AA.PR.empty:SetPoint("CENTER", AA.PR, "CENTER", 0, 0) +AA.PR.empty:SetWidth(240) +AA.PR.empty:Hide() + +AA.recList, AA.recRows = {}, {} +AA.PR.sf = CreateFrame("ScrollFrame", "AdeAltsRecipeScroll", AA.PR, "FauxScrollFrameTemplate") +AA.PR.sf:SetPoint("TOPLEFT", AA.PR, "TOPLEFT", 0, -26) +AA.PR.sf:SetPoint("BOTTOMRIGHT", AA.PR, "BOTTOMRIGHT", -26, 4) +AA.PR.sf:SetScript("OnVerticalScroll", function() FauxScrollFrame_OnVerticalScroll(AA.RROWH, AA.UpdateRecipes) end) +AA.PR:EnableMouseWheel(true) +AA.PR:SetScript("OnMouseWheel", function() AA.ScrollWheel(AA.PR.sf, AA.RROWH) end) + +function AA.MakeRecRow() + local r = CreateFrame("Button", nil, AA.PR) + r:SetHeight(AA.RROWH - 2) + r.text = r:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + r.text:SetPoint("LEFT", r, "LEFT", 2, 0) + r.text:SetJustifyH("LEFT") + r:EnableMouseWheel(true) + r:SetScript("OnMouseWheel", function() AA.ScrollWheel(AA.PR.sf, AA.RROWH) end) + r:Hide() + table.insert(AA.recRows, r) +end + +AA.UpdateRecipes = function() + FauxScrollFrame_Update(AA.PR.sf, table.getn(AA.recList), AA.RROWS, AA.RROWH) + local off = FauxScrollFrame_GetOffset(AA.PR.sf) + for i = 1, table.getn(AA.recRows) do + local r = AA.recRows[i] + local name = nil + if i <= AA.RROWS then name = AA.recList[off + i] end + if name then + r.text:SetText(name) + r:Show() + else + r:Hide() + end + end +end + diff --git a/ui_show.lua b/ui_show.lua new file mode 100644 index 0000000..e2bb92b --- /dev/null +++ b/ui_show.lua @@ -0,0 +1,274 @@ +-- Ade Alts: ui_show +local AA = AdeAlts + +local function ShowSearch(q) + for _, o in ipairs(AA.hdr) do o:Hide() end + AA.BI:Hide() + AA.BB:Hide() + AA.EQ:Hide() + AA.PS:Hide() + AA.PR:Hide() + AA.resList = {} + local total, chars = 0, {} + for _, k in ipairs(AA.SortedAlts()) do + local c = AA.db.chars[k] + for w = 1, 2 do + local list = c.inv + if w == 2 then list = c.bank end + if list then + for _, e in ipairs(list) do + local nm = AA.ItemName(e[1]) + if string.find(string.lower(nm), q, 1, true) then + local where = "Bags" + if w == 2 then where = "Bank" end + table.insert(AA.resList, { id = e[1], n = e[2], name = nm, char = c, where = where }) + total = total + e[2] + chars[k] = true + end + end + end + end + if c.prof then + for pname, pr in pairs(c.prof) do + if pr.rec then + for _, rn in ipairs(pr.rec) do + if string.find(string.lower(rn), q, 1, true) then + table.insert(AA.resList, { recipe = true, n = 0, name = rn, char = c, where = pname }) + chars[k] = true + end + end + end + end + end + end + table.sort(AA.resList, function(a, b) + if a.name ~= b.name then return a.name < b.name end + if a.char.name ~= b.char.name then return a.char.name < b.char.name end + return a.where < b.where + end) + local nc = 0 + for k in pairs(chars) do nc = nc + 1 end + if table.getn(AA.resList) == 0 then + AA.stitle:SetText("No items matching \"" .. q .. "\" in cached bags / banks.") + else + AA.stitle:SetText(table.getn(AA.resList) .. " stack group(s), " .. total .. " item(s) on " .. nc .. " alt(s) |cff808080(item count alt location)|r") + end + AA.ResetScroll(AA.ssf) + AA.UpdateResults() + AA.S:Show() +end + +local function ProfSummary(c) + if not c.prof then return "|cff808080professions: not scanned yet|r" end + local list = {} + for name, pr in pairs(c.prof) do table.insert(list, { name = name, r = pr.r or 0, m = pr.m or 0 }) end + if table.getn(list) == 0 then return "|cff808080no professions|r" end + table.sort(list, function(a, b) + if a.r ~= b.r then return a.r > b.r end + return a.name < b.name + end) + local parts = {} + for _, e in ipairs(list) do + local col = "ffd100" + if e.m > 0 and e.r >= e.m then col = "40ff40" end + table.insert(parts, "|cffb0b0b0" .. e.name .. "|r |cff" .. col .. e.r .. "|r") + end + return table.concat(parts, " ") +end + +local function ShowBags(c) + AA.BI:Show() + AA.BB:Show() + AA.BI.empty:Hide() + AA.SetBoxList(AA.BI, c.inv) + if c.invTs and c.invTs > 0 then + AA.BI.note:SetText("updated " .. AA.Ago(c.invTs)) + else + AA.BI.note:SetText("") + AA.BI.empty:SetText("Not cached yet.\nLog in on this character once.") + AA.BI.empty:Show() + end + + AA.BB.empty:Hide() + if c.bankTs and c.bankTs > 0 then + AA.SetBoxList(AA.BB, c.bank) + AA.BB.note:SetText("updated " .. AA.Ago(c.bankTs)) + else + AA.SetBoxList(AA.BB, {}) + AA.BB.note:SetText("") + AA.BB.empty:SetText("Bank not cached yet.\nOpen the bank on this character once.") + AA.BB.empty:Show() + end +end + +local function ShowEquip(c) + AA.EQ:Show() + if c.eqTs and c.eqTs > 0 then + AA.EQ.note:SetText("updated " .. AA.Ago(c.eqTs)) + AA.EQ.empty:Hide() + else + AA.EQ.note:SetText("") + AA.EQ.empty:SetText("Equipment not cached yet.\nLog in on this character once.") + AA.EQ.empty:Show() + end + for i, b in ipairs(AA.EQ.cells) do + local ref = c.equip and c.equip[b.slotId] + if ref then + local _, _, sid = string.find(ref, "^(%d+)") + local id = tonumber(sid) + b.itemStr = ref + b.itemId = id + b.icon:SetTexture(AA.ItemTex(id)) + b.name:SetText(AA.ItemName(id)) + local qr, qg, qb = AA.ItemColor(id) + b.name:SetTextColor(qr, qg, qb) + b.slot:SetText(b.slotName) + b.frame:SetBackdropBorderColor(qr, qg, qb, 1) + else + b.itemStr = nil + b.itemId = nil + b.icon:SetTexture("Interface\\Buttons\\UI-EmptySlot") + b.name:SetText(b.slotName) + b.name:SetTextColor(0.45, 0.45, 0.45) + b.slot:SetText("") + b.frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 1) + end + end +end + +local function ShowProfs(c) + AA.PS:Show() + AA.PR:Show() + local names = {} + if c.prof then + for name in pairs(c.prof) do table.insert(names, name) end + end + table.sort(names) + local found = false + for _, n in ipairs(names) do if n == AA.profSel then found = true end end + if not found then AA.profSel = names[1] end + if table.getn(names) == 0 then + AA.PS.empty:SetText("No professions cached yet.\nLog in on this character once.") + AA.PS.empty:Show() + else + AA.PS.empty:Hide() + end + for i = 1, 8 do + local r = AA.PS.rows[i] + local name = names[i] + if name then + local pr = c.prof[name] + r.prof = name + r.name:SetText(name) + local rank, mx = pr.r or 0, pr.m or 0 + if mx > 0 and rank >= mx then + r.rank:SetText("|cff40ff40" .. rank .. " / " .. mx .. "|r") + else + r.rank:SetText("|cffffd100" .. rank .. " / " .. mx .. "|r") + end + if AA.NORECIPES[name] then + r.sub:SetText("") + elseif pr.rec and table.getn(pr.rec) > 0 then + r.sub:SetText(table.getn(pr.rec) .. " recipes known") + else + r.sub:SetText("recipes not scanned yet") + end + if name == AA.profSel then r.sel:Show() else r.sel:Hide() end + r:Show() + else + r:Hide() + end + end + local pr = AA.profSel and c.prof and c.prof[AA.profSel] + AA.recList = (pr and pr.rec) or {} + if AA.profSel then AA.PR.title:SetText("Known recipes: " .. AA.profSel) else AA.PR.title:SetText("Known recipes") end + if AA.profSel and AA.NORECIPES[AA.profSel] then + AA.PR.note:SetText("") + AA.PR.empty:SetText("|cff808080" .. AA.profSel .. " has no recipes to track.|r") + AA.PR.empty:Show() + elseif pr and pr.rts and pr.rts > 0 then + AA.PR.note:SetText(table.getn(AA.recList) .. " known, updated " .. AA.Ago(pr.rts)) + AA.PR.empty:Hide() + else + AA.PR.note:SetText("") + if AA.profSel then + AA.PR.empty:SetText("Recipes not scanned yet.\nOpen the " .. AA.profSel .. " window on " .. c.name .. " once\n(clear its filters first).") + else + AA.PR.empty:SetText("") + end + AA.PR.empty:Show() + end + AA.ResetScroll(AA.PR.sf) + AA.UpdateRecipes() +end + +local function ShowChar() + AA.S:Hide() + for _, o in ipairs(AA.hdr) do o:Show() end + AA.BI:Hide() + AA.BB:Hide() + AA.EQ:Hide() + AA.PS:Hide() + AA.PR:Hide() + local c = AA.db.chars[AA.selKey] + if not c then return end + AA.view = AA.db.view or "bags" + for k, tb in pairs(AA.tabs) do + if k == AA.view then tb:Disable() else tb:Enable() end + end + AA.SetClassTex(AA.hIcon, c.class) + AA.hName:SetText("|cff" .. AA.ClassHex(c.class) .. c.name .. "|r") + local lv = "?" + if c.level and c.level > 0 then lv = c.level end + AA.hInfo:SetText("Level " .. lv .. " " .. AA.ClassName(c.class) .. " |cff808080" .. c.realm .. "|r") + AA.hProf:SetText(ProfSummary(c)) + AA.hGold:SetText(AA.Money(c.gold)) + AA.hAge:SetText("character data: " .. AA.Ago(c.dataTs)) + if AA.view == "equip" then + ShowEquip(c) + elseif AA.view == "profs" then + ShowProfs(c) + else + ShowBags(c) + end +end + +local footer = AA.M:CreateFontString(nil, "OVERLAY", "GameFontNormal") +footer:SetPoint("BOTTOMLEFT", AA.M, "BOTTOMLEFT", 16, 14) +local fstat = AA.M:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") +fstat:SetPoint("BOTTOMRIGHT", AA.M, "BOTTOMRIGHT", -16, 14) + +AA.RefreshManager = function() + if not AA.db or not AA.M:IsVisible() then return end + if not AA.selKey or not AA.db.chars[AA.selKey] then AA.selKey = AA.myKey end + if not AA.selKey or not AA.db.chars[AA.selKey] then + for k in pairs(AA.db.chars) do AA.selKey = k break end + end + local tot, n = 0, 0 + for k, c in pairs(AA.db.chars) do + tot = tot + (c.gold or 0) + n = n + 1 + end + footer:SetText("Total gold of " .. n .. " alts: " .. AA.Money(tot)) + if ImportFile and ExportFile then + fstat:SetText("SuperWoW file sync: |cff40ff40on|r") + else + fstat:SetText("SuperWoW file sync: |cffff6060off|r (data of other accounts will not update)") + end + AA.UpdateAltList() + local q = string.lower(AA.sbox:GetText() or "") + q = string.gsub(q, "^%s+", "") + q = string.gsub(q, "%s+$", "") + if string.len(q) >= 2 then ShowSearch(q) else ShowChar() end +end + +AA.sbox:SetScript("OnEscapePressed", function() + if this:GetText() ~= "" then this:SetText("") else this:ClearFocus() end +end) +AA.sbox:SetScript("OnEnterPressed", function() this:ClearFocus() end) +AA.sbox:SetScript("OnTextChanged", function() AA.RefreshManager() end) + +AA.M:SetScript("OnShow", function() + if AA.FileMerge then AA.FileMerge() end + AA.RefreshManager() +end)