mirror of
https://github.com/TheRealFayz/SHPlates.git
synced 2026-11-16 12:30:34 +00:00
First public upload of SHPlates, a nameplate addon for OctoWoW. Includes: - Server threat with Tug-o'-Threat line, threat wheel and tanked icon - Cast bars, with uninterruptible casts learned per mob - Debuff timers (Nampower, with a built-in fallback table) - Segmented combo point bar - Raid marks by keybind, including solo marks - Theme and Tank/DPS mode saved per talent build - Visibility filters for friendly, neutral, critter and non-elite plates - Class, tapped and stunned health colors, plus font options - Export/import of your whole setup as a string - Turns off pfUI nameplates while active Works best with SuperWoW and Nampower. The Neon theme still needs a lot of testing.
75 lines
2.4 KiB
Lua
75 lines
2.4 KiB
Lua
-------------------------------------------------------------------------------
|
|
-- SHPlates: Utility (table helpers and number formatting)
|
|
-------------------------------------------------------------------------------
|
|
|
|
local function copytable(original)
|
|
local duplicate = {}
|
|
for key, value in pairs(original) do
|
|
if type(value) == "table" then duplicate[key] = copytable(value)
|
|
else duplicate[key] = value end
|
|
end
|
|
return duplicate
|
|
end
|
|
|
|
-- Returns a new table: master's structure, overridden by mate's values
|
|
local function mergetable(master, mate)
|
|
local merged = {}
|
|
local matedata
|
|
for key, value in pairs(master) do
|
|
matedata = mate[key]
|
|
if type(value) == "table" then
|
|
if type(matedata) == "table" then merged[key] = mergetable(value, matedata)
|
|
else merged[key] = copytable(value) end
|
|
else
|
|
if matedata == nil then merged[key] = value
|
|
else merged[key] = matedata end
|
|
end
|
|
end
|
|
-- keep keys that only exist in the mate (e.g. user list entries)
|
|
for key, value in pairs(mate) do
|
|
if merged[key] == nil then
|
|
if type(value) == "table" then merged[key] = copytable(value) else merged[key] = value end
|
|
end
|
|
end
|
|
return merged
|
|
end
|
|
|
|
-- Writes saved values into an existing (live) table in place, so local
|
|
-- references held by themes stay valid. Lists (tables without a matching
|
|
-- default structure) are replaced wholesale.
|
|
local function applysaved(live, saved)
|
|
if type(live) ~= "table" or type(saved) ~= "table" then return live end
|
|
for key, value in pairs(saved) do
|
|
local current = live[key]
|
|
if type(value) == "table" then
|
|
if type(current) == "table" and key ~= "WidgetDebuffList" then
|
|
applysaved(current, value)
|
|
else
|
|
live[key] = copytable(value)
|
|
end
|
|
elseif type(current) == type(value) or current == nil then
|
|
live[key] = value
|
|
end
|
|
end
|
|
return live
|
|
end
|
|
|
|
local function valueToString(value)
|
|
if value ~= nil then
|
|
if value >= 1000000 then return string.format("%.1fm", value / 1000000)
|
|
elseif value >= 1000 then return string.format("%.1fk", value / 1000)
|
|
else return value end
|
|
end
|
|
end
|
|
|
|
SHPlatesUtility.abbrevNumber = valueToString
|
|
SHPlatesUtility.copyTable = copytable
|
|
SHPlatesUtility.mergeTable = mergetable
|
|
SHPlatesUtility.applySaved = applysaved
|
|
|
|
-- Threat helper: same contract as Tidy Plates' GetRelativeThreat, but takes
|
|
-- the plate's unit table (vanilla has no threat API). See Data.lua.
|
|
SHPlatesUtility.GetRelativeThreat = function(unit)
|
|
return SHPlates.Data.GetRelativeThreat(unit)
|
|
end
|