- 1 Talk
-
LegoBlock
LegoBlock: Embeddable library to provide block functionality. Generated LegoBlocks stick together using Tuller's FlyPaper code. Blocks do not currently stick across majors, though that is under consideration.
Contents |
Description
Edit
LegoBlock lets you create a small block to display information in it like time, performance, haste or anything you can think of! Blocks can be snapped together in any position or order you can do simple things like snap them together into a long line to be positioned at the top of your UI, or you can snap them together in an "L" position and so on.
Theres two methods of snapping blocks together, one is simply to drag it to another block and it'll snap to the closet block for example if you drag block "A" to the bottom of block "B" it'll snap to the bottom, if you snap it to the left side of "B" it'll snap to that side and so on. If you have muultiple blocks and you need to specifically choose which one to snap to then drag block "A" into block "B" and you can choose which side to snap to without it trying to snap to anything else.
Blocks that are snapped togther become a group, if you have A, B and C you can drag any of those 3 and they'll all move together when you want to unsnap a block from a group hold down CTRL and drag it out.
LegoBlock is meant to display information, not as a methods of launching or viewing configuration.
LegoBlock-Beta1 API
Edit
:New(name[, text, icon, optionsTbl])
Edit
Creates a new LegoBlock.
Args
Edit
| Arg | Type | Details |
|---|---|---|
| name | string | The name for your lego block. It will be prefixed with Lego. |
| text | string | (Optional) The initial text for the lego block. |
| icon | string/texture | (Optional) The initial texture for the icon on the lego block. |
| optionsTbl | table | (Optional) A table to store settings about the lego. Should be given as a LegoBlock optionsTbl |
Returns
Edit
| Return | Type | Details |
|---|---|---|
| legoBlock | frame | The frame created. It is a LegoBlock |
Remarks
Edit
The optionsTbl is used to store block information and should be of a permanent type storage like a SavedVariables table.
OptionsTbl
Edit
Format for the optionsTbl is thus:
| Key | Value Type | Details |
|---|---|---|
| width | int | The width of the LegoBlock |
| height | int | The height of the LegoBlock |
| text | string | The text on the LegoBlock |
| icon | string | The icon on the LegoBlock |
| x | int | the X coordinate for the center of the LegoBlock |
| y | int | The Y coordinate for the center of the LegoBlock |
| anchor | string | The anchor used for SetPoint'ing the LegoBlock |
| showIcon | boolean | Whether or not to show the icon. |
| showText | boolean | Whether or not to show the text. |
| hidden | boolean | Whether or not to show the LegoBlock. |
| noresize | boolean | Whether or not to resize the LegoBlock when you set the text. |
| appendstring | string | String to append to the CreateFrame call. |
[width] = int, [height] = int, [text] = string, [icon] = string, [x] = int, [y] = int, [anchor] = string, [showIcon] = boolean, [showText] = boolean, [hidden] = boolean, [appendString] = string, [savedFields] = integer indexed table with extra key/value pairs to fill in
Example
Edit
self:New("HelloWorld"[, "My first lego block", nil, {}])
LegoBlock:SetDB(optionsTbl)
Edit
Changes the optionsTbl attached to a lego block
Args
Edit
| Arg | Type | Details |
|---|---|---|
| optionsTbl | table | Sets the new optionsTbl for the lego block and restores settings based on the table |
Example
Edit
self:SetDB({})
LegoBlock:ShowIcon()
Edit
Shows the icon
Args
Edit
None
Remarks
Edit
Will automagically position the text on show.
Example
Edit
self:ShowIcon()
LegoBlock:HideIcon()
Edit
Hides the icon
Args
Edit
None
Remarks
Edit
Will automagically position the text on hide.
Example
Edit
self:HideIcon()
LegoBlock:SetIcon(icon)
Edit
Sets the icon
Args
Edit
| Arg | Type | Details |
|---|---|---|
| icon | string/texture | Sets the icon for the lego block. |
Remarks
Edit
Does not automatically show the icon
Example
Edit
self:SetIcon(<fill me in>)
LegoBlock:ShowText()
Edit
Shows the text
Example
Edit
self:ShowText()
LegoBlock:HideText()
Edit
Hides the text
Example
Edit
self:HideText()
LegoBlock:SetText(text)
Edit
Sets the text of the lego block
Args
Edit
| Arg | Type | Details |
|---|---|---|
| text | string | Sets the text of the lego block. |
Remarks
Edit
You can set self.optionsTbl.noresize = true to not resize. Does not automagically show the text, you must call ShowText.
Example
Edit
self:SetText("Woohooo")