comparison 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
comparison
equal deleted inserted replaced
3:a9b84f0d8235 4:24a1d78e2e8c
17 local ADDON_NAME, private = ... 17 local ADDON_NAME, private = ...
18 18
19 local LibStub = _G.LibStub 19 local LibStub = _G.LibStub
20 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0") 20 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0")
21 21
22 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate")
22 23
23 ----------------------------------------------------------------------- 24 -----------------------------------------------------------------------
24 -- Local constants. 25 -- Local constants.
25 ----------------------------------------------------------------------- 26 -----------------------------------------------------------------------
26 local DATABASE_DEFAULTS = { 27 local DATABASE_DEFAULTS = {
32 } 33 }
33 } 34 }
34 35
35 36
36 local EVENT_MAPPING = { 37 local EVENT_MAPPING = {
37 -- ARTIFACT_COMPLETE = true,
38 -- ARTIFACT_HISTORY_READY = true,
39 -- AUCTION_HOUSE_SHOW = true,
40 -- BANKFRAME_OPENED = true,
41 -- BATTLEFIELDS_SHOW = true,
42 -- CHAT_MSG_ADDON = true,
43 -- CHAT_MSG_MONSTER_EMOTE = true,
44 -- CHAT_MSG_MONSTER_SAY = true,
45 -- CHAT_MSG_MONSTER_WHISPER = true,
46 -- CHAT_MSG_MONSTER_YELL = true,
47 -- CHAT_MSG_SYSTEM = true,
48 -- COMBAT_LOG_EVENT_UNFILTERED = true,
49 -- COMBAT_TEXT_UPDATE = true,
50 -- CONFIRM_BINDER = true,
51 -- CONFIRM_PET_UNLEARN = true,
52 -- CONFIRM_TALENT_WIPE = true,
53 -- CURRENCY_DISPLAY_UPDATE = true,
54 -- GOSSIP_ENTER_CODE = true,
55 -- GOSSIP_SHOW = true,
56 -- ITEM_TEXT_BEGIN = true,
57 -- LOCALPLAYER_PET_RENAMED = true,
58 -- LOOT_CLOSED = true,
59 LOOT_OPENED = true, 38 LOOT_OPENED = true,
60 -- MAIL_SHOW = true, 39 MERCHANT_UPDATE = true,
61 -- MERCHANT_SHOW = true,
62 -- MERCHANT_UPDATE = true,
63 -- OPEN_TABARD_FRAME = true,
64 -- PET_BAR_UPDATE = true,
65 -- PET_STABLE_SHOW = true,
66 -- PLAYER_ALIVE = true,
67 -- PLAYER_ENTERING_WORLD = HandleZoneChange,
68 -- PLAYER_LOGIN = true,
69 -- PLAYER_LOGOUT = true,
70 PLAYER_TARGET_CHANGED = true, 40 PLAYER_TARGET_CHANGED = true,
71 -- QUEST_COMPLETE = true, 41 UNIT_QUEST_LOG_CHANGED = true,
72 -- QUEST_DETAIL = true,
73 -- QUEST_LOG_UPDATE = true,
74 -- QUEST_PROGRESS = true,
75 -- TAXIMAP_OPENED = true,
76 -- TRADE_SKILL_SHOW = true,
77 -- TRADE_SKILL_UPDATE = true,
78 -- TRAINER_SHOW = true,
79 -- UNIT_QUEST_LOG_CHANGED = true,
80 UNIT_SPELLCAST_FAILED = "HandleSpellFailure", 42 UNIT_SPELLCAST_FAILED = "HandleSpellFailure",
81 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure", 43 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure",
82 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure", 44 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure",
83 UNIT_SPELLCAST_SENT = true, 45 UNIT_SPELLCAST_SENT = true,
84 UNIT_SPELLCAST_SUCCEEDED = true, 46 UNIT_SPELLCAST_SUCCEEDED = true,
85 -- ZONE_CHANGED = HandleZoneChange, 47 }
86 -- ZONE_CHANGED_NEW_AREA = HandleZoneChange, 48
87 }
88 49
89 local AF = private.ACTION_TYPE_FLAGS 50 local AF = private.ACTION_TYPE_FLAGS
51
90 52
91 ----------------------------------------------------------------------- 53 -----------------------------------------------------------------------
92 -- Local variables. 54 -- Local variables.
93 ----------------------------------------------------------------------- 55 -----------------------------------------------------------------------
94 local db 56 local db
95 local durability_timer_handle 57 local durability_timer_handle
96 local target_location_timer_handle 58 local target_location_timer_handle
97 local action_data = {} 59 local action_data = {}
98
99 do
100 local UNIT_TYPE_BITMASK = 0x007
101
102 function WDP:ParseGUID(guid)
103 local types = private.UNIT_TYPES
104 local unit_type = _G.bit.band(tonumber(guid:sub(1, 5)), UNIT_TYPE_BITMASK)
105
106 if unit_type ~= types.PLAYER or unit_type ~= types.OBJECT or unit_type ~= types.PET then
107 return unit_type, tonumber(guid:sub(-12, -9), 16)
108 end
109
110 return unit_type
111 end
112 end -- do-block
113 60
114 61
115 ----------------------------------------------------------------------- 62 -----------------------------------------------------------------------
116 -- Helper Functions. 63 -- Helper Functions.
117 ----------------------------------------------------------------------- 64 -----------------------------------------------------------------------
148 end 95 end
149 local id = item_link:match("item:(%d+)") 96 local id = item_link:match("item:(%d+)")
150 return id and tonumber(id) or nil 97 return id and tonumber(id) or nil
151 end 98 end
152 99
100
101 do
102 local UNIT_TYPE_BITMASK = 0x007
103
104 function WDP:ParseGUID(guid)
105 local types = private.UNIT_TYPES
106 local unit_type = _G.bit.band(tonumber(guid:sub(1, 5)), UNIT_TYPE_BITMASK)
107
108 if unit_type ~= types.PLAYER or unit_type ~= types.OBJECT or unit_type ~= types.PET then
109 return unit_type, tonumber(guid:sub(-12, -9), 16)
110 end
111
112 return unit_type
113 end
114 end -- do-block
115
116
153 ----------------------------------------------------------------------- 117 -----------------------------------------------------------------------
154 -- Methods. 118 -- Methods.
155 ----------------------------------------------------------------------- 119 -----------------------------------------------------------------------
156 function WDP:OnInitialize() 120 function WDP:OnInitialize()
157 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global 121 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global
233 197
234 198
235 ----------------------------------------------------------------------- 199 -----------------------------------------------------------------------
236 -- Event handlers. 200 -- Event handlers.
237 ----------------------------------------------------------------------- 201 -----------------------------------------------------------------------
238 function WDP:CHAT_MSG_SYSTEM(event_name, message, sender_name, language)
239 end
240
241
242 local re_gold = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)") 202 local re_gold = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)")
243 local re_silver = _G.SILVER_AMOUNT:gsub("%%d", "(%%d+)") 203 local re_silver = _G.SILVER_AMOUNT:gsub("%%d", "(%%d+)")
244 local re_copper = _G.COPPER_AMOUNT:gsub("%%d", "(%%d+)") 204 local re_copper = _G.COPPER_AMOUNT:gsub("%%d", "(%%d+)")
245 205
246 206
271 end 231 end
272 return true 232 return true
273 end, 233 end,
274 } 234 }
275 235
236
276 local LOOT_UPDATE_FUNCS = { 237 local LOOT_UPDATE_FUNCS = {
277 [AF.NPC] = function() 238 [AF.NPC] = function()
278 local npc = db.npcs[action_data.id_num] 239 local npc = db.npcs[action_data.id_num]
279 240
280 if not npc then 241 if not npc then
318 279
319 for item_id, quantity in pairs(loot_registry) do 280 for item_id, quantity in pairs(loot_registry) do
320 table.insert(action_data.drops, ("%d:%d"):format(item_id, quantity)) 281 table.insert(action_data.drops, ("%d:%d"):format(item_id, quantity))
321 end 282 end
322 update_func() 283 update_func()
284 end
285
286
287 function WDP:MERCHANT_UPDATE()
288 local unit_type, unit_idnum = self:ParseGUID(_G.UnitGUID("target"))
289
290 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
291 return
292 end
293
294 for index = 1, _G.GetMerchantNumItems() do
295 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(index)
296 end
323 end 297 end
324 298
325 299
326 local GENDER_NAMES = { 300 local GENDER_NAMES = {
327 "UNKNOWN", 301 "UNKNOWN",
387 if max_power > 0 then 361 if max_power > 0 then
388 local power_type = _G.UnitPowerType("target") 362 local power_type = _G.UnitPowerType("target")
389 npc.stats[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power) 363 npc.stats[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power)
390 end 364 end
391 end 365 end
366 end
367
368
369 function WDP:QUEST_LOG_UPDATE()
370 self:UnregisterEvent("QUEST_LOG_UPDATE")
371 end
372
373
374 function WDP:UNIT_QUEST_LOG_CHANGED(event, unit_id)
375 if unit_id ~= "player" then
376 return
377 end
378 self:RegisterEvent("QUEST_LOG_UPDATE")
392 end 379 end
393 380
394 381
395 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line) 382 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line)
396 if private.tracked_line or unit_id ~= "player" then 383 if private.tracked_line or unit_id ~= "player" then