changeset 1:232617b8bcd5

New Order Hall mission tracker: - record active missions and shipments across characters
author Nenue
date Thu, 13 Oct 2016 05:32:43 -0400
parents 3830a592cb0f
children b8a19781f79b
files ClassPlan.lua ClassPlan.xml WorldPlan.lua WorldPlan.toc WorldPlan.xml
diffstat 5 files changed, 297 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ClassPlan.lua	Thu Oct 13 05:32:43 2016 -0400
@@ -0,0 +1,213 @@
+SLASH_CLASSPLAN1 = "/classplan"
+SLASH_CLASSPLAN2 = "/cp"
+SlashCmdList.CLASSPLAN = function(args)
+  if ClassOrderPlan:IsVisible() then
+    ClassOrderPlan:Hide()
+  else
+    ClassOrderPlan:Show()
+    DEFAULT_CHAT_FRAME:AddMessage('|cFF88FF00WorldPlan|r: Order Hall Panel')
+  end
+end
+
+ClassOrderPlanCore = {
+  blocks = {},
+  playerFirst = true,
+  timers = {}
+}
+ClassPlanBlockMixin = {
+  followers = {},
+  blocks = {},
+}
+local core, block = ClassOrderPlanCore, ClassPlanBlockMixin
+local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop
+
+function core:OnLoad ()
+  self:RegisterUnitEvent('UNIT_PORTRAIT_UPDATE', 'player')
+  self:RegisterEvent('GARRISON_MISSION_STARTED')
+  self:RegisterEvent('GARRISON_MISSION_FINISHED')
+  self:RegisterEvent('PLAYER_LOGIN')
+  self:RegisterEvent('PLAYER_ENTERING_WORLD')
+end
+
+
+function core:OnEvent (event, ...)
+  if event == 'UNIT_PORTRAIT_UPDATE' then
+    SetPortraitTexture(self.portrait, 'player')
+  elseif event == 'PLAYER_LOGIN' then
+    if not self.initialized then
+      if IsLoggedIn() then
+        WorldPlanData.OrderHall = WorldPlanData.OrderHall or {}
+        self.data = WorldPlanData.OrderHall
+
+
+        local name, realm = UnitName('player')
+        realm  = realm or GetRealmName()
+        self.profileKey = name .. '-' .. realm
+        if not self.data[self.profileKey] then
+          self.data[self.profileKey] = {}
+        end
+        self.profile = self.data[self.profileKey]
+
+        self.initialized = true
+        print('initialized')
+      end
+    end
+  else
+    self:Refresh ()
+  end
+end
+
+function core:UpdateList()
+  self.sortedMissions = self.sortedMissions or {}
+  table.wipe(self.sortedMissions)
+
+  for name, profile in pairs(self.data) do
+    local isMine = (profile == self.profile)
+    for index, data in pairs(profile.missions) do
+
+      data.classColor = profile.classColor or {r = 0.7, g = 0.7, b =0.7}
+
+      data.profileKey = name
+      data.isMine = (profile == self.profile)
+      tinsert(self.sortedMissions, data)
+    end
+  end
+
+  for i, v in ipairs(self.sortedMissions) do
+    print(i, v.missionEndTime, v.name)
+  end
+
+
+  table.sort(self.sortedMissions, function(a,b)
+    local result = false
+    if not a or not b then
+      result = true
+    else
+
+      if (a.isMine ~= b.isMine) and self.playerFirst then
+        result =  a.isMine
+      else
+        if (not b.missionEndTime) or (not a.missionEndTime) then
+          print('missing article', b.missionEndTime, a.missionEndTime)
+        end
+
+        result = ( b.missionEndTime > a.missionEndTime)
+      end
+    end
+
+    print('cmp', (b and (b.missionEndTime .. ' ' .. tostring(b.isMine)) or '-'), '>', (a and (a.missionEndTime .. ' ' .. tostring(a.isMine)) or '-'), result, n)
+    return result
+  end)
+  self.isStale = nil
+
+  local lastProfile
+  local numItems = #self.sortedMissions
+  for i, data in ipairs(self.sortedMissions) do
+    local block = self.blocks[i]
+    if not block then
+      block = CreateFrame('Frame', nil, self, 'ClassPlanBlock')
+      block:SetID(i)
+      self.numBlocks = (self.numBlocks or 0) + 1
+
+      if self.lastBlock then
+        block:SetPoint('TOPLEFT', self.lastBlock, 'BOTTOMLEFT', 0, 0)
+      else
+        block:SetPoint('TOPLEFT', self.portrait, 'TOPRIGHT', 0, 0)
+      end
+      self.lastBlock = block
+      self.blocks[i] = block
+    end
+
+    local r,g,b = 1, 1, 1
+    if data.isRare then
+      r,g,b = 0.1, 0.4, 1
+    end
+    if data.isMine then
+      block.Icon:SetVertexColor(0,1,0,1)
+    else
+      block.Icon:SetVertexColor(1,1,1)
+    end
+
+
+    --block.missionData = data
+    block.missionID = data.missionID
+    block.missionEndTime = data.missionEndTime
+    block.Icon:SetAtlas(data.typeAtlas, false)
+    block.Label:SetText(data.name)
+    block.Label:SetTextColor(r, g, b)
+
+    if lastProfile ~= data.profileKey then
+      block.Owner:SetText(data.profileKey)
+      block.Owner:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b)
+    else
+      block.Owner:SetText(nil)
+    end
+    block.Background:SetColorTexture(data.classColor.r, data.classColor.g, data.classColor.b, 0.5)
+
+    block:Show()
+    lastProfile = data.profileKey
+  end
+  for i = numItems + 1, self.numBlocks do
+    if self.blocks[i] then
+      self.blocks[i]:Hide()
+    end
+  end
+end
+
+function core:OnShow()
+  if self.isStale then
+    print('updating items on show')
+    self:UpdateList()
+  end
+end
+
+function core:Refresh ()
+  if not self.profile then
+    return
+  end
+
+  self.items = C_Garrison.GetLandingPageItems(LE_GARRISON_TYPE_7_0)
+
+  self.profile.missions = self.profile.missions or {}
+
+  self.profile.classColor = RAID_CLASS_COLORS[select(2, UnitClass('player'))]
+
+
+  print('|cFF0088FFLocal Scoop|r:', self.profileKey)
+  if #self.items >= 1 then
+    table.wipe(self.profile.missions)
+    for index, data in ipairs(self.items) do
+      print('', data.name)
+      print('  |cFF00FF00', data.timeLeft .. '|r', date("%A %I:%m %p", data.missionEndTime))
+      tinsert(self.profile.missions, data)
+    end
+  end
+
+  if self:IsVisible() then
+    self:UpdateList()
+  else
+    print('items update pending')
+    self.isStale = true
+  end
+end
+
+function block:OnUpdate()
+  if self.missionEndTime then
+    local timeLeft = self.missionEndTime - time()
+    if timeLeft < 0 then
+      self.TimeLeft:SetText('Complete!')
+    else
+      local days = floor(timeLeft/(24*3600))
+      local hours = floor(mod(timeLeft, (24*3600)) / 3600)
+      local minutes = floor(mod(timeLeft, 3600) / 60)
+      local seconds = mod(timeLeft, 60)
+      self.TimeLeft:SetText(
+        ((days > 0) and (days .. ' d') or '') ..
+            ((hours > 0) and (' '.. hours .. ' hr') or '')..
+            ((minutes > 0) and (' ' .. minutes .. ' min' or ''))
+        , 1,1,1)
+    end
+  else
+    self.TimeLeft:SetText(self.missionEndTime)
+  end
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ClassPlan.xml	Thu Oct 13 05:32:43 2016 -0400
@@ -0,0 +1,68 @@
+<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
+..\FrameXML\UI.xsd">
+
+  <Script file="ClassPlan.lua" />
+
+  <Frame name="ClassOrderPlan" mixin="ClassOrderPlanCore" parent="UIParent" hidden="true">
+    <Size x="500" y="40" />
+    <Anchors>
+      <Anchor point="TOP" />
+    </Anchors>
+    <Scripts>
+      <OnLoad method="OnLoad" />
+      <OnEvent method="OnEvent" />
+      <OnShow method="OnShow" />
+    </Scripts>
+    <Layers>
+      <Layer level="ARTWORK">
+        <Texture parentKey="portrait">
+          <Size x="40" y="40" />
+          <Anchors>
+            <Anchor point="TOPLEFT" />
+
+          </Anchors>
+        </Texture>
+      </Layer>
+    </Layers>
+  </Frame>
+
+  <Frame name="ClassPlanBlock" mixin="ClassPlanBlockMixin" virtual="true" hidden="true">
+    <Size x="400" y="32" />
+    <Scripts>
+      <OnUpdate method="OnUpdate" />
+      <OnShow method="OnShow" />
+    </Scripts>
+    <Layers>
+      <Layer level="BACKGROUND">
+        <Texture setAllPoints="true" parentKey="Background">
+          <Color a=".5" r="0" g="0" b="0" />
+        </Texture>
+      </Layer>
+      <Layer level="ARTWORK">
+        <Texture name="$parentIcon" parentKey="Icon">
+          <Size x="32" y="32" />
+          <Anchors>
+            <Anchor point="TOPLEFT" />
+          </Anchors>
+        </Texture>
+      </Layer>
+      <Layer level="OVERLAY">
+        <FontString name="$parentLabel" inherits="GameFontNormal" parentKey="Label" text="base text">
+          <Anchors>
+            <Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeKey="$parent.Icon" x="4" y="0" />
+          </Anchors>
+        </FontString>
+        <FontString name="$parentTimeLeft" inherits="GameFontNormalSmall" parentKey="TimeLeft" text="base text">
+          <Anchors>
+            <Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeKey="$parent.Label" x="4" y="-2" />
+          </Anchors>
+        </FontString>
+        <FontString name="$parentOwner" inherits="GameFontNormalSmall" parentKey="Owner" text="base text">
+          <Anchors>
+            <Anchor point="TOPRIGHT" />
+          </Anchors>
+        </FontString>
+      </Layer>
+    </Layers>
+  </Frame>
+</Ui>
\ No newline at end of file
--- a/WorldPlan.lua	Tue Oct 11 17:20:37 2016 -0400
+++ b/WorldPlan.lua	Thu Oct 13 05:32:43 2016 -0400
@@ -204,7 +204,8 @@
 local QuestsByID = {}
 local QuestPositions = {}
 local FilterInclusions = {rewardType = {}, worldQuestType = {}}
