Files
wow-voiceover/AI_VoiceOver/Libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua
Matthew Steinhardt f19d079fb8 Feature Contribution: Minimap Button, Addon Options Menu, Hide NPC Head (#41)
* Added Libaries

- AceConfig is used to register interface options with the Blizzard Addons UI
- AceGUI is used to create the options window
- LibDataBroker registers the optionsTable
- LibDBIcon registers the optionsTable

* Added new libraries to embeds.xml

* Added function to remove all sounds from queue

- this is used for a minimap button feature

* Updated Utils

- Added a function to add color to text. This is used when creating the options menu.

* Added minimap Icon

- I made this icon using the icon for the addon (slightly modified to fit the small resolution)

* Modified db variables

- Changed ShowFrameBackground to a string value (easier when using Ace dropdown)

* Add Options Menu

- Added the framework for an options menu that hooks into the Interface options panel as well. 

- I elected to break things down into localized modules with a Module Loader utility class.

- Also added some useful debugging utility too

* Added new Options files to TOC

* Added minimap button

- Removed old settings code and redirected the settings button to open the new settings window

- Added all the settings from the old frame

- Added ability to hide the talking frame as well

- Minimap button has three actions: 
-- Left Click: Opens settings menu
-- Right Click: Stops & clears all queued audio
-- Middle Click: Pauses/Plays audio

* Added "Hide Minimap" option

* Module-less version

- Settings have been moved to an options panel
- Minimap button has a few neat functions
- Added ability to hide talking NPC head (useful for immersion addon)

* Changed path used to reach option variables
2023-04-07 17:05:53 -04:00

144 lines
3.7 KiB
Lua

--[[-----------------------------------------------------------------------------
BlizOptionsGroup Container
Simple container widget for the integration of AceGUI into the Blizzard Interface Options
-------------------------------------------------------------------------------]]
local Type, Version = "BlizOptionsGroup", 26
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs = pairs
-- WoW APIs
local CreateFrame = CreateFrame
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function OnShow(frame)
frame.obj:Fire("OnShow")
end
local function OnHide(frame)
frame.obj:Fire("OnHide")
end
--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
local function okay(frame)
frame.obj:Fire("okay")
end
local function cancel(frame)
frame.obj:Fire("cancel")
end
local function default(frame)
frame.obj:Fire("default")
end
local function refresh(frame)
frame.obj:Fire("refresh")
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetName()
self:SetTitle()
end,
-- ["OnRelease"] = nil,
["OnWidthSet"] = function(self, width)
local content = self.content
local contentwidth = width - 63
if contentwidth < 0 then
contentwidth = 0
end
content:SetWidth(contentwidth)
content.width = contentwidth
end,
["OnHeightSet"] = function(self, height)
local content = self.content
local contentheight = height - 26
if contentheight < 0 then
contentheight = 0
end
content:SetHeight(contentheight)
content.height = contentheight
end,
["SetName"] = function(self, name, parent)
self.frame.name = name
self.frame.parent = parent
end,
["SetTitle"] = function(self, title)
local content = self.content
content:ClearAllPoints()
if not title or title == "" then
content:SetPoint("TOPLEFT", 10, -10)
self.label:SetText("")
else
content:SetPoint("TOPLEFT", 10, -40)
self.label:SetText(title)
end
content:SetPoint("BOTTOMRIGHT", -10, 10)
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
frame:Hide()
-- support functions for the Blizzard Interface Options
frame.okay = okay
frame.cancel = cancel
frame.default = default
frame.refresh = refresh
-- 10.0 support function aliases (cancel has been removed)
frame.OnCommit = okay
frame.OnDefault = default
frame.OnRefresh = refresh
frame:SetScript("OnHide", OnHide)
frame:SetScript("OnShow", OnShow)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
label:SetPoint("TOPLEFT", 10, -15)
label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
label:SetJustifyH("LEFT")
label:SetJustifyV("TOP")
--Container Support
local content = CreateFrame("Frame", nil, frame)
content:SetPoint("TOPLEFT", 10, -10)
content:SetPoint("BOTTOMRIGHT", -10, 10)
local widget = {
label = label,
frame = frame,
content = content,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsContainer(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)