-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMisc.lua
167 lines (147 loc) · 3.79 KB
/
Misc.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
local _, FS = ...
local Misc = FS:RegisterModule("Miscellaneous")
local features = {}
-------------------------------------------------------------------------------
-- Config
-------------------------------------------------------------------------------
local misc_defaults = {
profile = {}
}
local misc_config = {
title = {
type = "description",
name = "|cff64b4ffMiscellaneous",
fontSize = "large",
order = 0,
},
desc = {
type = "description",
name = "Various useful options.\n",
fontSize = "medium",
order = 1,
},
}
-------------------------------------------------------------------------------
-- Life-cycle
-------------------------------------------------------------------------------
function Misc:OnInitialize()
self.db = FS.db:RegisterNamespace("Miscellaneous", misc_defaults)
self.settings = self.db.profile
FS.Config:Register("Miscellaneous", misc_config, 12)
self:RegisterEvent("ADDON_LOADED")
end
function Misc:OnEnable()
for name in pairs(features) do
self:SyncFeature(name)
end
end
do
local order = 10
function Misc:RegisterFeature(name, short, long, default, fn)
misc_config[name] = {
type = "toggle",
name = short,
descStyle = "inline",
desc = "|cffaaaaaa" .. long,
width = "full",
get = function() return Misc.settings[name] end,
set = function(_, v)
Misc.settings[name] = v
Misc:SyncFeature(name)
end,
order = order
}
misc_defaults.profile[name] = default
order = order + 1
features[name] = fn
end
end
function Misc:SyncFeature(name)
features[name](Misc.settings[name])
end
function Misc:ADDON_LOADED(event, addon)
if addon == "Blizzard_TalkingHeadUI" then
self:SyncFeature("TalkingHead")
end
end
-------------------------------------------------------------------------------
-- Features
-------------------------------------------------------------------------------
do
Misc:RegisterFeature("MaxCam",
"Maximize camera distance",
"Automatically reset your camera to max distance when logging in.",
true,
function(state)
if state then
C_Timer.After(0.3, function()
SetCVar("cameraDistanceMaxZoomFactor", 2.6)
MoveViewOutStart(50000)
end)
end
end)
end
do
local enabled = false
Misc:RegisterFeature("SlashRL",
"Enable /rl",
"Enables the short version for reloading the interface.",
true,
function(state)
if state and not enabled then
enabled = true
FS.Console:RegisterChatCommand("rl", function() ReloadUI() end)
end
end)
end
do
local enabled = false
Misc:RegisterFeature("TalkingHead",
"Disable Talking Head",
"Disables the Talking Head feature that is used for some quest and event dialogues.",
false,
function(state)
if not enabled and TalkingHeadFrame_PlayCurrent then
enabled = true
hooksecurefunc("TalkingHeadFrame_PlayCurrent", function()
if state then TalkingHeadFrame:Hide() end
end)
end
end)
end
do
Misc:RegisterFeature("HideOrderHallBar",
"Disable Order Hall Command Bar",
"Hides the information bar inside your class Order Hall.",
false,
function(state)
if state then
C_Timer.After(0.3, function()
LoadAddOn("Blizzard_OrderHallUI")
local b = OrderHallCommandBar
b:UnregisterAllEvents()
b:HookScript("OnShow", b.Hide)
b:Hide()
end)
end
end)
end
-------------------------------------------------------------------------------
-- C_ArtifactUI.GetTotalPurchasedRanks() shenanigans
-------------------------------------------------------------------------------
do
local OnShow
local function OnShowHook(self)
if C_ArtifactUI.GetTotalPurchasedRanks() then
OnShow(self)
else
ArtifactFrame:Hide()
end
end
hooksecurefunc("ArtifactFrame_LoadUI", function()
if not OnShow then
OnShow = ArtifactFrame:GetScript("OnShow")
ArtifactFrame:SetScript("OnShow", OnShowHook)
end
end)
end