diff Main.lua @ 4:24a1d78e2e8c

Trimmed out things which aren't quite needed yet and fixed some library path issues.
author James D. Callahan III <jcallahan@curse.com>
date Fri, 27 Apr 2012 21:25:14 -0500
parents a9b84f0d8235
children 59400bdcf95c
line wrap: on
line diff
--- a/Main.lua	Fri Apr 27 14:03:17 2012 -0500
+++ b/Main.lua	Fri Apr 27 21:25:14 2012 -0500
@@ -19,6 +19,7 @@
 local LibStub = _G.LibStub
 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0")
 
+local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate")
 
 -----------------------------------------------------------------------
 -- Local constants.
@@ -34,60 +35,21 @@
 
 
 local EVENT_MAPPING = {
-    --    ARTIFACT_COMPLETE = true,
-    --    ARTIFACT_HISTORY_READY = true,
-    --    AUCTION_HOUSE_SHOW = true,
-    --    BANKFRAME_OPENED = true,
-    --    BATTLEFIELDS_SHOW = true,
-    --    CHAT_MSG_ADDON = true,
-    --    CHAT_MSG_MONSTER_EMOTE = true,
-    --    CHAT_MSG_MONSTER_SAY = true,
-    --    CHAT_MSG_MONSTER_WHISPER = true,
-    --    CHAT_MSG_MONSTER_YELL = true,
-    --    CHAT_MSG_SYSTEM = true,
-    --    COMBAT_LOG_EVENT_UNFILTERED = true,
-    --    COMBAT_TEXT_UPDATE = true,
-    --    CONFIRM_BINDER = true,
-    --    CONFIRM_PET_UNLEARN = true,
-    --    CONFIRM_TALENT_WIPE = true,
-    --    CURRENCY_DISPLAY_UPDATE = true,
-    --    GOSSIP_ENTER_CODE = true,
-    --    GOSSIP_SHOW = true,
-    --    ITEM_TEXT_BEGIN = true,
-    --    LOCALPLAYER_PET_RENAMED = true,
-    --    LOOT_CLOSED = true,
     LOOT_OPENED = true,
-    --    MAIL_SHOW = true,
-    --    MERCHANT_SHOW = true,
-    --    MERCHANT_UPDATE = true,
-    --    OPEN_TABARD_FRAME = true,
-    --    PET_BAR_UPDATE = true,
-    --    PET_STABLE_SHOW = true,
-    --    PLAYER_ALIVE = true,
-    --    PLAYER_ENTERING_WORLD = HandleZoneChange,
-    --    PLAYER_LOGIN = true,
-    --    PLAYER_LOGOUT = true,
+    MERCHANT_UPDATE = true,
     PLAYER_TARGET_CHANGED = true,
-    --    QUEST_COMPLETE = true,
-    --    QUEST_DETAIL = true,
-    --    QUEST_LOG_UPDATE = true,
-    --    QUEST_PROGRESS = true,
-    --    TAXIMAP_OPENED = true,
-    --    TRADE_SKILL_SHOW = true,
-    --    TRADE_SKILL_UPDATE = true,
-    --    TRAINER_SHOW = true,
-    --    UNIT_QUEST_LOG_CHANGED = true,
+    UNIT_QUEST_LOG_CHANGED = true,
     UNIT_SPELLCAST_FAILED = "HandleSpellFailure",
     UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure",
     UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure",
     UNIT_SPELLCAST_SENT = true,
     UNIT_SPELLCAST_SUCCEEDED = true,
-    --    ZONE_CHANGED = HandleZoneChange,
-    --    ZONE_CHANGED_NEW_AREA = HandleZoneChange,
 }
 
+
 local AF = private.ACTION_TYPE_FLAGS
 
+
 -----------------------------------------------------------------------
 -- Local variables.
 -----------------------------------------------------------------------
@@ -96,21 +58,6 @@
 local target_location_timer_handle
 local action_data = {}
 
-do
-    local UNIT_TYPE_BITMASK = 0x007
-
-    function WDP:ParseGUID(guid)
-        local types = private.UNIT_TYPES
-        local unit_type = _G.bit.band(tonumber(guid:sub(1, 5)), UNIT_TYPE_BITMASK)
-
-        if unit_type ~= types.PLAYER or unit_type ~= types.OBJECT or unit_type ~= types.PET then
-            return unit_type, tonumber(guid:sub(-12, -9), 16)
-        end
-
-        return unit_type
-    end
-end -- do-block
-
 
 -----------------------------------------------------------------------
 -- Helper Functions.
@@ -150,6 +97,23 @@
     return id and tonumber(id) or nil
 end
 
+
+do
+    local UNIT_TYPE_BITMASK = 0x007
+
+    function WDP:ParseGUID(guid)
+        local types = private.UNIT_TYPES
+        local unit_type = _G.bit.band(tonumber(guid:sub(1, 5)), UNIT_TYPE_BITMASK)
+
+        if unit_type ~= types.PLAYER or unit_type ~= types.OBJECT or unit_type ~= types.PET then
+            return unit_type, tonumber(guid:sub(-12, -9), 16)
+        end
+
+        return unit_type
+    end
+end -- do-block
+
+
 -----------------------------------------------------------------------
 -- Methods.
 -----------------------------------------------------------------------
@@ -235,10 +199,6 @@
 -----------------------------------------------------------------------
 -- Event handlers.
 -----------------------------------------------------------------------
-function WDP:CHAT_MSG_SYSTEM(event_name, message, sender_name, language)
-end
-
-
 local re_gold = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)")
 local re_silver = _G.SILVER_AMOUNT:gsub("%%d", "(%%d+)")
 local re_copper = _G.COPPER_AMOUNT:gsub("%%d", "(%%d+)")
@@ -273,6 +233,7 @@
     end,
 }
 
+
 local LOOT_UPDATE_FUNCS = {
     [AF.NPC] = function()
         local npc = db.npcs[action_data.id_num]
@@ -323,6 +284,19 @@
 end
 
 
+function WDP:MERCHANT_UPDATE()
+    local unit_type, unit_idnum = self:ParseGUID(_G.UnitGUID("target"))
+
+    if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
+        return
+    end
+
+    for index = 1, _G.GetMerchantNumItems() do
+        local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(index)
+    end
+end
+
+
 local GENDER_NAMES = {
     "UNKNOWN",
     "MALE",
@@ -392,6 +366,19 @@
 end
 
 
+function WDP:QUEST_LOG_UPDATE()
+    self:UnregisterEvent("QUEST_LOG_UPDATE")
+end
+
+
+function WDP:UNIT_QUEST_LOG_CHANGED(event, unit_id)
+    if unit_id ~= "player" then
+        return
+    end
+    self:RegisterEvent("QUEST_LOG_UPDATE")
+end
+
+
 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line)
     if private.tracked_line or unit_id ~= "player" then
         return