Various reogranization.
This commit is contained in:
parent
0f47d5494c
commit
ad053c1f1c
1 changed files with 44 additions and 50 deletions
|
@ -1,14 +1,7 @@
|
||||||
ChoreTracker = LibStub('AceAddon-3.0'):NewAddon('ChoreTracker', 'AceConsole-3.0', 'AceEvent-3.0')
|
ChoreTracker = LibStub('AceAddon-3.0'):NewAddon('ChoreTracker', 'AceConsole-3.0', 'AceEvent-3.0')
|
||||||
local core = ChoreTracker
|
local core = ChoreTracker
|
||||||
local LQT
|
local LQT, LDB, LDBIcon, LBZ
|
||||||
local db
|
local db, tooltip, zones, trackedInstances, vpResetTime
|
||||||
local LDB
|
|
||||||
local LDBIcon
|
|
||||||
local tooltip
|
|
||||||
local LBZ
|
|
||||||
local zones
|
|
||||||
local trackedInstances
|
|
||||||
local vpResetTime
|
|
||||||
|
|
||||||
local defaults = {
|
local defaults = {
|
||||||
global = {},
|
global = {},
|
||||||
|
@ -28,8 +21,8 @@ local options = {
|
||||||
name = 'Hide Minimap Icon',
|
name = 'Hide Minimap Icon',
|
||||||
desc = 'Removes the icon from your minimap.',
|
desc = 'Removes the icon from your minimap.',
|
||||||
type = 'toggle',
|
type = 'toggle',
|
||||||
get = function(info) return core.db.profile.minimap.hide end,
|
get = function(info) return db.profile.minimap.hide end,
|
||||||
set = function(info, value) core.db.profile.minimap.hide = value core.LDBIcon[value and 'Hide' or 'Show'](core.LDBIcon, 'ChoreTracker') end,
|
set = function(info, value) db.profile.minimap.hide = value LDBIcon[value and 'Hide' or 'Show'](LDBIcon, 'ChoreTracker') end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,17 +32,17 @@ local flagColors = {}
|
||||||
|
|
||||||
function core:OnInitialize()
|
function core:OnInitialize()
|
||||||
-- Prepare the database if necessary
|
-- Prepare the database if necessary
|
||||||
self.db = LibStub('AceDB-3.0'):New('ChoreTrackerDB', defaults, 'Default')
|
db = LibStub('AceDB-3.0'):New('ChoreTrackerDB', defaults, 'Default')
|
||||||
|
|
||||||
local level = UnitLevel('player')
|
local level = UnitLevel('player')
|
||||||
local realm = GetRealmName()
|
local realm = GetRealmName()
|
||||||
local name = UnitName('player')
|
local name = UnitName('player')
|
||||||
if self.db.global[realm] == nil then
|
if db.global[realm] == nil then
|
||||||
self.db.global[realm] = {}
|
db.global[realm] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.db.global[realm][name] == nil and level == 85 then
|
if db.global[realm][name] == nil and level == 85 then
|
||||||
self.db.global[realm][name] = {}
|
db.global[realm][name] = {}
|
||||||
|
|
||||||
local class = UnitClass('player')
|
local class = UnitClass('player')
|
||||||
class = class:lower()
|
class = class:lower()
|
||||||
|
@ -57,12 +50,12 @@ function core:OnInitialize()
|
||||||
class = 'death knight'
|
class = 'death knight'
|
||||||
end
|
end
|
||||||
|
|
||||||
self.db.global[realm][name].class = class
|
db.global[realm][name].class = class
|
||||||
self.db.global[realm][name].valorPoints = {
|
db.global[realm][name].valorPoints = {
|
||||||
valorPoints = 0,
|
valorPoints = 0,
|
||||||
resetTime = 0,
|
resetTime = 0,
|
||||||
}
|
}
|
||||||
self.db.global[realm][name].lockouts = {}
|
db.global[realm][name].lockouts = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register events (here for now; track data regardless of whether it is displayed?)
|
-- Register events (here for now; track data regardless of whether it is displayed?)
|
||||||
|
@ -72,12 +65,17 @@ function core:OnInitialize()
|
||||||
self:RegisterEvent('UPDATE_INSTANCE_INFO', 'UpdateChores')
|
self:RegisterEvent('UPDATE_INSTANCE_INFO', 'UpdateChores')
|
||||||
self:RegisterEvent('CHAT_MSG_CURRENCY', 'UpdateChores')
|
self:RegisterEvent('CHAT_MSG_CURRENCY', 'UpdateChores')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Reset data if necessary
|
||||||
|
core:ResetInstances()
|
||||||
|
core:ResetValorPoints()
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:OnEnable()
|
function core:OnEnable()
|
||||||
LQT = LibStub('LibQTip-1.0')
|
LQT = LibStub('LibQTip-1.0')
|
||||||
LBZ = LibStub('LibBabble-Zone-3.0')
|
LBZ = LibStub('LibBabble-Zone-3.0')
|
||||||
|
|
||||||
|
-- Setup font strings for later. (RAID_CLASS_COLORS always indexed in English?)
|
||||||
for class,color in pairs(RAID_CLASS_COLORS) do
|
for class,color in pairs(RAID_CLASS_COLORS) do
|
||||||
class = class:lower()
|
class = class:lower()
|
||||||
if class == 'deathknight' then
|
if class == 'deathknight' then
|
||||||
|
@ -97,12 +95,8 @@ function core:OnEnable()
|
||||||
flagColors['red']:CopyFontObject(GameTooltipText)
|
flagColors['red']:CopyFontObject(GameTooltipText)
|
||||||
flagColors['red']:SetTextColor(255, 0, 0)
|
flagColors['red']:SetTextColor(255, 0, 0)
|
||||||
|
|
||||||
--reset data if necessary
|
|
||||||
core:ResetInstances()
|
|
||||||
core:ResetValorPoints()
|
|
||||||
|
|
||||||
-- Setup LDB
|
-- Setup LDB
|
||||||
self.LDB = LibStub('LibDataBroker-1.1'):NewDataObject('ChoreTracker', {
|
LDB = LibStub('LibDataBroker-1.1'):NewDataObject('ChoreTracker', {
|
||||||
type = 'data source',
|
type = 'data source',
|
||||||
text = 'ChoreTracker',
|
text = 'ChoreTracker',
|
||||||
icon = 'Interface\\AddOns\\ChoreTracker\\icon',
|
icon = 'Interface\\AddOns\\ChoreTracker\\icon',
|
||||||
|
@ -126,13 +120,13 @@ function core:OnEnable()
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Deal with minimap
|
-- Deal with minimap
|
||||||
self.LDBIcon = LibStub('LibDBIcon-1.0')
|
LDBIcon = LibStub('LibDBIcon-1.0')
|
||||||
self.LDBIcon:Register('ChoreTracker', self.LDB, self.db.profile.minimap)
|
LDBIcon:Register('ChoreTracker', LDB, db.profile.minimap)
|
||||||
|
|
||||||
if self.db.profile.minimap.hide then
|
if db.profile.minimap.hide then
|
||||||
self.LDBIcon:Hide('ChoreTracker')
|
LDBIcon:Hide('ChoreTracker')
|
||||||
else
|
else
|
||||||
self.LDBIcon:Show('ChoreTracker')
|
LDBIcon:Show('ChoreTracker')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get instances
|
-- Get instances
|
||||||
|
@ -153,7 +147,7 @@ function core:OnEnable()
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:UpdateChores()
|
function core:UpdateChores()
|
||||||
--reset data if necessary
|
-- Reset data if necessary
|
||||||
core:ResetInstances()
|
core:ResetInstances()
|
||||||
core:ResetValorPoints()
|
core:ResetValorPoints()
|
||||||
|
|
||||||
|
@ -162,10 +156,10 @@ function core:UpdateChores()
|
||||||
local _,_,_,earnedThisWeek = GetCurrencyInfo(396)
|
local _,_,_,earnedThisWeek = GetCurrencyInfo(396)
|
||||||
|
|
||||||
--store Valor Points
|
--store Valor Points
|
||||||
if vpReset ~= nil then
|
if vpResetTime ~= nil then
|
||||||
self.db.global[realm][name].valorPoints = {}
|
db.global[realm][name].valorPoints = {}
|
||||||
self.db.global[realm][name].valorPoints.points = earnedThisWeek
|
db.global[realm][name].valorPoints.points = earnedThisWeek
|
||||||
self.db.global[realm][name].valorPoints.resetTime = vpResetTime
|
db.global[realm][name].valorPoints.resetTime = vpResetTime
|
||||||
end
|
end
|
||||||
|
|
||||||
--store Saved Instances
|
--store Saved Instances
|
||||||
|
@ -175,22 +169,22 @@ function core:UpdateChores()
|
||||||
|
|
||||||
if trackedInstances[instanceName] ~= nil then
|
if trackedInstances[instanceName] ~= nil then
|
||||||
if instanceReset > 0 then
|
if instanceReset > 0 then
|
||||||
self.db.global[realm][name].lockouts[instanceName] = {}
|
db.global[realm][name].lockouts[instanceName] = {}
|
||||||
self.db.global[realm][name].lockouts[instanceName].defeatedBosses = defeatedBosses
|
db.global[realm][name].lockouts[instanceName].defeatedBosses = defeatedBosses
|
||||||
self.db.global[realm][name].lockouts[instanceName].resetTime = time() + instanceReset
|
db.global[realm][name].lockouts[instanceName].resetTime = time() + instanceReset
|
||||||
else
|
else
|
||||||
self.db.global[realm][name].lockouts[instanceName] = nil
|
db.global[realm][name].lockouts[instanceName] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:ResetInstances()
|
function core:ResetInstances()
|
||||||
for realm,realmTable in pairs(self.db.global) do
|
for realm,realmTable in pairs(db.global) do
|
||||||
for name in pairs(realmTable) do
|
for name in pairs(realmTable) do
|
||||||
for instance,instanceTable in pairs(self.db.global[realm][name].lockouts) do
|
for instance,instanceTable in pairs(db.global[realm][name].lockouts) do
|
||||||
if instanceTable.resetTime < time() then
|
if instanceTable.resetTime < time() then
|
||||||
self.db.global[realm][name].lockouts[instance] = nil
|
db.global[realm][name].lockouts[instance] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -198,10 +192,10 @@ function core:ResetInstances()
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:ResetValorPoints()
|
function core:ResetValorPoints()
|
||||||
for realm,realmTable in pairs(self.db.global) do
|
for realm,realmTable in pairs(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 db.global[realm][name].valorPoints.resetTime < time() then
|
||||||
self.db.global[realm][name].valorPoints = {
|
db.global[realm][name].valorPoints = {
|
||||||
valorPoints = 0,
|
valorPoints = 0,
|
||||||
resetTime = 0,
|
resetTime = 0,
|
||||||
}
|
}
|
||||||
|
@ -274,14 +268,14 @@ function core:DrawTooltip()
|
||||||
nextColumn = nextColumn + 1
|
nextColumn = nextColumn + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
for realm in pairs(self.db.global) do
|
for realm in pairs(db.global) do
|
||||||
for name in pairs(self.db.global[realm]) do
|
for name in pairs(db.global[realm]) do
|
||||||
local characterLine = tooltip:AddLine('')
|
local characterLine = tooltip:AddLine('')
|
||||||
local class = self.db.global[realm][name].class
|
local class = db.global[realm][name].class
|
||||||
tooltip:SetCell(characterLine, 1, name, classColors[class], 'LEFT')
|
tooltip:SetCell(characterLine, 1, name, classColors[class], 'LEFT')
|
||||||
|
|
||||||
local valorPoints, valorPointColor
|
local valorPoints, valorPointColor
|
||||||
valorPoints = self.db.global[realm][name].valorPoints.points
|
valorPoints = db.global[realm][name].valorPoints.points
|
||||||
if valorPoints == nil then
|
if valorPoints == nil then
|
||||||
valorPoints = 0
|
valorPoints = 0
|
||||||
end
|
end
|
||||||
|
@ -294,8 +288,8 @@ function core:DrawTooltip()
|
||||||
|
|
||||||
local nextColumn = 3
|
local nextColumn = 3
|
||||||
for instance,abbreviation in pairs(trackedInstances) do
|
for instance,abbreviation in pairs(trackedInstances) do
|
||||||
if self.db.global[realm][name].lockouts[instance] ~= nil then
|
if db.global[realm][name].lockouts[instance] ~= nil then
|
||||||
local defeatedBosses = self.db.global[realm][name].lockouts[instance].defeatedBosses
|
local defeatedBosses = db.global[realm][name].lockouts[instance].defeatedBosses
|
||||||
tooltip:SetCell(characterLine, nextColumn, defeatedBosses, flagColors['red'], 'RIGHT')
|
tooltip:SetCell(characterLine, nextColumn, defeatedBosses, flagColors['red'], 'RIGHT')
|
||||||
else
|
else
|
||||||
tooltip:SetCell(characterLine, nextColumn, '0', flagColors['green'], 'RIGHT')
|
tooltip:SetCell(characterLine, nextColumn, '0', flagColors['green'], 'RIGHT')
|
||||||
|
|
Loading…
Reference in a new issue