-local FilterExclusions = {rewardType = {}, worldQuestType = {}}
+local FilterExclusions = {rewardType = {}, worldQuestType = {} }
+local NotificationTypes = {}
 local ZoneInfo = {}
 local SummaryHeaders = {}
 
@@ -799,11 +800,16 @@
             pin.FadeIn:Play()
           end)
           if not notifyPlayed then
-            notifyPlayed = true
-            PlaySoundKitID(23404)
+            for k,v in pairs(NotificationTypes) do
+              if v[pin[k]] then
+                notifyPlayed = true
+                PlaySoundKitID(23404)
+              end
+            end
           end
           tinsert(debug_animate,questID)
         end
+        -- trap new but animating pins here
       else
         -- hard show existing pin
         pin:Show()
@@ -831,6 +837,7 @@
   print('   adding:', table.concat(debug_animate, ',' ))
   print('  showing:', table.concat(debug_show, ',' ))
   hasNewQuestPins = nil
+  notifyPlayed = nil
 end
 
 -- data provider manipulations for the taxi map
--- a/WorldPlan.toc	Tue Oct 11 17:20:37 2016 -0400
+++ b/WorldPlan.toc	Thu Oct 13 05:32:43 2016 -0400
@@ -9,4 +9,5 @@
 ## LoadOnDemand: 0
 ## Dependencies: Veneer
 
