--[[-------------------------------------------------------------------------- ManiaxUpgrades - namespace, settings and the slash command. The add-on annotates the tooltip of an item that mod-upgrade-kits has upgraded: the rank word under the name, and the stats the upgrade added. Everything it needs is local - the clone id table ships with it (Clones.lua), and the base item's numbers come from the client's own item cache. There is no addon channel, no server round-trip and no chat output. ----------------------------------------------------------------------------]] ManiaxUpgrades = ManiaxUpgrades or {} local NS = ManiaxUpgrades NS.VERSION = "1.0.0" -- Rank word for the line under the name. Daniel's ruling from the Ascension -- reference screenshot: every rank prints in the same green as their -- "Superior" line, not tiered by rank - so there is no per-rank colour here -- any more, only the word. See NS.BONUS_COLOR. NS.RANKS = { [1] = { word = "Worn" }, [2] = { word = "Glimmering" }, [3] = { word = "Radiant" }, [4] = { word = "Pristine" }, } -- The upgrade tint - the rank word, every stat/armor/damage line the upgrade -- added or increased, and any random-suffix line the base item doesn't have. -- Matches Ascension's own "Superior" quality green (Daniel's reference -- screenshot), on purpose: the point is no longer "a colour nothing else -- uses", it is "the same green their own UI already uses for an addition". NS.BONUS_COLOR = "1eff00" -- Trailing " (Rank N)" is stripped from the name line. The clones are being -- renamed server-side so their names equal the base's; this handles a client -- whose itemcache still holds the old name, and costs nothing once they all do. NS.RANK_SUFFIX = "%s*%(Rank%s+%d+%)%s*$" local function Print(msg) DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00Maniax|r Upgrades: " .. msg) end NS.Print = Print function NS:Debug(msg) if ManiaxUpgradesDB and ManiaxUpgradesDB.debug then Print(msg) end end --- Resolve an item id to its base entry and rank. -- Arithmetic, not a per-clone table: every base owns four consecutive entries -- and both reserved blocks start on a multiple of four. Clones.lua's generator -- refuses to emit unless that holds for all of them. -- @return baseEntry, rank or nil when the id is not a clone. function NS:Resolve(itemId) if not itemId then return nil end if itemId < self.CLONE_MIN or itemId > self.CLONE_MAX then return nil end local offset = itemId % 4 local base = self.CloneBase[itemId - offset] if not base then return nil end return base, offset + 1 end local loader = CreateFrame("Frame") loader:RegisterEvent("ADDON_LOADED") loader:SetScript("OnEvent", function(_, _, addon) if addon ~= "ManiaxUpgrades" then return end ManiaxUpgradesDB = ManiaxUpgradesDB or {} if ManiaxUpgradesDB.debug == nil then ManiaxUpgradesDB.debug = false end loader:UnregisterEvent("ADDON_LOADED") end) SLASH_MANIAXUPGRADES1 = "/mxu" SlashCmdList["MANIAXUPGRADES"] = function(msg) local cmd = string.lower(strtrim(msg or "")) if cmd == "debug" then ManiaxUpgradesDB = ManiaxUpgradesDB or {} ManiaxUpgradesDB.debug = not ManiaxUpgradesDB.debug Print("debug " .. (ManiaxUpgradesDB.debug and "on" or "off")) else Print("version " .. NS.VERSION .. ", " .. (NS.CLONE_COUNT or 0) .. " upgrade entries known. /mxu debug toggles diagnostics.") end end