-
Notifications
You must be signed in to change notification settings - Fork 0
/
Options.lua
107 lines (96 loc) · 3.84 KB
/
Options.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--[[--------------------------------------------------------------------
BetterBattlePetTooltip
Copyright (c) 2012-2019 Phanx <[email protected]>. All rights reserved.
https://www.wowinterface.com/downloads/info21978-BetterBattlePetTooltip.html
https://www.curseforge.com/wow/addons/betterbattlepettooltip
https://github.com/phanx-wow/BetterBattlePetTooltip
----------------------------------------------------------------------]]
local ADDON, Addon = ...
local L = Addon.L
local Options = CreateFrame("Frame", ADDON.."Options", InterfaceOptionsFramePanelContainer)
Options.name = GetAddOnMetadata(ADDON, "Title") or ADDON
InterfaceOptions_AddCategory(Options)
Addon.OptionsPanel = Options
SLASH_BBPT1 = "/bbpt"
SlashCmdList.BBPT = function()
InterfaceOptionsFrame_OpenToCategory(Options)
end
do
local title = Options:CreateFontString("$parentTitle", "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText(Options.name)
local notes = Options:CreateFontString("$parentSubText", "ARTWORK", "GameFontHighlightSmall")
notes:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
notes:SetPoint("RIGHT", -32, 0)
notes:SetHeight(32)
notes:SetJustifyH("LEFT")
notes:SetJustifyV("TOP")
notes:SetText(GetAddOnMetadata(ADDON, "Notes"))
local chex = {}
local function click(self)
local checked = self:GetChecked()
PlaySound(checked and SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON or SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
BBPTDB[self.key] = checked
Addon.EventFrame:PET_JOURNAL_LIST_UPDATE() -- wipe text cache
Options:refresh() -- update enabled state of dependencies etc.
end
local function disable(self) self.Text:SetFontObject(GameFontDisable) end
local function enable(self) self.Text:SetFontObject(GameFontHighlightLeft) end
local function new(key, text, tooltipText, dependsOn)
local box = CreateFrame("CheckButton", nil, Options, "InterfaceOptionsCheckButtonTemplate")
box:SetScript("OnClick", click)
box:SetScript("OnDisable", disable)
box:SetScript("OnEnable", enable)
box:SetMotionScriptsWhileDisabled(true)
box.Text:SetText(text)
box.tooltipText = tooltipText
box.dependsOn = dependsOn
box.key = key
chex[key] = box
tinsert(chex, box)
local prev = chex[#chex-1]
if not prev then
box:SetPoint("TOPLEFT", notes, "BOTTOMLEFT", -2, -8)
elseif dependsOn and not prev.dependsOn then
box:SetPoint("TOPLEFT", prev, "BOTTOMLEFT", 24, -8)
elseif prev.dependsOn and not dependsOn then
box:SetPoint("TOPLEFT", prev, "BOTTOMLEFT", -24, -8)
else
box:SetPoint("TOPLEFT", prev, "BOTTOMLEFT", 0, -8)
end
return box
end
new("showAll", L.ShowAll, L.ShowAll_Tooltip)
new("showCount", L.ShowCount)
new("showLevel", L.ShowLevel)
new("compactLevel", L.CompactLevel, nil, "showLevel")
new("showBreed", L.ShowBreed)
new("showSource", L.ShowSource)
new("showSourceOnlyMissing", L.ShowSourceOnlyMissing, nil, "showSource")
new("showWildQuality", L.ShowWildQuality, L.ShowWildQuality_Tooltip)
new("colorTooltipBorder", L.ColorTooltipBorder, L.ColorTooltipBorder_Tooltip)
Options.refresh = function()
for i = 1, #chex do
local box = chex[i]
box:SetChecked(BBPTDB[box.key])
box:SetHitRectInsets(0, -16 - box.Text:GetWidth(), 0, 0)
if box.dependsOn then
box:SetEnabled(BBPTDB[box.dependsOn])
end
end
if BBPTDB.showAll then
chex.showCount:SetEnabled(false)
chex.showCount.tooltipText = L.ShowCount_Tooltip
else
chex.showCount:SetEnabled(true)
chex.showCount.tooltipText = nil
end
if GetBreedID_Battle or PetTracker or LibStub("LibPetBreedInfo-1.0", true) then
chex.showBreed:SetEnabled(true)
chex.showBreed.tooltipText = nil
else
chex.showBreed:SetEnabled(false)
chex.showBreed.tooltipText = RED_FONT_COLOR_CODE .. L.ShowBreed_Tooltip
end
end
end