forked from TekNoLogic/GnomishAuctionShrinker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortButton.lua
More file actions
78 lines (61 loc) · 2.71 KB
/
SortButton.lua
File metadata and controls
78 lines (61 loc) · 2.71 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
local sorts = {
buyout = {"duration", "quantity", "name", "level", "quality", "bid", "buyout"},
buyout_rev = { false, true, false, true, false, false, false},
quantity = {"duration", "buyoutthenbid", "name", "level", "quality", "quantity"},
quantity_rev = { false, false, false, true, false, false},
}
local function SortAuctions(self)
local existingSortColumn, existingSortReverse = GetAuctionSort("list", 1) -- change the sort as appropriate
local oppositeOrder = false
if existingSortColumn and existingSortColumn == self.sortcolumn then oppositeOrder = not existingSortReverse end
SortAuctionClearSort("list") -- clear the existing sort.
local revs = sorts[self.sortcolumn.."_rev"]
for i,column in ipairs(sorts[self.sortcolumn]) do -- set the columns
local reverse = revs[i]
if i == #revs and existingSortColumn and existingSortColumn == self.sortcolumn and (not not existingSortReverse) == reverse then reverse = not reverse end
SortAuctionSetSort("list", column, reverse)
end
AuctionFrameBrowse_Search() -- apply the sort
end
function tek_MakeSortButton(text, sortcolumn)
local butt = CreateFrame("Button", nil, AuctionFrameBrowse)
butt:SetHeight(19)
butt:SetNormalFontObject(GameFontHighlightSmall)
butt:SetText(text)
local fs = butt:GetFontString()
fs:ClearAllPoints()
fs:SetPoint("LEFT", butt, "LEFT", 8, 0)
local left = butt:CreateTexture(nil, "BACKGROUND")
left:SetWidth(5) left:SetHeight(19)
left:SetPoint("TOPLEFT")
left:SetTexture("Interface\\FriendsFrame\\WhoFrame-ColumnTabs")
left:SetTexCoord(0, 0.078125, 0, 0.59375)
local right = butt:CreateTexture(nil, "BACKGROUND")
right:SetWidth(4) right:SetHeight(19)
right:SetPoint("TOPRIGHT")
right:SetTexture("Interface\\FriendsFrame\\WhoFrame-ColumnTabs")
right:SetTexCoord(0.90625, 0.96875, 0, 0.59375)
local middle = butt:CreateTexture(nil, "BACKGROUND")
middle:SetHeight(19)
middle:SetPoint("LEFT", left, "RIGHT")
middle:SetPoint("RIGHT", right, "LEFT")
middle:SetTexture("Interface\\FriendsFrame\\WhoFrame-ColumnTabs")
middle:SetTexCoord(0.078125, 0.90625, 0, 0.59375)
local arrow = butt:CreateTexture()
arrow:ClearAllPoints()
arrow:SetPoint("LEFT", fs, "RIGHT", 0, -2)
arrow:SetWidth(9) arrow:SetHeight(8)
arrow:SetTexture("Interface\\Buttons\\UI-SortArrow")
arrow:SetTexCoord(0, 0.5625, 0, 1)
arrow:Hide()
butt.arrow = arrow
butt:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight", "ADD")
local highlight = butt:GetHighlightTexture()
highlight:ClearAllPoints()
highlight:SetPoint("LEFT")
highlight:SetPoint("RIGHT")
highlight:SetHeight(24)
butt.sortcolumn = sortcolumn
if sortcolumn then butt:SetScript("OnClick", SortAuctions) end
return butt
end