view ObjectiveUI.lua @ 15:f660f1c1e0aa

Objective Widgets - determine completion by fractional value
author Nenue
date Mon, 04 Apr 2016 03:41:28 -0400
parents ed642234f017
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