PK >ߟ OmniCC/aniUpdater.lua--[[
An animation sytem based timer thingy
--]]
local Classy = LibStub('Classy-1.0')
local OmniCC = OmniCC
local AniUpdater = Classy:New('Frame'); OmniCC.AniUpdater = AniUpdater
local updaters = setmetatable({}, {__index = function(self, frame)
local updater = AniUpdater:New(frame)
self[frame] = updater
return updater
end})
function AniUpdater:Get(frame)
-- print('AniUpdater:Get', frame)
return updaters[frame]
end
function AniUpdater:GetActive(frame)
-- print('AniUpdater:GetActive', frame)
return rawget(updaters, frame)
end
local animation_OnFinished = function(self) self:GetParent():OnFinished() end
function AniUpdater:New(frame)
-- print('AniUpdater:New', frame)
local updater = self:Bind(CreateFrame('Frame', nil)); updater:Hide()
updater.frame = frame
local aniGroup = updater:CreateAnimationGroup()
aniGroup:SetLooping('NONE')
aniGroup:SetScript('OnFinished', animation_OnFinished)
updater.aniGroup = aniGroup
local ani = aniGroup:CreateAnimation('Animation')
ani:SetOrder(1)
updater.ani = ani
return updater
end
function AniUpdater:StopAnimation()
-- print('AniUpdater:StopAnimation')
if self.aniGroup:IsPlaying() then
self.aniGroup:Stop()
end
end
function AniUpdater:ScheduleUpdate(delay)
-- print('AniUpdater:ScheduleUpdate', delay)
self:StopAnimation()
if delay > 0 then
self:Show()
self.ani:SetDuration(delay)
self.aniGroup:Play()
else
self:OnFinished()
end
end
function AniUpdater:CancelUpdate()
-- print('AniUpdater:CancelUpdate')
self:StopAnimation()
self:Hide()
end
function AniUpdater:OnFinished()
-- print('AniUpdater:OnFinished')
self:Hide()
self.frame:OnScheduledUpdate()
endPK >dL OmniCC/classicUpdater.lua--[[
An OnUpdate sytem based timer thingy
--]]
local OmniCC = OmniCC
local Classy = LibStub('Classy-1.0')
local ClassicUpdater = Classy:New('Frame'); OmniCC.ClassicUpdater = ClassicUpdater
local updaters = setmetatable({}, {__index = function(self, frame)
local updater = ClassicUpdater:New(frame)
self[frame] = updater
return updater
end})
--[[ Updater Retrieval ]]--
function ClassicUpdater:Get(frame)
-- print('ClassicUpdater:Get', frame)
return updaters[frame]
end
function ClassicUpdater:GetActive(frame)
-- print('ClassicUpdater:GetActive', frame)
return rawget(updaters, frame)
end
function ClassicUpdater:New(frame)
-- print('ClassicUpdater:New', count, frame)
local updater = self:Bind(CreateFrame('Frame', nil)); updater:Hide()
updater:SetScript('OnUpdate', updater.OnUpdate)
updater.frame = frame
return updater
end
--[[ Updater Events ]]--
function ClassicUpdater:OnUpdate(elapsed)
-- print('ClassicUpdater:OnUpdate', elapsed)
local delay = self.delay - elapsed
if delay > 0 then
self.delay = delay
else
self:OnFinished()
end
end
function ClassicUpdater:OnFinished()
-- print('ClassicUpdater:OnFinished')
self:Cleanup()
self.frame:OnScheduledUpdate()
end
--[[ Updater Updating ]]--
function ClassicUpdater:ScheduleUpdate(delay)
-- print('ClassicUpdater:ScheduleUpdate', delay)
if delay > 0 then
self.delay = delay
self:Show()
else
self:OnFinished()
end
end
function ClassicUpdater:CancelUpdate()
-- print('ClassicUpdater:CancelUpdate')
self:Cleanup()
end
function ClassicUpdater:Cleanup()
-- print('ClassicUpdater:Cleanup')
self:Hide()
self.delay = nil
endPK >S;j OmniCC/embeds.xml
PK >f嵮0 0 OmniCC/LICENSECopyright (c) 2010 Jason Greer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.PK >/)ch h OmniCC/localization.xml
PK e?u% % OmniCC/OmniCC.lua--[[
config.lua
OmniCC configuration settings
--]]
local OmniCC = CreateFrame('Frame', 'OmniCC'); OmniCC:Hide()
local CONFIG_NAME = 'OmniCC4Config'
local L = OMNICC_LOCALS
--[[---------------------------------------
Local Functions
--]]---------------------------------------
local function removeTable(tbl, defaults)
for k, v in pairs(defaults) do
if type(tbl[k]) == 'table' and type(v) == 'table' then
removeTable(tbl[k], v)
if next(tbl[k]) == nil then
tbl[k] = nil
end
elseif tbl[k] == v then
tbl[k] = nil
end
end
return tbl
end
local function copyTable(tbl, defaults)
for k, v in pairs(defaults) do
if type(v) == 'table' then
tbl[k] = copyTable(tbl[k] or {}, v)
elseif tbl[k] == nil then
tbl[k] = v
end
end
return tbl
end
--[[---------------------------------------
Events
--]]---------------------------------------
OmniCC:SetScript('OnEvent', function(self, event, ...)
local a = self[event]
if a then
a(self, event, ...)
end
end)
function OmniCC:PLAYER_LOGIN()
--add slash commands
SLASH_OmniCC1 = '/omnicc'
SLASH_OmniCC2 = '/occ'
SlashCmdList['OmniCC'] = function(msg)
self:OnSlashCmd(strsplit(' ', (msg or ''):lower()))
end
--create options loader
local f = CreateFrame('Frame', nil, InterfaceOptionsFrame)
f:SetScript('OnShow', function(self)
self:SetScript('OnShow', nil)
LoadAddOn('OmniCC_Config')
end)
end
function OmniCC:PLAYER_LOGOUT()
self:RemoveDefaults(self.db)
end
OmniCC:RegisterEvent('PLAYER_LOGOUT')
OmniCC:RegisterEvent('PLAYER_LOGIN')
--[[---------------------------------------
Saved Settings
--]]---------------------------------------
function OmniCC:GetDB()
return self.db or self:InitDB()
end
function OmniCC:InitDB()
local db = _G[CONFIG_NAME]
if db then
if db.version ~= self:GetAddOnVersion() then
db = self:UpgradeDB(db)
end
else
db = self:CreateNewDB()
_G[CONFIG_NAME] = db
end
copyTable(db, self:GetGlobalDefaults())
--copy defaults
local groupDefaults = self:GetGroupDefaults()
for groupId, styleInfo in pairs(db.groupSettings) do
copyTable(styleInfo, groupDefaults)
end
self.db = db
return db
end
function OmniCC:RemoveDefaults(db)
if not db then return end
removeTable(db, self:GetGlobalDefaults())
--remove base from any custom groups
local groupDefaults = self:GetGroupDefaults()
for groupId, styleInfo in pairs(db.groupSettings) do
removeTable(styleInfo, groupDefaults)
end
end
function OmniCC:CreateNewDB()
local db = {
groups = {},
groupSettings = {
base = {},
},
version = self:GetAddOnVersion()
}
--upgrade jamber from OmniCC3 to 4
if _G['OmniCCGlobalSettings'] then
db.groupSettings.base = _G['OmniCCGlobalSettings']
db.groupSettings.base.blacklist = nil
db.groupSettings.base.useBlacklist = nil
db.groupSettings.base.minFontSize = nil
end
return db
end
function OmniCC:GetGlobalDefaults()
return {
updaterEngine = 'AniUpdater',
}
end
function OmniCC:GetGroupDefaults()
return {
enabled = true,
scaleText = true,
showCooldownModels = true,
fontFace = STANDARD_TEXT_FONT,
fontSize = 18,
fontOutline = 'OUTLINE',
minDuration = 3,
minSize = 0.5,
effect = 'pulse',
minEffectDuration = 30,
tenthsDuration = 0,
mmSSDuration = 0,
--text coloring
styles = {
soon = {
r = 1, g = 0, b= 0, a = 1,
scale = 1.5,
},
seconds = {
r = 1, g = 1, b= 0, a = 1,
scale = 1,
},
minutes = {
r = 1, g = 1, b = 1, a = 1,
scale = 1,
},
hours = {
r = 0.7, g = 0.7, b = 0.7, a = 1,
scale = 0.75,
},
},
--text positioning
xOff = 0,
yOff = 0,
anchor = 'CENTER'
}
end
function OmniCC:UpgradeDB(db)
local pMajor, pMinor, pBugfix = db.version:match('(%d+)\.(%d+)\.(%w+)')
if tonumber(pMajor) < 4 then
db = OmniCC:CreateNewDB()
_G[CONFIG_NAME] = db
return db
end
db.version = self:GetAddOnVersion()
return db
end
function OmniCC:GetAddOnVersion()
return GetAddOnMetadata('OmniCC', 'Version')
end
--[[---------------------------------------
Update Engine
--]]---------------------------------------
function OmniCC:ScheduleUpdate(frame, delay)
local engine = self:GetUpdateEngine()
local updater = engine:Get(frame)
updater:ScheduleUpdate(delay)
end
function OmniCC:CancelUpdate(frame)
local engine = self:GetUpdateEngine()
local updater = engine:GetActive(frame)
if updater then
updater:CancelUpdate()
end
end
function OmniCC:GetUpdateEngine()
return self[self:GetDB().updaterEngine]
end
function OmniCC:GetUpdateEngineName()
return self:GetDB().updaterEngine
end
function OmniCC:SetUpdateEngine(engine)
self:GetDB().updaterEngine = engine or 'AniUpdater'
end
--[[---------------------------------------
Group Mapping
--]]---------------------------------------
local cdToGroupCache = {}
local function cooldown_GetGroupId(cooldown)
local name = cooldown:GetName()
if name then
local groups = OmniCC:GetDB().groups
for i = #groups, 1, -1 do
local group = groups[i]
if group.enabled then
for _, pattern in pairs(group.rules) do
if name:match(pattern) then
return group.id
end
end
end
end
end
return 'base'
end
--maps the given cooldown to a groupId
function OmniCC:CDToGroup(cooldown)
local groupId = cdToGroupCache[cooldown]
--save groupIds so that we don't have to look them up again
if not groupId then
groupId = cooldown_GetGroupId(cooldown)
cdToGroupCache[cooldown] = groupId
end
return groupId
end
function OmniCC:RecalculateCachedGroups()
for cooldown, groupId in pairs(cdToGroupCache) do
local newGroupId = cooldown_GetGroupId(cooldown)
if groupId ~= newGroupId then
cdToGroupCache[cooldown] = newGroupId
--settings group changed, update timer
local timer = self.Timer:Get(cooldown)
if timer and timer.visible then
timer:UpdateText(true)
timer:UpdateCooldownShown()
end
end
end
end
function OmniCC:GetGroupSettings(groupId)
return self:GetDB().groupSettings[groupId]
end
--[[---------------------------------------
Group Adding/Removing
--]]---------------------------------------
function OmniCC:AddGroup(groupId)
if not self:GetGroupIndex(groupId) then
local db = self:GetDB()
db.groupSettings[groupId] = copyTable({}, db.groupSettings['base'])
table.insert(db.groups, {id = groupId, rules = {}, enabled = true})
self:RecalculateCachedGroups()
return true
end
end
function OmniCC:RemoveGroup(groupId)
local index = self:GetGroupIndex(groupId)
if index then
local db = self:GetDB()
db.groupSettings[groupId] = nil
table.remove(db.groups, index)
self:RecalculateCachedGroups()
return true
end
end
function OmniCC:GetGroupIndex(groupId)
local db = self:GetDB()
for i, group in pairs(db.groups) do
if group.id == groupId then
return i
end
end
return false
end
--[[---------------------------------------
Finish Effects
--]]---------------------------------------
function OmniCC:TriggerEffect(effectId, cooldown, ...)
local effect = self:GetEffect(effectId)
if effect then
effect:Run(cooldown, ...)
end
end
function OmniCC:RegisterEffect(effect)
if not self:GetEffect(effect.id) then
self.effects = self.effects or {}
table.insert(self.effects, effect)
end
end
function OmniCC:GetEffect(effectId)
if self.effects then
for _, effect in pairs(self.effects) do
if effect.id == effectId then
return effect
end
end
end
end
function OmniCC:ForEachEffect(f, ...)
local results
if self.effects then
for _, effect in pairs(self.effects) do
local result = f(effect, ...)
if result then
results = results or {}
tinsert(results, result)
end
end
end
return results
end
function OmniCC:GetIcon(frame)
if frame then
local icon = frame.icon
if icon and icon.GetTexture then
return icon
end
local name = frame:GetName()
if name then
local icon = _G[name .. 'Icon'] or _G[name .. 'IconTexture']
if icon and icon.GetTexture then
return icon
end
end
end
end
--[[---------------------------------------
Slash Commands
--]]---------------------------------------
function OmniCC:OnSlashCmd(...)
local cmd = ...
if cmd == '' or cmd == 'config' or cmd == 'menu' then
if LoadAddOn('OmniCC_Config') then
InterfaceOptionsFrame_OpenToCategory('OmniCC')
end
elseif cmd == 'setengine' then
local engine = select(2, ...)
if engine == 'classic' then
self:SetUpdateEngine('ClassicUpdater')
self:Print(L.SetEngine_Classic)
elseif engine == 'animation' or engine == 'ani' then
self:SetUpdateEngine('AniUpdater')
self:Print(L.SetEngine_Animation)
elseif engine and engine ~= '' then
self:Print(L.UnknownEngineName:format(engine))
else
self:Print(L.SetEngineUsage)
end
elseif cmd == 'engine' then
local engineName = (self:GetUpdateEngineName() == 'AniUpdater' and 'Animation' or 'Classic')
self:Print(engineName)
elseif cmd == 'version' then
self:Print(self:GetAddOnVersion())
elseif cmd == 'help' then
self:Print(L.Commands)
print(L.Command_ShowOptionsMenu)
print(L.Command_SetTimerEngine)
print(L.Command_ShowAddonVersion)
else
self:Print(L.UnknownCommandName:format(cmd))
end
end
function OmniCC:Print(...)
return print('|cffFCF75EOmniCC|r:', ...)
endPK ?Fsob{ { OmniCC/OmniCC.toc## Interface: 40200
## Title: OmniCC
## Notes: Cooldown count for everything
## Notes-koKR: 모든 것을 위한 쿨다운 카운트
## Author: Tuller
## Version: 4.2.2
## SavedVariables: OmniCC4Config
embeds.xml
localization.xml
OmniCC.lua
timer.lua
aniUpdater.lua
classicUpdater.lua
effects\alert.lua
effects\activate.lua
effects\pulse.lua
effects\shine.luaPK >|. . OmniCC/timer.lua--[[
cc.lua
Displays text for cooldowns on widgets
cases when font size should be updated:
frame is resized
font is changed
cases when text should be hidden:
scale * fontSize < MIN_FONT_SIE
--]]
--globals!
local Classy = LibStub('Classy-1.0')
local OmniCC = OmniCC
--constants!
local ICON_SIZE = 36 --the normal size for an icon (don't change this)
local DAY, HOUR, MINUTE = 86400, 3600, 60 --used for formatting text
local DAYISH, HOURISH, MINUTEISH, SOONISH = 3600 * 23.5, 60 * 59.5, 59.5, 5.5 --used for formatting text at transition points
local HALFDAYISH, HALFHOURISH, HALFMINUTEISH = DAY/2 + 0.5, HOUR/2 + 0.5, MINUTE/2 + 0.5 --used for calculating next update times
local PADDING = 0 --amount of spacing between the timer text and the rest of the cooldown
--local bindings!
local floor = math.floor
local min = math.min
local round = function(x) return floor(x + 0.5) end
local GetTime = GetTime
--[[
the cooldown timer object:
displays time remaining for the given cooldown
--]]
local Timer = Classy:New('Frame'); Timer:Hide(); OmniCC.Timer = Timer
local timers = {}
--[[ Constructorish ]]--
function Timer:New(cooldown)
local timer = Timer:Bind(CreateFrame('Frame', nil, cooldown:GetParent())); timer.cooldown = cooldown
timer:SetFrameLevel(cooldown:GetFrameLevel() + 5)
timer:Hide()
timer.text = timer:CreateFontString(nil, 'OVERLAY')
--we set the timer to the center of the cooldown and manually set size information in order to allow me to scale text
--if we do set all points instead, then timer text tends to move around when the timer itself is scale)
timer:SetPoint('CENTER', cooldown)
timer:Size(cooldown:GetSize())
timers[cooldown] = timer
return timer
end
function Timer:Get(cooldown)
return timers[cooldown]
end
function Timer:OnScheduledUpdate()
--print('Timer:OnScheduledUpdate')
self:UpdateText()
end
--[[ Updaters ]]--
--starts the timer for the given cooldown
function Timer:Start(start, duration)
self.start = start
self.duration = duration
self.enabled = true
self.visible = self.cooldown:IsVisible()
self.textStyle = nil
self:UpdateShown()
end
--stops the timer
function Timer:Stop()
self.start = nil
self.duration = nil
self.enabled = nil
self.visible = nil
self.textStyle = nil
self:CancelUpdate()
self:Hide()
end
--adjust font size whenever the timer's parent size changes
--hide if it gets too tiny
function Timer:Size(width, height)
self.abRatio = round(width) / ICON_SIZE
self:SetSize(width, height)
self:UpdateTextPosition()
if self.enabled and self.visible then
self:UpdateText(true)
end
end
function Timer:UpdateText(forceStyleUpdate)
--print('Timer:UpdateText', forceStyleUpdate)
--handle deathknight runes, which have timers that start in the future
if self.start > GetTime() then
self:ScheduleUpdate(self.start - GetTime())
return
end
--if there's time left on the clock, then update the timer text
--otherwise stop the timer
local remain = self:GetRemain()
if remain > 0 then
local overallScale = self.abRatio * (self:GetEffectiveScale()/UIParent:GetScale()) --used to determine text visibility
--hide text if it's too small to display
--check again in one second
if overallScale < self:GetSettings().minSize then
self.text:Hide()
self:ScheduleUpdate(1)
else
--update text style based on time remaining
local styleId = self:GetTextStyleId(remain)
if (styleId ~= self.textStyle) or forceStyleUpdate then
self.textStyle = styleId
self:UpdateTextStyle()
end
--make sure that we have text, and then set text
if self.text:GetFont() then
self.text:SetFormattedText(self:GetTimeText(remain))
self.text:Show()
end
self:ScheduleUpdate(self:GetNextUpdate(remain))
end
else
--if the timer was long enough to, and text is still visible
--then trigger a finish effect
if self.duration >= self:GetSettings().minEffectDuration then
OmniCC:TriggerEffect(self:GetSettings().effect, self.cooldown, self.duration)
end
self:Stop()
end
end
function Timer:UpdateTextStyle()
--print('Timer:UpdateTextStyle')
local sets = self:GetSettings()
local font, size, outline = sets.fontFace, sets.fontSize, sets.fontOutline
local style = sets.styles[self.textStyle]
if sets.scaleText then
size = size * style.scale * (self.abRatio or 1)
else
size = size * style.scale
end
--fallback to the standard font if the font we tried to set happens to be invalid
if size > 0 then
local fontSet = self.text:SetFont(font, size, outline)
if not fontSet then
self.text:SetFont(STANDARD_TEXT_FONT, size, outline)
end
end
self.text:SetTextColor(style.r, style.g, style.b, style.a)
end
function Timer:UpdateTextPosition()
local sets = self:GetSettings()
local abRatio = self.abRatio or 1
local text = self.text
text:ClearAllPoints()
text:SetPoint(sets.anchor, sets.xOff * abRatio, sets.yOff * abRatio)
end
function Timer:UpdateShown()
if self:ShouldShow() then
self:Show()
self:UpdateText()
else
self:Hide()
end
end
function Timer:UpdateCooldownShown()
self.cooldown:SetAlpha(self:GetSettings().showCooldownModels and 1 or 0)
end
--[[ Update Scheduling ]]--
function Timer:ScheduleUpdate(delay)
--print('Timer:ScheduleUpdate', delay)
OmniCC:ScheduleUpdate(self, delay)
end
function Timer:CancelUpdate()
--print('Timer:CancelUpdate')
OmniCC:CancelUpdate(self)
end
--[[ Accessors ]]--
function Timer:GetRemain()
return self.duration - (GetTime() - self.start)
end
--retrieves the period style id associated with the given time frame
--necessary to retrieve text coloring information from omnicc
function Timer:GetTextStyleId(s)
if s < SOONISH then
return 'soon'
elseif s < MINUTEISH then
return 'seconds'
elseif s < HOURISH then
return 'minutes'
else
return 'hours'
end
end
--return the time until the next text update
function Timer:GetNextUpdate(remain)
local sets = self:GetSettings()
if remain < (sets.tenthsDuration + 0.5) then
return 0.1
elseif remain < MINUTEISH then
return remain - (round(remain) - 0.51)
elseif remain < sets.mmSSDuration then
return remain - (round(remain) - 0.51)
elseif remain < HOURISH then
local minutes = round(remain/MINUTE)
if minutes > 1 then
return remain - (minutes*MINUTE - HALFMINUTEISH)
end
return remain - (MINUTEISH - 0.01)
elseif remain < DAYISH then
local hours = round(remain/HOUR)
if hours > 1 then
return remain - (hours*HOUR - HALFHOURISH)
end
return remain - (HOURISH - 0.01)
else
local days = round(remain/DAY)
if days > 1 then
return remain - (days*DAY - HALFDAYISH)
end
return remain - (DAYISH - 0.01)
end
end
--returns a format string, as well as any args for text to display
function Timer:GetTimeText(remain)
local sets = self:GetSettings()
--show tenths of seconds below tenths threshold
if remain < sets.tenthsDuration then
return '%.1f', remain
--format text as seconds when at 90 seconds or below
elseif remain < MINUTEISH then
--prevent 0 seconds from displaying
local seconds = round(remain)
return (seconds == 0 and '') or seconds
--format text as MM:SS when below the MM:SS threshold
elseif remain < sets.mmSSDuration then
local seconds = round(remain)
return '%d:%02d', seconds/MINUTE, seconds%MINUTE
--format text as minutes when below an hour
elseif remain < HOURISH then
return '%dm', round(remain/MINUTE)
--format text as hours when below a day
elseif remain < DAYISH then
return '%dh', round(remain/HOUR)
--format text as days
else
return '%dd', round(remain/DAY)
end
end
--returns true if the timer should be shown
--and false otherwise
function Timer:ShouldShow()
--the timer should have text to display and also have its cooldown be visible
if not (self.enabled and self.visible) or self.cooldown.noCooldownCount then
return false
end
local sets = self:GetSettings()
if self.duration < sets.minDuration then
return false
end
--the cooldown of the timer shouldn't be blacklisted
return sets.enabled
end
function Timer:GetSettings()
return OmniCC:GetGroupSettings(OmniCC:CDToGroup(self.cooldown))
end
--[[ Meta Functions ]]--
function Timer:ForAll(f, ...)
if type(f) == 'string' then
f = self[f]
end
for _, timer in pairs(timers) do
f(timer, ...)
end
end
function Timer:ForAllShown(f, ...)
if type(f) == 'string' then
f = self[f]
end
for _, timer in pairs(timers) do
if timer:IsShown() then
f(timer, ...)
end
end
end
--[[ cooldown display ]]--
--show the timer if the cooldown is shown
local function cooldown_OnShow(self)
local timer = Timer:Get(self)
if timer and timer.enabled then
if timer:GetRemain() > 0 then
timer.visible = true
timer:UpdateShown()
else
timer:Stop()
end
end
end
--hide the timer if the cooldown is hidden
local function cooldown_OnHide(self)
local timer = Timer:Get(self)
if timer and timer.enabled then
timer.visible = nil
timer:Hide()
end
end
--adjust the size of the timer when the cooldown's size changes
--facts to know:
--OnSizeChanged occurs more frequently than you would think
--so I've added a check to only resize timers when a cooldown's width changes
local function cooldown_OnSizeChanged(self, ...)
local width = ...
if self.omniccw ~= width then
self.omniccw = width
local timer = Timer:Get(self)
if timer then
timer:Size(...)
end
end
end
local function cooldown_StopTimer(self)
local timer = Timer:Get(self)
if timer and timer.enabled then
timer:Stop()
end
end
--apply some extra functionality to the cooldown
--so that we can track hide/show/and size changes
local function cooldown_Init(self)
self:HookScript('OnShow', cooldown_OnShow)
self:HookScript('OnHide', cooldown_OnHide)
self:HookScript('OnSizeChanged', cooldown_OnSizeChanged)
end
local function cooldown_OnSetCooldown(self, start, duration)
--don't do anything if there's no timer to display, or the timer has been blacklisted
if self.noCooldownCount or not(start and duration) then
cooldown_StopTimer(self)
return
end
local sets = OmniCC:GetGroupSettings(OmniCC:CDToGroup(self))
--hide/show cooldown model as necessary
self:SetAlpha(sets.showCooldownModels and 1 or 0)
--start timer if duration is over the min duration & the timer is enabled
if start > 0 and duration >= sets.minDuration and sets.enabled then
--apply methods to the cooldown frame if they do not exist yet
if not self.omnicc then
cooldown_Init(self)
self.omnicc = true
end
--hide cooldown model if necessary and start the timer
local timer = Timer:Get(self) or Timer:New(self)
timer:Start(start, duration)
--stop timer
else
cooldown_StopTimer(self)
end
end
--bugfix: force update timers when entering an arena
do
local addonName = ...
local f = CreateFrame('Frame'); f:Hide()
f:SetScript('OnEvent', function(self, event, ...)
--update visible timers on player_entering_world (arena update hack)
if event == 'PLAYER_ENTERING_WORLD' then
Timer:ForAllShown('UpdateText')
--hook cooldown stuff only after the addon is actually loaded
elseif event == 'ADDON_LOADED' then
local name = ...
if name == addonName then
hooksecurefunc(getmetatable(ActionButton1Cooldown).__index, 'SetCooldown', cooldown_OnSetCooldown)
self:UnregisterEvent('ADDON_LOADED')
end
end
end)
f:RegisterEvent('PLAYER_ENTERING_WORLD')
f:RegisterEvent('ADDON_LOADED')
endPK ?Z#g, , OmniCC/effects/activate.lua--[[
activate.lua
mimics the default effect that shows up when an ability "procs"
--]]
local Classy = LibStub('Classy-1.0')
local L = OMNICC_LOCALS
local hooked = {}
local active = {}
OmniCC:RegisterEffect({
id = 'activate',
name = L.Activate,
desc = L.ActivateTip,
Run = function(self, cooldown)
local button = cooldown:GetParent()
if button then
ActionButton_ShowOverlayGlow(button)
active[button] = true
local overlay = button.overlay
if not hooked[overlay] then
overlay.animIn:HookScript('OnFinished', function()
if active[button] then
ActionButton_HideOverlayGlow(button)
active[button] = nil
end
end)
hooked[overlay] = true
end
end
end
})PK ?5 OmniCC/effects/alert.lua--[[
alert.lua
a finish effect that displays the cooldown at the center of the screen
--]]
local L = OMNICC_LOCALS
local Frame = CreateFrame('Frame', nil, UIParent)
Frame:SetPoint('CENTER')
Frame:SetSize(50, 50)
Frame:SetAlpha(0)
local Icon = Frame:CreateTexture()
Icon:SetAllPoints()
local Anims = Frame:CreateAnimationGroup()
Anims:SetLooping('NONE')
Anims:SetScript('OnFinished', function()
Frame:Hide()
end)
local function newAnim(type, change, order)
local anim = Anims:CreateAnimation(type)
anim:SetDuration(0.3)
anim:SetOrder(order)
if type == 'Scale' then
anim:SetOrigin('CENTER', 0, 0)
anim:SetScale(change, change)
else
anim:SetChange(change)
end
end
newAnim('Scale', 2.5, 1)
newAnim('Alpha', .7, 1)
newAnim('Scale', -2.5, 2)
newAnim('Alpha', -.7, 2)
OmniCC:RegisterEffect({
id = 'alert',
name = L.Alert,
desc = L.AlertTip,
Run = function(self, cooldown)
local button = cooldown:GetParent()
local icon = OmniCC:GetIcon(button)
if icon then
Icon:SetTexture(icon:GetTexture())
Frame:Show()
if Anims:IsPlaying() then
Anims:Finish()
end
Anims:Play()
end
end
})PK r?yAq OmniCC/effects/pulse.lua--[[
pulse.lua
a pulsing finish effect
--]]
local Classy = LibStub('Classy-1.0')
local L = OMNICC_LOCALS
local PULSE_SCALE = 2.5
local PULSE_DURATION = 0.6
--[[
The pulse object
--]]
local Pulse = Classy:New('Frame')
function Pulse:New(parent)
local f = self:Bind(CreateFrame('Frame', nil, parent)); f:Hide()
f:SetAllPoints(parent)
f:SetToplevel(true)
f:SetScript('OnHide', f.OnHide)
f.animation = f:CreatePulseAnimation()
local icon = f:CreateTexture(nil, 'OVERLAY')
icon:SetBlendMode('ADD')
icon:SetAllPoints(f)
f.icon = icon
return f
end
do
local function animation_OnFinished(self)
local parent = self:GetParent()
if parent:IsShown() then
parent:Hide()
end
end
local function scale_OnFinished(self)
if self.reverse then
self.reverse = nil
self:GetParent():Finish()
else
self.reverse = true
end
end
function Pulse:CreatePulseAnimation()
local g = self:CreateAnimationGroup()
g:SetLooping('BOUNCE')
g:SetScript('OnFinished', animation_OnFinished)
--animation = AnimationGroup:CreateAnimation("animationType" [, "name" [, "inheritsFrom"]])
local grow = g:CreateAnimation('Scale')
grow:SetScale(PULSE_SCALE, PULSE_SCALE)
grow:SetOrigin('CENTER', 0, 0)
grow:SetDuration(PULSE_DURATION/2)
grow:SetOrder(0)
grow:SetScript('OnFinished', scale_OnFinished)
return g
end
end
function Pulse:OnHide()
if self.animation:IsPlaying() then
self.animation:Stop()
end
self:Hide()
end
function Pulse:Start(texture)
if self.animation:IsPlaying() then
self.animation:Stop()
end
local icon = self.icon
local r, g, b = icon:GetVertexColor()
icon:SetVertexColor(r, g, b, 0.7)
icon:SetTexture(texture:GetTexture())
self:Show()
self.animation:Play()
end
--[[ register effect with OmniCC ]]--
do
local pulses = setmetatable({}, {__index = function(t, k)
local f = Pulse:New(k)
t[k] = f
return f
end})
OmniCC:RegisterEffect{
id = 'pulse',
name = L.Pulse,
desc = L.PulseTip,
Run = function(self, cooldown)
local b = cooldown:GetParent()
local icon = OmniCC:GetIcon(b)
if icon then
pulses[b]:Start(icon)
end
end
}
endPK ?=I I OmniCC/effects/shine.lua--[[
shine.lua
a shine finish effect
--]]
local Classy = LibStub('Classy-1.0')
local L = OMNICC_LOCALS
local SCALE = 5
local DURATION = 0.75
local TEXTURE = [[Interface\Cooldown\star4]]
--[[
The shine object
--]]
local Shine = Classy:New('Frame')
function Shine:New(parent)
local f = self:Bind(CreateFrame('Frame', nil, parent)); f:Hide()
f:SetScript('OnHide', f.OnHide)
f:SetAllPoints(parent)
f:SetToplevel(true)
f.animation = f:CreateShineAnimation()
local icon = f:CreateTexture(nil, 'OVERLAY')
icon:SetPoint('CENTER')
icon:SetBlendMode('ADD')
icon:SetAllPoints(f)
icon:SetTexture(TEXTURE)
return f
end
do
local function animation_OnFinished(self)
local parent = self:GetParent()
if parent:IsShown() then
parent:Hide()
end
end
function Shine:CreateShineAnimation()
local g = self:CreateAnimationGroup()
g:SetLooping('NONE')
g:SetScript('OnFinished', animation_OnFinished)
--start the animation as completely transparent
local startTrans = g:CreateAnimation('Alpha')
startTrans:SetChange(-1)
startTrans:SetDuration(0)
startTrans:SetOrder(0)
local grow = g:CreateAnimation('Scale')
grow:SetOrigin('CENTER', 0, 0)
grow:SetScale(SCALE, SCALE)
grow:SetDuration(DURATION/2)
grow:SetOrder(1)
local brighten = g:CreateAnimation('Alpha')
brighten:SetChange(1)
brighten:SetDuration(DURATION/2)
brighten:SetOrder(1)
local shrink = g:CreateAnimation('Scale')
shrink:SetOrigin('CENTER', 0, 0)
shrink:SetScale(-SCALE, -SCALE)
shrink:SetDuration(DURATION/2)
shrink:SetOrder(2)
local fade = g:CreateAnimation('Alpha')
fade:SetChange(-1)
fade:SetDuration(DURATION/2)
fade:SetOrder(2)
return g
end
end
function Shine:OnHide()
if self.animation:IsPlaying() then
self.animation:Finish()
end
self:Hide()
end
function Shine:Start()
if self.animation:IsPlaying() then
self.animation:Finish()
end
self:Show()
self.animation:Play()
end
--[[ register effect with OmniCC ]]--
do
local shines = setmetatable({}, {__index = function(t, k)
local f = Shine:New(k)
t[k] = f
return f
end})
OmniCC:RegisterEffect{
id = 'shine',
name = L.Shine,
Run = function(self, cooldown)
local p = cooldown:GetParent()
if p then
shines[p]:Start()
end
end
}
endPK >c4 4 % OmniCC/libs/Classy-1.0/Classy-1.0.lua--[[
Classy.lua
A wrapper for defining classes that inherit from widgets
--]]
local Classy = LibStub:NewLibrary('Classy-1.0', 0)
if not Classy then return end
function Classy:New(frameType, parentClass)
local class = CreateFrame(frameType)
class.mt = {__index = class}
if parentClass then
class = setmetatable(class, {__index = parentClass})
class.super = function(self, method, ...)
parentClass[method](self, ...)
end
end
class.Bind = function(self, obj)
return setmetatable(obj, self.mt)
end
return class
endPK >u u OmniCC/libs/LibStub/LibStub.lua-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor
end
function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end
return self.libs[major], self.minors[major]
end
function LibStub:IterateLibraries() return pairs(self.libs) end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
PK >Of f ' OmniCC/localization/localization.cn.lua--[[
OmniCC localization - zhCN
--]]
if GetLocale() ~= 'zhCN' then return end
local L = OMNICC_LOCALS
L.Updated = "升级至 v%s"
L.None = NONE
L.Pulse = "脉冲"
L.Shine = "闪亮"
--slash command text
L.SetEngine_Classic = '切换到经典计时器的引擎。此设置将在下次登录时生效.'
L.SetEngine_Animation = '切换到经典计时器的动画引擎。此设置将在下次登录时生效.'
L.UnknownEngineName = "未知的计时器引擎 '%s'"
L.SetEngineUsage = '用法: /omnicc setengine '
L.Commands = '命令 (/omnicc or /occ):'
L.Command_ShowOptionsMenu = '- config - 显示选项菜单'
L.Command_SetTimerEngine = '- setengine - 开关计时器的更新引擎'
L.Command_ShowAddonVersion = '- version - 显示目前插件的版本'
L.UnknownCommandName = "未知的命令 '%s'"PK >#6 ' OmniCC/localization/localization.de.lua--[[
OmniCC localization - deDE
--]]
if GetLocale() ~= 'deDE' then return end
local L = OMNICC_LOCALS
L.Updated = "Aktualisiert auf v%s"
L.None = NONE
L.Pulse = "Pulse"
L.Shine = "Shine"PK >1, ' OmniCC/localization/localization.ko.lua--[[
OmniCC localization - koKR
--]]
if GetLocale() ~= 'koKR' then return end
local L = OMNICC_LOCALS
L.Updated = "v%s로 업데이트되었습니다."
L.None = NONE
L.Pulse = "맥박"
L.Shine = "반짝임"PK b?U/T $ OmniCC/localization/localization.lua--[[
OmniCC localization - English
--]]
OMNICC_LOCALS = {} --should be done in the US locale file, only
local L = OMNICC_LOCALS
L.Updated = "Updated to version %s"
L.None = NONE
L.Pulse = "Pulse"
L.Shine = "Shine"
L.Alert = "Alert"
L.Activate = "Activate"
--effect tooltip text
L.ActivateTip = [[Mimics the default effect that shows on
action buttons when an ability "procs".]]
L.AlertTip = [[Pulses the finished cooldown icon
at the center of the screen.]]
L.PulseTip = [[Pulses the cooldown icon.]]
--slash command text
L.SetEngine_Classic = 'Switched timers to the Classic engine. This setting will take effect the next time you log in.'
L.SetEngine_Animation = 'Switched timers to the Animation engine. This setting will take effect the next time you log in.'
L.UnknownEngineName = "Unknown timer engine '%s'"
L.SetEngineUsage = 'Usage: /omnicc setengine '
L.Commands = 'Commands (/omnicc or /occ):'
L.Command_ShowOptionsMenu = '- config - Show the options menu'
L.Command_SetTimerEngine = '- setengine - Switches the timer update engine'
L.Command_ShowAddonVersion = '- version - Displays the current addon version'
L.UnknownCommandName = "Unknown command '%s'"PK >@ ' OmniCC/localization/localization.ru.lua--[[
OmniCC localization - Russian
--]]
if GetLocale() ~= 'ruRU' then return end
local L = OMNICC_LOCALS
--[[
if not GetLocale() == 'enUS' then
return
end
--]]
L.Updated = "Обновлено до v%s"
L.None = NONE
L.Pulse = "Импульс"
L.Shine = "Блеск"PK >f f ' OmniCC/localization/localization.tw.lua--[[
OmniCC localization - zhTW
--]]
if GetLocale() ~= 'zhTW' then return end
local L = OMNICC_LOCALS
L.Updated = "升級至 v%s"
L.None = NONE
L.Pulse = "脈衝"
L.Shine = "閃亮"
--slash command text
L.SetEngine_Classic = '切換到經典計時器的引擎。此設置將在下次登錄時生效.'
L.SetEngine_Animation = '切換到經典計時器的動畫引擎。此設置將在下次登錄時生效.'
L.UnknownEngineName = "未知的計時器引擎 '%s'"
L.SetEngineUsage = '用法: /omnicc setengine '
L.Commands = '命令 (/omnicc or /occ):'
L.Command_ShowOptionsMenu = '- config - 顯示選項菜單'
L.Command_SetTimerEngine = '- setengine - 開關計時器的更新引擎'
L.Command_ShowAddonVersion = '- version - 顯示目前插件的版本'
L.UnknownCommandName = "未知的命令 '%s'"PK >|0 OmniCC_Config/embeds.xml
PK >f嵮0 0 OmniCC_Config/LICENSECopyright (c) 2010 Jason Greer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.PK >/)ch h OmniCC_Config/localization.xml
PK >>w% % OmniCC_Config/mainPanel.lua--[[
mainPanel.lua
the main container panel for omnicc
provides ways of switching between tabs & groups
--]]
local L = OMNICC_LOCALS
local function createGroup(groupId)
if OmniCC:AddGroup(groupId) then
OmniCCOptions:SetGroupId(groupId)
end
end
StaticPopupDialogs['OmniCC_CONFIG_CREATE_GROUP'] = {
text = 'Enter Group Name',
button1 = ACCEPT,
button2 = CANCEL,
hasEditBox = 1,
maxLetters = 24,
OnAccept = function(self)
local groupId = _G[self:GetName()..'EditBox']:GetText()
if groupId ~= '' then
createGroup(groupId)
end
end,
EditBoxOnEnterPressed = function(self)
local groupId = self:GetText()
if groupId ~= '' then
createGroup(groupId)
end
self:GetParent():Hide()
end,
OnShow = function(self)
_G[self:GetName()..'EditBox']:SetFocus()
end,
OnHide = function(self)
_G[self:GetName()..'EditBox']:SetText('')
end,
timeout = 0, exclusive = 1, hideOnEscape = 1
}
--[[ utility functions of champions ]]--
local function map(t, f)
local newtbl = {}
for i, v in pairs(t) do
newtbl[i] = f(v)
end
return newtbl
end
local function sort(tbl, ...) table.sort(tbl, ...) return tbl end
--[[
OmniCC settings retrieval
--]]
local groupSets_Get = function(groupId)
return OmniCC:GetDB().groupSettings[groupId]
end
--[[
group settings selector
--]]
local function selectGroup(self)
self.owner:SetSavedValue(self.value)
end
local function deleteGroup(self, groupId)
self.owner:SetSavedValue('base')
OmniCC:RemoveGroup(groupId)
--hide the previous dropdown menus (hack)
for i = 1, UIDROPDOWNMENU_MENU_LEVEL-1 do
_G["DropDownList"..i]:Hide()
end
end
local function addGroup(self)
StaticPopup_Show('OmniCC_CONFIG_CREATE_GROUP')
end
local function groupSelector_Create(parent, size, onSetGroup)
local dd = CreateFrame('Frame', parent:GetName() .. 'GroupSelector', parent, 'UIDropDownMenuTemplate')
dd.SetSavedValue = function(self, value)
onSetGroup(parent, value)
end
dd.GetSavedValue = function(self)
return parent.selectedGroup or 'base'
end
--delete button for custom groups
local function init_levelTwo(self, level)
local info = UIDropDownMenu_CreateInfo()
info.text = DELETE
info.arg1 = UIDROPDOWNMENU_MENU_VALUE
info.func = deleteGroup
info.owner = self
info.notCheckable = true
UIDropDownMenu_AddButton(info, level)
end
local function init_levelOne(self, level)
local groups = sort(map(OmniCC:GetDB().groups, function(g) return g.id end))
--base group
local info = UIDropDownMenu_CreateInfo()
info.text = L['Group_base']
info.value = 'base'
info.func = selectGroup
info.owner = self
info.hasArrow = false
UIDropDownMenu_AddButton(info, level)
--custom groups (add delete button)
for i, g in ipairs(groups) do
local info = UIDropDownMenu_CreateInfo()
info.text = L['Group_' .. g] or g
info.value = g
info.func = selectGroup
info.owner = self
info.hasArrow = true
UIDropDownMenu_AddButton(info, level)
end
--new group button
local info = UIDropDownMenu_CreateInfo()
info.text = L.AddGroup
info.func = addGroup
info.owner = self
info.notCheckable = true
UIDropDownMenu_AddButton(info, level)
end
UIDropDownMenu_Initialize(dd, function(self, level)
level = level or 1
if level == 1 then
init_levelOne(self, level)
else
init_levelTwo(self, level)
end
end)
UIDropDownMenu_SetWidth(dd, 120)
UIDropDownMenu_SetSelectedValue(dd, dd:GetSavedValue())
dd:SetPoint('TOPRIGHT', 4, -8)
return dd
end
--[[
title portion of the main frame
--]]
local function title_Create(parent, text, subtext, icon)
local title = parent:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
title:SetPoint('TOPLEFT', 16, -16)
if icon then
title:SetFormattedText('|T%s:%d|t %s', icon, 32, name)
else
title:SetText(text)
end
if subtext then
local subTitle = parent:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall')
subTitle:SetPoint('BOTTOMLEFT', title, 'BOTTOMRIGHT', 4, 0)
subTitle:SetTextColor(0.8, 0.8, 0.8)
subTitle:SetText(subtext)
end
end
--[[
main frame tabs
--]]
local tab_Create, tab_OnClick
do
tab_Create = function(parent, id, name, panel)
parent.tabs = parent.tabs or {}
local t = CreateFrame('Button', parent:GetName() .. 'Tab' .. (#parent.tabs + 1), parent, 'OptionsFrameTabButtonTemplate')
table.insert(parent.tabs, t)
t.panel = panel
t.id = id
t:SetText(name)
t:SetScript('OnClick', tab_OnClick)
--this is the texture that makes up the top border around the main panel area
--its here because each tab needs one to create the illusion of the tab popping out in front of the player
t.sl = t:CreateTexture(nil, 'BACKGROUND')
t.sl:SetTexture([[Interface\OptionsFrame\UI-OptionsFrame-Spacer]])
t.sl:SetPoint('BOTTOMRIGHT', t, 'BOTTOMLEFT', 11, -6)
t.sl:SetPoint('BOTTOMLEFT', parent, 'TOPLEFT', 16, -(34 + t:GetHeight() + 7))
t.sr = t:CreateTexture(nil, 'BACKGROUND')
t.sr:SetTexture([[Interface\OptionsFrame\UI-OptionsFrame-Spacer]])
t.sr:SetPoint('BOTTOMLEFT', t, 'BOTTOMRIGHT', -11, -6)
t.sr:SetPoint('BOTTOMRIGHT', parent, 'TOPRIGHT', -16, -(34 + t:GetHeight() + 11))
--place the new tab
--if its the first tab, anchor to the main frame
--if not, anchor to the right of the last tab
local numTabs = #parent.tabs
if numTabs > 1 then
t:SetPoint('TOPLEFT', parent.tabs[numTabs - 1], 'TOPRIGHT', -8, 0)
t.sl:Hide()
t.sr:Hide()
else
t:SetPoint('TOPLEFT', parent, 'TOPLEFT', 12, -34)
t.sl:Show()
t.sr:Show()
end
t:SetID(numTabs)
--adjust tab sizes and other blizzy required things
PanelTemplates_TabResize(t, 0)
PanelTemplates_SetNumTabs(parent, numTabs)
--display the first tab, if its not already displayed
PanelTemplates_SetTab(parent, 1)
--place the panel associated with the tab
parent.panelArea:Add(panel)
return t
end
tab_OnClick = function(self)
local parent = self:GetParent()
--update tab selection
PanelTemplates_Tab_OnClick(self, parent)
PanelTemplates_UpdateTabs(parent)
--hide any visible panels/tabs
for i, tab in pairs(parent.tabs) do
if tab ~= self then
tab.panel:Hide()
tab.sl:Hide()
tab.sr:Hide()
end
end
--show the top of the panel texture from our tab
self.sl:Show()
self.sr:Show()
--show selected tab's panel
self.panel:Show()
end
end
--[[
main frame content area
--]]
local panelArea_Create, panelArea_Add
do
panelArea_Create = function(parent)
local f = CreateFrame('Frame', parent:GetName() .. '_PanelArea', parent, 'OmniCC_TabPanelTemplate')
f:SetPoint('TOPLEFT', 4, -56)
f:SetPoint('BOTTOMRIGHT', -4, 4)
f.Add = panelArea_Add
parent.panelArea = f
return f
end
panelArea_Add = function(self, panel)
panel:SetParent(self)
panel:SetAllPoints(self)
if self:GetParent():GetCurrentPanel() == panel then
panel:Show()
else
panel:Hide()
end
end
end
--[[
the main frame
--]]
local optionsPanel_Create, optionsPanel_SetGroup, optionsPanel_GetCurrentTab, optionsPanel_GetTabById, optionsPanel_GetCurrentPanel
do
optionsPanel_Create = function(title, subtitle)
local f = CreateFrame('Frame', 'OmniCCOptionsPanel')
f.name = title
f.GetCurrentPanel = optionsPanel_GetCurrentPanel
title_Create(f, title, subtitle)
f.dropdown = groupSelector_Create(f, 130, optionsPanel_SetGroup)
panelArea_Create(f)
InterfaceOptions_AddCategory(f, title)
return f
end
optionsPanel_SetGroup = function(self, groupId)
self.selectedGroup = groupId or 'base'
UIDropDownMenu_SetSelectedValue(self.dropdown, groupId)
UIDropDownMenu_SetText(self.dropdown, L['Group_' .. groupId] or groupId)
--special handling for the base tab
--since we don't want the user to mess with the rules tab
if groupId == 'base' then
--if we're on the rules tab, then move to the general tab
if optionsPanel_GetCurrentTab(self).id == 'rules' then
tab_OnClick(optionsPanel_GetTabById(self, 'general'))
end
--disable the rules tab
local tab = optionsPanel_GetTabById(self, 'rules')
if tab then
PanelTemplates_DisableTab(self, tab:GetID())
end
else
--enable the rules tab
local tab = optionsPanel_GetTabById(self, 'rules')
if tab then
PanelTemplates_EnableTab(self, tab:GetID())
end
end
--force the current panel to refresh
local panel = optionsPanel_GetCurrentPanel(self)
if panel.UpdateValues then
panel:UpdateValues()
end
end
optionsPanel_GetCurrentTab = function(self)
return self.tabs[PanelTemplates_GetSelectedTab(self)]
end
optionsPanel_GetTabById = function(self, tabId)
for i, tab in pairs(self.tabs) do
if tab.id == tabId then
return tab
end
end
end
optionsPanel_GetCurrentPanel = function(self)
return self.tabs[PanelTemplates_GetSelectedTab(self)].panel
end
end
--[[ build the main options panel ]]--
do
local f = optionsPanel_Create(select(2, GetAddOnInfo('OmniCC')))
OmniCCOptions.AddTab = function(self, id, name, panel)
tab_Create(f, id, name, panel)
optionsPanel_SetGroup(f, self:GetGroupId())
end
OmniCCOptions.GetGroupSets = function(self)
return groupSets_Get(f.selectedGroup or 'base')
end
OmniCCOptions.GetGroupId = function(self)
return f.selectedGroup or 'base'
end
OmniCCOptions.SetGroupId = function(self, groupId)
optionsPanel_SetGroup(f, groupId)
end
endPK ?ҫ OmniCC_Config/OmniCC_Config.toc## Interface: 40200
## Title: OmniCC Config
## Notes: OmniCC's configuration menu
## Notes-koKR: OmniCC의 설정 메뉴
## Author: Tuller
## Dependencies: OmniCC
## LoadOnDemand: 1
embeds.xml
localization.xml
widgets.xml
mainPanel.lua
panels.xml
PK >~O~ OmniCC_Config/panels.xml
PK >xm OmniCC_Config/widgets.xml
PK >{͢# # > OmniCC_Config/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua--[[ $Id: CallbackHandler-1.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 5
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
if not CallbackHandler then return end -- No upgrade needed
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
-- Lua APIs
local tconcat = table.concat
local assert, error, loadstring = assert, error, loadstring
local setmetatable, rawset, rawget = setmetatable, rawset, rawget
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: geterrorhandler
local xpcall = xpcall
local function errorhandler(err)
return geterrorhandler()(err)
end
local function CreateDispatcher(argCount)
local code = [[
local next, xpcall, eh = ...
local method, ARGS
local function call() method(ARGS) end
local function dispatch(handlers, ...)
local index
index, method = next(handlers)
if not method then return end
local OLD_ARGS = ARGS
ARGS = ...
repeat
xpcall(call, eh)
index, method = next(handlers, index)
until not method
ARGS = OLD_ARGS
end
return dispatch
]]
local ARGS, OLD_ARGS = {}, {}
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
end
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
local dispatcher = CreateDispatcher(argCount)
rawset(self, argCount, dispatcher)
return dispatcher
end})
--------------------------------------------------------------------------
-- CallbackHandler:New
--
-- target - target object to embed public APIs in
-- RegisterName - name of the callback registration API, default "RegisterCallback"
-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused)
-- TODO: Remove this after beta has gone out
assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused")
RegisterName = RegisterName or "RegisterCallback"
UnregisterName = UnregisterName or "UnregisterCallback"
if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
UnregisterAllName = "UnregisterAllCallbacks"
end
-- we declare all objects and exported APIs inside this closure to quickly gain access
-- to e.g. function names, the "target" parameter, etc
-- Create the registry object
local events = setmetatable({}, meta)
local registry = { recurse=0, events=events }
-- registry:Fire() - fires the given event/message into the registry
function registry:Fire(eventname, ...)
if not rawget(events, eventname) or not next(events[eventname]) then return end
local oldrecurse = registry.recurse
registry.recurse = oldrecurse + 1
Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
registry.recurse = oldrecurse
if registry.insertQueue and oldrecurse==0 then
-- Something in one of our callbacks wanted to register more callbacks; they got queued
for eventname,callbacks in pairs(registry.insertQueue) do
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
for self,func in pairs(callbacks) do
events[eventname][self] = func
-- fire OnUsed callback?
if first and registry.OnUsed then
registry.OnUsed(registry, target, eventname)
first = nil
end
end
end
registry.insertQueue = nil
end
end
-- Registration of a callback, handles:
-- self["method"], leads to self["method"](self, ...)
-- self with function ref, leads to functionref(...)
-- "addonId" (instead of self) with function ref, leads to functionref(...)
-- all with an optional arg, which, if present, gets passed as first argument (after self if present)
target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
if type(eventname) ~= "string" then
error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
end
method = method or eventname
local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
if type(method) ~= "string" and type(method) ~= "function" then
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
end
local regfunc
if type(method) == "string" then
-- self["method"] calling style
if type(self) ~= "table" then
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
elseif self==target then
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
elseif type(self[method]) ~= "function" then
error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
end
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
local arg=select(1,...)
regfunc = function(...) self[method](self,arg,...) end
else
regfunc = function(...) self[method](self,...) end
end
else
-- function ref with self=object or self="addonId"
if type(self)~="table" and type(self)~="string" then
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2)
end
if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
local arg=select(1,...)
regfunc = function(...) method(arg,...) end
else
regfunc = method
end
end
if events[eventname][self] or registry.recurse<1 then
-- if registry.recurse<1 then
-- we're overwriting an existing entry, or not currently recursing. just set it.
events[eventname][self] = regfunc
-- fire OnUsed callback?
if registry.OnUsed and first then
registry.OnUsed(registry, target, eventname)
end
else
-- we're currently processing a callback in this registry, so delay the registration of this new entry!
-- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
registry.insertQueue = registry.insertQueue or setmetatable({},meta)
registry.insertQueue[eventname][self] = regfunc
end
end
-- Unregister a callback
target[UnregisterName] = function(self, eventname)
if not self or self==target then
error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
end
if type(eventname) ~= "string" then
error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
end
if rawget(events, eventname) and events[eventname][self] then
events[eventname][self] = nil
-- Fire OnUnused callback?
if registry.OnUnused and not next(events[eventname]) then
registry.OnUnused(registry, target, eventname)
end
end
if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
registry.insertQueue[eventname][self] = nil
end
end
-- OPTIONAL: Unregister all callbacks for given selfs/addonIds
if UnregisterAllName then
target[UnregisterAllName] = function(...)
if select("#",...)<1 then
error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
end
if select("#",...)==1 and ...==target then
error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
end
for i=1,select("#",...) do
local self = select(i,...)
if registry.insertQueue then
for eventname, callbacks in pairs(registry.insertQueue) do
if callbacks[self] then
callbacks[self] = nil
end
end
end
for eventname, callbacks in pairs(events) do
if callbacks[self] then
callbacks[self] = nil
-- Fire OnUnused callback?
if registry.OnUnused and not next(callbacks) then
registry.OnUnused(registry, target, eventname)
end
end
end
end
end
end
return registry
end
-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
-- try to upgrade old implicit embeds since the system is selfcontained and
-- relies on closures to work.
PK >> > OmniCC_Config/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml
PK >@u - OmniCC_Config/libs/LibSharedMedia-3.0/lib.xml
PK >d <