shadowsight timer added

This commit is contained in:
Sumsebrum 2021-06-15 09:05:32 +02:00
parent 7b0bf921c4
commit 06884ae043
3 changed files with 166 additions and 68 deletions

View File

@ -47,6 +47,7 @@ function Announcements:Initialize()
self:RegisterMessage("UNIT_HEALTH")
self:RegisterMessage("TRINKET_USED")
self:RegisterMessage("TRINKET_READY")
self:RegisterMessage("SHADOWSIGHT")
end
function Announcements:Reset()
@ -148,6 +149,10 @@ function Announcements:CheckDrink(unit, aura)
end
end
function Announcements:SHADOWSIGHT(msg)
self:Send(msg, 2)
end
function Announcements:Send(msg, throttle, color)
if (throttle and throttle > 0) then
if (not self.throttled[msg]) then

View File

@ -15,11 +15,7 @@ function ACDFrame:OnEvent(event, ...)
end
function ACDFrame:Initialize()
if ACDFrame.locales[GetLocale()] then
self.locale = ACDFrame.locales[GetLocale()]
else
self.locale = ACDFrame.locales["default"]
end
self.locale = Gladdy:GetArenaTimer()
self.hidden = false
self.countdown = -1
self.texturePath = "Interface\\AddOns\\Gladdy\\Images\\Countdown\\";
@ -178,69 +174,7 @@ function ACDFrame:GetOptions()
min = 64,
max = 512,
step = 16,
width = "full",
}),
}
end
ACDFrame.locales = {
["default"] = {
[61] = "One minute until the Arena battle begins!",
[31] = "Thirty seconds until the Arena battle begins!",
[16] = "Fifteen seconds until the Arena battle begins!",
[0] = "The Arena battle has begun!",
},
["esES"] = {
[61] = "¡Un minuto hasta que dé comienzo la batalla en arena!",
[31] = "¡Treinta segundos hasta que comience la batalla en arena!",
[16] = "¡Quince segundos hasta que comience la batalla en arena!",
[0] = "¡La batalla en arena ha comenzado!",
},
["ptBR"] = {
[61] = "Um minuto até a batalha na Arena começar!",
[31] = "Trinta segundos até a batalha na Arena começar!",
[16] = "Quinze segundos até a batalha na Arena começar!",
[0] = "A batalha na Arena começou!",
},
["deDE"] = {
[61] = "Noch eine Minute bis der Arenakampf beginnt!",
[31] = "Noch dreißig Sekunden bis der Arenakampf beginnt!",
[16] = "Noch fünfzehn Sekunden bis der Arenakampf beginnt!",
[0] = "Der Arenakampf hat begonnen!",
},
["frFR"] = {
[60] = "Le combat d'arène commence dans une minute\194\160!",
[30] = "Le combat d'arène commence dans trente secondes\194\160!",
[15] = "Le combat d'arène commence dans quinze secondes\194\160!",
[0] = "Le combat d'arène commence\194\160!",
},
["ruRU"] = {
[61] = "Одна минута до начала боя на арене!",
[31] = "Тридцать секунд до начала боя на арене!",
[16] = "До начала боя на арене осталось 15 секунд.",
[0] = "Бой начался!",
},
["itIT"] = { -- TODO
-- Beta has no itIT version available?
},
["koKR"] = {
[61] = "투기장 전투 시작 1분 전입니다!",
[31] = "투기장 전투 시작 30초 전입니다!",
[16] = "투기장 전투 시작 15초 전입니다!",
[0] = "투기장 전투가 시작되었습니다!",
},
["zhCN"] = {
[61] = "竞技场战斗将在一分钟后开始!",
[31] = "竞技场战斗将在三十秒后开始!",
[16] = "竞技场战斗将在十五秒后开始!",
[0] = "竞技场的战斗开始了!",
},
["zhTW"] = {
[61] = "1分鐘後競技場戰鬥開始!",
[31] = "30秒後競技場戰鬥開始!",
[16] = "15秒後競技場戰鬥開始!",
[0] = "競技場戰鬥開始了!",
},
}
ACDFrame.locales["esMX"] = ACDFrame.locales["esES"]
ACDFrame.locales["ptPT"] = ACDFrame.locales["ptBR"]

View File

