Files
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

104 lines
2.7 KiB
Lua

--[[-----------------------------------------------------------------------------
Button Widget
Graphical Button.
-------------------------------------------------------------------------------]]
local Type, Version = "Button", 24
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 _G = _G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...)
AceGUI:ClearFocus()
PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
frame.obj:Fire("OnClick", ...)
end
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
end
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
-- restore default values
self:SetHeight(24)
self:SetWidth(200)
self:SetDisabled(false)
self:SetAutoWidth(false)
self:SetText()
end,
-- ["OnRelease"] = nil,
["SetText"] = function(self, text)
self.text:SetText(text)
if self.autoWidth then
self:SetWidth(self.text:GetStringWidth() + 30)
end
end,
["SetAutoWidth"] = function(self, autoWidth)
self.autoWidth = autoWidth
if self.autoWidth then
self:SetWidth(self.text:GetStringWidth() + 30)
end
end,
["SetDisabled"] = function(self, disabled)
self.disabled = disabled
if disabled then
self.frame:Disable()
else
self.frame:Enable()
end
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
frame:Hide()
frame:EnableMouse(true)
frame:SetScript("OnClick", Button_OnClick)
frame:SetScript("OnEnter", Control_OnEnter)
frame:SetScript("OnLeave", Control_OnLeave)
local text = frame:GetFontString()
text:ClearAllPoints()
text:SetPoint("TOPLEFT", 15, -1)
text:SetPoint("BOTTOMRIGHT", -15, 1)
text:SetJustifyV("MIDDLE")
local widget = {
text = text,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)