Skip to content

Commit

Permalink
Update RaidCD.lua
Browse files Browse the repository at this point in the history
L_COOLDOWNS_COMBATRESS,L_COOLDOWNS_NEXTTIME Need to translate.
  • Loading branch information
leg883 committed May 31, 2015
1 parent e6b90e3 commit ece5324
Showing 1 changed file with 148 additions and 36 deletions.
184 changes: 148 additions & 36 deletions ShestakUI/Modules/Cooldowns/RaidCD.lua
@@ -1,8 +1,8 @@
local T, C, L, _ = unpack(select(2, ...))
local T, C, L, _ = unpack(select(2, ...))
if C.raidcooldown.enable ~= true then return end

----------------------------------------------------------------------------------------
-- Raid cooldowns(alRaidCD by Allez)
-- Raid cooldowns(alRaidCD by Allez, msylgj0@NGACN)
----------------------------------------------------------------------------------------
local show = {
raid = C.raidcooldown.show_inraid,
Expand All @@ -14,8 +14,12 @@ local filter = COMBATLOG_OBJECT_AFFILIATION_RAID + COMBATLOG_OBJECT_AFFILIATION_
local band = bit.band
local sformat = string.format
local floor = math.floor
local currentNumResses = 0
local charges = nil
local inBossCombat = nil
local timer = 0
local inEncounter
local Ressesbars = {}
local bars = {}

local RaidCDAnchor = CreateFrame("Frame", "RaidCDAnchor", UIParent)
Expand Down Expand Up @@ -64,15 +68,38 @@ end
local StopTimer = function(bar)
bar:SetScript("OnUpdate", nil)
bar:Hide()
tremove(bars, bar.id)
if bar.isResses then
tremove(Ressesbars, bar.id)
else
tremove(bars, bar.id)
end
UpdatePositions()
end

local UpdateCharges = function(bar)
local curCharges, maxCharges, start, duration = GetSpellCharges(20484)
if curCharges == maxCharges then
bar.startTime = 0
bar.endTime = GetTime()
else
bar.startTime = start
bar.endTime = start + duration
end
if curCharges ~= currentNumResses then
currentNumResses = curCharges
bar.left:SetText(bar.name.." : "..currentNumResses)
end
end

local BarUpdate = function(self, elapsed)
local curTime = GetTime()
if self.endTime < curTime then
StopTimer(self)
return
if self.isResses then
UpdateCharges(self)
else
StopTimer(self)
return
end
end
self:SetValue(100 - (curTime - self.startTime) / (self.endTime - self.startTime) * 100)
self.right:SetText(FormatTime(self.endTime - curTime))
Expand All @@ -93,7 +120,11 @@ end

local OnMouseDown = function(self, button)
if button == "LeftButton" then
SendChatMessage(sformat(L_COOLDOWNS.."%s - %s: %s", self.name, GetSpellLink(self.spellId), self.right:GetText()), T.CheckChat())
if self.isResses then
SendChatMessage(sformat(L_COOLDOWNS_COMBATRESS.."%d, "..L_COOLDOWNS_NEXTTIME.."%s.", currentNumResses, self.right:GetText()), T.CheckChat)
else
SendChatMessage(sformat(L_COOLDOWNS.."%s - %s: %s", self.name, GetSpellLink(self.spellId), self.right:GetText()), T.CheckChat())
end
elseif button == "RightButton" then
StopTimer(self)
end
Expand Down Expand Up @@ -136,59 +167,138 @@ end

local StartTimer = function(name, spellId)
local spell, _, icon = GetSpellInfo(spellId)
if charges and spellId == 20484 then
--团队首领战中战复技能计时特殊处理
for _, v in pairs(Ressesbars) do
UpdateCharges(v)
return
end
end
for _, v in pairs(bars) do
if v.name == name and v.spell == spell then
return
--发现重复计时事件时重置计时条,适应战复以外充能技能
StopTimer(v)
end
end
local bar = CreateBar()
bar.endTime = GetTime() + T.raid_spells[spellId]
bar.startTime = GetTime()
bar.left:SetText(format("%s - %s", name:gsub("%-[^|]+", ""), spell))
bar.name = name
bar.right:SetText(FormatTime(T.raid_spells[spellId]))
if C.raidcooldown.show_icon == true then
bar.icon:SetNormalTexture(icon)
bar.icon:GetNormalTexture():SetTexCoord(0.1, 0.9, 0.1, 0.9)
end
bar.spell = spell
bar.spellId = spellId
bar:Show()
local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[select(2, UnitClass(name))]
if color then
bar:SetStatusBarColor(color.r, color.g, color.b)
bar.bg:SetVertexColor(color.r, color.g, color.b, 0.2)
if charges and spellId == 20484 then
--初始化战复技能计时条
local curCharges, _, _, duration = GetSpellCharges(20484)
currentNumResses = curCharges
bar.endTime = GetTime() + duration
bar.startTime = GetTime()
bar.left:SetText(name.." : "..curCharges)
bar.name = name
bar.right:SetText(FormatTime(duration))
if C.raidcooldown.show_icon == true then
bar.icon:SetNormalTexture(icon)
bar.icon:GetNormalTexture():SetTexCoord(0.1, 0.9, 0.1, 0.9)
end
bar.spell = spell
bar.spellId = spellId
bar:Show()
if color then
bar:SetStatusBarColor(color.r, color.g, color.b)
bar.bg:SetVertexColor(color.r, color.g, color.b, 0.2)
else
bar:SetStatusBarColor(0.3, 0.7, 0.3)
bar.bg:SetVertexColor(0.3, 0.7, 0.3, 0.2)
end
bar:EnableMouse(true)
bar:SetScript("OnUpdate", BarUpdate)
bar:SetScript("OnEnter", OnEnter)
bar:SetScript("OnLeave", OnLeave)
bar:SetScript("OnMouseDown", OnMouseDown)
tinsert(Ressesbars, bar)
if C.raidcooldown.expiration == true then
table.sort(Ressesbars, sortByExpiration)
end
else
bar:SetStatusBarColor(0.3, 0.7, 0.3)
bar.bg:SetVertexColor(0.3, 0.7, 0.3, 0.2)
end
bar:EnableMouse(true)
bar:SetScript("OnUpdate", BarUpdate)
bar:SetScript("OnEnter", OnEnter)
bar:SetScript("OnLeave", OnLeave)
bar:SetScript("OnMouseDown", OnMouseDown)
tinsert(bars, bar)
if C.raidcooldown.expiration == true then
table.sort(bars, sortByExpiration)
bar.endTime = GetTime() + T.raid_spells[spellId]
bar.startTime = GetTime()
bar.left:SetText(format("%s - %s", name:gsub("%-[^|]+", ""), spell))
bar.name = name
bar.right:SetText(FormatTime(T.raid_spells[spellId]))
if C.raidcooldown.show_icon == true then
bar.icon:SetNormalTexture(icon)
bar.icon:GetNormalTexture():SetTexCoord(0.1, 0.9, 0.1, 0.9)
end
bar.spell = spell
bar.spellId = spellId
bar:Show()
if color then
bar:SetStatusBarColor(color.r, color.g, color.b)
bar.bg:SetVertexColor(color.r, color.g, color.b, 0.2)
else
bar:SetStatusBarColor(0.3, 0.7, 0.3)
bar.bg:SetVertexColor(0.3, 0.7, 0.3, 0.2)
end
bar:EnableMouse(true)
bar:SetScript("OnUpdate", BarUpdate)
bar:SetScript("OnEnter", OnEnter)
bar:SetScript("OnLeave", OnLeave)
bar:SetScript("OnMouseDown", OnMouseDown)
tinsert(bars, bar)
if C.raidcooldown.expiration == true then
table.sort(bars, sortByExpiration)
end
end
UpdatePositions()
end

local OnEvent = function(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" or event == "ZONE_CHANGED_NEW_AREA" then
if select(2, IsInInstance()) == "raid" then
self:RegisterEvent("SPELL_UPDATE_CHARGES")
else
self:UnregisterEvent("SPELL_UPDATE_CHARGES")
charges = nil
inBossCombat = nil
currentNumResses = 0
Ressesbars = {}
end
end
if event == "SPELL_UPDATE_CHARGES" then
charges = select(1, GetSpellCharges(20484))
if charges then
if not inBossCombat then
for _, v in pairs(bars) do
StopTimer(v)
end
inBossCombat = true
end
StartTimer("战斗复活", 20484)
elseif not charges and inBossCombat then
inBossCombat = nil
currentNumResses = 0
for _, v in pairs(Ressesbars) do
StopTimer(v)
end
end
end
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
local _, eventType, _, _, sourceName, sourceFlags = ...
if band(sourceFlags, filter) == 0 then return end
if eventType == "SPELL_RESURRECT" or eventType == "SPELL_CAST_SUCCESS" or eventType == "SPELL_AURA_APPLIED" then
local spellId = select(12, ...)
if sourceName then
sourceName = sourceName:gsub("-.+", "")
else
return
end
if T.raid_spells[spellId] and show[select(2, IsInInstance())] then
if (sourceName == T.name and C.raidcooldown.show_my == true) or sourceName ~= T.name then
StartTimer(sourceName, spellId)
end
end
end
elseif event == "ZONE_CHANGED_NEW_AREA" and select(2, IsInInstance()) == "arena" or not IsInGroup() then
for k, v in pairs(bars) do
v.endTime = 0
for _, v in pairs(Ressesbars) do
StopTimer(v)
end
for _, v in pairs(bars) do
StopTimer(v)
end
elseif event == "ENCOUNTER_END" and IsInRaid() then
for k, v in pairs(bars) do
Expand All @@ -199,14 +309,16 @@ end

local addon = CreateFrame("Frame")
addon:SetScript("OnEvent", OnEvent)
addon:RegisterEvent("PLAYER_ENTERING_WORLD")
addon:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
addon:RegisterEvent("ZONE_CHANGED_NEW_AREA")
addon:RegisterEvent("ENCOUNTER_END")

SlashCmdList.RaidCD = function()
StartTimer(UnitName('player'), 740)
StartTimer(UnitName("player"), 20484) -- Rebirth
StartTimer(UnitName("player"), 20707) -- Soulstone
StartTimer(UnitName("player"), 108280) -- Healing Tide Totem
end
SLASH_RaidCD1 = "/raidcd"
SLASH_RaidCD2 = "/кфшвсв"
SLASH_RaidCD2 = "/кфшвсв"

0 comments on commit ece5324

Please sign in to comment.