-WorldPlan.xml
\ No newline at end of file
+WorldPlan.xml
+ClassPlan.xml
\ No newline at end of file
--- a/WorldPlan.xml	Tue Oct 11 17:20:37 2016 -0400
+++ b/WorldPlan.xml	Thu Oct 13 05:32:43 2016 -0400
@@ -3,8 +3,8 @@
 
   <Script file="WorldPlan.lua" />
 
-  <Font name="VeneerPinFont" font="Interface\AddOns\Veneer\Font\ArchivoNarrow-Bold.ttf" height="13" outline="NORMAL" virtual="true" />
-  <Font name="VeneerTimeFont" font="Interface\AddOns\Veneer\Font\ArchivoNarrow-Bold.ttf" height="10" outline="NORMAL" virtual="true" />
+  <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" />
 
   <GameTooltip name="WorldPlanTooltip" parent="UIParent" inherits="GameTooltipTemplate">
 
@@ -90,12 +90,12 @@
             <Anchor point="BOTTOMRIGHT" relativeKey="$parent.icon" x="0" y="0" />
           </Anchors>
         </FontString>
-        <FontString inherits="VeneerPinFont" parentKey="label">
+        <FontString inherits="WorldPlanFont" parentKey="label">
           <Anchors>
             <Anchor point="BOTTOM" x="0" y="0" />
           </Anchors>
         </FontString>
-        <FontString inherits="VeneerTimeFont" parentKey="timeLabel">
+        <FontString inherits="WorldPlanNumberFont" parentKey="timeLabel">
           <Anchors>
             <Anchor point="BOTTOM" relativePoint="TOP" relativeKey="$parent.label" x="0" y="0" />
           </Anchors>