------------------------------------------------------------------------------- -- AttachScriptOnThis( ScriptName ) -- AttachScriptOnCharacter( ScriptName ) -- SetParamOnThis( ParamName, ParamVal -- SetParam( MaxObjName, ParamName, ParamValue ) -- SetAttributeOnThis( AttName, AttValue, AttType, AttCatego ) -- SetAttributeOnCharacter( AttName, AttValue, AttType, AttCatego ) -- Load( fileName ) ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Global Variables ------------------------------------------------------------------------------- global exportFct, previewFct, quickPreviewFct, updateInstructionsList, registerInstruction global AddCKChunk, RemoveCKChunk, WriteConfig, ReadConfig, GetLevelObject global Virtools_Preview, VirtoolsExportOpt, VirtoolsExportProcess, VirtoolsInstructionsManager global posAsVirtools, boolAsVirtools, matrixInParentAsVirtools global ReadCKBufValue, ReadCKBufValueAsFloat, ReadCKBufValueAsInt, ReadCKBufValueAsVector global ReadCKBufValueAsAngle, ReadCKBufValueAsTime global maxPath = getdir #maxroot global virtoolsAddonsPath = maxPath + "plugins\\Virtools AddOns\\" global CKInstPath = maxPath + "scripts\\CKInstScripts\\" global previewFileName = virtoolsAddonsPath + "preview.vmo" global configFileName = (getdir #plugcfg) + "\\Max2Nmo.CFG" global configSettingSection = "Settings" if VirtoolsWindow!=undefined do ( closerolloutfloater VirtoolsWindow ) global VirtoolsWindow global currentRollout = unsupplied global CKCHUNKBEGINSTR = "CKCHUNK_BEGIN" global CKCHUNKENDSTR = "CKCHUNK_END" global CKAttacheScriptOnThisStr = "CK_AttachScriptOnThis" global CKAttachScriptOnCharacterStr = "CK_AttachScriptOnCharacter" global CKSetParamOnThisStr = "CK_SetParamOnThis" global CKSetParamStr = "CK_SetParam" global CKSetAttributeOnThisStr = "CK_SetAttributeOnThis" global CKSetAttributeOnCharacterStr= "CK_SetAttributeOnCharacter" global CKLoadStr = "CK_Load" global instNameSet = #() global instFctSet = #() global instRolloutSet = #() global objWithInst = #() global currentSelectedInst = 1 global objectAsLevel = undefined global currentChunkBuf = undefined ------------------------------------------------------------------------------- -- Reading CK Buffer Functions ------------------------------------------------------------------------------- fn GetCKChunk obj chunkKey = ( local buf = getUserPropBuffer obj if (buf==undefined) do return undefined local startIndex = findString buf (CKCHUNKBEGINSTR + " \"" + chunkKey + "\"") if (startIndex==undefined) do return undefined local endIndex = findstring buf CKCHUNKENDSTR if (endIndex==undefined) do return undefined endIndex += CKCHUNKENDSTR.count return (substring buf startIndex (endIndex-startIndex)) ) fn ReadCKBufValue paramString paramIsInst:false = ( if (currentChunkBuf==undefined) do return undefined if (paramString==undefined) do return undefined local strToFind = if paramIsInst then (paramString+"(\"") else ("\""+paramString+"\", \"") local tmp = findstring currentChunkBuf strToFind if (tmp==undefined) do return undefined tmp += strToFind.count local buf = substring currentChunkBuf tmp -1 tmp = findstring buf "\"" if (tmp==undefined) do return undefined return substring buf 1 (tmp-1) ) fn ReadCKBufValueAsNumber paramString = ( local str = ReadCKBufValue paramString if (str==undefined) do return undefined return (execute str) ) fn ReadCKBufValueAsVector paramString = ( local str = ReadCKBufValue paramString if (str==undefined) do return undefined return (execute ("["+str+"]")) ) fn ReadCKBufValueAsAngle paramString = ( local str = ReadCKBufValue paramString if (str==undefined) do return undefined -- Angles are always written "0:angle" return (execute (substring str 3 -1)) ) fn ReadCKBufValueAsTime paramString = ( local str = ReadCKBufValue paramString if (str==undefined) do return undefined -- Times are always written "0m times 0ms" local tmp = findstring str "s 0ms" return (execute (substring str 4 (tmp-4))) ) fn ReadCKBufValueAsBool paramString = ( local str = ReadCKBufValue paramString if (str==undefined) do return undefined if (str=="TRUE") then (return true) else (return false) ) ------------------------------------------------------------------------------- -- Convenient Conversion Functions ------------------------------------------------------------------------------- fn posAsVirtools v = ( (v.x as string) + "," + (v.z as string) + "," + (v.y as string) ) fn boolAsVirtools b = ( if b then (return "TRUE") else (return "FALSE") ) fn matrixInParentAsVirtools obj = ( m = if (obj.parent==undefined) then (obj.transform) else (obj.transform * inverse (obj.parent.transform) ) local row1 = m.row1 local row2 = m.row2 local row3 = m.row3 local row4 = m.row4 local str = "[" + (row1.x as string) + "," + (row1.z as string) + "," + (row1.y as string) + ",0]" str += "[" + (row3.x as string) + "," + (row3.z as string) + "," + (row3.y as string) + ",0]" str += "[" + (row2.x as string) + "," + (row2.z as string) + "," + (row2.y as string) + ",0]" str += "[" + (row4.x as string) + "," + (row4.z as string) + "," + (row4.y as string) + ",1]" return str ) ------------------------------------------------------------------------------- -- Export Options Rollout ------------------------------------------------------------------------------- rollout VirtoolsExportOpt "Export Options" width:408 height:500 category:0 rolledup:true ( radiobuttons exportas_Radio "" pos:[8,8] width:126 height:48 enabled:true labels:#("Export as Objects", "Export as a Character", "Export Animation Only") default:1 columns:1 edittext charname_Edit "Character Name: " text:"Character" pos:[200,16] width:191 height:16 enabled:false fieldwidth:200 edittext animname_Edit "Animation Name: " text:"Animation" pos:[200,40] width:191 height:16 enabled:true fieldwidth:150 GroupBox generaloptions_Group "General Options" pos:[8,72] width:208 height:96 checkbox onlytexturefilenames_Check "Store only texture filenames" pos:[22,90] width:154 height:16 checkbox rescale_Check "Rescale scene to 1 unit = 1 meter" pos:[22,109] width:184 height:16 checkbox placeasroup_Check "Convert group to places" pos:[22,128] width:152 height:16 checkbox selectiontogroup_Check "Named selections to groups" pos:[22,147] width:152 height:16 default:true GroupBox physique_Group "Physique conversion" pos:[224,72] width:168 height:56 radiobuttons convert_Radio "" pos:[232,88] width:154 height:32 enabled:true labels:#("Convert to Skin", "Convert to Morph Animation") default:1 columns:1 GroupBox biped_Group "Biped options" pos:[224,128] width:168 height:40 checkbox savebiped_Check "Save biped geometry" pos:[232,146] width:152 height:16 GroupBox line1_Group "" pos:[-4,58] width:410 height:8 GroupBox line2_Group "" pos:[-4,170] width:410 height:8 GroupBox grp22 "Controllers Output" pos:[8,184] width:384 height:96 label only_Label "Only Linear,TCB and Bezier controllers are supported; other controllers will be converted to Linear animation or morph Animation (Mesh modifiers) using the given sampling step:" pos:[16,202] width:196 height:70 label sampling_Label "Sampling Step for..." pos:[279,203] width:98 height:18 spinner sampstepforcontrollers_Spin "Controllers:" pos:[280,227] width:100 height:16 range:[0,10000,3] type:#integer fieldwidth:40 spinner sampstepfordeformables_Spin "Deformable Objects:" pos:[280,249] width:100 height:16 range:[0,10000,3] type:#integer fieldwidth:40 on exportas_Radio changed stat do ( if stat==2 then charname_Edit.enabled=true else charname_Edit.enabled=false ) ) ------------------------------------------------------------------------------- -- Export Process Rollout ------------------------------------------------------------------------------- rollout VirtoolsExportProcess "Export Process" width:408 height:86 category:0 ( spinner report_Spin "" pos:[104,34] width:48 height:16 range:[0,3,0] type:#integer spinner compression_Spin "" text:"3" pos:[104,8] width:48 height:16 range:[0,9,6] type:#integer label report_Label "Report log detail level: (0 for no log)" pos:[9,26] width:95 height:26 label compression_Label "Compression level:" pos:[9,8] width:95 height:16 button export_Button "Export" pos:[309,6] width:88 height:20 checkbox onlySelected_Check "Only Selected" pos:[215,10] width:88 height:16 button exactPreview_Button "Exact Preview" pos:[309,32] width:88 height:20 button quickPreview_Button "Quick Preview" pos:[212,32] width:88 height:20 Timer closePreview_Timer "" pos:[360,58] width:24 height:24 interval:50 active:true on export_Button pressed do ( local fileName if( alreadyGivenFileName==undefined ) then ( fileName = getsavefilename caption:"Virtools Export" \ types:"Virtools Export (*.NMO)|*.nmo|Virtools Viewer Export (*.VMO)|*.vmo"\ ) else ( fileName = alreadyGivenFileName alreadyGivenFileName = undefined ) if fileName != undefined do ( filetype = getfilenametype filename if filetype == "" do filename += ".nmo" setwaitcursor() exportFct fileName setarrowcursor() ) ) on exactPreview_Button pressed do ( previewFct() ) on quickPreview_Button pressed do ( quickPreviewFct() ) on closePreview_Timer tick do ( if not Virtools_Preview.open do ( removerollout Virtools_Preview VirtoolsWindow ) ) ) ------------------------------------------------------------------------------- -- Write Settings in the Configuration file ------------------------------------------------------------------------------- fn WriteConfig = ( local version = getINIsetting configFileName configSettingSection "Version" if (version!="2") do (createfile configFileName) setINIsetting configFileName configSettingSection "Version" "2" setINIsetting configFileName configSettingSection "Export As" (VirtoolsExportOpt.exportas_Radio.state as string) setINIsetting configFileName configSettingSection "Character Name" (VirtoolsExportOpt.charname_Edit.text as string) setINIsetting configFileName configSettingSection "Animation Name" (VirtoolsExportOpt.animname_Edit.text as string) setINIsetting configFileName configSettingSection "Only Texture Filenames" (VirtoolsExportOpt.onlytexturefilenames_Check.state as string) setINIsetting configFileName configSettingSection "Rescale" (VirtoolsExportOpt.rescale_Check.state as string) setINIsetting configFileName configSettingSection "Group To Place" (VirtoolsExportOpt.placeasroup_Check.state as string) setINIsetting configFileName configSettingSection "Selection To Group" (VirtoolsExportOpt.selectiontogroup_Check.state as string) setINIsetting configFileName configSettingSection "Physique Conversion" (VirtoolsExportOpt.convert_Radio.state as string) setINIsetting configFileName configSettingSection "Sampling Controllers" (VirtoolsExportOpt.sampstepforcontrollers_Spin.value as string) setINIsetting configFileName configSettingSection "Sampling Deformables" (VirtoolsExportOpt.sampstepfordeformables_Spin.value as string) setINIsetting configFileName configSettingSection "Compression level" (VirtoolsExportProcess.compression_Spin.value as string) setINIsetting configFileName configSettingSection "Report level" (VirtoolsExportProcess.report_Spin.value as string) setINIsetting configFileName configSettingSection "Only Selected" (VirtoolsExportProcess.onlySelected_Check.state as string) ) ------------------------------------------------------------------------------- -- Read Settings in the Configuration file ------------------------------------------------------------------------------- fn ReadConfig = ( local version = getINIsetting configFileName configSettingSection "Version" if (version!="2") do (return false) VirtoolsExportOpt.exportas_Radio.state = (getINIsetting configFileName configSettingSection "Export As") as integer VirtoolsExportOpt.charname_Edit.text = (getINIsetting configFileName configSettingSection "Character Name") VirtoolsExportOpt.animname_Edit.text = (getINIsetting configFileName configSettingSection "Animation Name") VirtoolsExportOpt.onlytexturefilenames_Check.state = (getINIsetting configFileName configSettingSection "Only Texture Filenames")=="true" VirtoolsExportOpt.rescale_Check.state = (getINIsetting configFileName configSettingSection "Rescale")=="true" VirtoolsExportOpt.placeasroup_Check.state= (getINIsetting configFileName configSettingSection "Group To Place")=="true" VirtoolsExportOpt.selectiontogroup_Check.state = (getINIsetting configFileName configSettingSection "Selection To Group")=="true" VirtoolsExportOpt.convert_Radio.state = (getINIsetting configFileName configSettingSection "Physique Conversion") as integer VirtoolsExportOpt.sampstepforcontrollers_Spin.value = (getINIsetting configFileName configSettingSection "Sampling Controllers") as integer VirtoolsExportOpt.sampstepfordeformables_Spin.value = (getINIsetting configFileName configSettingSection "Sampling Deformables") as integer VirtoolsExportProcess.compression_Spin.value = (getINIsetting configFileName configSettingSection "Compression level") as integer VirtoolsExportProcess.report_Spin.value = (getINIsetting configFileName configSettingSection "Report level") as integer VirtoolsExportProcess.onlySelected_Check.state = (getINIsetting configFileName configSettingSection "Only Selected")=="true" ) ------------------------------------------------------------------------------- -- Export function -- it can be called when hiting Export button, Quick Preview button or Exact -- Preview buttton. ------------------------------------------------------------------------------- fn exportFct fileName = ( -- Really Do Export WriteConfig() export2nmo fileName \ VirtoolsExportProcess.onlySelected_Check.checked \ VirtoolsExportOpt.exportas_Radio.state \ VirtoolsExportOpt.onlytexturefilenames_Check.checked \ VirtoolsExportOpt.rescale_Check.checked \ VirtoolsExportOpt.placeasroup_Check.checked \ VirtoolsExportOpt.selectiontogroup_Check.checked \ (VirtoolsExportOpt.convert_Radio.state == 1) \ VirtoolsExportOpt.savebiped_Check.checked \ VirtoolsExportOpt.sampstepforcontrollers_Spin.value \ VirtoolsExportOpt.sampstepfordeformables_Spin.value \ VirtoolsExportProcess.compression_Spin.value\ VirtoolsExportProcess.report_Spin.value\ VirtoolsExportOpt.charname_Edit.text\ VirtoolsExportOpt.animname_Edit.text ) ------------------------------------------------------------------------------- -- Preview Function ------------------------------------------------------------------------------- fn previewFct = ( setwaitcursor() exportFct previewFileName if Virtools_Preview.open then ( Virtools_Preview.ax.load previewFileName ) else ( addrollout Virtools_Preview VirtoolsWindow ) setarrowcursor() ) ------------------------------------------------------------------------------- -- Get Level Object ------------------------------------------------------------------------------- fn GetLevelObject = ( local virtoolsGlobalHelper = $VirtoolsGlobalHelper if (virtoolsGlobalHelper!=undefined) do return (objectAsLevel=virtoolsGlobalHelper) if (geometry==undefined) do return (objectAsLevel=undefined) if (geometry!=undefined and geometry.count!=0) then ( objectAsLevel=geometry[1] ) else if (ligths!=undefined and ligths.count!=0) then ( objectAsLevel=lights[1] ) else if (cameras!=undefined and cameras.count!=0) then ( objectAsLevel=cameras[1] ) else if (helpers!=undefined and helpers.count!=0) then ( objectAsLevel=helpers[1] ) else if (shapes!=undefined and shapes.count!=0) then ( objectAsLevel=shapes[1] ) else undefined objectAslevel ) ------------------------------------------------------------------------------- -- Quick Preview Function ------------------------------------------------------------------------------- fn quickPreviewFct = ( -------------------- -- Add Instructions if (GetLevelObject()==undefined) do return -- set camera activeCamera = undefined orbitCamera = undefined createdCamera = undefined local centerToLookAt = geometry.center if (selection.count!=0) do centerToLookAt = selection.center if (cameras.count!=0) then ( activeCamera = cameras[1] orbitCamera = activeCamera if (activeCamera.parent!=undefined) do ( if activeCamera.parent.isAnimated do (orbitCamera=undefined) ) if ( (findstring (getUserPropBuffer orbitCamera) CKCHUNKBEGINSTR)!=undefined ) do (orbitCamera=undefined) ) else ( if not gw.isperspview() do ( for a=1 to viewport.numviews do ( viewport.activeViewport = a if gw.isperspview() do exit ) ) orbitCamera = freecamera name:"Camera01" if gw.isperspview() then ( orbitCamera.fov = getviewfov() orbitCamera.transform = Inverse(getviewTM()) orbitCamera.pos = (Inverse(getViewTM())).row4 ) else ( orbitCamera.pos = geometry.max orbitCamera.dir = centerToLookAt orbitCamera.fov = 45.0 ) createdCamera = orbitCamera activeCamera = orbitCamera selectMore createdCamera ) if (orbitCamera!=undefined) do ( chunkData = " " + CKAttacheScriptOnThisStr + "(\"Camera Orbit\")\x0d\x0a" chunkData += " " + CKSetParamOnThisStr + "(\"Center To Look At\", \"" + (posAsVirtools centerToLookAt) + "\" )\x0d\x0a" AddCKChunk activeCamera "Quick Preview Camera Orbit" chunkData ) if (activeCamera!=undefined) do ( chunkData = " " + CKAttacheScriptOnThisStr + "(\"set_as_active_camera\")\x0d\x0a" AddCKChunk activeCamera "Quick Preview Active Camera" chunkData ) -- set light createdLight = undefined if (lights.count==0) do ( createdLight = omnilight name:"Omni01" color:[255,255,255] createdLight.pos = activeCamera.pos createdLight.parent = activeCamera selectMore createdLight ) -- set animation if (objectAsLevel!=undefined) do ( -- chunkData = " " + CKAttacheScriptOnThisStr + "(\"Play Global Animation\")\x0d\x0a" -- chunkData += " " + CKSetParamOnThisStr + "(\"Global Animation Name\", \"CK_EXPORTEDANIMATION\" )\x0d\x0a" -- duration = (animationrange.end.frame-animationrange.start.frame)/(framerate * 0.125 * pow 2 timeconfiguration.playbackspeed) -- chunkData += " " + CKSetParamOnThisStr + "(\"Global Animation Duration\", \"0m " + (duration as string) + "s 0ms\" )\x0d\x0a" -- AddCKChunk objectAsLevel "Quick Preview Play Global Animation" chunkData ) ----------- -- Preview previewFct () ------------------------------ -- Remove Added Intstructions if (activeCamera!=undefined) do (RemoveCKChunk activeCamera "Quick Preview Active Camera"; activeCamera=undefined) if (orbitCamera!=undefined) do (RemoveCKChunk orbitCamera "Quick Preview Camera Orbit"; orbitCamera=undefined) if (createdCamera!=undefined) do (delete createdCamera; createdCamera=undefined) if (createdLight!=undefined) do (delete createdLight; createdLight=undefined) if (objectAsLevel!=undefined) do (RemoveCKChunk objectAsLevel "Quick Preview Play Global Animation"; objectAsLevel=undefined) updateInstructionsList() ) ------------------------------------------------------------------------------- -- Preview Rollout ------------------------------------------------------------------------------- rollout Virtools_Preview "Preview" width:408 height:300 category:0 ( ActiveXControl ax "{C4925E65-7A1E-11D2-8BB4-00A0C9CC72C3}" pos:[4,4] width:394 height:298 align:#left setupEvents:false on Virtools_Preview open do ( ax.allowpause = 1 ax.src = previewFileName ax.keepkeyboard = 0 ax.AllowFullScreen = 0 enableAccelerators = false ) ) ------------------------------------------------------------------------------- -- Instructions Manager ------------------------------------------------------------------------------- rollout VirtoolsInstructionsManager "Instructions Manager" width:408 height:178 category:1 ( listbox instructionsApplied_List "Applied Instructions:" pos:[232,8] width:162 height:6 button removeInst_Button "Remove" pos:[232,114] width:78 height:24 enabled:false button removeAllInst_Button "Remove All" pos:[314,114] width:80 height:24 enabled:false GroupBox sepInstList_Group "" pos:[204,0] width:1 height:140 listbox instructions_List " " pos:[12,8] width:162 height:8 checkbutton instset_Check "Instruction Set:" pos:[12,8] width:80 height:16 checked:true checkbutton objlist_Check "Object List:" pos:[94,8] width:80 height:16 -------------------------------------- -- Update Instruction Set List -------------------------------------- fn updateInstSetList = ( instructions_List.selection = 0 if instset_Check.checked then ( instructions_List.items = instNameSet ) else ( objWithInst = #() for obj in objects do ( buf = getUserPropBuffer obj tmpStart = findstring buf CKCHUNKBEGINSTR if (tmpStart!=undefined) do ( objWithInst += #(obj) ) ) instructions_List.items = #() n=1 for obj in objWithInst do ( if obj!=undefined do ( instructions_List.items += #(obj.name) n += 1 ) ) ) updateInstructionsList() ) on instset_Check changed state do ( objlist_Check.checked = not state updateInstSetList() ) on objlist_Check changed state do ( instset_Check.checked = not state updateInstSetList() ) on instructionsApplied_List selected index do ( if instset_Check.checked do (instructions_List.selection=0) removeInst_Button.enabled = true removeAllInst_Button.enabled = true currentSelectedInst = finditem instNameSet (instructionsApplied_List.selected) if( currentSelectedInst!=0 ) do ( instRollout = instRolloutSet[currentSelectedInst] if (currentRollout!=instRollout) then ( if( currentRollout!=unsupplied ) do ( removerollout currentRollout VirtoolsWindow ) ) if (instRollout!=unsupplied) do ( addrollout instRollout VirtoolsWindow currentRollout = instRollout instRollout.UpdateFromChunk() ) ) ) on instructions_List selected index do ( if instset_Check.checked then ( -- Instruction List case currentSelectedInst = index instRollout = instRolloutSet[index] if (currentRollout!=instRollout) then ( if (currentRollout!=unsupplied) do ( removerollout currentRollout VirtoolsWindow ) ) else ( ) if (instRollout!=unsupplied) do ( addrollout instRollout VirtoolsWindow currentRollout = instRollout ) ) else ( -- Object List case select objWithInst[instructions_List.selection] ) instructionsApplied_List.selection = 0 removeInst_Button.enabled = false removeAllInst_Button.enabled = false ) on instructions_List doubleClicked index do ( if instset_Check.checked do ( -- Instruction List case currentSelectedInst = index (instFctSet[index])() ) ) on removeInst_Button pressed do ( if( ($!=undefined) and (instructionsApplied_List.selection!=0) ) do ( RemoveCKChunk $ instructionsApplied_List.selected updateInstSetList() ) ) on removeAllInst_Button pressed do ( if( $ != undefined ) do ( while( (RemoveCKChunk $ "") != undefined ) do () updateInstSetList() ) ) ) ------------------------------------------------------------------------------- -- Add CK CHUNK ------------------------------------------------------------------------------- fn AddCKChunk obj chunkKey chunkData AllowMultipleChunk:false = ( -- as we add some instruction, we can then create the virtools global helper -- if it doesn't exists local virtoolsGlobalHelper = $VirtoolsGlobalHelper if (virtoolsGlobalHelper==undefined) do (dummy name:"VirtoolsGlobalHelper" pos:[0,0,-100] scale:[0.1,0.1,0.1]) if (obj==undefined) do (obj=virtoolsGlobalHelper) buf = getUserPropBuffer obj if not AllowMultipleChunk do ( local startIndex = findString buf (CKCHUNKBEGINSTR + " \"" + chunkKey + "\"") if( startIndex != undefined ) do return ok ) buf += CKCHUNKBEGINSTR + " \"" + chunkKey + "\"\x0d\x0a" buf += chunkData buf += CKCHUNKENDSTR + "\x0d\x0a" setUserPropBuffer obj buf ) ------------------------------------------------------------------------------- -- Remove CK CHUNK -- if chunkey == "" removes the first CKCHUNK found -- return value = index of the found CKCHUNK, undefined if not found ------------------------------------------------------------------------------- fn RemoveCKChunk obj chunkKey = ( buf = getUserPropBuffer obj -- remove doubled carriage return local tmpIndex = findstring buf "\x0d\x0a\x0d\x0a" while (tmpIndex!=undefined) do ( buf = replace buf tmpIndex 4 "\x0d\x0a" tmpIndex = findstring buf "\x0d\x0a\x0d\x0a" ) -- local startIndex if( chunkKey=="" ) then ( startIndex = findString buf CKCHUNKBEGINSTR ) else ( startIndex = findString buf (CKCHUNKBEGINSTR + " \"" + chunkKey + "\"") ) if( startIndex != undefined ) do ( buf1 = substring buf 1 (startIndex-1) buf = substring buf startIndex -1 endIndex = (findstring buf CKCHUNKENDSTR) + CKCHUNKENDSTR.count if( endIndex != undefined ) do ( buf2 = substring buf endIndex -1 setUserPropBuffer obj (buf1+buf2) ) ) startIndex ) ------------------------------------------------------------------------------- -- Update Applied Instructions List ------------------------------------------------------------------------------- fn updateInstructionsList = ( local instructionStr = undefined instructionList = #() if( selection.count==1 ) do ( buf = getUserPropBuffer selection[1] tmpStart = findstring buf (CKCHUNKBEGINSTR+" \"") while (tmpStart!=undefined) do ( tmpStart += (CKCHUNKBEGINSTR+" \"").count buf = substring buf tmpStart -1 tmpEnd = findstring buf "\"" if (tmpEnd!=undefined) do ( instructionStr = substring buf 1 (tmpEnd-1) append instructionList instructionStr ) tmpStart = findstring buf (CKCHUNKBEGINSTR+" \"") ) if not VirtoolsInstructionsManager.instset_Check.checked do ( VirtoolsInstructionsManager.instructions_List.selection = 0 if instructionStr!=undefined do ( local tmp = finditem (VirtoolsInstructionsManager.instructions_List.items) (selection[1].name) VirtoolsInstructionsManager.instructions_List.selection = tmp ) ) ) VirtoolsInstructionsManager.instructionsApplied_List.items = instructionList VirtoolsInstructionsManager.instructionsApplied_List.selection = 0 VirtoolsInstructionsManager.removeInst_Button.enabled = false VirtoolsInstructionsManager.removeAllInst_Button.enabled = false ) ------------------------------------------------------------------------------- -- Register Instruction Function ------------------------------------------------------------------------------- fn registerInstruction instName instFct instRollout: instReadFct: = ( append instNameSet instName append instFctSet instFct append instRolloutSet instRollout if VirtoolsInstructionsManager.instset_Check.state do ( VirtoolsInstructionsManager.instructions_List.items += #(instName) ) ) VirtoolsWindow = newrolloutfloater "Virtools Exporter" 428 600 0 1 addrollout VirtoolsExportOpt VirtoolsWindow addrollout VirtoolsExportProcess VirtoolsWindow addrollout VirtoolsInstructionsManager VirtoolsWindow ReadConfig() VirtoolsInstructionsManager.instructions_List.selection = 0 VirtoolsInstructionsManager.instructionsApplied_List.selection = 0 callbacks.removeScripts #selectionsetchanged id:#VirtoolsUpdateList callbacks.addScript #selectionsetchanged "updateInstructionsList()" id:#VirtoolsUpdateList callbacks.broadcastCallback #selectionsetchanged ------------------------------------------------------------------------------- -- Register Instructions ------------------------------------------------------------------------------- files = getFiles (CKInstPath+"CK_*.ms") for f in files do ( filein f )