Redraw interface when processing added and removed user instances.
This commit is contained in:
parent
8cb8121d7b
commit
aea18de7ed
1 changed files with 54 additions and 39 deletions
|
@ -19,11 +19,11 @@ local defaults = {
|
||||||
vpPos = 1,
|
vpPos = 1,
|
||||||
-- Change table? ['Baradin Hold'] = { abbreviation = 'BH', enable = true }
|
-- Change table? ['Baradin Hold'] = { abbreviation = 'BH', enable = true }
|
||||||
instances = {
|
instances = {
|
||||||
[Z['Baradin Hold']] = { abbreviation = 'BH', enable = true },
|
[Z['Baradin Hold']] = { abbreviation = 'BH', enable = true, removed = false, },
|
||||||
[Z['Firelands']] = { abbreviation = 'FL', enable = true },
|
[Z['Firelands']] = { abbreviation = 'FL', enable = true, removed = false, },
|
||||||
[Z['The Bastion of Twilight']] = { abbreviation = 'BoT', enable = true },
|
[Z['The Bastion of Twilight']] = { abbreviation = 'BoT', enable = true, removed = false, },
|
||||||
[Z['Blackwing Descent']] = { abbreviation = 'BWD', enable = true },
|
[Z['Blackwing Descent']] = { abbreviation = 'BWD', enable = true, removed = false, },
|
||||||
[Z['Throne of the Four Winds']] = { abbreviation = '4W', enable = true },
|
[Z['Throne of the Four Winds']] = { abbreviation = '4W', enable = true, removed = false, },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -106,8 +106,11 @@ local options = {
|
||||||
set = function(info, value)
|
set = function(info, value)
|
||||||
if core:VerifyInstance(value) then
|
if core:VerifyInstance(value) then
|
||||||
print('Adding',value)
|
print('Adding',value)
|
||||||
|
db.profile.instances[value] = { }
|
||||||
db.profile.instances[value].abbreviation = ''
|
db.profile.instances[value].abbreviation = ''
|
||||||
db.profile.instances[value].enable = true
|
db.profile.instances[value].enable = true
|
||||||
|
db.profile.instances[value].removed = false
|
||||||
|
core:DrawInstanceOptions()
|
||||||
else
|
else
|
||||||
print('Invalid instance')
|
print('Invalid instance')
|
||||||
end
|
end
|
||||||
|
@ -213,38 +216,7 @@ function core:OnEnable()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup instance stuff for options
|
-- Setup instance stuff for options
|
||||||
local i = 1
|
core:DrawInstanceOptions()
|
||||||
for instance, abbreviation in pairs(db.profile.instances) do
|
|
||||||
options.args.instances.args[instance .. 'Enable'] = {
|
|
||||||
type = 'toggle',
|
|
||||||
name = instance,
|
|
||||||
order = 4 * i,
|
|
||||||
get = function(info) return db.profile.instances[instance].enable end,
|
|
||||||
set = function(info, value) db.profile.instances[instance].enable = value end,
|
|
||||||
}
|
|
||||||
options.args.instances.args[instance] = {
|
|
||||||
type = 'input',
|
|
||||||
name = '',
|
|
||||||
order = 4 * 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,
|
|
||||||
}
|
|
||||||
options.args.instances.args[instance .. 'Remove'] = {
|
|
||||||
type = 'execute',
|
|
||||||
name = 'Remove',
|
|
||||||
order = 4 * i + 2,
|
|
||||||
width = 'half',
|
|
||||||
confirm = true,
|
|
||||||
func = function(info) db.profile.instances[instance] = nil end,
|
|
||||||
}
|
|
||||||
options.args.instances.args[instance .. 'Spacer'] = {
|
|
||||||
type = 'description',
|
|
||||||
name = '',
|
|
||||||
order = 4 * i + 3,
|
|
||||||
}
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Add options to Interface Panel
|
-- Add options to Interface Panel
|
||||||
LibStub('AceConfigRegistry-3.0'):RegisterOptionsTable('ChoreTracker', options)
|
LibStub('AceConfigRegistry-3.0'):RegisterOptionsTable('ChoreTracker', options)
|
||||||
|
@ -288,6 +260,49 @@ end
|
||||||
|
|
||||||
|
|
||||||
--[[ FUNCTIONS ]]--
|
--[[ FUNCTIONS ]]--
|
||||||
|
function core:DrawInstanceOptions()
|
||||||
|
local i = 1
|
||||||
|
for instance, abbreviation in pairs(db.profile.instances) do
|
||||||
|
if 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,
|
||||||
|
set = function(info, value)
|
||||||
|
db.profile.instances[instance].enable = value
|
||||||
|
core:DrawInstanceOptions()
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
options.args.instances.args[instance] = {
|
||||||
|
type = 'input',
|
||||||
|
name = '',
|
||||||
|
order = 4 * 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,
|
||||||
|
}
|
||||||
|
options.args.instances.args[instance .. 'Remove'] = {
|
||||||
|
type = 'execute',
|
||||||
|
name = 'Remove',
|
||||||
|
order = 4 * i + 2,
|
||||||
|
width = 'half',
|
||||||
|
confirm = true,
|
||||||
|
func = function()
|
||||||
|
db.profile.instances[instance].removed = true
|
||||||
|
core:DrawInstanceOptions()
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
options.args.instances.args[instance .. 'Spacer'] = {
|
||||||
|
type = 'description',
|
||||||
|
name = '',
|
||||||
|
order = 4 * i + 3,
|
||||||
|
}
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function core:UpdateChores()
|
function core:UpdateChores()
|
||||||
-- Reset data if necessary
|
-- Reset data if necessary
|
||||||
core:ResetInstances()
|
core:ResetInstances()
|
||||||
|
@ -508,7 +523,7 @@ function core:DrawTooltip()
|
||||||
tooltip:SetCell(1, 2, 'VP')
|
tooltip:SetCell(1, 2, 'VP')
|
||||||
local nextColumn = 3
|
local nextColumn = 3
|
||||||
for instance,instanceInfo in pairs(db.profile.instances) do
|
for instance,instanceInfo in pairs(db.profile.instances) do
|
||||||
if db.profile.instances[instance].enable == true then
|
if db.profile.instances[instance].enable == true and db.profile.instances[instance].removed == false then
|
||||||
tooltip:SetCell(1, nextColumn, instanceInfo.abbreviation, nil, 'CENTER')
|
tooltip:SetCell(1, nextColumn, instanceInfo.abbreviation, nil, 'CENTER')
|
||||||
nextColumn = nextColumn + 1
|
nextColumn = nextColumn + 1
|
||||||
end
|
end
|
||||||
|
@ -528,7 +543,7 @@ function core:DrawTooltip()
|
||||||
|
|
||||||
local nextColumn = 3
|
local nextColumn = 3
|
||||||
for instance, abbreviation in pairs(db.profile.instances) do
|
for instance, abbreviation in pairs(db.profile.instances) do
|
||||||
if db.profile.instances[instance].enable == true then
|
if db.profile.instances[instance].enable == true and db.profile.instances[instance].removed == false then
|
||||||
local instanceColor
|
local instanceColor
|
||||||
if information[instance] == 0 then
|
if information[instance] == 0 then
|
||||||
instanceColor = flagColors['green']
|
instanceColor = flagColors['green']
|
||||||
|
|
Loading…
Reference in a new issue