Skip to content

Commit

Permalink
added way more functionality to settings
Browse files Browse the repository at this point in the history
Can now add header or footer dashed lines as well as header or footer blank lines.  Can also enable or disable the tooltip completely #5 .

Also fixed issues with resetting settings and now that should function way better.
  • Loading branch information
jbolduan committed Aug 14, 2024
1 parent 8744e21 commit 868558a
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 17 deletions.
119 changes: 109 additions & 10 deletions Click-To-Cast-Tooltip-Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ local defaults = {
b = 0,
a = 1
},
showHeader = true
dividerColor = {
r = 1,
g = 1,
b = 1,
a = 1
},
showHeader = false,
showFooter = false,
showTooltip = true,
showNewLineTop = false,
showNewLineBottom = false
}

-- Check to see if the SavedVariables are already set, if not, set them to the defaults.
Expand All @@ -36,6 +46,18 @@ function f:OnEvent(event, addOnName)
addonTable.db = ClickToCastTooltipDB

-- If any of the default settings are missing, copy them over.
-- Check if the root color tables are missing, if so, copy them over.
if ((addonTable.db.buttonColor == nil)) then
addonTable.db.buttonColor = CopyTable(defaults.buttonColor)
end
if ((addonTable.db.actionColor == nil)) then
addonTable.db.actionColor = CopyTable(defaults.actionColor)
end
if ((addonTable.db.dividerColor == nil)) then
addonTable.db.dividerColor = CopyTable(defaults.dividerColor)
end

-- Check if the individual color values are missing, if so, copy them over.
if ((addonTable.db.buttonColor.r == nil) or (addonTable.db.buttonColor.g == nil) or
(addonTable.db.buttonColor.b == nil) or (addonTable.db.buttonColor.a == nil)) then
addonTable.db.buttonColor = CopyTable(defaults.buttonColor)
Expand All @@ -44,9 +66,27 @@ function f:OnEvent(event, addOnName)
(addonTable.db.actionColor.b == nil) or (addonTable.db.actionColor.a == nil)) then
addonTable.db.actionColor = CopyTable(defaults.actionColor)
end
if ((addonTable.db.dividerColor.r == nil) or (addonTable.db.dividerColor.g == nil) or
(addonTable.db.dividerColor.b == nil) or (addonTable.db.dividerColor.a == nil)) then
addonTable.db.dividerColor = CopyTable(defaults.dividerColor)
end

-- Check if the boolean values are missing, if so, copy them over.
if (addonTable.db.showHeader ~= true and addonTable.db.showHeader ~= false) then
addonTable.db.showHeader = defaults.showHeader
end
if (addonTable.db.showFooter ~= true and addonTable.db.showFooter ~= false) then
addonTable.db.showFooter = defaults.showFooter
end
if (addonTable.db.showTooltip ~= true and addonTable.db.showTooltip ~= false) then
addonTable.db.showTooltip = defaults.showTooltip
end
if (addonTable.db.showNewLineTop ~= true and addonTable.db.showNewLineTop ~= false) then
addonTable.db.showNewLineTop = defaults.showNewLineTop
end
if (addonTable.db.showNewLineBottom ~= true and addonTable.db.showNewLineBottom ~= false) then
addonTable.db.showNewLineBottom = defaults.showNewLineBottom
end

self:InitializeOptions()
end
Expand All @@ -59,19 +99,55 @@ f:SetScript("OnEvent", f.OnEvent)
-- Create the options panel for the addon.
function f:InitializeOptions()

-- Create a checkbox which will allow the user to toggle the tooltip on and off.
local showTooltip = CreateFrame("CheckButton", nil, f, "InterfaceOptionsCheckButtonTemplate")
showTooltip:SetPoint("TOPLEFT")
showTooltip.Text:SetText("Show tooltip")
showTooltip:HookScript("OnClick", function(_, btn, down)
addonTable.db.showTooltip = showTooltip:GetChecked()
end)
showTooltip:SetChecked(addonTable.db.showTooltip)

-- Create a checkbox which will allow the user to toggle the header on the tooltip.
local showHeader = CreateFrame("CheckButton", nil, f, "InterfaceOptionsCheckButtonTemplate")
showHeader:SetPoint("TOPLEFT", 20, -20)
showHeader:SetPoint("TOPLEFT", showTooltip, "BOTTOMLEFT")
showHeader.Text:SetText("Show header with divider")
showHeader:HookScript("OnClick", function(_, btn, down)
addonTable.db.showHeader = showHeader:GetChecked()
end)
showHeader:SetChecked(addonTable.db.showHeader)

-- Create a checkbox which whill allow the user to toggle the footer on the tooltip.
local showFooter = CreateFrame("CheckButton", nil, f, "InterfaceOptionsCheckButtonTemplate")
showFooter:SetPoint("TOPLEFT", showHeader, "BOTTOMLEFT")
showFooter.Text:SetText("Show footer with divider")
showFooter:HookScript("OnClick", function(_, btn, down)
addonTable.db.showFooter = showFooter:GetChecked()
end)
showFooter:SetChecked(addonTable.db.showFooter)

-- Create a checkbox which will allow the user to toggle the new line at top.
local showNewLineTop = CreateFrame("CheckButton", nil, f, "InterfaceOptionsCheckButtonTemplate")
showNewLineTop:SetPoint("TOPLEFT", showFooter, "BOTTOMLEFT")
showNewLineTop.Text:SetText("Show new line at top")
showNewLineTop:HookScript("OnClick", function(_, btn, down)
addonTable.db.showNewLineTop = showNewLineTop:GetChecked()
end)
showNewLineTop:SetChecked(addonTable.db.showNewLineTop)

