comparison Main.lua @ 424:d06d1716228d

Implemented new system using SHOW_LOOT_TOAST for currency data during chat-based loot recording.
author MMOSimca <MMOSimca@gmail.com>
date Wed, 07 Jan 2015 17:32:19 -0500
parents 0aac203792c2
children 5bd49f0b635c
comparison
equal deleted inserted replaced
423:0aac203792c2 424:d06d1716228d
1569 end 1569 end
1570 1570
1571 GenericLootUpdate("items") 1571 GenericLootUpdate("items")
1572 current_loot = nil 1572 current_loot = nil
1573 container_loot_toasting = true -- Do not count further loots until timer expires or another container is opened 1573 container_loot_toasting = true -- Do not count further loots until timer expires or another container is opened
1574 elseif loot_source and (loot_source == LOOT_SOURCE_ID_REDUNDANT) and chat_loot_timer_handle then
1575 local currency_texture = CurrencyLinkToTexture(item_link)
1576 if currency_texture and currency_texture ~= "" then
1577 local container_id = chat_loot_data.identifier -- For faster access, since this is going to be called 9 times in the next 3 lines
1578 -- Verify that we're still assigning data to the right items
1579 if container_id and (private.CONTAINER_ITEM_ID_LIST[container_id] ~= nil) then
1580 local currency_token = ("currency:%s"):format(currency_texture)
1581 Debug("%s: Captured currency for chat-based loot recording. %s X %d", event_name, currency_token, quantity)
1582 chat_loot_data.sources[container_id] = chat_loot_data.sources[container_id] or {}
1583 chat_loot_data.sources[container_id][currency_token] = (chat_loot_data.sources[container_id][currency_token] or 0) + quantity
1584 else -- If not, cancel the timer and wipe the loot table early
1585 Debug("%s: Canceled chat-based loot recording because we would have assigned the wrong loot!", event_name)
1586 ClearChatLootData()
1587 end
1588 else
1589 Debug("%s: Currency texture is nil, from currency link %s", event_name, item_link)
1590 end
1574 else 1591 else
1575 Debug("%s: NPC and Container are nil, storing loot toast data for 5 seconds.", event_name) 1592 Debug("%s: NPC and Container are nil, storing loot toast data for 5 seconds.", event_name)
1576 1593
1577 loot_toast_data = loot_toast_data or {} 1594 loot_toast_data = loot_toast_data or {}
1578 loot_toast_data[#loot_toast_data + 1] = { loot_type, item_link, quantity } 1595 loot_toast_data[#loot_toast_data + 1] = { loot_type, item_link, quantity }
1587 end 1604 end
1588 1605
1589 1606
1590 do 1607 do
1591 local CHAT_MSG_CURRENCY_UPDATE_FUNCS = { 1608 local CHAT_MSG_CURRENCY_UPDATE_FUNCS = {
1592 [AF.ITEM] = function(currency_texture, quantity)
1593 local container_id = chat_loot_data.identifier -- For faster access, since this is going to be called 9 times in the next 3 lines
1594 -- Verify that we're still assigning data to the right items
1595 if container_id and (private.CONTAINER_ITEM_ID_LIST[container_id] ~= nil) then
1596 Debug("CHAT_MSG_CURRENCY: AF.ITEM %s (%d)", currency_token, quantity)
1597 local currency_token = ("currency:%s"):format(currency_texture:match("[^\\]+$"):lower())
1598 chat_loot_data.sources[container_id] = chat_loot_data.sources[container_id] or {}
1599 chat_loot_data.sources[container_id][currency_token] = (chat_loot_data.sources[container_id][currency_token] or 0) + quantity
1600 else -- If not, cancel the timer and wipe the loot table early
1601 Debug("CHAT_MSG_CURRENCY: We would have assigned the wrong loot!")
1602 ClearChatLootData()
1603 end
1604 end,
1605 [AF.NPC] = function(currency_texture, quantity) 1609 [AF.NPC] = function(currency_texture, quantity)
1606 Debug("CHAT_MSG_CURRENCY: AF.NPC currency:%s (%d)", currency_texture, quantity) 1610 Debug("CHAT_MSG_CURRENCY: AF.NPC currency:%s (%d)", currency_texture, quantity)
1607 end, 1611 end,
1608 [AF.ZONE] = function(currency_texture, quantity) 1612 [AF.ZONE] = function(currency_texture, quantity)
1609 local currency_token = ("currency:%s"):format(currency_texture) 1613 local currency_token = ("currency:%s"):format(currency_texture)
1632 -- Set update category 1636 -- Set update category
1633 if current_action.spell_label == "FISHING" then 1637 if current_action.spell_label == "FISHING" then
1634 category = AF.ZONE 1638 category = AF.ZONE
1635 elseif raid_boss_id then 1639 elseif raid_boss_id then
1636 category = AF.NPC 1640 category = AF.NPC
1637 elseif chat_loot_timer_handle then
1638 category = AF.ITEM
1639 end 1641 end
1640 1642
1641 -- Take action based on update category 1643 -- Take action based on update category
1642 local update_func = CHAT_MSG_CURRENCY_UPDATE_FUNCS[category] 1644 local update_func = CHAT_MSG_CURRENCY_UPDATE_FUNCS[category]
1643 if not category or not update_func then 1645 if not category or not update_func then