diff --git a/ThreatPlates_Core.lua b/ThreatPlates_Core.lua deleted file mode 100644 index d3318fa..0000000 --- a/ThreatPlates_Core.lua +++ /dev/null @@ -1,177 +0,0 @@ ----------------------------------------------------------------------- --- ThreatPlates_Core.lua --- Core addon initialization, saved variables, slash commands --- Compatible with WoW 1.12 (Vanilla / Turtle WoW / Octo WoW) ----------------------------------------------------------------------- - --- Create the global addon object -ThreatPlates = CreateFrame("Frame") - -local addon = ThreatPlates -addon.MAJOR = 1 -addon.MINOR = 1 - --- Version string -TP_VERSION = "2.3.1" -TP_ADDON_NAME = "ThreatPlates" - --- ================================================================== --- Default configuration --- ================================================================== -local DEFAULT_CONFIG = { - enabled = true, - showText = true, - barHeight = 6, - barAlpha = 0.5, - barOffsetY = 1, - barOffsetX = -17.8, - barWidthScale = 0.8, - fontSize = 9, - fontOutline = true, - smoothColors = true, - showOnFriendly = false, - showOnNeutral = true, - showOnHostile = true, - showSpark = false, - showFillBG = true, - fillAlpha = 0.1, - glowEnabled = false, - glowSize = 3, - glowAsShadow = true, - guiPos = { - point = "CENTER", - relPoint = "CENTER", - x = 0, - y = 0, - }, -} - --- ================================================================== --- Safe UnitGUID wrapper - UnitGUID does not exist in Vanilla 1.12 --- Returns nil on vanilla clients, falls back to unit name --- ================================================================== -function addon:SafeGUID(unit) - if UnitGUID then - local ok, guid = pcall(UnitGUID, unit) - if ok and guid then return guid end - end - return nil -end - --- ================================================================== --- Get a unique identifier for a unit (GUID or name) --- In vanilla 1.12, UnitGUID does not exist, so we use unit name --- ================================================================== -function addon:GetUnitID(unit) - if not unit then return nil end - local guid = addon:SafeGUID(unit) - if guid then return guid end - local ok, name = pcall(UnitName, unit) - if ok and name then return name end - return nil -end - --- ================================================================== --- Print helper --- ================================================================== -function addon:ui_print(msg) - if DEFAULT_CHAT_FRAME then - DEFAULT_CHAT_FRAME:AddMessage("|cffbb99ffThreatPlates|r " .. tostring(msg)) - end -end - --- ================================================================== --- Deep copy utility --- ================================================================== -local function DeepCopy(src) - if type(src) ~= "table" then return src end - local dst = {} - for k, v in pairs(src) do - if type(v) == "table" then - dst[k] = DeepCopy(v) - else - dst[k] = v - end - end - return dst -end - --- ================================================================== --- Event handling --- ================================================================== -addon:RegisterEvent("ADDON_LOADED") -addon:RegisterEvent("PLAYER_ENTERING_WORLD") - -addon:SetScript("OnEvent", function() - if event == "ADDON_LOADED" and arg1 == TP_ADDON_NAME then - -- Initialize saved variables with defaults - if not ThreatPlatesDB then - ThreatPlatesDB = DeepCopy(DEFAULT_CONFIG) - else - -- Merge in any missing keys from defaults - for k, v in pairs(DEFAULT_CONFIG) do - if ThreatPlatesDB[k] == nil then - ThreatPlatesDB[k] = DeepCopy(v) - end - end - end - - -- Ensure media textures - addon.Media.EnsureTextures() - - -- Initialize modules - addon.ThreatEngine:Initialize() - addon.Threat:Initialize() - addon.Nameplates:Initialize() - addon.GUI:Initialize() - - addon:ui_print("v" .. TP_VERSION .. " loaded! Type /tp for options.") - - elseif event == "PLAYER_ENTERING_WORLD" then - -- Force a nameplate scan on entering world - if ThreatPlatesDB and ThreatPlatesDB.enabled then - addon.Nameplates:UpdateAll() - end - end -end) - --- ================================================================== --- Slash commands --- ================================================================== -SLASH_THREATPLATES1 = "/threatplates" -SLASH_THREATPLATES2 = "/tp" - -SlashCmdList["THREATPLATES"] = function(msg) - -- Trim whitespace and lowercase (vanilla-safe) - msg = msg or "" - msg = string.lower(msg) - -- Trim leading/trailing spaces - msg = string.gsub(msg, "^%s*(.-)%s*$", "%1") - - if msg == "reset" then - ThreatPlatesDB = DeepCopy(DEFAULT_CONFIG) - addon:ui_print("Settings reset to defaults.") - addon.GUI:Refresh() - elseif msg == "toggle" then - ThreatPlatesDB.enabled = not ThreatPlatesDB.enabled - local state = ThreatPlatesDB.enabled and "|cff33ff99ON|r" or "|cffff3333OFF|r" - addon:ui_print("Threat bars " .. state) - addon.Nameplates:UpdateAll() - elseif msg == "threat" then - addon.ThreatEngine:DumpThreat() - elseif msg == "help" then - addon:ui_print("Commands:") - DEFAULT_CHAT_FRAME:AddMessage(" |cffbb99ff/tp|r - Open GUI") - DEFAULT_CHAT_FRAME:AddMessage(" |cffbb99ff/tp toggle|r - Toggle threat bars on/off") - DEFAULT_CHAT_FRAME:AddMessage(" |cffbb99ff/tp reset|r - Reset to defaults") - DEFAULT_CHAT_FRAME:AddMessage(" |cffbb99ff/tp threat|r - Dump threat table (debug)") - DEFAULT_CHAT_FRAME:AddMessage(" |cffbb99ff/tp help|r - Show this help") - else - addon.GUI:Toggle() - end -end - --- ================================================================== --- Expose DeepCopy on addon for other modules --- ================================================================== -addon.DeepCopy = DeepCopy