-- Create a checkbox which will allow the user to toggle the new line at bottom.
local showNewLineBottom = CreateFrame("CheckButton", nil, f, "InterfaceOptionsCheckButtonTemplate")
showNewLineBottom:SetPoint("TOPLEFT", showNewLineTop, "BOTTOMLEFT")
showNewLineBottom.Text:SetText("Show new line at bottom")
showNewLineBottom:HookScript("OnClick", function(_, btn, down)
addonTable.db.showNewLineBottom = showNewLineBottom:GetChecked()
end)
showNewLineBottom:SetChecked(addonTable.db.showNewLineBottom)

-- Create a button which will allow the user to change the color of the button text.
local buttonColorPicker = CreateFrame("Button", nil, f, "UIPanelButtonTemplate")
buttonColorPicker:SetPoint("TopLeft", showHeader, "TopLeft", 20, -30)
buttonColorPicker:SetSize(100, 25)
buttonColorPicker:SetPoint("TOPLEFT", showNewLineBottom, "BOTTOMLEFT")
buttonColorPicker:SetSize(150, 25)
buttonColorPicker:SetText("Button Text Color")
buttonColorPicker:SetScript("OnClick", function()
ShowColorPicker(addonTable.db.buttonColor.r, addonTable.db.buttonColor.g, addonTable.db.buttonColor.b,
Expand All @@ -80,21 +156,44 @@ function f:InitializeOptions()

-- Create a button which will allow the user to change the color of the action text.
local actionColorPicker = CreateFrame("Button", nil, f, "UIPanelButtonTemplate")
actionColorPicker:SetPoint("TopLeft", buttonColorPicker, "TopLeft", 0, -30)
actionColorPicker:SetSize(100, 25)
actionColorPicker:SetPoint("TOPLEFT", buttonColorPicker, "BOTTOMLEFT")
actionColorPicker:SetSize(150, 25)
actionColorPicker:SetText("Action Text Color")
actionColorPicker:SetScript("OnClick", function()
ShowColorPicker(addonTable.db.actionColor.r, addonTable.db.actionColor.g, addonTable.db.actionColor.b,
addonTable.db.actionColor.a, ActionColorCallback)
end)

-- Create a button which will allow the user to change the color of the divider.
local dividerColorPicker = CreateFrame("Button", nil, f, "UIPanelButtonTemplate")
dividerColorPicker:SetPoint("TOPLEFT", actionColorPicker, "BOTTOMLEFT")
dividerColorPicker:SetSize(150, 25)
dividerColorPicker:SetText("Divider Color")
dividerColorPicker:SetScript("OnClick", function()
ShowColorPicker(addonTable.db.dividerColor.r, addonTable.db.dividerColor.g, addonTable.db.dividerColor.b,
addonTable.db.dividerColor.a, DividerColorCallback)
end)

-- Create a button which will allow the user to reset the settings to the default values.
local resetSettings = CreateFrame("Button", nil, f, "UIPanelButtonTemplate")
resetSettings:SetPoint("TopLeft", actionColorPicker, "TopLeft", 0, -30)
resetSettings:SetSize(100, 25)
resetSettings:SetText("Reset Settings")
resetSettings:SetPoint("TOPLEFT", dividerColorPicker, "BOTTOMLEFT")
resetSettings:SetSize(150, 25)
resetSettings:SetText("Reset Addon")
resetSettings:SetScript("OnClick", function()
addonTable.db = CopyTable(defaults)
StaticPopupDialogs["RESET_SETTINGS"] = {
text = "Are you sure you want to reset the settings to the default values?\nThis will cause your UI to be reloaded.",
button1 = "Yes",
button2 = "No",
-- OnAccept = ResetSettings(),
OnAccept = function()
ClickToCastTooltipDB = nil;
C_UI.Reload();
end,
timeout = 0,
whileDead = true,
hideOnEscape = true
}
StaticPopup_Show("RESET_SETTINGS")
end)
end

Expand Down
23 changes: 17 additions & 6 deletions Click-To-Cast-Tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,23 @@ end
function ClickToCastTooltip_GenerateTooltip(tooltip)
local clickBindings = C_ClickBindings.GetProfileInfo();

if (addonTable.db.showHeader) then
tooltip:AddLine("---------------------")
tooltip:AddLine("Active Keybinds:")
end
for _, binding in ipairs(clickBindings) do
tooltipLine(binding, tooltip)
if (addonTable.db.showTooltip) then
if (addonTable.db.showNewLineTop) then
tooltip:AddLine(" ")
end
if (addonTable.db.showHeader) then
tooltip:AddLine("---------------------")
tooltip:AddLine("Active Keybinds:")
end
for _, binding in ipairs(clickBindings) do
tooltipLine(binding, tooltip)
end
if (addonTable.db.showFooter) then
tooltip:AddLine("---------------------")
end
if (addonTable.db.showNewLineBottom) then
tooltip:AddLine(" ")
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion Click-To-Cast-Tooltip.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 110002
## Title: Click to Cast Tooltip
## Author: theGimpboy
## Version: 1.4.2
## Version: 1.4.3
## Notes: Adds the click to cast spells and macros to the tooltip.
## SavedVariables: ClickToCastTooltipDB

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Click-To-Cast-Tooltip

A World of Warcraft addon to add the click to cast bindings you can currently cast to the tooltip.

0 comments on commit 868558a

Please sign in to comment.