diff --git a/.gitignore b/.gitignore index 5360bd9..06727ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .claude .vscode .idea -NUL \ No newline at end of file +NUL +temp \ No newline at end of file diff --git a/Assets/Bank-Background.blp b/Assets/Bank-Background.blp new file mode 100644 index 0000000..abc78c5 Binary files /dev/null and b/Assets/Bank-Background.blp differ diff --git a/Core/Init.lua b/Core/Init.lua index 01f5e98..d06061d 100644 --- a/Core/Init.lua +++ b/Core/Init.lua @@ -194,7 +194,15 @@ function Guda_ToggleBank() end -- Helper to apply backdrop with color +-- For main frames (DEFAULT_FRAME / MINIMALIST_BORDER), delegates to Theme module when available. +-- Explicit types like "DROPDOWN" bypass theming. function addon:ApplyBackdrop(frame, backdropType, colorType) + -- For main frame backdrop types, use Theme module if available + if (backdropType == "DEFAULT_FRAME" or backdropType == "MINIMALIST_BORDER") and self.Modules and self.Modules.Theme then + self.Modules.Theme:ApplyToFrame(frame) + return + end + local backdrop = self.Constants.Backdrops[backdropType] local color = self.Constants.BackdropColors[colorType or "DEFAULT"] @@ -205,18 +213,7 @@ function addon:ApplyBackdrop(frame, backdropType, colorType) end frame:SetBackdrop(backdrop) - - -- If it's a main frame, we should respect the transparency setting - local frameName = frame:GetName() - if frameName == "Guda_BagFrame" or frameName == "Guda_BankFrame" or frameName == "Guda_SettingsPopup" or frameName == "Guda_QuestItemBar" then - if Guda_ApplyBackgroundTransparency then - Guda_ApplyBackgroundTransparency() - else - frame:SetBackdropColor(color.r, color.g, color.b, color.a) - end - else - frame:SetBackdropColor(color.r, color.g, color.b, color.a) - end + frame:SetBackdropColor(color.r, color.g, color.b, color.a) -- Set border color to white for minimalist borders if backdropType == "MINIMALIST_BORDER" then diff --git a/Core/Theme.lua b/Core/Theme.lua new file mode 100644 index 0000000..4d79f8f --- /dev/null +++ b/Core/Theme.lua @@ -0,0 +1,416 @@ +-- Guda Theme System +-- Provides theme selection between Guda dark and Blizzard classic looks + +local addon = Guda + +local Theme = {} +addon.Modules.Theme = Theme + +-- Theme debug flag — set to true and /reload to trace every ApplyToFrame call +addon.DEBUG_THEME = false + +local function ThemeDebug(msg, a1, a2, a3, a4, a5, a6, a7) + if addon.DEBUG_THEME then + local text = string.format(msg or "nil", a1 or "", a2 or "", a3 or "", a4 or "", a5 or "", a6 or "", a7 or "") + DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800[Theme]|r " .. text) + end +end + +-- Theme definitions +-- Background is rendered via a standalone Texture child (not bgFile). +local themes = { + guda = { + -- ChatFrameBackground is a solid white 1x1 pixel. + -- Vertex-colored (0,0,0) it becomes a solid dark background. + bgTexture = "Interface\\ChatFrame\\ChatFrameBackground", + bgColor = { r = 0, g = 0, b = 0 }, + bgTile = true, + bgTileSize = 16, + border = { + edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", + edgeSize = 32, + insets = { left = 11, right = 12, top = 12, bottom = 11 } + }, + borderMinimal = { + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + edgeSize = 2, + insets = { left = 0, right = 0, top = 0, bottom = 0 } + }, + titleColor = { r = 1, g = 0.82, b = 0 }, + slotBgAlpha = { empty = 0.5, filled = 0.3 }, + }, + blizzard = { + -- Custom bank parchment texture bundled with the addon. + -- Blizzard's MPQ textures (UI-DialogBox-Background) don't render + -- when set via Lua SetBackdrop() in TurtleWoW 1.12. + bgTexture = "Interface\\AddOns\\Guda\\Assets\\Bank-Background", + bgColor = { r = 1, g = 1, b = 1 }, + bgTile = true, + bgTileSize = 256, + border = { + edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", + edgeSize = 32, + insets = { left = 11, right = 12, top = 12, bottom = 11 } + }, + borderMinimal = { + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + edgeSize = 2, + insets = { left = 0, right = 0, top = 0, bottom = 0 } + }, + titleColor = { r = 1, g = 0.82, b = 0 }, + slotBgAlpha = { empty = 1, filled = 1 }, + }, +} + +-- Cached active theme +local cachedTheme = nil +local cachedThemeName = nil + +-- Get the active theme name from DB +local function GetThemeName() + if addon.Modules and addon.Modules.DB then + return addon.Modules.DB:GetSetting("theme") or "guda" + end + return "guda" +end + +-- Get active theme table (cached) +function Theme:Get() + local name = GetThemeName() + if cachedTheme and cachedThemeName == name then + return cachedTheme + end + cachedThemeName = name + cachedTheme = themes[name] or themes.guda + return cachedTheme +end + +-- Single property lookup +function Theme:GetValue(key) + local t = self:Get() + return t[key] +end + +-- Get border config based on hideBorders setting +local function GetBorderConfig(t) + local hideBorders = false + if addon.Modules and addon.Modules.DB then + hideBorders = addon.Modules.DB:GetSetting("hideBorders") + if hideBorders == nil then hideBorders = false end + end + if hideBorders then + return t.borderMinimal, true + else + return t.border, false + end +end + +-- Apply theme to a single frame +function Theme:ApplyToFrame(frame) + if not frame then + ThemeDebug("ApplyToFrame called with nil frame") + return + end + + local frameName = frame:GetName() or "unnamed" + ThemeDebug("--- ApplyToFrame: %s ---", frameName) + + local t = self:Get() + local borderCfg, isMinimal = GetBorderConfig(t) + + ThemeDebug(" theme=%s minimal=%s", tostring(cachedThemeName), tostring(isMinimal)) + ThemeDebug(" bgTexture=%s tileSize=%s", tostring(t.bgTexture), tostring(t.bgTileSize)) + + -- Full backdrop: bgFile + border in a single SetBackdrop call. + local backdrop = { + bgFile = t.bgTexture, + edgeFile = borderCfg.edgeFile, + tile = true, + tileSize = t.bgTileSize, + edgeSize = borderCfg.edgeSize, + insets = { + left = borderCfg.insets.left, + right = borderCfg.insets.right, + top = borderCfg.insets.top, + bottom = borderCfg.insets.bottom, + } + } + + frame:SetBackdrop(nil) + frame:SetBackdrop(backdrop) + ThemeDebug(" SetBackdrop done (bgFile + border)") + + if isMinimal then + frame:SetBackdropBorderColor(1, 1, 1, 1) + end + + -- Background color / alpha + local bg = t.bgColor + local transparency = 0.15 + if addon.Modules and addon.Modules.DB then + transparency = addon.Modules.DB:GetSetting("bgTransparency") or 0.15 + end + local alpha = 1.0 - transparency + frame:SetBackdropColor(bg.r, bg.g, bg.b, alpha) + ThemeDebug(" SetBackdropColor(%s,%s,%s,%s)", tostring(bg.r), tostring(bg.g), tostring(bg.b), tostring(alpha)) + + -- Clean up legacy child frame / texture from previous approaches + if frame._gudaBgFrame then + frame._gudaBgFrame:Hide() + frame._gudaBgFrame:SetParent(nil) + frame._gudaBgFrame = nil + end + if frame._gudaBg then + frame._gudaBg:Hide() + end + + -- Verify + local bd = frame:GetBackdrop() + if bd then + ThemeDebug(" VERIFY: bgFile=%s tile=%s tileSize=%s", + tostring(bd.bgFile), tostring(bd.tile), tostring(bd.tileSize)) + end + ThemeDebug(" VERIFY: frame size=%sx%s visible=%s level=%s strata=%s", + tostring(frame:GetWidth()), tostring(frame:GetHeight()), + tostring(frame:IsVisible()), tostring(frame:GetFrameLevel()), + tostring(frame:GetFrameStrata())) +end + +-- Apply theme to all main frames +function Theme:ApplyToAllFrames() + ThemeDebug("=== ApplyToAllFrames ===") + local frameNames = { "Guda_BagFrame", "Guda_BankFrame", "Guda_MailboxFrame", "Guda_SettingsPopup", "Guda_CategoryEditor", "Guda_QuestItemBar" } + for _, frameName in ipairs(frameNames) do + local frame = getglobal(frameName) + if frame then + self:ApplyToFrame(frame) + else + ThemeDebug(" frame %s NOT FOUND (nil)", frameName) + end + end + + -- Update slot background alphas on all existing item buttons + local sa = self:GetValue("slotBgAlpha") + if sa then + self:UpdateAllSlotBackgrounds(sa) + end + + ThemeDebug("=== ApplyToAllFrames done ===") +end + +-- Update emptySlotBg alpha on all visible item buttons +function Theme:UpdateAllSlotBackgrounds(sa) + local i = 1 + while true do + local btn = getglobal("Guda_ItemButton" .. i) + if not btn then break end + local bg = getglobal(btn:GetName() .. "_EmptySlotBg") + if bg then + local alpha = btn.hasItem and sa.filled or sa.empty + if alpha > 0 then + bg:SetAlpha(alpha) + bg:Show() + else + bg:Hide() + end + end + i = i + 1 + end +end + +-- Clear cache (call when theme setting changes) +function Theme:ClearCache() + cachedTheme = nil + cachedThemeName = nil +end + +-- Slash command to toggle theme debug +SLASH_GUDATHEME1 = "/gudatheme" +SlashCmdList["GUDATHEME"] = function(msg) + if msg == "on" then + addon.DEBUG_THEME = true + DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800[Theme]|r Debug ON — reapplying all frames...") + Theme:ApplyToAllFrames() + elseif msg == "off" then + addon.DEBUG_THEME = false + DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800[Theme]|r Debug OFF") + elseif msg == "apply" then + local prev = addon.DEBUG_THEME + addon.DEBUG_THEME = true + Theme:ApplyToAllFrames() + addon.DEBUG_THEME = prev + elseif msg == "inspect" then + -- Dump backdrop state for all frames without reapplying + local frameNames = { "Guda_BagFrame", "Guda_BankFrame", "Guda_MailboxFrame", "Guda_SettingsPopup", "Guda_CategoryEditor", "Guda_QuestItemBar" } + -- Show current transparency setting + local transp = "N/A" + if addon.Modules and addon.Modules.DB then + transp = tostring(addon.Modules.DB:GetSetting("bgTransparency")) + end + DEFAULT_CHAT_FRAME:AddMessage(string.format("|cFFFF8800[Theme]|r === Inspect Backdrop === (bgTransparency=%s, alpha=%s)", + transp, tostring(1.0 - (tonumber(transp) or 0.15)))) + for _, fn in ipairs(frameNames) do + local f = getglobal(fn) + if f then + local bd = f:GetBackdrop() + if bd then + DEFAULT_CHAT_FRAME:AddMessage(string.format(" |cFFFFFF00%s|r: bgFile=%s edgeFile=%s tile=%s tileSize=%s", + fn, tostring(bd.bgFile), tostring(bd.edgeFile), tostring(bd.tile), tostring(bd.tileSize))) + else + DEFAULT_CHAT_FRAME:AddMessage(string.format(" |cFFFFFF00%s|r: backdrop=nil", fn)) + end + DEFAULT_CHAT_FRAME:AddMessage(string.format(" visible=%s size=%dx%d level=%s strata=%s", + tostring(f:IsVisible()), f:GetWidth(), f:GetHeight(), + tostring(f:GetFrameLevel()), tostring(f:GetFrameStrata()))) + -- Check child bg frame + if f._gudaBgFrame then + local cbd = f._gudaBgFrame:GetBackdrop() + DEFAULT_CHAT_FRAME:AddMessage(string.format(" bgFrame: bgFile=%s shown=%s visible=%s level=%s", + cbd and tostring(cbd.bgFile) or "nil", + tostring(f._gudaBgFrame:IsShown()), + tostring(f._gudaBgFrame:IsVisible()), + tostring(f._gudaBgFrame:GetFrameLevel()))) + end + else + DEFAULT_CHAT_FRAME:AddMessage(string.format(" |cFFFF0000%s|r: frame not found", fn)) + end + end + elseif msg == "test" then + -- Create standalone test frames to isolate which textures render via Lua + local p = DEFAULT_CHAT_FRAME + p:AddMessage("|cFFFF8800[Theme]|r === Texture Test ===") + + -- Test 1: ChatFrameBackground (known working) + local f1 = CreateFrame("Frame", "GudaThemeTest1", UIParent) + f1:SetWidth(200); f1:SetHeight(200) + f1:SetPoint("CENTER", -220, 0) + f1:SetFrameStrata("TOOLTIP") + f1:SetBackdrop({ + bgFile = "Interface\\ChatFrame\\ChatFrameBackground", + edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", + tile = true, tileSize = 16, edgeSize = 32, + insets = { left = 11, right = 12, top = 12, bottom = 11 } + }) + f1:SetBackdropColor(0, 0, 0, 1) + f1:Show() + p:AddMessage(" Test 1 (LEFT): ChatFrameBackground — should be solid black") + + -- Test 2: UI-DialogBox-Background (the broken one) + local f2 = CreateFrame("Frame", "GudaThemeTest2", UIParent) + f2:SetWidth(200); f2:SetHeight(200) + f2:SetPoint("CENTER", 0, 0) + f2:SetFrameStrata("TOOLTIP") + f2:SetBackdrop({ + bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", + edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", + tile = true, tileSize = 32, edgeSize = 32, + insets = { left = 11, right = 12, top = 12, bottom = 11 } + }) + f2:SetBackdropColor(1, 1, 1, 1) + f2:Show() + p:AddMessage(" Test 2 (CENTER): UI-DialogBox-Background — should be parchment") + + -- Test 3: UI-Tooltip-Background (another common texture) + local f3 = CreateFrame("Frame", "GudaThemeTest3", UIParent) + f3:SetWidth(200); f3:SetHeight(200) + f3:SetPoint("CENTER", 220, 0) + f3:SetFrameStrata("TOOLTIP") + f3:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", + tile = true, tileSize = 16, edgeSize = 32, + insets = { left = 11, right = 12, top = 12, bottom = 11 } + }) + f3:SetBackdropColor(1, 1, 1, 1) + f3:Show() + p:AddMessage(" Test 3 (RIGHT): UI-Tooltip-Background — should be purple/blue") + + p:AddMessage("|cFFFF8800[Theme]|r /gudatheme clear to remove test frames") + + elseif msg == "scan" then + -- Enable mouseover scanning: hover any frame to print its backdrop info + if addon._themeScanFrame then + addon._themeScanFrame:Hide() + addon._themeScanFrame = nil + DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800[Theme]|r Scan OFF") + else + local scanner = CreateFrame("Frame", nil, UIParent) + scanner:SetAllPoints(UIParent) + scanner:SetFrameStrata("TOOLTIP") + scanner:EnableMouse(false) + scanner._lastFrame = nil + scanner:SetScript("OnUpdate", function() + local f = GetMouseFocus() + if f and f ~= this._lastFrame then + this._lastFrame = f + local name = f:GetName() or "unnamed" + local p = DEFAULT_CHAT_FRAME + + -- Print backdrop if any + local bd = f.GetBackdrop and f:GetBackdrop() + if bd and (bd.bgFile or bd.edgeFile) then + p:AddMessage(string.format( + "|cFFFF8800[Scan]|r |cFFFFFF00%s|r bgFile=%s edgeFile=%s tile=%s tileSize=%s", + name, tostring(bd.bgFile), tostring(bd.edgeFile), + tostring(bd.tile), tostring(bd.tileSize))) + end + + -- Print textures via GetRegions() + if f.GetRegions then + local regions = { f:GetRegions() } + for i, region in ipairs(regions) do + if region and region.GetTexture then + local tex = region:GetTexture() + if tex and tex ~= "" then + local rname = region:GetName() or ("region" .. i) + local layer = region.GetDrawLayer and region:GetDrawLayer() or "?" + p:AddMessage(string.format( + "|cFFFF8800[Scan]|r |cFF88FF88%s|r tex=%s layer=%s", + rname, tostring(tex), tostring(layer))) + end + end + end + end + + -- If nothing printed, at least show the frame name + if not (bd and (bd.bgFile or bd.edgeFile)) then + local hasTextures = false + if f.GetRegions then + local regions = { f:GetRegions() } + for _, region in ipairs(regions) do + if region and region.GetTexture and region:GetTexture() and region:GetTexture() ~= "" then + hasTextures = true + break + end + end + end + if not hasTextures then + p:AddMessage(string.format("|cFFFF8800[Scan]|r |cFF888888%s|r (no backdrop, no textures)", name)) + end + end + end + end) + scanner:Show() + addon._themeScanFrame = scanner + DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800[Theme]|r Scan ON — hover any frame to see its backdrop. /gudatheme scan again to stop.") + end + + elseif msg == "clear" then + for _, name in ipairs({"GudaThemeTest1", "GudaThemeTest2", "GudaThemeTest3"}) do + local f = getglobal(name) + if f then f:Hide() end + end + DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800[Theme]|r Test frames hidden") + + else + DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8800[Theme]|r Usage:") + DEFAULT_CHAT_FRAME:AddMessage(" /gudatheme on — Enable debug logging") + DEFAULT_CHAT_FRAME:AddMessage(" /gudatheme off — Disable debug logging") + DEFAULT_CHAT_FRAME:AddMessage(" /gudatheme apply — Reapply all frames (with debug)") + DEFAULT_CHAT_FRAME:AddMessage(" /gudatheme inspect — Dump backdrop state") + DEFAULT_CHAT_FRAME:AddMessage(" /gudatheme test — Show 3 test frames with different textures") + DEFAULT_CHAT_FRAME:AddMessage(" /gudatheme clear — Hide test frames") + end +end + +addon:Debug("Theme module loaded") diff --git a/Guda.toc b/Guda.toc index c817bb3..775eb44 100644 --- a/Guda.toc +++ b/Guda.toc @@ -9,6 +9,7 @@ Localization.lua Core\Init.lua +Core\Theme.lua Core\Constants.lua Core\Database.lua DB\QuestItems.lua diff --git a/UI/BagFrame.lua b/UI/BagFrame.lua index 0163886..5b4f364 100644 --- a/UI/BagFrame.lua +++ b/UI/BagFrame.lua @@ -2352,6 +2352,12 @@ function BagFrame:UpdateBorderVisibility() local frame = getglobal("Guda_BagFrame") if not frame then return end + -- Use Theme module if available + if addon.Modules.Theme then + addon.Modules.Theme:ApplyToFrame(frame) + return + end + local hideBorders = addon.Modules.DB:GetSetting("hideBorders") if hideBorders == nil then hideBorders = false diff --git a/UI/BagFrame.xml b/UI/BagFrame.xml index 82d179f..e82a124 100644 --- a/UI/BagFrame.xml +++ b/UI/BagFrame.xml @@ -15,18 +15,6 @@ - - - - - - - - - - - - diff --git a/UI/BankFrame.lua b/UI/BankFrame.lua index 7365caf..aeb80b8 100644 --- a/UI/BankFrame.lua +++ b/UI/BankFrame.lua @@ -1886,6 +1886,12 @@ function BankFrame:UpdateBorderVisibility() local frame = getglobal("Guda_BankFrame") if not frame then return end + -- Use Theme module if available + if addon.Modules.Theme then + addon.Modules.Theme:ApplyToFrame(frame) + return + end + local hideBorders = addon.Modules.DB:GetSetting("hideBorders") if hideBorders == nil then hideBorders = false diff --git a/UI/BankFrame.xml b/UI/BankFrame.xml index 959a02f..a37e451 100644 --- a/UI/BankFrame.xml +++ b/UI/BankFrame.xml @@ -15,18 +15,6 @@ - - - - - - - - - - - - diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index 55c5003..04a7662 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -918,8 +918,17 @@ local function ClearItemButton(self, emptySlotBg, countText, bagID) -- Show/hide empty slot background if emptySlotBg then - emptySlotBg:Show() - emptySlotBg:SetAlpha(0.5) + local slotAlpha = 0.5 + if addon.Modules and addon.Modules.Theme then + local sa = addon.Modules.Theme:GetValue("slotBgAlpha") + if sa then slotAlpha = sa.empty end + end + if slotAlpha > 0 then + emptySlotBg:Show() + emptySlotBg:SetAlpha(slotAlpha) + else + emptySlotBg:Hide() + end end if countText then countText:Hide() end @@ -1215,8 +1224,17 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha -- Show bag pattern background behind items as well if emptySlotBg then - emptySlotBg:Show() - emptySlotBg:SetAlpha(0.3) -- More subtle for filled slots + local slotAlpha = 0.3 + if addon.Modules and addon.Modules.Theme then + local sa = addon.Modules.Theme:GetValue("slotBgAlpha") + if sa then slotAlpha = sa.filled end + end + if slotAlpha > 0 then + emptySlotBg:Show() + emptySlotBg:SetAlpha(slotAlpha) + else + emptySlotBg:Hide() + end end -- Check if item is junk using the CategoryManager @@ -1346,8 +1364,17 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha -- Show classic bag pattern background for empty slots if emptySlotBg then - emptySlotBg:Show() - emptySlotBg:SetAlpha(0.5) -- Slightly more visible + local slotAlpha = 0.5 + if addon.Modules and addon.Modules.Theme then + local sa = addon.Modules.Theme:GetValue("slotBgAlpha") + if sa then slotAlpha = sa.empty end + end + if slotAlpha > 0 then + emptySlotBg:Show() + emptySlotBg:SetAlpha(slotAlpha) + else + emptySlotBg:Hide() + end end -- Dim empty slots when searching diff --git a/UI/MailboxFrame.lua b/UI/MailboxFrame.lua index 9738ed3..9987418 100644 --- a/UI/MailboxFrame.lua +++ b/UI/MailboxFrame.lua @@ -73,6 +73,12 @@ end -- Update border visibility function MailboxFrame:UpdateBorderVisibility() + -- Use Theme module if available + if addon.Modules and addon.Modules.Theme then + addon.Modules.Theme:ApplyToFrame(Guda_MailboxFrame) + return + end + local hideBorders = addon.Modules.DB:GetSetting("hideBorders") if hideBorders then Guda:ApplyBackdrop(Guda_MailboxFrame, "MINIMALIST_BORDER", "DEFAULT") diff --git a/UI/MailboxFrame.xml b/UI/MailboxFrame.xml index 94d1590..2a3a8f7 100644 --- a/UI/MailboxFrame.xml +++ b/UI/MailboxFrame.xml @@ -91,18 +91,6 @@ - - - - - - - - - - - - diff --git a/UI/SettingsPopup.lua b/UI/SettingsPopup.lua index 21125bc..312897a 100644 --- a/UI/SettingsPopup.lua +++ b/UI/SettingsPopup.lua @@ -151,6 +151,7 @@ function Guda_SettingsPopup_OnShow(self) local showTooltipCountsCheckbox = getglobal("Guda_SettingsPopup_ShowTooltipCountsCheckbox") local bagViewButton = getglobal("Guda_SettingsPopup_BagViewTypeButton") local bankViewButton = getglobal("Guda_SettingsPopup_BankViewTypeButton") + local themeButton = getglobal("Guda_SettingsPopup_ThemeButton") local showTooltipCounts = Guda.Modules.DB:GetSetting("showTooltipCounts") if showTooltipCounts == nil then @@ -241,7 +242,11 @@ function Guda_SettingsPopup_OnShow(self) end end - + -- Initialize theme button text + if themeButton then + local currentTheme = Guda.Modules.DB:GetSetting("theme") or "guda" + themeButton:SetText(currentTheme == "guda" and "Theme: Guda" or "Theme: Blizzard") + end -- Apply border visibility if SettingsPopup.UpdateBorderVisibility then @@ -395,16 +400,21 @@ end -- Apply background transparency to bag and bank frames function Guda_ApplyBackgroundTransparency() + -- If Theme module is available, delegate to it (handles both themes correctly) + if Guda.Modules and Guda.Modules.Theme then + Guda.Modules.Theme:ApplyToAllFrames() + return + end + + -- Fallback: original behavior local transparency = Guda.Modules.DB:GetSetting("bgTransparency") or 0.15 local alpha = 1.0 - transparency - + local frames = { "Guda_BagFrame", "Guda_BankFrame", "Guda_MailboxFrame", "Guda_SettingsPopup", "Guda_QuestItemBar" } for _, frameName in ipairs(frames) do local frame = getglobal(frameName) if frame then - -- Reset frame alpha to 1.0 (previous version might have set it) frame:SetAlpha(1.0) - -- Set backdrop color (background only) frame:SetBackdropColor(0, 0, 0, alpha) end end @@ -684,37 +694,26 @@ function Guda_SettingsPopup_HideBordersCheckbox_OnClick(self) Guda.Modules.DB:SetSetting("hideBorders", isChecked) end - -- Update border visibility on both bag and bank frames using helper function - local bagFrame = getglobal("Guda_BagFrame") - if bagFrame then - if isChecked then - Guda:ApplyBackdrop(bagFrame, "MINIMALIST_BORDER", "DEFAULT") - else - Guda:ApplyBackdrop(bagFrame, "DEFAULT_FRAME", "DEFAULT") + -- Apply theme to all frames (respects hideBorders setting) + if Guda.Modules and Guda.Modules.Theme then + Guda.Modules.Theme:ApplyToAllFrames() + else + -- Fallback if theme module not loaded + local bagFrame = getglobal("Guda_BagFrame") + if bagFrame then + Guda:ApplyBackdrop(bagFrame, isChecked and "MINIMALIST_BORDER" or "DEFAULT_FRAME", "DEFAULT") end - end - - local bankFrame = getglobal("Guda_BankFrame") - if bankFrame then - if isChecked then - Guda:ApplyBackdrop(bankFrame, "MINIMALIST_BORDER", "DEFAULT") - else - Guda:ApplyBackdrop(bankFrame, "DEFAULT_FRAME", "DEFAULT") + local bankFrame = getglobal("Guda_BankFrame") + if bankFrame then + Guda:ApplyBackdrop(bankFrame, isChecked and "MINIMALIST_BORDER" or "DEFAULT_FRAME", "DEFAULT") end - end - - local mailboxFrame = getglobal("Guda_MailboxFrame") - if mailboxFrame then - if isChecked then - Guda:ApplyBackdrop(mailboxFrame, "MINIMALIST_BORDER", "DEFAULT") - else - Guda:ApplyBackdrop(mailboxFrame, "DEFAULT_FRAME", "DEFAULT") + local mailboxFrame = getglobal("Guda_MailboxFrame") + if mailboxFrame then + Guda:ApplyBackdrop(mailboxFrame, isChecked and "MINIMALIST_BORDER" or "DEFAULT_FRAME", "DEFAULT") + end + if SettingsPopup.UpdateBorderVisibility then + SettingsPopup:UpdateBorderVisibility() end - end - - -- Update border visibility on settings frame - if SettingsPopup.UpdateBorderVisibility then - SettingsPopup:UpdateBorderVisibility() end end @@ -1142,6 +1141,29 @@ function Guda_SettingsPopup_MarkUnusableCheckbox_OnClick(self) end end +-- Theme Button OnClick +function Guda_SettingsPopup_ThemeButton_OnClick() + local current = Guda.Modules.DB:GetSetting("theme") or "guda" + local newValue = (current == "guda") and "blizzard" or "guda" + Guda.Modules.DB:SetSetting("theme", newValue) + + -- Clear theme cache + if Guda.Modules.Theme then + Guda.Modules.Theme:ClearCache() + end + + -- Update button text + local btn = getglobal("Guda_SettingsPopup_ThemeButton") + if btn then + btn:SetText(newValue == "guda" and "Theme: Guda" or "Theme: Blizzard") + end + + -- Apply theme to all frames (also updates slot background alphas) + if Guda.Modules.Theme then + Guda.Modules.Theme:ApplyToAllFrames() + end +end + -- Bag View Type Button OnClick function Guda_SettingsPopup_BagViewTypeButton_OnClick() local current = Guda.Modules.DB:GetSetting("bagViewType") or "single" diff --git a/UI/SettingsPopup.xml b/UI/SettingsPopup.xml index 4a26cd7..c5b0c11 100644 --- a/UI/SettingsPopup.xml +++ b/UI/SettingsPopup.xml @@ -14,18 +14,6 @@ - - - - - - - - - - - - @@ -203,15 +191,28 @@ + + + - + - + @@ -819,18 +820,6 @@ - - - - - - - - - - - -