comparison options.lua @ 96:780b7e0eeeeb

Break the options panel out of gui.lua into new options.lua. Move default item lists from verbage.lua there also. Redo options panel as a tree instead of a massive scrolling thing, and prepare data structures to let plugins/etc add their own options code.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 26 Jul 2012 20:46:00 +0000
parents
children ba5ff82dcf19
comparison
equal deleted inserted replaced
95:3546c7b55986 96:780b7e0eeeeb
1 local addon = select(2,...)
2 if addon.NOLOAD then return end
3
4 -- Don't bother recording any of this loot:
5 addon.default_itemfilter = {
6 -- could probably remove most of this now
7 -- [29434] = true, -- Badge of Justice
8 -- [40752] = true, -- Emblem of Heroism
9 -- [40753] = true, -- Emblem of Valor
10 -- [45624] = true, -- Emblem of Conquest
11 -- [43228] = true, -- Stone Keeper's Shard
12 -- [47241] = true, -- Emblem of Triumph
13 -- [49426] = true, -- Emblem of Frost
14 }
15
16 -- Mark these as straight to guild vault:
17 addon.default_itemvault = {
18 [52078] = true, -- Chaos Orb
19 [69237] = true, -- Living Ember
20 [71998] = true, -- Essence of Destruction
21 }
22
23 local options_tree = {
24 {
25 value = "pong",
26 text = "Pongs",
27 },
28 {
29 value = "basic",
30 text = "Options",
31 children = {
32 {
33 value = "filter",
34 text = "Item Filters",
35 },
36 },
37 },
38 {
39 value = "adv",
40 text = "Advanced/Debugging",
41 },
42 }
43
44
45 --[[
46 mkbutton ("WidgetType", 'display key', "Text On Widget", "mouseover status text")
47 mkbutton ( [Button] 'display key', "Text On Widget", "mouseover status text")
48 mkbutton ( [Button] [text] "Text On Widget", "mouseover status text")
49 ]]
50 local mkbutton = addon.gui_state_pointer.mkbutton
51 local gui = addon.gui_state_pointer
52 local AceGUI = LibStub("AceGUI-3.0")
53 local flib = LibStub("LibFarmbuyer")
54 -- Local ref to OuroLootSV_opts, which may be reassigned after load.
55 -- So instead this is updated when the tab is displayed.
56 local opts
57
58 local function mktoggle (opt, label, width, desc, opt_func)
59 local w = mkbutton("CheckBoxSmallLabel", nil, "", desc)
60 w:SetRelativeWidth(width)
61 w:SetType("checkbox")
62 w:SetLabel(label)
63 if opt then
64 w:SetValue(opts[opt])
65 w:SetCallback("OnValueChanged", opt_func or (function(_w,event,value)
66 opts[opt] = value
67 end))
68 end
69 return w
70 end
71
72 local function mktitle (txt)
73 local t = AceGUI:Create("Label")
74 t:SetFullWidth(true)
75 t:SetColor (0.19, 0.68, 1) -- cff30adff
76 t:SetFontObject(GameFontHighlightLarge)
77 t:SetText(txt)
78 local s = AceGUI:Create("Spacer")
79 s:SetFullWidth(true)
80 s:SetHeight(20)
81 return t, s
82 end
83
84 local function adv_careful_OnTextChanged (ebox,event,value)
85 -- The EditBox widget's code will call an internal ShowButton routine
86 -- after this callback returns. ShowButton will test for this flag:
87 ebox:DisableButton (value == "")
88 end
89
90
91 ---------------
92 -- All controls take a scrollframe container set to Flow layout.
93 local controls = {}
94 controls.pong = function (container)
95 container:AddChildren(mktitle[[Echoes from latest ping:]])
96 addon.sender_list.sort()
97 if #addon.sender_list.namesI > 0 then
98 local w = AceGUI:Create("Label")
99 w:SetFullWidth(true)
100 w:SetText(table.concat(addon.sender_list.namesI,'\n')) -- sigh
101 container:AddChild(w)
102 end
103 end
104
105
106 ---------------
107 controls.basic = function (container)
108 container:AddChildren(mktitle[[Account Options (saved across sessions)]])
109
110 container:PauseLayout()
111 local w
112 local stdw = 0.99 -- standard width
113
114 -- the nubtoggle!
115 w = mktoggle('gui_noob', [[Show UI Tips]], stdw,
116 [[Toggles display of the "helpful tips" box hanging off the right side. Useful if you've just installed/upgraded.]])
117 container:AddChild(w)
118
119 -- reminder popup
120 w = mktoggle('popup_on_join', "Show reminder popup on new raid", stdw,
121 [[When joining a raid and not already tracking, display a dialog asking for instructions.]])
122 container:AddChild(w)
123
124 -- toggle scroll-to-bottom on first tab
125 w = mktoggle('scroll_to_bottom', "Scroll to bottom when opening display", stdw,
126 [[Scroll to the bottom of the loot window (most recent entries) when displaying the GUI.]])
127 container:AddChild(w)
128
129 -- chatty boss mode
130 w = mktoggle('chatty_on_kill', "Be chatty on boss kill", stdw,
131 [[Print something to chat output when the boss mod tells Ouro Loot about a successful boss kill.]])
132 container:AddChild(w)
133
134 -- less noise in main panel
135 w = mktoggle('no_tracking_wipes', "Do not track wipes", stdw,
136 [[Do not add 'wipe' entries on the main loot grid, or generate any text for them.]])
137 container:AddChild(w)
138
139 -- cutesy abbrevs
140 w = mktoggle('snarky_boss', "Use snarky boss names", stdw,
141 [[Irreverent replacement names for boss events. See abbreviations.lua for details.]])
142 container:AddChild(w)
143
144 -- LOD plugins in all cases
145 w = mktoggle('display_disabled_LODs', "Include disabled plugins", stdw,
146 [[Show loadable plugins even if they've been disabled (and offer to enable them). Relog to take effect.]])
147 container:AddChild(w)
148
149 -- showing the "(from Rebroadcasterdude)" in the notes column
150 w = mktoggle('display_bcast_from', "Show rebroadcasting player", stdw,
151 [[Include "from PlayerName" in the Notes column for loot that was broadcast to you. (Not included in forum output).]],
152 function(_w,_e,value)
153 opts.display_bcast_from = value
154 addon.loot_clean = nil
155 end)
156 container:AddChild(w)
157
158 -- prefilling g_uniques with history
159 w = mktoggle('precache_history_uniques', "Prescan for faster handling", stdw,
160 [[See description under +Help -- Handy Tips -- Prescanning> for instructions.]])
161 container:AddChild(w)
162
163 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w)
164 -- possible keybindings
165 do
166 local pair = AceGUI:Create("InlineGroup")
167 pair:SetLayout("List")
168 pair:SetRelativeWidth(0.49)
169 pair:SetTitle("Keybinding for '/ouroloot'")
170 local editbox, checkbox
171 editbox = mkbutton("EditBox", nil, opts.keybinding_text,
172 [[Keybinding text format is fragile! (All caps, ALT then CTRL then SHIFT.) Relog to take effect.]])
173 editbox:SetFullWidth(true)
174 editbox:SetLabel("Keybinding text")
175 editbox:SetCallback("OnEnterPressed", function(_w,event,value)
176 opts.keybinding_text = value
177 end)
178 editbox:SetDisabled(not opts.keybinding)
179 checkbox = mktoggle('keybinding', "Register keybinding", 1,
180 [[Register a keybinding to toggle the loot display. Relog to take effect.]],
181 function (_w,_,value)
182 opts.keybinding = value
183 editbox:SetDisabled(not opts.keybinding)
184 end)
185 checkbox:SetFullWidth(true)
186 pair:AddChild(checkbox)
187 pair:AddChild(editbox)
188 container:AddChild(pair)
189 end
190
191 -- replacement for slashloot
192 do
193 local pair = AceGUI:Create("InlineGroup")
194 pair:SetLayout("List")
195 pair:SetRelativeWidth(0.49)
196 pair:SetTitle('Synonyms for "/ouroloot"')
197 local editbox, checkbox
198 editbox = mkbutton("EditBox", nil, opts.slash_synonyms,
199 [[Separate multiple synonyms with a comma. Relog to take effect.]])
200 editbox:SetFullWidth(true)
201 editbox:SetLabel("Slash commands")
202 editbox:SetCallback("OnEnterPressed", function(_e,event,value)
203 -- Do the sanity checking here rather than at each login.
204 -- This is not foolproof. That's okay.
205 local t = { strsplit(',', tostring(value)) }
206 for k,v in ipairs(t) do
207 v = v:trim()
208 if v:sub(1,1) ~= "/" then
209 v = "/" .. v
210 end
211 t[k] = v
212 end
213 value = table.concat(t,',')
214 _e:SetText(value)
215 opts.slash_synonyms = value
216 end)
217 editbox:SetDisabled(not opts.register_slash_synonyms)
218 checkbox = mktoggle('register_slash_synonyms', "Register slash commands", 1,
219 [[Register these slash commands as synonyms for "/ouroloot". Relog to take effect.]],
220 function (_w,_,value)
221 opts.register_slash_synonyms = value
222 editbox:SetDisabled(not opts.register_slash_synonyms)
223 end)
224 checkbox:SetFullWidth(true)
225 pair:AddChild(checkbox)
226 pair:AddChild(editbox)
227 container:AddChild(pair)
228 end
229
230 -- chatty disposition/assignment changes
231 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w)
232 do
233 local chatgroup = AceGUI:Create("InlineGroup")
234 chatgroup:SetLayout("List")
235 chatgroup:SetRelativeWidth(0.75)
236 chatgroup:SetTitle("Remote Changes Chat")
237 local toggle, editbox
238 toggle = mktoggle('chatty_on_remote_changes', "Be chatty on remote changes", 1,
239 [[Print something to chat when other users change recorded loot.]],
240 function (_w,_,value)
241 opts.chatty_on_remote_changes = value
242 editbox:SetDisabled(not opts.chatty_on_remote_changes)
243 end)
244 toggle:SetFullWidth(true)
245 chatgroup:AddChild(toggle)
246 w = AceGUI:Create("Label")
247 w:SetFullWidth(true)
248 w:SetText("This controls the output of the |cff00ffff'Be chatty on remote changes'|r option. If this field is a number, it designates which chat frame to use. Otherwise it is the Lua variable name of a frame with AddMessage capability.")
249 chatgroup:AddChild(w)
250 editbox = mkbutton("EditBox", nil, opts.chatty_on_remote_changes_frame,
251 [[1 = default chat frame, 2 = combat log, etc]])
252 editbox:SetFullWidth(true)
253 editbox:SetLabel("Output Chatframe")
254 editbox:SetCallback("OnTextChanged", adv_careful_OnTextChanged)
255 editbox:SetCallback("OnEnterPressed", function(_w,event,value)
256 local prev = opts.chatty_on_remote_changes_frame
257 value = value:trim()
258 value = tonumber(value) or value
259 if addon:_set_remote_change_chatframe (value) then
260 opts.chatty_on_remote_changes_frame = value
261 _w:SetText(tostring(value))
262 _w.editbox:ClearFocus()
263 else
264 _w:SetText(tostring(prev))
265 end
266 end)
267 editbox:SetDisabled(not opts.chatty_on_remote_changes)
268 chatgroup:AddChild(editbox)
269 w = mkbutton("Chat Frame Numbers",
270 [[Print each chat window number in its own frame, for easy reference in the editing field.]])
271 w:SetFullWidth(true)
272 w:SetCallback("OnClick", function()
273 for i = 1, NUM_CHAT_WINDOWS do
274 local cf = _G['ChatFrame'..i]
275 if not cf then break end
276 addon:CFPrint (cf, "This is frame number |cffff0000%d|r.", i)
277 end
278 end)
279 chatgroup:AddChild(w)
280 container:AddChild(chatgroup)
281 end
282
283 -- boss mod selection
284 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) container:AddChild(w)
285 do
286 local list = {}
287 local current
288 for k,v in ipairs(addon.bossmods) do
289 list[k] = v.n
290 if v.n == opts.bossmod then
291 current = k
292 end
293 end
294 w = mkbutton("Dropdown", nil, "", [[Which 'boss mod' to use.]])
295 w:SetRelativeWidth(0.3)
296 w:SetLabel("Boss Mod:")
297 w:SetList(list)
298 w:SetValue(current)
299 w:SetCallback("OnValueChanged", function(_w,event,choice)
300 opts.bossmod = list[choice]
301 end)
302 container:AddChild(w)
303 end
304
305 container:ResumeLayout()
306 container:DoLayout()
307 AceGUI:ClearFocus()
308 end
309
310
311 ---------------
312 do
313 local warntext = [[At least one of the items in the filter list was not in your game client's cache. This is okay. Just wait a few seconds, display some other Ouro Loot tab or panel, and then display the Item Filters again.]]
314 local cache_warn, cache_warned = false, false
315 local function do_warning (cnt)
316 if cache_warn and not cache_warned then
317 cache_warned = true
318 addon:Print(warntext)
319 local t = AceGUI:Create("Label")
320 t:SetFullWidth(true)
321 t:SetText(warntext)
322 cnt:AddChild(t)
323 end
324 end
325
326 controls.basic_filter = function (container)
327 container:AddChildren(mktitle[[Item-Specific Special Handling]])
328
329 cache_warn, cache_warned = false, false
330 local filterlist, vaultlist = {}, {}
331 for id in pairs(opts.itemfilter) do
332 local iname, _, iquality = GetItemInfo(id)
333 if iname then
334 filterlist[id] = ITEM_QUALITY_COLORS[iquality].hex .. iname .. "|r"
335 else
336 filterlist[id] = id
337 cache_warn = true
338 end
339 end
340 for id in pairs(opts.itemvault) do
341 local iname, _, iquality = GetItemInfo(id)
342 if iname then
343 vaultlist[id] = ITEM_QUALITY_COLORS[iquality].hex .. iname .. "|r"
344 else
345 vaultlist[id] = id
346 cache_warn = true
347 end
348 end
349
350 local w = AceGUI:Create("EditBoxDropDown")
351 w:SetRelativeWidth(0.4)
352 w:SetText("Item filter")
353 w:SetEditBoxTooltip("Link items which should no longer be tracked.")
354 w:SetList(filterlist)
355 w:SetCallback("OnTextEnterPressed", function(_w, _, text)
356 local iname, ilink, iquality = GetItemInfo(text:trim())
357 if not iname then
358 return addon:Print("Error: %s is not a valid item name/link!", text)
359 end
360 local id = tonumber(ilink:match("item:(%d+)"))
361 filterlist[id] = ITEM_QUALITY_COLORS[iquality].hex .. iname .. "|r"
362 opts.itemfilter[id] = true
363 addon:Print("Now filtering out", ilink)
364 end)
365 w:SetCallback("OnListItemClicked", function(_w, _, key_id, val_name)
366 --local ilink = select(2,GetItemInfo(key_id))
367 opts.itemfilter[tonumber(key_id)] = nil
368 --addon:Print("No longer filtering out", ilink)
369 addon:Print("No longer filtering out", val_name)
370 end)
371 --w:SetCallback("OnDropdownShown",do_warning)
372 w:SetCallback("OnDropdownShown", function()
373 do_warning(container)
374 end)
375 container:AddChild(w)
376
377 w = AceGUI:Create("Spacer")
378 w:SetRelativeWidth(0.1)
379 w:SetHeight(2)
380 container:AddChild(w)
381
382 w = AceGUI:Create("EditBoxDropDown")
383 w:SetRelativeWidth(0.4)
384 w:SetText("Vault items")
385 w:SetEditBoxTooltip("Link items which should be automatically marked as guild vault.")
386 w:SetList(vaultlist)
387 w:SetCallback("OnTextEnterPressed", function(_w, _, text)
388 local iname, ilink, iquality = GetItemInfo(text:trim())
389 if not iname then
390 return addon:Print("Error: %s is not a valid item name/link!", text)
391 end
392 local id = tonumber(ilink:match("item:(%d+)"))
393 vaultlist[id] = ITEM_QUALITY_COLORS[iquality].hex .. iname .. "|r"
394 opts.itemvault[id] = true
395 addon:Print("Now auto-vaulting", ilink)
396 end)
397 w:SetCallback("OnListItemClicked", function(_w, _, key_id, val_name)
398 --local ilink = select(2,GetItemInfo(key_id))
399 opts.itemfilter[tonumber(key_id)] = nil
400 --addon:Print("No longer filtering out", ilink)
401 addon:Print("No longer auto-vaulting", val_name)
402 end)
403 w:SetCallback("OnDropdownShown",do_warning)
404 container:AddChild(w)
405 end
406 end
407
408
409 ---------------
410 local adv_real = function (container)
411 container:AddChildren(mktitle[[Debugging Options (not saved across sessions)]])
412
413 container:PauseLayout()
414 local w
415
416 do
417 local grp = AceGUI:Create("InlineGroup")
418 grp:SetLayout("List")
419 grp:SetRelativeWidth(0.60)
420 grp:SetTitle("Output of debugging messages")
421
422 w = AceGUI:Create("CheckBoxSmallLabel")
423 w:SetFullWidth(true)
424 w:SetType("checkbox")
425 w:SetLabel("master toggle")
426 w:SetValue(addon.DEBUG_PRINT)
427 w:SetCallback("OnValueChanged", function(_w,event,value)
428 addon.DEBUG_PRINT = value
429 addon:redisplay()
430 end)
431 grp:AddChild(w)
432 for d,v in pairs(addon.debug) do
433 w = AceGUI:Create("CheckBoxSmallLabel")
434 w:SetFullWidth(true)
435 w:SetType("checkbox")
436 w:SetLabel(d)
437 if d == "notraid" then
438 w:SetDescription[[Tick this before enabling to make the addon work outside of raid groups]]
439 else
440 if d == "alsolog" then
441 w:SetDescription[[Also log all debug messages to disk. See print_log.lua in the addon folder for later viewing.]]
442 end
443 w:SetDisabled(not addon.DEBUG_PRINT)
444 end
445 w:SetValue(v)
446 w:SetCallback("OnValueChanged", function(_w,event,value) addon.debug[d] = value end)
447 grp:AddChild(w)
448 end
449 container:AddChild(grp)
450 end
451
452 do
453 local simple = AceGUI:Create("SimpleGroup")
454 simple:SetLayout("List")
455 simple:SetRelativeWidth(0.35)
456 w = AceGUI:Create("CheckBoxSmallLabel")
457 --w:SetRelativeWidth(0.35)
458 w:SetFullWidth(true)
459 w:SetType("checkbox")
460 w:SetLabel("GOP history mode")
461 w:SetValue(addon.history_suppress)
462 w:SetCallback("OnValueChanged", function(_w,event,value) addon.history_suppress = value end)
463 simple:AddChild(w)
464 w = mkbutton("Dropdown", nil, "",
465 [[if active, tooltip shown when hovering over Item column only]])
466 --w:SetRelativeWidth(0.4)
467 w:SetFullWidth(true)
468 w:SetLabel("loot debugging tooltip")
469 w:SetList{
470 [1] = "Off",
471 [2] = "/dump into tooltip",
472 [3] = "small fixed fields",
473 }
474 w:SetValue(gui._do_debugging_tooltip or 1)
475 w:SetCallback("OnValueChanged", function(_w,event,choice)
476 gui._do_debugging_tooltip = choice > 1 and choice or nil
477 end)
478 simple:AddChild(w)
479 container:AddChild(simple)
480 end
481
482 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w)
483
484 w = mkbutton("EditBox", 'comm_ident', addon.ident,
485 [[Set tracking to 'Disabled' in the top-right dropdown, then change this field (click Okay or press Enter).]])
486 w:SetRelativeWidth(0.25)
487 w:SetLabel("Addon channel ID")
488 w:SetCallback("OnTextChanged", adv_careful_OnTextChanged)
489 w:SetCallback("OnEnterPressed", function(_w,event,value)
490 -- if they set it to blank spaces, they're boned. oh well.
491 -- Re-enabling will take care of propogating this new value.
492 addon.ident = (value == "") and "OuroLoot2" or value
493 _w:SetText(addon.ident)
494 addon:Print("Addon channel ID set to '".. addon.ident.. "' for rebroadcasting and listening.")
495 end)
496 w:SetDisabled(addon.enabled or addon.rebroadcast)
497 container:AddChild(w)
498
499 w = mkbutton("EditBox", nil, addon.recent_messages.ttl, [[comm cache TTL]])
500 w:SetRelativeWidth(0.1)
501 w:SetLabel("ttl")
502 w:SetCallback("OnTextChanged", adv_careful_OnTextChanged)
503 w:SetCallback("OnEnterPressed", function(_w,event,value)
504 value = tonumber(value) or addon.recent_messages.ttl
505 addon.recent_messages.ttl = value
506 _w:SetText(tostring(value))
507 end)
508 container:AddChild(w)
509
510 w = mkbutton("load nsaab1548", [[Cursed Darkhound]])
511 w:SetRelativeWidth(0.25)
512 w:SetCallback("OnClick", function()
513 for i, v in ipairs(DBM.AddOns) do
514 if v.modId == "DBM-NotScaryAtAll" then
515 DBM:LoadMod(v)
516 break
517 end
518 end
519 local mod = DBM:GetModByName("NotScaryAtAll")
520 if mod then
521 mod:EnableMod()
522 addon:Print("Now tracking ID",mod.creatureId)
523 else
524 addon:Print("Can do nothing; DBM testing mod wasn't loaded.")
525 end
526 end)
527 w:SetDisabled(addon.bossmod_registered ~= 'DBM')
528 container:AddChild(w)
529
530 w = mkbutton("GC", [[full GC cycle]])
531 w:SetRelativeWidth(0.2)
532 w:SetCallback("OnClick", function()
533 local before = collectgarbage('count')
534 collectgarbage('collect')
535 local after = collectgarbage('count')
536 addon:Print("Collected %d KB, %d KB still in use by Lua universe.", before-after, after)
537 end)
538 container:AddChild(w)
539
540 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(3) container:AddChild(w)
541 do
542 local simple = AceGUI:Create("SimpleGroup")
543 simple:SetLayout("Flow")
544 --simple:SetRelativeWidth(0.95)
545 simple:SetFullWidth(true)
546 w = mkbutton("MidS-H", [[not exactly an Easter egg, with sound]])
547 w:SetRelativeWidth(0.2)
548 w:SetCallback("OnClick", function()
549 PlaySoundFile ([[Sound\Music\WorldEvents\HordeFirepole.mp3]], "Master")
550 end)
551 simple:AddChild(w)
552 w = mkbutton("MidS-A", [[not exactly an Easter egg, with sound]])
553 w:SetRelativeWidth(0.2)
554 w:SetCallback("OnClick", function()
555 PlaySoundFile ([[Sound\Music\WorldEvents\AllianceFirepole.mp3]], "Master")
556 end)
557 simple:AddChild(w)
558 w = mkbutton("SFRR", [[test]])
559 w:SetRelativeWidth(0.15)
560 w:SetCallback("OnClick", function()
561 PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "Master")
562 end)
563 simple:AddChild(w)
564
565 container:AddChild(simple)
566 end
567
568 w = AceGUI:Create("Spacer") w:SetRelativeWidth(0.65) w:SetHeight(15) container:AddChild(w)
569 w = mkbutton("Clear All & Reload",
570 [[No confirmation! |cffff1010Erases absolutely all> Ouro Loot saved variables and reloads the UI.]])
571 w:SetRelativeWidth(0.3)
572 w:SetCallback("OnClick", function()
573 addon:_clear_SVs() -- reloads
574 end)
575 container:AddChild(w)
576
577 container:ResumeLayout()
578 container:DoLayout()
579 AceGUI:ClearFocus()
580 --container:SetScroll(1000) -- scrollframe widget's max value
581 end
582
583 -- Initial advanced panel function (unless debug mode is on during load, which
584 -- means it was almost certainly hardcoded that way, which means it's probably
585 -- me testing).
586 if false and addon.DEBUG_PRINT then
587 controls.adv = adv_real
588 else
589 controls.adv = function (container)
590 local speedbump = AceGUI:Create("InteractiveLabel")
591 speedbump:SetFullWidth(true)
592 speedbump:SetFontObject(GameFontHighlightLarge)
593 speedbump:SetImage[[Interface\DialogFrame\DialogAlertIcon]]
594 speedbump:SetImageSize(50,50)
595 speedbump:SetText[[The debugging/testing settings on the advanced panel can seriously bork up the addon if you make a mistake. If you're okay with the possibility of losing data, click this warning to load the panel.]]
596 speedbump:SetCallback("OnClick", function (_sb)
597 controls.adv = { adv_real }
598 return addon:redisplay()
599 end)
600 container:AddChild(speedbump)
601 end
602 end
603
604
605 ---------------
606 -- Tab 6: Options
607 do
608 local funkified = {}
609 for key,f in pairs(controls) do
610 -- this is how TreeGroup makes unique keys
611 local funkykey = key:gsub('_','\001')
612 funkified[funkykey] = { f }
613 end
614 controls = funkified
615 end
616
617 -- widget container status tables (will have things magically appear
618 -- inside them that we wish to preserve)
619 local status_for_scroll = {}
620 local status_for_select = { treewidth = 160 }
621
622 -- Clicking an entry on the left tree column.
623 local opt_OnGroupSelected_func = function (treeg,event,category)
624 local catfuncs = controls[category]
625 if not catfuncs then
626 addon:horrible_horrible_error(("Category '%s' has no handler function!"):format(category:gsub('\001','_')))
627 end
628 treeg:ReleaseChildren()
629 local sf = AceGUI:Create("ScrollFrame")
630 sf:SetStatusTable(status_for_scroll)
631 sf:SetLayout("Flow")
632 -- This forces the scrolling area to be bigger than the visible area; else
633 -- some of the text gets cut off without ever triggering the scrollbar.
634 sf.content:SetHeight(700)
635 for _,func in ipairs(catfuncs) do
636 if func(sf) then break end
637 end
638 treeg:AddChild(sf)
639 if treeg:GetUserData("options restore scroll") then
640 if status_for_scroll.scrollvalue then
641 sf:SetScroll(status_for_scroll.scrollvalue)
642 end
643 treeg:SetUserData("options restore scroll", false)
644 else
645 sf:SetScroll(0)
646 end
647 end
648
649 -- Clicking the Options tab as a whole (tabs_OnGroupSelected["opt"]).
650 local tabs_OGS = function (container, specials)
651 opts = OuroLootSV_opts
652
653 container:SetLayout("Fill")
654 local left = AceGUI:Create("TreeGroup")
655 left:SetStatusTable(status_for_select)
656 left:SetLayout("Fill")
657 left:SetFullWidth(true)
658 left:SetFullHeight(true)
659 left:EnableButtonTooltips(false)
660 left:SetTree(options_tree)
661 left:SetCallback("OnGroupSelected", opt_OnGroupSelected_func)
662 container:AddChild(left)
663 if status_for_select.selected then
664 left:SetUserData("options restore scroll", true)
665 left:SelectByValue(status_for_select.selected)
666 else
667 left:SelectByValue("basic")
668 end
669
670 local w = mkbutton("ReloadUI",
671 [[Does what you think it does. Loot information is written out and restored.]])
672 w:SetFullWidth(true)
673 w:SetCallback("OnClick", ReloadUI)
674 specials:AddChild(w)
675
676 w = mkbutton("Ping!",
677 [[Queries other raid users for their addon version and current status. Results displayed on Pongs panel after five seconds.]])
678 w:SetFullWidth(true)
679 w:SetCallback("OnClick", function(_w)
680 _w:SetText("5... 4... 3...")
681 _w:SetDisabled(true)
682 addon:DoPing()
683 addon:ScheduleTimer(function(b)
684 if b:IsVisible() then
685 return addon:redisplay()
686 end
687 end, 5, _w)
688 end)
689 specials:AddChild(w)
690 end
691
692 addon:register_tab_control_AT_END ("opt", [[Options]],
693 [[Options for fine-tuning behavior]], tabs_OGS)
694
695 -- vim:noet