Mercurial > wow > worldplan
changeset 7:34d9fbf7af20
beginning of reflecting code path isolation in file structure
author | Nenue |
---|---|
date | Sat, 22 Oct 2016 15:36:25 -0400 |
parents | 48001b6a9496 |
children | 802abb8a10ea |
files | QuestPOI.lua WorldPlan.lua WorldPlan.xml |
diffstat | 3 files changed, 226 insertions(+), 137 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QuestPOI.lua Sat Oct 22 15:36:25 2016 -0400 @@ -0,0 +1,212 @@ +-- WorldPlan +-- QuestPOI.lua +-- Created: 10/1/2016 7:21 PM +-- %file-revision% +-- +local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation +local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes +local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame + +local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end +local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end +local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end +local QuestPOI = WorldPlanPOIMixin + + local familiars = { + [42159] = {npc = 106552, name = 'Nightwatcher Merayl'}, + [40277] = {npc = 97804, name = 'Tiffany Nelson'}, + [40298] = {npc = 99182, name = 'Sir Galveston'}, + [40282] = {npc= 99150, name = 'Grixis Tinypop'}, + [40278] = {npc = 98270, name = 'Robert Craig'}, + [48195] = {npc = 105250, name = 'Aulier'}, + [41990] = {npc = 105674, name = 'Varenne'}, + [41860] = {npc = 104970, name = 'Xorvasc'}, + [40299] = {npc = 99210, name = 'Bodhi Sunwayver'}, + [42442] = {npc = 107489, name = 'Amalia'}, + [40280] = {npc = 99077, name = 'Bredda Tenderhide'}, + [41687] = {npc = 104553, name = 'Odrogg'}, + [41944] = {npc = 105455, name = 'Trapper Jarrun'}, + [40337] = {npc = 97709, name = 'Master Tamer Flummox'}, + [40279] = {npc = 99035, name = 'Durian Strongfruit'} + } + local familiars_id = 9696 + + +local PIN_TIME_CONTEXT = { + {max = 60, + r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end, + continentAlpha = 1, swipeTime = 1440, + }, + {max = 240, + r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end, + continentAlpha = 1, swipeTime = 1440, + }, + {max = 1440, + r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end, + continentAlpha = .55, swipeTime = 1440 + }, + {max = 10081, + r=0, g=1, b=0, + continentAlpha = .3, + }, -- 7 days + 1 minute +} + + +function QuestPOI:OnEnter() + local completed = select(4,GetAchievementInfo(familiars_id)) + if not completed then + if self.worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE and familiars[self.questID] then + WorldMapTooltip:SetOwner(self, 'ANCHOR_RIGHT') + WorldMapTooltip:AddLine('Family Familiars') + local trainer = familiars[self.questID].name + local numCheevs = GetAchievementNumCriteria(familiars_id) + for index = 1, numCheevs do + local cheevName, cType, cCompleted, quantity, requiredQuantity, charName, flags, cheevID, quantityString, criteriaID = GetAchievementCriteriaInfo(familiars_id, index) + local numTrainers = GetAchievementNumCriteria(cheevID) + for subIndex = 1, numTrainers do + local desc, cType, partCompleted = GetAchievementCriteriaInfo(cheevID, subIndex) + if desc == trainer then + if not partCompleted then + local iconPath = select(10, GetAchievementInfo(cheevID)) + WorldMapTooltip:AddLine(cheevName) + WorldMapTooltip:AddTexture(iconPath) + end + end + end + end + WorldMapTooltip:Show() + return + end + end + TaskPOI_OnEnter(self) +end +function QuestPOI:OnLeave() + TaskPOI_OnLeave(self) +end +function QuestPOI:OnMouseDown() + TaskPOI_OnClick(self) +end + + +function WorldPlanPOIMixin:SetAchievementProgressTooltip() + print('cheevos') + + +end + + +function QuestPOI:OnShow () + qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow()') + -- pop this on principle + self:Refresh() +end +function QuestPOI:OnHide() + --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()') +end + +function QuestPOI:SetAnchor(frame, mapID, mapWidth, mapHeight) + self:ClearAllPoints() + local dX, dY = TQ_GetQuestLocation(self.questID, mapID) + if not dX or dX == 0 then + local _, x, y = QuestPOIGetIconInfo(self.questID) + if x and floor(x) ~= 0 then + dX, dY = x, y + else + dX, dY = self.x, self.y + end + end + self.x = dX + self.y = dY + + print(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY)) + + local pX = (dX * mapWidth) + local pY = (-dY * mapHeight) + + self:SetParent(WorldMapPOIFrame) + self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY) +end + + +function QuestPOI:OnLoad() + self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED') +end + +function QuestPOI:OnEvent(event, ...) + if event == 'SUPER_TRACKED_QUEST_CHANGED' then + if self:IsVisible() then + self:Refresh() + end + end +end + + +local PIN_UPDATE_DELAY = .016 +local TOP_PIN_ID +function QuestPOI:OnUpdate (sinceLast) + -- control update check intervals + self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast + if self.throttle <= 0 then + -- factor overtime into the throttle timer + self.throttle = PIN_UPDATE_DELAY - self.throttle + else + return + end + + -- query for reward data if it wasn't found in the original scan + local questID = self.questID + if self.isPending then + self:Reset() + if not (self.PendingFade:IsPlaying() or self.isAnimating) then + self.PendingFade:Play() + end + return + else + if self.PendingFade:IsPlaying() then + self.PendingFade:Stop() + end + end + + if self.hasUpdate then + self:Refresh() + self.hasUpdate = nil + end + + -- update time elements + local tl = self.timeThreschold + local timeLeft = TQ_GetQuestTimeLeftMinutes(questID) + if timeLeft > 0 then + for i, context in ipairs(PIN_TIME_CONTEXT) do + if i > self.TimeleftStage then + self.timeLabel:SetText(nil) + break + end + + + if timeLeft <= context.max then + if tl ~= i then + tl = i + end + + if context.format then + self.timeLabel:SetText(context.format(timeLeft)) + else + self.timeLabel:SetText(nil) + end + break + end + end + else + -- remove self in a timely manner + if not self.isPending then + self:Hide() + end + end + self.timeThreschold = tl + + if self:IsMouseOver() then + self.MouseGlow:Show() + else + self.MouseGlow:Hide() + end +end \ No newline at end of file
--- a/WorldPlan.lua Fri Oct 21 18:10:53 2016 -0400 +++ b/WorldPlan.lua Sat Oct 22 15:36:25 2016 -0400 @@ -23,6 +23,9 @@ local WP_VERSION = "1.0" local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end +local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end +local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end + local wipe, tremove, tinsert, pairs, floor, tContains = table.wipe, table.remove, table.insert, pairs, floor, tContains local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented @@ -45,8 +48,6 @@ local GetCurrentMapAreaID, GetMapNameByID, GetSuperTrackedQuestID = GetCurrentMapAreaID, GetMapNameByID, GetSuperTrackedQuestID local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo -local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end -local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end local SearchFaction local PinBaseIndex = 1600 @@ -177,25 +178,6 @@ { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_DUNGEON, label = 'Dungeon', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", }, } -local PIN_TIME_CONTEXT = { - {max = 60, - r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end, - continentAlpha = 1, swipeTime = 1440, - }, - {max = 240, - r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end, - continentAlpha = 1, swipeTime = 1440, - }, - {max = 1440, - r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end, - continentAlpha = .55, swipeTime = 1440 - }, - {max = 10081, - r=0, g=1, b=0, - continentAlpha = .3, - }, -- 7 days + 1 minute -} - local numPins = 0 local QuestsByZone = {} local QuestsByFaction = {} @@ -499,13 +481,6 @@ --print('|cFF00FF00Creating', name) pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin') pin:SetFrameStrata('HIGH') - pin:SetScript('OnEnter', function(self) - TaskPOI_OnEnter(self) - end) - pin:SetScript('OnLeave', function(self) - TaskPOI_OnLeave(self) - end) - pin:SetScript('OnMouseDown', TaskPOI_OnClick) NumPinFrames = NumPinFrames + 1 @@ -519,6 +494,10 @@ -- used by TaskPOI_x scripts pin.questID = questID pin.worldQuest = true + + pin.Reset = function(self) + WorldQuests:GetPinByQuestID(questID) + end else --print('|cFF00FF00Using', pin:GetName()) end @@ -883,96 +862,9 @@ local tooltipLine3 = _G['VeneerWorldQuestsScannerTextLeft3'] local GetTime, mod = GetTime, mod -function QuestPOI:OnLoad() - self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED') -end -function QuestPOI:OnEvent(event, ...) - if event == 'SUPER_TRACKED_QUEST_CHANGED' then - if self:IsVisible() then - self:Refresh() - end - end -end -local PIN_UPDATE_DELAY = .016 -local TOP_PIN_ID -function QuestPOI:OnUpdate (sinceLast) - -- control update check intervals - self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast - if self.throttle <= 0 then - -- factor overtime into the throttle timer - self.throttle = PIN_UPDATE_DELAY - self.throttle - else - return - end - -- query for reward data if it wasn't found in the original scan - local questID = self.questID - if self.isPending then - WorldQuests:GetPinByQuestID(questID) - if not (self.PendingFade:IsPlaying() or self.isAnimating) then - self.PendingFade:Play() - end - return - else - if self.PendingFade:IsPlaying() then - self.PendingFade:Stop() - end - end - - if self.hasUpdate then - self:Refresh() - self.hasUpdate = nil - end - - -- update time elements - local tl = self.timeThreschold - local timeLeft = TQ_GetQuestTimeLeftMinutes(questID) - if timeLeft > 0 then - for i, context in ipairs(PIN_TIME_CONTEXT) do - if i > self.TimeleftStage then - self.timeLabel:SetText(nil) - break - end - - - if timeLeft <= context.max then - if tl ~= i then - tl = i - end - - if context.format then - self.timeLabel:SetText(context.format(timeLeft)) - else - self.timeLabel:SetText(nil) - end - break - end - end - else - -- remove self in a timely manner - if not self.isPending then - self:Hide() - end - end - self.timeThreschold = tl - - if self:IsMouseOver() then - self.MouseGlow:Show() - else - self.MouseGlow:Hide() - end -end - -function QuestPOI:OnShow () - qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow()') - -- pop this on principle - self:Refresh() -end -function QuestPOI:OnHide() - --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()') -end function QuestPOI:Refresh () print('|cFF00FF88["'..tostring(self.title)..'"]|r:Refresh()', tostring(self.title), "|T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName)) qprint(self.style) @@ -1035,28 +927,7 @@ qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '') end -function QuestPOI:SetAnchor(frame, mapID, mapWidth, mapHeight) - self:ClearAllPoints() - local dX, dY = TQ_GetQuestLocation(self.questID, mapID) - if not dX or dX == 0 then - local _, x, y = QuestPOIGetIconInfo(self.questID) - if x and floor(x) ~= 0 then - dX, dY = x, y - else - dX, dY = self.x, self.y - end - end - self.x = dX - self.y = dY - print(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY)) - - local pX = (dX * mapWidth) - local pY = (-dY * mapHeight) - - self:SetParent(WorldMapPOIFrame) - self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY) -end function QuestPOI:IsShowable (ignoreFilters) @@ -1161,7 +1032,6 @@ end - function FilterBar:OnEvent(event) if event == 'QUEST_LOG_UPDATE' then self:Refresh()
--- a/WorldPlan.xml Fri Oct 21 18:10:53 2016 -0400 +++ b/WorldPlan.xml Sat Oct 22 15:36:25 2016 -0400 @@ -2,6 +2,7 @@ ..\FrameXML\UI.xsd"> <Script file="WorldPlan.lua" /> + <Script file="QuestPOI.lua" /> <Font name="WorldPlanFont" font="Interface\AddOns\Veneer\Font\ArchivoNarrow-Bold.ttf" height="13" outline="NORMAL" virtual="true" /> <Font name="WorldPlanNumberFont" font="Interface\AddOns\Veneer\Font\ArchivoNarrow-Bold.ttf" height="10" outline="NORMAL" virtual="true" /> @@ -139,12 +140,18 @@ <OnUpdate method="OnUpdate" /> <OnShow method="OnShow" /> <OnHide method="OnHide" /> + <OnMouseDown method="OnMouseDown" /> + <OnEnter method="OnEnter" /> + <OnLeave method="OnLeave" /> </Scripts> </Button> <Button name="WorldPlanFilterPin" virtual="true" inherits="WorldPlanQuestPin" mixin="WorldPlanFilterPinMixin"> <Scripts> + <OnMouseDown method="OnMouseDown" /> <OnClick method="OnClick" /> <OnLoad method="OnLoad" /> + <OnEnter method="OnEnter" /> + <OnLeave method="OnLeave" /> </Scripts> </Button>