Mercurial > wow > ouroloot
comparison core.lua @ 128:dc39ce56a62d
- Adding new loot dispositions requires plugin module.
- 'NewLootEntry' and 'NewEOIEntry' events also take a row index. (Hmmm)
- Loot disposition options broken out into a submenu, and use the same
color their notes text do. Toggle a checkbox for the current value.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Wed, 22 Aug 2012 23:37:24 -0400 |
parents | a9cf9b2fbf9b |
children | 2731702567c4 |
comparison
equal
deleted
inserted
replaced
127:c6d8e096296e | 128:dc39ce56a62d |
---|---|
394 local GetNumRaidMembers = GetNumGroupMembers or GetNumRaidMembers | 394 local GetNumRaidMembers = GetNumGroupMembers or GetNumRaidMembers |
395 local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end) | 395 local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end) |
396 -- En masse forward decls of symbols defined inside local blocks | 396 -- En masse forward decls of symbols defined inside local blocks |
397 local _register_bossmod, makedate, create_new_cache, _init, _log, _do_loot_metas | 397 local _register_bossmod, makedate, create_new_cache, _init, _log, _do_loot_metas |
398 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision | 398 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision |
399 local _notify_about_change, _LFR_suppressing | 399 local _notify_about_change, _LFR_suppressing, _add_loot_disposition |
400 | 400 |
401 -- Try to extract numbers from the .toc "Version" and munge them into an | 401 -- Try to extract numbers from the .toc "Version" and munge them into an |
402 -- integral form for comparison. The result doesn't need to be meaningful as | 402 -- integral form for comparison. The result doesn't need to be meaningful as |
403 -- long as we can reliably feed two of them to "<" and get useful answers. | 403 -- long as we can reliably feed two of them to "<" and get useful answers. |
404 -- | 404 -- |
997 | 997 |
998 Args: code, rhex, ghex, bhex, | 998 Args: code, rhex, ghex, bhex, |
999 text_notes, opt_text_menu (uses notes if nil), opt_tooltip_txt, | 999 text_notes, opt_text_menu (uses notes if nil), opt_tooltip_txt, |
1000 can_reassign_p, do_history_p, from_notes_text_p | 1000 can_reassign_p, do_history_p, from_notes_text_p |
1001 ]] | 1001 ]] |
1002 local norm = self:_add_loot_disposition ('normal', "ff","ff","ff", "", "normal", | 1002 local norm = _add_loot_disposition (self, 'normal', "ff","ff","ff", "", "normal/mainspec", |
1003 [[This is the default. Selecting any 'Mark as <x>' action blanks out extra notes about who broadcast this entry, etc.]], | 1003 [[This is the default. Selecting any 'Mark as <x>' action blanks out extra notes about who broadcast this entry, etc.]], |
1004 true, true, false) | 1004 true, true, false) |
1005 self:_add_loot_disposition ('offspec', "c6","9b","6d", "offspec", nil, nil, | 1005 _add_loot_disposition (self, 'offspec', "c6","9b","6d", "offspec", nil, nil, |
1006 true, true, true) | 1006 true, true, true) |
1007 self:_add_loot_disposition ('shard', "a3","35","ee", "shard", | 1007 _add_loot_disposition (self, 'shard', "a3","35","ee", "shard", |
1008 "disenchanted", nil, false, false, true) | 1008 "disenchanted", nil, false, false, true) |
1009 -- suddenly changing localization mid-phrase is horky, change this to a submenu: | 1009 _add_loot_disposition (self, 'gvault', "33","ff","99", _G.GUILD_BANK:lower(), |
1010 self:_add_loot_disposition ('gvault', "33","ff","99", _G.GUILD_BANK:lower(), | |
1011 nil, nil, false, false, true) | 1010 nil, nil, false, false, true) |
1012 -- fix up the odd (!) standard case of having a nil disposition field | 1011 -- fix up the odd(!) standard case of having a nil disposition field |
1013 norm.arg2 = nil | 1012 norm.arg2 = nil |
1014 | 1013 |
1015 --[[ | 1014 --[[ |
1016 Stick something in the Blizzard addons options list, where most users | 1015 Stick something in the Blizzard addons options list, where most users |
1017 will probably look these days. Try to be conservative about needless | 1016 will probably look these days. Try to be conservative about needless |
1056 - option_defaults: (IN) Standard AceDB-style table. Use a profiles key! | 1055 - option_defaults: (IN) Standard AceDB-style table. Use a profiles key! |
1057 - db: (OUT) AceDB object, set during init. | 1056 - db: (OUT) AceDB object, set during init. |
1058 - opts: (OUT) Pointer to plugin's "db.profile" subtable. | 1057 - opts: (OUT) Pointer to plugin's "db.profile" subtable. |
1059 | 1058 |
1060 Inherited unchanged: | 1059 Inherited unchanged: |
1060 - _add_loot_disposition | |
1061 | 1061 |
1062 Inherited module variants: | 1062 Inherited module variants: |
1063 - OnInitialize, OnEnable | 1063 - OnInitialize, OnEnable |
1064 - register_text_generator, register_tab_control: also flag plugin as | 1064 - register_text_generator, register_tab_control: also flag plugin as |
1065 a text-generating module in main addon | 1065 a text-generating module in main addon |
1150 else | 1150 else |
1151 return AC:Print (ps, str, ...) | 1151 return AC:Print (ps, str, ...) |
1152 end | 1152 end |
1153 end | 1153 end |
1154 | 1154 |
1155 -- For references that would be nil at load time, and I don't feel like | |
1156 -- rearranging the entire file. | |
1157 function addon:MODULE_PROTOTYPE_POINTERS() | |
1158 prototype.add_loot_disposition = _add_loot_disposition | |
1159 self.MODULE_PROTOTYPE_POINTERS = nil | |
1160 end | |
1161 | |
1155 addon:SetDefaultModuleLibraries("AceConsole-3.0") | 1162 addon:SetDefaultModuleLibraries("AceConsole-3.0") |
1156 addon:SetDefaultModulePrototype(prototype) | 1163 addon:SetDefaultModulePrototype(prototype) |
1157 | 1164 |
1158 local err = [[Module '%s' cannot register itself because it failed a required condition: '%s']] | 1165 local err = [[Module '%s' cannot register itself because it failed a required condition: '%s']] |
1159 function addon:ConstrainedNewModule (modname, minrev, mincomm, mindata) | 1166 function addon:ConstrainedNewModule (modname, minrev, mincomm, mindata) |
1201 | 1208 |
1202 'NewBossEntry', boss | 1209 'NewBossEntry', boss |
1203 New row in primary EOI table of kind=='boss'. Includes all 'NewBoss' | 1210 New row in primary EOI table of kind=='boss'. Includes all 'NewBoss' |
1204 occasions, plus manual boss additions, testing, etc. Arg same as NewBoss. | 1211 occasions, plus manual boss additions, testing, etc. Arg same as NewBoss. |
1205 | 1212 |
1206 'NewLootEntry', loot | 1213 'NewLootEntry', loot, row_index |
1207 'DelLootEntry', loot | 1214 'DelLootEntry', loot |
1208 New or removed row in primary EOI table of kind=='loot'. Argument is a | 1215 New or removed row in primary EOI table of kind=='loot'. Argument is a |
1209 g_loot table entry of kind=='loot'. | 1216 g_loot table entry of kind=='loot', and the index into g_loot of where |
1210 | 1217 the entry "is" (read: "will be" by the time the event fires). |
1211 'NewEOIEntry', entry | 1218 |
1219 'NewEOIEntry', entry, row_index | |
1212 'DelEOIEntry', entry | 1220 'DelEOIEntry', entry |
1213 New or removed row in primary EOI table, of any kind. Argument is the | 1221 New or removed row in primary EOI table, of any kind. Argument is the |
1214 g_loot entry, already inserted into or removed from g_loot. | 1222 g_loot entry, already inserted into or removed from g_loot. Note that |
1223 boss entries may shift around after this event (if loot has happened and | |
1224 needs to be re-sorted). | |
1215 | 1225 |
1216 'NewHistory', player_name, uniqueID | 1226 'NewHistory', player_name, uniqueID |
1217 'DelHistory', player_name, uniqueID | 1227 'DelHistory', player_name, uniqueID |
1218 New or removed entry in player history. Name argument self-explanatory. | 1228 New or removed entry in player history. Name argument self-explanatory. |
1219 ID is the corresponding loot, already inserted into or removed from the | 1229 ID is the corresponding loot, already inserted into or removed from the |
2663 --local localuptime = math.floor(GetTime()) | 2673 --local localuptime = math.floor(GetTime()) |
2664 local time_t = time() | 2674 local time_t = time() |
2665 e.hour = h | 2675 e.hour = h |
2666 e.minute = m | 2676 e.minute = m |
2667 e.stamp = time_t --localuptime | 2677 e.stamp = time_t --localuptime |
2678 local index = #g_loot + 1 | |
2668 if e.kind == 'loot' then | 2679 if e.kind == 'loot' then |
2669 if (not e.unique) or (#e.unique==0) then | 2680 if (not e.unique) or (#e.unique==0) then |
2670 e.unique = e.id .. (e.disposition or e.person) .. date("%Y/%m/%d %H:%M",e.stamp) | 2681 e.unique = e.id .. (e.disposition or e.person) .. date("%Y/%m/%d %H:%M",e.stamp) |
2671 end | 2682 end |
2672 addon:Fire ('NewLootEntry', e) | 2683 addon:Fire ('NewLootEntry', e, index) |
2673 end | 2684 end |
2674 local index = #g_loot + 1 | |
2675 g_loot[index] = e | 2685 g_loot[index] = e |
2676 addon:Fire ('NewEOIEntry', e) | 2686 addon:Fire ('NewEOIEntry', e, index) |
2677 return index | 2687 return index |
2678 end | 2688 end |
2679 | 2689 |
2680 -- Safety/convenience wrapper only. | 2690 -- Safety/convenience wrapper only. |
2681 function addon._addBossEntry (e) | 2691 function addon._addBossEntry (e) |
2688 local ss, max, inst = addon:snapshot_raid() | 2698 local ss, max, inst = addon:snapshot_raid() |
2689 if needSize then e.maxsize = max end | 2699 if needSize then e.maxsize = max end |
2690 if needSnap then e.raidersnap = ss end | 2700 if needSnap then e.raidersnap = ss end |
2691 if needInst then e.instance = inst end | 2701 if needInst then e.instance = inst end |
2692 end | 2702 end |
2693 addon:Fire ('NewBossEntry', e) | 2703 addon:Fire ('NewBossEntry', e, ret) |
2694 return ret | 2704 return ret |
2695 end | 2705 end |
2696 | 2706 |
2697 -- Problem: (1) boss kill happens, (2) fast looting happens, (3) boss | 2707 -- Problem: (1) boss kill happens, (2) fast looting happens, (3) boss |
2698 -- cache cleanup fires. Result: loot shows up before boss kill entry. | 2708 -- cache cleanup fires. Result: loot shows up before boss kill entry. |
2752 end | 2762 end |
2753 end | 2763 end |
2754 return next, r | 2764 return next, r |
2755 end | 2765 end |
2756 | 2766 |
2757 function addon:_add_loot_disposition (code, rhex, ghex, bhex, text_notes, | 2767 function _add_loot_disposition (self, code, rhex, ghex, bhex, text_notes, |
2758 text_menu, tooltip_txt, can_reassign_p, do_history_p, from_notes_text_p | 2768 text_menu, tooltip_txt, can_reassign_p, do_history_p, from_notes_text_p |
2759 ) | 2769 ) |
2760 assert(type(code)=='string' and #code>0) | 2770 assert(type(code)=='string' and #code>0) |
2761 assert(type(text_notes)=='string') | 2771 assert(type(text_notes)=='string') |
2762 assert(type(rhex)=='string') | 2772 assert(type(rhex)=='string') |
2763 assert(type(bhex)=='string') | 2773 assert(type(bhex)=='string') |
2764 assert(type(ghex)=='string') | 2774 assert(type(ghex)=='string') |
2765 | 2775 |
2766 self.disposition_colors[code] = { | 2776 addon.disposition_colors[code] = { |
2767 text = text_notes, | 2777 text = text_notes, |
2768 -- for chat output by core code | 2778 -- for chat output by core code |
2769 hex = "|cff" .. rhex .. ghex .. bhex, | 2779 hex = "|cff" .. rhex .. ghex .. bhex, |
2770 -- for lib-st | 2780 -- for lib-st |
2771 r = tonumber(rhex,16)/255, | 2781 r = tonumber(rhex,16)/255, |
2780 can_reassign = not not can_reassign_p, | 2790 can_reassign = not not can_reassign_p, |
2781 affects_history = not not do_history_p, | 2791 affects_history = not not do_history_p, |
2782 from_notes_text = not not from_notes_text_p, | 2792 from_notes_text = not not from_notes_text_p, |
2783 } | 2793 } |
2784 | 2794 |
2785 return g_gui.add_dropdown_entry ('eoi_loot', "Mark as "..(text_menu or text_notes), | 2795 local dd = g_gui.add_dropdown_entry ('eoi_loot_mark', text_menu or text_notes, |
2786 --[[function_table=]]nil, 'df_DISPOSITION', code, tooltip_txt) | 2796 --[[function_table=]]nil, 'df_DISPOSITION', code, tooltip_txt) |
2797 dd.colorCode = addon.disposition_colors[code].hex | |
2798 addon.dprint('flow', ("Source '%s' adds loot disposition '%s', flags"): | |
2799 format(self.name or tostring(self), code), | |
2800 can_reassign_p, do_history_p, from_notes_text_p) | |
2801 return dd | |
2787 end | 2802 end |
2788 end | 2803 end |
2789 | 2804 |
2790 -- In the rare case of items getting put into the loot table without current | 2805 -- In the rare case of items getting put into the loot table without current |
2791 -- item cache data (which will have arrived by now). | 2806 -- item cache data (which will have arrived by now). |
3660 end | 3675 end |
3661 | 3676 |
3662 -- This is not entirely "history" but not completely anything else either. | 3677 -- This is not entirely "history" but not completely anything else either. |
3663 -- Handles the primary "Mark as <x>" action. Arguments depend on who's | 3678 -- Handles the primary "Mark as <x>" action. Arguments depend on who's |
3664 -- calling it: | 3679 -- calling it: |
3665 -- "local", row_index, new_disposition | 3680 -- 'local', row_index, new_disposition |
3666 -- "remote", sender, unique_id, item_id, old_disposition, new_disposition | 3681 -- 'remote', sender, unique_id, item_id, old_disposition, new_disposition |
3667 -- In the local case, must also broadcast a trigger. In the remote case, | 3682 -- In the local case, must also broadcast a trigger. In the remote case, |
3668 -- must figure out the corresponding loot entry (if it exists). In both | 3683 -- must figure out the corresponding loot entry (if it exists). In both |
3669 -- cases, must update history appropriately. Returns nil if anything odd | 3684 -- cases, must update history appropriately. Returns nil if anything odd |
3670 -- happens (not necessarily an error!); returns the affected loot index | 3685 -- happens (not necessarily an error!); returns the affected loot index |
3671 -- on success. | 3686 -- on success. |
3673 -- This must all be filled out in all cases: | 3688 -- This must all be filled out in all cases: |
3674 local e, index, olddisp, newdisp, unique, id | 3689 local e, index, olddisp, newdisp, unique, id |
3675 -- Only set in remote case: | 3690 -- Only set in remote case: |
3676 local sender | 3691 local sender |
3677 | 3692 |
3678 if how == "local" then | 3693 if how == 'local' then |
3679 index, newdisp = ... | 3694 index, newdisp = ... |
3680 index = assert(tonumber(index)) | 3695 index = assert(tonumber(index)) |
3681 e = g_loot[index] | 3696 e = g_loot[index] |
3682 id = e.id | 3697 id = e.id |
3683 unique = e.unique -- can potentially still be nil at this step | 3698 unique = e.unique -- can potentially still be nil at this step |
3684 olddisp = e.disposition | 3699 olddisp = e.disposition |
3685 | 3700 |
3686 elseif how == "remote" then | 3701 elseif how == 'remote' then |
3687 sender, unique, id, olddisp, newdisp = ... | 3702 sender, unique, id, olddisp, newdisp = ... |
3688 id = tonumber(id) | 3703 id = tonumber(id) |
3689 local cache | 3704 local cache |
3690 local loop = 0 | 3705 local loop = 0 |
3691 repeat -- wtb continue statement pst | 3706 repeat -- wtb continue statement pst |
3724 e.extratext = nil | 3739 e.extratext = nil |
3725 self:history_handle_disposition (index, olddisp) | 3740 self:history_handle_disposition (index, olddisp) |
3726 self.hist_clean = nil | 3741 self.hist_clean = nil |
3727 self.loot_clean = nil | 3742 self.loot_clean = nil |
3728 -- A unique tag has been set by this point. | 3743 -- A unique tag has been set by this point. |
3729 if how == "local" then | 3744 if how == 'local' then |
3730 unique = assert(e.unique) | 3745 unique = assert(e.unique) |
3731 if opts.chatty_on_local_changes then | 3746 if opts.chatty_on_local_changes then |
3732 _notify_about_change (_G.UNIT_YOU, index, olddisp) | 3747 _notify_about_change (_G.UNIT_YOU, index, olddisp) |
3733 end | 3748 end |
3734 self:vbroadcast('mark', unique, id, olddisp, newdisp) | 3749 self:vbroadcast('mark', unique, id, olddisp, newdisp) |
3947 self.dprint('comm', ":OCRN from", sender, "message is", msg) | 3962 self.dprint('comm', ":OCRN from", sender, "message is", msg) |
3948 return dotdotdot(sender,strsplit('\a',msg)) | 3963 return dotdotdot(sender,strsplit('\a',msg)) |
3949 end | 3964 end |
3950 end | 3965 end |
3951 | 3966 |
3967 addon:MODULE_PROTOTYPE_POINTERS() | |
3952 addon.FILES_LOADED = 1 | 3968 addon.FILES_LOADED = 1 |
3953 -- vim:noet | 3969 -- vim:noet |