-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FilterButton.lua
664 lines (595 loc) · 27.6 KB
/
FilterButton.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
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
664
---@class GT
local GT = LibStub("AceAddon-3.0"):GetAddon("GatheringTracker")
-- Localize global functions
local ipairs = ipairs
local math = math
local max = max
local next = next
local pairs = pairs
local select = select
local string = string
local table = table
local time = time
local tonumber = tonumber
local tostring = tostring
local type = type
local unpack = unpack
function GT:ToggleFilterButton(show)
if show then
GT.Debug("Show Filters Button", 1)
GT.baseFrame.button:Show()
if GT.baseFrame.button.mouseOver then
GT.baseFrame.button.mouseOver:Show()
end
GT:FiltersButtonFade()
return
end
if not show then
GT.Debug("Hide Filters Button", 1)
if GT.baseFrame.button then
GT.baseFrame.button:Hide()
if GT.baseFrame.button.mouseOver then
GT.baseFrame.button.mouseOver:Hide()
end
end
return
end
end
function GT:FiltersButton()
if not GT.db.profile.General.filtersButton then
GT:ToggleFilterButton(false)
return
end
if not GT.Enabled then
GT:ToggleFilterButton(false)
return
end
if GT.baseFrame.button then
GT:ToggleFilterButton(true)
return
end
GT.Debug("Create Filters Button", 1)
local filterButton = CreateFrame("Button", "GT_baseFrame_filtersButton", UIParent, "UIPanelButtonTemplate")
filterButton:SetPoint("BOTTOMRIGHT", GT.baseFrame.backdrop, "TOPLEFT")
filterButton:SetWidth(25)
filterButton:SetHeight(25)
filterButton:SetText("F")
filterButton:EnableMouse(true)
filterButton:RegisterForClicks("AnyDown")
filterButton:SetFrameStrata("BACKGROUND")
filterButton:SetFrameLevel(1)
filterButton:Show()
filterButton:SetScript("OnClick", function(self, button, down)
if button == "LeftButton" and IsShiftKeyDown() then
GT:ResetSession()
elseif button == "LeftButton" then
GT:GenerateFiltersMenu(self)
elseif button == "RightButton" and IsShiftKeyDown() then
GT.AlertSystem:ResetAlerts()
elseif button == "RightButton" then
GT:ClearFilters()
end
end)
GT.baseFrame.button = filterButton
GT:FiltersButtonFade()
end
function GT:AnchorFilterButton()
if not GT.baseFrame.button then
return
end
-- 25 is the size of the filter button, so if any part of the button is off screen it will be moved
local UITop = UIParent:GetTop() - 25
local UILeft = UIParent:GetLeft() + 25
local backdropTop = GT.baseFrame.backdrop:GetTop()
local backdropLeft = GT.baseFrame.backdrop:GetLeft()
if backdropTop >= UITop and backdropLeft <= UILeft then
GT.Debug("Display Location", 1, "Top Left", UITop, UILeft, backdropTop, backdropLeft)
local left, bottom, width, height = GT.baseFrame.frame:GetBoundsRect()
GT.baseFrame.button:SetPoint("BOTTOMRIGHT", GT.baseFrame.backdrop, "TOPLEFT", 25, -1 * (height + 25))
elseif backdropTop >= UITop then
GT.Debug("Display Location", 1, "Top", UITop, UILeft, backdropTop, backdropLeft)
GT.baseFrame.button:SetPoint("BOTTOMRIGHT", GT.baseFrame.backdrop, "TOPLEFT", 0, -25)
elseif backdropLeft <= UILeft then
GT.Debug("Display Location", 1, "Left", UITop, UILeft, backdropTop, backdropLeft)
GT.baseFrame.button:SetPoint("BOTTOMRIGHT", GT.baseFrame.backdrop, "TOPLEFT", 25, 0)
else
GT.baseFrame.button:SetPoint("BOTTOMRIGHT", GT.baseFrame.backdrop, "TOPLEFT")
end
end
local function CreateItemCheckBox(frame, itemData)
local expansion = itemData.expansion
local category = itemData.category
local function IsSelected_Item()
if GT.db.profile.Filters[itemData.id] == true then
return true
else
return false
end
end
local function SetSelected_Item()
GT.Debug("Item Button Clicked", 2, expansion, category, itemData.name)
local key = not IsSelected_Item()
GT.db.profile.Filters[itemData.id] = key or nil
GT:UpdateIDTable(itemData.id, key)
GT:RemoveItemData(key, itemData.id)
GT:InventoryUpdate(expansion .. " " .. category .. " " .. itemData.name .. " menu clicked", false)
end
if itemData.id == -1 then
local divider = frame:CreateTitle(itemData.name)
else
local rarity = C_Item.GetItemQualityByID(itemData.id) or 1
local R, G, B = C_Item.GetItemQualityColor(rarity)
local qualityHex = GT:RGBtoHex(R or 1, G or 1, B or 1, 1)
local name = "|c" .. qualityHex .. "|Hitem:" .. itemData.id .. "::::::::::::::::::|h" .. itemData.name
if itemData.quality then
if itemData.quality == 1 then
name = name .. " |A:Professions-ChatIcon-Quality-Tier1:17:15::1|a|h|r"
elseif itemData.quality == 2 then
name = name .. " |A:Professions-ChatIcon-Quality-Tier2:17:23::|a|h|r"
elseif itemData.quality == 3 then
name = name .. " |A:Professions-ChatIcon-Quality-Tier3:17:18::1|a|h|r"
end
else
name = name .. "|h|r"
end
frame[itemData.name] = frame:CreateCheckbox(name, IsSelected_Item, SetSelected_Item)
frame[itemData.name]:AddInitializer(function(text, description, menu)
local leftTexture = text:AttachTexture()
leftTexture:SetDrawLayer("BACKGROUND", 0)
leftTexture:SetPoint("LEFT", text.leftTexture1, "RIGHT", 7, 1)
text:SetHeight(26)
leftTexture:SetSize(24, 24)
if itemData.icon then
leftTexture:SetTexture(itemData.icon)
else
leftTexture:SetTexture(C_Item.GetItemIconByID(itemData.id))
end
text.fontString:SetPoint("LEFT", leftTexture, "RIGHT", 7, 1)
local leftTextureRarity = text:AttachTexture()
leftTextureRarity:SetDrawLayer("BACKGROUND", 1)
if rarity <= 1 then
leftTextureRarity:SetTexture("Interface\\Common\\WhiteIconFrame")
else
leftTextureRarity:SetAtlas("bags-glow-white")
end
leftTextureRarity:SetVertexColor(R, G, B, 0.8)
leftTextureRarity:SetAllPoints(leftTexture)
if itemData.quality then
local leftTextureQuality = text:AttachTexture()
leftTextureQuality:SetDrawLayer("BACKGROUND", 2)
if itemData.quality == 1 then
leftTextureQuality:SetAtlas("professions-icon-quality-tier1-inv", true)
elseif itemData.quality == 2 then
leftTextureQuality:SetAtlas("professions-icon-quality-tier2-inv", true)
elseif itemData.quality == 3 then
leftTextureQuality:SetAtlas("professions-icon-quality-tier3-inv", true)
end
leftTextureQuality:SetAllPoints(leftTexture)
end
end)
frame[itemData.name]:SetTooltip(function(tooltip, elementDescription)
tooltip:SetHyperlink(name)
end)
end
end
function GT:GenerateFiltersMenu(frame)
local function FiltersMenu(frame, rootDescription)
rootDescription:SetTag("GatheringTracker_Filter_Menu")
--GT:CreateSearchMenu(frame, rootDescription)
for expansionIndex, expansion in ipairs(GT.expansionsOrder) do
if GT.ItemData[expansion] then
local function IsSelected_Expansion()
local checked = true
for category, categoryData in pairs(GT.ItemData[expansion]) do
for _, itemData in ipairs(categoryData) do
if itemData.id ~= -1 and checked == true then
if GT.db.profile.Filters[itemData.id] == true then
checked = GT.db.profile.Filters[itemData.id]
else
checked = false
break
end
end
end
end
return checked
end
local function SetSelected_Expansion()
GT.Debug("Expansion Button Clicked", 2, expansion)
local key = not IsSelected_Expansion()
for category, categoryData in pairs(GT.ItemData[expansion]) do
for _, itemData in ipairs(categoryData) do
if not (itemData.id == -1) then
GT.db.profile.Filters[itemData.id] = key or nil
GT:UpdateIDTable(itemData.id, key)
GT:RemoveItemData(key, itemData.id)
end
end
end
GT:InventoryUpdate(expansion .. " clicked", false)
end
frame[expansion] = rootDescription:CreateCheckbox(expansion, IsSelected_Expansion, SetSelected_Expansion)
for categoryIndex, category in ipairs(GT.categoriesOrder) do
if GT.ItemData[expansion][category] then
local function IsSelected_Category()
local checked = true
for _, itemData in ipairs(GT.ItemData[expansion][category]) do
if itemData.id ~= -1 and checked == true then
if GT.db.profile.Filters[itemData.id] == true then
checked = GT.db.profile.Filters[itemData.id]
else
checked = false
break
end
end
end
return checked
end
local function SetSelected_Category()
GT.Debug("Category Button Clicked", 2, expansion, category)
local key = not IsSelected_Category()
for _, itemData in ipairs(GT.ItemData[expansion][category]) do
if not (itemData.id == -1) then
GT.db.profile.Filters[itemData.id] = key or nil
GT:UpdateIDTable(itemData.id, key)
GT:RemoveItemData(key, itemData.id)
end
end
GT:InventoryUpdate(expansion .. " " .. category .. " clicked", false)
end
frame[expansion][category] = frame[expansion]:CreateCheckbox(category, IsSelected_Category, SetSelected_Category)
frame[expansion][category]:SetScrollMode(GetScreenHeight() * 0.75)
for _, itemData in ipairs(GT.ItemData[expansion][category]) do
CreateItemCheckBox(frame[expansion][category], itemData)
end
end
end
end
end
--add Custom Filters to filterMenu
GT:CreateCustomFiltersList(frame, rootDescription)
--add Inventory Filters to the filterMenu
--these will use existing filters or add an item to custom filters is a normal filter doesn't exist
GT:CreateInventoryFilters(frame, rootDescription)
--add Profiles to filterMenu
GT:CreateProfilesList(frame, rootDescription)
GT.baseFrame.menu.rootDescription = rootDescription
end
---@class GT.baseFrame.menu: MenuProxy
GT.baseFrame.menu = GT.baseFrame.menu or {}
GT.baseFrame.menu = MenuUtil.CreateContextMenu(frame, FiltersMenu)
end
function GT:FiltersButtonFade(alpha)
GT.Debug("Filters Button Fade", 2, alpha)
if not GT.Enabled then
return
end
if not GT.db.profile.General.filtersButton then
return
end
if not GT.baseFrame.button then
return
end
if alpha then
local alpha = alpha / 100
if not GT.db.profile.General.buttonFade then
alpha = 1
end
GT.baseFrame.button:SetAlpha(alpha)
return
end
if GT.db.profile.General.buttonFade then
if not GT.baseFrame.button.mouseOver then
local mouseOver = CreateFrame("Frame", "GT_baseFrame_filterButton_mouseOver", UIParent)
mouseOver:SetWidth(75)
mouseOver:SetHeight(75)
mouseOver:SetPoint("CENTER", GT.baseFrame.button, "CENTER")
mouseOver:SetMouseClickEnabled(false)
mouseOver:SetFrameStrata("BACKGROUND")
mouseOver:SetFrameLevel(2)
GT.baseFrame.button.mouseOver = mouseOver
end
GT.baseFrame.button:SetIgnoreParentAlpha(GT.db.profile.General.buttonFade)
GT.baseFrame.button:LockHighlight()
GT.baseFrame.button.mouseOver:SetScript("OnEnter", function(self, motion)
if motion then
GT.baseFrame.button:SetAlpha(1)
GT:wait(nil, "FiltersButtonFade")
end
end)
GT.baseFrame.button.mouseOver:SetScript("OnLeave", function(self, motion)
if motion then
GT:wait(GT.db.profile.General.buttonDelay, "FiltersButtonFade", GT.db.profile.General.buttonAlpha)
end
end)
GT.baseFrame.button.mouseOver:SetMouseClickEnabled(false)
GT:wait(GT.db.profile.General.buttonDelay, "FiltersButtonFade", GT.db.profile.General.buttonAlpha)
else
GT.baseFrame.button:SetIgnoreParentAlpha(GT.db.profile.General.buttonFade)
GT.baseFrame.button:SetAlpha(1)
GT.baseFrame.button:UnlockHighlight()
if GT.baseFrame.button.mouseOver then
GT.baseFrame.button.mouseOver:SetScript("OnEnter", nil)
GT.baseFrame.button.mouseOver:SetScript("OnLeave", nil)
GT.baseFrame.button.mouseOver:SetMouseMotionEnabled(false)
end
end
end
function GT:CreateCustomFiltersList(frame, rootDescription)
local customFiltersList = {}
for id, data in pairs(GT.db.profile.CustomFiltersTable) do
local itemID = tonumber(id) or 1
local item = Item:CreateFromItemID(itemID)
--Waits for the data to be returned from the server
if not item:IsItemEmpty() then
item:ContinueOnItemLoad(function()
local itemLink = string.gsub(item:GetItemLink(), "[%[%]]", "")
local itemDetails = {
id = tonumber(id),
text = item:GetItemName(),
icon = tostring(C_Item.GetItemIconByID(itemID) or ""),
link = itemLink,
}
table.insert(customFiltersList, itemDetails)
end)
end
end
table.sort(customFiltersList, function(a, b)
return a.text < b.text
end)
local function IsSelected_CustomFilter()
local checked = true
for id, data in pairs(GT.db.profile.CustomFiltersTable) do
if data == true then
checked = true
else
checked = false
break
end
end
return checked
end
local function SetSelected_CustomFilter()
GT.Debug("Custom Filters Button Clicked", 2)
local key = not IsSelected_CustomFilter()
for id, data in pairs(GT.db.profile.CustomFiltersTable) do
GT.db.profile.CustomFiltersTable[id] = key
GT:UpdateIDTable(id, key)
GT:RemoveItemData(key, id)
end
GT:InventoryUpdate("Custom Filters clicked", false)
end
frame["Custom Filters"] = rootDescription:CreateCheckbox("Custom Filters", IsSelected_CustomFilter,
SetSelected_CustomFilter)
for itemIndex, itemData in ipairs(customFiltersList) do
local function IsSelected_CustomFilterItem()
return GT.db.profile.CustomFiltersTable[itemData.id]
end
local function SetSelected_CustomFilterItem()
GT.Debug("Custom Filter Item Button Clicked", 2, itemData.text)
local key = not IsSelected_CustomFilterItem()
GT.db.profile.CustomFiltersTable[itemData.id] = key
GT:UpdateIDTable(itemData.id, key)
GT:RemoveItemData(IsSelected_CustomFilterItem(), itemData.id)
GT:InventoryUpdate("Custom Filter " .. itemData.text .. " menu clicked", false)
end
frame["Custom Filters"][itemData.text] = frame["Custom Filters"]:CreateCheckbox(itemData.link,
IsSelected_CustomFilterItem, SetSelected_CustomFilterItem)
frame["Custom Filters"][itemData.text]:AddInitializer(function(text, description, menu)
local leftTexture = text:AttachTexture()
leftTexture:SetDrawLayer("BACKGROUND", 0)
leftTexture:SetPoint("LEFT", text.leftTexture1, "RIGHT", 7, 1)
text:SetHeight(26)
leftTexture:SetSize(24, 24)
leftTexture:SetTexture(tonumber(itemData.icon))
text.fontString:SetPoint("LEFT", leftTexture, "RIGHT", 7, 1)
local leftTextureRarity = text:AttachTexture()
leftTextureRarity:SetDrawLayer("BACKGROUND", 1)
local rarity = C_Item.GetItemQualityByID(itemData.id) or 1
if rarity <= 1 then
leftTextureRarity:SetTexture("Interface\\Common\\WhiteIconFrame")
else
leftTextureRarity:SetAtlas("bags-glow-white")
end
local R, G, B = C_Item.GetItemQualityColor(rarity)
leftTextureRarity:SetVertexColor(R, G, B, 0.8)
leftTextureRarity:SetAllPoints(leftTexture)
end)
frame["Custom Filters"][itemData.text]:SetTooltip(function(tooltip, elementDescription)
tooltip:SetHyperlink(itemData.link)
end)
end
end
function GT:CreateInventoryFilters(frame, rootDescription)
local BagStart = BACKPACK_CONTAINER
local BagEnd = BACKPACK_CONTAINER + NUM_BAG_SLOTS + 1
local inventoryItems = {}
local itemlist = {}
local normalFilter = {}
local customFilter = {}
for bag = BagStart, BagEnd do
for slot = 1, C_Container.GetContainerNumSlots(bag) do
local itemInfo = C_Container.GetContainerItemInfo(bag, slot)
if itemInfo and not itemlist[itemInfo.itemID] then
itemlist[itemInfo.itemID] = true
table.insert(inventoryItems, itemInfo)
end
end
end
if #inventoryItems > 0 then
for _, itemInfo in ipairs(inventoryItems) do
local itemFound = false
for _, itemData in ipairs(GT.ItemDataFlat) do
if itemData[GT.gameVersion] then
if itemInfo.itemID == itemData.id then
itemFound = true
table.insert(normalFilter, itemData)
end
end
end
if not itemFound then
table.insert(customFilter, itemInfo)
end
end
frame.Inventory = rootDescription:CreateButton("Inventory", function() end)
frame.Inventory:SetScrollMode(GetScreenHeight() * 0.75)
if #normalFilter > 0 then
local header = frame.Inventory:CreateTitle("Normal Filters Available")
header:SetTooltip(function(tooltip)
GameTooltip_SetTitle(tooltip, "Normal Filters Available")
GameTooltip_AddNormalLine(tooltip, "Normal filters exist for the following items.", false)
GameTooltip_AddNormalLine(tooltip, "When toggled, the normal filter will also be toggled.", false)
GameTooltip_AddNormalLine(tooltip, "If the item is removed from your inventory the normal filter will remain available under the appropriate expansion and category.")
end)
table.sort(normalFilter, function(a, b)
return a.name < b.name
end)
for _, itemData in ipairs(normalFilter) do
CreateItemCheckBox(frame.Inventory, itemData)
end
end
if #customFilter > 0 then
local header = frame.Inventory:CreateTitle("Add Custom Filter")
header:SetTooltip(function(tooltip)
GameTooltip_SetTitle(tooltip, "Add Custom Filter")
GameTooltip_AddNormalLine(tooltip, "Normal filters do |cffff0000NOT|r exist for the following items.", false)
GameTooltip_AddNormalLine(tooltip, "A |cff0dd110Checkmark|r means that a custom filter exists and is |cff0dd110Enabled|r for the item.", false)
GameTooltip_AddNormalLine(tooltip, "A |cffcf2929Dot|r means that a custom filter exists and is |cffcf2929Disabled|r for the item.", false)
GameTooltip_AddNormalLine(tooltip, "Unchecking an item will remove the custom filter for that item", false)
GameTooltip_AddNormalLine(tooltip, "If the item is removed from inventory while checked, the Custom Filter will |cffff0000NOT|r be removed.", false)
end)
table.sort(customFilter, function(a, b)
return a.itemName < b.itemName
end)
for _, itemInfo in ipairs(customFilter) do
-- template isn't working out, maybe try creating from lua?
frame.Inventory[itemInfo.itemName] = frame.Inventory:CreateTemplate("GTTriStateButtonTemplate")
frame.Inventory[itemInfo.itemName]:AddInitializer(function(checkbox)
checkbox:SetPoint("LEFT")
local itemLink = string.gsub(itemInfo.hyperlink, "[%[%]]", "")
checkbox:SetText(itemLink)
checkbox.icon:SetTexture(itemInfo.iconFileID)
if itemInfo.quality <= 1 then
checkbox.iconBorder:SetTexture("Interface\\Common\\WhiteIconFrame")
else
checkbox.iconBorder:SetAtlas("bags-glow-white")
end
local R, G, B = C_Item.GetItemQualityColor(itemInfo.quality)
checkbox.iconBorder:SetVertexColor(R, G, B, 0.8)
checkbox.checkBoxFill = checkbox:AttachTexture()
checkbox.checkBoxFill:SetPoint("CENTER", checkbox.checkBox)
function checkbox:SetCheckedTexture()
if checkbox.checked == 0 then
checkbox.checkBoxFill:SetAtlas(nil)
elseif checkbox.checked == 1 then
checkbox.checkBoxFill:SetAtlas("common-dropdown-icon-checkmark-yellow", true)
checkbox.checkBoxFill:SetPoint("CENTER", checkbox.checkBox, "CENTER", 2, 1)
elseif checkbox.checked == 2 then
checkbox.checkBoxFill:SetAtlas("common-dropdown-icon-radialtick-yellow", true)
checkbox.checkBoxFill:SetPoint("CENTER", checkbox.checkBox, "CENTER")
end
end
if GT.db.profile.CustomFiltersTable[itemInfo.itemID] ~= nil then
if GT.db.profile.CustomFiltersTable[itemInfo.itemID] then
checkbox.checked = 1
else
checkbox.checked = 2
end
checkbox:SetCheckedTexture()
end
checkbox:SetScript("OnClick", function()
if checkbox.checked == 0 then
GT:CreateCustomFilterItem(itemInfo.itemID, true)
GT:UpdateIDTable(itemInfo.itemID, true)
GT:InventoryUpdate("Inventory Custom Filter " .. itemInfo.itemName .. " option clicked", true)
checkbox.checked = 1
elseif checkbox.checked == 1 then
GT.db.profile.CustomFiltersTable[itemInfo.itemID] = false
GT:UpdateIDTable(itemInfo.itemID, false)
GT:RemoveItemData(false, itemInfo.itemID)
GT:InventoryUpdate("Inventory Custom Filter " .. itemInfo.itemName .. " option clicked", true)
checkbox.checked = 2
elseif checkbox.checked == 2 then
GT:DeleteCustomFilter(itemInfo.itemID, itemInfo.itemName)
checkbox.checked = 0
end
checkbox:SetCheckedTexture()
end)
local height = 26
local width = checkbox.checkBox:GetWidth() + checkbox.icon:GetWidth() + checkbox.text:GetUnboundedStringWidth()
return width, height
end)
frame.Inventory[itemInfo.itemName]:SetTooltip(function(tooltip, elementDescription)
tooltip:SetHyperlink(itemInfo.hyperlink)
end)
end
end
end
end
function GT:CreateProfilesList(frame, rootDescription)
local function IsSelected_ProfilesCategory()
return false
end
local function SetSelected_ProfilesCategory()
end
frame["Profiles"] = rootDescription:CreateCheckbox("Profiles", IsSelected_ProfilesCategory, SetSelected_ProfilesCategory)
frame["Profiles"]:SetSelectionIgnored()
for _, name in ipairs(GT.db:GetProfiles()) do
local function IsSelected_Profile()
local current = GT.db:GetCurrentProfile()
if current == name then
return true
else
return false
end
end
local function SetSelected_Profile()
GT.Debug("Profile Button Clicked", 2, name)
GT.db:SetProfile(name)
GT.baseFrame.menu:Close()
end
frame["Profiles"][name] = frame["Profiles"]:CreateCheckbox(name, IsSelected_Profile, SetSelected_Profile)
end
end
function GT:DisplayAllCheck()
if not GT.db.profile.General.allFiltered then
return
end
if #GT.IDs > 500 then
GT.db.profile.General.allFiltered = false
end
end
--[[
function GT:CreateSearchMenu(frame, rootDescription)
GT.baseFrame.menu.SearchResults = GT.baseFrame.menu.SearchResults or {}
local frame = frame or {}
frame.Search = rootDescription:CreateButton("Search", function() end)
frame.Search:SetScrollMode(GetScreenHeight() * 0.75)
frame.Search.searchBar = frame.Search:CreateFrame()
frame.Search.searchBar:AddInitializer(function(searchBar)
local editbox = searchBar:AttachTemplate("SearchBoxTemplate")
editbox:SetPoint("TOPLEFT")
editbox:SetSize(200, 22)
editbox:HookScript("OnEnterPressed", function()
GT.baseFrame.menu.SearchResults = {}
for _, itemData in ipairs(GT.ItemDataFlat) do
if itemData[GT.gameVersion] then
if string.find(string.lower(itemData.name), string.lower(editbox:GetText())) then
GT.Debug("Filter Menu Search", 2, editbox:GetText(), itemData.name)
table.insert(GT.baseFrame.menu.SearchResults, itemData)
end
end
end
GT:GenerateFiltersMenu(GT.baseFrame.button)
--GT.baseFrame.menu:ReinitializeAll()
end)
editbox.clearButton:HookScript("OnClick", function()
end)
end)
if #GT.baseFrame.menu.SearchResults > 0 then
for index, itemData in ipairs(GT.baseFrame.menu.SearchResults) do
CreateItemCheckBox(frame.Search, itemData)
end
end
end
]]