-
Notifications
You must be signed in to change notification settings - Fork 3
/
Options.lua
283 lines (238 loc) · 11.2 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
--[[--------------------------------------------------------------------
PhanxChat
Reduces chat frame clutter and enhances chat frame functionality.
Copyright (c) 2006-2014 Phanx <[email protected]>. All rights reserved.
https://www.wowinterface.com/downloads/info6323-PhanxChat.html
https://www.curseforge.com/wow/addons/phanxchat
https://github.com/phanx-wow/PhanxChat
----------------------------------------------------------------------]]
local PHANXCHAT, PhanxChat = ...
PhanxChat.OptionsPanel = LibStub("PhanxConfig-OptionsPanel").CreateOptionsPanel(PHANXCHAT, nil, function(self)
local L = PhanxChat.L
local db = PhanxChat.db
local NEW = " |TInterface\\OptionsFrame\\UI-OptionsFrame-NewFeatureIcon:0|t"
local title, notes = self:CreateHeader(self.name, GetAddOnMetadata(PHANXCHAT, "Notes"))
--------------------------------------------------------------------
-- Frame options
local HideButtons = self:CreateCheckbox(L.HideButtons, L.HideButtons_Desc)
HideButtons:SetPoint("TOPLEFT", notes, "BOTTOMLEFT", -2, -8)
function HideButtons:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetHideButtons", value) end
PhanxChat:SetHideButtons(value)
end
local HideTextures = self:CreateCheckbox(L.HideTextures, L.HideTextures_Desc)
HideTextures:SetPoint("TOPLEFT", HideButtons, "BOTTOMLEFT", 0, -8)
function HideTextures:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetHideTextures", value) end
PhanxChat:SetHideTextures(value)
end
local HideFlash = self:CreateCheckbox(L.HideFlash, L.HideFlash_Desc)
HideFlash:SetPoint("TOPLEFT", HideTextures, "BOTTOMLEFT", 0, -8)
function HideFlash:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetHideFlash", value) end
PhanxChat:SetHideFlash(value)
end
local LockTabs = self:CreateCheckbox(L.LockTabs, L.LockTabs_Desc)
LockTabs:SetPoint("TOPLEFT", HideFlash, "BOTTOMLEFT", 0, -8)
function LockTabs:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetLockTabs", value) end
PhanxChat:SetLockTabs(value)
end
local RemoveHoverDelay = self:CreateCheckbox(REMOVE_CHAT_DELAY_TEXT)
RemoveHoverDelay:SetPoint("TOPLEFT", LockTabs, "BOTTOMLEFT", 0, -8)
function RemoveHoverDelay:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: removeChatDelay", value) end
SetCVar("removeChatDelay", value and "1" or "0")
end
local ScrollWheel = self:CreateCheckbox(CHAT_MOUSE_WHEEL_SCROLL, OPTION_TOOLTIP_CHAT_MOUSE_WHEEL_SCROLL)
ScrollWheel:SetPoint("TOPLEFT", RemoveHoverDelay, "BOTTOMLEFT", 0, -8)
function ScrollWheel:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: chatMouseScroll", value) end
SetCVar("chatMouseScroll", value and "1" or "0")
end
local EnableResizeEdges = self:CreateCheckbox(L.EnableResizeEdges, L.EnableResizeEdges_Desc)
EnableResizeEdges:SetPoint("TOPLEFT", ScrollWheel, "BOTTOMLEFT", 0, -8)
function EnableResizeEdges:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetEnableResizeEdges", value) end
PhanxChat:SetEnableResizeEdges(value)
end
--------------------------------------------------------------------
-- Edit box options
local EnableArrows = self:CreateCheckbox(L.EnableArrows, L.EnableArrows_Desc)
EnableArrows:SetPoint("TOPLEFT", EnableResizeEdges, "BOTTOMLEFT", 0, -8) -- TODO add space
function EnableArrows:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: EnableArrows", value) end
PhanxChat:SetEnableArrows(value)
end
local MoveEditBox = self:CreateCheckbox(L.MoveEditBox, L.MoveEditBox_Desc)
MoveEditBox:SetPoint("TOPLEFT", EnableArrows, "BOTTOMLEFT", 0, -8)
function MoveEditBox:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetMoveEditBox", value) end
PhanxChat:SetMoveEditBox(value)
end
local EnableSticky = self:CreateDropdown(L.EnableSticky, L.EnableSticky_Desc, {
{ value = "ALL", text = L.All },
{ value = "BLIZZARD", text = L.Default },
{ value = "NONE", text = L.None },
})
EnableSticky:SetPoint("TOPLEFT", MoveEditBox, "BOTTOMLEFT", 0, -14)
EnableSticky:SetWidth(200)
function EnableSticky:OnValueChanged(value, text)
if PhanxChat.debug then print("PhanxChat: SetEnableSticky", value) end
PhanxChat:SetEnableSticky(value)
end
--------------------------------------------------------------------
local FadeTime = self:CreateSlider(L.FadeTime, L.FadeTime_Desc, 0, 5, 0.25, nil, true)
FadeTime:SetPoint("TOPLEFT", EnableSticky, "BOTTOMLEFT", 2, -14)
FadeTime:SetWidth(200)
function FadeTime:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetFadeTime", value) end
PhanxChat:SetFadeTime(value)
return value
end
local MINUTES_AND_SECONDS = MINUTE_ONELETTER_ABBR .. " " .. SECOND_ONELETTER_ABBR
function FadeTime.valueText:SetText(text)
local v = self:GetParent():GetValue()
if PhanxChat.debug then print(type(v), tostring(v), "SetText", type(text), tostring(text)) end
local m = floor(text)
local s = 60 * (text - m)
if m > 0 and s > 0 then
self:SetFormattedText(MINUTES_AND_SECONDS, m, s)
elseif m > 0 then
self:SetFormattedText(MINUTE_ONELETTER_ABBR, m)
elseif s > 0 then
self:SetFormattedText(SECOND_ONELETTER_ABBR, s)
else
self:SetFormattedText(VIDEO_OPTIONS_DISABLED) -- use instead of SetText to avoid infinite loop
end
end
--------------------------------------------------------------------
local HidePetCombatLog = self:CreateCheckbox(L.HidePetCombatLog, L.HidePetCombatLog_Desc)
HidePetCombatLog:SetPoint("TOPLEFT", notes, "BOTTOM", 2, -8)
function HidePetCombatLog:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: HidePetCombatLog", value) end
db.HidePetCombatLog = value
end
--------------------------------------------------------------------
-- Message options
local HideNotices = self:CreateCheckbox(L.HideNotices, L.HideNotices_Desc)
HideNotices:SetPoint("TOPLEFT", HidePetCombatLog, "BOTTOMLEFT", 0, -8)
function HideNotices:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetHideNotices", value) end
PhanxChat:SetHideNotices(value)
end
local HideRepeats = self:CreateCheckbox(L.HideRepeats, L.HideRepeats_Desc)
HideRepeats:SetPoint("TOPLEFT", HideNotices, "BOTTOMLEFT", 0, -8)
function HideRepeats:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetHideRepeats", value) end
PhanxChat:SetHideRepeats(value)
end
local LinkURLs = self:CreateCheckbox(L.LinkURLs, L.LinkURLs_Desc)
LinkURLs:SetPoint("TOPLEFT", HideRepeats, "BOTTOMLEFT", 0, -8)
function LinkURLs:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetLinkURLs", value) end
PhanxChat:SetLinkURLs(value)
end
local ShortenChannelNames = self:CreateCheckbox(L.ShortenChannelNames, L.ShortenChannelNames_Desc)
ShortenChannelNames:SetPoint("TOPLEFT", LinkURLs, "BOTTOMLEFT", 2, -8)
function ShortenChannelNames:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: ShortenChannelNames", value) end
PhanxChat:SetShortenChannelNames(value)
end
--------------------------------------------------------------------
-- Player name options
local ShowClassColors = self:CreateCheckbox(L.ShowClassColors, L.ShowClassColors_Desc)
ShowClassColors:SetPoint("TOPLEFT", ShortenChannelNames, "BOTTOMLEFT", 0, -8)
function ShowClassColors:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: SetShowClassColors", value) end
PhanxChat:SetShowClassColors(value)
PhanxChat:SetReplaceRealNames() -- need to flush the bnetName cache
end
local RemoveRealmNames = self:CreateCheckbox(L.RemoveRealmNames, L.RemoveRealmNames_Desc)
RemoveRealmNames:SetPoint("TOPLEFT", ShowClassColors, "BOTTOMLEFT", 0, -8)
function RemoveRealmNames:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: RemoveRealmNames", value) end
db.RemoveRealmNames = value
end
local ReplaceRealNames = self:CreateCheckbox(L.ReplaceRealNames, L.ReplaceRealNames_Desc)
ReplaceRealNames:SetPoint("TOPLEFT", RemoveRealmNames, "BOTTOMLEFT", 0, -8)
function ReplaceRealNames:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: ReplaceRealNames", value) end
PhanxChat:SetReplaceRealNames(value)
end
local ShortenRealNames = self:CreateDropdown(L.ShortenRealNames, L.ShortenRealNames_Desc, {
{ value = "BATTLETAG", text = L.ShortenRealNames_UseBattleTag },
{ value = "FIRSTNAME", text = L.ShortenRealNames_UseFirstName },
{ value = "FULLNAME", text = L.ShortenRealNames_UseFullName },
})
ShortenRealNames:SetPoint("TOPLEFT", ReplaceRealNames, "BOTTOMLEFT", 0, -14)
ShortenRealNames:SetWidth(200)
function ShortenRealNames:OnValueChanged(value, text)
if PhanxChat.debug then print("PhanxChat: ShortenRealNames", value) end
PhanxChat:SetReplaceRealNames(value)
end
--------------------------------------------------------------------
local FontSize = self:CreateSlider(L.FontSize, L.FontSize_Desc .. "\n\n" .. L.FontSize_Note, 8, 24, 1)
FontSize:SetPoint("TOPLEFT", ShortenRealNames, "BOTTOMLEFT", 0, -14)
FontSize:SetWidth(200)
function FontSize:OnValueChanged(value)
if PhanxChat.debug then print("PhanxChat: FCF_SetChatWindowFontSize", value) end
db.FontSize = value
for frame in pairs(PhanxChat.frames) do
FCF_SetChatWindowFontSize(nil, frame, value)
end
end
--------------------------------------------------------------------
local LineSpacing = self:CreateSlider("Line Spacing", nil, 0, 5, 1)
LineSpacing:SetPoint("TOPLEFT", FontSize, "BOTTOMLEFT", 0, -14)
LineSpacing:SetWidth(200)
function LineSpacing:OnValueChanged(value)
db.LineSpacing = value
for frame in pairs(PhanxChat.frames) do
frame:SetSpacing(value)
end
end
--------------------------------------------------------------------
local bnetValues = {
BATTLETAG = L.ShortenRealNames_UseBattleTag,
FIRSTNAME = L.ShortenRealNames_UseFirstName,
FULLNAME = L.ShortenRealNames_UseFullName,
}
local stickyValues = {
ALL = L.All,
BLIZZARD = L.Default,
NONE = L.None,
}
self.refresh = function(self)
ShortenChannelNames:SetChecked(db.ShortenChannelNames)
ShowClassColors:SetChecked(db.ShowClassColors)
RemoveRealmNames:SetChecked(db.RemoveRealmNames)
ReplaceRealNames:SetChecked(db.ReplaceRealNames)
ShortenRealNames:SetValue(db.ShortenRealNames, bnetValues[db.ShortenRealNames])
EnableArrows:SetChecked(db.EnableArrows)
EnableResizeEdges:SetChecked(db.EnableResizeEdges)
LinkURLs:SetChecked(db.LinkURLs)
LockTabs:SetChecked(db.LockTabs)
MoveEditBox:SetChecked(db.MoveEditBox)
HideNotices:SetChecked(db.HideNotices)
HideRepeats:SetChecked(db.HideRepeats)
HidePetCombatLog:SetChecked(db.HidePetCombatLog)
HideButtons:SetChecked(db.HideButtons)
HideTextures:SetChecked(db.HideTextures)
HideFlash:SetChecked(db.HideFlash)
EnableSticky:SetValue(db.EnableSticky, stickyValues[db.EnableSticky])
FadeTime:SetValue(db.FadeTime)
FontSize:SetValue(db.FontSize or floor(select(2, ChatFrame1:GetFont()) + 0.5))
LineSpacing:SetValue(db.LineSpacing or 0)
ScrollWheel:SetChecked(GetCVarBool("chatMouseScroll"))
RemoveHoverDelay:SetChecked(GetCVarBool("removeChatDelay"))
end
self:refresh()
end)
------------------------------------------------------------------------
-- Slash command
------------------------------------------------------------------------
SLASH_PHANXCHAT1 = "/pchat"
SlashCmdList.PHANXCHAT = function(cmd)
InterfaceOptionsFrame_OpenToCategory(PhanxChat.OptionsPanel)
end