-
Notifications
You must be signed in to change notification settings - Fork 6
TopFit supports plugins by other authors. To make this more feasible, I will add documentation for functions interesting to plugin authorts on this page.
If you are missing functionality, drop me a message and I will see about implementing it.
The list is currently very brief, but I will expand it once I rewrite some core functionatilty to better support plugins interfering with normal behavior.
These functions will help you setup and manage your plugin.
This function will create a tab for your plugin on the right side of the options frame. You can use this to implement any custum UI your plugin needs right within Topfit.
- title (string): The caption of your plugin’s tab in the options frame.
- description (string): A brief description of your plugin. It will be shown in the tab’s tooltip.
- frame (Frame): A frame object which you should add your custom UI elements to. It will start hidden and show up when the user clicks your plugin’s tab.
- pluginId (number): An ID to identify your plugin for future API calls. You need this if you want to programmatically change the plugin tab’s text, for example.
Selects a plugin’s tab in the options frame.
- pluginId (number): The ID of the plugin whose tab you want to show. Usually your own plugin’s.
Event handling within TopFit is handled by lib-CallbackHandler 1.0. Therefore, the following methods are exposed:
This lets you register a function to be called whenever the specified event occurs. A list of supported events can be found in the next section.
- self (table or string): A table or a string identifier unique to your plugin.
- eventName (string): The name of the event you want to register for.
- eventHandler (function): The function you want to be called when the event occurs. It will be passed the event’s name as the first parameter, and any event-specific parameters after that.
Example:
local frame, pluginId = TopFit:RegisterPlugin("Test", "My Test Plugin")
TopFit.RegisterCallback("testplugin", "OnShow", function(event, id)
if (id == pluginId) then
TopFit:Print("Wheee, test plugin selected!")
end
end)
local frame, pluginId = TopFit:RegisterPlugin("Test", "My Test Plugin")
TopFit.RegisterCallback("testplugin", "OnShow", function(event, id)
if (id == pluginId) then
TopFit:Print("Wheee, test plugin selected!")
end
end)The following events are curently supported and sent by TopFit:
Fired whenever a plugin’s tab is selected in the options frame.
- pluginId (number): The ID of the selected plugin. Compare this to your plugin’s ID if you want to update or create your plugin’s UI elements when the plugin is actually shown.
Fired whenever the currently selected set in the options frame changes.
- setId (string): The identifier of the selected set. Will be nil if no set has been selected, for example if the user deletes all his sets.