2011-08-20 07:41:29 -04:00
|
|
|
ChoreTracker = LibStub('AceAddon-3.0'):NewAddon('ChoreTracker','AceConsole-3.0','AceEvent-3.0')
|
|
|
|
local core = ChoreTracker
|
|
|
|
|
2011-08-21 10:59:28 -04:00
|
|
|
local trackedInstances = {
|
|
|
|
['Baradin Hold'] = true,
|
|
|
|
['Firelands'] = true,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-20 07:41:29 -04:00
|
|
|
local defaults = {
|
2011-08-25 02:02:50 -04:00
|
|
|
global = {
|
2011-08-20 07:41:29 -04:00
|
|
|
valorPoints = {},
|
|
|
|
lockouts = {},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function core:OnInitialize()
|
|
|
|
self.db = LibStub('AceDB-3.0'):New('ChoreTrackerDB',defaults,'Default')
|
|
|
|
end
|
|
|
|
|
|
|
|
function core:OnEnable()
|
2011-08-21 12:23:18 -04:00
|
|
|
local name = UnitName('player')
|
|
|
|
|
2011-08-23 04:27:44 -04:00
|
|
|
if self.db.global.lockouts[name] == nil then
|
|
|
|
self.db.global.lockouts[name] = {}
|
2011-08-21 12:23:18 -04:00
|
|
|
end
|
|
|
|
|
2011-08-21 14:26:49 -04:00
|
|
|
self:RegisterChatCommand('ct','ViewChores');
|
2011-08-21 14:10:05 -04:00
|
|
|
self:RegisterEvent('UPDATE_INSTANCE_INFO','UpdateChores')
|
2011-08-20 07:41:29 -04:00
|
|
|
end
|
|
|
|
|
2011-08-21 14:26:49 -04:00
|
|
|
function core:ViewChores()
|
2011-08-25 02:02:50 -04:00
|
|
|
local ChoresDisplay = CreateFrame('Frame','ChoreTrackerFrame',UIParent)
|
|
|
|
ChoresDisplay:SetPoint('CENTER')
|
|
|
|
ChoresDisplay:EnableMouse(true)
|
|
|
|
ChoresDisplay:SetMovable(true)
|
|
|
|
ChoresDisplay:RegisterForDrag('LeftButton')
|
|
|
|
|
|
|
|
ChoresDisplay:SetScript('OnDragStart',ChoresDisplay.StartMoving)
|
|
|
|
ChoresDisplay:SetScript('OnDragStop',ChoresDisplay.StopMovingOrSizing)
|
|
|
|
ChoresDisplay:SetScript('OnHide',ChoresDisplay.StopMovingOrSizing)
|
|
|
|
|
|
|
|
ChoresDisplay.background = ChoresDisplay:CreateTexture(nil,'BACKGROUND')
|
|
|
|
ChoresDisplay.background:SetAllPoints(true)
|
|
|
|
ChoresDisplay.background:SetTexture(1,0.5,0,0.5)
|
|
|
|
|
|
|
|
ChoresDisplay.lines = {}
|
|
|
|
local lineCount = 1
|
2011-08-23 04:27:44 -04:00
|
|
|
for k,v in pairs(self.db.global.valorPoints) do
|
2011-08-25 02:02:50 -04:00
|
|
|
local line = ChoresDisplay:CreateFontString(nil,'OVERLAY','GameFontNormal')
|
|
|
|
ChoresDisplay.lines[lineCount] = line
|
|
|
|
|
|
|
|
if lineCount > 1 then
|
|
|
|
line:SetPoint('TOPLEFT',ChoresDisplay.lines[lineCount - 1],'BOTTOMLEFT',0,0)
|
|
|
|
line:SetPoint('TOPRIGHT',ChoresDisplay.lines[lineCount - 1],'BOTTOMRIGHT',0,0)
|
|
|
|
else
|
|
|
|
line:SetPoint('TOPLEFT',ChoresDisplay,'TOPLEFT',5,-5)
|
|
|
|
line:SetPoint('TOPRIGHT',ChoresDisplay,'TOPRIGHT',5,-5)
|
|
|
|
end
|
|
|
|
|
|
|
|
line:SetFormattedText("%s - %d",k,v)
|
|
|
|
lineCount = lineCount + 1
|
2011-08-21 14:26:49 -04:00
|
|
|
end
|
2011-08-25 02:02:50 -04:00
|
|
|
|
|
|
|
local height = select(2,GameFontNormal:GetFont())
|
|
|
|
ChoresDisplay:SetHeight(height * lineCount)
|
|
|
|
ChoresDisplay:SetWidth(300)
|
|
|
|
|
|
|
|
ChoresDisplay:Show()
|
2011-08-21 14:26:49 -04:00
|
|
|
end
|
|
|
|
|
2011-08-21 14:10:05 -04:00
|
|
|
function core:UpdateChores()
|
2011-08-21 00:03:50 -04:00
|
|
|
local level = UnitLevel('player')
|
2011-08-20 07:41:29 -04:00
|
|
|
|
2011-08-25 02:02:50 -04:00
|
|
|
--reset data if necessary
|
|
|
|
core:ResetInstances()
|
|
|
|
core:ResetValorPoints()
|
|
|
|
|
2011-08-21 00:03:50 -04:00
|
|
|
if(level == 85) then
|
2011-08-21 14:10:05 -04:00
|
|
|
local _,_,_,earnedThisWeek = GetCurrencyInfo(396)
|
|
|
|
local name = UnitName('player')
|
|
|
|
|
2011-08-21 12:48:18 -04:00
|
|
|
--store Valor Points
|
2011-08-23 04:27:44 -04:00
|
|
|
self.db.global.valorPoints[name] = earnedThisWeek
|
2011-08-21 11:01:32 -04:00
|
|
|
|
2011-08-21 12:48:18 -04:00
|
|
|
--store Saved Instances
|
2011-08-21 11:01:32 -04:00
|
|
|
local savedInstances = GetNumSavedInstances()
|
2011-08-21 14:10:05 -04:00
|
|
|
for i = 1, savedInstances do
|
2011-08-21 10:59:28 -04:00
|
|
|
local instanceName,_,instanceReset,_,_,_,_,_,_,_,_,defeatedBosses = GetSavedInstanceInfo(i)
|
|
|
|
|
2011-08-21 12:23:18 -04:00
|
|
|
if trackedInstances[instanceName] == true then
|
2011-08-21 10:59:28 -04:00
|
|
|
if instanceReset > 0 then
|
2011-08-23 04:27:44 -04:00
|
|
|
self.db.global.lockouts[name][instanceName] = {}
|
|
|
|
self.db.global.lockouts[name][instanceName].defeatedBosses = defeatedBosses
|
|
|
|
self.db.global.lockouts[name][instanceName].resetTime = time() + instanceReset
|
2011-08-21 10:59:28 -04:00
|
|
|
else
|
2011-08-23 04:27:44 -04:00
|
|
|
self.db.global.lockouts[name][instanceName] = nil
|
2011-08-21 10:59:28 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-08-21 00:03:50 -04:00
|
|
|
end
|
2011-08-23 04:27:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
function core:ResetInstances()
|
|
|
|
for k,v in pairs(self.db.global.lockouts) do
|
|
|
|
for x,y in pairs(self.db.global.lockouts[k]) do
|
|
|
|
if y.resetTime < time() then
|
2011-08-25 02:02:50 -04:00
|
|
|
self.db.global.lockouts[k][x] = nil
|
2011-08-23 04:27:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function core:ResetValorPoints()
|
|
|
|
|
2011-08-20 07:41:29 -04:00
|
|
|
end
|