Mercurial > wow > ouroloot
comparison options.lua @ 97:ba5ff82dcf19
(First breaking change for MoP/3.0, incomplete transition.) Move generic user options to acedb. Remove older savedvar-upgrade code for a clean break. Add a profiles tab since it will be expected; changing profiles not yet implemented.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Fri, 27 Jul 2012 10:23:12 +0000 |
parents | 780b7e0eeeeb |
children | b5a55c69ef67 |
comparison
equal
deleted
inserted
replaced
96:780b7e0eeeeb | 97:ba5ff82dcf19 |
---|---|
1 local addon = select(2,...) | 1 local addon = select(2,...) |
2 if addon.NOLOAD then return end | 2 if addon.NOLOAD then return end |
3 | 3 |
4 -- Don't bother recording any of this loot: | 4 -- Don't bother recording any of this loot: |
5 addon.default_itemfilter = { | 5 addon.default_itemfilter = { |
6 [52190] = true, -- Inferno Ruby | |
7 [52191] = true, -- Ocean Sapphire | |
8 [52192] = true, -- Dream Emerald | |
9 [52193] = true, -- Ember Topaz | |
10 [52194] = true, -- Demonseye | |
11 [52195] = true, -- Amberjewel | |
12 [52722] = true, -- Maelstrom Crystal | |
13 [71716] = true, -- Soothsayer's Runes | |
6 -- could probably remove most of this now | 14 -- could probably remove most of this now |
7 -- [29434] = true, -- Badge of Justice | 15 -- [29434] = true, -- Badge of Justice |
8 -- [40752] = true, -- Emblem of Heroism | 16 -- [40752] = true, -- Emblem of Heroism |
9 -- [40753] = true, -- Emblem of Valor | 17 -- [40753] = true, -- Emblem of Valor |
10 -- [45624] = true, -- Emblem of Conquest | 18 -- [45624] = true, -- Emblem of Conquest |
11 -- [43228] = true, -- Stone Keeper's Shard | 19 -- [43228] = true, -- Stone Keeper's Shard |
12 -- [47241] = true, -- Emblem of Triumph | 20 -- [47241] = true, -- Emblem of Triumph |
13 -- [49426] = true, -- Emblem of Frost | 21 -- [49426] = true, -- Emblem of Frost |
14 } | 22 } |
15 | 23 |
16 -- Mark these as straight to guild vault: | 24 -- Mark these as straight to guild vault: |
17 addon.default_itemvault = { | 25 addon.default_itemvault = { |
18 [52078] = true, -- Chaos Orb | 26 [52078] = true, -- Chaos Orb |
19 [69237] = true, -- Living Ember | 27 [69237] = true, -- Living Ember |
20 [71998] = true, -- Essence of Destruction | 28 [71998] = true, -- Essence of Destruction |
21 } | 29 } |
22 | 30 |
23 local options_tree = { | 31 local options_tree = { |
24 { | 32 { |
25 value = "pong", | 33 value = "pong", |
31 children = { | 39 children = { |
32 { | 40 { |
33 value = "filter", | 41 value = "filter", |
34 text = "Item Filters", | 42 text = "Item Filters", |
35 }, | 43 }, |
44 { | |
45 value = "profiles", | |
46 text = "Profiles", | |
47 }, | |
36 }, | 48 }, |
37 }, | 49 }, |
38 { | 50 { |
39 value = "adv", | 51 value = "adv", |
40 text = "Advanced/Debugging", | 52 text = "Advanced/Debugging", |
49 ]] | 61 ]] |
50 local mkbutton = addon.gui_state_pointer.mkbutton | 62 local mkbutton = addon.gui_state_pointer.mkbutton |
51 local gui = addon.gui_state_pointer | 63 local gui = addon.gui_state_pointer |
52 local AceGUI = LibStub("AceGUI-3.0") | 64 local AceGUI = LibStub("AceGUI-3.0") |
53 local flib = LibStub("LibFarmbuyer") | 65 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 | 66 local opts |
57 | 67 |
58 local function mktoggle (opt, label, width, desc, opt_func) | 68 local function mktoggle (opt, label, width, desc, opt_func) |
59 local w = mkbutton("CheckBoxSmallLabel", nil, "", desc) | 69 local w = mkbutton("CheckBoxSmallLabel", nil, "", desc) |
60 w:SetRelativeWidth(width) | 70 w:SetRelativeWidth(width) |
67 end)) | 77 end)) |
68 end | 78 end |
69 return w | 79 return w |
70 end | 80 end |
71 | 81 |
82 local function spacer (height) | |
83 local s = AceGUI:Create("Spacer") | |
84 s:SetFullWidth(true) | |
85 s:SetHeight(height) | |
86 return s | |
87 end | |
88 | |
72 local function mktitle (txt) | 89 local function mktitle (txt) |
73 local t = AceGUI:Create("Label") | 90 local t = AceGUI:Create("Label") |
74 t:SetFullWidth(true) | 91 t:SetFullWidth(true) |
75 t:SetColor (0.19, 0.68, 1) -- cff30adff | 92 t:SetColor (0.19, 0.68, 1) -- cff30adff |
76 t:SetFontObject(GameFontHighlightLarge) | 93 t:SetFontObject(GameFontHighlightLarge) |
77 t:SetText(txt) | 94 t:SetText(txt) |
78 local s = AceGUI:Create("Spacer") | 95 return t, spacer(20) |
79 s:SetFullWidth(true) | |
80 s:SetHeight(20) | |
81 return t, s | |
82 end | 96 end |
83 | 97 |
84 local function adv_careful_OnTextChanged (ebox,event,value) | 98 local function adv_careful_OnTextChanged (ebox,event,value) |
85 -- The EditBox widget's code will call an internal ShowButton routine | 99 -- The EditBox widget's code will call an internal ShowButton routine |
86 -- after this callback returns. ShowButton will test for this flag: | 100 -- after this callback returns. ShowButton will test for this flag: |
158 -- prefilling g_uniques with history | 172 -- prefilling g_uniques with history |
159 w = mktoggle('precache_history_uniques', "Prescan for faster handling", stdw, | 173 w = mktoggle('precache_history_uniques', "Prescan for faster handling", stdw, |
160 [[See description under +Help -- Handy Tips -- Prescanning> for instructions.]]) | 174 [[See description under +Help -- Handy Tips -- Prescanning> for instructions.]]) |
161 container:AddChild(w) | 175 container:AddChild(w) |
162 | 176 |
163 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w) | 177 container:AddChild(spacer(10)) |
164 -- possible keybindings | 178 -- possible keybindings |
165 do | 179 do |
166 local pair = AceGUI:Create("InlineGroup") | 180 local pair = AceGUI:Create("InlineGroup") |
167 pair:SetLayout("List") | 181 pair:SetLayout("List") |
168 pair:SetRelativeWidth(0.49) | 182 pair:SetRelativeWidth(0.49) |
226 pair:AddChild(editbox) | 240 pair:AddChild(editbox) |
227 container:AddChild(pair) | 241 container:AddChild(pair) |
228 end | 242 end |
229 | 243 |
230 -- chatty disposition/assignment changes | 244 -- chatty disposition/assignment changes |
231 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w) | 245 container:AddChild(spacer(10)) |
232 do | 246 do |
233 local chatgroup = AceGUI:Create("InlineGroup") | 247 local chatgroup = AceGUI:Create("InlineGroup") |
234 chatgroup:SetLayout("List") | 248 chatgroup:SetLayout("List") |
235 chatgroup:SetRelativeWidth(0.75) | 249 chatgroup:SetRelativeWidth(0.75) |
236 chatgroup:SetTitle("Remote Changes Chat") | 250 chatgroup:SetTitle("Remote Changes Chat") |
279 chatgroup:AddChild(w) | 293 chatgroup:AddChild(w) |
280 container:AddChild(chatgroup) | 294 container:AddChild(chatgroup) |
281 end | 295 end |
282 | 296 |
283 -- boss mod selection | 297 -- boss mod selection |
284 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) container:AddChild(w) | 298 container:AddChild(spacer(2)) |
285 do | 299 do |
286 local list = {} | 300 local list = {} |
287 local current | 301 local current |
288 for k,v in ipairs(addon.bossmods) do | 302 for k,v in ipairs(addon.bossmods) do |
289 list[k] = v.n | 303 list[k] = v.n |
308 end | 322 end |
309 | 323 |
310 | 324 |
311 --------------- | 325 --------------- |
312 do | 326 do |
327 local description = [[These control automatic handling of specific items when they are looted. "Item filter" is a list of items to ignore. "Vault items" is a list of items to mark as going to the guild vault (as if you had chosen "Mark as guild vault" from the Loot tab). | |
328 | |
329 Proper use of these lists can avoid a lot of noise and tedious clicking during or after a raid. You will probably need to add/remove entries as you advance between expansions and tiers.]] | |
330 local defaultstext = [[Clicking this button adds some reasonable defaults to your item lists. (This was done once automatically, the first time you loaded Ouro Loot, but you can delete them at any time.)]] | |
331 | |
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.]] | 332 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 | 333 local cache_warn, cache_warned = false, false |
315 local function do_warning (cnt) | 334 local function do_warning (cnt) |
316 if cache_warn and not cache_warned then | 335 if cache_warn and not cache_warned then |
317 cache_warned = true | 336 cache_warned = true |
324 end | 343 end |
325 | 344 |
326 controls.basic_filter = function (container) | 345 controls.basic_filter = function (container) |
327 container:AddChildren(mktitle[[Item-Specific Special Handling]]) | 346 container:AddChildren(mktitle[[Item-Specific Special Handling]]) |
328 | 347 |
348 local w = AceGUI:Create("Label") | |
349 w:SetFullWidth(true) | |
350 w:SetText(description) | |
351 container:AddChild(w) | |
352 container:AddChild(spacer(20)) | |
353 | |
329 cache_warn, cache_warned = false, false | 354 cache_warn, cache_warned = false, false |
330 local filterlist, vaultlist = {}, {} | 355 local filterlist, vaultlist = {}, {} |
331 for id in pairs(opts.itemfilter) do | 356 for id in pairs(opts.itemfilter) do |
332 local iname, _, iquality = GetItemInfo(id) | 357 local iname, _, iquality = GetItemInfo(id) |
333 if iname then | 358 if iname then |
344 else | 369 else |
345 vaultlist[id] = id | 370 vaultlist[id] = id |
346 cache_warn = true | 371 cache_warn = true |
347 end | 372 end |
348 end | 373 end |
349 | 374 -- This is so that the "add all defaults" button will never, ever, |
350 local w = AceGUI:Create("EditBoxDropDown") | 375 -- trip over cache misses. |
376 for id in pairs(addon.default_itemfilter) do GetItemInfo(id) end | |
377 for id in pairs(addon.default_itemvault) do GetItemInfo(id) end | |
378 | |
379 w = AceGUI:Create("EditBoxDropDown") | |
351 w:SetRelativeWidth(0.4) | 380 w:SetRelativeWidth(0.4) |
352 w:SetText("Item filter") | 381 w:SetText("Item filter") |
353 w:SetEditBoxTooltip("Link items which should no longer be tracked.") | 382 w:SetEditBoxTooltip("Link items which should no longer be tracked.") |
354 w:SetList(filterlist) | 383 w:SetList(filterlist) |
355 w:SetCallback("OnTextEnterPressed", function(_w, _, text) | 384 w:SetCallback("OnTextEnterPressed", function(_w, _, text) |
400 --addon:Print("No longer filtering out", ilink) | 429 --addon:Print("No longer filtering out", ilink) |
401 addon:Print("No longer auto-vaulting", val_name) | 430 addon:Print("No longer auto-vaulting", val_name) |
402 end) | 431 end) |
403 w:SetCallback("OnDropdownShown",do_warning) | 432 w:SetCallback("OnDropdownShown",do_warning) |
404 container:AddChild(w) | 433 container:AddChild(w) |
434 | |
435 local function MAYBE_ADD (destname, dest, id) | |
436 local name, link = GetItemInfo(id) | |
437 if not name then | |
438 addon:Print("> No data on ID %d, this may be a bug.",id) | |
439 return | |
440 end | |
441 if dest[id] then | |
442 addon:Print("> Skipping %s as it's already in '%s' list.", | |
443 link, destname) | |
444 else | |
445 dest[id] = true | |
446 addon:Print("> Added %s to '%s' list.", link, destname) | |
447 end | |
448 end | |
449 | |
450 container:AddChild(spacer(40)) | |
451 w = AceGUI:Create("Label") | |
452 w:SetFullWidth(true) | |
453 w:SetText(defaultstext) | |
454 container:AddChild(w) | |
455 w = AceGUI:Create("Button") | |
456 w:SetRelativeWidth(0.4) | |
457 w:SetText[[Add Default Entries]] | |
458 w:SetCallback("OnClick", function() | |
459 for id in pairs(addon.default_itemfilter) do | |
460 MAYBE_ADD ("filter", opts.itemfilter, id) | |
461 end | |
462 for id in pairs(addon.default_itemvault) do | |
463 MAYBE_ADD ("vault", opts.itemvault, id) | |
464 end | |
465 addon:redisplay() | |
466 end) | |
467 container:AddChild(w) | |
468 end | |
469 end | |
470 | |
471 | |
472 --------------- | |
473 do | |
474 local profiles | |
475 controls.basic_profiles = function (container) | |
476 if not profiles then | |
477 profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(addon.db) | |
478 LibStub("AceConfig-3.0"):RegisterOptionsTable("OuroLootProfiles", profiles) | |
479 end | |
480 LibStub("AceConfigDialog-3.0"):Open ("OuroLootProfiles", container) | |
405 end | 481 end |
406 end | 482 end |
407 | 483 |
408 | 484 |
409 --------------- | 485 --------------- |
477 end) | 553 end) |
478 simple:AddChild(w) | 554 simple:AddChild(w) |
479 container:AddChild(simple) | 555 container:AddChild(simple) |
480 end | 556 end |
481 | 557 |
482 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w) | 558 container:AddChild(spacer(10)) |
483 | 559 |
484 w = mkbutton("EditBox", 'comm_ident', addon.ident, | 560 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).]]) | 561 [[Set tracking to 'Disabled' in the top-right dropdown, then change this field (click Okay or press Enter).]]) |
486 w:SetRelativeWidth(0.25) | 562 w:SetRelativeWidth(0.25) |
487 w:SetLabel("Addon channel ID") | 563 w:SetLabel("Addon channel ID") |
535 local after = collectgarbage('count') | 611 local after = collectgarbage('count') |
536 addon:Print("Collected %d KB, %d KB still in use by Lua universe.", before-after, after) | 612 addon:Print("Collected %d KB, %d KB still in use by Lua universe.", before-after, after) |
537 end) | 613 end) |
538 container:AddChild(w) | 614 container:AddChild(w) |
539 | 615 |
540 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(3) container:AddChild(w) | 616 container:AddChild(spacer(3)) |
541 do | 617 do |
542 local simple = AceGUI:Create("SimpleGroup") | 618 local simple = AceGUI:Create("SimpleGroup") |
543 simple:SetLayout("Flow") | 619 simple:SetLayout("Flow") |
544 --simple:SetRelativeWidth(0.95) | 620 --simple:SetRelativeWidth(0.95) |
545 simple:SetFullWidth(true) | 621 simple:SetFullWidth(true) |
581 end | 657 end |
582 | 658 |
583 -- Initial advanced panel function (unless debug mode is on during load, which | 659 -- 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 | 660 -- means it was almost certainly hardcoded that way, which means it's probably |
585 -- me testing). | 661 -- me testing). |
586 if false and addon.DEBUG_PRINT then | 662 if addon.DEBUG_PRINT then |
587 controls.adv = adv_real | 663 controls.adv = adv_real |
588 else | 664 else |
589 controls.adv = function (container) | 665 controls.adv = function (container) |
590 local speedbump = AceGUI:Create("InteractiveLabel") | 666 local speedbump = AceGUI:Create("InteractiveLabel") |
591 speedbump:SetFullWidth(true) | 667 speedbump:SetFullWidth(true) |
617 -- widget container status tables (will have things magically appear | 693 -- widget container status tables (will have things magically appear |
618 -- inside them that we wish to preserve) | 694 -- inside them that we wish to preserve) |
619 local status_for_scroll = {} | 695 local status_for_scroll = {} |
620 local status_for_select = { treewidth = 160 } | 696 local status_for_select = { treewidth = 160 } |
621 | 697 |
698 local function preload() | |
699 for id in pairs(opts.itemfilter) do GetItemInfo(id) end | |
700 for id in pairs(opts.itemvault) do GetItemInfo(id) end | |
701 preload = nil | |
702 end | |
703 | |
622 -- Clicking an entry on the left tree column. | 704 -- Clicking an entry on the left tree column. |
623 local opt_OnGroupSelected_func = function (treeg,event,category) | 705 local opt_OnGroupSelected_func = function (treeg,event,category) |
624 local catfuncs = controls[category] | 706 local catfuncs = controls[category] |
625 if not catfuncs then | 707 if not catfuncs then |
626 addon:horrible_horrible_error(("Category '%s' has no handler function!"):format(category:gsub('\001','_'))) | 708 addon:horrible_horrible_error(("Category '%s' has no handler function!"):format(category:gsub('\001','_'))) |
646 end | 728 end |
647 end | 729 end |
648 | 730 |
649 -- Clicking the Options tab as a whole (tabs_OnGroupSelected["opt"]). | 731 -- Clicking the Options tab as a whole (tabs_OnGroupSelected["opt"]). |
650 local tabs_OGS = function (container, specials) | 732 local tabs_OGS = function (container, specials) |
651 opts = OuroLootSV_opts | 733 opts = gui.opts |
652 | 734 |
653 container:SetLayout("Fill") | 735 container:SetLayout("Fill") |
654 local left = AceGUI:Create("TreeGroup") | 736 local left = AceGUI:Create("TreeGroup") |
655 left:SetStatusTable(status_for_select) | 737 left:SetStatusTable(status_for_select) |
656 left:SetLayout("Fill") | 738 left:SetLayout("Fill") |
685 return addon:redisplay() | 767 return addon:redisplay() |
686 end | 768 end |
687 end, 5, _w) | 769 end, 5, _w) |
688 end) | 770 end) |
689 specials:AddChild(w) | 771 specials:AddChild(w) |
772 | |
773 if preload then preload() end | |
690 end | 774 end |
691 | 775 |
692 addon:register_tab_control_AT_END ("opt", [[Options]], | 776 addon:register_tab_control_AT_END ("opt", [[Options]], |
693 [[Options for fine-tuning behavior]], tabs_OGS) | 777 [[Options for fine-tuning behavior]], tabs_OGS) |
694 | 778 |