Mercurial > wow > ouroloot
comparison core.lua @ 93:ea20a28327b5
More tweaks in preparation for MoP.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Wed, 18 Jul 2012 07:42:16 +0000 |
parents | 01cfbfa96dd6 |
children | db1d5d09e5f5 |
comparison
equal
deleted
inserted
replaced
92:01cfbfa96dd6 | 93:ea20a28327b5 |
---|---|
325 -- Class color support. Do the expensive string.format calls up front, and | 325 -- Class color support. Do the expensive string.format calls up front, and |
326 -- the cheap all-string-all-at-once single-op concatenation as needed. | 326 -- the cheap all-string-all-at-once single-op concatenation as needed. |
327 do | 327 do |
328 local cc = {} | 328 local cc = {} |
329 local function extract (color_info) | 329 local function extract (color_info) |
330 local hex = ("|cff%.2x%.2x%.2x"):format(255*color_info.r, | 330 local hex |
331 255*color_info.g, 255*color_info.b) | 331 if color_info.colorStr then -- MoP |
332 hex = "|c" .. color_info.colorStr | |
333 else -- pre-MoP | |
334 hex = ("|cff%.2x%.2x%.2x"):format(255*color_info.r, | |
335 255*color_info.g, 255*color_info.b) | |
336 end | |
332 return { r=color_info.r, g=color_info.g, b=color_info.b, a=1, hex=hex } | 337 return { r=color_info.r, g=color_info.g, b=color_info.b, a=1, hex=hex } |
333 end | 338 end |
334 local function fill_out_class_colors() | 339 local function fill_out_class_colors() |
335 for class,color in pairs(CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS) do | 340 for class,color in pairs(CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS) do |
336 cc[class] = extract(color) | 341 cc[class] = extract(color) |
338 cc.DEFAULT = extract(_G.NORMAL_FONT_COLOR) | 343 cc.DEFAULT = extract(_G.NORMAL_FONT_COLOR) |
339 end | 344 end |
340 if CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS.RegisterCallback then | 345 if CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS.RegisterCallback then |
341 CUSTOM_CLASS_COLORS:RegisterCallback(fill_out_class_colors) | 346 CUSTOM_CLASS_COLORS:RegisterCallback(fill_out_class_colors) |
342 end | 347 end |
343 fill_out_class_colors() | 348 addon.class_colors = cc -- this stays around |
344 addon.class_colors = cc | 349 addon.fill_out_class_colors = fill_out_class_colors -- this doesn't |
350 | |
345 -- What I really want is to have the hooked :Print understand a special | 351 -- What I really want is to have the hooked :Print understand a special |
346 -- format specifier like "%Cs" and do the colorizing automatically. | 352 -- format specifier like "%Cs" and do the colorizing automatically. |
347 function addon:colorize (text, class) | 353 function addon:colorize (text, class) |
348 return ((class and cc[class]) or cc.DEFAULT).hex .. text .. "|r" | 354 return ((class and cc[class]) or cc.DEFAULT).hex .. text .. "|r" |
349 end | 355 end |
377 local wipe = _G.table.wipe | 383 local wipe = _G.table.wipe |
378 | 384 |
379 local pprint, tabledump = addon.pprint, flib.tabledump | 385 local pprint, tabledump = addon.pprint, flib.tabledump |
380 local CopyTable = _G.CopyTable | 386 local CopyTable = _G.CopyTable |
381 local GetNumRaidMembers = _G.GetNumGroupMembers or _G.GetNumRaidMembers | 387 local GetNumRaidMembers = _G.GetNumGroupMembers or _G.GetNumRaidMembers |
388 local IsInRaid = _G.IsInRaid or (function() return GetNumRaidMembers() > 0 end) | |
382 -- En masse forward decls of symbols defined inside local blocks | 389 -- En masse forward decls of symbols defined inside local blocks |
383 local _register_bossmod, makedate, create_new_cache, _init, _log | 390 local _register_bossmod, makedate, create_new_cache, _init, _log |
384 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision | 391 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision |
385 local _notify_about_change, _notify_about_remote | 392 local _notify_about_change, _notify_about_remote |
386 | 393 |
499 if typeof == "none" then return name, MAX_RAID_MEMBERS end | 506 if typeof == "none" then return name, MAX_RAID_MEMBERS end |
500 -- diffstr is "5 Player", "10 Player (Heroic)", etc. ugh. | 507 -- diffstr is "5 Player", "10 Player (Heroic)", etc. ugh. |
501 if (GetLFGMode()) and (GetLFGModeType() == 'raid') then | 508 if (GetLFGMode()) and (GetLFGModeType() == 'raid') then |
502 t,r = 'LFR', 25 | 509 t,r = 'LFR', 25 |
503 elseif diffcode == 1 then | 510 elseif diffcode == 1 then |
504 if GetNumRaidMembers() > 0 then | 511 if IsInRaid() then |
505 t,r = "10",10 | 512 t,r = "10",10 |
506 else | 513 else |
507 t,r = "5",5 | 514 t,r = "5",5 |
508 end | 515 end |
509 elseif diffcode == 2 then | 516 elseif diffcode == 2 then |
510 if GetNumRaidMembers() > 0 then | 517 if IsInRaid() then |
511 t,r = "25",25 | 518 t,r = "25",25 |
512 else | 519 else |
513 t,r = "5h",5 | 520 t,r = "5h",5 |
514 end | 521 end |
515 elseif diffcode == 3 then | 522 elseif diffcode == 3 then |
916 return AC:Print (frame, chat_prefix_s, str, ...) | 923 return AC:Print (frame, chat_prefix_s, str, ...) |
917 end | 924 end |
918 end | 925 end |
919 end | 926 end |
920 | 927 |
928 -- Copy these over once, now that other addons have mostly loaded. Any | |
929 -- future tweaks via CUSTOM_CLASS_COLORS will trigger the same callback. | |
930 if addon.fill_out_class_colors then | |
931 addon.fill_out_class_colors() | |
932 addon.fill_out_class_colors = nil | |
933 end | |
934 | |
921 while opts.keybinding do | 935 while opts.keybinding do |
922 if InCombatLockdown() then | 936 if InCombatLockdown() then |
923 local reload = self.format_hypertext ([[the options tab]], | 937 local reload = self.format_hypertext ([[the options tab]], |
924 ITEM_QUALITY_UNCOMMON, 'opt') | 938 ITEM_QUALITY_UNCOMMON, 'opt') |
925 self:Print("Cannot create '%s' as a keybinding while in combat!", | 939 self:Print("Cannot create '%s' as a keybinding while in combat!", |
1709 self.dprint('flow', ":Activate is running") | 1723 self.dprint('flow', ":Activate is running") |
1710 self:RegisterEvent(RAID_ROSTER_UPDATE_EVENT,"RAID_ROSTER_UPDATE") | 1724 self:RegisterEvent(RAID_ROSTER_UPDATE_EVENT,"RAID_ROSTER_UPDATE") |
1711 self:RegisterEvent("PLAYER_ENTERING_WORLD", | 1725 self:RegisterEvent("PLAYER_ENTERING_WORLD", |
1712 function() self:ScheduleTimer("RAID_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end) | 1726 function() self:ScheduleTimer("RAID_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end) |
1713 self.popped = true | 1727 self.popped = true |
1714 if GetNumRaidMembers() > 0 then | 1728 if IsInRaid() then |
1715 self.dprint('flow', ">:Activate calling RRU") | 1729 self.dprint('flow', ">:Activate calling RRU") |
1716 self:RAID_ROSTER_UPDATE("Activate") | 1730 self:RAID_ROSTER_UPDATE("Activate") |
1717 elseif self.debug.notraid then | 1731 elseif self.debug.notraid then |
1718 self.dprint('flow', ">:(notraid) Activate registering loot and bossmods") | 1732 self.dprint('flow', ">:(notraid) Activate registering loot and bossmods") |
1719 self:RegisterEvent("CHAT_MSG_LOOT") | 1733 self:RegisterEvent("CHAT_MSG_LOOT") |
1923 self:broadcast('ping') | 1937 self:broadcast('ping') |
1924 self:broadcast('revcheck',version_large) | 1938 self:broadcast('revcheck',version_large) |
1925 end | 1939 end |
1926 | 1940 |
1927 function addon:_check_version (otherrev) | 1941 function addon:_check_version (otherrev) |
1928 self.dprint('comm', "revchecking against", otherrev) | 1942 self.dprint('comm', version_large, "revchecking against", otherrev) |
1929 otherrev = tonumber(otherrev) | 1943 otherrev = tonumber(otherrev) |
1930 if otherrev == version_large then | 1944 if otherrev == version_large then |
1931 -- normal case | 1945 -- normal case |
1932 | 1946 |
1933 elseif otherrev < version_large then | 1947 elseif otherrev < version_large then |