diff --git a/README.md b/README.md index 9385fb6..55e60b4 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,16 @@ including those on **other accounts**, and shows it in one window. - **Total gold** of all alts. - **Professions** – skill levels, known and **missing recipes** with required level and source (trainer, vendor, drop, quest...), sortable, with tooltips. Recipe items also show which of your alts can learn them, and every item tooltip shows how many of it your other alts carry. - **Equipped gear** of every alt. -- **Minimap button** – docks into pfUI's addon button panel automatically. -- **Settings** – window scale, width, height, background opacity, background colour, cooldown-window opacity. +- **Minimap button** – classic round button; docks into pfUI's addon button panel automatically. +- **Settings** – window scale, width, height, background opacity, background colour, cooldown-window opacity, window style. +- **Looks** – classic Blizzard windows by default, pfUI look automatically when pfUI is installed (switchable). ## Requirements - Turtle WoW / any 1.12 client. - Optional but recommended: **[SuperWoW](https://github.com/balakethelock/SuperWoW)** – lets all accounts in the same game folder share data through `imports\AdeAlts.txt`. Without it, nothing is shared between accounts unless you enable chat sync with `/ade chat` (cooldowns only). -- Optional: pfUI (minimap button docking and skin). +- Optional: pfUI (pfUI window look and minimap button docking). Not required: without pfUI the addon uses classic Blizzard-style windows. ## Installation @@ -58,6 +59,7 @@ Every alias works the same: `/ade`, `/adealts`, `/pcd`, `/profcd`, `/cdt`. | `/ade del ` | Remove a cached character and ignore it from now on, so chat / shared-file sync cannot bring it back (not the one you are logged in on) | | `/ade unignore ` | Stop ignoring a character removed with `del` | | `/ade counts` | Turn the "On alts: N" item amounts in item tooltips on / off | +| `/ade style [auto\|blizz\|pfui]` | Window style: `auto` = pfUI look when pfUI is installed, otherwise Blizzard; `blizz` forces the classic look; `pfui` forces pfUI (needs pfUI installed). Also in Settings. | | `/ade chat` | Turn guild / party / raid addon-message sync on or off (**off by default**; SuperWoW file sync is unaffected) | ## How data is shared diff --git a/events.lua b/events.lua index d492289..1dc5b7b 100644 --- a/events.lua +++ b/events.lua @@ -99,6 +99,7 @@ ev:SetScript("OnEvent", function() local sv = ch.prof and ch.prof.Survival if sv and AA.BadProf("Survival", sv.m) then ch.prof.Survival = nil end end + AA.ApplyStyle() AA.ApplyConfig() AA.db.angle = AA.db.angle or 200 if AA.db.hidden then AA.btn:Hide() end @@ -288,6 +289,18 @@ SlashCmdList["PROFCD"] = function(msg) end end AA.Print("no longer ignoring " .. n .. " character(s).") + elseif cmd == "style" then + local a = string.lower(arg or "") + if a == "blizz" or a == "blizzard" then AA.db.style = "blizz" + elseif a == "pfui" then AA.db.style = "pfui" + elseif a == "auto" then AA.db.style = nil + else + AA.Print("window style: " .. (AA.db.style or "auto") .. " - use /ade style auto | blizz | pfui") + return + end + AA.ApplyStyle() + if AA.UpdateStyleBtn then AA.UpdateStyleBtn() end + AA.Print("window style: " .. (AA.db.style or "auto") .. (AA.UsePf() and " (pfUI look)" or " (Blizzard look)")) elseif cmd == "chat" then AA.db.chat = not AA.db.chat AA.Print("guild / party / raid sync " .. (AA.db.chat and "|cff40ff40ON|r (cooldowns are sent to and accepted from guild / party / raid)" or "|cffff6060OFF|r (default; nothing is sent or accepted from chat)") .. ".") diff --git a/minimap.lua b/minimap.lua index 46099c8..a6208e5 100644 --- a/minimap.lua +++ b/minimap.lua @@ -12,46 +12,25 @@ AA.btn:SetFrameLevel(8) AA.btn:RegisterForClicks("LeftButtonUp", "RightButtonUp") AA.btn:RegisterForDrag("LeftButton") -local icon = AA.btn:CreateTexture(nil, "BACKGROUND") +-- classic round minimap button (gold ring); pfUI keeps this look for docked buttons +local bg = AA.btn:CreateTexture(nil, "BACKGROUND") +bg:SetTexture("Interface\\Minimap\\UI-Minimap-Background") +bg:SetWidth(20) +bg:SetHeight(20) +bg:SetPoint("TOPLEFT", AA.btn, "TOPLEFT", 7, -5) +local icon = AA.btn:CreateTexture(nil, "ARTWORK") icon:SetTexture("Interface\\Icons\\Trade_Alchemy") +icon:SetWidth(20) +icon:SetHeight(20) +icon:SetPoint("TOPLEFT", AA.btn, "TOPLEFT", 7, -5) +icon:SetTexCoord(0.07, 0.93, 0.07, 0.93) local border = AA.btn:CreateTexture(nil, "OVERLAY") border:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") - -function AA.StyleButton() - if pfUI and pfUI.api and pfUI.api.CreateBackdrop then - -- pfUI look: flat icon inside a pfUI backdrop, same as other docked buttons - if not AA.btn.pcdBackdrop then - AA.btn.pcdBackdrop = true - pcall(pfUI.api.CreateBackdrop, AA.btn, nil, true) - end - icon:SetDrawLayer("ARTWORK") - icon:ClearAllPoints() - icon:SetPoint("TOPLEFT", AA.btn, "TOPLEFT", 3, -3) - icon:SetPoint("BOTTOMRIGHT", AA.btn, "BOTTOMRIGHT", -3, 3) - icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) - border:Hide() - AA.btn:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") - elseif pfUI then - icon:SetDrawLayer("ARTWORK") - icon:ClearAllPoints() - icon:SetAllPoints(AA.btn) - icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) - border:Hide() - AA.btn:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") - else - icon:SetDrawLayer("BACKGROUND") - icon:ClearAllPoints() - icon:SetWidth(20); icon:SetHeight(20) - icon:SetPoint("TOPLEFT", AA.btn, "TOPLEFT", 6, -5) - icon:SetTexCoord(0, 1, 0, 1) - border:ClearAllPoints() - border:SetWidth(53); border:SetHeight(53) - border:SetPoint("TOPLEFT", AA.btn, "TOPLEFT", 0, 0) - border:Show() - AA.btn:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight") - end -end -AA.StyleButton() +border:SetWidth(53) +border:SetHeight(53) +border:SetPoint("TOPLEFT", AA.btn, "TOPLEFT", 0, 0) +AA.btn:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight") +AA.StyleButton = function() end function AA.PlaceButton() if AA.btn:GetParent() ~= Minimap then return end -- docked by pfUI diff --git a/skin.lua b/skin.lua new file mode 100644 index 0000000..f03f7df --- /dev/null +++ b/skin.lua @@ -0,0 +1,115 @@ +-- Ade Alts: skin (window backgrounds: pfUI look or classic Blizzard look) +local AA = AdeAlts + +-- backgrounds: only these colours change with the opacity setting (never icons / text) ----- +local skinned = {} -- frames that follow the opacity setting +local allskins = {} -- every skinned frame (the style can be switched at any time) + +-- pfUI look when pfUI is installed (and not switched off in the settings), Blizzard look otherwise +function AA.UsePf() + if AA.db and AA.db.style == "blizz" then return false end + return (pfUI and pfUI.api and pfUI.api.CreateBackdrop) and true or false +end + +function AA.ApplySkin(rec) + local fr = rec.f + rec.pf = false + if AA.UsePf() then + if not fr.backdrop then pcall(pfUI.api.CreateBackdrop, fr) end + if fr.backdrop and fr.backdrop.GetBackdropColor then + if not rec.pfeff then + local r, g, b, a0 = fr.backdrop:GetBackdropColor() + rec.pfr, rec.pfg, rec.pfb, rec.pfeff = r or 0, g or 0, b or 0, a0 or 0.85 -- pfUI's own alpha counts as 100 % + end + fr:SetBackdrop(nil) + fr.backdrop:Show() + rec.pf = true + rec.r, rec.g, rec.b, rec.eff = rec.pfr, rec.pfg, rec.pfb, rec.pfeff + return + end + end + if fr.backdrop then fr.backdrop:Hide() end + if rec.top then + -- classic dialog window + fr:SetBackdrop({ + bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", + edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", + tile = true, tileSize = 32, edgeSize = 16, + insets = { left = 4, right = 4, top = 4, bottom = 4 }, + }) + rec.r, rec.g, rec.b = 1, 1, 1 + else + -- classic tooltip-style panel + fr:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + tile = true, tileSize = 16, edgeSize = 14, + insets = { left = 4, right = 4, top = 4, bottom = 4 }, + }) + rec.r, rec.g, rec.b = 0, 0, 0 + end + rec.eff = rec.base +end + +-- a = background alpha, fixed = ignores the opacity setting, top = main window (dialog look) +function AA.SkinFrame(fr, a, fixed, top) + local rec = { f = fr, base = a or 0.9, top = top } + fr.adeSkin = rec + table.insert(allskins, rec) + if not fixed then table.insert(skinned, rec) end + AA.ApplySkin(rec) + AA.PaintSkin(rec, 1) +end + +-- chosen background colour (settings), or nil for the default +function AA.BgColor() + local c = AA.db and AA.db.bg + if c then return c[1], c[2], c[3] end +end + +function AA.PaintSkin(rec, o) + local cr, cg, cb = AA.BgColor() + local r, g, b = cr or rec.r, cg or rec.g, cb or rec.b + local target = rec.pf and rec.f.backdrop or rec.f + target:SetBackdropColor(r, g, b, rec.eff * o) +end + +function AA.ApplyOpacity(o) + for _, rec in ipairs(skinned) do AA.PaintSkin(rec, o) end +end + +-- opacity of one skinned frame (cooldowns window) +function AA.SetSkinAlpha(fr, o) + if fr.adeSkin then AA.PaintSkin(fr.adeSkin, o) end +end + +-- re-skin every window (style setting changed) +function AA.ApplyStyle() + for _, rec in ipairs(allskins) do AA.ApplySkin(rec) end + AA.ApplyOpacity((AA.db and AA.db.alpha) or 1) + if AA.f then AA.SetSkinAlpha(AA.f, (AA.db and AA.db.cdalpha) or 1) end +end + +function AA.ItemTip(b) + local ref = b.itemStr + if not ref and b.itemId then ref = b.itemId .. ":0:0:0" end + if not ref then return end + GameTooltip:SetOwner(b, "ANCHOR_RIGHT") + local ok = pcall(GameTooltip.SetHyperlink, GameTooltip, "item:" .. ref) + if not ok or GameTooltip:NumLines() == 0 then + GameTooltip:ClearLines() + GameTooltip:AddLine(b.itemId and AA.ItemName(b.itemId) or ref) + end + GameTooltip:Show() +end + +function AA.ScrollWheel(sf, step) + local sb = getglobal(sf:GetName() .. "ScrollBar") + if sb then sb:SetValue(sb:GetValue() - arg1 * step * 2) end +end + +function AA.ResetScroll(sf) + local sb = getglobal(sf:GetName() .. "ScrollBar") + if sb then sb:SetValue(0) end +end + diff --git a/ui_base.lua b/ui_base.lua index 224c2d6..4c5d544 100644 --- a/ui_base.lua +++ b/ui_base.lua @@ -95,71 +95,6 @@ function AA.SetClassTex(tex, class) end end --- backgrounds: only these colours change with the opacity setting (never icons / text) ----- -local skinned = {} -function AA.SkinFrame(fr, a, fixed) - local rec = { f = fr, base = a or 0.9 } - if pfUI and pfUI.api and pfUI.api.CreateBackdrop then - local ok = pcall(pfUI.api.CreateBackdrop, fr) - if ok and fr.backdrop and fr.backdrop.GetBackdropColor then - local r, g, b, a0 = fr.backdrop:GetBackdropColor() - rec.pf = true - rec.r, rec.g, rec.b = r or 0, g or 0, b or 0 - rec.base = a0 or 0.85 -- pfUI's own alpha counts as 100 % - if not fixed then table.insert(skinned, rec) end - return - end - end - fr:SetBackdrop({ - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 14, - insets = { left = 4, right = 4, top = 4, bottom = 4 }, - }) - fr:SetBackdropColor(0, 0, 0, rec.base) - if not fixed then table.insert(skinned, rec) end -end - --- chosen background colour (settings), or nil for the default -function AA.BgColor() - local c = AA.db and AA.db.bg - if c then return c[1], c[2], c[3] end -end - -function AA.ApplyOpacity(o) - local cr, cg, cb = AA.BgColor() - for _, rec in ipairs(skinned) do - if rec.pf then - rec.f.backdrop:SetBackdropColor(cr or rec.r, cg or rec.g, cb or rec.b, rec.base * o) - else - rec.f:SetBackdropColor(cr or 0, cg or 0, cb or 0, rec.base * o) - end - end -end - -function AA.ItemTip(b) - local ref = b.itemStr - if not ref and b.itemId then ref = b.itemId .. ":0:0:0" end - if not ref then return end - GameTooltip:SetOwner(b, "ANCHOR_RIGHT") - local ok = pcall(GameTooltip.SetHyperlink, GameTooltip, "item:" .. ref) - if not ok or GameTooltip:NumLines() == 0 then - GameTooltip:ClearLines() - GameTooltip:AddLine(b.itemId and AA.ItemName(b.itemId) or ref) - end - GameTooltip:Show() -end - -function AA.ScrollWheel(sf, step) - local sb = getglobal(sf:GetName() .. "ScrollBar") - if sb then sb:SetValue(sb:GetValue() - arg1 * step * 2) end -end - -function AA.ResetScroll(sf) - local sb = getglobal(sf:GetName() .. "ScrollBar") - if sb then sb:SetValue(0) end -end - -- main frame ---------------------------------------------------------- AA.M = CreateFrame("Frame", "AdeAltsManager", UIParent) AA.M:SetWidth(AA.DEF_W) @@ -172,7 +107,7 @@ AA.M:RegisterForDrag("LeftButton") AA.M:SetScript("OnDragStart", function() this:StartMoving() end) AA.M:SetScript("OnDragStop", function() this:StopMovingOrSizing() end) AA.M:Hide() -AA.SkinFrame(AA.M, 0.95) +AA.SkinFrame(AA.M, 0.95, false, true) table.insert(UISpecialFrames, "AdeAltsManager") local mtitle = AA.M:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")