Cooldowns.lua 19.9 KB
Newer Older
Azilroka's avatar
Azilroka committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
local PA = _G.ProjectAzilroka

--Lua functions
local next = next
local ipairs = ipairs
local pairs = pairs
local floor = floor
local tinsert = tinsert
local ceil = ceil
local gsub = gsub

--WoW API / Variables
local GetTime = GetTime
local CreateFrame = CreateFrame
local hooksecurefunc = hooksecurefunc

local ICON_SIZE = 36 --the normal size for an icon (don't change this)
local FONT_SIZE = 20 --the base font size to use at a scale of 1
local MIN_SCALE = 0.5 --the minimum scale we want to show cooldown counts at, anything below this will be hidden
local MIN_DURATION = 1.5 --the minimum duration to show cooldown text for

PA.TimeThreshold = 3

PA.TimeColors = { --aura time colors
	[0] = '|cffeeeeee', --days
	[1] = '|cffeeeeee', --hours
	[2] = '|cffeeeeee', --minutes
	[3] = '|cffeeeeee', --seconds
	[4] = '|cfffe0000', --expire (fade timer)
	[5] = '|cff909090', --mmss
	[6] = '|cff707070', --hhmm
}

PA.TimeFormats = { -- short / indicator color
	[0] = {'%dd', '%d%sd|r'},
	[1] = {'%dh', '%d%sh|r'},
	[2] = {'%dm', '%d%sm|r'},
	[3] = {'%ds', '%d%ss|r'},
	[4] = {'%.1fs', '%.1f%ss|r'},
	[5] = {'%d:%02d', '%d%s:|r%02d'}, --mmss
	[6] = {'%d:%02d', '%d%s:|r%02d'}, --hhmm
}

for _, x in pairs(PA.TimeFormats) do
	x[3] = gsub(x[1], 's$', '') -- 1 without seconds
	x[4] = gsub(x[2], '%%ss', '%%s') -- 2 without seconds
end

PA.TimeIndicatorColors = {
	[0] = '|cff00b3ff',
	[1] = '|cff00b3ff',
	[2] = '|cff00b3ff',
	[3] = '|cff00b3ff',
	[4] = '|cff00b3ff',
	[5] = '|cff00b3ff',
	[6] = '|cff00b3ff',
}

local DAY, HOUR, MINUTE = 86400, 3600, 60
local DAYISH, HOURISH, MINUTEISH = HOUR * 23.5, MINUTE * 59.5, 59.5
local HALFDAYISH, HALFHOURISH, HALFMINUTEISH = DAY/2 + 0.5, HOUR/2 + 0.5, MINUTE/2 + 0.5

function PA:GetTimeInfo(s, threshhold, hhmm, mmss)
	if s < MINUTE then
		if s >= threshhold then
			return floor(s), 3, 0.51
		else
			return s, 4, 0.051
		end
	elseif s < HOUR then
		if mmss and s < mmss then
			return s/MINUTE, 5, 0.51, s%MINUTE
		else
			local minutes = floor((s/MINUTE)+.5)
			if hhmm and s < (hhmm * MINUTE) then
				return s/HOUR, 6, minutes > 1 and (s - (minutes*MINUTE - HALFMINUTEISH)) or (s - MINUTEISH), minutes%MINUTE
			else
				return ceil(s / MINUTE), 2, minutes > 1 and (s - (minutes*MINUTE - HALFMINUTEISH)) or (s - MINUTEISH)
			end
		end
	elseif s < DAY then
		if mmss and s < mmss then
			return s/MINUTE, 5, 0.51, s%MINUTE
		elseif hhmm and s < (hhmm * MINUTE) then
			local minutes = floor((s/MINUTE)+.5)
			return s/HOUR, 6, minutes > 1 and (s - (minutes*MINUTE - HALFMINUTEISH)) or (s - MINUTEISH), minutes%MINUTE
		else
			local hours = floor((s/HOUR)+.5)
			return ceil(s / HOUR), 1, hours > 1 and (s - (hours*HOUR - HALFHOURISH)) or (s - HOURISH)
		end
	else
		local days = floor((s/DAY)+.5)
		return ceil(s / DAY), 0, days > 1 and (s - (days*DAY - HALFDAYISH)) or (s - DAYISH)
	end
end

function PA:Cooldown_TextThreshold(cd, now)
	if cd.parent and cd.parent.textThreshold and cd.endTime then
		return (cd.endTime - now) >= cd.parent.textThreshold
	end
end

function PA:Cooldown_BelowScale(cd)
	if cd.parent then
		if cd.parent.hideText then return true end
		if cd.parent.skipScale then return end
	end

	return cd.fontScale and (cd.fontScale < MIN_SCALE)
end

function PA:Cooldown_OnUpdate(elapsed)
Azilroka's avatar
Azilroka committed
113 114 115 116
	local forced = elapsed == -1
	if forced then
		self.nextUpdate = 0
	elseif self.nextUpdate > 0 then
Azilroka's avatar
Azilroka committed
117 118 119 120 121 122 123 124 125 126
		self.nextUpdate = self.nextUpdate - elapsed
		return
	end

	if not PA:Cooldown_IsEnabled(self) then
		PA:Cooldown_StopTimer(self)
	else
		local now = GetTime()
		if self.endCooldown and now >= self.endCooldown then
			PA:Cooldown_StopTimer(self)
Azilroka's avatar
Azilroka committed
127 128 129
		elseif PA:Cooldown_BelowScale(self) then
			self.text:SetText('')
			if not forced then
Azilroka's avatar
Azilroka committed
130
				self.nextUpdate = 500
Azilroka's avatar
Azilroka committed
131 132 133 134
			end
		elseif PA:Cooldown_TextThreshold(self, now) then
			self.text:SetText('')
			if not forced then
Azilroka's avatar
Azilroka committed
135
				self.nextUpdate = 1
Azilroka's avatar
Azilroka committed
136 137 138 139
			end
		elseif self.endTime then
			local value, id, nextUpdate, remainder = PA:GetTimeInfo(self.endTime - now, self.threshold, self.hhmmThreshold, self.mmssThreshold)
			if not forced then
Azilroka's avatar
Azilroka committed
140
				self.nextUpdate = nextUpdate
Azilroka's avatar
Azilroka committed
141
			end
Azilroka's avatar
Azilroka committed
142

Azilroka's avatar
Azilroka committed
143 144 145 146 147 148 149
			local style = PA.TimeFormats[id]
			if style then
				local which = (self.textColors and 2 or 1) + (self.showSeconds and 0 or 2)
				if self.textColors then
					self.text:SetFormattedText(style[which], value, self.textColors[id], remainder)
				else
					self.text:SetFormattedText(style[which], value, remainder)
Azilroka's avatar
Azilroka committed
150
				end
Azilroka's avatar
Azilroka committed
151
			end
Azilroka's avatar
Azilroka committed
152

Azilroka's avatar
Azilroka committed
153 154 155
			local color = self.timeColors[id]
			if color then
				self.text:SetTextColor(color.r, color.g, color.b)
Azilroka's avatar
Azilroka committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
			end
		end
	end
end

function PA:Cooldown_OnSizeChanged(cd, width, force)
	local scale = width and (floor(width + 0.5) / ICON_SIZE)

	-- dont bother updating when the fontScale is the same, unless we are passing the force arg
	if scale and (scale == cd.fontScale) and (force ~= true) then return end
	cd.fontScale = scale

	-- this is needed because of skipScale variable, we wont allow a font size under the minscale
	if cd.fontScale and (cd.fontScale < MIN_SCALE) then
		scale = MIN_SCALE
	end

	if cd.customFont then -- override font
Azilroka's avatar
Azilroka committed
174
		cd.text:SetFont(PA.LSM:Fetch('font', cd.customFont), (scale * cd.customFontSize), cd.customFontOutline)
Azilroka's avatar
Azilroka committed
175
	elseif scale then -- default, no override
Azilroka's avatar
Azilroka committed
176
		cd.text:SetFont(PA.LSM:Fetch('font', PA.LSM:GetDefault('font')), (scale * FONT_SIZE), 'OUTLINE')
Azilroka's avatar
Azilroka committed
177 178 179 180 181 182 183 184 185 186 187
	end
end

function PA:Cooldown_IsEnabled(cd)
	if cd.forceEnabled then
		return true
	elseif cd.forceDisabled then
		return false
	elseif cd.reverseToggle ~= nil then
		return cd.reverseToggle
	else
Merathilis's avatar
whoops  
Merathilis committed
188
		return PA.db.Cooldown.Enable
Azilroka's avatar
Azilroka committed
189 190 191 192
	end
end

function PA:Cooldown_ForceUpdate(cd)
Azilroka's avatar
Azilroka committed
193
	PA.Cooldown_OnUpdate(cd, -1)
Azilroka's avatar
Azilroka committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
	cd:Show()
end

function PA:Cooldown_StopTimer(cd)
	cd.text:SetText('')
	cd:Hide()
end

function PA:Cooldown_Options(timer, db, parent)
	local threshold, colors, icolors, hhmm, mmss, fonts
	if parent and db.override then
		threshold = db.threshold
		icolors = db.useIndicatorColor and PA.TimeIndicatorColors[parent.CooldownOverride]
		colors = PA.TimeColors[parent.CooldownOverride]
	end

	if db.checkSeconds then
		hhmm, mmss = db.hhmmThreshold, db.mmssThreshold
	end

	timer.timeColors = colors or PA.TimeColors
Merathilis's avatar
Merathilis committed
215 216 217 218 219
	timer.threshold = threshold or PA.db.Cooldown.threshold or PA.TimeThreshold
	timer.textColors = icolors or (PA.db.Cooldown.useIndicatorColor and PA.TimeIndicatorColors)
	timer.hhmmThreshold = hhmm or (PA.db.Cooldown.checkSeconds and PA.db.Cooldown.hhmmThreshold)
	timer.mmssThreshold = mmss or (PA.db.Cooldown.checkSeconds and PA.db.Cooldown.mmssThreshold)
	timer.hideBlizzard = db.hideBlizzard or PA.db.Cooldown.hideBlizzard
Azilroka's avatar
Azilroka committed
220 221

	if db.reverse ~= nil then
Merathilis's avatar
Merathilis committed
222
		timer.reverseToggle = (PA.db.Cooldown.Enable and not db.reverse) or (db.reverse and not PA.db.Cooldown.Enable)
Azilroka's avatar
Azilroka committed
223 224 225 226
	else
		timer.reverseToggle = nil
	end

Merathilis's avatar
Merathilis committed
227
	if (db ~= PA.db.Cooldown) and db.fonts and db.fonts.enable then
Azilroka's avatar
Azilroka committed
228
		fonts = db.fonts -- custom fonts override default fonts
Merathilis's avatar
Merathilis committed
229 230
	elseif PA.db.Cooldown.fonts and PA.db.Cooldown.fonts.enable then
		fonts = PA.db.Cooldown.fonts -- default global font override
Azilroka's avatar
Azilroka committed
231 232 233
	end

	if fonts and fonts.enable then
234
		timer.customFont = fonts.font
Azilroka's avatar
Azilroka committed
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
		timer.customFontSize = fonts.fontSize
		timer.customFontOutline = fonts.fontOutline
	else
		timer.customFont = nil
		timer.customFontSize = nil
		timer.customFontOutline = nil
	end
end

function PA:CreateCooldownTimer(parent)
	local timer = CreateFrame('Frame', nil, parent)
	timer:Hide()
	timer:SetAllPoints()
	timer.parent = parent
	parent.timer = timer

	local text = timer:CreateFontString(nil, 'OVERLAY')
Azilroka's avatar
1.61  
Azilroka committed
252
	text:SetPoint('CENTER', 1, 1)
Azilroka's avatar
Azilroka committed
253 254 255 256 257 258 259 260 261 262
	text:SetJustifyH('CENTER')
	timer.text = text

	-- can be used to modify elements created from this function
	if parent.CooldownPreHook then
		parent.CooldownPreHook(parent)
	end

	-- cooldown override settings
	local db = (parent.CooldownOverride and PA.db[parent.CooldownOverride]) or PA.db
Merathilis's avatar
Merathilis committed
263
	if db and db.Cooldown then
Merathilis's avatar
Merathilis committed
264
		PA:Cooldown_Options(timer, db.Cooldown, parent)
Azilroka's avatar
Azilroka committed
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
	end

	PA:ToggleBlizzardCooldownText(parent, timer)

	-- keep an eye on the size so we can rescale the font if needed
	self:Cooldown_OnSizeChanged(timer, parent:GetWidth())
	parent:SetScript('OnSizeChanged', function(_, width)
		self:Cooldown_OnSizeChanged(timer, width)
	end)

	-- keep this after Cooldown_OnSizeChanged
	timer:SetScript('OnUpdate', PA.Cooldown_OnUpdate)

	return timer
end

PA.RegisteredCooldowns = {}
function PA:OnSetCooldown(start, duration)
	if (not self.forceDisabled) and (start and duration) and (duration > MIN_DURATION) then
		local timer = self.timer or PA:CreateCooldownTimer(self)
		timer.start = start
		timer.duration = duration
		timer.endTime = start + duration
		timer.endCooldown = timer.endTime - 0.05
Azilroka's avatar
Azilroka committed
289
		PA:Cooldown_ForceUpdate(timer)
Azilroka's avatar
Azilroka committed
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
	elseif self.timer then
		PA:Cooldown_StopTimer(self.timer)
	end
end

function PA:RegisterCooldown(cooldown)
	if not cooldown.isHooked then
		hooksecurefunc(cooldown, 'SetCooldown', PA.OnSetCooldown)
		cooldown.isHooked = true
	end

	if not cooldown.isRegisteredCooldown then
		local module = (cooldown.CooldownOverride or 'global')
		if not PA.RegisteredCooldowns[module] then PA.RegisteredCooldowns[module] = {} end

		tinsert(PA.RegisteredCooldowns[module], cooldown)
		cooldown.isRegisteredCooldown = true
	end
end

function PA:ToggleBlizzardCooldownText(cd, timer, request)
	-- we should hide the blizzard cooldown text when ours are enabled
	if timer and cd and cd.SetHideCountdownNumbers then
		local forceHide = cd.hideText or timer.hideBlizzard
		if request then
			return forceHide or PA:Cooldown_IsEnabled(timer)
		else
			cd:SetHideCountdownNumbers(forceHide or PA:Cooldown_IsEnabled(timer))
		end
	end
end

function PA:GetCooldownColors(db)
Merathilis's avatar
Merathilis committed
323
	if not db then db = PA.db.Cooldown end -- just incase someone calls this without a first arg use the global
Azilroka's avatar
Azilroka committed
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
	local c13 = PA:RGBToHex(db.hhmmColorIndicator.r, db.hhmmColorIndicator.g, db.hhmmColorIndicator.b) -- color for timers that are soon to expire
	local c12 = PA:RGBToHex(db.mmssColorIndicator.r, db.mmssColorIndicator.g, db.mmssColorIndicator.b) -- color for timers that are soon to expire
	local c11 = PA:RGBToHex(db.expireIndicator.r, db.expireIndicator.g, db.expireIndicator.b) -- color for timers that are soon to expire
	local c10 = PA:RGBToHex(db.secondsIndicator.r, db.secondsIndicator.g, db.secondsIndicator.b) -- color for timers that have seconds remaining
	local c9 = PA:RGBToHex(db.minutesIndicator.r, db.minutesIndicator.g, db.minutesIndicator.b) -- color for timers that have minutes remaining
	local c8 = PA:RGBToHex(db.hoursIndicator.r, db.hoursIndicator.g, db.hoursIndicator.b) -- color for timers that have hours remaining
	local c7 = PA:RGBToHex(db.daysIndicator.r, db.daysIndicator.g, db.daysIndicator.b) -- color for timers that have days remaining
	local c6 = db.hhmmColor -- HH:MM color
	local c5 = db.mmssColor -- MM:SS color
	local c4 = db.expiringColor -- color for timers that are soon to expire
	local c3 = db.secondsColor -- color for timers that have seconds remaining
	local c2 = db.minutesColor -- color for timers that have minutes remaining
	local c1 = db.hoursColor -- color for timers that have hours remaining
	local c0 = db.daysColor -- color for timers that have days remaining
	return c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13
end

function PA:UpdateCooldownOverride(module)
	local cooldowns = (module and PA.RegisteredCooldowns[module])
	if (not cooldowns) or not next(cooldowns) then return end

	for _, parent in ipairs(cooldowns) do
		local db = (parent.CooldownOverride and PA.db[parent.CooldownOverride]) or PA.db
Merathilis's avatar
Merathilis committed
347
		if db and db.Cooldown then
Azilroka's avatar
Azilroka committed
348 349 350 351
			local timer = parent.isHooked and parent.isRegisteredCooldown and parent.timer
			local cd = timer or parent

			-- cooldown override settings
Merathilis's avatar
Merathilis committed
352
			PA:Cooldown_Options(cd, db.Cooldown, parent)
Azilroka's avatar
Azilroka committed
353 354 355 356 357 358

			-- update font on cooldowns
			if timer and cd then -- has a parent, these are timers from RegisterCooldown
				PA:Cooldown_OnSizeChanged(cd, parent:GetWidth(), true)

				PA:ToggleBlizzardCooldownText(parent, cd)
Azilroka's avatar
Azilroka committed
359
			elseif cd.text and cd.customFont then
Azilroka's avatar
Azilroka committed
360
				cd.text:SetFont(PA.LSM:Fetch('font', cd.customFont), cd.customFontSize, cd.customFontOutline)
Azilroka's avatar
Azilroka committed
361 362 363 364 365 366
			end
		end
	end
end

function PA:UpdateCooldownSettings(module)
Merathilis's avatar
Merathilis committed
367
	local db, timeColors, textColors = PA.db.Cooldown, PA.TimeColors, PA.TimeIndicatorColors
Azilroka's avatar
Azilroka committed
368 369 370

	-- update the module timecolors if the config called it but ignore 'global' and 'all':
	-- global is the main call from config, all is the core file calls
Merathilis's avatar
Merathilis committed
371
	local isModule = module and (module ~= 'global' and module ~= 'all') and PA.db[module] and PA.db[module].Cooldown
Azilroka's avatar
Azilroka committed
372 373 374
	if isModule then
		if not PA.TimeColors[module] then PA.TimeColors[module] = {} end
		if not PA.TimeIndicatorColors[module] then PA.TimeIndicatorColors[module] = {} end
Merathilis's avatar
Merathilis committed
375
		db, timeColors, textColors = PA.db[module].Cooldown, PA.TimeColors[module], PA.TimeIndicatorColors[module]
Azilroka's avatar
Azilroka committed
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
	end

	timeColors[0], timeColors[1], timeColors[2], timeColors[3], timeColors[4], timeColors[5], timeColors[6], textColors[0], textColors[1], textColors[2], textColors[3], textColors[4], textColors[5], textColors[6] = PA:GetCooldownColors(db)

	if isModule then
		PA:UpdateCooldownOverride(module)
	elseif module == 'global' then -- this is only a call from the config change
		for key in pairs(PA.RegisteredCooldowns) do
			PA:UpdateCooldownOverride(key)
		end
	end

	-- okay update the other override settings if it was one of the core file calls
	if module and (module == 'all') then
		PA:UpdateCooldownSettings('OzCooldowns')
Azilroka's avatar
Azilroka committed
391
		PA:UpdateCooldownSettings('iFilger')
Azilroka's avatar
Azilroka committed
392 393 394 395
	end
end

local function profile(db)
Merathilis's avatar
Merathilis committed
396
	return (db == 'global' and PA.db.Cooldown) or PA.db[db].Cooldown
Azilroka's avatar
Azilroka committed
397 398 399
end

local function group(order, db, label)
Azilroka's avatar
Azilroka committed
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
	local main = PA.ACH:Group(label, nil, order, nil, function(info) local t = (profile(db))[info[#info]] return t.r, t.g, t.b, t.a end, function(info, r, g, b) local t = (profile(db))[info[#info]] t.r, t.g, t.b = r, g, b; PA:UpdateCooldownSettings(db); end)
	PA.Options.args.Cooldown.args[db] = main

	local mainArgs = main.args
	mainArgs.reverse = PA.ACH:Toggle(PA.ACL["Reverse Toggle"], PA.ACL["Reverse Toggle will enable Cooldown Text on this module when the global setting is disabled and disable them when the global setting is enabled."], 1, nil, nil, nil, function(info) return (profile(db))[info[#info]] end, function(info, value) (profile(db))[info[#info]] = value; PA:UpdateCooldownSettings(db); end)
	mainArgs.hideBlizzard = PA.ACH:Toggle(PA.ACL["Force Hide Blizzard Text"], PA.ACL["This option will force hide Blizzard's cooldown text if it is enabled at [Interface > ActionBars > Show Numbers on Cooldown]."], 2, nil, nil, nil, function(info) return (profile(db))[info[#info]] end, function(info, value) (profile(db))[info[#info]] = value; PA:UpdateCooldownSettings(db); end, nil, function() if db == 'global' then return PA.db.Cooldown.Enable else return (PA.db.Cooldown.Enable and not profile(db).reverse) or (not PA.db.Cooldown.Enable and profile(db).reverse) end end)

	local seconds = PA.ACH:Group(PA.ACL["Text Threshold"], nil, 3, nil, function(info) return (profile(db))[info[#info]] end, function(info, value) (profile(db))[info[#info]] = value; PA:UpdateCooldownSettings(db); end, function() return not (profile(db)).checkSeconds end)
	seconds.inline = true
	seconds.args.checkSeconds = PA.ACH:Toggle(PA.ACL["Enable"], PA.ACL["This will override the global cooldown settings."], 1, nil, nil, nil, nil, nil, false)
	seconds.args.mmssThreshold = PA.ACH:Range(PA.ACL["MM:SS Threshold"], PA.ACL["Threshold (in seconds) before text is shown in the MM:SS format. Set to -1 to never change to this format."], 2, { min = -1, max = 10800, step = 1 })
	seconds.args.hhmmThreshold = PA.ACH:Range(PA.ACL["HH:MM Threshold"], PA.ACL["Threshold (in minutes) before text is shown in the HH:MM format. Set to -1 to never change to this format."], 3, { min = -1, max = 1440, step = 1 })
	mainArgs.secondsGroup = seconds

	local fonts = PA.ACH:Group(PA.ACL["Fonts"], nil, 4, nil, function(info) return (profile(db)).fonts[info[#info]] end, function(info, value) (profile(db)).fonts[info[#info]] = value; PA:UpdateCooldownSettings(db); end, function() return not (profile(db)).fonts.enable end)
	fonts.inline = true
	fonts.args.enable = PA.ACH:Toggle(PA.ACL["Enable"], PA.ACL["This will override the global cooldown settings."], 1, nil, nil, nil, nil, nil, false)
	fonts.args.font = PA.ACH:SharedMediaFont(PA.ACL["Font"], nil, 2)
	fonts.args.fontSize = PA.ACH:Range(PA.ACL["Font Size"], nil, 3, { min = 10, max = 50, step = 1 })
	fonts.args.fontOutline = PA.ACH:FontFlags(PA.ACL["Font Outline"], nil, 4)
	mainArgs.fontGroup = fonts

	local colors = PA.ACH:Group(PA.ACL["Color Override"], nil, 5, nil, nil, nil, function() return not (profile(db)).override end)
	colors.inline = true
	colors.args.override = PA.ACH:Toggle(PA.ACL["Enable"], PA.ACL["This will override the global cooldown settings."], 1, nil, nil, nil, function(info) return (profile(db))[info[#info]] end, function(info, value) (profile(db))[info[#info]] = value; PA:UpdateCooldownSettings(db); end, false)
	colors.args.threshold = PA.ACH:Range(PA.ACL["Low Threshold"], PA.ACL["Threshold before text turns red and is in decimal form. Set to -1 for it to never turn red"], 2, { min = -1, max = 20, step = 1 }, nil, function(info) return (profile(db))[info[#info]] end, function(info, value) (profile(db))[info[#info]] = value; PA:UpdateCooldownSettings(db); end)
	mainArgs.colorGroup = colors

	local tColors = PA.ACH:Group(PA.ACL["Threshold Colors"], nil, 3)
	tColors.args.expiringColor = PA.ACH:Color(PA.ACL["Expiring"], PA.ACL["Color when the text is about to expire"], 1)
	tColors.args.secondsColor = PA.ACH:Color(PA.ACL["Seconds"], PA.ACL["Color when the text is in the seconds format."], 2)
	tColors.args.minutesColor = PA.ACH:Color(PA.ACL["Minutes"], PA.ACL["Color when the text is in the minutes format."], 3)
	tColors.args.hoursColor = PA.ACH:Color(PA.ACL["Hours"], PA.ACL["Color when the text is in the hours format."], 4)
	tColors.args.daysColor = PA.ACH:Color(PA.ACL["Days"], PA.ACL["Color when the text is in the days format."], 5)
	tColors.args.mmssColor = PA.ACH:Color(PA.ACL["MM:SS"], nil, 6)
	tColors.args.hhmmColor = PA.ACH:Color(PA.ACL["HH:MM"], nil, 7)
	mainArgs.colorGroup.args.timeColors = tColors

	local iColors = PA.ACH:Group(PA.ACL["Time Indicator Colors"], nil, 4, nil, nil, nil, function() return not (profile(db)).useIndicatorColor end)
	iColors.args.useIndicatorColor = PA.ACH:Toggle(PA.ACL["Use Indicator Color"], nil, 0, nil, nil, nil, function(info) return (profile(db))[info[#info]] end, function(info, value) (profile(db))[info[#info]] = value; PA:UpdateCooldownSettings(db); end, false)
	iColors.args.expireIndicator = PA.ACH:Color(PA.ACL["Expiring"], PA.ACL["Color when the text is about to expire"], 1)
	iColors.args.secondsIndicator = PA.ACH:Color(PA.ACL["Seconds"], PA.ACL["Color when the text is in the seconds format."], 2)
	iColors.args.minutesIndicator = PA.ACH:Color(PA.ACL["Minutes"], PA.ACL["Color when the text is in the minutes format."], 3)
	iColors.args.hoursIndicator = PA.ACH:Color(PA.ACL["Hours"], PA.ACL["Color when the text is in the hours format."], 4)
	iColors.args.daysIndicator = PA.ACH:Color(PA.ACL["Days"], PA.ACL["Color when the text is in the days format."], 5)
	iColors.args.hhmmColorIndicator = PA.ACH:Color(PA.ACL["MM:SS"], nil, 6)
	iColors.args.mmssColorIndicator = PA.ACH:Color(PA.ACL["HH:MM"], nil, 7)
	mainArgs.colorGroup.args.indicatorColors = iColors
Azilroka's avatar
Azilroka committed
448 449

	if db == 'global' then
Azilroka's avatar
Azilroka committed
450 451 452 453 454 455 456 457
		mainArgs.reverse = nil
		mainArgs.colorGroup.args.override = nil
		mainArgs.colorGroup.disabled = nil
		mainArgs.colorGroup.name = PA.ACL["COLORS"]

		-- keep these two in this order
		PA.Options.args.Cooldown.args.hideBlizzard = mainArgs.hideBlizzard
		mainArgs.hideBlizzard = nil
Azilroka's avatar
Azilroka committed
458
	else
Azilroka's avatar
Azilroka committed
459 460 461
		mainArgs.reverse = nil
		mainArgs.hideBlizzard = nil
		mainArgs.fontGroup = nil
Azilroka's avatar
Azilroka committed
462 463 464
	end
end

Azilroka's avatar
Azilroka committed
465 466 467
PA.Options.args.Cooldown = PA.ACH:Group(PA.ACL["Cooldown Text"], nil, 2, 'tab', function(info) return PA.db.Cooldown[info[#info]] end, function(info, value) PA.db.Cooldown[info[#info]] = value; PA:UpdateCooldownSettings('global'); end)
PA.Options.args.Cooldown.args.intro = PA.ACH:Description(PA.ACL["COOLDOWN_DESC"], 0)
PA.Options.args.Cooldown.args.Enable = PA.ACH:Toggle(PA.ACL["Enable"], PA.ACL["Display cooldown text on anything with the cooldown spiral."], 1)
Azilroka's avatar
Azilroka committed
468 469 470

group(5,  'global',     PA.ACL["Global"])
group(6, 'OzCooldowns',  PA.ACL.OzCooldowns)
Azilroka's avatar
Azilroka committed
471
group(7, 'iFilger',  PA.ACL.iFilger)