-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTrinketMenuQueue.lua
More file actions
663 lines (618 loc) · 21.9 KB
/
TrinketMenuQueue.lua
File metadata and controls
663 lines (618 loc) · 21.9 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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
--[[ TrinketMenuQueue : auto queue system ]]
local _G, type, string, tonumber, table, pairs, select = _G, type, string, tonumber, table, pairs, select
local IsClassic = WOW_PROJECT_ID >= WOW_PROJECT_CLASSIC
local IsVanillaClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
TrinketMenu.PausedQueue = { } -- 0 or 1 whether queue is paused
local TRINKET_KEEP_BUFF_AFTER_SWAP = {
["19341"] = true,
}
function TrinketMenu.QueueInit()
TrinketMenuQueue = TrinketMenuQueue or {
Stats = { }, -- indexed by id of trinket, delay, priority and keep
Sort = { }, -- indexed by number, ids in order of use
Enabled = { } -- 0 or 1 whether auto queue is on for the slot
}
TrinketMenuQueue.Sort[0] = TrinketMenuQueue.Sort[0] or { }
TrinketMenuQueue.Sort[1] = TrinketMenuQueue.Sort[1] or { }
TrinketMenu_SubQueueFrame:SetBackdropBorderColor(.3, .3, .3,1)
TrinketMenu_ProfilesFrame:SetBackdropBorderColor(.3, .3, .3, 1)
TrinketMenu_ProfilesListFrame:SetBackdropBorderColor(.3, .3, .3, 1)
TrinketMenu_SortPriorityText:SetText("Priority")
TrinketMenu_SortPriorityText:SetTextColor(.95, .95, .95)
TrinketMenu_SortKeepEquippedText:SetText("Pause Queue")
TrinketMenu_SortKeepEquippedText:SetTextColor(.95, .95, .95)
TrinketMenu_SortListFrame:SetBackdropBorderColor(.3, .3, .3, 1)
TrinketMenu.ReflectQueueEnabled()
TrinketMenu.UpdateCombatQueue()
TrinketMenuQueue.Profiles = TrinketMenuQueue.Profiles or { }
TrinketMenu.ValidateProfile()
TrinketMenu.OpenSort(0)
TrinketMenu.OpenSort(1)
end
function TrinketMenu.ReflectQueueEnabled()
TrinketMenu_Trinket0Check:SetChecked(TrinketMenuQueue.Enabled[0])
TrinketMenu_Trinket1Check:SetChecked(TrinketMenuQueue.Enabled[1])
end
function TrinketMenu.OpenSort(which)
TrinketMenu.CurrentlySorting = which
TrinketMenu.PopulateSort(which)
TrinketMenu.SortSelected = 0
TrinketMenu_SortScrollScrollBar:SetValue(0)
TrinketMenu.SortValidate()
TrinketMenu.SortScrollFrameUpdate()
end
function TrinketMenu.GetID(bag, slot)
local _, id
if slot then
_, _, id = string.find(TrinketMenu.GetContainerItemLink(bag, slot) or "", "item:(%d+)")
else
_, _, id = string.find(GetInventoryItemLink("player", bag) or "", "item:(%d+)")
end
return id or 0
end
function TrinketMenu.GetNameByID(id)
if id == 0 then
return "-- stop queue here --", "Interface\\Buttons\\UI-GroupLoot-Pass-Up", 1
else
local name, _, quality, _, _, _, _, _, _, texture = C_Item.GetItemInfo(id or "")
return name, texture, quality
end
end
-- adds id to which sort if it's not already in the list
function TrinketMenu.AddToSort(which, id)
if not id then
return
end
local found
for i = 1, #TrinketMenuQueue.Sort[which] do
found = found or TrinketMenuQueue.Sort[which][i] == id
end
if not found then
table.insert(TrinketMenuQueue.Sort[which], id)
end
end
-- populates sorts adding any new trinkets
function TrinketMenu.PopulateSort(which)
TrinketMenuQueue.Sort[which] = TrinketMenuQueue.Sort[which] or { }
local id = TrinketMenu.GetID(which + 13)
if id ~= 0 then
TrinketMenu.AddToSort(which, id)
end
id = TrinketMenu.GetID((1 - which) + 13)
if id ~= 0 then
TrinketMenu.AddToSort(which, id)
end
local _, equipLoc, id
for i = 0, 4 do
for j = 1, TrinketMenu.GetContainerNumSlots(i) do
id = TrinketMenu.GetID(i, j)
_, _, _, _, _, _, _, _, equipLoc = C_Item.GetItemInfo(id or "")
if equipLoc == "INVTYPE_TRINKET" then
TrinketMenu.AddToSort(which, id)
end
end
end
TrinketMenu.AddToSort(which, 0) -- id 0 is Stop
end
function TrinketMenu.SortScrollFrameUpdate()
local offset = FauxScrollFrame_GetOffset(TrinketMenu_SortScroll)
local list = TrinketMenuQueue.Sort[TrinketMenu.CurrentlySorting]
FauxScrollFrame_Update(TrinketMenu_SortScroll, list and #list or 0, 9, 24)
if list and list[1] then
local r, g, b, found
local texture, name, quality, idx
local item, itemName, itemIcon
for i = 1, 9 do
item = _G["TrinketMenu_Sort"..i]
itemName = _G["TrinketMenu_Sort"..i.."Name"]
itemIcon = _G["TrinketMenu_Sort"..i.."Icon"]
idx = offset + i
if idx <= #list then
name, texture, quality = TrinketMenu.GetNameByID(list[idx])
itemIcon:SetTexture(texture)
itemName:SetText(name)
if quality then -- GetItemInfo may not be valid early on after patches
r, g, b = C_Item.GetItemQualityColor(quality)
itemName:SetTextColor(r, g, b)
itemIcon:SetVertexColor(1, 1, 1)
end
item:Show()
if idx == TrinketMenu.SortSelected then
TrinketMenu.LockHighlight(item)
else
TrinketMenu.UnlockHighlight(item)
end
else
item:Hide()
end
end
end
end
function TrinketMenu.LockHighlight(frame)
if type(frame) == "string" then
frame = _G[frame]
end
if not frame then
return
end
frame.lockedHighlight = 1
_G[frame:GetName().."Highlight"]:Show()
end
function TrinketMenu.UnlockHighlight(frame)
if type(frame) == "string" then
frame = _G[frame]
end
if not frame then
return
end
frame.lockedHighlight = nil
_G[frame:GetName().."Highlight"]:Hide()
end
-- shows tooltip for items in the sort list
function TrinketMenu.SortTooltip(self)
local idx = FauxScrollFrame_GetOffset(TrinketMenu_SortScroll) + self:GetID()
local _, itemLink = C_Item.GetItemInfo(TrinketMenuQueue.Sort[TrinketMenu.CurrentlySorting][idx] or "")
itemLink = string.match(itemLink or "", "item:[%d:]+")
if itemLink and TrinketMenuOptions.ShowTooltips == "ON" then
TrinketMenu.AnchorTooltip(self)
GameTooltip:SetHyperlink(itemLink)
GameTooltip:Show()
else
TrinketMenu.OnTooltip(self,"Stop Queue Here", "Move this to mark the lowest trinket to auto queue. Sometimes you may want a passive trinket with a click effect to be the end (Burst of Knowledge, Second Wind, etc).")
end
end
function TrinketMenu.SortOnClick(self)
TrinketMenu_SortDelay:ClearFocus()
local idx = FauxScrollFrame_GetOffset(TrinketMenu_SortScroll) + self:GetID()
if TrinketMenu.SortSelected == idx then
TrinketMenu.SortSelected = 0
else
TrinketMenu.SortSelected = idx
end
TrinketMenu.SortScrollFrameUpdate()
TrinketMenu.SortValidate()
end
-- turns move buttons on/off, moves the list to keep selected in view and keeps the sorting slot button highlighted
function TrinketMenu.SortValidate()
local selected = TrinketMenu.SortSelected
local list = TrinketMenuQueue.Sort[TrinketMenu.CurrentlySorting]
TrinketMenu_MoveTop:Enable()
TrinketMenu_MoveUp:Enable()
TrinketMenu_MoveDown:Enable()
TrinketMenu_MoveBottom:Enable()
if selected == 0 or #list < 2 then -- none selected, disable all
TrinketMenu_MoveTop:Disable()
TrinketMenu_MoveUp:Disable()
TrinketMenu_MoveDown:Disable()
TrinketMenu_MoveBottom:Disable()
elseif selected == 1 then -- top selected, disable up
TrinketMenu_MoveUp:Disable()
TrinketMenu_MoveTop:Disable()
TrinketMenu_MoveDown:Enable()
elseif selected == #list then -- bottom selected, disable down
TrinketMenu_MoveDown:Disable()
TrinketMenu_MoveBottom:Disable()
end
local idx = FauxScrollFrame_GetOffset(TrinketMenu_SortScroll)
if selected > 0 and list[selected] and list[selected] ~= 0 then
TrinketMenu_SortDelay:Show()
TrinketMenu_SortPriority:Show()
TrinketMenu_SortKeepEquipped:Show()
TrinketMenu_Delete:Enable()
else
TrinketMenu_SortDelay:Hide()
TrinketMenu_SortPriority:Hide()
TrinketMenu_SortKeepEquipped:Hide()
TrinketMenu_Delete:Disable()
end
local stats = TrinketMenuQueue.Stats[list[TrinketMenu.SortSelected]]
TrinketMenu_SortDelay:SetText(stats and (stats.delay or "0") or "0")
TrinketMenu_SortPriority:SetChecked(stats and stats.priority)
TrinketMenu_SortKeepEquipped:SetChecked(stats and stats.keep)
if not IsShiftKeyDown() and selected > 0 then -- keep selected visible on list, moving thumb as needed, unless shift is down
local parent = TrinketMenu_SortScrollScrollBar
local offset
if selected <= idx then
offset = (selected == 1) and 0 or (parent:GetValue() - (parent:GetHeight() / 2))
parent:SetValue(offset)
PlaySound(1115)
elseif selected >= (idx + 10) then
offset = (selected == #list) and TrinketMenu_SortScroll:GetVerticalScrollRange() or (parent:GetValue() + (parent:GetHeight() / 2))
parent:SetValue(offset)
PlaySound(1115)
end
end
end
-- movement buttons
function TrinketMenu.SortMove(self)
TrinketMenu_SortDelay:ClearFocus()
local dir = ((self == TrinketMenu_MoveUp) and - 1) or ((self == TrinketMenu_MoveTop) and "top") or ((self == TrinketMenu_MoveDown) and 1) or ((self == TrinketMenu_MoveBottom) and "bottom")
local list = TrinketMenuQueue.Sort[TrinketMenu.CurrentlySorting]
local idx1 = TrinketMenu.SortSelected
if dir then
local idx2 = ((dir == "top") and 1) or ((dir == "bottom") and #list) or idx1 + dir
local temp = list[idx1]
if tonumber(dir) then
list[idx1] = list[idx2]
list[idx2] = temp
elseif dir == "top" then
table.remove(list, idx1)
table.insert(list, 1, temp)
elseif dir == "bottom" then
table.remove(list, idx1)
table.insert(list, temp)
end
TrinketMenu.SortSelected = idx2
elseif self == TrinketMenu_Profiles then
TrinketMenu.SortSelected = 0
TrinketMenu.ShowProfiles(TrinketMenu_SortListFrame:IsVisible())
elseif self == TrinketMenu_Delete then
table.remove(list, idx1)
TrinketMenu.SortSelected = 0
end
TrinketMenu.SortValidate()
TrinketMenu.SortScrollFrameUpdate()
end
function TrinketMenu.SortDelay_OnTextChanged()
local id = TrinketMenuQueue.Sort[TrinketMenu.CurrentlySorting][TrinketMenu.SortSelected]
if not id or id == 0 then
return
end
local delay = tonumber(TrinketMenu_SortDelay:GetText()) or 0
TrinketMenuQueue.Stats[id] = TrinketMenuQueue.Stats[id] or { }
TrinketMenuQueue.Stats[id].delay = delay ~= 0 and delay or nil
end
function TrinketMenu.SortPriority_OnClick(self)
local check = self:GetChecked()
local id = TrinketMenuQueue.Sort[TrinketMenu.CurrentlySorting][TrinketMenu.SortSelected]
TrinketMenuQueue.Stats[id] = TrinketMenuQueue.Stats[id] or { }
TrinketMenuQueue.Stats[id].priority = check
end
function TrinketMenu.SortKeepEquipped_OnClick(self)
local check = self:GetChecked()
local id = TrinketMenuQueue.Sort[TrinketMenu.CurrentlySorting][TrinketMenu.SortSelected]
TrinketMenuQueue.Stats[id] = TrinketMenuQueue.Stats[id] or { }
TrinketMenuQueue.Stats[id].keep = check
end
function TrinketMenu.TabCheck_OnClick(self)
TrinketMenuQueue.Enabled[3 - self:GetID()] = self:GetChecked()
TrinketMenu.UpdateCombatQueue()
end
--[[ Auto queue processing ]]
function TrinketMenu.TrinketNearReady(id)
local start, duration = TrinketMenu.GetItemCooldown(id)
if start == 0 or duration - (GetTime() - start) <= 30 then
return 1
end
end
function TrinketMenu.CanCooldown(inv)
local _, _, enable = GetInventoryItemCooldown("player", inv)
return enable == 1
end
-- this function quickly checks if conditions are right for a possible ProcessAutoQueue
function TrinketMenu.PeriodicQueueCheck()
if not TrinketMenuQueue.Enabled[0] and not TrinketMenuQueue.Enabled[1] then
TrinketMenu.StopTimer("QueueUpdate")
return
end
TrinketMenu.StartTimer("QueueUpdate")
for i = 0, 1 do
if TrinketMenuQueue.Enabled[i] then
TrinketMenu.ProcessAutoQueue(i)
end
end
end
-- which = 0 or 1, decides if a trinket should be equipped and equips if so
function TrinketMenu.ProcessAutoQueue(which)
local _, _, id = string.find(GetInventoryItemLink("player", 13 + which) or "", "item:(%d+)")
if not id then
return
end -- leave if no trinket equipped
local start, duration, enable = GetInventoryItemCooldown("player", 13 + which)
local timeLeft = GetTime() - start
local icon = _G["TrinketMenu_Trinket"..which.."Queue"]
if IsInventoryItemLocked(13 + which) then
return
end -- leave if slot being swapped
if (IsVanillaClassic and CastingInfo and (CastingInfo() or ChannelInfo())) or (not IsVanillaClassic and (UnitCastingInfo("player") or UnitChannelInfo("player"))) then
return
end -- leave if player is casting/channeling
if TrinketMenu.PausedQueue[which] then
icon:SetVertexColor(1, .5, .5) -- leave if SetQueue(which, "PAUSE")
return
end
if TrinketMenuQueue.Stats[id] then
if TrinketMenuQueue.Stats[id].keep then
icon:SetVertexColor(1, .5, .5)
return -- leave if .keep flag set on this item
end
if TrinketMenuQueue.Stats[id].delay then
-- leave if currently equipped trinket is on cooldown for less than its delay
if start > 0 and (duration - timeLeft) > 30 and timeLeft < TrinketMenuQueue.Stats[id].delay then
icon:SetDesaturated(true)
return
end
else
local buffName = C_Item.GetItemSpell(id)
if buffName then
if AuraUtil.FindAuraByName(buffName, "player", "HELPFUL") or (start > 0 and (duration - timeLeft) > 30 and timeLeft < 1) then
if not TRINKET_KEEP_BUFF_AFTER_SWAP[id] then
icon:SetDesaturated(true)
return
end
end
end
end
end
icon:SetDesaturated(false) -- normal queue operation, reflect that in queue inset
icon:SetVertexColor(1, 1, 1)
local name
local ready = TrinketMenu.TrinketNearReady(id)
if ready and TrinketMenu.CombatQueue[which] then
TrinketMenu.CombatQueue[which] = nil
TrinketMenu.UpdateCombatQueue()
end
local list, rank = TrinketMenuQueue.Sort[which], nil
for i = 1, #list do
if list[i] == 0 then
rank = i
break
end
if ready and list[i] == id then
rank = i
break
end
end
if rank then
for i = 1, rank do
if not ready or enable == 0 or (TrinketMenuQueue.Stats[list[i]] and TrinketMenuQueue.Stats[list[i]].priority) then
if TrinketMenu.TrinketNearReady(list[i]) then
if C_Item.GetItemCount(list[i]) > 0 and not C_Item.IsEquippedItem(list[i]) then
local _, bag, slot = TrinketMenu.FindItem(list[i])
if bag and slot then
name = C_Item.GetItemInfo(list[i])
if TrinketMenu.CombatQueue[which] ~= name then
TrinketMenu.EquipTrinketByName(name, 13 + which)
end
break
end
end
end
end
end
end
end
--[[ TrinketMenu.SetQueue and TrinketMenu.GetQueue ]]
-- These functions are for macros and mods to configure sort queues
-- TrinketMenu.SetQueue(0 or 1,"ON" or "OFF" or "PAUSE" or "RESUME" or "SORT"[,"sort list")
-- some examples:
-- TrinketMenu.SetQueue(1, "PAUSE") -- if queue is going, pause it
-- TrinketMenu.SetQueue(1, "RESUME") -- if queue is paused, resume it
-- TrinketMenu.SetQueue(1, "SORT", "Earthstrike", "Insignia of the Alliance", "Diamond Flask") -- set sort
-- TrinketMenu.SetQueue(0, "SORT", "Lifestone", "Darkmoon Card: Heroism") -- set sort for trinket 0
-- TrinketMenu.SetQueue(1, "SORT", "Pvp Profile") -- note you can replace list with a profile name
-- (a "stop the queue" is assumed at the end of the list)
function TrinketMenu.SetQueue(which, ...)
local errorstub = "|cFFBBBBBBTrinketMenu:|cFFFFFFFF "
if not which or not tonumber(which) or which < 0 or which > 1 then
DEFAULT_CHAT_FRAME:AddMessage(errorstub.."First parameter must be 0 for top trinket or 1 for bottom.")
return
end
if (select("#", ...)) < 1 then
DEFAULT_CHAT_FRAME:AddMessage(errorstub.."Second parameter is either ON, OFF, PAUSE, RESUME or the beginning of a list of trinkets in a sort order.")
return
end
if TrinketMenu_OptFrame:IsVisible() then
TrinketMenu_OptFrame:Hide() -- close option frame if it's up. the mess otherwise would be scary
end
local cmd = (select(1, ...))
if cmd == "ON" then
TrinketMenuQueue.Enabled[which] = true
TrinketMenu.PausedQueue[which] = nil
elseif cmd == "OFF" then
TrinketMenuQueue.Enabled[which] = nil
TrinketMenu.PausedQueue[which] = nil
elseif cmd == "PAUSE" then
TrinketMenu.PausedQueue[which] = true
elseif cmd == "RESUME" then
TrinketMenu.PausedQueue[which] = nil
elseif cmd == "SORT" and (select("#", ...)) > 1 then
local inv, bag, slot
wipe(TrinketMenuQueue.Sort[which])
--table.setn(TrinketMenuQueue.Sort[which], 0)
local profile = TrinketMenu.GetProfileID((select(2,...)))
if profile then
for i = 2, #TrinketMenuQueue.Profiles[profile] do
table.insert(TrinketMenuQueue.Sort[which], TrinketMenuQueue.Profiles[profile][i])
end
else
for i = 2, (select("#", ...)) do
inv, bag, slot = TrinketMenu.FindItem((select(i, ...)), true) -- include inventory
if inv then
table.insert(TrinketMenuQueue.Sort[which], TrinketMenu.GetID(inv))
elseif bag then
table.insert(TrinketMenuQueue.Sort[which], TrinketMenu.GetID(bag, slot))
else
DEFAULT_CHAT_FRAME:AddMessage(errorstub.."Trinket or profile \""..(select(i, ...)).."\" not found.")
end
end
table.insert(TrinketMenuQueue.Sort[which], 0)
end
else
DEFAULT_CHAT_FRAME:AddMessage(errorstub.." Expected ON, OFF, PAUSE, RESUME or SORT+list")
end
TrinketMenu.ReflectQueueEnabled()
TrinketMenu.UpdateCombatQueue()
end
-- returns 1 or nil if queue is enabled, and a table containing an ordered list of the trinkets
function TrinketMenu.GetQueue(which)
if not which or not tonumber(which) or which < 0 or which > 1 then
DEFAULT_CHAT_FRAME:AddMessage("|cFFBBBBBBTrinketMenu.GetQueue:|cFFFFFFFF Parameter must be 0 for top trinket or 1 for bottom.")
return
end
local trinketList, name = { }, nil
for i = 1, #TrinketMenuQueue.Sort[which] do
name = TrinketMenu.GetNameByID(TrinketMenuQueue.Sort[which][i])
table.insert(trinketList, name)
end
return TrinketMenuQueue.Enabled[which], trinketList
end
--[[ Profiles ]]
-- add="add" or "remove" to add or remove "frame" from UISpecialFrames
function TrinketMenu.Escable(frame, add)
local found
for i in pairs(UISpecialFrames) do
found = found or (UISpecialFrames[i] == frame and i)
end
if not found and add == "add" then
table.insert(UISpecialFrames, frame)
elseif found and add == "remove" then
table.remove(UISpecialFrames, found)
end
end
-- shows profile if show non-nil. TrinketMenu_ProfilesFrame has an OnHide that calls this with nil
function TrinketMenu.ShowProfiles(show)
local normalTexture = TrinketMenu_Profiles:GetNormalTexture()
local pushedTexture = TrinketMenu_Profiles:GetPushedTexture()
if show then
TrinketMenu_SortListFrame:Hide()
TrinketMenu_ProfilesFrame:Show()
normalTexture:SetTexCoord(.875, 1, .25, .375)
pushedTexture:SetTexCoord(.75, .875, .25, .375)
TrinketMenu.Escable("TrinketMenu_ProfilesFrame", "add")
TrinketMenu.Escable("TrinketMenu_OptFrame", "remove")
else
TrinketMenu_SortListFrame:Show()
TrinketMenu_ProfilesFrame:Hide()
pushedTexture:SetTexCoord(.875, 1, .25, .375)
normalTexture:SetTexCoord(.75, .875, .25, .375)
TrinketMenu.Escable("TrinketMenu_ProfilesFrame", "remove")
TrinketMenu.Escable("TrinketMenu_OptFrame", "add")
end
end
function TrinketMenu.ProfilesFrame_OnHide()
PlaySound(624)
TrinketMenu.ResetProfileSelected()
TrinketMenu.ShowProfiles(nil)
end
function TrinketMenu.ResetProfileSelected()
TrinketMenu.ProfileSelected = nil
TrinketMenu_ProfileName:SetText("")
TrinketMenu.ProfileScrollFrameUpdate()
TrinketMenu.ValidateProfile()
end
function TrinketMenu.ProfileScrollFrameUpdate()
local offset = FauxScrollFrame_GetOffset(TrinketMenu_ProfileScroll)
local list = TrinketMenuQueue.Profiles
FauxScrollFrame_Update(TrinketMenu_ProfileScroll, #(list) or 0, 7, 20)
local item, idx
for i = 1, 7 do
idx = offset + i
item = _G["TrinketMenu_Profile"..i]
if idx <= #list then
_G["TrinketMenu_Profile"..i.."Name"]:SetText(list[idx][1])
item:Show()
if TrinketMenu.ProfileSelected == idx then
item:LockHighlight()
else
item:UnlockHighlight()
end
else
item:Hide()
end
end
if #list == 0 then
TrinketMenu_Profile1Name:SetText("No profiles saved yet.")
TrinketMenu_Profile1:Show()
TrinketMenu_Profile1:UnlockHighlight()
end
end
function TrinketMenu.ProfileList_OnClick(self)
if #TrinketMenuQueue.Profiles > 0 then
local idx = self:GetID() + FauxScrollFrame_GetOffset(TrinketMenu_ProfileScroll)
if TrinketMenu.ProfileSelected == idx then
TrinketMenu.ProfileSelected = nil
TrinketMenu_ProfileName:SetText("")
else
TrinketMenu.ProfileSelected = idx
TrinketMenu_ProfileName:SetText(TrinketMenuQueue.Profiles[idx][1])
end
TrinketMenu.ProfileScrollFrameUpdate()
TrinketMenu.ValidateProfile()
end
end
function TrinketMenu.GetProfileID(name)
for i = 1, #TrinketMenuQueue.Profiles do
if TrinketMenuQueue.Profiles[i][1] == name then
return i
end
end
end
function TrinketMenu.ValidateProfile()
local name = TrinketMenu_ProfileName:GetText() or ""
TrinketMenu_ProfilesDelete:Disable()
TrinketMenu_ProfilesLoad:Disable()
TrinketMenu_ProfilesSave:Disable()
if TrinketMenu.GetProfileID(name) then
TrinketMenu_ProfilesDelete:Enable()
TrinketMenu_ProfilesLoad:Enable()
end
if strlen(name) > 0 then
TrinketMenu_ProfilesSave:Enable()
end
end
function TrinketMenu.ProfileName_OnTextChanged()
TrinketMenu.ProfileSelected = TrinketMenu.GetProfileID(TrinketMenu_ProfileName:GetText())
TrinketMenu.ProfileScrollFrameUpdate()
TrinketMenu.ValidateProfile()
end
function TrinketMenu.ProfilesButton_OnClick(self)
local idx = TrinketMenu.ProfileSelected
local name = TrinketMenu_ProfileName:GetText() or ""
if self == TrinketMenu_ProfilesDelete then
if idx and TrinketMenuQueue.Profiles[idx] then
table.remove(TrinketMenuQueue.Profiles, idx)
end
TrinketMenu.ResetProfileSelected()
elseif self == TrinketMenu_ProfilesSave then
if idx and TrinketMenuQueue.Profiles[idx] then
table.remove(TrinketMenuQueue.Profiles, idx)
end
table.insert(TrinketMenuQueue.Profiles, 1, {name})
local list = TrinketMenuQueue.Sort[TrinketMenu.CurrentlySorting]
local save = TrinketMenuQueue.Profiles[1]
for i = 1, #list do
table.insert(save, list[i])
if list[i] == 0 then
break
end
end
TrinketMenu_ProfilesFrame:Hide()
elseif self == TrinketMenu_ProfilesLoad then
TrinketMenu.LoadProfile(TrinketMenu.CurrentlySorting, idx)
elseif self == TrinketMenu_ProfilesCancel then
TrinketMenu_ProfilesFrame:Hide()
end
end
function TrinketMenu.ProfileList_OnDoubleClick(self)
if #TrinketMenuQueue.Profiles > 0 then
local idx = self:GetID() + FauxScrollFrame_GetOffset(TrinketMenu_ProfileScroll)
if TrinketMenuQueue.Profiles[idx] then
TrinketMenu.LoadProfile(TrinketMenu.CurrentlySorting, idx)
end
end
end
function TrinketMenu.LoadProfile(which, idx)
local list = TrinketMenuQueue.Sort[which]
local load = TrinketMenuQueue.Profiles[idx]
wipe(list)
--table.setn(list, 0)
for i = 2, #load do
table.insert(list, load[i])
end
TrinketMenu_ProfilesFrame:Hide()
TrinketMenu.OpenSort(which)
if TrinketMenuOptions.HideOnLoad == "ON" then
TrinketMenu_OptFrame:Hide()
end
end