--[[-------------------------------------------------------------------------- ManiaxNamePlates - the pieces this fork supplies for itself. Everything shared lives in !Maniax335Compat instead: Mixin, the frame pools, GenerateClosure, nop, OnEventToMethod, UseParentLevel, EventRegistry, C_NamePlateManager, C_CVar, PixelUtil, AuraUtil, UnitIsPet, RunNextFrame. Those are globals other add-ons in the bundle also define partially, and whichever loads first wins - so the complete versions belong in the add-on whose folder starts with "!" and therefore loads before everything. What is here is what must NOT be global: a texture helper, and one function that would otherwise collide for no benefit. ----------------------------------------------------------------------------]] --------------------------------------------------------------------------- -- SetAtlas -- -- This client has no atlas system - zero hits for SetAtlas in Wow.exe and in -- realm.dll - so there is no sheet to resolve a name against. -- -- Handled here as a plain function rather than as a Texture method, because -- adding a method means patching a shared widget metatable, frame types share -- one metatable on 3.3.5a, and the last two times this pack did that it broke -- Escape and Jump for players. Every call site in the fork was rewritten to -- call through this instead, which is a local change with no reach. -- -- Every mapping below was confirmed present in this client's archives, with -- the winning-archive copy checked rather than the first one found. That check -- matters: a texture path the client does not have renders as a solid green -- block, which reads as a bug, whereas an absent decoration reads as absent. --------------------------------------------------------------------------- local ATLAS = { -- A plain white 8x8. Both of these are drawn tinted by the caller through -- SetVertexColor, so a solid white source is exactly right rather than a -- compromise - the colour was always coming from Lua. ["nameplates-bar-background-white"] = "Interface\\Buttons\\WHITE8X8", ["bonusobjectives-bar-glow"] = "Interface\\Buttons\\WHITE8X8", -- The classic 3.3.5a nameplate elite dragon. Silver gets the same art: this -- client has no separate rare-elite nameplate icon, and showing the elite -- dragon for a rare-elite is true, where showing nothing would not be. ["nameplates-icon-elite-gold"] = "Interface\\Tooltips\\EliteNameplateIcon", ["nameplates-icon-elite-silver"] = "Interface\\Tooltips\\EliteNameplateIcon", -- What the template's own XML already specifies for these two regions, -- at alpha .25 with ADD blending. The SetAtlas calls in the setup functions -- only ever overrode that with an atlas equivalent, so mapping back to it -- restores the intended look exactly rather than approximating it. ["raid-AggroHighlight"] = "Interface\\TargetingFrame\\UI-TargetingFrame-BarFill", ["raid-TargetHighlight"] = "Interface\\TargetingFrame\\UI-TargetingFrame-BarFill", -- These two are called from the XML templates' OnLoad, not from Lua, which -- is exactly how they were missed: the SetAtlas rewrite covered the .lua -- files only. They kept calling the real SetAtlas and indexing Ascension's -- Const table, and both threw during castBar and LevelFrame OnLoad - which -- is mid-construction, so the plate was never finished. ["nameplates-InterruptShield"] = "Interface\\CastingBar\\UI-CastingBar-Small-Shield", ["nameplates-icon-level"] = "Interface\\Common\\Indicator-Gray", } function ManiaxNamePlates_SetAtlas(region, atlasName) if not region or not region.SetTexture then return end -- If a real atlas system ever turns up - the client gaining one, or another -- add-on providing it - defer to it rather than second-guessing. if region.SetAtlas then local ok = pcall(region.SetAtlas, region, atlasName) if ok then return end end local path = atlasName and ATLAS[atlasName] if path then pcall(region.SetTexture, region, path) -- An atlas carries its own texcoords; a file does not, so any previously -- set ones have to be cleared or the replacement draws cropped. if region.SetTexCoord then pcall(region.SetTexCoord, region, 0, 1, 0, 1) end if region.Show then pcall(region.Show, region) end else pcall(region.SetTexture, region, nil) if region.Hide then pcall(region.Hide, region) end end end --------------------------------------------------------------------------- -- UnitShouldDisplayName -- -- Ported from Ascension's FrameXML/Util/UnitUtil.lua. Every CVar it reads is -- a stock 3.3.5a name-display CVar, so the logic carries over unchanged. -- -- Deliberately a local rather than a global. Ascension has it as FrameXML, but -- nothing else in this bundle defines or wants it, and a new global is a new -- chance for some future add-on's partial version to race this one. The rule -- this pack follows is that a shared global belongs in !Maniax335Compat and -- everything else stays where it is used. --------------------------------------------------------------------------- local function GetCVarBoolSafe(name) if C_CVar and C_CVar.GetBool then local ok, v = pcall(C_CVar.GetBool, name) if ok then return v end end return GetCVarBool and GetCVarBool(name) or false end function ManiaxNamePlates_UnitShouldDisplayName(unit) if not unit or not UnitExists(unit) then return false elseif UnitIsUnit("player", unit) then return GetCVarBoolSafe("UnitNameOwn") elseif not UnitIsPlayer(unit) then return GetCVarBoolSafe("UnitNameNPC") elseif UnitIsFriend("player", unit) then return GetCVarBoolSafe("UnitNameFriendlyPlayerName") end return GetCVarBoolSafe("UnitNameEnemyPlayerName") end