From f87f0fc097aadde566a2b13e47ea60c94a8142d5 Mon Sep 17 00:00:00 2001 From: jKalfis Date: Fri, 4 Sep 2026 11:20:52 +0100 Subject: [PATCH] Update gui.lua --- gui.lua | 735 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 444 insertions(+), 291 deletions(-) diff --git a/gui.lua b/gui.lua index 5a4796d..5cd9437 100644 --- a/gui.lua +++ b/gui.lua @@ -11,6 +11,439 @@ if not DQB then return end +------------------------------------------------------------ +-- Helpers +------------------------------------------------------------ + +local function GetPFUIFont() + if pfUI and pfUI.font_default then + return pfUI.font_default + end + + if pfUI_config + and pfUI_config.global + and pfUI_config.global.font_default then + return pfUI_config.global.font_default + end + + return "Interface\\AddOns\\pfUI\\fonts\\Myriad-Pro.ttf" +end + +local function GetPFUIBackgroundColor() + if pfUI_config + and pfUI_config.global + and pfUI_config.global.background_color then + return pfUI_config.global.background_color + end + + return "0,0,0,1" +end + +local function GetPFUIBackgroundAlpha() + if pfUI_config + and pfUI_config.global + and pfUI_config.global.background_alpha ~= nil then + return tostring(pfUI_config.global.background_alpha) + end + + return "0.75" +end + +------------------------------------------------------------ +-- Reset pfUI Style +------------------------------------------------------------ + +local function ResetPFUIStyle(module) + + if not module then + return + end + + module.pfui_background_alpha = GetPFUIBackgroundAlpha() + + if pfUI + and pfUI.events + and pfUI.events.TriggerEvent then + pfUI.events:TriggerEvent( + "config:changed", + module, + "pfui_background_alpha" + ) + end + + if pfUI.gui then + pfUI.gui.settingChanged = true + end + +end + +------------------------------------------------------------ +-- Reset Custom Style +------------------------------------------------------------ + +local function ResetCustomStyle(module) + + if not module then + return + end + + if not module.custom then + module.custom = {} + end + + local custom = module.custom + + custom.remove_parchment = "1" + custom.background_color = GetPFUIBackgroundColor() + custom.background_alpha = GetPFUIBackgroundAlpha() + custom.font = GetPFUIFont() + + custom.title_color = "1,0.82,0,1" + custom.text_color = "1,1,1,1" + + if pfUI + and pfUI.events + and pfUI.events.TriggerEvent then + pfUI.events:TriggerEvent( + "config:changed", + custom, + "remove_parchment" + ) + + pfUI.events:TriggerEvent( + "config:changed", + custom, + "background_color" + ) + + pfUI.events:TriggerEvent( + "config:changed", + custom, + "background_alpha" + ) + + pfUI.events:TriggerEvent( + "config:changed", + custom, + "font" + ) + + pfUI.events:TriggerEvent( + "config:changed", + custom, + "title_color" + ) + + pfUI.events:TriggerEvent( + "config:changed", + custom, + "text_color" + ) + end + + if pfUI.gui then + pfUI.gui.settingChanged = true + end + +end + +------------------------------------------------------------ +-- Update dependency states +------------------------------------------------------------ + +local function UpdateModuleState(module, frameRefs) + + if not module or not frameRefs then + return + end + + local usePFUI = module.use_pfui_style == "1" + local useCustom = module.use_custom_style == "1" + + -------------------------------------------------------- + -- pfUI Style controls + -------------------------------------------------------- + + if frameRefs.pfuiAlpha then + + if usePFUI then + frameRefs.pfuiAlpha.input:Enable() + frameRefs.pfuiAlpha.caption:SetTextColor( + 1, 1, 1, 1 + ) + else + frameRefs.pfuiAlpha.input:Disable() + frameRefs.pfuiAlpha.caption:SetTextColor( + 0.5, 0.5, 0.5, 1 + ) + end + + end + + if frameRefs.resetPFUI then + + if usePFUI then + frameRefs.resetPFUI.button:Enable() + frameRefs.resetPFUI.caption:SetTextColor( + 1, 1, 1, 1 + ) + else + frameRefs.resetPFUI.button:Disable() + frameRefs.resetPFUI.caption:SetTextColor( + 0.5, 0.5, 0.5, 1 + ) + end + + end + + -------------------------------------------------------- + -- Custom Style controls + -------------------------------------------------------- + + if frameRefs.custom then + + local enabled = useCustom + + for _, frame in pairs(frameRefs.custom) do + + if frame and frame.input then + + if enabled then + frame.input:Enable() + else + frame.input:Disable() + end + + elseif frame and frame.color then + + if enabled then + frame.color:Enable() + else + frame.color:Disable() + end + + elseif frame and frame.button then + + if enabled then + frame.button:Enable() + else + frame.button:Disable() + end + + end + + if frame and frame.caption then + + if enabled then + frame.caption:SetTextColor( + 1, 1, 1, 1 + ) + else + frame.caption:SetTextColor( + 0.5, 0.5, 0.5, 1 + ) + end + + end + + end + + end + +end + +------------------------------------------------------------ +-- Create one module configuration page +------------------------------------------------------------ + +local function CreateModuleConfig( + moduleName, + module, + CreateConfig +) + + local refs = { + custom = {} + } + + -------------------------------------------------------- + -- Use pfUI Style + -------------------------------------------------------- + + refs.usePFUI = CreateConfig( + nil, + "Use pfUI Style", + module, + "use_pfui_style", + "checkbox", + function() + + if module.use_pfui_style == "1" then + + module.use_custom_style = "0" + + end + + UpdateModuleState(module, refs) + + end + ) + + -------------------------------------------------------- + -- pfUI Background Opacity + -------------------------------------------------------- + + refs.pfuiAlpha = CreateConfig( + nil, + "pfUI Background Opacity", + module, + "pfui_background_alpha", + "slider" + ) + + -------------------------------------------------------- + -- Reset pfUI Default + -------------------------------------------------------- + + refs.resetPFUI = CreateConfig( + nil, + "Reset to pfUI Default", + module, + "reset_pfui", + "button", + function() + + ResetPFUIStyle(module) + + end + ) + + -------------------------------------------------------- + -- Use Custom Style + -------------------------------------------------------- + + refs.useCustom = CreateConfig( + nil, + "Use Custom Style", + module, + "use_custom_style", + "checkbox", + function() + + if module.use_custom_style == "1" then + + module.use_pfui_style = "0" + + end + + UpdateModuleState(module, refs) + + end + ) + + -------------------------------------------------------- + -- Custom: + -- Remove Blizzard Parchment Texture + -------------------------------------------------------- + + refs.custom.parchment = CreateConfig( + nil, + "Remove Blizzard Parchment Texture", + module.custom, + "remove_parchment", + "checkbox" + ) + + -------------------------------------------------------- + -- Custom: + -- Background Color + -------------------------------------------------------- + + refs.custom.backgroundColor = CreateConfig( + nil, + "Background Color", + module.custom, + "background_color", + "color" + ) + + -------------------------------------------------------- + -- Custom: + -- Background Opacity + -------------------------------------------------------- + + refs.custom.backgroundAlpha = CreateConfig( + nil, + "Background Opacity", + module.custom, + "background_alpha", + "slider" + ) + + -------------------------------------------------------- + -- Custom: + -- Fonts + -------------------------------------------------------- + + refs.custom.font = CreateConfig( + nil, + "Fonts", + module.custom, + "font", + "font" + ) + + -------------------------------------------------------- + -- Custom: + -- Title Color + -------------------------------------------------------- + + refs.custom.titleColor = CreateConfig( + nil, + "Title Color", + module.custom, + "title_color", + "color" + ) + + -------------------------------------------------------- + -- Custom: + -- Text Color + -------------------------------------------------------- + + refs.custom.textColor = CreateConfig( + nil, + "Text Color", + module.custom, + "text_color", + "color" + ) + + -------------------------------------------------------- + -- Reset Custom Values + -------------------------------------------------------- + + refs.custom.reset = CreateConfig( + nil, + "Reset Custom Values", + module.custom, + "reset", + "button", + function() + + ResetCustomStyle(module) + + end + ) + + -------------------------------------------------------- + -- Initial dependency state + -------------------------------------------------------- + + UpdateModuleState(module, refs) + +end + ------------------------------------------------------------ -- Create GUI ------------------------------------------------------------ @@ -65,104 +498,10 @@ function DQB:CreateGUI() "Quest & Gossip", function() - ------------------------------------------------ - -- Use pfUI Style - ------------------------------------------------ - - CreateConfig( - nil, - "Use pfUI Style", + CreateModuleConfig( + "questgossip", pfUI_config.dqb.questgossip, - "use_pfui_style", - "checkbox" - ) - - CreateConfig( - nil, - "pfUI Background Opacity", - pfUI_config.dqb.questgossip, - "pfui_background_alpha", - "slider" - ) - - CreateConfig( - nil, - "Reset to pfUI Default", - pfUI_config.dqb.questgossip, - "reset_pfui", - "button" - ) - - ------------------------------------------------ - -- Use Custom Style - ------------------------------------------------ - - CreateConfig( - nil, - "Use Custom Style", - pfUI_config.dqb.questgossip, - "use_custom_style", - "checkbox" - ) - - ------------------------------------------------ - -- Custom options - ------------------------------------------------ - - CreateConfig( - nil, - "Remove Blizzard Parchment Texture", - pfUI_config.dqb.questgossip.custom, - "remove_parchment", - "checkbox" - ) - - CreateConfig( - nil, - "Background Color", - pfUI_config.dqb.questgossip.custom, - "background_color", - "color" - ) - - CreateConfig( - nil, - "Background Opacity", - pfUI_config.dqb.questgossip.custom, - "background_alpha", - "slider" - ) - - CreateConfig( - nil, - "Fonts", - pfUI_config.dqb.questgossip.custom, - "font", - "font" - ) - - CreateConfig( - nil, - "Title Color", - pfUI_config.dqb.questgossip.custom, - "title_color", - "color" - ) - - CreateConfig( - nil, - "Text Color", - pfUI_config.dqb.questgossip.custom, - "text_color", - "color" - ) - - CreateConfig( - nil, - "Reset Custom Values", - pfUI_config.dqb.questgossip.custom, - "reset", - "button" + CreateConfig ) end @@ -177,104 +516,10 @@ function DQB:CreateGUI() "Quest Log", function() - ------------------------------------------------ - -- Use pfUI Style - ------------------------------------------------ - - CreateConfig( - nil, - "Use pfUI Style", + CreateModuleConfig( + "questlog", pfUI_config.dqb.questlog, - "use_pfui_style", - "checkbox" - ) - - CreateConfig( - nil, - "pfUI Background Opacity", - pfUI_config.dqb.questlog, - "pfui_background_alpha", - "slider" - ) - - CreateConfig( - nil, - "Reset to pfUI Default", - pfUI_config.dqb.questlog, - "reset_pfui", - "button" - ) - - ------------------------------------------------ - -- Use Custom Style - ------------------------------------------------ - - CreateConfig( - nil, - "Use Custom Style", - pfUI_config.dqb.questlog, - "use_custom_style", - "checkbox" - ) - - ------------------------------------------------ - -- Custom options - ------------------------------------------------ - - CreateConfig( - nil, - "Remove Blizzard Parchment Texture", - pfUI_config.dqb.questlog.custom, - "remove_parchment", - "checkbox" - ) - - CreateConfig( - nil, - "Background Color", - pfUI_config.dqb.questlog.custom, - "background_color", - "color" - ) - - CreateConfig( - nil, - "Background Opacity", - pfUI_config.dqb.questlog.custom, - "background_alpha", - "slider" - ) - - CreateConfig( - nil, - "Fonts", - pfUI_config.dqb.questlog.custom, - "font", - "font" - ) - - CreateConfig( - nil, - "Title Color", - pfUI_config.dqb.questlog.custom, - "title_color", - "color" - ) - - CreateConfig( - nil, - "Text Color", - pfUI_config.dqb.questlog.custom, - "text_color", - "color" - ) - - CreateConfig( - nil, - "Reset Custom Values", - pfUI_config.dqb.questlog.custom, - "reset", - "button" + CreateConfig ) end @@ -289,108 +534,15 @@ function DQB:CreateGUI() "Books", function() - ------------------------------------------------ - -- Use pfUI Style - ------------------------------------------------ - - CreateConfig( - nil, - "Use pfUI Style", + CreateModuleConfig( + "books", pfUI_config.dqb.books, - "use_pfui_style", - "checkbox" - ) - - CreateConfig( - nil, - "pfUI Background Opacity", - pfUI_config.dqb.books, - "pfui_background_alpha", - "slider" - ) - - CreateConfig( - nil, - "Reset to pfUI Default", - pfUI_config.dqb.books, - "reset_pfui", - "button" - ) - - ------------------------------------------------ - -- Use Custom Style - ------------------------------------------------ - - CreateConfig( - nil, - "Use Custom Style", - pfUI_config.dqb.books, - "use_custom_style", - "checkbox" - ) - - ------------------------------------------------ - -- Custom options - ------------------------------------------------ - - CreateConfig( - nil, - "Remove Blizzard Parchment Texture", - pfUI_config.dqb.books.custom, - "remove_parchment", - "checkbox" - ) - - CreateConfig( - nil, - "Background Color", - pfUI_config.dqb.books.custom, - "background_color", - "color" - ) - - CreateConfig( - nil, - "Background Opacity", - pfUI_config.dqb.books.custom, - "background_alpha", - "slider" - ) - - CreateConfig( - nil, - "Fonts", - pfUI_config.dqb.books.custom, - "font", - "font" - ) - - CreateConfig( - nil, - "Title Color", - pfUI_config.dqb.books.custom, - "title_color", - "color" - ) - - CreateConfig( - nil, - "Text Color", - pfUI_config.dqb.books.custom, - "text_color", - "color" - ) - - CreateConfig( - nil, - "Reset Custom Values", - pfUI_config.dqb.books.custom, - "reset", - "button" + CreateConfig ) end ) + end ------------------------------------------------------------ @@ -422,6 +574,7 @@ event:SetScript("OnEvent", function() end event:UnregisterEvent("ADDON_LOADED") + end end)