Cleaned commentary lines
Comentários em o que vai ser mudado a seguir.
This commit is contained in:
@@ -1,35 +1,21 @@
|
||||
------------------------------------------------------------
|
||||
-- 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
|
||||
------------------------------------------------------------
|
||||
|
||||
function DQB:CreateGUI()
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
-- Make sure pfUI GUI is available
|
||||
--------------------------------------------------------
|
||||
|
||||
if not pfUI.gui then
|
||||
return
|
||||
end
|
||||
|
||||
--------------------------------------------------------
|
||||
-- Make sure our configuration exists
|
||||
--------------------------------------------------------
|
||||
|
||||
|
||||
-- Makes sure that the configuration exists
|
||||
if self.InitializeConfig then
|
||||
self:InitializeConfig()
|
||||
end
|
||||
@@ -37,37 +23,24 @@ 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
|
||||
--------------------------------------------------------
|
||||
--
|
||||
|
||||
-- CUSTOM OPACITY SLIDER
|
||||
-- pfUI's CreateConfig does not provide a slider widget.
|
||||
-- We therefore create the normal pfUI configuration row
|
||||
-- first and replace its EditBox with our own Slider.
|
||||
--
|
||||
-- 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.
|
||||
--------------------------------------------------------
|
||||
|
||||
-- the rest of pfUI's GUI.
|
||||
local function CreateOpacitySlider(caption, category, config)
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
-- Create the normal pfUI config row.
|
||||
----------------------------------------------------
|
||||
|
||||
local frame = CreateConfig(
|
||||
nil,
|
||||
caption,
|
||||
@@ -79,20 +52,13 @@ function DQB:CreateGUI()
|
||||
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,
|
||||
@@ -105,22 +71,15 @@ function DQB:CreateGUI()
|
||||
slider:SetOrientation("HORIZONTAL")
|
||||
|
||||
slider:SetMinMaxValues(0, 1)
|
||||
|
||||
----------------------------------------------------
|
||||
-- IMPORTANT:
|
||||
-- Set the thumb texture BEFORE GetThumbTexture().
|
||||
----------------------------------------------------
|
||||
|
||||
|
||||
-- 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,
|
||||
@@ -128,16 +87,11 @@ function DQB:CreateGUI()
|
||||
-38,
|
||||
0
|
||||
)
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
-- Try to apply pfUI slider skin.
|
||||
--
|
||||
|
||||
-- Try to apply pfUI slider skin.
|
||||
-- SkinSlider expects a valid thumb texture.
|
||||
-- If anything is unavailable, we simply keep the
|
||||
-- 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()
|
||||
|
||||
@@ -145,12 +99,8 @@ function DQB:CreateGUI()
|
||||
pfUI.api.SkinSlider(slider)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
-- Current value.
|
||||
----------------------------------------------------
|
||||
|
||||
local value = tonumber(category[config])
|
||||
|
||||
if not value then
|
||||
@@ -164,12 +114,8 @@ function DQB:CreateGUI()
|
||||
end
|
||||
|
||||
slider:SetValue(value)
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
-- Value text.
|
||||
----------------------------------------------------
|
||||
|
||||
local valueText = frame:CreateFontString(
|
||||
nil,
|
||||
"OVERLAY"
|
||||
@@ -196,22 +142,16 @@ function DQB:CreateGUI()
|
||||
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
|
||||
|
||||
@@ -220,46 +160,31 @@ function DQB:CreateGUI()
|
||||
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
|
||||
|
||||
@@ -277,12 +202,9 @@ function DQB:CreateGUI()
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
-- Mouse wheel support.
|
||||
----------------------------------------------------
|
||||
|
||||
-- If round value changed to 0.1 also change this for the mousewheel
|
||||
slider:EnableMouseWheel(true)
|
||||
|
||||
slider:SetScript(
|
||||
@@ -309,24 +231,16 @@ function DQB:CreateGUI()
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
-- Store references.
|
||||
----------------------------------------------------
|
||||
|
||||
|
||||
-- Store references
|
||||
frame.input = slider
|
||||
frame.value = valueText
|
||||
|
||||
return frame
|
||||
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
-- GENERAL
|
||||
--------------------------------------------------------
|
||||
|
||||
CreateGUIEntry(
|
||||
"DQB",
|
||||
"General",
|
||||
@@ -342,21 +256,16 @@ function DQB:CreateGUI()
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
-- 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.)
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Skin and apply pfUI Style",
|
||||
@@ -372,12 +281,9 @@ function DQB:CreateGUI()
|
||||
"fix_fonts",
|
||||
"checkbox"
|
||||
)
|
||||
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-- CUSTOM
|
||||
------------------------------------------------
|
||||
|
||||
-- ALTERAR HOJE O COMPORTAMENTO ENTRE pfUI Style E Custom. ADD GREYOUT OPTIONS; ADD REVERT BACK TO DEFAULTS
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Parchment Texture",
|
||||
@@ -399,11 +305,9 @@ function DQB:CreateGUI()
|
||||
pfUI_config.dqb.questgossip.custom,
|
||||
"background_alpha"
|
||||
)
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-- USE PFUI FONT DROPDOWN
|
||||
------------------------------------------------
|
||||
|
||||
-- INCLUÍDO NO CUSTOM; PARA ALTERAR.
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fonts",
|
||||
@@ -431,21 +335,15 @@ function DQB:CreateGUI()
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
-- QUEST LOG
|
||||
--------------------------------------------------------
|
||||
|
||||
CreateGUIEntry(
|
||||
"DQB",
|
||||
"Quest Log",
|
||||
function()
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-- PRESETS
|
||||
------------------------------------------------
|
||||
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Skin and apply pfUI Style",
|
||||
@@ -461,12 +359,9 @@ function DQB:CreateGUI()
|
||||
"fix_fonts",
|
||||
"checkbox"
|
||||
)
|
||||
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-- CUSTOM
|
||||
------------------------------------------------
|
||||
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Parchment Texture",
|
||||
@@ -488,11 +383,9 @@ function DQB:CreateGUI()
|
||||
pfUI_config.dqb.questlog.custom,
|
||||
"background_alpha"
|
||||
)
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-- USE PFUI FONT DROPDOWN
|
||||
------------------------------------------------
|
||||
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fonts",
|
||||
@@ -520,24 +413,16 @@ function DQB:CreateGUI()
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- BOOKS
|
||||
--------------------------------------------------------
|
||||
--
|
||||
-- Books corresponds to the original pfUI itemtext.lua.
|
||||
--------------------------------------------------------
|
||||
|
||||
|
||||
-- BOOKS
|
||||
-- Books corresponds to the original brues's pfUI itemtext.lua.
|
||||
CreateGUIEntry(
|
||||
"DQB",
|
||||
"Books",
|
||||
function()
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-- PRESETS
|
||||
------------------------------------------------
|
||||
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Skin and apply pfUI Style",
|
||||
@@ -553,12 +438,9 @@ function DQB:CreateGUI()
|
||||
"fix_fonts",
|
||||
"checkbox"
|
||||
)
|
||||
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-- CUSTOM
|
||||
------------------------------------------------
|
||||
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Remove Blizzard Parchment Texture",
|
||||
@@ -580,11 +462,9 @@ function DQB:CreateGUI()
|
||||
pfUI_config.dqb.books.custom,
|
||||
"background_alpha"
|
||||
)
|
||||
|
||||
------------------------------------------------
|
||||
|
||||
-- USE PFUI FONT DROPDOWN
|
||||
------------------------------------------------
|
||||
|
||||
-- O MESMO DO QUE O QUEST & GOSSIP.
|
||||
CreateConfig(
|
||||
nil,
|
||||
"Fonts",
|
||||
@@ -612,32 +492,18 @@ function DQB:CreateGUI()
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- MERCHANT
|
||||
--------------------------------------------------------
|
||||
--
|
||||
|
||||
-- MERCHANT
|
||||
-- Intentionally not configured yet.
|
||||
-- Merchant remains untouched for now.
|
||||
--------------------------------------------------------
|
||||
|
||||
-- Don't think Merchant is need to be customized with DQB, in case of, it will be here.
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------
|
||||
-- Compatibility with core.lua
|
||||
------------------------------------------------------------
|
||||
|
||||
function DQB:InitializeGUI()
|
||||
self:CreateGUI()
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------
|
||||
-- Initialize GUI after pfUI has loaded
|
||||
------------------------------------------------------------
|
||||
|
||||
local event = CreateFrame("Frame")
|
||||
|
||||
event:RegisterEvent("ADDON_LOADED")
|
||||
@@ -657,4 +523,4 @@ event:SetScript("OnEvent", function()
|
||||
event:UnregisterEvent("ADDON_LOADED")
|
||||
end
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user