Mercurial > wow > buffalo2
comparison ObjectiveCore.lua @ 21:d5ee940de273
use hardcoded aesthetic manipulations over loadstring cramming
| author | Nenue |
|---|---|
| date | Fri, 08 Apr 2016 06:12:05 -0400 |
| parents | 6bd2102d340b |
| children | 9b3fa734abff |
comparison
equal
deleted
inserted
replaced
| 20:6bd2102d340b | 21:d5ee940de273 |
|---|---|
| 56 local OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED = OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED -- 0x0040 | 56 local OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED = OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED -- 0x0040 |
| 57 local OBJECTIVE_TRACKER_UPDATE_SCENARIO_BONUS_DELAYED = OBJECTIVE_TRACKER_UPDATE_SCENARIO_BONUS_DELAYED -- 0x0080 | 57 local OBJECTIVE_TRACKER_UPDATE_SCENARIO_BONUS_DELAYED = OBJECTIVE_TRACKER_UPDATE_SCENARIO_BONUS_DELAYED -- 0x0080 |
| 58 | 58 |
| 59 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_ALL -- default | 59 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_ALL -- default |
| 60 --- Used to determine which trackers are listening for money events | 60 --- Used to determine which trackers are listening for money events |
| 61 mod.MoneyReasons = 0 | 61 mod.watchMoneyReasons = 0 |
| 62 | 62 |
| 63 --- Baseline defaults table; values defined in the files that they pertain to | 63 --- Baseline defaults table; values defined in the files that they pertain to |
| 64 mod.defaults = {} | 64 mod.defaults = {} |
| 65 | 65 |
| 66 --- Tracker display order | 66 --- Tracker display order |
| 85 AnchorPoint = WRAPPER_ANCHOR_POINT, | 85 AnchorPoint = WRAPPER_ANCHOR_POINT, |
| 86 OffsetX = WRAPPER_OFFSET_X, | 86 OffsetX = WRAPPER_OFFSET_X, |
| 87 OffsetY = WRAPPER_OFFSET_Y, | 87 OffsetY = WRAPPER_OFFSET_Y, |
| 88 Height = WRAPPER_MAX_HEIGHT, | 88 Height = WRAPPER_MAX_HEIGHT, |
| 89 Width = WRAPPER_WIDTH, | 89 Width = WRAPPER_WIDTH, |
| 90 HeaderHeight = WRAPPER_HEADER_HEIGHT | 90 HeaderHeight = WRAPPER_HEADER_HEIGHT, |
| 91 } | 91 TextSpacing = 3, |
| 92 TitleSpacing = 3, | |
| 93 } | |
| 94 | |
| 95 | |
| 96 | |
| 92 --- Tracker module definitions begin here; innards dealing with data retreival and output are defined further in | 97 --- Tracker module definitions begin here; innards dealing with data retreival and output are defined further in |
| 93 mod.DefaultTracker = { | 98 mod.DefaultHandler = { |
| 94 previousHeight = 0, | 99 previousHeight = 0, |
| 95 | 100 |
| 96 name = "temp", | 101 name = "temp", |
| 97 displayName = "temp", | 102 displayName = "temp", |
| 98 updateReasonModule = 0xFF00, | 103 updateReasonModule = 0xFF00, |
| 148 return self.name | 153 return self.name |
| 149 end | 154 end |
| 150 local Tracker_call = function (self, reason) | 155 local Tracker_call = function (self, reason) |
| 151 self:Update(reason) | 156 self:Update(reason) |
| 152 end | 157 end |
| 153 | 158 local Handler_Initialize = function (self, name, index) |
| 154 local Tracker_Initialize = function (self, name, index) | |
| 155 print('Initializing |cFF00FFFF'..name..'|r module...') | 159 print('Initializing |cFF00FFFF'..name..'|r module...') |
| 156 | 160 |
| 157 local handler = setmetatable(mod[name] or {}, { | 161 local handler = setmetatable(mod[name] or {}, { |
| 158 __tostring = Tracker_string, | 162 __tostring = Tracker_string, |
| 159 __call = Tracker_call | 163 __call = Tracker_call |
| 193 local frame = CreateFrame('Frame', trackerName, _G.VeneerObjectiveScroll, 'VeneerTrackerTemplate') | 197 local frame = CreateFrame('Frame', trackerName, _G.VeneerObjectiveScroll, 'VeneerTrackerTemplate') |
| 194 frame.title:SetText(handler.displayName) | 198 frame.title:SetText(handler.displayName) |
| 195 mod.SetBlockStyle(frame, 'Tracker', 'Normal') | 199 mod.SetBlockStyle(frame, 'Tracker', 'Normal') |
| 196 handler.frame = frame | 200 handler.frame = frame |
| 197 handler.trackerName = trackerName | 201 handler.trackerName = trackerName |
| 202 handler.lines = {} | |
| 198 mod.orderedTrackers[index] = frame | 203 mod.orderedTrackers[index] = frame |
| 199 mod.namedTrackers[name] = frame | 204 mod.namedTrackers[name] = frame |
| 200 mod.indexedTrackers[handler] = frame | 205 mod.indexedTrackers[handler] = frame |
| 201 print('|cFFFF0088' .. trackerName .. '|r created for |cFF00FFFF' .. handler.displayName .. '|r module') | 206 print('|cFFFF0088' .. trackerName .. '|r created for |cFF00FFFF' .. handler.displayName .. '|r module') |
| 202 | 207 |
| 203 mod.orderedHandlers[index] = handler | 208 mod.orderedHandlers[index] = handler |
| 204 return true | 209 return true |
| 205 end | 210 end |
| 206 | 211 |
| 212 | |
| 207 function mod:OnEvent (event, ...) | 213 function mod:OnEvent (event, ...) |
| 208 local isHandled | 214 local isHandled |
| 209 print('|cFF00FF00'.. event ..'|r', ...) | 215 print('OnEvent(|cFF00FF00'.. event ..'|r):', ...) |
| 210 if ( event == "QUEST_LOG_UPDATE" ) then | 216 if ( event == "QUEST_LOG_UPDATE" ) then |
| 211 mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST); | 217 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST); |
| 218 | |
| 212 elseif ( event == "TRACKED_ACHIEVEMENT_UPDATE" ) then | 219 elseif ( event == "TRACKED_ACHIEVEMENT_UPDATE" ) then |
| 213 --AchievementObjectiveTracker_OnAchievementUpdate(...); | 220 --AchievementObjectiveTracker_OnAchievementUpdate(...); |
| 214 mod.Cheevs:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT) | 221 mod.Cheevs:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT) |
| 222 | |
| 215 elseif ( event == "QUEST_ACCEPTED" ) then | 223 elseif ( event == "QUEST_ACCEPTED" ) then |
| 216 local questLogIndex, questID = ...; | 224 local questLogIndex, questID = ...; |
| 217 if ( IsQuestTask(questID) ) then | 225 if ( IsQuestTask(questID) ) then |
| 218 mod:Update(OBJECTIVE_TRACKER_UPDATE_TASK_ADDED, questID); | 226 mod:Update(OBJECTIVE_TRACKER_UPDATE_TASK_ADDED, questID); |
| 219 else | 227 else |
| 220 if ( AUTO_QUEST_WATCH == "1" and GetNumQuestWatches() < MAX_WATCHABLE_QUESTS ) then | 228 if ( AUTO_QUEST_WATCH == "1" and GetNumQuestWatches() < MAX_WATCHABLE_QUESTS ) then |
| 221 AddQuestWatch(questLogIndex); | 229 AddQuestWatch(questLogIndex); |
| 222 SetSuperTrackedQuestID(questID); | 230 SetSuperTrackedQuestID(questID); |
| 223 end | 231 end |
| 224 end | 232 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) |
| 233 end | |
| 234 | |
| 225 elseif ( event == "TRACKED_ACHIEVEMENT_LIST_CHANGED" ) then | 235 elseif ( event == "TRACKED_ACHIEVEMENT_LIST_CHANGED" ) then |
| 226 local achievementID, added = ...; | 236 local achievementID, added = ...; |
| 227 if ( added ) then | 237 if ( added ) then |
| 228 mod:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED, achievementID); | 238 mod:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED, achievementID); |
| 229 else | 239 else |
| 230 mod:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT); | 240 mod:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT); |
| 231 end | 241 end |
| 242 | |
| 232 elseif ( event == "QUEST_WATCH_LIST_CHANGED" ) then | 243 elseif ( event == "QUEST_WATCH_LIST_CHANGED" ) then |
| 233 local questID, added = ...; | 244 local questID, added = ...; |
| 234 if ( added ) then | 245 if ( added ) then |
| 235 if ( not IsQuestTask(questID) ) then | 246 if ( not IsQuestTask(questID) ) then |
| 236 mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID); | 247 mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID, added); |
| 237 end | 248 end |
| 238 else | 249 else |
| 239 mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST); | 250 mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST, questID, added); |
| 240 end | 251 end |
| 252 | |
| 241 elseif ( event == "QUEST_POI_UPDATE" ) then | 253 elseif ( event == "QUEST_POI_UPDATE" ) then |
| 242 QuestPOIUpdateIcons(); | 254 QuestPOIUpdateIcons(); |
| 243 if ( GetCVar("trackQuestSorting") == "proximity" ) then | 255 if ( GetCVar("trackQuestSorting") == "proximity" ) then |
| 244 SortQuestWatches(); | 256 SortQuestWatches(); |
| 245 end | 257 end |
| 246 | 258 |
| 247 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST); | 259 mod:Update(OBJECTIVE_TRACKER_UPDATE_ALL); |
| 248 | 260 |
| 249 elseif ( event == "SCENARIO_CRITERIA_UPDATE" ) then | 261 elseif ( event == "SCENARIO_CRITERIA_UPDATE" ) then |
| 250 mod:Update(OBJECTIVE_TRACKER_UPDATE_SCENARIO); | 262 mod:Update(OBJECTIVE_TRACKER_UPDATE_SCENARIO); |
| 251 elseif ( event == "SUPER_TRACKED_QUEST_CHANGED" ) then | 263 elseif ( event == "SUPER_TRACKED_QUEST_CHANGED" ) then |
| 252 mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST) | 264 --mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST) |
| 253 elseif ( event == "ZONE_CHANGED" ) then | 265 elseif ( event == "ZONE_CHANGED" ) then |
| 254 local inMicroDungeon = IsPlayerInMicroDungeon(); | 266 local inMicroDungeon = IsPlayerInMicroDungeon(); |
| 255 if ( inMicroDungeon ~= self.inMicroDungeon ) then | 267 if ( inMicroDungeon ~= self.inMicroDungeon ) then |
| 256 if ( not WorldMapFrame:IsShown() and GetCVarBool("questPOI") ) then | 268 if ( not WorldMapFrame:IsShown() and GetCVarBool("questPOI") ) then |
| 257 SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker | 269 SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker |
| 260 self.inMicroDungeon = inMicroDungeon; | 272 self.inMicroDungeon = inMicroDungeon; |
| 261 end | 273 end |
| 262 elseif ( event == "QUEST_AUTOCOMPLETE" ) then | 274 elseif ( event == "QUEST_AUTOCOMPLETE" ) then |
| 263 local questId = ...; | 275 local questId = ...; |
| 264 AddAutoQuestPopUp(questId, "COMPLETE"); | 276 AddAutoQuestPopUp(questId, "COMPLETE"); |
| 265 mod:Update(OBJECTIVE_TRACKER_UPDATE_STATIC) | 277 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) |
| 266 elseif ( event == "SCENARIO_UPDATE" ) then | 278 elseif ( event == "SCENARIO_UPDATE" ) then |
| 267 local newStage = ...; | 279 local newStage = ...; |
| 268 if ( newStage ) then | 280 if ( newStage ) then |
| 269 mod:Update(OBJECTIVE_TRACKER_UPDATE_SCENARIO_NEW_STAGE); | 281 mod:Update(OBJECTIVE_TRACKER_UPDATE_SCENARIO_NEW_STAGE); |
| 270 else | 282 else |
| 273 elseif ( event == "ZONE_CHANGED_NEW_AREA" ) then | 285 elseif ( event == "ZONE_CHANGED_NEW_AREA" ) then |
| 274 if ( not WorldMapFrame:IsShown() and GetCVarBool("questPOI") ) then | 286 if ( not WorldMapFrame:IsShown() and GetCVarBool("questPOI") ) then |
| 275 SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker | 287 SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker |
| 276 end | 288 end |
| 277 SortQuestWatches(); | 289 SortQuestWatches(); |
| 290 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE) | |
| 291 elseif (event == 'CRITERIA_COMPLETE') then | |
| 292 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE) | |
| 293 | |
| 278 elseif ( event == "QUEST_TURNED_IN" ) then | 294 elseif ( event == "QUEST_TURNED_IN" ) then |
| 279 local questID, xp, money = ...; | 295 local questID, xp, money = ...; |
| 280 if ( IsQuestTask(questID) ) then | 296 if ( IsQuestTask(questID) ) then |
| 281 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE) | 297 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE) |
| 298 else | |
| 299 | |
| 300 mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) | |
| 282 end | 301 end |
| 283 elseif ( event == "PLAYER_MONEY" and self.watchMoneyReasons > 0 ) then | 302 elseif ( event == "PLAYER_MONEY" and self.watchMoneyReasons > 0 ) then |
| 303 -- only update trackers that have money counters | |
| 284 mod:Update(self.watchMoneyReasons); | 304 mod:Update(self.watchMoneyReasons); |
| 285 end | 305 end |
| 286 end | 306 end |
| 287 | 307 |
| 288 --- Done once per ui load | 308 --- Done once per ui load |
| 315 end | 335 end |
| 316 end | 336 end |
| 317 end | 337 end |
| 318 Scroller:SetScrollChild(Scroll) | 338 Scroller:SetScrollChild(Scroll) |
| 319 Scroller:SetWidth(c.Width) | 339 Scroller:SetWidth(c.Width) |
| 320 Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT') | |
| 321 Scroll:SetWidth(c.Width) | 340 Scroll:SetWidth(c.Width) |
| 341 Scroll:ClearAllPoints() | |
| 342 Scroll:SetPoint('TOP', Scroller, 'TOP') | |
| 322 ObjectiveTrackerFrame:UnregisterAllEvents() | 343 ObjectiveTrackerFrame:UnregisterAllEvents() |
| 323 ObjectiveTrackerFrame:Hide() | 344 ObjectiveTrackerFrame:Hide() |
| 324 end | 345 end |
| 325 | 346 |
| 326 --- Done any time the the minimize button is toggled up | 347 --- Done any time the the minimize button is toggled up |
| 348 | |
| 327 | 349 |
| 328 function mod:OnEnable() | 350 function mod:OnEnable() |
| 329 for id, name in ipairs(mod.orderedNames) do | 351 for id, name in ipairs(mod.orderedNames) do |
| 330 if not mod.orderedHandlers[id] then | 352 if not mod.orderedHandlers[id] then |
| 331 Tracker_Initialize(mod.DefaultTracker, name, id) | 353 Handler_Initialize(mod.DefaultHandler, name, id) |
| 332 end | 354 end |
| 333 end | 355 end |
| 334 | 356 |
| 335 for event, func in pairs(mod) do | 357 Wrapper:RegisterEvent("CRITERIA_COMPLETE"); |
| 336 if type(func) == 'function' and event:match('^[A-Z_]+$') then | 358 Wrapper:RegisterEvent("SCENARIO_UPDATE"); |
| 337 print('|cFFFF44FFlistening to', event) | 359 Wrapper:RegisterEvent("SCENARIO_CRITERIA_UPDATE"); |
| 338 Wrapper:RegisterEvent(event) | 360 Wrapper:RegisterEvent("PLAYER_MONEY"); |
| 339 end | 361 Wrapper:RegisterEvent("QUEST_ACCEPTED"); |
| 340 end | 362 Wrapper:RegisterEvent("QUEST_AUTOCOMPLETE"); |
| 363 Wrapper:RegisterEvent("QUEST_LOG_UPDATE"); | |
| 364 Wrapper:RegisterEvent("QUEST_POI_UPDATE"); | |
| 365 Wrapper:RegisterEvent("QUEST_TURNED_IN"); | |
| 366 Wrapper:RegisterEvent("QUEST_WATCH_LIST_CHANGED"); | |
| 367 Wrapper:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED"); | |
| 368 Wrapper:RegisterEvent("TRACKED_ACHIEVEMENT_LIST_CHANGED"); | |
| 369 Wrapper:RegisterEvent("TRACKED_ACHIEVEMENT_UPDATE"); | |
| 370 Wrapper:RegisterEvent("VARIABLES_LOADED"); | |
| 371 Wrapper:RegisterEvent("ZONE_CHANGED_NEW_AREA"); | |
| 372 Wrapper:RegisterEvent("ZONE_CHANGED"); | |
| 373 Wrapper:SetScript('OnEvent', mod.OnEvent) | |
| 341 | 374 |
| 342 local c = mod.Conf.Wrapper | 375 local c = mod.Conf.Wrapper |
| 343 Wrapper:SetPoint(c.AnchorPoint, UIParent, c.AnchorPoint, c.OffsetX, c.OffsetY) | 376 --Wrapper:SetPoint(c.AnchorPoint, UIParent, c.AnchorPoint, c.OffsetX, c.OffsetY) |
| 344 B.Conf.FramePosition[Wrapper:GetName()] = {c.AnchorPoint, c.AnchorPoint, c.OffsetX, c.OffsetY} | 377 --B.Conf.FramePosition[Wrapper:GetName()] = {c.AnchorPoint, c.AnchorPoint, c.OffsetX, c.OffsetY} |
| 345 Wrapper:SetWidth(c.Width) | 378 Wrapper:SetWidth(c.Width) |
| 346 | 379 |
| 347 | 380 |
| 348 mod.InitializeWidgets() | 381 mod.InitializeWidgets() |
| 349 mod:Update() | 382 mod:Update() |
