Plugin API

Registering your plugin for load

At runtime, you first register your plugin with SimpleHUD. This is done by calling the following:

SimpleHUD:RegisterForLoad(OnLoad)


Once SimpleHUD has initialized and the DB is loaded, the OnLoad function you passed as arg1 is called.

Registering your plugin with SimpleHUD

In the function passed above, you can now call

Arguments

local frame, db, config = SimpleHUD:RegisterPlugin(name, width, height, defaults)


name is used as a local identifier for your addon and in the config.
width and height are initial size values for your HUD frame. This is required because the frame is made movable when a plugin first loads.
defaults is a table. The contents of this table are added to the db table returned.

Return values

frame is your HUD frame. Do not SetPoint this frame, SetHeight/SetWidth are fine. Parent all your HUD objects to this frame.
db is your plugin's AceDB subtable. If this is the first time your plugin loads, it will contain an "pos" subtable used to store location information for your HUD frame aswell as any keys you specified in your defaults table. If it is not your first load, this will be the same table you left the last time.
config is your addon's AceConfig-3.0 sub-table. You can use this to configure your addon.
Example code:

config.size = {type="input",
		name="Size",
		desc="Set the buttons' size",
		order=1,
		get=function() return tostring(db.size) end,
		set=function(info, value) db.size = tonumber(value) for id, btn in ipairs(buttons) do btn:SetWidth(tonumber(value)) btn:SetHeight(tonumber(value)) btn:SetPoint("TOPLEFT", (id-1)*db.size, 0) end frame:SetHeight(tonumber(value)) local scnt = 0 while buttons[scnt+1] and buttons[scnt+1]:IsShown() do scnt = scnt+1 end frame:SetWidth(tonumber(value)*scnt) end,
	}
	config.rotation = {type="group",
		name="Rotation",
		desc="Configure your rotation",
		args={},
		order=-1,
		dialogInline=true,
	}


See this page for further options.

Getting the state of the HUD

If your addon needs to know whether or not the HUD is currently shown, you can use this API.

local showState = SimpleHUD:GetHUDState()


Return values

showState - string - either "shown", "showing", "hidden" or "hiding". "showing" and "hiding" mean that the HUD is currently mid-animation. "shown" and "hidden" mean that the HUD is in that state.


Comments

Posts Quoted:
Reply
Clear All Quotes