Mercurial > wow > buffalo2
comparison ObjectiveTracker/ObjectiveTracker.lua @ 34:9856ebc63fa4
- half solution to Update being fired multiple times during load
- change securefunc handlers to dispense a reason code; catch that reason code in the enclosure passed to hooksecurefunc, and decide whether to update or not from there.
author | Nenue |
---|---|
date | Sun, 17 Apr 2016 00:21:45 -0400 |
parents | 64f2a9bbea79 |
children | 69d03f8e293e |
comparison
equal
deleted
inserted
replaced
33:64f2a9bbea79 | 34:9856ebc63fa4 |
---|---|
65 T.strings = {} | 65 T.strings = {} |
66 T.strings.CLICK_TO_ACCCEPT = 'Click to Accept' | 66 T.strings.CLICK_TO_ACCCEPT = 'Click to Accept' |
67 T.strings.CLICK_TO_COMPLETE = 'Click to complete' | 67 T.strings.CLICK_TO_COMPLETE = 'Click to complete' |
68 T.colors ={ | 68 T.colors ={ |
69 enable = true, | 69 enable = true, |
70 default = { | |
71 titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125}, | |
72 textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }, | |
73 selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}, | |
74 }, | |
75 daily = { | |
76 titlebg = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125}, | |
77 textbg = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 }, | |
78 }, | |
79 weekly = { | |
80 titlebg = {'HORIZONTAL', 0, .35, .7, .25, 0, .35, .7, .125}, | |
81 textbg = {'HORIZONTAL', 0, .35, .7, .1, 0, .35, .7, .075 }, | |
82 }, | |
83 account = { | |
84 titlebg = {'HORIZONTAL', .1, .1, .1, .25, .1, .1, .1, .125}, | |
85 textbg = {'HORIZONTAL', .1, .1, .1, 0.4, .1, .1, .1, .085 }, | |
86 }, | |
87 -- alliance | |
88 faction_1 = { | |
89 titlebg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 }, | |
90 textbg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 }, | |
91 }, | |
92 -- horde | |
93 faction_2 = { | |
94 titlebg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 }, | |
95 textbg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 }, | |
96 } | |
97 } | 70 } |
98 | 71 |
99 T.watchMoneyReasons = 0 | 72 T.watchMoneyReasons = 0 |
100 | 73 |
101 --- Baseline defaults table; values defined in the files that they pertain to | 74 --- Baseline defaults table; values defined in the files that they pertain to |
102 T.defaults = {} | 75 T.defaults = {} |
76 | |
103 | 77 |
104 --- Tracker display order | 78 --- Tracker display order |
105 T.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'} | 79 T.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'} |
106 | 80 |
107 --- ipairs() argument tables | 81 --- ipairs() argument tables |
144 updateReasonEvent = 0x00FF, | 118 updateReasonEvent = 0x00FF, |
145 | 119 |
146 numWatched = 0, --- number of entries being handled | 120 numWatched = 0, --- number of entries being handled |
147 numBlocks = 0, --- number of blocks created | 121 numBlocks = 0, --- number of blocks created |
148 actualBlocks = 0, --- number of blocks in use | 122 actualBlocks = 0, --- number of blocks in use |
149 | 123 Info = {}, --- stored watch list information, keyed by whatever unique ID is involved for that tracker |
150 freeBlocks = {}, --- block heap | 124 Watched = {}, --- stores whether the given unique ID is tracked |
151 usedBlocks = {}, | 125 |
152 | 126 freeBlocks = {}, --- blocks hidden due to list shrinkage |
153 Info = {}, -- find data by ID | 127 usedBlocks = {}, --- block in use |
154 BlockInfo = {}, -- find data by block ID | 128 BlockInfo = {}, --- by block creation offset, used by framescript |
155 Watched = {}, -- find watchIndex by data ID | 129 |
156 WatchInfo = {}, -- find data by watch index | 130 --- Indexes |
157 WatchBlock = {}, -- find block by watch index | 131 LogBlock = {}, --- by API log offset, used by GetBlock if possible |
132 WatchBlock = {}, --- block by internal offset, used in GetBlock scope | |
133 WatchInfo = {}, --- info by internal offset, used in Update scope | |
158 } | 134 } |
159 | 135 |
160 T.AutoQuest = { | 136 T.AutoQuest = { |
161 name = "AutoQuest", | 137 name = "AutoQuest", |
162 displayName = "Notice", | 138 displayName = "Notice", |
163 updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, | 139 updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, |
164 updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, | 140 updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, |
165 LogInfo = {}, | 141 LogInfo = {}, |
166 LogBlock = {}, | |
167 QuestBlock = {}, | 142 QuestBlock = {}, |
168 } | 143 } |
169 T.Quest = { | 144 T.Quest = { |
170 name = "Quest", | 145 name = "Quest", |
171 displayName = "Quests", | 146 displayName = "Quests", |
172 updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, | 147 updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, |
173 updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, | 148 updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, |
174 itemButtons = {}, | 149 itemButtons = {}, |
175 freeButtons = {}, | 150 freeButtons = {}, |
176 LogInfo = {}, | 151 LogInfo = {}, |
177 LogBlock = {}, | |
178 QuestBlock = {}, | 152 QuestBlock = {}, |
179 } | 153 } |
180 T.Cheevs = { | 154 T.Cheevs = { |
181 name = "Cheevs", | 155 name = "Cheevs", |
182 displayName = "Achievements", | 156 displayName = "Achievements", |
271 local GetNumQuestWatches, AddQuestWatch, SetSuperTrackedQuestID = GetNumQuestWatches, AddQuestWatch, SetSuperTrackedQuestID | 245 local GetNumQuestWatches, AddQuestWatch, SetSuperTrackedQuestID = GetNumQuestWatches, AddQuestWatch, SetSuperTrackedQuestID |
272 Event.QUEST_ACCEPTED = function(questLogIndex, questID, added) | 246 Event.QUEST_ACCEPTED = function(questLogIndex, questID, added) |
273 if ( IsQuestTask(questID) ) then | 247 if ( IsQuestTask(questID) ) then |
274 return OBJECTIVE_TRACKER_UPDATE_TASK_ADDED, questID | 248 return OBJECTIVE_TRACKER_UPDATE_TASK_ADDED, questID |
275 else | 249 else |
276 if ( _G.AUTO_QUEST_WATCH == "1" ) then | |
277 AddQuestWatch(questLogIndex); | |
278 SetSuperTrackedQuestID(questID); | |
279 end | |
280 return OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID, added | 250 return OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID, added |
281 end | 251 end |
282 end | 252 end |
283 | 253 |
284 Event.QUEST_REMOVED = function(questLogIndex, questID) | 254 Event.QUEST_REMOVED = function(questLogIndex, questID) |
372 end | 342 end |
373 T.Event = Event | 343 T.Event = Event |
374 | 344 |
375 --- Done once per ui load | 345 --- Done once per ui load |
376 local BlizzHooks = { | 346 local BlizzHooks = { |
347 ['AcceptQuest'] = 'AcceptQuest', | |
377 ['AddQuestWatch'] = 'AddQuestWatch', | 348 ['AddQuestWatch'] = 'AddQuestWatch', |
378 ['RemoveQuestWatch'] = 'RemoveQuestWatch', | 349 ['RemoveQuestWatch'] = 'RemoveQuestWatch', |
379 ['AbandonQuest'] = 'AbandonQuest', | 350 ['AbandonQuest'] = 'AbandonQuest', |
380 ['AcknowledgeAutoAcceptQuest'] = 'AcknowledgeAutoAcceptQuest', | 351 ['AcknowledgeAutoAcceptQuest'] = 'AcknowledgeAutoAcceptQuest', |
381 ['AddAutoQuestPopUp'] = 'AddAutoQuestPopUp', | 352 ['AddAutoQuestPopUp'] = 'AddAutoQuestPopUp', |
411 end | 382 end |
412 end | 383 end |
413 | 384 |
414 local iprint = B.print('Info') | 385 local iprint = B.print('Info') |
415 T.SetRewards = function(t, questID) | 386 T.SetRewards = function(t, questID) |
387 local previousSelection = GetQuestLogSelection() | |
416 | 388 |
417 SelectQuestLogEntry(GetQuestLogIndexByID(questID)) | 389 SelectQuestLogEntry(GetQuestLogIndexByID(questID)) |
418 local numQuestChoices = GetNumQuestLogChoices(); | 390 local numQuestChoices = GetNumQuestLogChoices(); |
419 local skillName, skillIcon, skillPoints = GetQuestLogRewardSkillPoints(); | 391 local skillName, skillIcon, skillPoints = GetQuestLogRewardSkillPoints(); |
420 local xp = GetQuestLogRewardXP(); | 392 local xp = GetQuestLogRewardXP(); |
421 local playerTitle = GetQuestLogRewardTitle(); | 393 local playerTitle = GetQuestLogRewardTitle(); |
422 ProcessQuestLogRewardFactions(); | 394 ProcessQuestLogRewardFactions(); |
395 if previousSelection then | |
396 SelectQuestLogEntry(previousSelection) | |
397 end | |
398 | |
423 local rewards = {} | 399 local rewards = {} |
424 local texture, name, isTradeskillSpell, isSpellLearned, hideSpellLearnText, isBoostSpell, garrFollowerID = GetQuestLogRewardSpell(questID) | 400 local texture, name, isTradeskillSpell, isSpellLearned, hideSpellLearnText, isBoostSpell, garrFollowerID = GetQuestLogRewardSpell(questID) |
425 if name then | 401 if name then |
426 tinsert(rewards,{ | 402 tinsert(rewards,{ |
427 type = 'spell', | 403 type = 'spell', |
471 t.rewardInfo = rewards | 447 t.rewardInfo = rewards |
472 end | 448 end |
473 end | 449 end |
474 | 450 |
475 local Play = function(file) if Devian and Devian.InWorkspace() then PlaySoundFile(file) end end | 451 local Play = function(file) if Devian and Devian.InWorkspace() then PlaySoundFile(file) end end |
452 | |
453 T.OnHookedFunc = function(name, ...) | |
454 print('|cFFFF8800securehook:|r', name, '|cFF00FFFFargs:|r', ...) | |
455 local updateReason = T[name](...) | |
456 if updateReason then | |
457 print('|cFF00FFFFupdate reason:|r', updateReason) | |
458 T:Update(updateReason) | |
459 end | |
460 end | |
476 | 461 |
477 function T:OnEvent (event, ...) | 462 function T:OnEvent (event, ...) |
478 local isHandled | 463 local isHandled |
479 print('OnEvent(|cFF00FF00'.. event ..'|r):', ...) | 464 print('OnEvent(|cFF00FF00'.. event ..'|r):', ...) |
480 local reason, arg1, arg2, arg3 | 465 local reason, arg1, arg2, arg3 |
520 VeneerData.CallLog = VeneerData.CallLog or {} | 505 VeneerData.CallLog = VeneerData.CallLog or {} |
521 if not T.isHooked then | 506 if not T.isHooked then |
522 T.isHooked = true | 507 T.isHooked = true |
523 for blizzFunc, veneerFunc in pairs(BlizzHooks) do | 508 for blizzFunc, veneerFunc in pairs(BlizzHooks) do |
524 if T[veneerFunc] then | 509 if T[veneerFunc] then |
525 hooksecurefunc(blizzFunc, T[veneerFunc]) | 510 hooksecurefunc(blizzFunc, function(...) return T.OnHookedFunc(blizzFunc, ...) end) |
526 else | 511 else |
527 hooksecurefunc(blizzFunc, function(...) | 512 hooksecurefunc(blizzFunc, function(...) |
528 print('|cFFFF0088securehook('..tostring(blizzFunc)..')|r args:', ...) | 513 print('|cFFFF0088securehook('..tostring(blizzFunc)..')|r args:', ...) |
529 tinsert(VeneerData.CallLog, {blizzFunc, ...}) | 514 tinsert(VeneerData.CallLog, {blizzFunc, ...}) |
530 end) | 515 end) |
549 | 534 |
550 --- Done any time the the minimize button is toggled up | 535 --- Done any time the the minimize button is toggled up |
551 function T:OnEnable() | 536 function T:OnEnable() |
552 | 537 |
553 print(B.Conf.VeneerObjectiveWrapper.enabled) | 538 print(B.Conf.VeneerObjectiveWrapper.enabled) |
554 if not B.Conf.VeneerObjectiveWrapper.enabled then | 539 |
555 return | |
556 end | |
557 | 540 |
558 for event, action in pairs(Event) do | 541 for event, action in pairs(Event) do |
559 print('|cFFFF0088listen to', event, 'for action|r', tostring(action)) | 542 print('|cFFFF0088listen to', event, 'for action|r', tostring(action)) |
560 Wrapper:RegisterEvent(event) | 543 Wrapper:RegisterEvent(event) |
561 end | 544 end |