Add tested modules and organize Extras categories

This commit is contained in:
Dusk-92
2026-08-30 16:05:21 +02:00
parent 2c594d2506
commit 531b3feefb
9 changed files with 1141 additions and 13 deletions
+70
View File
@@ -0,0 +1,70 @@
local _G = ShaguTweaks.GetGlobalEnv()
local T = ShaguTweaks.T
local HookScript = ShaguTweaks.HookScript
local module = ShaguTweaks:register({
title = T["Metric Range"],
description = T["Displays tooltip range units in metres instead of yards."],
expansions = { ["vanilla"] = true, ["tbc"] = nil },
category = T["Tooltip & Items"],
enabled = true,
})
module.enable = function(self)
-- Avoid double processing while the old standalone addon is still enabled.
if IsAddOnLoaded("MetricRange") then return end
local function ConvertText(text)
if type(text) ~= "string" then return text end
-- Intentionally keep the original behavior: only replace the displayed
-- unit label. Do not numerically convert the range value.
text = string.gsub(text, " yards", " metres")
text = string.gsub(text, " yard", " metre")
text = string.gsub(text, " yd", " m")
return text
end
local function ConvertTooltip(tooltip)
if not tooltip or not tooltip.GetName then return end
local name = tooltip:GetName()
if not name then return end
for i = 1, 30 do
local left = _G[name .. "TextLeft" .. i]
if left then
local old = left:GetText()
if old then
local new = ConvertText(old)
if new ~= old then left:SetText(new) end
end
end
local right = _G[name .. "TextRight" .. i]
if right then
local old = right:GetText()
if old then
local new = ConvertText(old)
if new ~= old then right:SetText(new) end
end
end
end
end
local function HookTooltip(tooltip)
if not tooltip then return end
HookScript(tooltip, "OnShow", function()
ConvertTooltip(tooltip)
end)
end
HookTooltip(GameTooltip)
HookTooltip(ItemRefTooltip)
HookTooltip(ShoppingTooltip1)
HookTooltip(ShoppingTooltip2)
HookTooltip(ShoppingTooltip3)
if GameTooltip and GameTooltip:IsVisible() then ConvertTooltip(GameTooltip) end
if ItemRefTooltip and ItemRefTooltip:IsVisible() then ConvertTooltip(ItemRefTooltip) end
end