comparison core.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
100 ------ Saved variables 100 ------ Saved variables
101 OuroLootSV = nil -- possible copy of g_loot 101 OuroLootSV = nil -- possible copy of g_loot
102 OuroLootSV_saved = nil -- table of copies of saved texts, default nil; keys 102 OuroLootSV_saved = nil -- table of copies of saved texts, default nil; keys
103 -- are numeric indices of tables, subkeys of those 103 -- are numeric indices of tables, subkeys of those
104 -- are name/forum/attend/date 104 -- are name/forum/attend/date
105 OuroLootSV_opts = nil -- same as option_defaults until changed
106 -- autoshard: optional name of disenchanting player, default nil
107 -- threshold: optional loot threshold, default nil
108 OuroLootSV_hist = nil 105 OuroLootSV_hist = nil
109 OuroLootSV_log = {} 106 OuroLootSV_log = {}
110 107
111 108
112 ------ Constants 109 ------ Constants
136 ['display_disabled_LODs'] = false, 133 ['display_disabled_LODs'] = false,
137 ['display_bcast_from'] = true, 134 ['display_bcast_from'] = true,
138 ['precache_history_uniques'] = false, 135 ['precache_history_uniques'] = false,
139 ['chatty_on_remote_changes'] = false, 136 ['chatty_on_remote_changes'] = false,
140 ['chatty_on_remote_changes_frame'] = 1, 137 ['chatty_on_remote_changes_frame'] = 1,
138 ['itemfilter'] = {},
139 ['itemvault'] = {},
141 } 140 }
142 local virgin = "First time loaded? Hi! Use the /ouroloot command" 141 local virgin = "First time loaded? Hi! Use the /ouroloot command"
143 .." to show the main display. You should probably browse the instructions" 142 .." to show the main display. You should probably browse the instructions"
144 .." if you've never used this before; %s to display the help window. This" 143 .." if you've never used this before; %s to display the help window. This"
145 .." welcome message will not intrude again." 144 .." welcome message will not intrude again."
710 -- relogging during a raid and already have collected loot data 709 -- relogging during a raid and already have collected loot data
711 local OuroLootSV = _G.OuroLootSV 710 local OuroLootSV = _G.OuroLootSV
712 g_restore_p = OuroLootSV ~= nil 711 g_restore_p = OuroLootSV ~= nil
713 self.dprint('flow', "oninit sets restore as", g_restore_p) 712 self.dprint('flow', "oninit sets restore as", g_restore_p)
714 713
715 if _G.OuroLootSV_opts == nil then 714 if _G.OuroLootOptsDB == nil then
716 _G.OuroLootSV_opts = {}
717 local vclick = self.format_hypertext ([[click here]], ITEM_QUALITY_UNCOMMON, 'help') 715 local vclick = self.format_hypertext ([[click here]], ITEM_QUALITY_UNCOMMON, 'help')
718 self:ScheduleTimer(function(s) 716 self:ScheduleTimer(function(s)
717 for id in pairs(self.default_itemfilter) do
718 opts.itemfilter[id] = true
719 end
720 for id in pairs(self.default_itemvault) do
721 opts.itemvault[id] = true
722 end
719 s:Print(virgin, tostring(vclick)) 723 s:Print(virgin, tostring(vclick))
720 virgin = nil 724 virgin = nil
721 end,10,self) 725 end,10,self)
722 else 726 else
723 virgin = nil 727 virgin = nil
724 end 728 end
725 opts = _G.OuroLootSV_opts 729 self.db = _G.LibStub("AceDB-3.0"):New("OuroLootOptsDB",
730 { profile = option_defaults } , --[[Default=]]true)
731 opts = self.db.profile
732
733 --[[
726 local stored_datarev = opts.datarev or 14 734 local stored_datarev = opts.datarev or 14
727 for opt,default in pairs(option_defaults) do 735 for opt,default in pairs(option_defaults) do
728 if opts[opt] == nil then 736 if opts[opt] == nil then
729 opts[opt] = default 737 opts[opt] = default
730 end 738 end
731 end 739 end
732 opts.datarev = option_defaults.datarev 740 opts.datarev = option_defaults.datarev]]
733
734 -- transition&remove old options
735 opts['forum_use_itemid'] = nil
736 if opts['forum_format'] then
737 opts.forum['Custom...'] = opts['forum_format']
738 opts['forum_format'] = nil
739 end
740 if opts.forum['[url]'] then
741 opts.forum['[url] Wowhead'] = opts.forum['[url]']
742 opts.forum['[url]'] = nil
743 opts.forum['[url] MMO/Wowstead'] = option_defaults.forum['[url] MMO/Wowstead']
744 if opts['forum_current'] == '[url]' then
745 opts['forum_current'] = '[url] Wowhead'
746 end
747 end
748 if opts['register_slashloot'] then
749 self:Print[[The "/loot" command is no longer available, because it is used by Blizzard in MoP. You can toggle on other synonyms for "/ouroloot" in the Options tab.]]
750 end
751 opts['register_slashloot'] = nil
752 option_defaults = nil
753 if OuroLootSV then -- may not be the same as testing g_restore_p soon
754 if OuroLootSV.saved then
755 OuroLootSV_saved = OuroLootSV.saved; OuroLootSV.saved = nil
756 end
757 if OuroLootSV.threshold then
758 opts.threshold = OuroLootSV.threshold; OuroLootSV.threshold = nil
759 end
760 if OuroLootSV.autoshard then
761 opts.autoshard = OuroLootSV.autoshard; OuroLootSV.autoshard = nil
762 end
763 end
764
765 -- get item filter table if needed
766 if opts.itemfilter == nil then
767 opts.itemfilter = self.default_itemfilter
768 else
769 -- remove old stuff that doesn't "drop" anymore
770 -- find some way of only doing this once
771 opts.itemfilter[29434] = nil -- Badge of Justice
772 opts.itemfilter[40752] = nil -- Emblem of Heroism
773 opts.itemfilter[40753] = nil -- Emblem of Valor
774 opts.itemfilter[45624] = nil -- Emblem of Conquest
775 opts.itemfilter[43228] = nil -- Stone Keeper's Shard
776 opts.itemfilter[47241] = nil -- Emblem of Triumph
777 opts.itemfilter[49426] = nil -- Emblem of Frost
778 end
779 self.default_itemfilter = nil
780 if opts.itemvault == nil then
781 opts.itemvault = self.default_itemvault
782 end
783 self.default_itemvault = nil
784 741
785 self:RegisterChatCommand("ouroloot", "OnSlash") 742 self:RegisterChatCommand("ouroloot", "OnSlash")
786 if opts.register_slash_synonyms then 743 if opts.register_slash_synonyms then
787 -- Maybe use %w here for non-English locales? 744 -- Maybe use %w here for non-English locales?
788 local n = 2 745 local n = 2
823 --OuroLootSV_hist = nil 780 --OuroLootSV_hist = nil
824 781
825 -- Handle changes to the stored data format in stages from oldest to newest. 782 -- Handle changes to the stored data format in stages from oldest to newest.
826 -- bumpers[X] is responsible for updating from X to X+1. 783 -- bumpers[X] is responsible for updating from X to X+1.
827 -- (This is turning into a lot of loops over the same table. Consolidate?) 784 -- (This is turning into a lot of loops over the same table. Consolidate?)
828 if OuroLootSV then 785 if false and OuroLootSV then
829 local dirty = false 786 local dirty = false
830 local bumpers = {} 787 local bumpers = {}
831 bumpers[14] = function() 788 --bumpers[14] = function() start
832 for i,e in ipairs(OuroLootSV) do 789 --bumpers[19] = function() latest
833 if e.bosskill then
834 e.bossname, e.bosskill = e.bosskill, nil
835 end
836 end
837 end
838
839 bumpers[15] = function()
840 for i,e in ipairs(OuroLootSV) do
841 if e.kind == 'boss' then
842 e.maxsize, e.raiderlist, e.raidersnap = 0, nil, {}
843 end
844 end
845 OuroLootSV.raiders = OuroLootSV.raiders or {}
846 for name,r in pairs(OuroLootSV.raiders) do
847 r.subgroup = 0
848 end
849 end
850
851 bumpers[16] = function()
852 for i,e in ipairs(OuroLootSV) do
853 if e.kind == 'boss' then -- brown paper bag bugs
854 e.raidersnap = e.raidersnap or {}
855 e.maxsize = e.maxsize or 0
856 end
857 end
858 end
859
860 bumpers[17] = function()
861 for i,e in ipairs(OuroLootSV) do
862 if e.kind == 'loot' and e.is_heroic then
863 e.variant, e.is_heroic = 1, nil
864 -- Could try detecting any previous LFR loot here, but... gah
865 end
866 end
867 end
868
869 bumpers[18] = bumpers[16]
870 -- In the not-very-many days between 16 and 19, I managed to break
871 -- the exact same data in the exact same way. At least they're
872 -- not actually running the same loop twice... probably... sigh.
873
874 bumpers[19] = function()
875 local date = _G.date
876 for i,e in ipairs(OuroLootSV) do
877 if e.kind == 'loot' then
878 if e.history_unique then
879 e.unique, e.history_unique = e.history_unique, nil
880 end
881 if e.unique == nil or #e.unique == 0 then
882 e.unique = e.id .. e.person .. date("%Y/%m/%d %H:%M",e.stamp)
883 end
884 end
885 end
886 end
887 790
888 --[===[ 791 --[===[
889 local real = bumpers 792 local real = bumpers
890 bumpers = newproxy(true) 793 bumpers = newproxy(true)
891 local mt = getmetatable(bumpers) 794 local mt = getmetatable(bumpers)
1118 ------ Event handlers 1021 ------ Event handlers
1119 function addon:_clear_SVs() 1022 function addon:_clear_SVs()
1120 g_loot = {} -- not saved, just fooling PLAYER_LOGOUT tests 1023 g_loot = {} -- not saved, just fooling PLAYER_LOGOUT tests
1121 _G.OuroLootSV = nil 1024 _G.OuroLootSV = nil
1122 _G.OuroLootSV_saved = nil 1025 _G.OuroLootSV_saved = nil
1123 _G.OuroLootSV_opts = nil 1026 _G.OuroLootOptsDB = nil
1124 _G.OuroLootSV_hist = nil 1027 _G.OuroLootSV_hist = nil
1125 _G.OuroLootSV_log = nil 1028 _G.OuroLootSV_log = nil
1126 _G.ReloadUI() 1029 _G.ReloadUI()
1127 end 1030 end
1128 function addon:PLAYER_LOGOUT() 1031 function addon:PLAYER_LOGOUT()