@ -0,0 +1,159 @@
local floor, str_len, tostring, str_sub, str_find, pairs = math.floor, string.len, tostring, string.sub, string.find, pairs
local CreateFrame = CreateFrame
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local ShadowsightTimer = Gladdy:NewModule("Shadowsight Timer", nil, {
shadowsightTimerEnabled = true,
shadowsightTimerScale = 1,
shadowsightTimerRelPoint1 = "CENTER",
shadowsightTimerRelPoint2 = "CENTER",
shadowsightTimerX = 0,
shadowsightTimerY = 0,
})
function ShadowsightTimer:OnEvent(event, ...)
self[event](self, ...)
end
function ShadowsightTimer:Initialize()
self.locale = Gladdy:GetArenaTimer()
self:RegisterMessage("JOINED_ARENA")
self:CreateTimerFrame()
end
function ShadowsightTimer:JOINED_ARENA()
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL")
self:SetScript("OnEvent", ShadowsightTimer.OnEvent)
self.timerFrame.font:SetText("1:30")
self.timerFrame.font:SetTextColor(1, 0.8, 0)
self.timerFrame:Show()
end
function ShadowsightTimer:CHAT_MSG_BG_SYSTEM_NEUTRAL(msg)
for k,v in pairs(self.locale) do
if str_find(msg, v) then
if k == 0 then
self:Start()
end
end
end
end
function ShadowsightTimer:Test()
if Gladdy.db.shadowsightTimerEnabled then
self.timerFrame:Show()
self:Start()
end
end
function ShadowsightTimer:Reset()
self.timerFrame:Hide()
self.timerFrame:SetScript("OnUpdate", nil)
self.timerFrame.font:SetTextColor(1, 0.8, 0)
end
function ShadowsightTimer:CreateTimerFrame()
self.timerFrame = CreateFrame("Frame", nil, UIParent, BackdropTemplateMixin and "BackdropTemplate")
self.timerFrame:SetPoint(Gladdy.db.shadowsightTimerRelPoint1, nil, Gladdy.db.shadowsightTimerRelPoint, Gladdy.db.shadowsightTimerX, Gladdy.db.shadowsightTimerY)
local backdrop = {
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "",
tile = true, tileSize = 16, edgeSize = 10,
insets = {left = 0, right = 0, top = 0, bottom = 0}
}
self.timerFrame:SetBackdrop(backdrop)
self.timerFrame:SetBackdropColor(0,0,0,0.8)
self.timerFrame:SetHeight(17)
self.timerFrame:SetWidth(35)
self.timerFrame:SetMovable(true)
self.timerFrame:EnableMouse(true)
self.timerFrame.texture = self.timerFrame:CreateTexture(nil,"OVERLAY")
self.timerFrame.texture:SetWidth(16)
self.timerFrame.texture:SetHeight(16)
self.timerFrame.texture:SetTexture("Interface\\Icons\\Spell_Shadow_EvilEye")
self.timerFrame.texture:SetTexCoord(0.125,0.875,0.125,0.875)
self.timerFrame.texture:SetPoint("RIGHT", self.timerFrame, "LEFT")
self.timerFrame.font = self.timerFrame:CreateFontString(nil,"OVERLAY","GameFontNormal")
self.timerFrame.font:SetPoint("LEFT", 5, 0)
self.timerFrame.font:SetJustifyH("LEFT")
self.timerFrame.font:SetTextColor(1, 0.8, 0)
self.timerFrame:SetScript("OnMouseDown",function(self) self:StartMoving() end)
self.timerFrame:SetScript("OnMouseUp",function(self)
self:StopMovingOrSizing()
Gladdy.db.shadowsightTimerRelPoint1,_,Gladdy.db.shadowsightTimerRelPoint2,Gladdy.db.shadowsightTimerX,Gladdy.db.shadowsightTimerY = self:GetPoint()
end)
self.timerFrame:SetScale(Gladdy.db.shadowsightTimerScale)
self.timerFrame:Hide()
end
function ShadowsightTimer:UpdateFrame()
if Gladdy.db.shadowsightTimerEnabled then
self.timerFrame:SetScale(Gladdy.db.shadowsightTimerScale)
self.timerFrame:ClearAllPoints()
self.timerFrame:SetPoint(Gladdy.db.shadowsightTimerRelPoint1, nil, Gladdy.db.shadowsightTimerRelPoint2, Gladdy.db.shadowsightTimerX, Gladdy.db.shadowsightTimerY)
self.timerFrame:Show()
else
self.timerFrame:SetScale(Gladdy.db.shadowsightTimerScale)
self.timerFrame:ClearAllPoints()
self.timerFrame:SetPoint(Gladdy.db.shadowsightTimerRelPoint1, nil, Gladdy.db.shadowsightTimerRelPoint2, Gladdy.db.shadowsightTimerX, Gladdy.db.shadowsightTimerY)
self.timerFrame:Hide()
end
end
function ShadowsightTimer:Start()
self.timerFrame.endTime = 92
self.timerFrame.timeSinceLastUpdate = 0
self.timerFrame:SetScript("OnUpdate", ShadowsightTimer.OnUpdate)
end
function ShadowsightTimer.OnUpdate(self, elapsed)
self.timeSinceLastUpdate = self.timeSinceLastUpdate + elapsed;
self.endTime = self.endTime - elapsed
if (self.timeSinceLastUpdate > 0.1) then
self.font:SetFormattedText(floor(self.endTime / 60) .. ":" .. "%02d", self.endTime - floor(self.endTime / 60) * 60)
self.timeSinceLastUpdate = 0;
if floor(self.endTime) == 15 then
Gladdy:SendMessage("SHADOWSIGHT", L["Shadowsight up in %ds"]:format(15))
end
end
if self.endTime <= 0 then
Gladdy:SendMessage("SHADOWSIGHT", L["Shadowsight up!"])
self:SetScript("OnUpdate", nil)
self.font:SetText("0:00")
self.font:SetTextColor(0, 1, 0)
end
end
function ShadowsightTimer:GetOptions()
return {
headerArenaCountdown = {
type = "header",
name = L["Shadowsight Timer"],
order = 2,
},
shadowsightTimerEnabled = Gladdy:option({
type = "toggle",
name = L["Enabled"],
--desc = L["Turns countdown before the start of an arena match on/off."],
order = 3,
width = "full",
}),
shadowsightTimerScale = Gladdy:option({
type = "range",
name = L["Scale"],
order = 4,
min = 0.1,
max = 5,
step = 0.1,
width = "full",
}),
}
end