1
0
Fork 0

Implemented beginning of options for user selected instances.

This commit is contained in:
Andrew Tomaka 2011-09-21 11:05:06 -04:00
parent 3a5412ba73
commit 9b31a2f28f

View file

@ -1,7 +1,11 @@
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, LDB, LDBIcon, LBZ local LQT, LDB, LDBIcon, LBZ
local db, tooltip, zones, trackedInstances, vpResetTime local db, tooltip, Z, vpResetTime
-- Get localized instances
LBZ = LibStub('LibBabble-Zone-3.0')
Z = LBZ:GetLookupTable()
local defaults = { local defaults = {
global = {}, global = {},
@ -11,7 +15,13 @@ local defaults = {
}, },
sortType = 1, sortType = 1,
sortDirection = 1, sortDirection = 1,
instances = {}, instances = {
[Z['Baradin Hold']] = 'BH',
[Z['Firelands']] = 'FL',
[Z['The Bastion of Twilight']] = 'BoT',
[Z['Blackwing Descent']] = 'BWD',
[Z['Throne of the Four Winds']] = '4W',
},
}, },
} }
@ -53,7 +63,14 @@ local options = {
name = 'Instances', name = 'Instances',
type = 'group', type = 'group',
order = 2, order = 2,
args = { }, args = {
instance = {
name = 'Add instance to track.',
desc = 'Etner an instance on a seven day lockout that you would like ChoreTracker to track.',
type = 'input',
set = function(info, value) db.profile.instances[value] = '' end,
},
},
} }
}, },
} }
@ -92,7 +109,6 @@ end
function core:OnEnable() function core:OnEnable()
LQT = LibStub('LibQTip-1.0') LQT = LibStub('LibQTip-1.0')
LBZ = LibStub('LibBabble-Zone-3.0')
-- Setup font strings for later. (RAID_CLASS_COLORS always indexed in English?) -- 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
@ -148,22 +164,21 @@ function core:OnEnable()
LDBIcon:Show('ChoreTracker') LDBIcon:Show('ChoreTracker')
end end
-- Get instances -- Setup instance stuff for options
zones = LBZ:GetLookupTable() for instance, abbreviation in pairs(db.profile.instances) do
options.args.instances.args[instance] = {
-- Move to a profile variable populated by instances added by user type = 'input',
trackedInstances = { name = instance,
[zones['Baradin Hold']] = 'BH', get = function(info) return db.profile.instances[info] end,
[zones['Firelands']] = 'FL', set = function(info, value) db.profile.instances[info] = value end,
[zones['The Bastion of Twilight']] = 'BoT', }
[zones['Blackwing Descent']] = 'BWD', end
[zones['Throne of the Four Winds']] = '4W',
}
-- Add options to Interface Panel -- Add options to Interface Panel
LibStub('AceConfigRegistry-3.0'):RegisterOptionsTable('ChoreTracker', options) LibStub('AceConfigRegistry-3.0'):RegisterOptionsTable('ChoreTracker', options)
local ACD = LibStub('AceConfigDialog-3.0') local ACD = LibStub('AceConfigDialog-3.0')
ACD:AddToBlizOptions('ChoreTracker', 'ChoreTracker') ACD:AddToBlizOptions('ChoreTracker', 'ChoreTracker')
options.args.profile = LibStub('AceDBOptions-3.0'):GetOptionsTable(db)
-- Register events -- Register events
local level = UnitLevel('player') local level = UnitLevel('player')
@ -219,13 +234,10 @@ function core:UpdateChores()
-- Store Saved Instances; sometimes, there can be two lockouts to the same instance -- Store Saved Instances; sometimes, there can be two lockouts to the same instance
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 trackedInstances[instanceName] ~= nil then if db.profile.instances[instanceName] ~= nil then
if instanceReset > 0 then if instanceReset > 0 then
db.global[realm][name].lockouts[instanceName] = {} db.global[realm][name].lockouts[instanceName] = {}
db.global[realm][name].lockouts[instanceName].defeatedBosses = defeatedBosses db.global[realm][name].lockouts[instanceName].defeatedBosses = defeatedBosses
@ -288,7 +300,7 @@ function core:GetNextVPReset()
local title,hour,minute = CalendarGetDayEvent(monthOffset, day, i) local title,hour,minute = CalendarGetDayEvent(monthOffset, day, i)
if title == zones['Baradin Hold'] then if title == Z['Baradin Hold'] then
resetDate = { year = year, month = month + monthOffset, day = day } resetDate = { year = year, month = month + monthOffset, day = day }
end end
end end
@ -321,7 +333,7 @@ function core:DrawTooltip()
core:UpdateChores() core:UpdateChores()
local columnCount = 2 local columnCount = 2
for instance,abbreviation in pairs(trackedInstances) do for instance,abbreviation in pairs(db.profile.instances) do
columnCount = columnCount + 1 columnCount = columnCount + 1
end end
tooltip = LQT:Acquire('ChoreTrackerTooltip', columnCount, 'LEFT', 'CENTER', 'RIGHT') tooltip = LQT:Acquire('ChoreTrackerTooltip', columnCount, 'LEFT', 'CENTER', 'RIGHT')
@ -338,7 +350,7 @@ function core:DrawTooltip()
end end
local characterTable = { name = name, realm = realm, class = class, valorPoints = valorPoints } local characterTable = { name = name, realm = realm, class = class, valorPoints = valorPoints }
for instance in pairs(trackedInstances) do for instance in pairs(db.profile.instances) do
local defeatedBosses local defeatedBosses
if db.global[realm][name].lockouts[instance] ~= nil then if db.global[realm][name].lockouts[instance] ~= nil then
defeatedBosses = db.global[realm][name].lockouts[instance].defeatedBosses defeatedBosses = db.global[realm][name].lockouts[instance].defeatedBosses
@ -382,7 +394,7 @@ function core:DrawTooltip()
tooltip:SetCell(1, 1, '') tooltip:SetCell(1, 1, '')
tooltip:SetCell(1, 2, 'VP') tooltip:SetCell(1, 2, 'VP')
local nextColumn = 3 local nextColumn = 3
for instance,abbreviation in pairs(trackedInstances) do for instance,abbreviation in pairs(db.profile.instances) do
tooltip:SetCell(1, nextColumn, abbreviation, nil, 'CENTER') tooltip:SetCell(1, nextColumn, abbreviation, nil, 'CENTER')
nextColumn = nextColumn + 1 nextColumn = nextColumn + 1
end end
@ -400,7 +412,7 @@ function core:DrawTooltip()
tooltip:SetCell(characterLine, 2, information.valorPoints, valorPointColor, 'RIGHT') tooltip:SetCell(characterLine, 2, information.valorPoints, valorPointColor, 'RIGHT')
local nextColumn = 3 local nextColumn = 3
for instance, abbreviation in pairs(trackedInstances) do for instance, abbreviation in pairs(db.profile.instances) do
local instanceColor local instanceColor
if information[instance] == 0 then if information[instance] == 0 then
instanceColor = flagColors['green'] instanceColor = flagColors['green']