1
0
Fork 0

Compare commits

...

20 Commits

Author SHA1 Message Date
Andrew Tomaka 5f7cfc7610 Use CURRENCY_DISPLAY_UPDATE to track Valor Point spending. 2011-12-06 19:13:13 -05:00
Andrew Tomaka da5111170f Probably fix LFR lockouts not resetting. 2011-12-06 17:23:06 -05:00
Andrew Tomaka 4cee09a6d4 Fix issue with low level characters. 2011-12-04 03:14:36 -05:00
Andrew Tomaka be3b33f3e4 Track total VP for each character and display if enabled. 2011-12-03 23:01:37 -05:00
Andrew Tomaka 4a80527bf5 Add LFR instances to defaults directly from API for localization reasons. 2011-12-03 22:42:03 -05:00
Andrew Tomaka 53974a8640 Use LFG_LOCK_INFO_RECEIVED for updating LFR data. 2011-12-03 21:01:07 -05:00
Andrew Tomaka ba5151792f Track the two new LFR Instances. 2011-12-03 06:16:13 -05:00
Andrew Tomaka 20156e6f94 Change defaults to account for new 4.3 instances. 2011-12-03 04:38:08 -05:00
Andrew Tomaka 0b3278e883 Change max valor points to 1000 2011-12-03 04:26:10 -05:00
Andrew Tomaka 0fefdb710d 4.3 TOC Bump 2011-12-03 04:24:05 -05:00
Andrew Tomaka 2c5c8735cb TOC Bump for 4.3 2011-12-02 17:10:28 -05:00
Andrew Tomaka 64af7e3bc2 Make sure that vpResetTime is refreshed when the UI is reloaded 2011-10-18 14:15:38 -04:00
Andrew Tomaka 4262c0cdb6 Include an option that will allow the user to show a realm abbreviation next to their character name. 2011-10-16 01:17:43 -04:00
Andrew Tomaka 691540a108 Fixed a bug preventing Valor Points from resetting. 2011-10-11 12:09:45 -04:00
Andrew Tomaka 754ad92e27 More scope fixes. 2011-10-08 19:54:12 -04:00
Andrew Tomaka 8309a33c8f Several scope fixes. 2011-10-08 19:49:07 -04:00
Andrew Tomaka 130467f864 Store all character information at enable instead of recalling everytime it's needed. 2011-10-08 18:26:00 -04:00
Andrew Tomaka 2b214a8943 Combine raid instance lockout search functions. 2011-10-08 06:35:16 -04:00
Andrew Tomaka 79ba491c9a Various reorganizing. 2011-10-07 19:52:02 -04:00
Andrew Tomaka d7efdbe934 Only update instance lockouts when raid info is fresh. 2011-10-07 02:41:43 -04:00
3 changed files with 411 additions and 255 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.hg
.hgignore
.hgtags

View File

