mNo edit summary |
mNo edit summary |
||
Line 60: | Line 60: | ||
:tag('div') -- HTML div to contain the field. We specify a min-height of 40px for consistency. | :tag('div') -- HTML div to contain the field. We specify a min-height of 40px for consistency. | ||
:cssText('display: flex; min-height: 40px;') | :cssText('display: flex; min-height: 40px;') | ||
:tag('div') -- HTML div to contain the field | :tag('div') -- HTML div to contain the field | ||
:cssText( 'flex-grow: 2; overflow: hidden; display: flex; flex-direction: | :cssText( 'flex-grow: 2; overflow: hidden; display: flex; flex-direction: row;') | ||
:tag('div') -- HTML div to contain the | :tag('div') -- HTML div to contain the field label | ||
:attr('title', Input and (Field.Name .. ' <' .. Field.Type .. '>') or '') -- Add a basic mouseover description | :attr('title', Input and (Field.Name .. ' <' .. Field.Type .. '>') or '') -- Add a basic mouseover description | ||
:cssText('text-align: left; overflow: hidden; text-overflow: ellipsis; padding-left: 4px;') | :cssText('text-align: left; width:30%; overflow: hidden; text-overflow: ellipsis; padding-left: 4px;') | ||
:wikitext( (Field and Field.Name or '') .. ':' ) | :wikitext( (Field and Field.Name or '') .. ':' ) | ||
:done() -- Close input label div | :done() -- Close input label div | ||
:tag('div') -- HTML div to contain the | :tag('div') -- HTML div to contain the field UI | ||
:cssText('text-align: left; overflow: hidden; text-overflow: ellipsis; padding-left: 4px;') | :cssText('text-align: left; overflow: hidden; text-overflow: ellipsis; padding-left: 4px;') | ||
:wikitext( 'Test Content' ) | :wikitext( 'Test Content' ) |
Revision as of 19:49, 14 January 2024
The Text Component
Text
The RelativePositioner Component
RelativePositioner
The AssetMultiplexer<ITexture2D> Component
AssetMultiplexer<ITexture2D>
-- Package definition to return to Scribunto - this allows us to define methods that can be called
-- when this module is targeted.
local p = {}
local fieldHandlers = {}
-- Type colors - RGB values to be included in the HTML output when a color is needed. This will be replaced with CSS at some point.
local typeColor =
{
User = '255, 128, 255',
Impulse = '179, 255, 255',
bool = '115, 115, 115',
AsyncImpulse = '204, 179, 255',
String = '245, 31, 31',
Dummy = '255, 0, 255',
IFormatProvider = '168, 143, 214',
float = '0, 255, 255',
ColorProfile = '255, 196, 54',
colorX = '255, 89, 0',
Component = '112, 76, 85',
float3 = '0, 255, 255',
float2 = '0, 255, 255',
ulong = '0, 255, 127',
int = '0, 255, 0',
Continuation = '255, 255, 178',
Slot = '191, 255, 127'
}
--- Method that generates the HTML output
-- @param frame A Scribunto frame instance. frame.args contains the parameters passed into the module call
function p.GenerateUI( frame )
-- Parse the JSON input, returning an empty array if no argument was passed
local fields = mw.text.jsonDecode(frame.args.Fields or '[]')
-- Create an HTML div element to contain our component UI
local componentContainer = mw.html.create( 'div' )
componentContainer
:attr('class', frame.args.Inline and '' or 'floatright')
:cssText('color: rgb(224, 224, 224); background-color: rgb(18, 20, 28); width: 512px; display: flex; flex-direction: column; align-items: stretch;')
:tag('div') -- HTML div to contain the component title
:cssText('color: rgb(247, 247, 112); border-radius: 10px; background-color: rgb(43, 46, 54); text-align:center; font-size: 1.25rem; font-weight: bold; flex-grow: 1;')
:wikitext(frame.args.Name)
:done() -- Close node title div
-- Iterate over each row, and populate it with the inputs/outputs. If the node is asymmetric,
-- the value passed for either input or output might be nil.
for i=1,#fields do
CreateField(componentContainer, fields[i])
end
-- Return the HTML generated above to the wiki page this script is invoked from.
return tostring(componentContainer) .. '[[Category:Components:All]]'
end
--- Creates a new Component field row in the output
-- @param Container The Scribunto HTML node we'll be creating this row inside of. Should be a container of some sort.
-- @param Field Table containing a Name, FieldType, and Type for the field on this row.
function CreateField(Container, Field)
Container
:tag('div') -- HTML div to contain the field. We specify a min-height of 40px for consistency.
:cssText('display: flex; min-height: 40px;')
:tag('div') -- HTML div to contain the field
:cssText( 'flex-grow: 2; overflow: hidden; display: flex; flex-direction: row;')
:tag('div') -- HTML div to contain the field label
:attr('title', Input and (Field.Name .. ' <' .. Field.Type .. '>') or '') -- Add a basic mouseover description
:cssText('text-align: left; width:30%; overflow: hidden; text-overflow: ellipsis; padding-left: 4px;')
:wikitext( (Field and Field.Name or '') .. ':' )
:done() -- Close input label div
:tag('div') -- HTML div to contain the field UI
:cssText('text-align: left; overflow: hidden; text-overflow: ellipsis; padding-left: 4px;')
:wikitext( 'Test Content' )
:done() -- Close input label div
:done() -- Close div
end
function fieldHandlers.Sync(Container, Field)
end
function fieldHandlers.AssetRef(Container,Field)
end
--- Returns an RGBA value representing the type color within Resonite
-- @param Connector Table containing a Name (Optional) and Type (Required) for the input/output attachment point.
-- @param Alpha The alpha to use in the RGBA value.
function GetTypeColor(Connector, Alpha)
return (Connector and 'rgba(' .. (typeColor[Connector.Type] or '0, 0, 0') .. ',' .. Alpha .. ')' or 'rgba(0, 0, 0, 0)')
end
return p