vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | ------------------- |
||
3 | - Madorin's - |
||
4 | -Bag Status Meters- |
||
5 | - v1.3.7 - |
||
6 | ------------------- |
||
7 | |||
8 | Author: Romualdo |
||
9 | Original Author: Kevin "Madorin" Hassett |
||
10 | Last Updated: October 15, 2005 |
||
11 | |||
12 | -Patch Notes- |
||
13 | v1.3.7 (10/15/2005) |
||
14 | -TOC updated to 1800 |
||
15 | -Fixed errors with 1800 |
||
16 | -Fixed bug with quiver |
||
17 | v1.3.6 (4/04/2005): |
||
18 | -TOC updated to 4297 |
||
19 | -Added support for myAddOns AddOn arrangement (separate AddOn) |
||
20 | |||
21 | v1.3.5.1 (3/03/2005): |
||
22 | -Fixed a bug where any bag after an ammo bag or empty slot would not be checked |
||
23 | |||
24 | v1.3.5 (2/26/2005): |
||
25 | -TOC updated to 4216 |
||
26 | -Added an option to hide the background and meter on the Overall Meter |
||
27 | |||
28 | v1.3.4 (2/17/2005): |
||
29 | -Merged all localizations |
||
30 | -TOC updated to 4211 |
||
31 | -Added German Description |
||
32 | |||
33 | v1.3.3 (2/04/2005): |
||
34 | -Changed some variables from local to global for dependency possibilities. |
||
35 | -Fixed a quest reward ammo bag, "Bandolier of the Watch", to not show up as inventory. |
||
36 | -Put in bank bag labels. |
||
37 | -Set the Overall and Dropdown frame level to LOW. |
||
38 | -Commented Code. |
||
39 | |||
40 | v1.3.2 (1/24/2005): |
||
41 | -Fixed layering issues with overlay bars/labels. |
||
42 | -Replaced the command system with a GUI for more customizability. |
||
43 | -To access GUI, just type "/bsm" with anything or nothing following it. |
||
44 | -Added a key binding for BSM Options Pane. |
||
45 | -Added a UI button for the BSM Options Pane. |
||
46 | -Changed binding labels to buttons that toggle corresponding bag. |
||
47 | -Added an option to lock the overall meter. |
||
48 | -Added an option to place the overall meter at a specified location. |
||
49 | |||
50 | v1.3.1 (1/8/2005): |
||
51 | -Added "/bsm color" to toggle colors on/off. |
||
52 | -Added "/bsm totals" to toggle displaying the totals. |
||
53 | -Added "/bsm slots" to toggle using either free or used slots for display. |
||
54 | -Added "/bsm title" to toggle displaying the title on the overall meter. |
||
55 | -Added "/bsm notify" to toggle displaying notifications. |
||
56 | -Fixed "Inventory Full" notification to "Backpack Full". |
||
57 | -Fixed overall frame obstruction. |
||
58 | -Added notification when settings have changed. |
||
59 | -Changed color function to the one contributed by Azam. |
||
60 | -Added a brief readme. |
||
61 | |||
62 | v1.3 (1/5/2005): |
||
63 | -Fixed the small bug with ammo bags counting as inventory. |
||
64 | -Added alternative to use only text for displaying bag status ("/bsm none"). |
||
65 | -Added alternative to use a dropdown frame for displaying bag status ("/bsm none"). |
||
66 | -Added "/bsm help". |
||
67 | -Added ability to toggle hiding of labels ("/bsm labels"). |
||
68 | -Added saved variables. |
||
69 | -Added notification when a bag becomes full. |
||
70 | -Huge XML overhaul. |
||
71 | |||
72 | v1.2 (1/2/2005): |
||
73 | -Fixed a layer problem where the meters showed up over the map frame. |
||
74 | -Added "/bsm hide" and "/bsm show" to hide or show the overall bag meter. |
||
75 | -Minor tweak to the % at which the meters turn yellow. |
||
76 | |||
77 | v1.1 (1/1/2005): |
||
78 | -Optimization help from Vjeux. |
||
79 | -Fixed a bug where a bag dragged into the bag bar from a non-inventory bag would not update. |
||
80 | -Added the missing line of XML to make it draggable. |
||
81 | |||
82 | Special Thanks: Vjeux for v1.1 LUA and XML optimization |
||
83 | Azam for contributing an improved color function |
||
84 | kiki for the french localization |
||
85 | SirPennt for the german localization |
||
86 | SoNeX for the german description |
||
87 | ]] |
||
88 | |||
89 | |||
90 | --BSM_NumSlots: global variable that holds the total number of slots per bag |
||
91 | BSM_NumSlots = {0, 0, 0, 0, 0}; |
||
92 | --BSM_UsedSlots: global variable that holds the number of used slots per bag |
||
93 | BSM_UsedSlots = {0, 0, 0, 0, 0}; |
||
94 | --BSM_BagFull: global variable used for displaying notifications only once |
||
95 | BSM_BagFull = {false, false, false, false, false}; |
||
96 | |||
97 | BSM_LOADED = false; |
||
98 | |||
99 | --Variables for UI Objects |
||
100 | BSM_FRAME = "BSM_Frame"; |
||
101 | BSM_DROPDOWNS = "BSM_Dropdowns"; |
||
102 | BSM_DROPDOWNS_BARS = "BSM_DropdownsBars"; |
||
103 | BSM_BARS = "BSM_Bars"; |
||
104 | BSM_COODLOWNS = "BSM_Cooldowns"; |
||
105 | BSM_BARS_LABELS = "BSM_BarLabels"; |
||
106 | BSM_DROPDOWNS_LABELS = "BSM_DropdownLabels"; |
||
107 | BSM_BANK = "BSM_BankBag"; |
||
108 | |||
109 | --Variables for the type of slot used to keep count |
||
110 | BSM_SLOTS_FREE = 0; |
||
111 | BSM_SLOTS_TAKEN = 1; |
||
112 | |||
113 | |||
114 | |||
115 | --BSM_SavePosition: |
||
116 | -- Purpose - Save the position of the Overall Meter frame |
||
117 | -- Parameters - None |
||
118 | -- Returns - Nothing |
||
119 | function BSM_SavePosition() |
||
120 | BSM_Save.dispX = this:GetLeft(); |
||
121 | BSM_Save.dispY = this:GetBottom(); |
||
122 | end |
||
123 | |||
124 | --BSM_DisableAllIndividual: |
||
125 | -- Purpose - Hide all the individual meters components |
||
126 | -- Parameters - None |
||
127 | -- Returns - Nothing |
||
128 | function BSM_DisableAllIndividual() |
||
129 | getglobal(BSM_BARS_LABELS):Hide(); |
||
130 | getglobal(BSM_BARS):Hide(); |
||
131 | getglobal(BSM_DROPDOWNS):Hide(); |
||
132 | getglobal(BSM_DROPDOWNS_LABELS):Hide(); |
||
133 | end |
||
134 | --BSM_EnableAllIndividual: |
||
135 | -- Purpose - Show all the individual meters components that need to be |
||
136 | -- Parameters - None |
||
137 | -- Returns - Nothing |
||
138 | function BSM_EnableAllIndividual() |
||
139 | if BSM_Save.I.bars and BSM_Save.I.overlay then |
||
140 | getglobal(BSM_BARS):Show(); |
||
141 | end |
||
142 | if BSM_Save.I.showlabels and (BSM_Save.I.bars or BSM_Save.I.labels) and BSM_Save.I.overlay then |
||
143 | getglobal(BSM_BARS_LABELS):Show(); |
||
144 | end |
||
145 | if BSM_Save.I.dropdowns then |
||
146 | getglobal(BSM_DROPDOWNS):Show(); |
||
147 | if BSM_Save.I.showlabels then |
||
148 | getglobal(BSM_DROPDOWNS_LABELS):Show(); |
||
149 | end |
||
150 | end |
||
151 | end |
||
152 | |||
153 | --BSM_command: |
||
154 | -- Purpose - Show the Options frame for any "/bsm" command |
||
155 | -- Parameters - the message following "/bsm " |
||
156 | -- Returns - Nothing |
||
157 | local function BSM_command(msg) |
||
158 | msg = string.lower(msg); |
||
159 | |||
160 | if not getglobal("BSM_Options"):IsVisible() then |
||
161 | getglobal("BSM_Options"):Show(); |
||
162 | else |
||
163 | getglobal("BSM_Options"):Hide(); |
||
164 | end |
||
165 | end |
||
166 | |||
167 | --BSM_initCommands: |
||
168 | -- Purpose - Register the "/bsm" slash command |
||
169 | -- Parameters - None |
||
170 | -- Returns - Nothing |
||
171 | function BSM_initCommands() |
||
172 | SlashCmdList["BSMCOMMAND"] = BSM_command; |
||
173 | SLASH_BSMCOMMAND1 = "/bsm"; |
||
174 | end |
||
175 | |||
176 | --BSM_loadVariables: |
||
177 | -- Purpose - Initialize the save vairiables if they don't exist and hide/show appropriate things |
||
178 | -- Parameters - None |
||
179 | -- Returns - Nothing |
||
180 | function BSM_loadVariables() |
||
181 | --Register with myAddOns |
||
182 | if(myAddOnsFrame) then |
||
183 | myAddOnsList.BagStatusMeters = {name = "Bag Status Meters", |
||
184 | description = "Use bar/text overlays for bag status", |
||
185 | version = BSM_VERSION, |
||
186 | category = MYADDONS_CATEGORY_INVENTORY, |
||
187 | frame = BSM_FRAME, |
||
188 | optionsframe = "BSM_Options"}; |
||
189 | end |
||
190 | |||
191 | --If any of the key save elements does not exist, create a new save |
||
192 | if not BSM_Save or not BSM_Save.I or not BSM_Save.O then |
||
193 | --BSM_Save: the saved variable for everything |
||
194 | BSM_Save = { }; |
||
195 | --BSM_Save.I: the saved variables used for individual meters |
||
196 | BSM_Save.I = { }; |
||
197 | --BSM_Save.O: the saved variables used for the overall meter |
||
198 | BSM_Save.O = { }; |
||
199 | --BSM_Save.I.enable: enables/disables all of the individual meters |
||
200 | BSM_Save.I.enable = true; |
||
201 | --BSM_Save.I.overlay: enables/disables the individual meters displayed over the bag slots |
||
202 | BSM_Save.I.overlay = true; |
||
203 | --BSM_Save.I.bars: set the display mode for the overlay meters to include the bar |
||
204 | BSM_Save.I.bars = true; |
||
205 | --BSM_Save.I.bars: set the display mode for the overlay meters to only text |
||
206 | BSM_Save.I.labels = false; |
||
207 | --BSM_Save.I.dropdowns: enables/disables the dropdown meters from the overall meter |
||
208 | BSM_Save.I.dropdowns = false; |
||
209 | --BSM_Save.I.bindings: enables/disables the binding buttons next to the dropdown meters that open the bags |
||
210 | BSM_Save.I.bindings = true; |
||
211 | --BSM_Save.I.showlabels: enables/disables the use of any labels on the individual meters |
||
212 | BSM_Save.I.showlabels = true; |
||
213 | --BSM_Save.I.color: enables/disables color changing of the individual bars |
||
214 | BSM_Save.I.color = true; |
||
215 | --BSM_Save.I.totals: enables/disables displaying the total slots on the labels |
||
216 | BSM_Save.I.totals = true; |
||
217 | --BSM_Save.I.slots: determines whether to use free or used slots in the labels |
||
218 | BSM_Save.I.slots = BSM_SLOTS_FREE; |
||
219 | --BSM_Save.O.enable: enables/disables the entire overall meter |
||
220 | BSM_Save.O.enable = true; |
||
221 | --BSM_Save.O.title: enables/disables displaying the title over the overall meter |
||
222 | BSM_Save.O.title = true; |
||
223 | --BSM_Save.O.back: hides/shows the background and meter for the overall meter so there's only text |
||
224 | BSM_Save.O.back = true; |
||
225 | --BSM_Save.O.showlabels: enables/disables the use of the label on the overall meter |
||
226 | BSM_Save.O.showlabels = true; |
||
227 | --BSM_Save.O.color: enables/disables color changing of the overall bar |
||
228 | BSM_Save.O.color = true; |
||
229 | --BSM_Save.O.totals: enables/disables displaying the total slots on the label |
||
230 | BSM_Save.O.totals = true; |
||
231 | --BSM_Save.O.slots: determines whether to use free or used slots in the overall label |
||
232 | BSM_Save.O.slots = BSM_SLOTS_USED; |
||
233 | --BSM_Save.O.lock: locks/unlocks the overall meter from dragging |
||
234 | BSM_Save.O.lock = false; |
||
235 | --BSM_Save.dispX/dispY: the position of the overall meter relative to the bottom left of the screen |
||
236 | BSM_Save.dispX = GetScreenWidth()/2 + 150; |
||
237 | BSM_Save.dispY = 50; |
||
238 | --BSM_Save.notify: enables/disables notifications when bags are full |
||
239 | BSM_Save.notify = true; |
||
240 | --BSM_Save.optbutton: enables/disables displaying the options button next to the overall meter |
||
241 | BSM_Save.optbutton = true; |
||
242 | end |
||
243 | |||
244 | BSM_DisableAllIndividual(); |
||
245 | if BSM_Save.I.enable then |
||
246 | BSM_EnableAllIndividual(); |
||
247 | end |
||
248 | |||
249 | if not BSM_Save.I.bindings then |
||
250 | for i = 0, 4, 1 do |
||
251 | getglobal(BSM_DROPDOWNS..i.."Key"):Hide(); |
||
252 | end |
||
253 | else |
||
254 | end |
||
255 | |||
256 | if not BSM_Save.O.enable then |
||
257 | getglobal(BSM_FRAME):Hide(); |
||
258 | end |
||
259 | if not BSM_Save.O.showlabels then |
||
260 | getglobal("BSM_FrameText"):Hide(); |
||
261 | end |
||
262 | if not BSM_Save.O.title then |
||
263 | getglobal("BSM_FrameButtonLabel"):Hide(); |
||
264 | end |
||
265 | if not BSM_Save.optbutton then |
||
266 | getglobal("BSM_OptionsButton"):Hide(); |
||
267 | end |
||
268 | if not BSM_Save.O.back then |
||
269 | getglobal(BSM_FRAME.."BackAlpha"):Hide(); |
||
270 | getglobal(BSM_FRAME.."Border"):Hide(); |
||
271 | BSM_FrameStatus:Hide(); |
||
272 | end |
||
273 | |||
274 | --Set the position of the Overall Meter frame relative to the bottom left of the screen |
||
275 | getglobal(BSM_FRAME):ClearAllPoints(); |
||
276 | getglobal(BSM_FRAME):SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", BSM_Save.dispX, BSM_Save.dispY); |
||
277 | |||
278 | BSM_LOADED = true; |
||
279 | BSM_updateFreeSlots(); |
||
280 | end |
||
281 | |||
282 | --BSM_updateFreeSlots: |
||
283 | -- Purpose - Update the BSM_NumSlots and BSM_UsedSlots to accurately reflect the inventory |
||
284 | -- Also updates all meters that need to be updated |
||
285 | -- Parameters - None |
||
286 | -- Returns - Nothing |
||
287 | function BSM_updateFreeSlots() |
||
288 | --totalSlots: the number of slots in all bags |
||
289 | local totalSlots = 0; |
||
290 | --totalUsedSlots: the number of used slots in all bags |
||
291 | local totalUsedSlots = 0; |
||
292 | --slotsText: the text that is to be displayed on the meter labels |
||
293 | local slotsText = 0; |
||
294 | --isAmmo: true if the current bag is one of the recognized ammo bags |
||
295 | local isAmmo = false; |
||
296 | |||
297 | --Loop through for every bag |
||
298 | for bag = 0, 4, 1 do |
||
299 | --Save the number of total slots in the current bag to the global variable |
||
300 | BSM_NumSlots[bag+1] = GetContainerNumSlots(bag); |
||
301 | |||
302 | isAmmo = false; |
||
303 | |||
304 | --Check if the current bag is an ammo bag or can't get the bag name |
||
305 | if ( not GetBagName(bag) ) then |
||
306 | isAmmo = true; |
||
307 | else |
||
308 | for i = 1, table.getn( BSM_AMMO ), 1 do |
||
309 | if ( string.find( GetBagName(bag), BSM_AMMO[i] ) ) then |
||
310 | isAmmo = true; |
||
311 | break; |
||
312 | end |
||
313 | end |
||
314 | end |
||
315 | |||
316 | --If there is no bag in the current bag slot or it is an ammo bag, hide all of its meters and don't count it in the total |
||
317 | if (BSM_NumSlots[bag+1] == 0 or isAmmo) then |
||
318 | getglobal(BSM_BARS..bag):Hide(); |
||
319 | getglobal(BSM_BARS_LABELS..bag):Hide(); |
||
320 | getglobal(BSM_DROPDOWNS..bag):Hide(); |
||
321 | getglobal(BSM_DROPDOWNS_LABELS..bag):Hide(); |
||
322 | getglobal(BSM_DROPDOWNS_BARS..bag):Hide(); |
||
323 | BSM_BagFull[bag+1] = false; |
||
324 | else |
||
325 | totalSlots = totalSlots + BSM_NumSlots[bag+1]; |
||
326 | |||
327 | --Reset the used slots global variable and |
||
328 | --loop through every slot in the current bag and |
||
329 | --increment the variable if an item exists |
||
330 | BSM_UsedSlots[bag+1] = 0; |
||
331 | for slot = 1, BSM_NumSlots[bag+1], 1 do |
||
332 | if (GetContainerItemInfo(bag, slot)) then |
||
333 | BSM_UsedSlots[bag+1] = BSM_UsedSlots[bag+1] + 1; |
||
334 | totalUsedSlots = totalUsedSlots + 1; |
||
335 | end |
||
336 | end |
||
337 | |||
338 | --If free slots are used in the individual labels, subtract the used slots from the free slots and |
||
339 | --use that number in the slots text instead of used slots |
||
340 | if BSM_Save.I.slots == BSM_SLOTS_FREE then |
||
341 | slotsText = BSM_NumSlots[bag+1] - BSM_UsedSlots[bag+1]; |
||
342 | else |
||
343 | slotsText = BSM_UsedSlots[bag+1]; |
||
344 | end |
||
345 | --If the totals are shown in the individual labels, concatenate it onto the end of the text |
||
346 | if BSM_Save.I.totals then |
||
347 | slotsText = slotsText.."/"..BSM_NumSlots[bag+1]; |
||
348 | end |
||
349 | |||
350 | --Show the current bag text and reset the text color |
||
351 | getglobal(BSM_BARS_LABELS..bag):Show(); |
||
352 | getglobal(BSM_BARS_LABELS..bag):SetText(slotsText); |
||
353 | getglobal(BSM_BARS_LABELS..bag):SetTextColor(1.0, 1.0, 1.0, 1.0); |
||
354 | getglobal(BSM_DROPDOWNS_LABELS..bag):Show(); |
||
355 | getglobal(BSM_DROPDOWNS_LABELS..bag):SetText(slotsText); |
||
356 | |||
357 | --status: a temporary variable to hold the current meter being updated |
||
358 | local status; |
||
359 | --If the bars are shown and the overlay is enabled, update the meter/label over the current bag |
||
360 | if BSM_Save.I.bars and BSM_Save.I.overlay then |
||
361 | --Set status to the meter that is over the current bag |
||
362 | status = getglobal(BSM_BARS..bag); |
||
363 | --Set the meter's min, max, and current values accordingly |
||
364 | status:SetMinMaxValues(0, BSM_NumSlots[bag+1]); |
||
365 | status:SetValue(BSM_UsedSlots[bag+1]); |
||
366 | --If color is enabled, color the bar according to the ratio of used slots to total slots |
||
367 | --Otherwise make it a gray color |
||
368 | if BSM_Save.I.color then |
||
369 | status:SetStatusBarColor(BSM_GetColor(BSM_NumSlots[bag+1] - BSM_UsedSlots[bag+1], BSM_NumSlots[bag+1], 0.6)); |
||
370 | else |
||
371 | status:SetStatusBarColor(0.5, 0.5, 0.5, 0.6); |
||
372 | end |
||
373 | status:Show(); |
||
374 | end |
||
375 | |||
376 | --If the overlay display is set to just labels and the overlay is enabled, update only the label |
||
377 | if BSM_Save.I.labels and BSM_Save.I.overlay then |
||
378 | --If color is disabled or the bag is less than half full, keep the label white |
||
379 | --Otherwise color the label according to the ratio of used slots to total slots |
||
380 | if not BSM_Save.I.color then |
||
381 | getglobal(BSM_BARS_LABELS..bag):SetTextColor(1.0, 1.0, 1.0, 1.0); |
||
382 | elseif BSM_UsedSlots[bag+1] / BSM_NumSlots[bag+1] >= 0.5 then |
||
383 | getglobal(BSM_BARS_LABELS..bag):SetTextColor(BSM_GetColor(BSM_NumSlots[bag+1] - BSM_UsedSlots[bag+1], BSM_NumSlots[bag+1], 1.0)); |
||
384 | else |
||
385 | getglobal(BSM_BARS_LABELS..bag):SetTextColor(1.0, 1.0, 1.0, 1.0); |
||
386 | end |
||
387 | end |
||
388 | |||
389 | --If the dropdown meters are enabled, update them |
||
390 | if BSM_Save.I.dropdowns then |
||
391 | --Set status to the dropdown meter that is for the current bag |
||
392 | status = getglobal(BSM_DROPDOWNS_BARS..bag); |
||
393 | --Set the meter's min, max, and current values accordingly |
||
394 | status:SetMinMaxValues(0, BSM_NumSlots[bag+1]); |
||
395 | status:SetValue(BSM_UsedSlots[bag+1]); |
||
396 | --If color is enabled, color the bar according to the ratio of used slots to total slots |
||
397 | --Otherwise make it a gray color |
||
398 | if BSM_Save.I.color then |
||
399 | status:SetStatusBarColor(BSM_GetColor(BSM_NumSlots[bag+1] - BSM_UsedSlots[bag+1], BSM_NumSlots[bag+1], 1.0)); |
||
400 | else |
||
401 | status:SetStatusBarColor(0.5, 0.5, 0.5, 1.0); |
||
402 | end |
||
403 | status:Show(); |
||
404 | getglobal(BSM_DROPDOWNS..bag):Show() |
||
405 | end |
||
406 | |||
407 | --If the current bag is full and notifications are enabled, check if a notification should be given |
||
408 | if BSM_UsedSlots[bag+1] == BSM_NumSlots[bag+1] and BSM_Save.notify then |
||
409 | --If the bag was not full last check, give a notification and |
||
410 | --set the full bag variable to true |
||
411 | --Otherwise keep the full bag variable false |
||
412 | if not BSM_BagFull[bag+1] then |
||
413 | if bag == 0 then |
||
414 | UIErrorsFrame:AddMessage(BSM_BACKPACK..BSM_FULL, 1.0, 0.1, 1.0, 1.0, UIERRORS_HOLD_TIME); |
||
415 | DEFAULT_CHAT_FRAME:AddMessage(BSM_MSG.."|cffff0fff"..BSM_BACKPACK..BSM_FULL.."|r"); |
||
416 | else |
||
417 | UIErrorsFrame:AddMessage(BSM_BAG..bag..BSM_FULL, 1.0, 0.1, 1.0, 1.0, UIERRORS_HOLD_TIME); |
||
418 | DEFAULT_CHAT_FRAME:AddMessage(BSM_MSG.."|cffff0fff"..BSM_BAG..bag..BSM_FULL.."|r"); |
||
419 | end |
||
420 | BSM_BagFull[bag+1] = true; |
||
421 | end |
||
422 | else |
||
423 | BSM_BagFull[bag+1] = false; |
||
424 | end |
||
425 | end |
||
426 | end |
||
427 | |||
428 | --Update the bindings for all of the dropdown meter buttons |
||
429 | getglobal(BSM_DROPDOWNS.."0Key"):SetText(GetBindingText(GetBindingKey("TOGGLEBACKPACK"), "KEY_")); |
||
430 | getglobal(BSM_DROPDOWNS.."4Key"):SetText(GetBindingText(GetBindingKey("TOGGLEBAG1"), "KEY_")); |
||
431 | getglobal(BSM_DROPDOWNS.."3Key"):SetText(GetBindingText(GetBindingKey("TOGGLEBAG2"), "KEY_")); |
||
432 | getglobal(BSM_DROPDOWNS.."2Key"):SetText(GetBindingText(GetBindingKey("TOGGLEBAG3"), "KEY_")); |
||
433 | getglobal(BSM_DROPDOWNS.."1Key"):SetText(GetBindingText(GetBindingKey("TOGGLEBAG4"), "KEY_")); |
||
434 | |||
435 | --If the overall meter is disabled, then everything else can be ignored |
||
436 | if not BSM_Save.O.enable then return; end |
||
437 | |||
438 | --totalFreeSlots: free slots in all of the bags |
||
439 | local totalFreeSlots = totalSlots - totalUsedSlots; |
||
440 | |||
441 | --If free slots are used in the overall label, use that number in the slots text instead of used slots |
||
442 | if BSM_Save.O.slots == BSM_SLOTS_FREE then |
||
443 | slotsText = totalFreeSlots; |
||
444 | else |
||
445 | slotsText = totalUsedSlots; |
||
446 | end |
||
447 | --If the totals are shown in the overall label, concatenate it onto the end of the text |
||
448 | if BSM_Save.O.totals then |
||
449 | slotsText = slotsText.."/"..totalSlots; |
||
450 | end |
||
451 | |||
452 | --Update the text and |
||
453 | --min, max, and current values of the overall bar |
||
454 | BSM_FrameText:SetText(slotsText); |
||
455 | BSM_FrameStatus:SetMinMaxValues(0, totalSlots); |
||
456 | BSM_FrameStatus:SetValue(totalUsedSlots); |
||
457 | --If color is enabled, color the bar according to the ratio of used slots to total slots |
||
458 | --Otherwise make it a gray color |
||
459 | if BSM_Save.O.color then |
||
460 | BSM_FrameStatus:SetStatusBarColor(BSM_GetColor(totalFreeSlots, totalSlots, 1.0)); |
||
461 | else |
||
462 | BSM_FrameStatus:SetStatusBarColor(0.5, 0.5, 0.5, 1.0); |
||
463 | end |
||
464 | |||
465 | --Update the bank bars if the Bank frame is open |
||
466 | --[[if getglobal("BSM_Bank_Bars"):IsVisible() then |
||
467 | BSM_updateBankBags(); |
||
468 | end]] |
||
469 | end |
||
470 | |||
471 | --BSM_GetColor: |
||
472 | -- Purpose - Get the appropriate color for the bar being updated |
||
473 | -- Parameters - freeSlots: free slots in the bag |
||
474 | -- totalSlots: number of slots in the bag |
||
475 | -- alpha: desired opacity of the color |
||
476 | -- Returns - Color for the bar (red, green, blue, alpha) |
||
477 | function BSM_GetColor(freeSlots, totalSlots, alpha) |
||
478 | local pct = freeSlots / totalSlots; |
||
479 | local r, g; |
||
480 | r = 1.0; |
||
481 | g = 1.0; |
||
482 | if pct < 0.5 then |
||
483 | --r = 1.0; |
||
484 | g = pct * 2; |
||
485 | elseif pct > 0.5 then |
||
486 | r = 1.0 - (pct-0.5) * 2; |
||
487 | --g = 1.0; |
||
488 | --elseif pct == 0.5 then |
||
489 | --Do nothing, both already 1.0 |
||
490 | end |
||
491 | |||
492 | return r, g, 0.0, alpha; |
||
493 | end |
||
494 | |||
495 | |||
496 | |||
497 | --BSM_updateBankBags: |
||
498 | -- Purpose - Update the bank bars when the bank frame is open |
||
499 | -- Parameters - None |
||
500 | -- Returns - Nothing |
||
501 | function BSM_updateBankBags() |
||
502 | --num: number of slots in the current bank bag |
||
503 | local num = 0; |
||
504 | --used: number of used slots in the current bank bag |
||
505 | local used = 0; |
||
506 | --slotsText: the text that is to be displayed on the meter labels |
||
507 | local slotsText = 0; |
||
508 | --status: the current bar being updated |
||
509 | local status; |
||
510 | |||
511 | --Loop through for every bank bag |
||
512 | for bag = 5, 10, 1 do |
||
513 | --set status to the current bar and get the number of slots in the current bank bag |
||
514 | status = getglobal(BSM_BANK..(bag-4)); |
||
515 | num = GetContainerNumSlots(bag); |
||
516 | --if there is no bag in the current bank bag slot, then hide the bar |
||
517 | if num == 0 then |
||
518 | status:Hide(); |
||
519 | else |
||
520 | --Reset the used slots and |
||
521 | --loop through every slot in the current bank bag and |
||
522 | --increment the variable if an item exists |
||
523 | used = 0; |
||
524 | for slot = 1, num, 1 do |
||
525 | if GetContainerItemInfo(bag, slot) then |
||
526 | used = used + 1; |
||
527 | end |
||
528 | end |
||
529 | |||
530 | --[[--bar: the bar to the current bank bag |
||
531 | local bar = getglobal(status:GetName().."Bar"); |
||
532 | --Set the meter's min, max, and current values accordingly |
||
533 | bar:SetMinMaxValues(0, num); |
||
534 | bar:SetValue(used); |
||
535 | --If color is enabled, color the bar according to the ratio of used slots to total slots |
||
536 | --Otherwise make it a gray color |
||
537 | if BSM_Save.I.color then |
||
538 | bar:SetStatusBarColor(BSM_GetColor(num - used, num, 0.6)); |
||
539 | else |
||
540 | bar:SetStatusBarColor(0.5, 0.5, 0.5, 0.6); |
||
541 | end]] |
||
542 | |||
543 | if BSM_Save.I.slots == BSM_SLOTS_FREE then |
||
544 | slotsText = num - used; |
||
545 | else |
||
546 | slotsText = used; |
||
547 | end |
||
548 | |||
549 | if BSM_Save.I.totals then |
||
550 | slotsText = slotsText.."/"..num; |
||
551 | end |
||
552 | |||
553 | status:Show(); |
||
554 | getglobal(status:GetName().."Label"):SetText(slotsText); |
||
555 | end |
||
556 | end |
||
557 | end |
||
558 | |||
559 | --BSM_DividerOnShow: |
||
560 | -- Purpose - Set the text of a header depending on its name |
||
561 | -- Parameters - h: the header that's being shown |
||
562 | -- Returns - Nothing |
||
563 | function BSM_DividerOnShow(h) |
||
564 | local name = h:GetName(); |
||
565 | |||
566 | if name == "BSM_Divider_Individual" then |
||
567 | getglobal(name.."HeaderText"):SetText(BSM_OPTIONS_INDIVID); |
||
568 | getglobal(name.."Header"):SetWidth(250); |
||
569 | elseif name == "BSM_Divider_Overall" then |
||
570 | getglobal(name.."HeaderText"):SetText(BSM_OPTIONS_OVERALL); |
||
571 | getglobal(name.."Header"):SetWidth(220); |
||
572 | elseif name == "BSM_Divider_Global" then |
||
573 | getglobal(name.."HeaderText"):SetText(BSM_OPTIONS_GLOBAL); |
||
574 | getglobal(name.."Header"):SetWidth(128); |
||
575 | end |
||
576 | end |
||
577 | |||
578 | --BSM_EnableIndividualChecks: |
||
579 | -- Purpose - Enables all the check boxes having to do with individual meters |
||
580 | -- Parameters - None |
||
581 | -- Returns - Nothing |
||
582 | function BSM_EnableIndividualChecks() |
||
583 | getglobal("BSM_Check_Overlay"):Enable(); |
||
584 | getglobal("BSM_Check_Bars"):Enable(); |
||
585 | getglobal("BSM_Check_Labels"):Enable(); |
||
586 | getglobal("BSM_Check_Dropdown"):Enable(); |
||
587 | getglobal("BSM_Check_IndvLabels"):Enable(); |
||
588 | getglobal("BSM_Check_IndvColor"):Enable(); |
||
589 | getglobal("BSM_Check_IndvTotals"):Enable(); |
||
590 | getglobal("BSM_Check_IndvSlots"):Enable(); |
||
591 | getglobal("BSM_Check_Bindings"):Enable(); |
||
592 | end |
||
593 | |||
594 | --BSM_DisableIndividualChecks: |
||
595 | -- Purpose - Disables all the check boxes having to do with individual meters |
||
596 | -- Parameters - None |
||
597 | -- Returns - Nothing |
||
598 | function BSM_DisableIndividualChecks() |
||
599 | getglobal("BSM_Check_Overlay"):Disable(); |
||
600 | getglobal("BSM_Check_Bars"):Disable(); |
||
601 | getglobal("BSM_Check_Labels"):Disable(); |
||
602 | getglobal("BSM_Check_Dropdown"):Disable(); |
||
603 | getglobal("BSM_Check_IndvLabels"):Disable(); |
||
604 | getglobal("BSM_Check_IndvColor"):Disable(); |
||
605 | getglobal("BSM_Check_IndvTotals"):Disable(); |
||
606 | getglobal("BSM_Check_IndvSlots"):Disable(); |
||
607 | getglobal("BSM_Check_Bindings"):Disable(); |
||
608 | end |
||
609 | |||
610 | --BSM_CheckOnShow: |
||
611 | -- Purpose - Set the text of a check box depending on its name |
||
612 | -- Also makes the necessary checks for enabling/disabling child check boxes |
||
613 | -- Parameters - b: the check box that's being shown |
||
614 | -- Returns - Nothing |
||
615 | function BSM_CheckOnShow(b) |
||
616 | local name = b:GetName(); |
||
617 | |||
618 | if name == "BSM_Check_Individual" then |
||
619 | getglobal(name.."Text"):SetText(BSM_TEXT_INDIVIDUAL); |
||
620 | if BSM_Save.I.enable then |
||
621 | b:SetChecked(1); |
||
622 | else |
||
623 | b:SetChecked(0); |
||
624 | end |
||
625 | if b:GetChecked() == 1 then |
||
626 | BSM_EnableIndividualChecks(); |
||
627 | else |
||
628 | BSM_DisableIndividualChecks(); |
||
629 | end |
||
630 | elseif name == "BSM_Check_Overlay" then |
||
631 | getglobal(name.."Text"):SetText(BSM_TEXT_OVERLAY); |
||
632 | if BSM_Save.I.overlay then |
||
633 | b:SetChecked(1); |
||
634 | else |
||
635 | b:SetChecked(0); |
||
636 | end |
||
637 | if b:GetChecked() == 1 and BSM_Save.I.enable then |
||
638 | getglobal("BSM_Check_Bars"):Enable(); |
||
639 | getglobal("BSM_Check_Labels"):Enable(); |
||
640 | else |
||
641 | getglobal("BSM_Check_Bars"):Disable(); |
||
642 | getglobal("BSM_Check_Labels"):Disable(); |
||
643 | end |
||
644 | elseif name == "BSM_Check_Bars" then |
||
645 | getglobal(name.."Text"):SetText(BSM_TEXT_BAR); |
||
646 | if BSM_Save.I.bars then |
||
647 | b:SetChecked(1); |
||
648 | else |
||
649 | b:SetChecked(0); |
||
650 | end |
||
651 | elseif name == "BSM_Check_Labels" then |
||
652 | getglobal(name.."Text"):SetText(BSM_TEXT_LABELSTAT); |
||
653 | if BSM_Save.I.labels then |
||
654 | b:SetChecked(1); |
||
655 | else |
||
656 | b:SetChecked(0); |
||
657 | end |
||
658 | elseif name == "BSM_Check_Dropdown" then |
||
659 | getglobal(name.."Text"):SetText(BSM_TEXT_DROPDOWN); |
||
660 | if BSM_Save.I.dropdowns then |
||
661 | b:SetChecked(1); |
||
662 | else |
||
663 | b:SetChecked(0); |
||
664 | end |
||
665 | if b:GetChecked() == 1 and BSM_Save.I.enable then |
||
666 | getglobal("BSM_Check_Bindings"):Enable(); |
||
667 | else |
||
668 | getglobal("BSM_Check_Bindings"):Disable(); |
||
669 | end |
||
670 | elseif name == "BSM_Check_Bindings" then |
||
671 | getglobal(name.."Text"):SetText(BSM_TEXT_BINDINGS); |
||
672 | if BSM_Save.I.bindings then |
||
673 | b:SetChecked(1); |
||
674 | else |
||
675 | b:SetChecked(0); |
||
676 | end |
||
677 | elseif name == "BSM_Check_IndvLabels" then |
||
678 | getglobal(name.."Text"):SetText(BSM_TEXT_LABELS); |
||
679 | if BSM_Save.I.showlabels then |
||
680 | b:SetChecked(1); |
||
681 | else |
||
682 | b:SetChecked(0); |
||
683 | end |
||
684 | elseif name == "BSM_Check_IndvColor" then |
||
685 | getglobal(name.."Text"):SetText(BSM_TEXT_COLOR); |
||
686 | if BSM_Save.I.color then |
||
687 | b:SetChecked(1); |
||
688 | else |
||
689 | b:SetChecked(0); |
||
690 | end |
||
691 | elseif name == "BSM_Check_IndvTotals" then |
||
692 | getglobal(name.."Text"):SetText(BSM_TEXT_TOTALS); |
||
693 | if BSM_Save.I.totals then |
||
694 | b:SetChecked(1); |
||
695 | else |
||
696 | b:SetChecked(0); |
||
697 | end |
||
698 | elseif name == "BSM_Check_IndvSlots" then |
||
699 | getglobal(name.."Text"):SetText(BSM_TEXT_SLOTS); |
||
700 | if BSM_Save.I.slots == BSM_SLOTS_FREE then |
||
701 | b:SetChecked(1); |
||
702 | else |
||
703 | b:SetChecked(0); |
||
704 | end |
||
705 | |||
706 | elseif name == "BSM_Check_Overall" then |
||
707 | getglobal(name.."Text"):SetText(BSM_TEXT_OVERALL); |
||
708 | if BSM_Save.O.enable then |
||
709 | b:SetChecked(1); |
||
710 | else |
||
711 | b:SetChecked(0); |
||
712 | end |
||
713 | if b:GetChecked() == 1 then |
||
714 | getglobal("BSM_Check_Title"):Enable(); |
||
715 | getglobal("BSM_Check_Back"):Enable(); |
||
716 | getglobal("BSM_Check_OverallLabels"):Enable(); |
||
717 | getglobal("BSM_Check_OverallColor"):Enable(); |
||
718 | getglobal("BSM_Check_OverallTotals"):Enable(); |
||
719 | getglobal("BSM_Check_OverallSlots"):Enable(); |
||
720 | else |
||
721 | getglobal("BSM_Check_Title"):Disable(); |
||
722 | getglobal("BSM_Check_Back"):Disable(); |
||
723 | getglobal("BSM_Check_OverallLabels"):Disable(); |
||
724 | getglobal("BSM_Check_OverallColor"):Disable(); |
||
725 | getglobal("BSM_Check_OverallTotals"):Disable(); |
||
726 | getglobal("BSM_Check_OverallSlots"):Disable(); |
||
727 | end |
||
728 | elseif name == "BSM_Check_Title" then |
||
729 | getglobal(name.."Text"):SetText(BSM_TEXT_TITLE); |
||
730 | if BSM_Save.O.title then |
||
731 | b:SetChecked(1); |
||
732 | else |
||
733 | b:SetChecked(0); |
||
734 | end |
||
735 | elseif name == "BSM_Check_Back" then |
||
736 | getglobal(name.."Text"):SetText(BSM_TEXT_BACK); |
||
737 | if BSM_Save.O.back then |
||
738 | b:SetChecked(1); |
||
739 | else |
||
740 | b:SetChecked(0); |
||
741 | end |
||
742 | elseif name == "BSM_Check_OverallLabels" then |
||
743 | getglobal(name.."Text"):SetText(BSM_TEXT_LABELS); |
||
744 | if BSM_Save.O.showlabels then |
||
745 | b:SetChecked(1); |
||
746 | else |
||
747 | b:SetChecked(0); |
||
748 | end |
||
749 | elseif name == "BSM_Check_OverallColor" then |
||
750 | getglobal(name.."Text"):SetText(BSM_TEXT_COLOR); |
||
751 | if BSM_Save.O.color then |
||
752 | b:SetChecked(1); |
||
753 | else |
||
754 | b:SetChecked(0); |
||
755 | end |
||
756 | elseif name == "BSM_Check_OverallTotals" then |
||
757 | getglobal(name.."Text"):SetText(BSM_TEXT_TOTALS); |
||
758 | if BSM_Save.O.totals then |
||
759 | b:SetChecked(1); |
||
760 | else |
||
761 | b:SetChecked(0); |
||
762 | end |
||
763 | elseif name == "BSM_Check_OverallSlots" then |
||
764 | getglobal(name.."Text"):SetText(BSM_TEXT_SLOTS); |
||
765 | if BSM_Save.O.slots == BSM_SLOTS_FREE then |
||
766 | b:SetChecked(1); |
||
767 | else |
||
768 | b:SetChecked(0); |
||
769 | end |
||
770 | elseif name == "BSM_Check_OverallLock" then |
||
771 | getglobal(name.."Text"):SetText(BSM_TEXT_OVERALLLOCK); |
||
772 | if BSM_Save.O.lock then |
||
773 | b:SetChecked(1); |
||
774 | else |
||
775 | b:SetChecked(0); |
||
776 | end |
||
777 | elseif name == "BSM_Options_Position" then |
||
778 | getglobal(name.."Text"):SetText(BSM_TEXT_OVERALLPOS); |
||
779 | |||
780 | elseif name == "BSM_Check_Notify" then |
||
781 | getglobal(name.."Text"):SetText(BSM_TEXT_NOTIFY); |
||
782 | if BSM_Save.notify then |
||
783 | b:SetChecked(1); |
||
784 | else |
||
785 | b:SetChecked(0); |
||
786 | end |
||
787 | elseif name == "BSM_Check_OptionsButton" then |
||
788 | getglobal(name.."Text"):SetText(BSM_TEXT_OPTBUTTON); |
||
789 | if BSM_Save.optbutton then |
||
790 | b:SetChecked(1); |
||
791 | else |
||
792 | b:SetChecked(0); |
||
793 | end |
||
794 | end |
||
795 | end |
||
796 | |||
797 | --BSM_Chk_Individual: |
||
798 | -- Purpose - Enables/Disables all individual meter elements in options and in UI when the "Enable Individual" option is clicked |
||
799 | -- Parameters - b: the "Enable Individual" check box |
||
800 | -- Returns - Nothing |
||
801 | function BSM_Chk_Individual(b) |
||
802 | if b:GetChecked() == 1 then |
||
803 | BSM_EnableIndividualChecks(); |
||
804 | BSM_Save.I.enable = true; |
||
805 | BSM_EnableAllIndividual(); |
||
806 | BSM_updateFreeSlots(); |
||
807 | else |
||
808 | BSM_DisableIndividualChecks(); |
||
809 | BSM_Save.I.enable = false; |
||
810 | BSM_DisableAllIndividual(); |
||
811 | end |
||
812 | end |
||
813 | |||
814 | --BSM_Chk_Overall: |
||
815 | -- Purpose - Enables/Disables all overall meter elements in options and in UI when the "Enable Overall" option is clicked |
||
816 | -- Parameters - b: the "Enable Overall" check box |
||
817 | -- Returns - Nothing |
||
818 | function BSM_Chk_Overall(b) |
||
819 | if b:GetChecked() == 1 then |
||
820 | getglobal("BSM_Check_Title"):Enable(); |
||
821 | getglobal("BSM_Check_Back"):Enable(); |
||
822 | getglobal("BSM_Check_OverallLabels"):Enable(); |
||
823 | getglobal("BSM_Check_OverallColor"):Enable(); |
||
824 | getglobal("BSM_Check_OverallTotals"):Enable(); |
||
825 | getglobal("BSM_Check_OverallSlots"):Enable(); |
||
826 | getglobal("BSM_Check_OverallLock"):Enable(); |
||
827 | getglobal("BSM_Options_PositionSet"):Enable(); |
||
828 | BSM_Save.O.enable = true; |
||
829 | getglobal(BSM_FRAME):Show(); |
||
830 | BSM_updateFreeSlots(); |
||
831 | else |
||
832 | getglobal("BSM_Check_Title"):Disable(); |
||
833 | getglobal("BSM_Check_Back"):Disable(); |
||
834 | getglobal("BSM_Check_OverallLabels"):Disable(); |
||
835 | getglobal("BSM_Check_OverallColor"):Disable(); |
||
836 | getglobal("BSM_Check_OverallTotals"):Disable(); |
||
837 | getglobal("BSM_Check_OverallSlots"):Disable(); |
||
838 | getglobal("BSM_Check_OverallLock"):Disable(); |
||
839 | getglobal("BSM_Options_PositionSet"):Disable(); |
||
840 | BSM_Save.O.enable = false; |
||
841 | getglobal(BSM_FRAME):Hide(); |
||
842 | end |
||
843 | end |
||
844 | |||
845 | --BSM_CheckOnClick: |
||
846 | -- Purpose - Makes the necessary checks for enabling/disabling child check boxes and sets necessary variables |
||
847 | -- Parameters - b: the check box that's being clicked |
||
848 | -- Returns - Nothing |
||
849 | function BSM_CheckOnClick(b) |
||
850 | local name = b:GetName(); |
||
851 | |||
852 | if name == "BSM_Check_Individual" then |
||
853 | BSM_Chk_Individual(b); |
||
854 | elseif name == "BSM_Check_Overlay" then |
||
855 | if b:GetChecked() == 1 then |
||
856 | getglobal("BSM_Check_Bars"):Enable(); |
||
857 | getglobal("BSM_Check_Labels"):Enable(); |
||
858 | BSM_Save.I.overlay = true; |
||
859 | --if BSM_Save.I.enabled then |
||
860 | if BSM_Save.I.bars then |
||
861 | getglobal(BSM_BARS):Show(); |
||
862 | end |
||
863 | if BSM_Save.I.showlabels and (BSM_Save.I.bars or BSM_Save.I.labels) then |
||
864 | getglobal(BSM_BARS_LABELS):Show(); |
||
865 | end |
||
866 | BSM_updateFreeSlots(); |
||
867 | --end |
||
868 | else |
||
869 | getglobal("BSM_Check_Bars"):Disable(); |
||
870 | getglobal("BSM_Check_Labels"):Disable(); |
||
871 | BSM_Save.I.overlay = false; |
||
872 | getglobal(BSM_BARS_LABELS):Hide(); |
||
873 | getglobal(BSM_BARS):Hide(); |
||
874 | end |
||
875 | elseif name == "BSM_Check_Bars" then |
||
876 | b:SetChecked(1); |
||
877 | getglobal("BSM_Check_Labels"):SetChecked(0); |
||
878 | BSM_Save.I.bars = true; |
||
879 | BSM_Save.I.labels = false; |
||
880 | --if BSM_Save.I.enabled then |
||
881 | if BSM_Save.I.showlabels then |
||
882 | getglobal(BSM_BARS_LABELS):Show(); |
||
883 | end |
||
884 | getglobal(BSM_BARS):Show(); |
||
885 | BSM_updateFreeSlots(); |
||
886 | --end |
||
887 | elseif name == "BSM_Check_Labels" then |
||
888 | b:SetChecked(1); |
||
889 | getglobal("BSM_Check_Bars"):SetChecked(0); |
||
890 | BSM_Save.I.labels = true; |
||
891 | BSM_Save.I.bars = false; |
||
892 | getglobal(BSM_BARS):Hide(); |
||
893 | --if BSM_Save.I.enabled then |
||
894 | if BSM_Save.I.showlabels then |
||
895 | getglobal(BSM_BARS_LABELS):Show(); |
||
896 | BSM_updateFreeSlots(); |
||
897 | end |
||
898 | --end |
||
899 | elseif name == "BSM_Check_Dropdown" then |
||
900 | if b:GetChecked() == 1 then |
||
901 | getglobal("BSM_Check_Bindings"):Enable(); |
||
902 | BSM_Save.I.dropdowns = true; |
||
903 | --if BSM_Save.I.enabled then |
||
904 | getglobal(BSM_DROPDOWNS):Show(); |
||
905 | if BSM_Save.I.showlabels then |
||
906 | getglobal(BSM_DROPDOWNS_LABELS):Show(); |
||
907 | end |
||
908 | BSM_updateFreeSlots(); |
||
909 | --end |
||
910 | else |
||
911 | getglobal("BSM_Check_Bindings"):Disable(); |
||
912 | BSM_Save.I.dropdowns = false; |
||
913 | getglobal(BSM_DROPDOWNS):Hide(); |
||
914 | getglobal(BSM_DROPDOWNS_LABELS):Hide(); |
||
915 | end |
||
916 | elseif name == "BSM_Check_Bindings" then |
||
917 | if b:GetChecked() == 1 then |
||
918 | BSM_Save.I.bindings = true; |
||
919 | --if BSM_Save.I.enabled then |
||
920 | if BSM_Save.I.bindings then |
||
921 | for i = 0, 4, 1 do |
||
922 | getglobal(BSM_DROPDOWNS..i.."Key"):Show(); |
||
923 | end |
||
924 | end |
||
925 | --end |
||
926 | else |
||
927 | BSM_Save.I.bindings = false; |
||
928 | for i = 0, 4, 1 do |
||
929 | getglobal(BSM_DROPDOWNS..i.."Key"):Hide(); |
||
930 | end |
||
931 | end |
||
932 | elseif name == "BSM_Check_IndvLabels" then |
||
933 | if b:GetChecked() == 1 then |
||
934 | BSM_Save.I.showlabels = true; |
||
935 | --if BSM_Save.I.enabled then |
||
936 | if (BSM_Save.I.bars or BSM_Save.I.labels) and BSM_Save.I.overlay then |
||
937 | getglobal(BSM_BARS_LABELS):Show(); |
||
938 | end |
||
939 | getglobal(BSM_DROPDOWNS_LABELS):Show(); |
||
940 | BSM_updateFreeSlots(); |
||
941 | --end |
||
942 | else |
||
943 | BSM_Save.I.showlabels = false; |
||
944 | getglobal(BSM_BARS_LABELS):Hide(); |
||
945 | getglobal(BSM_DROPDOWNS_LABELS):Hide(); |
||
946 | end |
||
947 | elseif name == "BSM_Check_IndvColor" then |
||
948 | if b:GetChecked() == 1 then |
||
949 | BSM_Save.I.color = true; |
||
950 | else |
||
951 | BSM_Save.I.color = false; |
||
952 | end |
||
953 | BSM_updateFreeSlots(); |
||
954 | elseif name == "BSM_Check_IndvTotals" then |
||
955 | if b:GetChecked() == 1 then |
||
956 | BSM_Save.I.totals = true; |
||
957 | else |
||
958 | BSM_Save.I.totals = false; |
||
959 | end |
||
960 | BSM_updateFreeSlots(); |
||
961 | elseif name == "BSM_Check_IndvSlots" then |
||
962 | if b:GetChecked() == 1 then |
||
963 | BSM_Save.I.slots = BSM_SLOTS_FREE; |
||
964 | else |
||
965 | BSM_Save.I.slots = BSM_SLOTS_USED; |
||
966 | end |
||
967 | BSM_updateFreeSlots(); |
||
968 | |||
969 | elseif name == "BSM_Check_Overall" then |
||
970 | BSM_Chk_Overall(b); |
||
971 | elseif name == "BSM_Check_Title" then |
||
972 | if b:GetChecked() == 1 then |
||
973 | BSM_Save.O.title = true; |
||
974 | --if BSM_Save.O.enabled then |
||
975 | getglobal("BSM_FrameButtonLabel"):Show(); |
||
976 | --end |
||
977 | else |
||
978 | BSM_Save.O.title = false; |
||
979 | getglobal("BSM_FrameButtonLabel"):Hide(); |
||
980 | end |
||
981 | elseif name == "BSM_Check_Back" then |
||
982 | if b:GetChecked() == 1 then |
||
983 | BSM_Save.O.back = true; |
||
984 | --if BSM_Save.O.enabled then |
||
985 | getglobal(BSM_FRAME.."BackAlpha"):Show(); |
||
986 | getglobal(BSM_FRAME.."Border"):Show(); |
||
987 | BSM_FrameStatus:Show(); |
||
988 | --end |
||
989 | else |
||
990 | BSM_Save.O.back = false; |
||
991 | getglobal(BSM_FRAME.."BackAlpha"):Hide(); |
||
992 | getglobal(BSM_FRAME.."Border"):Hide(); |
||
993 | BSM_FrameStatus:Hide(); |
||
994 | end |
||
995 | elseif name == "BSM_Check_OverallLabels" then |
||
996 | if b:GetChecked() == 1 then |
||
997 | BSM_Save.O.showlabels = true; |
||
998 | --if BSM_Save.O.enabled then |
||
999 | getglobal("BSM_FrameText"):Show(); |
||
1000 | BSM_updateFreeSlots(); |
||
1001 | --end |
||
1002 | else |
||
1003 | BSM_Save.O.showlabels = false; |
||
1004 | getglobal("BSM_FrameText"):Hide(); |
||
1005 | end |
||
1006 | elseif name == "BSM_Check_OverallColor" then |
||
1007 | if b:GetChecked() == 1 then |
||
1008 | BSM_Save.O.color = true; |
||
1009 | else |
||
1010 | BSM_Save.O.color = false; |
||
1011 | end |
||
1012 | BSM_updateFreeSlots(); |
||
1013 | elseif name == "BSM_Check_OverallTotals" then |
||
1014 | if b:GetChecked() == 1 then |
||
1015 | BSM_Save.O.totals = true; |
||
1016 | else |
||
1017 | BSM_Save.O.totals = false; |
||
1018 | end |
||
1019 | BSM_updateFreeSlots(); |
||
1020 | elseif name == "BSM_Check_OverallSlots" then |
||
1021 | if b:GetChecked() == 1 then |
||
1022 | BSM_Save.O.slots = BSM_SLOTS_FREE; |
||
1023 | else |
||
1024 | BSM_Save.O.slots = BSM_SLOTS_USED; |
||
1025 | end |
||
1026 | BSM_updateFreeSlots(); |
||
1027 | elseif name == "BSM_Check_OverallLock" then |
||
1028 | if b:GetChecked() == 1 then |
||
1029 | BSM_Save.O.lock = true; |
||
1030 | else |
||
1031 | BSM_Save.O.lock = false; |
||
1032 | end |
||
1033 | |||
1034 | elseif name == "BSM_Check_Notify" then |
||
1035 | if b:GetChecked() == 1 then |
||
1036 | BSM_Save.notify = true; |
||
1037 | else |
||
1038 | BSM_Save.notify = false; |
||
1039 | end |
||
1040 | elseif name == "BSM_Check_OptionsButton" then |
||
1041 | if b:GetChecked() == 1 then |
||
1042 | BSM_Save.optbutton = true; |
||
1043 | getglobal("BSM_OptionsButton"):Show(); |
||
1044 | else |
||
1045 | BSM_Save.optbutton = false; |
||
1046 | getglobal("BSM_OptionsButton"):Hide(); |
||
1047 | end |
||
1048 | end |
||
1049 | end |
||
1050 | |||
1051 | --BSM_SetPosition: |
||
1052 | -- Purpose - Sets the position of the Overall Meter frame according to what is in the X/Y text boxes in the Options frame |
||
1053 | -- Parameters - None |
||
1054 | -- Returns - Nothing |
||
1055 | function BSM_SetPosition() |
||
1056 | local x, y; |
||
1057 | |||
1058 | --convert the text in the text boxes to numbers |
||
1059 | x = tonumber(getglobal("BSM_Options_PositionX"):GetText()); |
||
1060 | y = tonumber(getglobal("BSM_Options_PositionY"):GetText()); |
||
1061 | --if the text converted correctly to a number, set the position of the Overall Meter |
||
1062 | if x then |
||
1063 | BSM_Save.dispX = x; |
||
1064 | end |
||
1065 | if y then |
||
1066 | BSM_Save.dispY = y; |
||
1067 | end |
||
1068 | getglobal(BSM_FRAME):ClearAllPoints(); |
||
1069 | getglobal(BSM_FRAME):SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", BSM_Save.dispX, BSM_Save.dispY); |
||
1070 | end |
||
1071 | |||
1072 | --BSM_openBag: |
||
1073 | -- Purpose - Opens the appropriate bag when hitting a key binding button |
||
1074 | -- Parameters - b: the button that was pressed |
||
1075 | -- Returns - Nothing |
||
1076 | function BSM_openBag(b) |
||
1077 | --name: the name of the button that was pressed |
||
1078 | local name = b:GetName(); |
||
1079 | |||
1080 | --Find the number in the button's name |
||
1081 | name = string.sub( name, string.len(BSM_DROPDOWNS)+1, string.len(BSM_DROPDOWNS)+1 ); |
||
1082 | |||
1083 | --Convert the number string to an actual number and toggle that bag |
||
1084 | ToggleBag( tonumber(name) ); |
||
1085 | end |