view ObjectiveUI.lua @ 14:ed642234f017

ObjectiveFrame - implement proper tracker name text - expanded tracker prototypes to cover "objective lines" formatting and accommodation of widget variables - implement the progress bars for bonus objectives ObjectiveStyle - moved `UpdateWrapperStyle` over and renamed it to fit semantics - change the formula for block.`height` to measure non-widget content only - allows widgets to position relative to text - size FontString `status` to match block.`height` - full block height is acquired by adding block.`height` and block.`attachmentHeight` which is calculated during objective parsing ObjectiveWidgets - use string keys for generated widgets to deal with multiple objectives under the same questID, and maybe dungeon objectives - wrapper buttons use a common code path - specialized handlers for wheel scrolling moved over to fit semantics
author Nenue
date Mon, 04 Apr 2016 03:16:22 -0400
parents 9455693fc290
children 880828018bf4
line wrap: on
line source
--- ${PACKAGE_NAME}
-- @file-author@
-- @project-revision@ @project-hash@
-- @file-revision@ @file-hash@
-- Created: 3/29/2016 7:07 PM
local B = select(2,...).frame
local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
local print = B.print('Objectives')
local Tracker, AutoQuest, Quest, Cheevs = mod.Tracker, mod.AutoQuest, mod.Quest, mod.Cheevs
local itemButtonSize, itemButtonSpacing =  36, 1
local tremove, tremovebyval = table.remove, table.removebyval

--------------------------------------------------------------------
--- Functions responsible for:
--- - UI interactions that propagate to the BlizzardUI (sending RemoveQuestWatch() on remove quest action)
--- -
--------------------------------------------------------------------

Tracker.Select = function(self) end
Tracker.Open = function(self) end
Tracker.Remove = function(self) end
Tracker.Report = function(self)
  print('Stats:', self.numWatched,'items tracked,', self.numBlocks,'blocks assigned.')
end

Tracker.OnMouseUp = function(self, button)
  print(self.handler.name, self.mainStyle, self.subStyle)
  if button == 'LeftButton' then
    if IsModifiedClick("CHATLINK") and ChatEdit_GetActiveWindow() then
      self:Link()
    elseif IsModifiedClick("QUESTWATCHTOGGLE") then
      self:Remove()
    else
      self:Select()
    end
  elseif button == 'RightButton' then
    self:Open()
  end
  self.initialButton = nil
  self.modChatLink = nil
  self.modQuestWatch = nil
  self:SetStyle('TrackerBlock',  self.handler.name, self.mainStyle, self.subStyle)
  print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r')
end

Tracker.OnMouseDown = function(self, button)
  self:SetStyle('TrackerBlock', self.handler.name, 'MouseDown')
  print(IsModifiedClick("CHATLINK"), IsModifiedClick("QUESTWATCHTOGGLE"))
  print(self.info.title)
end

Quest.Select = function(self)
  SetSuperTrackedQuestID(self.info.questID)
  mod.UpdateWrapper()
end
Quest.Link = function(self)
  local questLink = GetQuestLink(block.questLogIndex);
  if ( questLink ) then
    ChatEdit_InsertLink(questLink);
  end
end
Quest.Open = function(self)
  QuestMapFrame_OpenToQuestDetails(self.info.questID)
end

Quest.Remove = function(self)
  print('removing', self.info.questLogIndex, 'from watcher')
  RemoveQuestWatch(self.info.questLogIndex)
end


-----------------------------
--- CHEEVS
Cheevs.Select = function(self)
  self:SetStyle('TrackerBlock',  self.info.type, 'Normal')
end
Cheevs.Remove = function(self)
  RemoveTrackedAchievement(self.info.cheevID)
end
Cheevs.OnMouseUp = function(self, button)
  Tracker.OnMouseUp(self, button)
end
Cheevs.Link = function(self)
  local achievementLink = GetAchievementLink(self.info.cheevID);
  if ( achievementLink ) then
    ChatEdit_InsertLink(achievementLink);
  end
end

Cheevs.Open = function(self)
  if ( not AchievementFrame ) then
    AchievementFrame_LoadUI();
  end
  if ( not AchievementFrame:IsShown() ) then
    AchievementFrame_ToggleAchievementFrame();
  end
  AchievementFrame_SelectAchievement(self.info.cheevID);
end