From 65b20962229263d67d7bac0445c78898b8fed5b0 Mon Sep 17 00:00:00 2001 From: Pascal Faust Date: Sun, 22 Feb 2026 18:28:29 +0100 Subject: [PATCH] add: movement tracker module --- Core.lua | 5 +- DX_Tweaks.toc | 3 +- modules/movementtracker/MovementTracker.lua | 92 +++++++++++++++++++ modules/talentbackground/TalentBackground.lua | 5 +- 4 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 modules/movementtracker/MovementTracker.lua diff --git a/Core.lua b/Core.lua index eab19d5..4063568 100644 --- a/Core.lua +++ b/Core.lua @@ -1,10 +1,11 @@ local addonName, DX = ... DX.Modules = {} -function DX:AddModule(name, func) +function DX:AddModule(name, desc, func) DX.Modules[name] = { Init = func, - Enabled = true + Enabled = true, + Description = desc } end diff --git a/DX_Tweaks.toc b/DX_Tweaks.toc index 1237062..2d78140 100644 --- a/DX_Tweaks.toc +++ b/DX_Tweaks.toc @@ -28,4 +28,5 @@ Media.lua Core.lua # Modules -modules\talentbackground\TalentBackground.lua \ No newline at end of file +modules\talentbackground\TalentBackground.lua +modules\movementtracker\MovementTracker.lua \ No newline at end of file diff --git a/modules/movementtracker/MovementTracker.lua b/modules/movementtracker/MovementTracker.lua new file mode 100644 index 0000000..792362a --- /dev/null +++ b/modules/movementtracker/MovementTracker.lua @@ -0,0 +1,92 @@ +local addonName, DX = ... + +local LSM = LibStub("LibSharedMedia-3.0") + +local moduleName = "MovementTracker" +local moduleDesc = "Tracks different movement cooldowns like Blink, Shimmer or Shift" +local moduleTicker + +local movementCooldowns = { + Blink = 1953, + Shimmer = 212653, + Shift = 123 +} + +local movementConfig = { + [movementCooldowns.Blink] = { + text = "No Blink: " + }, + [movementCooldowns.Shimmer] = { + text = "No Shimmer: " + }, + [movementCooldowns.Shift] = { + text = "No Shift: " + } +} + +local function LoadMovementTracker() + local eventFrame = CreateFrame("Frame") + + -- Create the frame + local trackerFrame = CreateFrame("Frame", "DX_MovementTracker", UIParent) + trackerFrame:SetSize(400, 50) + trackerFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 18) + trackerFrame:SetFrameStrata("LOW") + trackerFrame:Show() + + local trackerText = trackerFrame:CreateFontString(nil, "OVERLAY") + local trackerFont = LSM:Fetch("font", "DX Narrow") + trackerText:SetFont(trackerFont, 20, "OUTLINE") + trackerText:SetPoint("CENTER") + trackerText:SetJustifyH("CENTER") + trackerText:SetTextColor(1, 1, 1, 1) + + -- Returns the spellId of the learned movement cooldown + local function getRelevantSpellId() + if C_SpellBook.IsSpellKnown(movementCooldowns.Shimmer) then + return movementCooldowns.Shimmer + elseif C_SpellBook.IsSpellKnown(movementCooldowns.Blink) then + return movementCooldowns.Blink + elseif C_SpellBook.IsSpellKnown(movementCooldowns.Shift) then + return movementCooldowns.Shift + else + -- No spell known + return -1 + end + end + + -- Applies the cooldown to the TextFrame and hide/shows it accordingly + local function applyCooldownText() + local spellId = getRelevantSpellId() + local config = movementConfig[spellId] + local durationObject = C_Spell.GetSpellCooldownDuration(spellId) + local cooldown = durationObject:GetRemainingDuration(1) + + -- Ignore spell if only on GCD or not on cooldown + if (C_Spell.GetSpellCooldown(spellId).isOnGCD ~= false) or (not cooldown) or (cooldown == 0) then + trackerFrame:Hide() + if moduleTicker then + moduleTicker:Cancel() + end + return + end + + trackerFrame:Show() + trackerText:SetText(string.format("%s%.1f", config.text, cooldown)) + end + + function eventFrame:SPELL_UPDATE_COOLDOWN() + if getRelevantSpellId() == -1 then + return + end + if moduleTicker then + moduleTicker:Cancel() + end + moduleTicker = C_Timer.NewTicker(0.1, applyCooldownText) + end + + eventFrame:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end) + eventFrame:RegisterEvent("SPELL_UPDATE_COOLDOWN") +end + +DX:AddModule(moduleName, moduleDesc, LoadMovementTracker) \ No newline at end of file diff --git a/modules/talentbackground/TalentBackground.lua b/modules/talentbackground/TalentBackground.lua index fe82374..a7ba721 100644 --- a/modules/talentbackground/TalentBackground.lua +++ b/modules/talentbackground/TalentBackground.lua @@ -2,6 +2,9 @@ local addonName, DX = ... local LSM = LibStub("LibSharedMedia-3.0") +local moduleName = "TalentBackground" +local moduleDesc = "Changes the background of the TalentFrame" + local function LoadTalentBackground() local eventFrame = CreateFrame("Frame") @@ -48,4 +51,4 @@ local function LoadTalentBackground() end end -DX:AddModule("TalentBackground", LoadTalentBackground) \ No newline at end of file +DX:AddModule(moduleName, moduleDesc, LoadTalentBackground) \ No newline at end of file