6.3.4
What's new
Version 6.3.4
| Area | What the library does for you |
|---|---|
| Addon container | Lib:CreateAddon() creates the addon object: name, version (from the TOC), chat prefix, SavedVariables prefix, event frame, lifecycle hooks (OnLoaded, OnCombatStart, OnCombatEnd) and inCombat tracking. |
| Dependency injection | CreateModel / CreateService / CreateView register types, GetService / GetModel / NewView resolve them. Services are created lazily and initialized once; every service, view and model gets self.addon, self:GetService() and self:GetModel() injected. |
| Client detection | isVanilla, isSod, isBcc, isWrath, isCata, isMop, the is*AtLeast flags and a numeric expansionId — one code base for all Classic flavors. |
| Log service | addon:Log(class, method, format, ...) writes to a day-keyed SavedVariable (<Prefix>_Logs), old days are purged automatically, GetLogText() renders it for a log window. |
| Locale service | Full-locale first (zhCN), then short (de), then English. Get(key, ...) formats only when arguments are given, so placeholders like %player% stay untouched. |
| Timer service | Named countdowns with a 1-second ticker, one-shot Wait, and FormatTime ("5m", "1d 2h 10m", colored "Ready"). |
| UI service | Movable/resizable windows with the animated purple→gold gradient border, ElvUI-scale awareness, position and size persistence (<Prefix>_Frames), panels, flat/round/close/icon buttons, tabs, scroll frames, edit boxes, dropdowns with hover glow, tooltips and a LibDBIcon minimap button with one call. |
Supported clients
Classic Era & Season of Discovery, Anniversary/TBC, Wrath, Cataclysm and Mists of Pandaria Classic.
Quick start
Embed the library (libs\LibMasterAddons\) and load it after LibStub, LibDataBroker and LibDBIcon in your TOC:
## OptionalDeps: LibMasterAddons
## X-Embeds: LibMasterAddons
libs\LibStub.lua
libs\CallbackHandler-1.0.lua
libs\LibDataBroker-1.1.lua
libs\LibDBIcon-1.0.lua
libs\LibMasterAddons\LibMasterAddons.xml
MyAddon.lua
Create your addon:
local Lib = LibStub("LibMasterAddons-1.0");
local addon = Lib:CreateAddon({
id = "MyAddon", -- folder / TOC name
name = "My Addon",
shortcut = "|cffDA8CFF[MA]|r ", -- prefix of window titles and chat output
storagePrefix = "MA", -- MA_Logs, MA_Frames, MA_Settings (SavedVariables)
});
addon:OnLoaded(function()
addon:GetService("startup"); -- start your services once SavedVariables are loaded
end);
_G.myAddon = addon;
Define a service and a view:
local StartupService = _G.myAddon:CreateService("startup");
function StartupService:Initialize()
self:HandleEvent("PLAYER_LOGIN", function()
self.addon.mainView = self.addon:NewView("main");
self:GetService("ui"):CreateMinimapIcon({
icon = "Interface\\Icons\\INV_Misc_Book_09",
onClick = function(button) self.addon.mainView:Toggle(); end,
onTooltip = { "My Addon", "Left-click: toggle window" },
});
self.addon:Log("StartupService", "Initialize", "ready on expansion %d", self.addon.expansionId);
end);
end
local MainView = _G.myAddon:CreateView("main");
function MainView:Toggle()
if (not self.frame) then
local ui = self:GetService("ui");
self.frame = ui:CreateView("main", 600, 400, "My Addon", true, true);
ui:CreateFlatCloseButton(self.frame, function() self.frame:Hide(); end);
end
self.frame:SetShown(not self.frame:IsShown());
end
Built-in services are resolved by name (log, locale, timer, ui); an addon can replace any of them by creating its own service with the same name.
Compatibility promise
The LibStub major LibMasterAddons-1.0 is the API contract: members are only ever added, never removed or changed in meaning. Breaking changes would ship as a new major (LibMasterAddons-2.0) that can be embedded side by side. The minor is derived from the release version, so the newest embedded copy is always the one that runs.
This mod has no additional files

