Store all character information at enable instead of recalling everytime it's needed.
This commit is contained in:
parent
2b214a8943
commit
130467f864
1 changed files with 28 additions and 34 deletions
|
@ -90,25 +90,27 @@ local options = {
|
||||||
function core:OnInitialize()
|
function core:OnInitialize()
|
||||||
self.db = LibStub('AceDB-3.0'):New('ChoreTrackerDB', defaults, 'Default')
|
self.db = LibStub('AceDB-3.0'):New('ChoreTrackerDB', defaults, 'Default')
|
||||||
|
|
||||||
local level = UnitLevel('player')
|
self.character = {
|
||||||
local realm = GetRealmName()
|
name = UnitName('player'),
|
||||||
local name = UnitName('player')
|
level = UnitLevel('player'),
|
||||||
if self.db.global[realm] == nil then
|
realm = GetRealmName(),
|
||||||
self.db.global[realm] = {}
|
class = UnitClass('player'),
|
||||||
|
}
|
||||||
|
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
|
end
|
||||||
|
|
||||||
if self.db.global[realm][name] == nil and level == 85 then
|
if self.db.global[self.character.realm][self.character.name] == nil and self.character.level == 85 then
|
||||||
self.db.global[realm][name] = {}
|
self.db.global[self.character.realm][self.character.name] = {}
|
||||||
|
|
||||||
local class = UnitClass('player')
|
self.db.global[self.character.realm][self.character.name].class = self.character.class
|
||||||
class = class:lower():gsub("^%s*(.-)%s*$", "%1")
|
self.db.global[self.character.realm][self.character.name].valorPoints = {
|
||||||
|
|
||||||
self.db.global[realm][name].class = class
|
|
||||||
self.db.global[realm][name].valorPoints = {
|
|
||||||
points = 0,
|
points = 0,
|
||||||
resetTime = 0,
|
resetTime = 0,
|
||||||
}
|
}
|
||||||
self.db.global[realm][name].lockouts = {}
|
self.db.global[self.character.realm][self.character.name].lockouts = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -120,7 +122,7 @@ function core:OnEnable()
|
||||||
|
|
||||||
-- Setup font strings for later. (RAID_CLASS_COLORS always indexed in English?)
|
-- Setup font strings for later. (RAID_CLASS_COLORS always indexed in English?)
|
||||||
self.fontObjects = { }
|
self.fontObjects = { }
|
||||||
for class,color in pairs(RAID_CLASS_COLORS) do
|
for class, color in pairs(RAID_CLASS_COLORS) do
|
||||||
class = class:lower():gsub("^%s*(.-)%s*$", "%1")
|
class = class:lower():gsub("^%s*(.-)%s*$", "%1")
|
||||||
|
|
||||||
self.fontObjects[class] = CreateFont('ClassFont' .. class)
|
self.fontObjects[class] = CreateFont('ClassFont' .. class)
|
||||||
|
@ -194,8 +196,7 @@ function core:OnEnable()
|
||||||
options.args.profile = LibStub('AceDBOptions-3.0'):GetOptionsTable(db)
|
options.args.profile = LibStub('AceDBOptions-3.0'):GetOptionsTable(db)
|
||||||
|
|
||||||
-- Register events
|
-- Register events
|
||||||
local level = UnitLevel('player')
|
if self.character.level == 85 then
|
||||||
if level == 85 then
|
|
||||||
self:RegisterEvent('CALENDAR_UPDATE_EVENT_LIST')
|
self:RegisterEvent('CALENDAR_UPDATE_EVENT_LIST')
|
||||||
|
|
||||||
self:RegisterEvent('LFG_UPDATE_RANDOM_INFO')
|
self:RegisterEvent('LFG_UPDATE_RANDOM_INFO')
|
||||||
|
@ -246,22 +247,19 @@ end
|
||||||
|
|
||||||
--[[ FUNCTIONS ]]--
|
--[[ FUNCTIONS ]]--
|
||||||
function core:UpdateValorPoints()
|
function core:UpdateValorPoints()
|
||||||
local realm = GetRealmName()
|
|
||||||
local name = UnitName('player')
|
|
||||||
|
|
||||||
local _, _, _, earnedThisWeek = GetCurrencyInfo(396)
|
local _, _, _, earnedThisWeek = GetCurrencyInfo(396)
|
||||||
|
|
||||||
if self.db.global[realm][name].valorPoints == nil then
|
if self.db.global[self.character.realm][self.character.name].valorPoints == nil then
|
||||||
self.db.global[realm][name].valorPoints = {}
|
self.db.global[self.character.realm][self.character.name].valorPoints = {}
|
||||||
end
|
end
|
||||||
self.db.global[realm][name].valorPoints.points = earnedThisWeek
|
self.db.global[self.character.realm][self.character.name].valorPoints.points = earnedThisWeek
|
||||||
if vpResetTime ~= false then
|
if self.vpResetTime ~= false then
|
||||||
self.db.global[realm][name].valorPoints.resetTime = self.vpResetTime
|
self.db.global[self.character.realm][self.character.name].valorPoints.resetTime = self.vpResetTime
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:ResetValorPoints()
|
function core:ResetValorPoints()
|
||||||
for realm,realmTable in pairs(self.db.global) do
|
for realm, realmTable in pairs(self.db.global) do
|
||||||
for name in pairs(realmTable) do
|
for name in pairs(realmTable) do
|
||||||
if self.db.global[realm][name].valorPoints.resetTime < time() then
|
if self.db.global[realm][name].valorPoints.resetTime < time() then
|
||||||
self.db.global[realm][name].valorPoints = {
|
self.db.global[realm][name].valorPoints = {
|
||||||
|
@ -274,18 +272,15 @@ function core:ResetValorPoints()
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:UpdateRaidLockouts()
|
function core:UpdateRaidLockouts()
|
||||||
local realm = GetRealmName()
|
|
||||||
local name = UnitName('player')
|
|
||||||
|
|
||||||
local savedInstances = GetNumSavedInstances()
|
local savedInstances = GetNumSavedInstances()
|
||||||
for i = 1, savedInstances do
|
for i = 1, savedInstances do
|
||||||
local instanceName, _, instanceReset, _, _, _, _, _, _, _, _, defeatedBosses = GetSavedInstanceInfo(i)
|
local instanceName, _, instanceReset, _, _, _, _, _, _, _, _, defeatedBosses = GetSavedInstanceInfo(i)
|
||||||
|
|
||||||
if self.db.profile.instances[instanceName] ~= nil then
|
if self.db.profile.instances[instanceName] ~= nil then
|
||||||
if instanceReset > 0 then
|
if instanceReset > 0 then
|
||||||
self.db.global[realm][name].lockouts[instanceName] = {}
|
self.db.global[self.character.realm][self.character.name].lockouts[instanceName] = {}
|
||||||
self.db.global[realm][name].lockouts[instanceName].defeatedBosses = defeatedBosses
|
self.db.global[self.character.realm][self.character.name].lockouts[instanceName].defeatedBosses = defeatedBosses
|
||||||
self.db.global[realm][name].lockouts[instanceName].resetTime = self.instanceInfoTime + instanceReset
|
self.db.global[self.character.realm][self.character.name].lockouts[instanceName].resetTime = self.instanceInfoTime + instanceReset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -344,7 +339,7 @@ function core:DrawInstanceOptions()
|
||||||
core:DrawInstanceOptions()
|
core:DrawInstanceOptions()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
options.args.instances.args[instance] = {
|
options.args.instances.args[instance .. 'Abbreviation'] = {
|
||||||
type = 'input',
|
type = 'input',
|
||||||
name = '',
|
name = '',
|
||||||
order = 4 * i + 1,
|
order = 4 * i + 1,
|
||||||
|
@ -427,8 +422,7 @@ end
|
||||||
|
|
||||||
function core:DrawTooltip()
|
function core:DrawTooltip()
|
||||||
-- UpdateChores before we show the tooltip to make sure we have the most recent data
|
-- UpdateChores before we show the tooltip to make sure we have the most recent data
|
||||||
local level = UnitLevel('player')
|
if self.character.level == 85 then
|
||||||
if level == 85 then
|
|
||||||
-- Should not update without being 100% sure our raid info is correct
|
-- Should not update without being 100% sure our raid info is correct
|
||||||
core:UpdateValorPoints()
|
core:UpdateValorPoints()
|
||||||
core:UpdateRaidLockouts()
|
core:UpdateRaidLockouts()
|
||||||
|
|
Loading…
Reference in a new issue