vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local locals = KC_ITEMS_LOCALS.modules.auction |
2 | KC_Auction.gui = {} |
||
3 | local gui = KC_Auction.gui |
||
4 | |||
5 | gui.frame = AceGUI:new() |
||
6 | |||
7 | gui.filtertemplate = { |
||
8 | type = ACEGUI_CHECKBOX, |
||
9 | title = "", |
||
10 | disabled = FALSE, |
||
11 | OnClick = "FilterClick", |
||
12 | width = 20, |
||
13 | height = 20, |
||
14 | anchors = { |
||
15 | right = { |
||
16 | relPoint = "right", |
||
17 | xOffset = -5, |
||
18 | yOffset = 0, |
||
19 | } |
||
20 | } |
||
21 | } |
||
22 | |||
23 | gui.config = { |
||
24 | name = "KC_Auction_", |
||
25 | elements = { |
||
26 | ScanButton = { |
||
27 | type = ACEGUI_BUTTON, |
||
28 | title = locals.labels.scan, |
||
29 | disabled = FALSE, |
||
30 | OnClick = "ScanClick", |
||
31 | width = 80, |
||
32 | height = 22, |
||
33 | anchors = { |
||
34 | right = { |
||
35 | relTo = "BrowseBidButton", |
||
36 | relPoint = "left", |
||
37 | xOffset = 0, |
||
38 | yOffset = 0, |
||
39 | } |
||
40 | }, |
||
41 | }, |
||
42 | FilterChk0 = { |
||
43 | type = ACEGUI_CHECKBOX, |
||
44 | title = locals.labels.all, |
||
45 | disabled = FALSE, |
||
46 | OnClick = "FilterAllClick", |
||
47 | width = 20, |
||
48 | height = 20, |
||
49 | anchors = { |
||
50 | bottom = { |
||
51 | relTo = "KC_Auction_FilterChk1", |
||
52 | relPoint = "top", |
||
53 | xOffset = -8, |
||
54 | yOffset = 3, |
||
55 | } |
||
56 | } |
||
57 | }, |
||
58 | FilterChk1 = gui.filtertemplate, |
||
59 | FilterChk2 = gui.filtertemplate, |
||
60 | FilterChk3 = gui.filtertemplate, |
||
61 | FilterChk4 = gui.filtertemplate, |
||
62 | FilterChk5 = gui.filtertemplate, |
||
63 | FilterChk6 = gui.filtertemplate, |
||
64 | FilterChk7 = gui.filtertemplate, |
||
65 | FilterChk8 = gui.filtertemplate, |
||
66 | FilterChk9 = gui.filtertemplate, |
||
67 | FilterChk10 = gui.filtertemplate, |
||
68 | FilterChk11 = gui.filtertemplate, |
||
69 | FilterChk12 = gui.filtertemplate, |
||
70 | FilterChk13 = gui.filtertemplate, |
||
71 | FilterChk14 = gui.filtertemplate, |
||
72 | FilterChk15 = gui.filtertemplate, |
||
73 | } |
||
74 | } |
||
75 | |||
76 | function gui.frame:SetParents() |
||
77 | KC_Auction_ScanButton:SetParent("AuctionFrameBrowse"); |
||
78 | KC_Auction_FilterChk0:SetParent("AuctionFilterButton1") |
||
79 | KC_Auction_FilterChk1:SetParent("AuctionFilterButton1") |
||
80 | KC_Auction_FilterChk2:SetParent("AuctionFilterButton2") |
||
81 | KC_Auction_FilterChk3:SetParent("AuctionFilterButton3") |
||
82 | KC_Auction_FilterChk4:SetParent("AuctionFilterButton4") |
||
83 | KC_Auction_FilterChk5:SetParent("AuctionFilterButton5") |
||
84 | KC_Auction_FilterChk6:SetParent("AuctionFilterButton6") |
||
85 | KC_Auction_FilterChk7:SetParent("AuctionFilterButton7") |
||
86 | KC_Auction_FilterChk8:SetParent("AuctionFilterButton8") |
||
87 | KC_Auction_FilterChk9:SetParent("AuctionFilterButton9") |
||
88 | KC_Auction_FilterChk10:SetParent("AuctionFilterButton10") |
||
89 | KC_Auction_FilterChk11:SetParent("AuctionFilterButton11") |
||
90 | KC_Auction_FilterChk12:SetParent("AuctionFilterButton12") |
||
91 | KC_Auction_FilterChk13:SetParent("AuctionFilterButton13") |
||
92 | KC_Auction_FilterChk14:SetParent("AuctionFilterButton14") |
||
93 | KC_Auction_FilterChk15:SetParent("AuctionFilterButton15") |
||
94 | end |
||
95 | |||
96 | function gui.frame:OnLoad() |
||
97 | self.filters = {self.app.common:Explode(self.app:GetOpt({"options"}, "filters"), ",")} |
||
98 | self:UpdateChks() |
||
99 | |||
100 | self:Hook("AuctionFrameFilter_OnClick", function () self.Hooks.AuctionFrameFilter_OnClick.orig(); self:UpdateChks() end); |
||
101 | self:Hook("AuctionFrameFilters_Update", function () self.Hooks.AuctionFrameFilters_Update.orig(); self:UpdateChks() end); |
||
102 | end |
||
103 | |||
104 | function gui.frame:FilterClick() |
||
105 | self.filters[this:GetID()] = (self.filters[this:GetID()] == 1) and 0 or 1 |
||
106 | this:SetChecked(self.filters[this:GetID()]) |
||
107 | self:UpdateAllChk() |
||
108 | end |
||
109 | |||
110 | function gui.frame:FilterAllClick() |
||
111 | for i = 1, 10 do |
||
112 | self.filters[i] = (this:GetChecked() == 1) and 1 or 0 |
||
113 | end |
||
114 | self:SaveFilters() |
||
115 | self:UpdateChks() |
||
116 | end |
||
117 | |||
118 | function gui.frame:ScanClick() |
||
119 | if (self.scanning) then |
||
120 | self.ScanButton:SetValue(locals.labels.scan); |
||
121 | self.scanning = false; |
||
122 | self.app:ScanCanceled(); |
||
123 | else |
||
124 | self.ScanButton:SetValue(locals.labels.stopscan); |
||
125 | self.scanning = true; |
||
126 | self.app:Scan(); |
||
127 | end |
||
128 | end |
||
129 | |||
130 | function gui.frame:UpdateAllChk() |
||
131 | self:SaveFilters() |
||
132 | self.FilterChk0:SetChecked(not strfind(self.app:GetOpt({"options"}, "filters"), "0") and 1) |
||
133 | end |
||
134 | |||
135 | function gui.frame:UpdateChks() |
||
136 | for i = 1, 15 do |
||
137 | local button = getglobal("AuctionFilterButton" .. i) |
||
138 | local chk = self["FilterChk" .. i] |
||
139 | if (not button:IsVisible() or button.type ~= "class") then |
||
140 | chk:Hide() |
||
141 | else |
||
142 | chk:Show() |
||
143 | chk:SetID(button.index) |
||
144 | chk:SetChecked(self.filters[button.index]) |
||
145 | end |
||
146 | end |
||
147 | self:UpdateAllChk() |
||
148 | end |
||
149 | |||
150 | function gui.frame:SaveFilters() |
||
151 | self.app:SetOpt({"options"}, "filters", format("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", unpack(self.filters))) |
||
152 | end |