home *** CD-ROM | disk | FTP | other *** search
/ Photography Workshop / PhotoWorkShop.iso / pc / Content / Decisive / Decisive.cst / 00001_Decisive Script.ls next >
Encoding:
Text File  |  2002-04-11  |  7.1 KB  |  229 lines

  1. property ancestor
  2. property ShutterModeButtons, ClapperButton, ShutterButton
  3. property theVideo
  4. property currentSlideID
  5. property slideHotSpots, images
  6. property slideBackgrounds
  7. property frameList, framecount
  8. property savedClapperPosition, savedShutterPosition, savedImagePosition
  9. property savedSlideBackgroundPosition
  10. property savedSlidePositions
  11. property lastShutterClick
  12. property slidesets
  13.  
  14. global pageChannels
  15. global folderSeparator
  16.  
  17. on Birth me, theChannelObject, theName, thePageInfo
  18.   
  19.   -- muck around the channel allocator around to give this workshop more channels
  20.   set the ancestor of me to Birth( script "Master Page Template", theChannelObject, theName, thePageInfo, true, true )
  21.   
  22.   set the subject of me to "D1"
  23.   
  24.   set ClapperButton to FindButton( me, "Clap" )
  25.   set savedClapperPosition to the location of ClapperButton
  26.   
  27.   
  28.   set ShutterButton to FindButton( me, "Shu" )
  29.   set the soundname of shutterbutton to "shutter Click"
  30.   set the repeatable of shutterbutton to true
  31.   set the repeatrate of shutterbutton to 60
  32.   set the nowait of shutterbutton to true
  33.   set the immediate of shutterButton to true
  34.   set savedShutterPosition to the location of ShutterButton
  35.   Move( ShutterButton, Point(-100,-100) )
  36.   set lastShutterClick to the ticks
  37.   
  38.   set currentSlideID to 1
  39.   set theVideo to FindDisplay( me, "DecisiveVideo" )  
  40.   SetVideoCastName( theVideo, "D1.MOV" )
  41.   Move( theVideo, Point(-1000,1000) )
  42.   
  43.   set savedImagePosition to the location of the image of me
  44.   
  45.   set slideBackgrounds to FindDisplay( me, "Slides" )
  46.   SetInk( slideBackgrounds, #Copy )
  47.   set savedSlideBackgroundPosition to the location of slideBackgrounds
  48.   Hide( slideBackgrounds )
  49.   
  50.   set slideHotSpots to []
  51.   set images to [:]
  52.   set savedSlidePositions to []
  53.   repeat with i = 1 to 10
  54.     set thisImage to FindDisplay( me, "T" & i )
  55.     set thisSlide to FindButton( me, "Slide" & i )
  56.     add( savedSlidePositions, the location of thisSlide )
  57.     SetCastName( thisImage, "T" & i )
  58.     set the name of thisSlide to "Slide"
  59.     SetState( thisSlide, "Disabled" )
  60.     addprop( images, thisImage, the subject of me & "B_001.pic" )
  61.     add( slideHotSpots, thisSlide )
  62.   end repeat
  63.   
  64.   set slidesets to []
  65.   setAt( slidesets, 1, [3] )
  66.   setAt( slidesets, 2, [3, 4] )
  67.   setAt( slidesets, 3, [2, 3, 4] )
  68.   setAt( slidesets, 4, [2, 3, 4, 5] )
  69.   setAt( slidesets, 5, [1, 2, 3, 4, 5] )
  70.   setAt( slidesets, 6, [1, 2, 3, 4, 5, 8] )
  71.   setAt( slidesets, 7, [1, 2, 3, 4, 5, 8, 9] )
  72.   setAt( slidesets, 8, [1, 2, 3, 4, 5, 7, 8, 9] )
  73.   setAt( slidesets, 9, [1, 2, 3, 4, 5, 7, 8, 9, 10] )
  74.   setAt( slidesets, 10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )
  75.   
  76.   ClearSlides me
  77.   Show me
  78.   return me
  79. end
  80.  
  81. on SetImages me
  82.   set framecount to count( FrameList )
  83.   if framecount > 10 then set frameCount to 10
  84.   
  85.   if frameCount > 0 then
  86.     SetCastName( slideBackgrounds, "Slide" & frameCount )
  87.     Show( slideBackgrounds )
  88.     
  89.     set thisSlideSet to getat( slidesets, frameCount )
  90.     
  91.     repeat with i = 1 to framecount
  92.       set thisFrame to getat( FrameList, i )
  93.       set thisImage to getpropat( images, getat( thisSlideSet, i ) )
  94.       set thisSlide to getat( slideHotSpots, getat( thisSlideSet, i ) )
  95.       
  96.       set frameStr to string( thisFrame )      
  97.       set frameLength to the number of chars in frameStr
  98.       repeat with j = 1 to 3 - frameLength
  99.         put "0" before frameStr
  100.       end repeat
  101.       set theImageName to the subject of me & "B_" & frameStr & ".pic"
  102.       setprop( images, thisImage, theImageName )
  103.       
  104.       set theImageName to the subject of me & "T_" & frameStr & ".pic"
  105.       SetCastName( thisImage, theImageName )
  106.       set the location of thisImage to the location of thisSlide
  107.       Show( thisImage )
  108.       SetState( thisSlide, "Enabled" )
  109.     end repeat
  110.     Move( slideBackgrounds, savedSlideBackgroundPosition )
  111.   end if
  112. end
  113.  
  114. on PageIdle me
  115.   PageIdle( the ancestor of me )
  116.   if the playing of theVideo = true then
  117.     if the currentstate of shutterbutton = "Disabled" then
  118.       if the ticks - lastShutterClick > the repeatrate of shutterbutton then
  119.         SetState( shutterButton, "Enabled" )
  120.         if the mousedown = true then
  121.           PageHit( me )
  122.         end if
  123.       end if
  124.     end if
  125.     
  126.     if VideoIdle( theVideo ) = #Stopped then
  127.       Move( ClapperButton, savedClapperPosition )
  128.       Move( ShutterButton, Point(-1000,1000) )
  129.       Move( theVideo, Point(-1000,1000) )
  130.       
  131.       Setimages me
  132.       set currentSlideID to 1
  133.       show( me )      
  134.       UpdateButtonBar
  135.       UpdateStage
  136.     end if
  137.   end if
  138. end
  139.  
  140. on ClearSlides me
  141.   repeat with i = 1 to 10
  142.     Move( getpropat( images, i ), Point(-1000,0) )
  143.     SetState( getat( slideHotSpots, i ), "Disabled" )
  144.   end repeat
  145.   Move( slideBackgrounds, Point(-1000,0) )
  146. end
  147.  
  148. on ResetDecisivePage me
  149.   Move( ShutterButton, savedShutterPosition )
  150.   SetState( ShutterButton, "Enabled" )
  151.   Move( ClapperButton, point(-1000,-1000) )
  152.   Show( ShutterButton )
  153.   Hide( slideBackgrounds )
  154.   Move( theVideo, savedImagePosition )
  155.   ClearSlides me
  156.   updatestage
  157.   set the playing of theVideo to true -- so updatebuttonbar will do the right thing
  158.   UpdateButtonBar
  159.   start( theVideo )
  160.   set framelist to []
  161.   put "reseting video"
  162. end
  163.  
  164. on GetState me, buttonID
  165.   if the playing of theVideo = true then
  166.     case ( buttonid ) of
  167.       #Basics, #TeachMes, #GoBack, #ProTips, #RelatedTopics, #Subjects, #Guide, #GoUp, #Subjects, #GoAway, #GoAhead, #Pause:
  168.         return 0
  169.     end case
  170.   else
  171.     return StandardGetState( me, buttonID )
  172.   end if
  173. end
  174.  
  175. on ChangePage me, theElementID, theValue1, theValue2
  176.   case theElementID of
  177.     #Subject:
  178.       ClearSlides me
  179.   end case
  180.   
  181.   ChangePage( the ancestor of me, theElementID, theValue1, theValue2 )
  182.   
  183.   case theElementID of
  184.     #Subject:
  185.       SetVideoCastName( theVideo, the subject of me & ".MOV" )
  186.       Move( theVideo, Point(-1000,1000) )
  187.       set theImageName to the subject of me & "B_001.pic"
  188.       set currentSlideID to 1
  189.       setprop( images, getpropat( images, 1 ), theImageName )
  190.       ShowImage( me )
  191.       
  192.     #Image:
  193.       --put "Image change" && theValue1
  194.       set currentSlideID to value(theValue1)
  195.       show( me )      
  196.       
  197.     #Shutter:
  198.       Add( FrameList, GetFrameNumber( theVideo ) )
  199.       SetState( ShutterButton, "Disabled" )
  200.       set lastShutterClick to the ticks
  201.       
  202.     #Clapper:
  203.       --put "hit clapper"
  204.       ResetDecisivePage me
  205.   end case
  206. end
  207.  
  208. on buildimagename me
  209.   put "currentSlideID" && currentSlideID
  210.   set thisImageName to getat( images, currentSlideID )
  211.   put "thisImageName" && thisImageName
  212.   return thisImageName
  213. end
  214.  
  215. on ImportImages SubjectName, startCastIndex, startImageIndex, endImageIndex
  216.   set fileNamePrefix to "Programming:New Art:vollyball:D3_T:"
  217.   repeat with i = startImageIndex to endImageIndex
  218.     set indexString to string(i)
  219.     repeat while the number of chars in indexString < 3
  220.       put "0" before indexString
  221.     end repeat
  222.     set filename to  subjectName & "_" & indexString & ".pic"    
  223.     importFileInto member startCastIndex of castlib "Decisive", fileNamePrefix & fileName
  224.     put "T" after char 2 of filename
  225.     set the name of member startCastIndex of castlib "Decisive" to filename
  226.     put fileName && the result
  227.     set startCastIndex to startCastIndex + 1
  228.   end repeat
  229. end