NexUI
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
User Interface Project
Setup
Rez a object to serve as root, recommended as the menu-background of the UI.
new script, name as 'uiMaster'. This is the default basic setup: <lsl>
</lsl>
new scripts (4 total), name as 'uiSlave:0', 'uiSlave:1', 'uiSlave:2' and 'uiSlave:3', which serve to speed up feedback significantly of the pseudo dynamic graphics.
<lsl> integer x;
default{
state_entry(){ x = (integer)llList2String( llParseString2List( llGetScriptName(), [":"], [] ), 1 ); state Main; }
}
state Main{
link_message( integer sn, integer n, string str, key k ){ if( n == x ){ list t = llParseString2List( str, ["|"], [] ); llSetLinkPrimitiveParams( (integer)llList2String(t,0), [(integer)llList2String(t,1),(integer)llList2String(t,2),(key)llList2String(t,3),(vector)llList2String(t,4),(vector)llList2String(t,5),(float)llList2String(t,6)] ); } }
} </lsl>
uiFunctions
Initialization | ||||
---|---|---|---|---|
Initializes UI Elements into lists. Goes through all child prims to identify them as being a UI element by their prim description. And includes them into global lists of link number, name and their UI type for: use in other functions, debug saving time from re-searching entire linksets again and; preventing objects having hard-coded scripts which would defy the point of flexibility. <lsl> uiInit(){ integer y = llGetNumberOfPrims(); while( --y-1 ){ list Dat = llGetObjectDetails( llGetLinkKey( y ), [OBJECT_NAME,OBJECT_DESC] ); string lDesc = llList2String( Dat, 1 ); if( llGetSubString( lDesc, 0, 2 ) == "UI_" ){ uiLnk = (uiLnk = []) + uiLnk + y; uiNm = (uiNm = []) + uiNm + llList2String( Dat, 0 ); uiType = (uiType = []) + uiType + lDesc; } } } </lsl>
By Nexii Malthus
|
Click and Drag | ||||||||
---|---|---|---|---|---|---|---|---|
Based on my Click and Drag script. <lsl> list uiCND( integer Mode ){ if( llDetectedTouchFace( 0 ) == -1 ) return [-1]; if( Mode == 0 ){ // START // tData1 = [ llDetectedTouchPos(0), llDetectedTouchNormal(0), llDetectedTouchBinormal(0) ]; ST1 = llDetectedTouchST( 0 ); } else if( Mode == 1 ){ // TOUCH // vector ST2 = llDetectedTouchST( 0 ); if( ST1 == <-1,-1,0> || ST2 == <-1,-1,0> ) return [-1]; if( llVecDist( ST1, ST2 ) > 0.01 ){ llSetLinkColor( Lnk, < 0.0, 0.0, 1.0 >, 0 ); llSetLinkAlpha( Lnk, 0.2, 0 ); float relSize = 0.08;//0.084; vector selCentre = <1,1,0> - ((ST2+ST1)/2); vector selSize = (ST1-ST2); selSize = <llFabs(selSize.x),llFabs(selSize.y),0>; vector Scale = <relSize/selSize.x,relSize/selSize.y,0>; vector Offset = (selCentre-<0.5,0.5,0>); Offset = <Offset.x*Scale.x,Offset.y*Scale.y,0>; llMessageLinked( LINK_THIS, Smoother, llDumpList2String( [Lnk,PRIM_TEXTURE,0,kTextureDrag,Scale,Offset,0], "|" ), "" ); if( ++Smoother > 3 ) Smoother = 0; } } else if( Mode == 2 ){ // END // key nKey = llDetectedKey( 0 ); vector tPos = llDetectedTouchPos( 0 ); tData2 = [ tPos, llDetectedTouchNormal( 0 ), llDetectedTouchBinormal( 0 ) ]; vector ST2 = llDetectedTouchST( 0 ); if( ST1 == <-1,-1,0> || ST2 == <-1,-1,0> ) return [-1]; if( llVecDist( ST1, ST2 ) < 0.01 ){ llSetLinkColor( Lnk, < 0.0, 1.0, 0.0 >, 0 ); llSetLinkAlpha( Lnk, 1.0, 0 ); vector Scale = < 1.0, 1.0, 0>; vector Offset = < 1.0, 1.0, 0 > - ST1; llSetLinkPrimitiveParams( Lnk, [ PRIM_TEXTURE, 0, kTextureClick, Scale, Offset, 0 ]); llSetLinkAlpha( Lnk, 0.0, 0 ); return [0] + tData1; } else { llSetLinkColor( Lnk, < 0.0, 0.0, 1.0 >, 0 ); llSetLinkAlpha( Lnk, 0.2, 0 ); float relSize = 0.08; vector selCentre = <1,1,0> - ((ST2+ST1)/2); vector selSize = (ST1-ST2); selSize = <llFabs(selSize.x),llFabs(selSize.y),0>; vector Scale = <relSize/selSize.x,relSize/selSize.y,0>; vector Offset = (selCentre-<0.5,0.5,0>);Offset = <Offset.x*Scale.x,Offset.y*Scale.y,0>; llSetLinkPrimitiveParams( Lnk, [ PRIM_TEXTURE, 0, kTextureDrag, Scale, Offset, 0 ]); llSetLinkAlpha( Lnk, 0.0, 0 ); return [1] + tData1 + tData2; } } return [-1]; } </lsl>
By Nexii Malthus
|