Update gui.lua
Changed the menus in the GUI
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
------------------------------------------------------------
|
||||
-- pfUI-DQB
|
||||
-- gui.lua
|
||||
--
|
||||
-- Registers DQB configuration inside pfUI's GUI.
|
||||
------------------------------------------------------------
|
||||
|
||||
local DQB = pfUI and pfUI.dqb
|
||||
|
||||
if not DQB then
|
||||
return
|
||||
end
|
||||
|
||||
-- Create DQB configuration menu
|
||||
------------------------------------------------------------
|
||||
-- Create GUI
|
||||
------------------------------------------------------------
|
||||
|
||||
function DQB:CreateGUI()
|
||||
|
||||
-- Make sure pfUI GUI is available
|
||||
|
||||
if not pfUI.gui then
|
||||
return
|
||||
end
|
||||
|
||||
-- Makes sure that the configuration exists
|
||||
|
||||
if self.InitializeConfig then
|
||||
self:InitializeConfig()
|
||||
end
|
||||
@@ -23,224 +28,18 @@ function DQB:CreateGUI()
|
||||
if not pfUI_config or not pfUI_config.dqb then
|
||||
return
|
||||
end
|
||||
|
||||
-- pfUI GUI helpers
|
||||
|
||||
local CreateConfig = pfUI.gui.CreateConfig
|
||||
local CreateGUIEntry = pfUI.gui.CreateGUIEntry
|
||||
|
||||
if not CreateConfig or not CreateGUIEntry then
|
||||
return
|
||||
end
|
||||
|
||||
-- CUSTOM OPACITY SLIDER
|
||||
-- pfUI's CreateConfig does not provide a slider widget.
|
||||
-- Therefore it has to create the normal pfUI configuration row
|
||||
-- first and replace its EditBox with the Slider.
|
||||
-- This keeps the exact same positioning/layout used by
|
||||
-- the rest of pfUI's GUI.
|
||||
local function CreateOpacitySlider(caption, category, config)
|
||||
|
||||
-- Create the normal pfUI config row.
|
||||
local frame = CreateConfig(
|
||||
nil,
|
||||
caption,
|
||||
category,
|
||||
config,
|
||||
"text"
|
||||
)
|
||||
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
|
||||
-- Hide the normal text input.
|
||||
if frame.input then
|
||||
frame.input:Hide()
|
||||
end
|
||||
|
||||
-- Create slider.
|
||||
local slider = CreateFrame(
|
||||
"Slider",
|
||||
nil,
|
||||
frame
|
||||
)
|
||||
--------------------------------------------------------
|
||||
-- General
|
||||
--------------------------------------------------------
|
||||
|
||||
slider:SetWidth(180)
|
||||
slider:SetHeight(10)
|
||||
|
||||
slider:SetOrientation("HORIZONTAL")
|
||||
|
||||
slider:SetMinMaxValues(0, 1)
|
||||
|
||||
-- Set the thumb texture
|
||||
if pfUI.media and pfUI.media["img:col"] then
|
||||
slider:SetThumbTexture(
|
||||
pfUI.media["img:col"]
|
||||
)
|
||||
end
|
||||
|
||||
-- Position slider.
|
||||
slider:SetPoint(
|
||||
"RIGHT",
|
||||
frame,
|
||||
"RIGHT",
|
||||
-38,
|
||||
0
|
||||
)
|
||||
|
||||
-- Try to apply pfUI slider skin.
|
||||
-- SkinSlider expects a valid thumb texture.
|
||||
-- If anything is unavailable it will simply keep the
|
||||
-- normal slider instead of generating an error.
|
||||
if pfUI.api and pfUI.api.SkinSlider then
|
||||
local thumb = slider:GetThumbTexture()
|
||||
|
||||
if thumb then
|
||||
pfUI.api.SkinSlider(slider)
|
||||
end
|
||||
end
|
||||
|
||||
-- Current value.
|
||||
local value = tonumber(category[config])
|
||||
|
||||
if not value then
|
||||
value = 0.85
|
||||
end
|
||||
|
||||
if value < 0 then
|
||||
value = 0
|
||||
elseif value > 1 then
|
||||
value = 1
|
||||
end
|
||||
|
||||
slider:SetValue(value)
|
||||
|
||||
-- Value text.
|
||||
local valueText = frame:CreateFontString(
|
||||
nil,
|
||||
"OVERLAY"
|
||||
)
|
||||
|
||||
valueText:SetFont(
|
||||
pfUI.font_default,
|
||||
pfUI_config.global.font_size - 1,
|
||||
"OUTLINE"
|
||||
)
|
||||
|
||||
valueText:SetJustifyH("RIGHT")
|
||||
|
||||
valueText:SetWidth(34)
|
||||
|
||||
valueText:SetPoint(
|
||||
"RIGHT",
|
||||
frame,
|
||||
"RIGHT",
|
||||
0,
|
||||
0
|
||||
)
|
||||
|
||||
valueText:SetText(
|
||||
math.floor(value * 100 + 0.5) .. "%"
|
||||
)
|
||||
|
||||
-- Slider value changed.
|
||||
slider:SetScript(
|
||||
"OnValueChanged",
|
||||
function()
|
||||
|
||||
local raw = this:GetValue()
|
||||
|
||||
-- Round to 5%.
|
||||
-- Testing with 0.5 first, changing to 0.1 for more precise control later, maybe.
|
||||
local newValue =
|
||||
math.floor(raw * 20 + 0.5) / 20
|
||||
|
||||
if newValue < 0 then
|
||||
newValue = 0
|
||||
elseif newValue > 1 then
|
||||
newValue = 1
|
||||
end
|
||||
|
||||
-- Prevent unnecessary recursion.
|
||||
if math.abs(raw - newValue) > 0.001 then
|
||||
|
||||
this:SetValue(newValue)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- Save value.
|
||||
category[config] = string.format(
|
||||
"%.2f",
|
||||
newValue
|
||||
)
|
||||
|
||||
-- Update visible percentage.
|
||||
-- if later changed the round value to 0.1 also change this
|
||||
if valueText then
|
||||
valueText:SetText(
|
||||
math.floor(newValue * 100 + 0.5)
|
||||
.. "%"
|
||||
)
|
||||
end
|
||||
|
||||
-- Tell pfUI that configuration changed.
|
||||
if pfUI.events
|
||||
and pfUI.events.TriggerEvent then
|
||||
|
||||
pfUI.events:TriggerEvent(
|
||||
"config:changed",
|
||||
category,
|
||||
config
|
||||
)
|
||||
|
||||
else
|
||||
|
||||
pfUI.gui.settingChanged = true
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
-- Mouse wheel support.
|
||||
-- If round value changed to 0.1 also change this for the mousewheel
|
||||
slider:EnableMouseWheel(true)
|
||||
|
||||
slider:SetScript(
|
||||
"OnMouseWheel",
|
||||
function()
|
||||
|
||||
local current = this:GetValue()
|
||||
|
||||
local step = 0.05
|
||||
|
||||
if arg1 > 0 then
|
||||
current = current + step
|
||||
else
|
||||
current = current - step
|
||||
end
|
||||
|
||||
if current < 0 then
|
||||
current = 0
|
||||
elseif current > 1 then
|
||||
current = 1
|
||||
end
|
||||
|
||||
this:SetValue(current)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
-- Store references
|
||||
frame.input = slider
|
||||
frame.value = valueText
|
||||
|
||||
return frame
|
||||
|
||||
end
|
||||
|
||||
-- GENERAL
|
||||
CreateGUIEntry(
|
||||
"DQB",
|
||||
"General",
|
||||
@@ -256,34 +55,60 @@ function DQB:CreateGUI()
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
-- QUEST & GOSSIP
|
||||
|
||||
--------------------------------------------------------
|
||||
-- Quest & Gossip
|
||||
--------------------------------------------------------
|
||||
|
||||
CreateGUIEntry(
|
||||
"DQB",
|
||||
"Quest & Gossip",
|
||||
function()
|
||||
|
||||
-- PRESETS
|
||||
-- PARA ALTERAR HOJE COMO VAI SER FEITO O GUI PARA IMPLEMENTAÇÃO DO NOVO ESTILO (ESTA PARTE + FIXFONTS
|
||||
-- A TRABALHAR EM CONJUNTO, APENAS 1 OPÇÃO.)
|
||||
|
||||
------------------------------------------------
|
||||
-- Use pfUI Style
|
||||
------------------------------------------------
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Skin and apply pfUI Style",
|
||||
"Use pfUI Style",
|
||||
pfUI_config.dqb.questgossip,
|
||||
"pfui_style",
|
||||
"use_pfui_style",
|
||||
"checkbox"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fix Fonts",
|
||||
"pfUI Background Opacity",
|
||||
pfUI_config.dqb.questgossip,
|
||||
"fix_fonts",
|
||||
"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
|
||||
-- ALTERAR HOJE O COMPORTAMENTO ENTRE pfUI Style E Custom. ADD GREYOUT OPTIONS; ADD REVERT BACK TO DEFAULTS
|
||||
|
||||
------------------------------------------------
|
||||
-- Custom options
|
||||
------------------------------------------------
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Parchment Texture",
|
||||
@@ -300,21 +125,20 @@ function DQB:CreateGUI()
|
||||
"color"
|
||||
)
|
||||
|
||||
CreateOpacitySlider(
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Background Opacity",
|
||||
pfUI_config.dqb.questgossip.custom,
|
||||
"background_alpha"
|
||||
"background_alpha",
|
||||
"slider"
|
||||
)
|
||||
|
||||
-- USE PFUI FONT DROPDOWN
|
||||
-- INCLUÍDO NO CUSTOM; PARA ALTERAR.
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fonts",
|
||||
pfUI_config.dqb.questgossip.custom,
|
||||
"font",
|
||||
"dropdown",
|
||||
pfUI.gui.dropdowns.fonts
|
||||
"font"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
@@ -333,35 +157,70 @@ function DQB:CreateGUI()
|
||||
"color"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Reset Custom Values",
|
||||
pfUI_config.dqb.questgossip.custom,
|
||||
"reset",
|
||||
"button"
|
||||
)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
-- QUEST LOG
|
||||
|
||||
--------------------------------------------------------
|
||||
-- Quest Log
|
||||
--------------------------------------------------------
|
||||
|
||||
CreateGUIEntry(
|
||||
"DQB",
|
||||
"Quest Log",
|
||||
function()
|
||||
|
||||
-- PRESETS
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
|
||||
------------------------------------------------
|
||||
-- Use pfUI Style
|
||||
------------------------------------------------
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Skin and apply pfUI Style",
|
||||
"Use pfUI Style",
|
||||
pfUI_config.dqb.questlog,
|
||||
"pfui_style",
|
||||
"use_pfui_style",
|
||||
"checkbox"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fix Fonts",
|
||||
"pfUI Background Opacity",
|
||||
pfUI_config.dqb.questlog,
|
||||
"fix_fonts",
|
||||
"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
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
|
||||
------------------------------------------------
|
||||
-- Custom options
|
||||
------------------------------------------------
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Parchment Texture",
|
||||
@@ -378,21 +237,20 @@ function DQB:CreateGUI()
|
||||
"color"
|
||||
)
|
||||
|
||||
CreateOpacitySlider(
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Background Opacity",
|
||||
pfUI_config.dqb.questlog.custom,
|
||||
"background_alpha"
|
||||
"background_alpha",
|
||||
"slider"
|
||||
)
|
||||
|
||||
-- USE PFUI FONT DROPDOWN
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fonts",
|
||||
pfUI_config.dqb.questlog.custom,
|
||||
"font",
|
||||
"dropdown",
|
||||
pfUI.gui.dropdowns.fonts
|
||||
"font"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
@@ -411,36 +269,70 @@ function DQB:CreateGUI()
|
||||
"color"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Reset Custom Values",
|
||||
pfUI_config.dqb.questlog.custom,
|
||||
"reset",
|
||||
"button"
|
||||
)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
-- BOOKS
|
||||
-- Books corresponds to the original brues's pfUI itemtext.lua.
|
||||
|
||||
--------------------------------------------------------
|
||||
-- Books
|
||||
--------------------------------------------------------
|
||||
|
||||
CreateGUIEntry(
|
||||
"DQB",
|
||||
"Books",
|
||||
function()
|
||||
|
||||
-- PRESETS
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
|
||||
------------------------------------------------
|
||||
-- Use pfUI Style
|
||||
------------------------------------------------
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Skin and apply pfUI Style",
|
||||
"Use pfUI Style",
|
||||
pfUI_config.dqb.books,
|
||||
"pfui_style",
|
||||
"use_pfui_style",
|
||||
"checkbox"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fix Fonts",
|
||||
"pfUI Background Opacity",
|
||||
pfUI_config.dqb.books,
|
||||
"fix_fonts",
|
||||
"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
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
|
||||
------------------------------------------------
|
||||
-- Custom options
|
||||
------------------------------------------------
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Parchment Texture",
|
||||
@@ -457,21 +349,20 @@ function DQB:CreateGUI()
|
||||
"color"
|
||||
)
|
||||
|
||||
CreateOpacitySlider(
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Background Opacity",
|
||||
pfUI_config.dqb.books.custom,
|
||||
"background_alpha"
|
||||
"background_alpha",
|
||||
"slider"
|
||||
)
|
||||
|
||||
-- USE PFUI FONT DROPDOWN
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fonts",
|
||||
pfUI_config.dqb.books.custom,
|
||||
"font",
|
||||
"dropdown",
|
||||
pfUI.gui.dropdowns.fonts
|
||||
"font"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
@@ -490,20 +381,30 @@ function DQB:CreateGUI()
|
||||
"color"
|
||||
)
|
||||
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Reset Custom Values",
|
||||
pfUI_config.dqb.books.custom,
|
||||
"reset",
|
||||
"button"
|
||||
)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
-- MERCHANT
|
||||
-- Intentionally not configured yet.
|
||||
-- Don't think Merchant is need to be customized with DQB, in case of, it will be here.
|
||||
end
|
||||
|
||||
-- Compatibility with core.lua
|
||||
------------------------------------------------------------
|
||||
-- Initialize GUI
|
||||
------------------------------------------------------------
|
||||
|
||||
function DQB:InitializeGUI()
|
||||
self:CreateGUI()
|
||||
end
|
||||
|
||||
-- Initialize GUI after pfUI has loaded
|
||||
------------------------------------------------------------
|
||||
-- Wait for pfUI
|
||||
------------------------------------------------------------
|
||||
|
||||
local event = CreateFrame("Frame")
|
||||
|
||||
event:RegisterEvent("ADDON_LOADED")
|
||||
|
||||
Reference in New Issue
Block a user