LibHijackMinimap-1.0

LibHijackMinimap is a library that provides centralized handling for re-parenting the minimap. LHM provides functionality to handle multiple hijackers and brokers requests between hijacker and client addons.

Addons that draw to the minimap (clients) and want to support minimap replacement/reparenting can register to this library with a callback that is executed on minimap replacement. In the callback routine the client has to handle the reparenting of their minimap items.

Addons that replace the minimap (hijackers) and want to notify clients can register to this library and use library calls to notify the hijack and release of the minimap.

One of the major advantages of using LHM is that new client addons don't have to contact every single hijacker addon to be supported, existing hijacker addons don't have to update for every new client addon and new hijacker addons don't have to find all existing clients out there.

Clients can be blacklisted for hijacking by specific hijackers. If more than one hijacker addon replaced the minimap for a client the first hijacker wins. If a hijacker restores the minimap the client will fall back to the next valid hijacker or be restored to the minimap if none.

The blacklisting can be configured through an external addon. Only one addon can be used for configuration. As default LibHijackMinimap-1.0-Options has been designed to do the job.

With LibHijackMinimap hijacker addons don't have direct control over which client addons they hijack and therefore don't need to provide a setup for this.

With a single hijacker addon and assuming the user will want to see all client addons on the minimap replacement this behaviour is the default with no need for the options addon.

API Reference

Example

Hijacker

local AddonName = "Hijacker"
local Addon = LibStub:GetLibrary("AceAddon-3.0"):NewAddon(AddonName)
local LHM = LibStub:GetLibrary("LibHijackMinimap-1.0")

-- used as private unique id to authenticate hijack requests with LHM
local lhmToken = {}

LHM:RegisterHijacker(AddonName, lhmToken)

function Addon:HijackMinimap(frame)
	if not frame then
		return
	end

	LHM:HijackMinimap(lhmToken, frame)
end

function Addon:ReleaseMinimap()
	LHM:ReleaseMinimap(lhmToken)
end

Client

local AddonName = "Client"
local Addon = LibStub:GetLibrary("AceAddon-3.0"):NewAddon(AddonName)
local LHM = LibStub:GetLibrary("LibHijackMinimap-1.0")

function Addon:ReparentMinimap(frame)
	if not frame then
		return
	end

	-- in case hijacker did not provide optional argument "ROTATE_MINIMAP" in SetCVar("rotateMinimap", value, "ROTATE_MINIMAP") so CVAR_UPDATE did not fire
	local rotateMinimap = GetCVar("rotateMinimap") == "1"

	-- reparent your minimap items
end

LHM:RegisterClient(AddonName, Addon, "ReparentMinimap")

Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    92912
  • Created
    Jun 24, 2015
  • Last Released File
    Jun 24, 2015
  • Total Downloads
    702
  • License

Categories

Members

Recent Files