vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --$Id: opt-gui.lua 2106 2006-05-24 03:47:06Z kaelten $ |
2 | local locals = KC_ET_LOCALS |
||
3 | local tablet = TabletLib:GetInstance('1.0') |
||
4 | |||
5 | |||
6 | KC_EnhancedTrades.opt = {} |
||
7 | local opt = KC_EnhancedTrades.opt |
||
8 | |||
9 | opt.frame = AceGUI:new() |
||
10 | |||
11 | opt.config = { |
||
12 | name = "KC_EnhancedTradesConfigFrame", |
||
13 | type = ACEGUI_DIALOG, |
||
14 | title = "EnhancedTrades Options", |
||
15 | isSpecial = TRUE, |
||
16 | width = 275, |
||
17 | height = 290, |
||
18 | OnShow = "OnShow", |
||
19 | OnHide = "OnHide", |
||
20 | anchors = { |
||
21 | topright = {relPoint = "topright", xOffset = 0, yOffset = 0} |
||
22 | }, |
||
23 | elements = { |
||
24 | Toggle = { |
||
25 | type = ACEGUI_CHECKBOX, |
||
26 | title = "Enable KC_EnhancedTrades", |
||
27 | disabled = FALSE, |
||
28 | OnClick = "ToggleEnable", |
||
29 | width = 26, |
||
30 | height = 26, |
||
31 | anchors = { |
||
32 | topleft = {xOffset = 37, yOffset = -35} |
||
33 | }, |
||
34 | }, |
||
35 | ShowLegend = { |
||
36 | type = ACEGUI_CHECKBOX, |
||
37 | title = "Show Legend", |
||
38 | disabled = FALSE, |
||
39 | OnClick = "ChangeOpt", |
||
40 | width = 26, |
||
41 | height = 26, |
||
42 | anchors = { |
||
43 | topleft = {relTo = "$parentToggle", relPoint = "bottomleft", xOffset = 0, yOffset = 0} |
||
44 | }, |
||
45 | }, |
||
46 | Smart = { |
||
47 | type = ACEGUI_CHECKBOX, |
||
48 | title = "Use Smart Display", |
||
49 | disabled = FALSE, |
||
50 | OnClick = "ChangeOpt", |
||
51 | width = 26, |
||
52 | height = 26, |
||
53 | anchors = { |
||
54 | topleft = {relTo = "$parentShowLegend", relPoint = "bottomleft", xOffset = 0, yOffset = 0} |
||
55 | }, |
||
56 | }, |
||
57 | ShowIv = { |
||
58 | type = ACEGUI_CHECKBOX, |
||
59 | title = "Show Inv + Vendor", |
||
60 | disabled = FALSE, |
||
61 | OnClick = "ChangeOpt", |
||
62 | width = 26, |
||
63 | height = 26, |
||
64 | anchors = { |
||
65 | topleft = {relTo = "$parentSmart", relPoint = "bottomleft", xOffset = 0, yOffset = -20} |
||
66 | }, |
||
67 | }, |
||
68 | ShowIb = { |
||
69 | type = ACEGUI_CHECKBOX, |
||
70 | title = "Show Inv + Bank", |
||
71 | disabled = FALSE, |
||
72 | OnClick = "ChangeOpt", |
||
73 | width = 26, |
||
74 | height = 26, |
||
75 | anchors = { |
||
76 | topleft = {relTo = "$parentShowIv", relPoint = "bottomleft", xOffset = 0, yOffset = 0} |
||
77 | }, |
||
78 | }, |
||
79 | ShowIvb = { |
||
80 | type = ACEGUI_CHECKBOX, |
||
81 | title = "Show Inv + Vendor + Bank ", |
||
82 | disabled = FALSE, |
||
83 | OnClick = "ChangeOpt", |
||
84 | width = 26, |
||
85 | height = 26, |
||
86 | anchors = { |
||
87 | topleft = {relTo = "$parentShowIb", relPoint = "bottomleft", xOffset = 0, yOffset = 0} |
||
88 | }, |
||
89 | }, |
||
90 | ShowIvba = { |
||
91 | type = ACEGUI_CHECKBOX, |
||
92 | title = "Show Inv + Vendor + Bank + Alts", |
||
93 | disabled = FALSE, |
||
94 | OnClick = "ChangeOpt", |
||
95 | width = 26, |
||
96 | height = 26, |
||
97 | anchors = { |
||
98 | topleft = {relTo = "$parentShowIvb", relPoint = "bottomleft", xOffset = 0, yOffset = 0} |
||
99 | }, |
||
100 | }, |
||
101 | |||
102 | } |
||
103 | } |
||
104 | |||
105 | function opt.frame:OnShow() |
||
106 | self:UpdateAnchor() |
||
107 | self:RegisterHints() |
||
108 | self:FillSettings() |
||
109 | end |
||
110 | |||
111 | function opt.frame:FillSettings() |
||
112 | self.Toggle:SetValue(not self.app.disabled) |
||
113 | self.ShowLegend:SetValue(self.app:GetOpt({"trades", "options"}, 1)) |
||
114 | self.Smart:SetValue(self.app:GetOpt({"trades", "options"}, 2)) |
||
115 | self.ShowIv:SetValue(self.app:GetOpt({"trades", "options"}, 3)) |
||
116 | self.ShowIb:SetValue(self.app:GetOpt({"trades", "options"}, 4)) |
||
117 | self.ShowIvb:SetValue(self.app:GetOpt({"trades", "options"}, 5)) |
||
118 | self.ShowIvba:SetValue(self.app:GetOpt({"trades", "options"}, 6)) |
||
119 | |||
120 | end |
||
121 | |||
122 | function opt.frame:RegisterHints() |
||
123 | local frames = { |
||
124 | [0] = KC_EnhancedTradesConfigFrameToggle, |
||
125 | [1] = KC_EnhancedTradesConfigFrameShowLegend, |
||
126 | [2] = KC_EnhancedTradesConfigFrameSmart, |
||
127 | [3] = KC_EnhancedTradesConfigFrameShowIv, |
||
128 | [4] = KC_EnhancedTradesConfigFrameShowIb, |
||
129 | [5] = KC_EnhancedTradesConfigFrameShowIvb, |
||
130 | [6] = KC_EnhancedTradesConfigFrameShowIvba, |
||
131 | } |
||
132 | |||
133 | for i = 0, 6 do |
||
134 | local id = i |
||
135 | tablet:Register(frames[id], 'children', function() tablet:SetTitle(locals.titles[id]) tablet:SetHint(locals.hints[id]) end, 'data', {}, 'point', function() return "TOPRIGHT", "TOPLEFT" end) |
||
136 | end |
||
137 | end |
||
138 | |||
139 | function opt.frame:UpdateAnchor() |
||
140 | local frame |
||
141 | |||
142 | if (CraftFrame and CraftFrame:IsVisible()) then |
||
143 | frame = CraftFrame |
||
144 | elseif (TradeSkillFrame and TradeSkillFrame:IsVisible()) then |
||
145 | frame = TradeSkillFrame |
||
146 | else |
||
147 | self:Hide() |
||
148 | return |
||
149 | end |
||
150 | |||
151 | self.topUnit:ApplyAnchors({topleft = {relTo = frame:GetName(), relPoint = "topright", xOffset = 0, yOffset = -35}}, true) |
||
152 | end |
||
153 | |||
154 | function opt.frame:ToggleEnable() |
||
155 | self.app:Toggle() |
||
156 | end |
||
157 | |||
158 | function opt.frame:ChangeOpt() |
||
159 | self.app:TogOpt({"trades", "options"}, this:GetID()) |
||
160 | this:SetValue(self.app:GetOpt({"trades", "options"}, this:GetID())) |
||
161 | |||
162 | if (this:GetID() == 1) then |
||
163 | if (self.app.Hooks["TradeSkillFrame_Update"]) then |
||
164 | self.app:Update() |
||
165 | end |
||
166 | |||
167 | if (self.app.Hooks["CraftFrame_Update"]) then |
||
168 | self.app:Update(true) |
||
169 | end |
||
170 | end |
||
171 | |||
172 | if (this:GetID() > 1) then |
||
173 | self.app.cache = nil |
||
174 | self.app:Msg("The complete Datacache has been purged due to options change.") |
||
175 | |||
176 | self.app:BuildLegend() |
||
177 | |||
178 | if (self.app.Hooks["TradeSkillFrame_Update"]) then |
||
179 | self.app:Update() |
||
180 | end |
||
181 | |||
182 | if (self.app.Hooks["CraftFrame_Update"]) then |
||
183 | self.app:Update(true) |
||
184 | end |
||
185 | |||
186 | if (self.app.Hooks["TradeSkillFrame_SetSelection"]) then |
||
187 | self.app:SetSelection(self.app.tsfid) |
||
188 | end |
||
189 | |||
190 | if (self.app.Hooks["CraftFrame_SetSelection"]) then |
||
191 | self.app:SetSelection(self.app.cfid, true) |
||
192 | end |
||
193 | end |
||
194 | end |