Usage

AS A MIXIN / EMBEDDING
The following methods are made available when using the library as a mixin or when embedding it in another object (which is essentially the same thing).

:Build(var, name)
Build an AceConfigDialog3 optiontable from a variable

var(object) = the variable
name(string) = the name of the variable

returns the name under which the optiontable will be stored, the table itself and the setup-table where the config stores it's working variables

:GetTempStorage()
returns the table where the Build-results are stored in for the current addon. Can be nil if nothing has been built yet. The table is structured like this:

table = {
  [buildname] = {
    table = *configtable*,
    setup = *the setup-table*
  },
}


Each mixed in object has it's own storage. This prevents naming conflicts.

:AddFtionTip(func, paramstring, ismethod)
func(function) = the function in question
paramstring(string) = the parameterstring of the function
ismethod(boolean) = indicated if there is an extra 'self' parameter to be added

Adds the function tip to the functiontip table

:AddFtionTips(tiptable)
tiptable(table) = table with a whole lotta tips. Needs to be in following format:

tiptable = {
  [func] = paramstring,
}

Notice that the keys are the functions themselves, not their names.

Adds the tips to our own tip-table

:ShowBuild(rootname, tab)
IF AceConfigDialog3 is found this shows the provided table as a GUI. If not, it does nothing.

rootname(string) = name of Build, may be nil, if not nil and the table is found in the storage, tab is ignored
tab(table) = the GUI-table to show, if name is nil, this needs to have a value

DIRECT
Additionally, if you use the library directly, the following method is available. It is only meant to be used by non-addon specific code like MindBrowser.

:GetAllStorage()
return the whole table where the Build-results are stored. This table is formatted like this (obj = the object MindReader was mixed in with):

table = {
  [obj] = *the result of :GetTempStorage()*
}


The table also contains a member for LibMindReader itself if it has been used to build for itself directly.

EXAMPLE

A typical, but dumbed down, scenario:

local mr = {};
mr = LibStub('LibMindReader'):Embed(mr);

local MyAddon = LibStub('AceAddon-3.0'):NewAddon('MyAddon','AceConsole-3.0','AceEvent-3.0','AceTimer-3.0');

local helper_func(stuff1)
  --some code
end
mr:AddFtionTip(helper_func,'stuff',false);

function MyAddon:MyFunction(param1, param2)
  ...
  -- Returns 'MyAddon'..GetTime()
  local buildname = mr:Build(MyAddon,'MyAddon');
  mr:ShowBuild(buildname);
end
mr:AddFtionTip(MyAddon.MyFunction,'param1, param2',true);

On loading the addon LibMindReader will be embedded in the 'mr' local and be fed function tips every time a function is defined. Eventually, the code will hand mr a table to build and ask it to be shown.

The ShowBuild-method will fail silently if it cannot find the AceConfigDialog-3.0 library. So if your code is intending to do more than building it should embed this library as well. The order of embedding is not important. As long as it's loaded when :ShowBuild() is called.


Comments

Posts Quoted:
Reply
Clear All Quotes