1
0
Fork 0

Compare commits

...

11 Commits

3 changed files with 202 additions and 21 deletions

3
.gitignore vendored Normal file
View File

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

View File

@ -10,6 +10,7 @@ local Z = LibStub('LibBabble-Zone-3.0'):GetLookupTable()
--
local CURRENT_MAX_LEVEL = 85
local MAX_VALOR_POINTS = 1000
local defaults = {
global = {},
@ -21,16 +22,29 @@ local defaults = {
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',
@ -94,14 +108,23 @@ local options = {
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 = { },
}
},
},
}
@ -125,11 +148,21 @@ function core:OnInitialize()
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,
}
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()
@ -220,8 +253,10 @@ function core:OnEnable()
self:RegisterEvent('CALENDAR_UPDATE_EVENT_LIST')
self:RegisterEvent('LFG_UPDATE_RANDOM_INFO')
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
@ -232,6 +267,7 @@ function core:OnEnable()
-- Reset data if necessary
core:ResetRaidLockouts()
core:ResetValorPoints()
core:ResetLFRLockouts()
end
@ -255,6 +291,14 @@ function core:LFG_UPDATE_RANDOM_INFO()
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()
RequestRaidInfo()
RequestLFDPlayerLockInfo()
@ -267,16 +311,15 @@ function core:INSTANCE_ENCOUNTER_ENGAGE_UNIT()
end
--[[ FUNCTIONS ]]--
function core:UpdateValorPoints()
local _, _, _, earnedThisWeek = GetCurrencyInfo(396)
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
@ -286,10 +329,8 @@ 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,
resetTime = 0,
}
self.db.global[realm][name].valorPoints.points = 0
self.db.global[realm][name].valorPoints.resetTime = 0
end
end
end
@ -299,7 +340,7 @@ 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] = {}
@ -322,7 +363,33 @@ function core:ResetRaidLockouts()
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.
@ -344,10 +411,15 @@ function core:DrawInstanceOptions()
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
@ -356,7 +428,7 @@ function core:DrawInstanceOptions()
options.args.instances.args[instance .. 'Enable'] = {
type = 'toggle',
name = instance,
order = 4 * i,
order = 500 + (5 * i) + 0,
get = function(info) return self.db.profile.instances[instance].enable end,
set = function(info, value)
self.db.profile.instances[instance].enable = value
@ -366,7 +438,7 @@ function core:DrawInstanceOptions()
options.args.instances.args[instance .. 'Abbreviation'] = {
type = 'input',
name = '',
order = 4 * i + 1,
order = 500 + (5 * i) + 1,
width = 'half',
get = function(info) return self.db.profile.instances[instance].abbreviation end,
set = function(info, value) self.db.profile.instances[instance].abbreviation = value end,
@ -374,7 +446,7 @@ function core:DrawInstanceOptions()
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()
@ -385,7 +457,48 @@ function core:DrawInstanceOptions()
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
@ -450,6 +563,7 @@ function core:DrawTooltip()
-- Should not update without being 100% sure our raid info is correct
core:UpdateValorPoints()
core:UpdateRaidLockouts()
core:UpdateLFRLockouts()
end
if self.tooltip then
@ -463,6 +577,11 @@ function core:DrawTooltip()
columnCount = columnCount + 1
end
end
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
@ -472,11 +591,12 @@ function core:DrawTooltip()
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(self.db.profile.instances) do
local defeatedBosses
@ -488,6 +608,16 @@ function core:DrawTooltip()
characterTable[instance] = defeatedBosses
end
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
@ -541,12 +671,22 @@ function core:DrawTooltip()
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
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
if self.db.profile.showServer then
@ -557,7 +697,7 @@ function core:DrawTooltip()
self.tooltip:SetCell(characterLine, 1, information.name, self.fontObjects[information.class], 'LEFT')
local valorPointColor
if information.valorPoints == 980 then
if information.valorPoints == MAX_VALOR_POINTS then
valorPointColor = self.fontObjects['red']
else
valorPointColor = self.fontObjects['green']
@ -578,5 +718,43 @@ function core:DrawTooltip()
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