mirror of
https://github.com/TheRealFayz/SHPlates.git
synced 2026-11-16 12:30:34 +00:00
Settings window - New layout with tabs down the side, the portrait, and a resize grip (right-click the grip to reset the size) - Tabs: General, one tab for each template (Grey Tank, Grey DPS, Neon Tank, Neon DPS), Casts/Tanks/Notes, and Share - Each template tab has the Designer pinned at the top and its settings scrolling underneath - Clicking a piece in the Designer scrolls to that piece's settings and briefly highlights the section Per-template settings - Every setting is now saved per template, so tank and DPS plates can look and behave completely differently - Existing settings are copied into all four templates on first load, so nothing is lost - Old share strings still import and apply to every template Designer - Drag pieces on a sample plate: name, level, health text, spell name, cast bar, spell icon, raid icon, elite star, debuffs, class icon, mob note, threat line, aggro holder name, threat wheel, and tanked icon - Arrow buttons nudge the selected piece, and right-click puts a piece back where it started - The threat line and the aggro holder name now move separately - The sample shows the full threat line so it's easier to center - Boxes hide when their piece is turned off or has no text Size and Style - Width, height, and text size for enemy plates, friendly plates, and cast bars - Debuff icon size, font, health text alignment, aggro holder name size - Custom colors for health text, names, cast bars, and the target box - Back to Theme Sizes button Cast bars - Cast bars work without SuperWoW, read from the combat log with cast times for over 1,200 spells (table from ShaguTweaks, MIT License) - Unknown spells learn their cast time once they land - Option to hide cast bars - Neon's spell icon backing is now its own piece Debuffs - Your own debuffs are always shown first - Hide debuffs option and a debuff timers toggle Plates - Option to hide unit levels - "Show critters" is now "Hide critters", and without SuperWoW critters are learned by name - The elite star can be moved Other addons - ShaguTweaks nameplate tweaks are switched off while SHPlates runs (can be turned off on the General tab) Removed - Separate Threat line section and its setting - Short Debuffs and Debuff Tracker checkboxes (replaced by Hide debuffs) README rewritten with an Installation section and a client mod comparison table
146 lines
6.2 KiB
Lua
146 lines
6.2 KiB
Lua
-------------------------------------------------------------------------------
|
|
-- SHPlates: cast bars without SuperWoW
|
|
--
|
|
-- The 1.12 client only reports other units' casts as combat log text, e.g.
|
|
-- "Defias Pillager begins to cast Fireball." There is no GUID, so a cast
|
|
-- belongs to every plate with that name. Cast times come from the table in
|
|
-- CastTimes.lua. A spell that isn't in it gets a 2 second bar the first time
|
|
-- and its real cast time is learned when it lands (saved for all characters).
|
|
-- With SuperWoW none of this runs: UNIT_CASTEVENT is exact.
|
|
-------------------------------------------------------------------------------
|
|
local C = SHPlates.Compat
|
|
local Data = SHPlates.Data
|
|
local CastLog = {}
|
|
SHPlates.CastLog = CastLog
|
|
|
|
local DEFAULT_MS = 2000
|
|
local byName = {} -- caster name -> cast (same shape as Data.casts entries)
|
|
|
|
local function Pattern(gs)
|
|
if not gs then return nil end
|
|
local p = string.gsub(gs, "([%(%)%.%%%+%-%*%?%[%]%^%$])", "%%%1")
|
|
p = string.gsub(p, "%%%%s", "(.+)")
|
|
p = string.gsub(p, "%%%%d", "(%%d+)")
|
|
return "^" .. p -- no end anchor: hits can end with " (12 resisted)"
|
|
end
|
|
|
|
-- English fallbacks in case a global string is missing
|
|
local P = {
|
|
start = Pattern(SPELLCASTOTHERSTART or "%s begins to cast %s."),
|
|
perform = Pattern(SPELLPERFORMOTHERSTART or "%s begins to perform %s."),
|
|
hit = Pattern(SPELLLOGOTHEROTHER or "%s's %s hits %s for %d."),
|
|
crit = Pattern(SPELLLOGCRITOTHEROTHER or "%s's %s crits %s for %d."),
|
|
hitYou = Pattern(SPELLLOGOTHERSELF or "%s's %s hits you for %d."),
|
|
critYou = Pattern(SPELLLOGCRITOTHERSELF or "%s's %s crits you for %d."),
|
|
castGo = Pattern(SPELLCASTGOOTHER or "%s casts %s."),
|
|
castOn = Pattern(SPELLCASTGOOTHERTARGETTED or "%s casts %s on %s."),
|
|
performGo = Pattern(SPELLPERFORMGOOTHER or "%s performs %s."),
|
|
performOn = Pattern(SPELLPERFORMGOOTHERTARGETTED or "%s performs %s on %s."),
|
|
resist = Pattern(SPELLRESISTOTHEROTHER or "%s's %s was resisted by %s."),
|
|
resistYou = Pattern(SPELLRESISTOTHERSELF or "%s's %s was resisted."),
|
|
youKick = Pattern(SPELLINTERRUPTSELFOTHER or "You interrupt %s's %s."),
|
|
otherKick = Pattern(SPELLINTERRUPTOTHEROTHER or "%s interrupts %s's %s."),
|
|
afflicted = Pattern(AURAADDEDOTHERHARMFUL or "%s is afflicted by %s."),
|
|
dies = Pattern(UNITDIESOTHER or "%s dies."),
|
|
slain = Pattern(PARTYKILLOTHER or "%s is slain by %s!"),
|
|
}
|
|
|
|
local function Learned()
|
|
if type(SHPlatesLearned) ~= "table" then SHPlatesLearned = {} end
|
|
if type(SHPlatesLearned.castTimes) ~= "table" then SHPlatesLearned.castTimes = {} end
|
|
return SHPlatesLearned.castTimes
|
|
end
|
|
|
|
local function Changed(name)
|
|
if SHPlates.OnCastChangedByName then SHPlates.OnCastChangedByName(name) end
|
|
end
|
|
|
|
local function Start(caster, spell)
|
|
local info = SHPlates.CastTimes[spell]
|
|
local ms = (info and info.t) or Learned()[spell]
|
|
local cast = {
|
|
spell = spell,
|
|
icon = info and info.icon and ("Interface\\Icons\\" .. info.icon) or "Interface\\Icons\\INV_Misc_QuestionMark",
|
|
start = GetTime(),
|
|
guessed = not ms,
|
|
}
|
|
cast.finish = cast.start + (ms or DEFAULT_MS) / 1000
|
|
byName[caster] = cast
|
|
Changed(caster)
|
|
end
|
|
|
|
-- landed: the spell finished, so a guessed cast time can be learned
|
|
local function Stop(caster, spell, landed)
|
|
local cast = caster and byName[caster]
|
|
if not cast or (spell and cast.spell ~= spell) then return end
|
|
if landed and cast.guessed then
|
|
local took = (GetTime() - cast.start) * 1000
|
|
if took >= 300 and took <= 10000 then Learned()[cast.spell] = math.floor(took / 100 + .5) * 100 end
|
|
end
|
|
byName[caster] = nil
|
|
Changed(caster)
|
|
end
|
|
|
|
function CastLog.Get(name)
|
|
local cast = name and byName[name]
|
|
if cast and GetTime() > cast.finish + .2 then byName[name] = nil; return nil end
|
|
return cast
|
|
end
|
|
|
|
local function M(msg, pattern) return string.find(msg, pattern) end
|
|
|
|
local function Parse(msg)
|
|
if not msg then return end
|
|
local _, a, b, c
|
|
_, _, a, b = M(msg, P.start); if a then Start(a, b); return end
|
|
_, _, a, b = M(msg, P.perform); if a then Start(a, b); return end
|
|
_, _, a, b = M(msg, P.hit); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.crit); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.hitYou); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.critYou); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.castOn); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.castGo); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.performOn); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.performGo); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.resist); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.resistYou); if a then Stop(a, b, true); return end
|
|
_, _, a, b = M(msg, P.youKick); if a then Stop(a, b); return end
|
|
_, _, c, a, b = M(msg, P.otherKick); if a then Stop(a, b); return end
|
|
-- stunned, silenced or feared by something that breaks casts
|
|
_, _, a, b = M(msg, P.afflicted)
|
|
if a then
|
|
if SHPlates.CastInterrupts[b] then Stop(a) end
|
|
return
|
|
end
|
|
_, _, a = M(msg, P.dies); if a then Stop(a); return end
|
|
_, _, a = M(msg, P.slain); if a then Stop(a); return end
|
|
end
|
|
|
|
local EVENTS = {
|
|
"CHAT_MSG_SPELL_CREATURE_VS_SELF_DAMAGE", "CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE",
|
|
"CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE", "CHAT_MSG_SPELL_CREATURE_VS_SELF_BUFF",
|
|
"CHAT_MSG_SPELL_CREATURE_VS_PARTY_BUFF", "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF",
|
|
"CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE", "CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF",
|
|
"CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE", "CHAT_MSG_SPELL_FRIENDLYPLAYER_BUFF",
|
|
"CHAT_MSG_SPELL_PARTY_DAMAGE", "CHAT_MSG_SPELL_PARTY_BUFF",
|
|
"CHAT_MSG_SPELL_SELF_DAMAGE", "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE",
|
|
"CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE", "CHAT_MSG_COMBAT_HOSTILE_DEATH",
|
|
}
|
|
|
|
local frame = CreateFrame("Frame")
|
|
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
|
frame:SetScript("OnEvent", function()
|
|
if event == "PLAYER_ENTERING_WORLD" then
|
|
for k in pairs(byName) do byName[k] = nil end
|
|
if not C.HasSuperWoW and not this.listening then
|
|
this.listening = true
|
|
for i = 1, table.getn(EVENTS) do this:RegisterEvent(EVENTS[i]) end
|
|
end
|
|
return
|
|
end
|
|
if SHPlates.disabled then return end
|
|
Parse(arg1)
|
|
end)
|
|
|
|
CastLog.Parse = Parse -- for testing
|