-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemTooltipProfessionConfigFrame.lua
More file actions
339 lines (251 loc) · 11.5 KB
/
Copy pathItemTooltipProfessionConfigFrame.lua
File metadata and controls
339 lines (251 loc) · 11.5 KB
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
--[[
ItemTooltipProfessionIcons (Ascension Edition)
Configuration Frame & Options UI
Original Author: Bytespire
Modified by Xurkon (Ascension Backport)
Handles the Interface Options subpanel for visual settings.
]]--
local frame = CreateFrame( "Frame" )
frame.name = "ItemTooltipProfessionIcons"
local NUM_PROFS_TRACKED = ItemProfConstants.NUM_PROF_FLAGS
local NUM_QUEST_FILTERS = ItemProfConstants.NUM_QUEST_FLAGS
local profsCheck
local questCheck
--local vendorCheck
local dmfCheck
local classQuestLabel
local profQuestLabel
local iconSizeSlider
local iconSizeLabel
local iconDemoTexture
local PROF_CHECK = {}
local QUEST_CHECK = {}
local configDefaultShowProfs = true
local configDefaultShowQuests = true
local configDefaultProfFlags = 0x3FF
local configDefaultQuestFlags = 0x3FFFFF
local configDefaultIncludeVendor = false
local configDefaultIconSize = 16
local configDefaultShowDMF = true
local userVariables
local function SaveAndQuit()
local profFlags = 0
-- Ignore the profession flags if master profession checkbox is unchecked
for i=0, NUM_PROFS_TRACKED-1 do
local bitMask = bit.lshift( 1, i )
local isChecked = PROF_CHECK[ bitMask ]:GetChecked()
if isChecked then
profFlags = profFlags + bitMask
end
end
local questFlags = 1 -- Normal quests flag
for i=1, NUM_QUEST_FILTERS do
local bitMask = bit.lshift( 1, i )
local isChecked = QUEST_CHECK[ bitMask ]:GetChecked()
if isChecked then
questFlags = questFlags + bitMask
end
end
userVariables.showProfs = profsCheck:GetChecked()
userVariables.showQuests = questCheck:GetChecked()
userVariables.profFlags = profFlags
userVariables.questFlags = questFlags
--userVariables.includeVendor = vendorCheck:GetChecked()
userVariables.iconSize = iconSizeSlider:GetValue()
userVariables.showDMF = dmfCheck:GetChecked()
ItemProfConstants:ConfigChanged()
end
local function ToggleProfCheckbox()
local isChecked = profsCheck:GetChecked()
-- How do I call as a stored function CheckButton:Enable()?
for k,v in pairs( PROF_CHECK ) do
if isChecked then
v:Enable()
else
v:Disable()
end
end
end
local function ToggleQuestCheckbox()
local isChecked = questCheck:GetChecked()
if isChecked then
for k,v in pairs( QUEST_CHECK ) do
v:Enable()
end
else
for k,v in pairs( QUEST_CHECK ) do
v:Disable()
end
end
end
local function RefreshWidgets()
if not userVariables then InitVariables() end
if not userVariables then return end
-- Sync the widgets state with the config variables
profsCheck:SetChecked( userVariables.showProfs )
questCheck:SetChecked( userVariables.showQuests )
--vendorCheck:SetChecked( userVariables.includeVendor )
dmfCheck:SetChecked( userVariables.showDMF )
local profFlags = userVariables.profFlags
local questFlags = userVariables.questFlags
iconSizeSlider:SetValue( userVariables.iconSize )
-- Update the profession checkboxes
for i=0, NUM_PROFS_TRACKED-1 do
local bitMask = bit.lshift( 1, i )
local isSet = bit.band( profFlags, bitMask )
PROF_CHECK[ bitMask ]:SetChecked( isSet ~= 0 )
end
-- Update the quest checkboxes
for i=1, NUM_QUEST_FILTERS do
local bitMask = bit.lshift( 1, i )
local isSet = bit.band( questFlags, bitMask )
QUEST_CHECK[ bitMask ]:SetChecked( isSet ~= 0 )
end
-- Set checkboxes enabled/disabled
ToggleProfCheckbox()
ToggleQuestCheckbox()
end
local function IconSizeChanged( self, value )
-- Called when the icon slider widget changes value
iconDemoTexture:SetSize( value, value )
iconSizeLabel:SetText( value )
end
local function InitVariables()
if not ItemProfConstants.configTooltipIconsRealm then
ItemProfConstants.configTooltipIconsRealm = GetRealmName()
ItemProfConstants.configTooltipIconsChar = UnitName("player")
end
local configRealm = ItemProfConstants.configTooltipIconsRealm
local configChar = ItemProfConstants.configTooltipIconsChar
if not ItemTooltipIconsConfig then
ItemTooltipIconsConfig = {}
end
if not ItemTooltipIconsConfig[ configRealm ] then
ItemTooltipIconsConfig[ configRealm ] = {}
end
if not ItemTooltipIconsConfig[ configRealm ][ configChar ] then
ItemTooltipIconsConfig[ configRealm ][ configChar ] = {}
end
userVariables = ItemTooltipIconsConfig[ configRealm ][ configChar ]
if userVariables.showProfs == nil then
userVariables.showProfs = configDefaultShowProfs
end
if userVariables.showQuests == nil then
userVariables.showQuests = configDefaultShowQuests
end
if userVariables.profFlags == nil then
userVariables.profFlags = configDefaultProfFlags
end
if userVariables.questFlags == nil then
userVariables.questFlags = configDefaultQuestFlags
end
if userVariables.includeVendor == nil then
userVariables.includeVendor = configDefaultIncludeVendor
end
if userVariables.iconSize == nil then
userVariables.iconSize = configDefaultIconSize
end
if userVariables.showDMF == nil then
userVariables.showDMF = configDefaultShowDMF
end
RefreshWidgets()
ItemProfConstants:ConfigChanged()
end
local function CreateCheckbox( name, x, y, label, tooltip )
local check = CreateFrame( "CheckButton", name, frame, "ChatConfigCheckButtonTemplate" ) --"OptionsCheckButtonTemplate" )
_G[ name .. "Text" ]:SetText( label )
check.tooltip = tooltip
check:SetPoint( "TOPLEFT", x, y )
return check
end
local function CreateProfessionWidgets()
profsCheck = CreateCheckbox( "ItemTooltipIconsConfigCheck0", 20, -50, " Enable Profession Icons", "If enabled profession icons will be displayed on items that are crafting materials" )
profsCheck:SetScript( "OnClick", ToggleProfCheckbox )
-- Checkbox alignment offsets
local x0 = 45
local x1 = 245
local y0 = -70
local dy = -20
PROF_CHECK[ 1 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0a", x0, y0+dy, " Cooking", nil )
PROF_CHECK[ 2 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0b", x1, y0+(2*dy), " First Aid", nil )
PROF_CHECK[ 4 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0c", x0, y0, " Alchemy", nil )
PROF_CHECK[ 8 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0d", x1, y0, " Blacksmithing", nil )
PROF_CHECK[ 16 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0e", x1, y0+dy, " Enchanting", nil )
PROF_CHECK[ 32 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0f", x0, y0+(2*dy), " Engineering", nil )
PROF_CHECK[ 64 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0g", x0, y0+(4*dy), " Leatherworking", nil )
PROF_CHECK[ 128 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0h", x1, y0+(4*dy), " Tailoring", nil )
PROF_CHECK[ 256 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0i", x1, y0+(3*dy), " Jewelcrafting", nil )
PROF_CHECK[ 512 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck0j", x0, y0+(3*dy), " Inscription", nil )
end
local function CreateQuestWidgets()
questCheck = CreateCheckbox( "ItemTooltipIconsConfigCheck1", 20, -180, " Enable Quest Icons", "If enabled quest icons will be displayed on items that are needed by quests" )
questCheck:SetScript( "OnClick", ToggleQuestCheckbox )
local x0 = 45
local x1 = 245
local x2 = 445
local y0 = -200
local dy = -20
QUEST_CHECK[ 0x00002 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1b", x0, y0, " Alliance", nil )
QUEST_CHECK[ 0x00004 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1c", x0, y0+dy, " Horde", nil )
classQuestLabel = frame:CreateFontString( "ClassQuestLabel", "OVERLAY", "GameTooltipText" )
classQuestLabel:SetFont( "Fonts\\FRIZQT__.TTF", 14, "THINOUTLINE" )
classQuestLabel:SetPoint( "TOPLEFT", x0, -255 )
classQuestLabel:SetTextColor( 1, 0.85, 0.15 )
classQuestLabel:SetText( "Class Quests" )
y0 = -270
QUEST_CHECK[ 0x00008 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d1", x0, y0, " Druid", nil )
QUEST_CHECK[ 0x00010 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d2", x0, y0+dy, " Hunter", nil )
QUEST_CHECK[ 0x00020 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d3", x0, y0+(2*dy), " Mage", nil )
QUEST_CHECK[ 0x00040 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d4", x1, y0, " Paladin", nil )
QUEST_CHECK[ 0x00080 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d5", x1, y0+dy, " Priest", nil )
QUEST_CHECK[ 0x00100 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d6", x1, y0+(2*dy), " Rogue", nil )
QUEST_CHECK[ 0x00200 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d7", x2, y0, " Shaman", nil )
QUEST_CHECK[ 0x00400 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d8", x2, y0+dy, " Warlock", nil )
QUEST_CHECK[ 0x00800 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1d9", x2, y0+(2*dy), " Warrior", nil )
profQuestLabel = frame:CreateFontString( "ProfQuestLabel", "OVERLAY", "GameTooltipText" )
profQuestLabel:SetFont( "Fonts\\FRIZQT__.TTF", 14, "THINOUTLINE" )
profQuestLabel:SetPoint( "TOPLEFT", x0, -345 )
profQuestLabel:SetTextColor( 1, 0.85, 0.15 )
profQuestLabel:SetText( "Profession Quests" )
y0 = -360
QUEST_CHECK[ 0x001000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e1", x0, y0+(2*dy), " Cooking", nil )
QUEST_CHECK[ 0x002000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e2", x1, y0+(2*dy), " First Aid", nil )
QUEST_CHECK[ 0x004000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e3", x0, y0, " Alchemy", nil )
QUEST_CHECK[ 0x008000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e4", x0, y0+dy, " Blacksmithing", nil )
QUEST_CHECK[ 0x010000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e5", x1, y0, " Enchanting", nil )
QUEST_CHECK[ 0x020000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e6", x1, y0+dy, " Engineering", nil )
QUEST_CHECK[ 0x040000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e7", x2, y0+dy, " Leatherworking", nil )
QUEST_CHECK[ 0x080000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e8", x2, y0+(2*dy), " Tailoring", nil )
QUEST_CHECK[ 0x100000 ] = CreateCheckbox( "ItemTooltipIconsConfigCheck1e9", x2, y0, " Jewelcrafting", nil )
end
local function CreateIconResizeWidgets()
iconSizeSlider = CreateFrame( "Slider", "ItemTooltipIconsConfigSlider0", frame, "OptionsSliderTemplate" )
iconSizeSlider:SetPoint( "TOPLEFT", 20, -540 )
iconSizeSlider:SetMinMaxValues( 8, 64 )
iconSizeSlider:SetValueStep( 1 )
iconSizeSlider:SetWidth( 200 )
iconSizeSlider:SetScript( "OnValueChanged", IconSizeChanged )
_G[ "ItemTooltipIconsConfigSlider0Text" ]:SetText( "Icon Size" )
_G[ "ItemTooltipIconsConfigSlider0Low" ]:SetText( nil )
_G[ "ItemTooltipIconsConfigSlider0High" ]:SetText( nil )
iconSizeLabel = frame:CreateFontString( nil, "OVERLAY", "GameTooltipText" )
iconSizeLabel:SetFont( "Fonts\\FRIZQT__.TTF", 12, "THINOUTLINE" )
iconSizeLabel:SetPoint( "TOPLEFT", 225, -542 )
iconDemoTexture = frame:CreateTexture( nil, "OVERLAY" )
iconDemoTexture:SetPoint( "TOPLEFT", 300, -540 )
iconDemoTexture:SetTexture( GetSpellTexture( 4036 ) )
end
local dialogHeader = frame:CreateFontString( nil, "OVERLAY", "GameTooltipText" )
dialogHeader:SetFont( "Fonts\\FRIZQT__.TTF", 10, "THINOUTLINE" )
dialogHeader:SetPoint( "TOPLEFT", 20, -20 )
dialogHeader:SetText( "These options allow you control which icons are displayed on the item tooltips.\nThe quest icon can be filtered to display on items needed for quests of specific class/profession." )
CreateProfessionWidgets()
CreateQuestWidgets()
--vendorCheck = CreateCheckbox( "ItemTooltipIconsConfigCheck2", 20, -470, " Vendor Items", "Display icons on items sold by vendors" )
dmfCheck = CreateCheckbox( "ItemTooltipIconsConfigCheck3", 20, -470, " Darkmoon Faire Ticket Items", "Display a ticket icon if the item can be exchanged for Darkmoon Faire tickets" )
CreateIconResizeWidgets()
frame.okay = SaveAndQuit
frame:SetScript( "OnShow", RefreshWidgets )
frame:SetScript( "OnEvent", InitVariables )
frame:RegisterEvent( "VARIABLES_LOADED" )
InterfaceOptions_AddCategory( frame )