Mercurial > wow > ouroloot
changeset 109:ce45011fab4c
- Test for errors during startup before trying to manipulate data.
- Thin encapsulation around dispositions. Abstract everything except the
insertion into GUI dropdowns (that comes next).
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Wed, 08 Aug 2012 14:43:26 -0400 |
parents | 04ccd12c2a41 |
children | f93c1a93923b |
files | abbreviations.lua bossmods.lua core.lua gui.lua options.lua text_tabs.lua verbage.lua |
diffstat | 7 files changed, 133 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/abbreviations.lua Mon Aug 06 14:57:14 2012 -0400 +++ b/abbreviations.lua Wed Aug 08 14:43:26 2012 -0400 @@ -106,4 +106,5 @@ ["Valithria Dreamwalker"] = "Dreeeeaaamweaaaaaverrrr", } +addon.FILES_LOADED = addon.FILES_LOADED + 1 -- vim:noet
--- a/bossmods.lua Mon Aug 06 14:57:14 2012 -0400 +++ b/bossmods.lua Wed Aug 08 14:43:26 2012 -0400 @@ -124,4 +124,5 @@ -- DXE, BigWigs, etc, need to be researched for this too +addon.FILES_LOADED = addon.FILES_LOADED + 1 -- vim:noet
--- a/core.lua Mon Aug 06 14:57:14 2012 -0400 +++ b/core.lua Wed Aug 08 14:43:26 2012 -0400 @@ -64,7 +64,8 @@ - bcast_from player's name if received rebroadcast from that player; missing otherwise; can be deleted as a result of in-game fiddling of loot data -- extratext text in Note column, including disposition and rebroadcasting +- extratext text in Note column, including disposition and rebroadcasting; + missing otherwise - extratext_byhand true if text edited by player directly; missing otherwise @@ -260,7 +261,7 @@ if cond then return cond,msg,... else - error('ASSERT() FAILED: '..tostring(msg or 'nil')) + error('ASSERT() FAILED: '.._G.tostring(msg or 'nil'),3) end end @@ -308,6 +309,7 @@ SLASH_ACECONSOLE_OUROLOOT2 = nil self.error (msg, --[[level=]]2) end +addon.FILES_LOADED = 0 -- Seriously? ORLY? -- YARLY. Go ahead and guess what was involved in tracking this down. If @@ -724,6 +726,15 @@ _G.OL = self _G.g_uniques = g_uniques end + -- This kludgy-looking thing is because if there are serious errors in + -- loading, some of the actions during PLAYER_LOGOUT can destroy data. + if self.FILES_LOADED ~= 7 then + print('|cffaee3ffouroloot reports load count of',self.FILES_LOADED,'fml|r') + self:SetEnabledState(false) + return + end + self.FILES_LOADED = nil + _log = OuroLootSV_log -- VARIABLES_LOADED has fired by this point; test if we're doing something like @@ -1466,8 +1477,7 @@ candidates[sig] = nil local looti = addon._addLootEntry(loot) addon.dprint('loot', "entry", i, "was found, added at index", looti) - if (loot.disposition ~= 'shard') - and (loot.disposition ~= 'gvault') + if addon:_test_disposition (loot.disposition, 'affects_history') and (not addon.history_suppress) then addon:_addHistoryEntry(looti) @@ -1583,15 +1593,16 @@ if local_override then -- player is adding loot by hand, don't wait for network cache timeouts -- keep this sync'd with prefer_local_loots above - if i.extratext == 'shard' - or i.extratext == 'gvault' - or i.extratext == 'offspec' - then - i.disposition = i.extratext + if i.extratext then + for disp,text in self:_iter_dispositions('from_notes_text') do + if text == i.extratext then + i.disposition = disp + break + end + end end local looti = self._addLootEntry(i) - if (i.disposition ~= 'shard') - and (i.disposition ~= 'gvault') + if self:_test_disposition (i.disposition, 'affects_history') and (not self.history_suppress) then self:_addHistoryEntry(looti) @@ -1984,7 +1995,7 @@ else to_text = "normal" end - to_text = addon.disposition_colors[e.disposition or "normal"].hex + to_text = addon.disposition_colors[e.disposition].hex .. to_text .. "|r" end @@ -2551,6 +2562,75 @@ end end +-- Disposition control; more precisely, how various dispositions affect flow +-- and displays elsewhere. +do + local default = { + text = "", + hex = "|cffffffff", + r = 1.0, g = 1.0, b = 1.0, a = 1, + can_reassign = true, + affects_history = true, + from_notes_text = false, + } + local mt = { + __index = function (t,k) + -- don't point index directly at default, need to catch nils + return default + end, + } + local alldisps = setmetatable({}, mt) + addon.disposition_colors = setmetatable({}, mt) + + -- These two are clunky wrappers, probably rework this once gain some data. + function addon:_test_disposition (code, attrib) + return alldisps[code][attrib] + end + function addon:_iter_dispositions (attrib) + local r = {} + for code,disp in next, alldisps do + if disp.attrib then + r[code] = disp.text + end + end + return next, r + end + + function addon:_add_loot_disposition (code, rhex, ghex, bhex, text, + can_reassign_p, do_history_p, from_notes_text_p + ) + assert(type(code)=='string' and #code>0) + assert(type(text)=='string') + assert(type(rhex)=='string') + assert(type(bhex)=='string') + assert(type(ghex)=='string') + self.disposition_colors[code] = { + text = text, + -- for chat output by core code + hex = "|cff" .. rhex .. ghex .. bhex, + -- for lib-st + r = tonumber(rhex,16)/255, + g = tonumber(ghex,16)/255, + b = tonumber(bhex,16)/255, + a = 1, + } + -- not not = poor man's "toboolean", don't potentially hold arg + -- objects from garbage collection + alldisps[code] = { + text = text, + can_reassign = not not can_reassign_p, + affects_history = not not do_history_p, + from_notes_text = not not from_notes_text_p, + } + end + + -- reassign while tagged, affects history, copy from notes + addon:_add_loot_disposition ('normal', "ff","ff","ff", "", true, true, false) + addon:_add_loot_disposition ('offspec', "c6","9b","6d", "offspec", true, true, true) + addon:_add_loot_disposition ('shard', "a3","35","ee", "shard", false, false, true) + addon:_add_loot_disposition ('gvault', "33","ff","99", _G.GUILD_BANK:lower(), false, false, true) +end + -- In the rare case of items getting put into the loot table without current -- item cache data (which will have arrived by now). function addon:do_item_cache_fixup() @@ -2965,7 +3045,7 @@ local hmmm = rawget(g_uniques,e.unique) if hmmm then hmmm.loot = i - elseif e.disposition == 'shard' or e.disposition == 'gvault' then + elseif not self:_test_disposition (e.disposition, 'affects_history') then g_uniques[e.unique] = { loot = i, history = g_uniques.NOTFOUND } count = count + 1 else @@ -3367,7 +3447,7 @@ local name = e.person - if (newdisp == 'shard' or newdisp == 'gvault') then + if not self:_test_disposition (newdisp, 'affects_history') then local name_i, name_h, hist_i = _history_by_loot_id (e, "mark") -- remove history entry if it exists -- FIXME revist this and use expunge @@ -3382,7 +3462,7 @@ name_h.id[hist_u] = nil name_h.count[hist_u] = nil self.hist_clean = nil - elseif (olddisp == 'shard' or olddisp == 'gvault') then + elseif not self:_test_disposition (olddisp, 'affects_history') then -- Sharding a vault item, or giving the auto-sharder something to bank, -- etc, wouldn't necessarily have had a history entry to begin with. -- So this isn't treated as an error. @@ -3392,8 +3472,8 @@ return end - if (olddisp == 'shard' or olddisp == 'gvault') - and (newdisp == 'normal' or newdisp == 'offspec') + if (not self:_test_disposition (olddisp, 'affects_history')) + and self:_test_disposition (newdisp, 'affects_history') then local name_i, name_h = self:get_loot_history(name) @@ -3722,4 +3802,5 @@ end end +addon.FILES_LOADED = 1 -- vim:noet
--- a/gui.lua Mon Aug 06 14:57:14 2012 -0400 +++ b/gui.lua Wed Aug 08 14:43:26 2012 -0400 @@ -23,25 +23,9 @@ } eoi_st_otherrow_bgcolortable[""] = eoi_st_otherrow_bgcolortable["kill"] local eoi_st_otherrow_bgcolortable_default -local eoi_st_lootrow_col3_colortable = { - normal = { text = "", r = "ff", g = "ff", b = "ff" }, - shard = { text = "shard", r = "a3", g = "35", b = "ee" }, - offspec = { text = "offspec", r = "c6", g = "9b", b = "6d" }, - gvault = { text = "guild vault", r = "33", g = "ff", b = "99" }, -} -for k,v in pairs(eoi_st_lootrow_col3_colortable) do - -- for chat output by core code - v.hex = "|cff" .. v.r .. v.g .. v.b - -- for lib-st - v.r = tonumber(v.r,16)/255 - v.g = tonumber(v.g,16)/255 - v.b = tonumber(v.b,16)/255 - v.a = 1 -end -addon.disposition_colors = eoi_st_lootrow_col3_colortable +local eoi_st_lootrow_col3_colortable = addon.disposition_colors local function eoi_st_lootrow_col3_colortable_func (data, _, realrow) - local disp = data[realrow].disposition - return eoi_st_lootrow_col3_colortable[disp or 'normal'] + return eoi_st_lootrow_col3_colortable[data[realrow].disposition] end local time_column1_used_mt = { __index = { [2] = {value=""}, @@ -122,7 +106,7 @@ -- Working around this bug: -- http://forums.wowace.com/showpost.php?p=295202&postcount=31 -if false then -- XXX no longer needed? +if false then -- XXX no longer needed? test on mop beta local function fix_frame_level (level, ...) for i = 1, select("#", ...) do local button = select(i, ...) @@ -369,14 +353,15 @@ {} } -- This is horrible. Must do better. - if e.extratext then for k,v in pairs(eoi_st_lootrow_col3_colortable) do - if v.text == e.extratext then - e.disposition = k ~= 'normal' and k or nil - --e.extratext = nil, not feasible - break + if e.extratext then + for disp,text in self:_iter_dispositions('from_notes_text') do + if text == e.extratext then + e.disposition = disp + break + end end - end end - local ex = eoi_st_lootrow_col3_colortable[e.disposition or 'normal'].text + end + local ex = eoi_st_lootrow_col3_colortable[e.disposition].text if e.bcast_from and display_bcast_from and e.extratext then ex = e.extratext .. " (from " .. e.bcast_from .. ")" elseif e.bcast_from and display_bcast_from then @@ -993,7 +978,7 @@ eoi_dropdownfuncs["Insert new loot entry"] = eoi_dropdownfuncs.df_INSERT eoi_dropdownfuncs["Insert new boss kill event"] = eoi_dropdownfuncs.df_INSERT eoi_dropdownfuncs["Mark as disenchanted"] = eoi_dropdownfuncs["Mark as normal"] -eoi_dropdownfuncs["Mark as guild vault"] = eoi_dropdownfuncs["Mark as normal"] +eoi_dropdownfuncs["Mark as ".._G.GUILD_BANK:lower()] = eoi_dropdownfuncs["Mark as normal"] eoi_dropdownfuncs["Mark as offspec"] = eoi_dropdownfuncs["Mark as normal"] eoi_dropdownfuncs["Delete remaining entries for this boss"] = eoi_dropdownfuncs["Delete remaining entries for this day"] @@ -1021,7 +1006,7 @@ { "Mark as disenchanted%shard", "Mark as offspec%offspec", - "Mark as guild vault%gvault", + "Mark as ".._G.GUILD_BANK:lower().."%gvault", "Mark as normal|This is the default. Selecting any 'Mark as <x>' action blanks out extra notes about who broadcast this entry, etc.", "--", "Rebroadcast this loot entry|Sends this loot event, including special notes, as if it just happened.", @@ -1193,7 +1178,8 @@ end eoi_player_dropdown[2].menuList = gen_easymenu_table (raiders, {"Enter name...",CLOSE}, eoi_dropdownfuncs) - if e.disposition == 'shard' or e.disposition == 'gvault' then + + if not addon:_test_disposition (e.disposition, 'can_reassign') then eoi_player_dropdown[2].disabled = true eoi_player_dropdown[2].tooltipTitle = "Cannot Reassign" eoi_player_dropdown[2].tooltipText = "You must first mark this item as 'normal' or 'offspec' before reassignment." @@ -2701,4 +2687,5 @@ end end +addon.FILES_LOADED = addon.FILES_LOADED + 1 -- vim:noet
--- a/options.lua Mon Aug 06 14:57:14 2012 -0400 +++ b/options.lua Wed Aug 08 14:43:26 2012 -0400 @@ -974,4 +974,5 @@ end +addon.FILES_LOADED = addon.FILES_LOADED + 1 -- vim:noet
--- a/text_tabs.lua Mon Aug 06 14:57:14 2012 -0400 +++ b/text_tabs.lua Wed Aug 08 14:43:26 2012 -0400 @@ -61,17 +61,21 @@ local e = loot[i] if e.kind == 'loot' then - -- Assuming nobody names a toon "offspec" or "gvault" - -- 16Apr2011: armory finds 20 Gvaults and 77 Offspecs... hulk smash. - local disp = e.disposition or e.person - if disp == 'offspec' then - disp = e.person .. " " .. 'offspec' - elseif disp == 'gvault' then - --disp = "guild vault (".. e.person .. ")" - disp = "guild vault" + local destination = e.person + if e.disposition then + local disp = e.disposition + local disptext = addon:_test_disposition(disp,'text') + if disp == 'offspec' then + destination = e.person .. " " .. disptext + elseif disp == 'gvault' then + --destination = ("%s (%s)"):format(disptext,e.person) + destination = disptext + else + destination = disptext + end end if e.extratext_byhand then - disp = disp .. " -- " .. e.extratext + destination = destination .. " -- " .. e.extratext end if e.variant and not forum_warned_heroic then forum_warned_heroic = true @@ -80,7 +84,7 @@ local t = fmt:gsub('%$I', e.id) :gsub('%$N', e.itemname) :gsub('%$X', e.count or "") - :gsub('%$T', disp) + :gsub('%$T', destination) cache[#cache+1] = t elseif e.kind == 'boss' and e.reason == 'kill' then @@ -210,4 +214,5 @@ addon:register_text_generator ("attend", [[Attendance]], [[Attendance list for each kill]], att, att_specials) +addon.FILES_LOADED = addon.FILES_LOADED + 1 -- vim:noet