Combine raid instance lockout search functions.
This commit is contained in:
parent
79ba491c9a
commit
2b214a8943
1 changed files with 16 additions and 61 deletions
|
@ -94,24 +94,21 @@ function core:OnInitialize()
|
||||||
local realm = GetRealmName()
|
local realm = GetRealmName()
|
||||||
local name = UnitName('player')
|
local name = UnitName('player')
|
||||||
if self.db.global[realm] == nil then
|
if self.db.global[realm] == nil then
|
||||||
db.global[realm] = {}
|
self.db.global[realm] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.db.global[realm][name] == nil and level == 85 then
|
if self.db.global[realm][name] == nil and level == 85 then
|
||||||
db.global[realm][name] = {}
|
self.db.global[realm][name] = {}
|
||||||
|
|
||||||
local class = UnitClass('player')
|
local class = UnitClass('player')
|
||||||
class = class:lower()
|
class = class:lower():gsub("^%s*(.-)%s*$", "%1")
|
||||||
if class == 'deathknight' then
|
|
||||||
class = 'death knight'
|
|
||||||
end
|
|
||||||
|
|
||||||
db.global[realm][name].class = class
|
self.db.global[realm][name].class = class
|
||||||
db.global[realm][name].valorPoints = {
|
self.db.global[realm][name].valorPoints = {
|
||||||
points = 0,
|
points = 0,
|
||||||
resetTime = 0,
|
resetTime = 0,
|
||||||
}
|
}
|
||||||
db.global[realm][name].lockouts = {}
|
self.db.global[realm][name].lockouts = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,10 +121,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()
|
class = class:lower():gsub("^%s*(.-)%s*$", "%1")
|
||||||
if class == 'deathknight' then
|
|
||||||
class = 'death knight'
|
|
||||||
end
|
|
||||||
|
|
||||||
self.fontObjects[class] = CreateFont('ClassFont' .. class)
|
self.fontObjects[class] = CreateFont('ClassFont' .. class)
|
||||||
self.fontObjects[class]:CopyFontObject(GameTooltipText)
|
self.fontObjects[class]:CopyFontObject(GameTooltipText)
|
||||||
|
@ -224,7 +218,7 @@ end
|
||||||
|
|
||||||
--[[ EVENTS ]]--
|
--[[ EVENTS ]]--
|
||||||
function core:CALENDAR_UPDATE_EVENT_LIST()
|
function core:CALENDAR_UPDATE_EVENT_LIST()
|
||||||
core:GetNextVPReset()
|
self.vpResetTime = core:FindLockout(Z['Baradin Hold'])
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:UPDATE_INSTANCE_INFO()
|
function core:UPDATE_INSTANCE_INFO()
|
||||||
|
@ -320,7 +314,7 @@ function core:DrawInstanceOptions()
|
||||||
type = 'input',
|
type = 'input',
|
||||||
order = 1,
|
order = 1,
|
||||||
set = function(info, value)
|
set = function(info, value)
|
||||||
if core:VerifyInstance(value) then
|
if core:FindLockout(value) then
|
||||||
db.profile.instances[value] = { }
|
db.profile.instances[value] = { }
|
||||||
db.profile.instances[value].abbreviation = string.sub(value,0,1)
|
db.profile.instances[value].abbreviation = string.sub(value,0,1)
|
||||||
db.profile.instances[value].enable = true
|
db.profile.instances[value].enable = true
|
||||||
|
@ -379,7 +373,7 @@ function core:DrawInstanceOptions()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:GetNextVPReset()
|
function core:FindLockout(instance)
|
||||||
-- We need to have access to the instance lockouts on the calendar.
|
-- We need to have access to the instance lockouts on the calendar.
|
||||||
local currentCalendarSetting = GetCVar('calendarShowResets')
|
local currentCalendarSetting = GetCVar('calendarShowResets')
|
||||||
SetCVar('calendarShowResets', 1)
|
SetCVar('calendarShowResets', 1)
|
||||||
|
@ -392,8 +386,8 @@ function core:GetNextVPReset()
|
||||||
local _, month, day, year = CalendarGetDate()
|
local _, month, day, year = CalendarGetDate()
|
||||||
|
|
||||||
local monthOffset = 0
|
local monthOffset = 0
|
||||||
local resetDate = nil
|
local resetDate = false
|
||||||
while resetDate == nil do
|
while resetDate == false do
|
||||||
local todaysEvents = CalendarGetNumDayEvents(monthOffset, day)
|
local todaysEvents = CalendarGetNumDayEvents(monthOffset, day)
|
||||||
|
|
||||||
for i = 1,todaysEvents do
|
for i = 1,todaysEvents do
|
||||||
|
@ -403,7 +397,7 @@ function core:GetNextVPReset()
|
||||||
|
|
||||||
local title,hour,minute = CalendarGetDayEvent(monthOffset, day, i)
|
local title,hour,minute = CalendarGetDayEvent(monthOffset, day, i)
|
||||||
|
|
||||||
if title == Z['Baradin Hold'] then
|
if title == instance then
|
||||||
resetDate = { year = year, month = month + monthOffset, day = day }
|
resetDate = { year = year, month = month + monthOffset, day = day }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -420,56 +414,17 @@ function core:GetNextVPReset()
|
||||||
SetCVar('calendarShowResets', currentCalendarSetting)
|
SetCVar('calendarShowResets', currentCalendarSetting)
|
||||||
|
|
||||||
-- And combine for the reset timestamp
|
-- And combine for the reset timestamp
|
||||||
if(resetDate ~= nil) then
|
if(resetDate ~= false) then
|
||||||
resetDate.hour = resetTime.hour
|
resetDate.hour = resetTime.hour
|
||||||
resetDate.min = resetTime.min
|
resetDate.min = resetTime.min
|
||||||
resetDate.sec = resetTime.sec
|
resetDate.sec = resetTime.sec
|
||||||
|
|
||||||
self.vpResetTime = time(resetDate)
|
return time(resetDate)
|
||||||
else
|
else
|
||||||
print('Error: Could not caculate the next VP Reset Time.')
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:VerifyInstance(instance)
|
|
||||||
-- Use a method similar to GetNextVPReset() to make sure the instance
|
|
||||||
-- has a lockout on the calendar
|
|
||||||
local currentCalendarSetting = GetCVar('calendarShowResets')
|
|
||||||
SetCVar('calendarShowResets', 1)
|
|
||||||
|
|
||||||
local _, month, day, year = CalendarGetDate()
|
|
||||||
|
|
||||||
local monthOffset = 0
|
|
||||||
local resetDate = nil
|
|
||||||
while resetDate == nil do
|
|
||||||
local todaysEvents = CalendarGetNumDayEvents(monthOffset, day)
|
|
||||||
|
|
||||||
for i = 1,todaysEvents do
|
|
||||||
if todaysEvents == 0 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
local title,hour,minute = CalendarGetDayEvent(monthOffset, day, i)
|
|
||||||
|
|
||||||
if title == instance then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
day = day + 1
|
|
||||||
if day > 31 then
|
|
||||||
if monthOffset == 1 then break end
|
|
||||||
day = 1
|
|
||||||
monthOffset = 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Reset the calendar to the original settings
|
|
||||||
SetCVar('calendarShowResets', currentCalendarSetting)
|
|
||||||
|
|
||||||
return false
|
|
||||||
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')
|
local level = UnitLevel('player')
|
||||||
|
|
Loading…
Reference in a new issue