Mercurial > wow > ouroloot
diff 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 |
line wrap: on
line diff
--- a/core.lua Sun Aug 19 22:08:17 2012 -0400 +++ b/core.lua Wed Aug 22 23:37:24 2012 -0400 @@ -396,7 +396,7 @@ -- En masse forward decls of symbols defined inside local blocks local _register_bossmod, makedate, create_new_cache, _init, _log, _do_loot_metas local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision -local _notify_about_change, _LFR_suppressing +local _notify_about_change, _LFR_suppressing, _add_loot_disposition -- Try to extract numbers from the .toc "Version" and munge them into an -- integral form for comparison. The result doesn't need to be meaningful as @@ -999,17 +999,16 @@ text_notes, opt_text_menu (uses notes if nil), opt_tooltip_txt, can_reassign_p, do_history_p, from_notes_text_p ]] - local norm = self:_add_loot_disposition ('normal', "ff","ff","ff", "", "normal", + local norm = _add_loot_disposition (self, 'normal', "ff","ff","ff", "", "normal/mainspec", [[This is the default. Selecting any 'Mark as <x>' action blanks out extra notes about who broadcast this entry, etc.]], true, true, false) - self:_add_loot_disposition ('offspec', "c6","9b","6d", "offspec", nil, nil, + _add_loot_disposition (self, 'offspec', "c6","9b","6d", "offspec", nil, nil, true, true, true) - self:_add_loot_disposition ('shard', "a3","35","ee", "shard", + _add_loot_disposition (self, 'shard', "a3","35","ee", "shard", "disenchanted", nil, false, false, true) - -- suddenly changing localization mid-phrase is horky, change this to a submenu: - self:_add_loot_disposition ('gvault', "33","ff","99", _G.GUILD_BANK:lower(), + _add_loot_disposition (self, 'gvault', "33","ff","99", _G.GUILD_BANK:lower(), nil, nil, false, false, true) - -- fix up the odd (!) standard case of having a nil disposition field + -- fix up the odd(!) standard case of having a nil disposition field norm.arg2 = nil --[[ @@ -1058,6 +1057,7 @@ - opts: (OUT) Pointer to plugin's "db.profile" subtable. Inherited unchanged: + - _add_loot_disposition Inherited module variants: - OnInitialize, OnEnable @@ -1152,6 +1152,13 @@ end end + -- For references that would be nil at load time, and I don't feel like + -- rearranging the entire file. + function addon:MODULE_PROTOTYPE_POINTERS() + prototype.add_loot_disposition = _add_loot_disposition + self.MODULE_PROTOTYPE_POINTERS = nil + end + addon:SetDefaultModuleLibraries("AceConsole-3.0") addon:SetDefaultModulePrototype(prototype) @@ -1203,15 +1210,18 @@ New row in primary EOI table of kind=='boss'. Includes all 'NewBoss' occasions, plus manual boss additions, testing, etc. Arg same as NewBoss. -'NewLootEntry', loot +'NewLootEntry', loot, row_index 'DelLootEntry', loot New or removed row in primary EOI table of kind=='loot'. Argument is a - g_loot table entry of kind=='loot'. - -'NewEOIEntry', entry + g_loot table entry of kind=='loot', and the index into g_loot of where + the entry "is" (read: "will be" by the time the event fires). + +'NewEOIEntry', entry, row_index 'DelEOIEntry', entry New or removed row in primary EOI table, of any kind. Argument is the - g_loot entry, already inserted into or removed from g_loot. + g_loot entry, already inserted into or removed from g_loot. Note that + boss entries may shift around after this event (if loot has happened and + needs to be re-sorted). 'NewHistory', player_name, uniqueID 'DelHistory', player_name, uniqueID @@ -2665,15 +2675,15 @@ e.hour = h e.minute = m e.stamp = time_t --localuptime + local index = #g_loot + 1 if e.kind == 'loot' then if (not e.unique) or (#e.unique==0) then e.unique = e.id .. (e.disposition or e.person) .. date("%Y/%m/%d %H:%M",e.stamp) end - addon:Fire ('NewLootEntry', e) + addon:Fire ('NewLootEntry', e, index) end - local index = #g_loot + 1 g_loot[index] = e - addon:Fire ('NewEOIEntry', e) + addon:Fire ('NewEOIEntry', e, index) return index end @@ -2690,7 +2700,7 @@ if needSnap then e.raidersnap = ss end if needInst then e.instance = inst end end - addon:Fire ('NewBossEntry', e) + addon:Fire ('NewBossEntry', e, ret) return ret end @@ -2754,7 +2764,7 @@ return next, r end - function addon:_add_loot_disposition (code, rhex, ghex, bhex, text_notes, + function _add_loot_disposition (self, code, rhex, ghex, bhex, text_notes, text_menu, tooltip_txt, can_reassign_p, do_history_p, from_notes_text_p ) assert(type(code)=='string' and #code>0) @@ -2763,7 +2773,7 @@ assert(type(bhex)=='string') assert(type(ghex)=='string') - self.disposition_colors[code] = { + addon.disposition_colors[code] = { text = text_notes, -- for chat output by core code hex = "|cff" .. rhex .. ghex .. bhex, @@ -2782,8 +2792,13 @@ from_notes_text = not not from_notes_text_p, } - return g_gui.add_dropdown_entry ('eoi_loot', "Mark as "..(text_menu or text_notes), + local dd = g_gui.add_dropdown_entry ('eoi_loot_mark', text_menu or text_notes, --[[function_table=]]nil, 'df_DISPOSITION', code, tooltip_txt) + dd.colorCode = addon.disposition_colors[code].hex + addon.dprint('flow', ("Source '%s' adds loot disposition '%s', flags"): + format(self.name or tostring(self), code), + can_reassign_p, do_history_p, from_notes_text_p) + return dd end end @@ -3662,8 +3677,8 @@ -- This is not entirely "history" but not completely anything else either. -- Handles the primary "Mark as <x>" action. Arguments depend on who's -- calling it: - -- "local", row_index, new_disposition - -- "remote", sender, unique_id, item_id, old_disposition, new_disposition + -- 'local', row_index, new_disposition + -- 'remote', sender, unique_id, item_id, old_disposition, new_disposition -- In the local case, must also broadcast a trigger. In the remote case, -- must figure out the corresponding loot entry (if it exists). In both -- cases, must update history appropriately. Returns nil if anything odd @@ -3675,7 +3690,7 @@ -- Only set in remote case: local sender - if how == "local" then + if how == 'local' then index, newdisp = ... index = assert(tonumber(index)) e = g_loot[index] @@ -3683,7 +3698,7 @@ unique = e.unique -- can potentially still be nil at this step olddisp = e.disposition - elseif how == "remote" then + elseif how == 'remote' then sender, unique, id, olddisp, newdisp = ... id = tonumber(id) local cache @@ -3726,7 +3741,7 @@ self.hist_clean = nil self.loot_clean = nil -- A unique tag has been set by this point. - if how == "local" then + if how == 'local' then unique = assert(e.unique) if opts.chatty_on_local_changes then _notify_about_change (_G.UNIT_YOU, index, olddisp) @@ -3949,5 +3964,6 @@ end end +addon:MODULE_PROTOTYPE_POINTERS() addon.FILES_LOADED = 1 -- vim:noet