@ -1,15 +1,16 @@
ChoreTracker = LibStub('AceAddon-3.0'):NewAddon('ChoreTracker', 'AceConsole-3.0', 'AceEvent-3.0')
local core = ChoreTracker
local LQT, LDB, LDBIcon, LBZ
local db, tooltip, vpResetTime
local fontObjects = { }
local LQT, LDB, LDBIcon
-- Localization
local L = LibStub('AceLocale-3.0'):GetLocale('ChoreTracker')
-- Get localized instances
LBZ = LibStub('LibBabble-Zone-3.0')
local Z = LBZ:GetLookupTable()
local Z = LibStub('LibBabble-Zone-3.0'):GetLookupTable()
--
local CURRENT_MAX_LEVEL = 85
local MAX_VALOR_POINTS = 1000
local defaults = {
global = {},
@ -20,16 +21,30 @@ local defaults = {
sortType = 1,
sortDirection = 1,
currentOnTop = false,
showServer = false,
showTotalVp = true,
instances = {
[Z['Dragon Soul']] = { abbreviation = 'DS', enable = true, removed = false, },
[Z['Baradin Hold']] = { abbreviation = 'BH', enable = true, removed = false, },
[Z['Firelands']] = { abbreviation = 'FL', enable = true, removed = false, },
[Z['The Bastion of Twilight']] = { abbreviation = 'BoT', enable = true, removed = false, },
[Z['Blackwing Descent']] = { abbreviation = 'BWD', enable = true, removed = false, },
[Z['Throne of the Four Winds']] = { abbreviation = '4W', enable = true, removed = false, },
[Z['The Bastion of Twilight']] = { abbreviation = 'BoT', enable = false, removed = false, },
[Z['Blackwing Descent']] = { abbreviation = 'BWD', enable = false, removed = false, },
[Z['Throne of the Four Winds']] = { abbreviation = '4W', enable = false, removed = false, },
},
lfrs = {}
},
}
-- Setup LFR Defaults
local RFDungeonCount = GetNumRFDungeons()
for i = 1, RFDungeonCount do
id, instanceName = GetRFDungeonInfo(i)
defaults.profile.lfrs[instanceName] = { enable = true, removed = false, }
defaults.profile.lfrs[instanceName].abbreviation = string.sub(instanceName, 0, 1)
end
local options = {
name = 'ChoreTracker',
type = 'group',
@ -44,8 +59,8 @@ local options = {
desc = L['Removes the icon from your minimap.'],
type = 'toggle',
order = 1,
get = function(info) return db.profile.minimap.hide end,
set = function(info, value) db.profile.minimap.hide = value LDBIcon[value and 'Hide' or 'Show'](LDBIcon, 'ChoreTracker') end,
get = function(info) return core.db.profile.minimap.hide end,
set = function(info, value) core.db.profile.minimap.hide = value LDBIcon[value and 'Hide' or 'Show'](LDBIcon, 'ChoreTracker') end,
},
verticalHeader = {
name = L['Vertical Sorting'],
@ -58,8 +73,8 @@ local options = {
type = 'toggle',
width = 'full',
order = 3,
get = function(info) return db.profile.currentOnTop end,
set = function(info, value) db.profile.currentOnTop = value end,
get = function(info) return core.db.profile.currentOnTop end,
set = function(info, value) core.db.profile.currentOnTop = value end,
},
sortType = {
name = L['Sort Field'],
@ -67,8 +82,8 @@ local options = {
type = 'select',
order = 5,
values = { L['Character'], L['Valor Points'], L['Class'] },
get = function(info) return db.profile.sortType end,
set = function(info, value) db.profile.sortType = value end,
get = function(info) return core.db.profile.sortType end,
set = function(info, value) core.db.profile.sortType = value end,
},
sortingDirection = {
name = L['Sorting Direction'],
@ -76,71 +91,112 @@ local options = {
type = 'select',
order = 6,
values = { L['Ascending'], L['Descending'] },
get = function(info) return db.profile.sortDirection end,
set = function(info, value) db.profile.sortDirection = value end,
get = function(info) return core.db.profile.sortDirection end,
set = function(info, value) core.db.profile.sortDirection = value end,
},
otherHeader = {
name = '',
type = 'header',
order = 20,
},
showServer = {
name = L['Show Server'],
desc = L['Show the server abbreviation next to a character name in the list.'],
type = 'toggle',
width = 'full',
order = 21,
get = function(info) return core.db.profile.showServer end,
set = function(info, value) core.db.profile.showServer = value end,
},
showTotalVp = {
name = L['Show Total VP'],
desc = L['Show the total valor points for all characters in the tooltip.'],
type = 'toggle',
width = 'full',
order = 22,
get = function(info) return core.db.profile.showTotalVp end,
set = function(info, value) core.db.profile.showTotalVp = value end,
},
},
},
instances = {
name = L['Instances'],
type = 'group',
order = 2,
order = 20,
args = { },
}
},
},
}
function core:OnInitialize()
-- Prepare the database if necessary
db = LibStub('AceDB-3.0'):New('ChoreTrackerDB', defaults, 'Default')
self.db = LibStub('AceDB-3.0'):New('ChoreTrackerDB', defaults, 'Default')
local level = UnitLevel('player')
local realm = GetRealmName()
local name = UnitName('player')
if db.global[realm] == nil then
db.global[realm] = {}
self.character = {
name = UnitName('player'),
level = UnitLevel('player'),
class = UnitClass('player'),
realm = GetRealmName(),
}
self.character.class = self.character.class:lower():gsub("%s*(.-)%s*", "%1")
if self.db.global[self.character.realm] == nil then
self.db.global[self.character.realm] = {}
end
if db.global[realm][name] == nil and level == 85 then
db.global[realm][name] = {}
if self.db.global[self.character.realm][self.character.name] == nil and self.character.level == CURRENT_MAX_LEVEL then
self.db.global[self.character.realm][self.character.name] = {}
local class = UnitClass('player')
class = class:lower()
if class == 'deathknight' then
class = 'death knight'
end
db.global[realm][name].class = class
db.global[realm][name].valorPoints = {
valorPoints = 0,
self.db.global[self.character.realm][self.character.name].class = self.character.class
self.db.global[self.character.realm][self.character.name].valorPoints = {
total = 0,
points = 0,
resetTime = 0,
}
db.global[realm][name].lockouts = {}
self.db.global[self.character.realm][self.character.name].lockouts = {}
end
if self.db.global[self.character.realm][self.character.name] ~= nil then
if self.db.global[self.character.realm][self.character.name].lfrs == nil and self.character.level == CURRENT_MAX_LEVEL then
self.db.global[self.character.realm][self.character.name].lfrs = {}
end
end
-- Add LFR stuff to profile if it isn't there already
core:LFRProfileUpdate()
end
function core:OnEnable()
LQT = LibStub('LibQTip-1.0')
self.instanceInfoTime = false
self.vpResetTime = false
-- Setup font strings for later. (RAID_CLASS_COLORS always indexed in English?)
for class,color in pairs(RAID_CLASS_COLORS) do
self.fontObjects = { }
for class, color in pairs(RAID_CLASS_COLORS) do
class = class:lower()
if class == 'deathknight' then
class = 'death knight'
end
fontObjects[class] = CreateFont('ClassFont' .. class)
fontObjects[class]:CopyFontObject(GameTooltipText)
fontObjects[class]:SetTextColor(color.r, color.g, color.b)
self.fontObjects[class] = CreateFont('ClassFont' .. class)
self.fontObjects[class]:CopyFontObject(GameTooltipText)
self.fontObjects[class]:SetTextColor(color.r, color.g, color.b)
end
fontObjects['green'] = CreateFont('FlagFontGreen')
fontObjects['green']:CopyFontObject(GameTooltipText)
fontObjects['green']:SetTextColor(0, 255, 0)
self.fontObjects['green'] = CreateFont('FlagFontGreen')
self.fontObjects['green']:CopyFontObject(GameTooltipText)
self.fontObjects['green']:SetTextColor(0, 255, 0)
fontObjects['red'] = CreateFont('FlagFontRed')
fontObjects['red']:CopyFontObject(GameTooltipText)
fontObjects['red']:SetTextColor(255, 0, 0)
self.fontObjects['red'] = CreateFont('FlagFontRed')
self.fontObjects['red']:CopyFontObject(GameTooltipText)
self.fontObjects['red']:SetTextColor(255, 0, 0)
-- Setup instance stuff for options
core:DrawInstanceOptions()
-- Add options to Interface Panel
LibStub('AceConfigRegistry-3.0'):RegisterOptionsTable('ChoreTracker', options)
local ACD = LibStub('AceConfigDialog-3.0')
ACD:AddToBlizOptions('ChoreTracker', 'ChoreTracker')
options.args.profile = LibStub('AceDBOptions-3.0'):GetOptionsTable(self.db)
-- Setup LDB
LDB = LibStub('LibDataBroker-1.1'):NewDataObject('ChoreTracker', {
@ -156,14 +212,14 @@ function core:OnEnable()
end
else
-- Cycle through our sort options
if db.profile.sortType == 1 then
db.profile.sortType = 2
if core.db.profile.sortType == 1 then
core.db.profile.sortType = 2
core:DrawTooltip()
elseif db.profile.sortType == 2 then
db.profile.sortType = 3
elseif core.db.profile.sortType == 2 then
core.db.profile.sortType = 3
core:DrawTooltip()
else
db.profile.sortType = 1
core.db.profile.sortType = 1
core:DrawTooltip()
end
end
@ -171,42 +227,37 @@ function core:OnEnable()
OnEnter = function(self)
core:DrawTooltip()
tooltip:SmartAnchorTo(self)
tooltip:Show()
core.tooltip:SmartAnchorTo(self)
core.tooltip:Show()
end,
OnLeave = function(self)
LQT:Release(tooltip)
tooltip = nil
LQT:Release(core.tooltip)
core.tooltip = nil
end,
})
-- Deal with minimap
LDBIcon = LibStub('LibDBIcon-1.0')
LDBIcon:Register('ChoreTracker', LDB, db.profile.minimap)
LDBIcon:Register('ChoreTracker', LDB, self.db.profile.minimap)
if db.profile.minimap.hide then
if self.db.profile.minimap.hide then
LDBIcon:Hide('ChoreTracker')
else
LDBIcon:Show('ChoreTracker')
end
-- Setup instance stuff for options
core:DrawInstanceOptions()
-- Add options to Interface Panel
LibStub('AceConfigRegistry-3.0'):RegisterOptionsTable('ChoreTracker', options)
local ACD = LibStub('AceConfigDialog-3.0')
ACD:AddToBlizOptions('ChoreTracker', 'ChoreTracker')
options.args.profile = LibStub('AceDBOptions-3.0'):GetOptionsTable(db)
-- Register events
local level = UnitLevel('player')
if level == 85 then
if self.character.level == CURRENT_MAX_LEVEL then
self:RegisterEvent('PLAYER_ENTERING_WORLD')
self:RegisterEvent('CALENDAR_UPDATE_EVENT_LIST')
self:RegisterEvent('UPDATE_INSTANCE_INFO')
self:RegisterEvent('CHAT_MSG_CURRENCY')
self:RegisterEvent('LFG_UPDATE_RANDOM_INFO')
-- Since CHAT_MSG_CURRENCY will not fire if you have max currency
self:RegisterEvent('LFG_LOCK_INFO_RECEIVED')
self:RegisterEvent('UPDATE_INSTANCE_INFO')
self:RegisterEvent('CURRENCY_DISPLAY_UPDATE')
self:RegisterEvent('CHAT_MSG_CURRENCY')
self:RegisterEvent('INSTANCE_ENCOUNTER_ENGAGE_UNIT')
end
@ -214,24 +265,38 @@ function core:OnEnable()
OpenCalendar()
-- Reset data if necessary
core:ResetInstances()
core:ResetRaidLockouts()
core:ResetValorPoints()
core:ResetLFRLockouts()
end
--[[ EVENTS ]]--
function core:PLAYER_ENTERING_WORLD()
self.vpResetTime = core:FindLockout(Z['Baradin Hold'])
end
function core:CALENDAR_UPDATE_EVENT_LIST()
core:GetNextVPReset()
self.vpResetTime = core:FindLockout(Z['Baradin Hold'])
end
function core:UPDATE_INSTANCE_INFO()
core:UpdateChores()
self.instanceInfoTime = time()
core:UpdateRaidLockouts()
end
function core:LFG_UPDATE_RANDOM_INFO()
core:UpdateChores()
core:UpdateValorPoints()
end
function core:LFG_LOCK_INFO_RECEIVED()
core:UpdateLFRLockouts()
end
function core:CURRENCY_DISPLAY_UPDATE()
core:UpdateValorPoints()
end
function core:CHAT_MSG_CURRENCY()
@ -246,9 +311,86 @@ function core:INSTANCE_ENCOUNTER_ENGAGE_UNIT()
end
--[[ FUNCTIONS ]]--
function core:UpdateValorPoints()
local _, amount, _, earnedThisWeek = GetCurrencyInfo(396)
if self.db.global[self.character.realm][self.character.name].valorPoints == nil then
self.db.global[self.character.realm][self.character.name].valorPoints = {}
end
self.db.global[self.character.realm][self.character.name].valorPoints.points = earnedThisWeek
self.db.global[self.character.realm][self.character.name].valorPoints.total = amount
if self.vpResetTime ~= false then
self.db.global[self.character.realm][self.character.name].valorPoints.resetTime = self.vpResetTime
end
end
function core:ResetValorPoints()
for realm, realmTable in pairs(self.db.global) do
for name in pairs(realmTable) do
if self.db.global[realm][name].valorPoints.resetTime < time() then
self.db.global[realm][name].valorPoints.points = 0
self.db.global[realm][name].valorPoints.resetTime = 0
end
end
end
end
function core:UpdateRaidLockouts()
local savedInstances = GetNumSavedInstances()
for i = 1, savedInstances do
local instanceName, _, instanceReset, _, _, _, _, _, _, _, _, defeatedBosses = GetSavedInstanceInfo(i)
if self.db.profile.instances[instanceName] ~= nil then
if instanceReset > 0 then
self.db.global[self.character.realm][self.character.name].lockouts[instanceName] = {}
self.db.global[self.character.realm][self.character.name].lockouts[instanceName].defeatedBosses = defeatedBosses
self.db.global[self.character.realm][self.character.name].lockouts[instanceName].resetTime = self.instanceInfoTime + instanceReset
end
end
end
end
function core:ResetRaidLockouts()
for realm,realmTable in pairs(self.db.global) do
for name in pairs(realmTable) do
for instance,instanceTable in pairs(self.db.global[realm][name].lockouts) do
if instanceTable.resetTime < time() then
self.db.global[realm][name].lockouts[instance] = nil
end
end
end
end
end
function core:UpdateLFRLockouts()
local RFDungeonCount = GetNumRFDungeons()
for i = 1, RFDungeonCount do
id, instanceName = GetRFDungeonInfo(i)
_, defeatedBosses = GetLFGDungeonNumEncounters(id)
if self.db.profile.lfrs[instanceName] ~= nil then
self.db.global[self.character.realm][self.character.name].lfrs[instanceName] = {}
self.db.global[self.character.realm][self.character.name].lfrs[instanceName].defeatedBosses = defeatedBosses
self.db.global[self.character.realm][self.character.name].lfrs[instanceName].resetTime = self.vpResetTime
end
end
end
function core:ResetLFRLockouts()
for realm,realmTable in pairs(self.db.global) do
for name in pairs(realmTable) do
for instance,instanceTable in pairs(self.db.global[realm][name].lfrs) do
if instanceTable.resetTime < time() then
self.db.global[realm][name].lfrs[instance] = nil
end
end
end
end
end
function core:DrawInstanceOptions()
-- Redraw our instance options everytime they are updated.
options.args.instances.args = {
@ -258,131 +400,112 @@ function core:DrawInstanceOptions()
type = 'input',
order = 1,
set = function(info, value)
if core:VerifyInstance(value) then
db.profile.instances[value] = { }
db.profile.instances[value].abbreviation = string.sub(value,0,1)
db.profile.instances[value].enable = true
db.profile.instances[value].removed = false
if core:FindLockout(value) then
self.db.profile.instances[value] = { }
self.db.profile.instances[value].abbreviation = string.sub(value,0,1)
self.db.profile.instances[value].enable = true
self.db.profile.instances[value].removed = false
core:DrawInstanceOptions()
else
print('Invalid instance')
end
end,
},
lfrsHeader = {
name = L['Looking for Raid Instances'],
type = 'header',
order = 100,
},
instancesHeader = {
name = L['Instances'],
type = 'header',
order = 2,
order = 500,
},
}
local i = 1
for instance, abbreviation in pairs(db.profile.instances) do
if db.profile.instances[instance].removed == false then
for instance, abbreviation in pairs(self.db.profile.instances) do
if self.db.profile.instances[instance].removed == false then
options.args.instances.args[instance .. 'Enable'] = {
type = 'toggle',
name = instance,
order = 4 * i,
get = function(info) return db.profile.instances[instance].enable end,
order = 500 + (5 * i) + 0,
get = function(info) return self.db.profile.instances[instance].enable end,
set = function(info, value)
db.profile.instances[instance].enable = value
self.db.profile.instances[instance].enable = value
core:DrawInstanceOptions()
end,
}
options.args.instances.args[instance] = {
options.args.instances.args[instance .. 'Abbreviation'] = {
type = 'input',
name = '',
order = 4 * i + 1,
order = 500 + (5 * i) + 1,
width = 'half',
get = function(info) return db.profile.instances[instance].abbreviation end,
set = function(info, value) db.profile.instances[instance].abbreviation = value end,
get = function(info) return self.db.profile.instances[instance].abbreviation end,
set = function(info, value) self.db.profile.instances[instance].abbreviation = value end,
}
options.args.instances.args[instance .. 'Remove'] = {
type = 'execute',
name = L['Remove'],
order = 4 * i + 2,
order = 500 + (5 * i) + 2,
width = 'half',
confirm = true,
func = function()
db.profile.instances[instance].removed = true
self.db.profile.instances[instance].removed = true
core:DrawInstanceOptions()
end,
}
options.args.instances.args[instance .. 'Spacer'] = {
type = 'description',
name = '',
order = 4 * i + 3,
order = 500 + (5 * i) + 3,
}
i = i + 1
end
end
i = 1
for instance, abbreviation in pairs(self.db.profile.lfrs) do
if self.db.profile.lfrs[instance].removed == false then
options.args.instances.args[instance .. 'Enable'] = {
type = 'toggle',
name = instance,
order = 100 + (5 * i) + 0,
get = function(info) return self.db.profile.lfrs[instance].enable end,
set = function(info, value)
self.db.profile.lfrs[instance].enable = value
core:DrawInstanceOptions()
end,
}
options.args.instances.args[instance .. 'Abbreviation'] = {
type = 'input',
name = '',
order = 100 + (5 * i) + 1,
width = 'half',
get = function(info) return self.db.profile.lfrs[instance].abbreviation end,
set = function(info, value) self.db.profile.lfrs[instance].abbreviation = value end,
}
options.args.instances.args[instance .. 'Remove'] = {
type = 'execute',
name = L['Remove'],
order = 100 + (5 * i) + 2,
width = 'half',
confirm = true,
func = function()
self.db.profile.lfrs[instance].removed = true
core:DrawInstanceOptions()
end,
}
options.args.instances.args[instance .. 'Spacer'] = {
type = 'description',
name = '',
order = 100 + (5 * i) + 3,
}
i = i + 1
end
end
end
function core:UpdateChores()
-- Reset data if necessary
core:ResetInstances()
core:ResetValorPoints()
local realm = GetRealmName()
local name = UnitName('player')
local _,_,_,earnedThisWeek = GetCurrencyInfo(396)
-- Store Valor Points if we were able to establish a reset time.
-- Try to alleviate issues with vpResetTime not getting set
-- by updating vp regardless and assuming previous time is still
-- correct.
if db.global[realm][name].valorPoints == nil then
db.global[realm][name].valorPoints = {}
end
db.global[realm][name].valorPoints.points = earnedThisWeek
if vpResetTime ~= nil then
db.global[realm][name].valorPoints.resetTime = vpResetTime
end
-- Store Saved Instances; sometimes, there can be two lockouts to the same instance
local savedInstances = GetNumSavedInstances()
for i = 1, savedInstances do
local instanceName, _, instanceReset, _, _, _, _, _, _, _, _, defeatedBosses = GetSavedInstanceInfo(i)
if db.profile.instances[instanceName] ~= nil then
if instanceReset > 0 then
db.global[realm][name].lockouts[instanceName] = {}
db.global[realm][name].lockouts[instanceName].defeatedBosses = defeatedBosses
db.global[realm][name].lockouts[instanceName].resetTime = time() + instanceReset
-- Let's not delete instances with no lockout for now. ResetInstances() should take care of this
-- and it solves an issue with two lockouts to the same instance being listed.
--else
-- db.global[realm][name].lockouts[instanceName] = nil
end
end
end
end
function core:ResetInstances()
for realm,realmTable in pairs(db.global) do
for name in pairs(realmTable) do
for instance,instanceTable in pairs(db.global[realm][name].lockouts) do
if instanceTable.resetTime < time() then
db.global[realm][name].lockouts[instance] = nil
end
end
end
end
end
function core:ResetValorPoints()
for realm,realmTable in pairs(db.global) do
for name in pairs(realmTable) do
if db.global[realm][name].valorPoints.resetTime < time() then
db.global[realm][name].valorPoints = {
valorPoints = 0,
resetTime = 0,
}
end
end
end
end
function core:GetNextVPReset()
function core:FindLockout(instance)
-- We need to have access to the instance lockouts on the calendar.
local currentCalendarSetting = GetCVar('calendarShowResets')
SetCVar('calendarShowResets', 1)
@ -395,8 +518,8 @@ function core:GetNextVPReset()
local _, month, day, year = CalendarGetDate()
local monthOffset = 0
local resetDate = nil
while resetDate == nil do
local resetDate = false
while resetDate == false do
local todaysEvents = CalendarGetNumDayEvents(monthOffset, day)
for i = 1,todaysEvents do
@ -406,7 +529,7 @@ function core:GetNextVPReset()
local title,hour,minute = CalendarGetDayEvent(monthOffset, day, i)
if title == Z['Baradin Hold'] then
if title == instance then
resetDate = { year = year, month = month + monthOffset, day = day }
end
end
@ -423,101 +546,79 @@ function core:GetNextVPReset()
SetCVar('calendarShowResets', currentCalendarSetting)
-- And combine for the reset timestamp
if(resetDate ~= nil) then
if(resetDate ~= false) then
resetDate.hour = resetTime.hour
resetDate.min = resetTime.min
resetDate.sec = resetTime.sec
vpResetTime = time(resetDate)
return time(resetDate)
else
print('Error: Could not caculate the next VP Reset Time.')
vpResetTime = nil
return false
end
end
function core:VerifyInstance(instance)
-- Use a method similar to GetNextVPReset() to make sure the instance
-- has a lockout on the calendar
local currentCalendarSetting = GetCVar('calendarShowResets')
SetCVar('calendarShowResets', 1)
local _, month, day, year = CalendarGetDate()
local monthOffset = 0
local resetDate = nil
while resetDate == nil do
local todaysEvents = CalendarGetNumDayEvents(monthOffset, day)
for i = 1,todaysEvents do
if todaysEvents == 0 then
break
end
local title,hour,minute = CalendarGetDayEvent(monthOffset, day, i)
if title == instance then
return true
end
end
day = day + 1
if day > 31 then
if monthOffset == 1 then break end
day = 1
monthOffset = 1
end
end
-- Reset the calendar to the original settings
SetCVar('calendarShowResets', currentCalendarSetting)
return false
end
function core:DrawTooltip()
-- UpdateChores before we show the tooltip to make sure we have the most recent data
local level = UnitLevel('player')
if level == 85 then
core:UpdateChores()
if self.character.level == CURRENT_MAX_LEVEL then
-- Should not update without being 100% sure our raid info is correct
core:UpdateValorPoints()
core:UpdateRaidLockouts()
core:UpdateLFRLockouts()
end
if tooltip then
tooltip:ClearAllPoints()
tooltip:Clear()
tooltip = nil
if self.tooltip then
self.tooltip:ClearAllPoints()
self.tooltip:Clear()
self.tooltip = nil
end
local columnCount = 2
for instance in pairs(db.profile.instances) do
if db.profile.instances[instance].enable == true and db.profile.instances[instance].removed == false then
for instance in pairs(self.db.profile.instances) do
if self.db.profile.instances[instance].enable == true and self.db.profile.instances[instance].removed == false then
columnCount = columnCount + 1
end
end
tooltip = LQT:Acquire('ChoreTrackerTooltip', columnCount, 'LEFT', 'CENTER', 'RIGHT')
for instance in pairs(self.db.profile.lfrs) do
if self.db.profile.lfrs[instance].enable == true and self.db.profile.lfrs[instance].removed == false then
columnCount = columnCount + 1
end
end
self.tooltip = LQT:Acquire('ChoreTrackerTooltip', columnCount, 'LEFT', 'CENTER', 'RIGHT')
-- Populate a table with the information we want for our tooltip
local tooltipTable = {}
local currentTable = {}
for realm in pairs(db.global) do
for name in pairs(db.global[realm]) do
local valorPoints = db.global[realm][name].valorPoints.points
local class = db.global[realm][name].class
for realm in pairs(self.db.global) do
for name in pairs(self.db.global[realm]) do
local valorPoints = self.db.global[realm][name].valorPoints.points
local class = self.db.global[realm][name].class
local totalVp = self.db.global[realm][name].valorPoints.total
if valorPoints == nil then
valorPoints = 0
end
local characterTable = { name = name, realm = realm, class = class, valorPoints = valorPoints }
local characterTable = { name = name, realm = realm, class = class, valorPoints = valorPoints, totalVp = totalVp }
for instance in pairs(db.profile.instances) do
for instance in pairs(self.db.profile.instances) do
local defeatedBosses
if db.global[realm][name].lockouts[instance] ~= nil then
defeatedBosses = db.global[realm][name].lockouts[instance].defeatedBosses
if self.db.global[realm][name].lockouts[instance] ~= nil then
defeatedBosses = self.db.global[realm][name].lockouts[instance].defeatedBosses
else
defeatedBosses = 0
end
characterTable[instance] = defeatedBosses
end
if name == UnitName('player') and db.profile.currentOnTop == true then
for instance in pairs(self.db.profile.lfrs) do
local defeatedBosses
if self.db.global[realm][name].lfrs[instance] ~= nil then
defeatedBosses = self.db.global[realm][name].lfrs[instance].defeatedBosses
else
defeatedBosses = 0
end
characterTable[instance] = defeatedBosses
end
if name == UnitName('player') and self.db.profile.currentOnTop == true then
currentTable = characterTable
else
table.insert(tooltipTable, characterTable)
@ -528,18 +629,18 @@ function core:DrawTooltip()
-- Sort table according to options.
local sortTooltip = function(a, b)
local aValue, bValue
if db.profile.sortType == 1 then
if self.db.profile.sortType == 1 then
aValue = a.name:lower()
bValue = b.name:lower()
elseif db.profile.sortType == 2 then
elseif self.db.profile.sortType == 2 then
aValue = a.valorPoints
bValue = b.valorPoints
elseif db.profile.sortType == 3 then
elseif self.db.profile.sortType == 3 then
aValue = a.class
bValue = b.class
end
if db.profile.sortDirection == 1 then
if self.db.profile.sortDirection == 1 then
return aValue < bValue
else
return aValue > bValue
@ -548,7 +649,7 @@ function core:DrawTooltip()
table.sort(tooltipTable, sortTooltip )
-- Toss the current character on top if it is set that way
if db.profile.currentOnTop == true then
if self.db.profile.currentOnTop == true then
table.insert(tooltipTable, 1, currentTable)
end
@ -556,52 +657,104 @@ function core:DrawTooltip()
-- Draw tooltip table then looped through.
-- Draw the tooltip
tooltip:AddHeader('')
tooltip:SetScale(1)
local valorPointColumn = tooltip:AddColumn('LEFT')
tooltip:SetCell(1, 1, '')
tooltip:SetCell(1, 2, 'VP')
self.tooltip:AddHeader('')
self.tooltip:SetScale(1)
local valorPointColumn = self.tooltip:AddColumn('LEFT')
self.tooltip:SetCell(1, 1, '')
self.tooltip:SetCell(1, 2, 'VP')
-- Build and sort our headers
local headerTable = { }
--headerTable['Valor Points'] = { abbreviation = 'VP', enable = true, removed = false, }
for instance, instanceInfo in pairs(db.profile.instances) do
if db.profile.instances[instance].enable == true and db.profile.instances[instance].removed == false then
for instance, instanceInfo in pairs(self.db.profile.instances) do
if self.db.profile.instances[instance].enable == true and self.db.profile.instances[instance].removed == false then
table.insert(headerTable,instanceInfo)
end
end
for instance, instanceInfo in pairs(self.db.profile.lfrs) do
if self.db.profile.lfrs[instance].enable == true and self.db.profile.lfrs[instance].removed == false then
table.insert(headerTable,instanceInfo)
end
end
local nextColumn = 3
for instance,instanceInfo in pairs(headerTable) do
tooltip:SetCell(1, nextColumn, instanceInfo.abbreviation, nil, 'CENTER')
self.tooltip:SetCell(1, nextColumn, instanceInfo.abbreviation, nil, 'CENTER')
nextColumn = nextColumn + 1
end
if self.db.profile.showTotalVp == true then
self.tooltip:SetCell(1, nextColumn, 'Total VP')
nextColumn = nextColumn + 1
end
for _,information in pairs(tooltipTable) do
local characterLine = tooltip:AddLine('')
tooltip:SetCell(characterLine, 1, information.name, fontObjects[information.class], 'LEFT')
if self.db.profile.showServer then
information.name = information.name .. '-' .. string.sub(information.realm,0,3)
end
local characterLine = self.tooltip:AddLine('')
self.tooltip:SetCell(characterLine, 1, information.name, self.fontObjects[information.class], 'LEFT')
local valorPointColor
if information.valorPoints == 980 then
valorPointColor = fontObjects['red']
if information.valorPoints == MAX_VALOR_POINTS then
valorPointColor = self.fontObjects['red']
else
valorPointColor = fontObjects['green']
valorPointColor = self.fontObjects['green']
end
tooltip:SetCell(characterLine, 2, information.valorPoints, valorPointColor, 'RIGHT')
self.tooltip:SetCell(characterLine, 2, information.valorPoints, valorPointColor, 'RIGHT')
local nextColumn = 3
for instance, abbreviation in pairs(db.profile.instances) do
if db.profile.instances[instance].enable == true and db.profile.instances[instance].removed == false then
for instance, abbreviation in pairs(self.db.profile.instances) do
if self.db.profile.instances[instance].enable == true and self.db.profile.instances[instance].removed == false then
local instanceColor
if information[instance] == 0 then
instanceColor = fontObjects['green']
instanceColor = self.fontObjects['green']
else
instanceColor = fontObjects['red']
instanceColor = self.fontObjects['red']
end
tooltip:SetCell(characterLine, nextColumn, information[instance], instanceColor, 'RIGHT')
self.tooltip:SetCell(characterLine, nextColumn, information[instance], instanceColor, 'RIGHT')
nextColumn = nextColumn + 1
end
end
for instance, abbreviation in pairs(self.db.profile.lfrs) do
if self.db.profile.lfrs[instance].enable == true and self.db.profile.lfrs[instance].removed == false then
local instanceColor
if information[instance] == 0 then
instanceColor = self.fontObjects['green']
else
instanceColor = self.fontObjects['red']
end
self.tooltip:SetCell(characterLine, nextColumn, information[instance], instanceColor, 'RIGHT')
nextColumn = nextColumn + 1
end
end
if self.db.profile.showTotalVp then
self.tooltip:SetCell(characterLine, nextColumn, information.totalVp, self.fontObjects['green'], 'RIGHT')
end
end
end
--[[ PROFILE UPDATES ]]--
function core:LFRProfileUpdate()
for realm,realmTable in pairs(self.db.global) do
for name in pairs(realmTable) do
if self.db.global[realm][name].lfrs == nil then
self.db.global[realm][name].lfrs = {}
end
for instance in pairs(self.db.profile.lfrs) do
if self.db.global[realm][name].lfrs[instance] == nil then
self.db.global[realm][name].lfrs[instance] = {}
self.db.global[realm][name].lfrs[instance].defeatedBosses = 0
self.db.global[realm][name].lfrs[instance].resetTime = 0
end
end
end
end
end

View File

@ -1,4 +1,4 @@
## Interface: 42000
## Interface: 43000
## Title: ChoreTracker
## Version: @project-version@
## Author: Gaffer