home *** CD-ROM | disk | FTP | other *** search
/ Better Homes & Gardens: …oking for Today - Chicken / Image.iso / pc / main.dxr / 00001_movie.ls next >
Encoding:
Text File  |  1995-11-20  |  14.4 KB  |  548 lines

  1. on startMovie
  2.   global gFirstMainRun, gOldPage1, gOldPage2, gOldPage4, gCFTBundle, gShadowSprite, gScrollSprite, gPhotoSprite, gLastRecipeLine, gHelpSprite, gFromRecipeP, gLastIndexButton
  3.   set the textHeight of field "current recipe" to 10
  4.   if gFirstMainRun then
  5.     set gFirstMainRun to 0
  6.     if the machineType = 256 then
  7.       set the textHeight of field "scroll" to 14
  8.       set the textSize of field "scroll" to 12
  9.       set the textStyle of field "scroll" to "plain"
  10.       set the textFont of field "scroll" to "arial"
  11.       set the textHeight of field "scrollShadow" to 14
  12.       set the textSize of field "scrollShadow" to 12
  13.       set the textStyle of field "scrollShadow" to "bold"
  14.       set the textFont of field "scrollShadow" to "arial"
  15.     else
  16.       set the textHeight of field "scroll" to 14
  17.       set the textSize of field "scroll" to 12
  18.       set the textStyle of field "scroll" to "plain"
  19.       set the textFont of field "scroll" to "helvetica"
  20.       set the textHeight of field "scrollShadow" to 14
  21.       set the textSize of field "scrollShadow" to 12
  22.       set the textStyle of field "scrollShadow" to "bold"
  23.       set the textFont of field "scrollShadow" to "helvetica"
  24.     end if
  25.   end if
  26.   set gOldPage1 to 0
  27.   set gOldPage2 to 0
  28.   set gOldPage4 to 0
  29.   cursor(-1)
  30.   set gShadowSprite to 2
  31.   set gScrollSprite to 3
  32.   set gPhotoSprite to 12
  33.   set gLastRecipeLine to 1
  34.   set gHelpSprite to 44
  35.   helpOff()
  36.   if gFromRecipeP then
  37.     backIndex()
  38.   else
  39.     set gLastIndexButton to EMPTY
  40.     main()
  41.   end if
  42. end
  43.  
  44. on stopMovie
  45.   unLoadCast()
  46.   cleanLegos()
  47.   helpOff()
  48.   set the keyDownScript to EMPTY
  49. end
  50.  
  51. on makeScroll
  52.   global gIndexScroll, gScrollSprite, gShadowSprite
  53.   set spriteList to [gShadowSprite]
  54.   set track to new("Button", [#spriteChan: 7])
  55.   set ball to new("Button", [#spriteChan: 8, #pressedCast: 64])
  56.   set up to new("Button", [#spriteChan: 9, #pressedCast: 66])
  57.   set down to new("Button", [#spriteChan: 10, #pressedCast: 68])
  58.   set gIndexScroll to new("ScrollBar", [#scrollSprite: gScrollSprite, #scrollLinks: spriteList, #handler: "scrollRatio", #minButton: up, #maxButton: down, #thumbButton: ball, #trackButton: track])
  59. end
  60.  
  61. on scrollRatio ratio
  62.   global gCurrentIndexRatio
  63.   set gCurrentIndexRatio to ratio
  64. end
  65.  
  66. on resetScroll textIn
  67.   global gIndexScroll
  68.   setScroll(textIn)
  69.   controlPosition(gIndexScroll, 0.0)
  70.   selectRecipe(1)
  71. end
  72.  
  73. on setScroll textIn
  74.   global gLastRecipeLine, gLastIndexChapter, gPhotoSprite, gKeySequence
  75.   set gKeySequence to EMPTY
  76.   set the keyDownScript to "keyScroll"
  77.   set gLastRecipeLine to 0
  78.   set gLastIndexChapter to textIn
  79.   set newText to field textIn
  80.   put EMPTY into field "scrollShadow"
  81.   put newText into field "scroll"
  82.   set shadowField to textIn & "Shadow"
  83.   set shadowText to field shadowField
  84.   put shadowText into field "scrollShadow"
  85.   set the textStyle of field "scrollShadow" to "bold"
  86.   put " " into field "current recipe"
  87.   set the visible of sprite gPhotoSprite to 0
  88. end
  89.  
  90. on keyScroll
  91.   global gKeySequence, gLastRecipeLine
  92.   if "abcdefghijklmnopqrstuvwxyz " contains the key then
  93.     put the key after gKeySequence
  94.     if length(gKeySequence) > 1 then
  95.       findKeyLine(gLastRecipeLine)
  96.     else
  97.       findKeyLine(1)
  98.     end if
  99.   else
  100.     if the key = BACKSPACE then
  101.       delete char -30000 of gKeySequence
  102.       findKeyLine(1)
  103.     end if
  104.   end if
  105. end
  106.  
  107. on findKeyLine begin
  108.   global gIndexScroll, gKeySequence
  109.   cursor(4)
  110.   set Index to field "scroll"
  111.   set num to the number of lines in Index
  112.   if gKeySequence <> EMPTY then
  113.     set keyCount to length(gKeySequence)
  114.     repeat with i = begin to num
  115.       if char 1 to keyCount of line i of Index = gKeySequence then
  116.         set keyLine to i
  117.         exit repeat
  118.       end if
  119.     end repeat
  120.   end if
  121.   if keyLine > 1 then
  122.     set aRatio to float(keyLine - 1) / (num - 1)
  123.     controlPosition(gIndexScroll, aRatio)
  124.     selectRecipe(keyLine)
  125.   else
  126.     set gKeySequence to EMPTY
  127.     controlPosition(gIndexScroll, 0.0)
  128.     selectRecipe(1)
  129.   end if
  130.   cursor(-1)
  131. end
  132.  
  133. on main
  134.   global gCFTBook
  135.   set the keyDownScript to EMPTY
  136.   cleanLegos()
  137.   go("main" & gCFTBook)
  138.   mainPuppetsOn()
  139. end
  140.  
  141. on backIndex
  142.   global gLastIndexChapter, gIndexScroll, gCurrentMainFrame, gCurrentIndexLine, gCurrentIndexRatio
  143.   setScroll(gLastIndexChapter)
  144.   go(gCurrentMainFrame)
  145.   makeScroll()
  146.   if gCurrentMainFrame = "PastaIndex" then
  147.     makePastaButtons()
  148.   else
  149.     if gCurrentMainFrame = "VegiIndex" then
  150.       makeVegiButtons()
  151.     else
  152.       if gCurrentMainFrame = "StirIndex" then
  153.         makeStirButtons()
  154.       else
  155.         if gCurrentMainFrame = "ChickIndex" then
  156.           makeChickButtons()
  157.         else
  158.           if gCurrentMainFrame = "PastaIndexSolo" then
  159.             makePastaButtons()
  160.           else
  161.             if gCurrentMainFrame = "VegiIndexSolo" then
  162.               makeVegiButtons()
  163.             else
  164.               if gCurrentMainFrame = "StirIndexSolo" then
  165.                 makeStirButtons()
  166.               else
  167.                 if gCurrentMainFrame = "ChickIndexSolo" then
  168.                   makeChickButtons()
  169.                 else
  170.                   if gCurrentMainFrame = "AZIndex" then
  171.                     makeAZButtons()
  172.                   end if
  173.                 end if
  174.               end if
  175.             end if
  176.           end if
  177.         end if
  178.       end if
  179.     end if
  180.   end if
  181.   controlPosition(gIndexScroll, gCurrentIndexRatio)
  182.   selectRecipe(gCurrentIndexLine)
  183. end
  184.  
  185. on PastaIndex
  186.   global gCFTBundle
  187.   cleanButtons()
  188.   cleanLegos()
  189.   setScroll("Pasta A-E")
  190.   if gCFTBundle = 1 then
  191.     go("PastaIndex")
  192.   else
  193.     go("PastaIndexSolo")
  194.   end if
  195.   makeScroll()
  196.   makePastaButtons()
  197.   scrollRatio(0.0)
  198.   selectRecipe(1)
  199. end
  200.  
  201. on VegiIndex
  202.   global gCFTBundle
  203.   cleanButtons()
  204.   cleanLegos()
  205.   setScroll("Vegi A-F")
  206.   if gCFTBundle = 1 then
  207.     go("VegiIndex")
  208.   else
  209.     go("VegiIndexSolo")
  210.   end if
  211.   makeScroll()
  212.   makeVegiButtons()
  213.   scrollRatio(0.0)
  214.   selectRecipe(1)
  215. end
  216.  
  217. on StirIndex
  218.   global gCFTBundle
  219.   cleanButtons()
  220.   cleanLegos()
  221.   setScroll("Stir A-C")
  222.   if gCFTBundle = 1 then
  223.     go("StirIndex")
  224.   else
  225.     go("StirIndexSolo")
  226.   end if
  227.   makeScroll()
  228.   makeStirButtons()
  229.   scrollRatio(0.0)
  230.   selectRecipe(1)
  231. end
  232.  
  233. on ChickIndex
  234.   global gCFTBundle
  235.   cleanButtons()
  236.   cleanLegos()
  237.   setScroll("Chick A-B")
  238.   if gCFTBundle = 1 then
  239.     go("ChickIndex")
  240.   else
  241.     go("ChickIndexSolo")
  242.   end if
  243.   makeScroll()
  244.   makeChickButtons()
  245.   scrollRatio(0.0)
  246.   selectRecipe(1)
  247. end
  248.  
  249. on AZindex
  250.   cleanButtons()
  251.   cleanLegos()
  252.   setScroll("A-C recipes")
  253.   go("AZIndex")
  254.   makeScroll()
  255.   makeAZButtons()
  256.   scrollRatio(0.0)
  257.   selectRecipe(1)
  258. end
  259.  
  260. on selectRecipe lineNum
  261.   global gCurrentBook, gCurrentRecipe, gLastRecipeLine, gCurrentIndexLine, gRecipeIDDB, gPhotoSprite
  262.   if lineNum < 1 then
  263.     exit
  264.   end if
  265.   if lineNum = 1 then
  266.     repeat while length(line lineNum of field "scroll") < 1
  267.       set lineNum to lineNum + 1
  268.     end repeat
  269.   end if
  270.   if gLastRecipeLine = lineNum then
  271.     exit
  272.   end if
  273.   set theRecipe to line lineNum of field "scroll"
  274.   if theRecipe = EMPTY then
  275.     exit
  276.   end if
  277.   set gCurrentIndexLine to lineNum
  278.   set gLastRecipeLine to lineNum
  279.   set gCurrentRecipe to getProp(gRecipeIDDB, theRecipe)
  280.   if gCurrentRecipe < 427 then
  281.     set gCurrentBook to "healthy"
  282.   else
  283.     if gCurrentRecipe < 1457 then
  284.       set gCurrentBook to "ABL"
  285.     else
  286.       if gCurrentRecipe < 1613 then
  287.         set gCurrentBook to "guide"
  288.       else
  289.         if gCurrentRecipe <= 1772 then
  290.           set gCurrentBook to "Pasta"
  291.         else
  292.           if gCurrentRecipe <= 1868 then
  293.             set gCurrentBook to "Vegi"
  294.           else
  295.             if gCurrentRecipe <= 1968 then
  296.               set gCurrentBook to "Stir"
  297.             else
  298.               if gCurrentRecipe <= 2068 then
  299.                 set gCurrentBook to "Chick"
  300.               else
  301.                 set gCurrentBook to "personal"
  302.               end if
  303.             end if
  304.           end if
  305.         end if
  306.       end if
  307.     end if
  308.   end if
  309.   updateIndexPhoto()
  310.   set the visible of sprite gPhotoSprite to 1
  311.   if the number of words in theRecipe > 3 then
  312.     if length(word 1 to 3 of theRecipe) < 28 then
  313.       put word 1 to 3 of theRecipe & "..." into field "current recipe"
  314.     else
  315.       put word 1 to 2 of theRecipe & "..." into field "current recipe"
  316.     end if
  317.   else
  318.     if length(theRecipe) < 28 then
  319.       put theRecipe into field "current recipe"
  320.     else
  321.       put word 1 to 2 of theRecipe & "..." into field "current recipe"
  322.     end if
  323.   end if
  324. end
  325.  
  326. on newDoRoll
  327.   repeat with i = 3 to 12
  328.     if rollOver(i) then
  329.       glow(i)
  330.       next repeat
  331.     end if
  332.     noGlow(i)
  333.   end repeat
  334.   updateStage()
  335. end
  336.  
  337. on glow i
  338.   if the castNum of sprite i mod 2 then
  339.     set the castNum of sprite i to the castNum of sprite i + 1
  340.   else
  341.     nothing()
  342.   end if
  343. end
  344.  
  345. on noGlow i
  346.   if the castNum of sprite i mod 2 then
  347.     nothing()
  348.   else
  349.     set the castNum of sprite i to the castNum of sprite i - 1
  350.   end if
  351. end
  352.  
  353. on mainPuppetsOn
  354.   global gAnimationSprites, gRollTitle, gPlanDay, gPlanMonth
  355.   repeat with spriteNum = 3 to 12
  356.     puppetSprite(spriteNum, 1)
  357.   end repeat
  358. end
  359.  
  360. on darkScreen
  361.   cleanLegos()
  362.   puppetSound("switch")
  363.   go("quit")
  364. end
  365.  
  366. on makePastaButtons
  367.   global gCFTBundle, gPastaButton1, gPastaButton2, gPastaButton3, gPastaButton4, gPastaButton5, gPastaButton6, gPastaButton7, gPastaButton8, gPastaButton9, gPastaButton10, gPastaButton11, gLastIndexButton
  368.   set gPastaButton1 to indexButton(18)
  369.   set gPastaButton2 to indexButton(19)
  370.   set gPastaButton3 to indexButton(20)
  371.   set gPastaButton4 to indexButton(21)
  372.   set gPastaButton5 to indexButton(22)
  373.   set gPastaButton6 to indexButton(23)
  374.   set gPastaButton7 to indexButton(24)
  375.   set gPastaButton8 to indexButton(25)
  376.   set gPastaButton9 to indexButton(26)
  377.   set gPastaButton10 to indexButton(27)
  378.   set gPastaButton11 to indexButton(28)
  379.   puppetSprite(29, 1)
  380.   if gCFTBundle = 1 then
  381.     makeBookButtons()
  382.   end if
  383.   if objectp(gLastIndexButton) then
  384.     select(gLastIndexButton)
  385.   else
  386.     select(gPastaButton1)
  387.   end if
  388. end
  389.  
  390. on makeVegiButtons
  391.   global gCFTBundle, gVegiButton1, gVegiButton2, gVegiButton3, gVegiButton4, gVegiButton5, gVegiButton6, gVegiButton7, gVegiButton8, gVegiButton9, gLastIndexButton
  392.   set gVegiButton1 to indexButton(18)
  393.   set gVegiButton2 to indexButton(19)
  394.   set gVegiButton3 to indexButton(20)
  395.   set gVegiButton4 to indexButton(21)
  396.   set gVegiButton5 to indexButton(22)
  397.   set gVegiButton6 to indexButton(23)
  398.   set gVegiButton7 to indexButton(24)
  399.   set gVegiButton8 to indexButton(25)
  400.   set gVegiButton9 to indexButton(26)
  401.   puppetSprite(27, 1)
  402.   if gCFTBundle = 1 then
  403.     makeBookButtons()
  404.   end if
  405.   if objectp(gLastIndexButton) then
  406.     select(gLastIndexButton)
  407.   else
  408.     select(gVegiButton1)
  409.   end if
  410. end
  411.  
  412. on makeStirButtons
  413.   global gCFTBundle, gStirButton1, gStirButton2, gStirButton3, gStirButton4, gStirButton5, gStirButton6, gStirButton7, gStirButton8, gStirButton9, gStirButton10, gLastIndexButton
  414.   set gStirButton1 to indexButton(18)
  415.   set gStirButton2 to indexButton(19)
  416.   set gStirButton3 to indexButton(20)
  417.   set gStirButton4 to indexButton(21)
  418.   set gStirButton5 to indexButton(22)
  419.   set gStirButton6 to indexButton(23)
  420.   set gStirButton7 to indexButton(24)
  421.   set gStirButton8 to indexButton(25)
  422.   set gStirButton9 to indexButton(26)
  423.   set gStirButton10 to indexButton(27)
  424.   puppetSprite(28, 1)
  425.   if gCFTBundle = 1 then
  426.     makeBookButtons()
  427.   end if
  428.   if objectp(gLastIndexButton) then
  429.     select(gLastIndexButton)
  430.   else
  431.     select(gStirButton1)
  432.   end if
  433. end
  434.  
  435. on makeChickButtons
  436.   global gCFTBundle, gChickButton1, gChickButton2, gChickButton3, gChickButton4, gChickButton5, gChickButton6, gChickButton7, gChickButton8, gChickButton9, gChickButton10, gChickButton11, gChickButton12, gChickButton13, gLastIndexButton
  437.   set gChickButton1 to indexButton(18)
  438.   set gChickButton2 to indexButton(19)
  439.   set gChickButton3 to indexButton(20)
  440.   set gChickButton4 to indexButton(21)
  441.   set gChickButton5 to indexButton(22)
  442.   set gChickButton6 to indexButton(23)
  443.   set gChickButton7 to indexButton(24)
  444.   set gChickButton8 to indexButton(25)
  445.   set gChickButton9 to indexButton(26)
  446.   set gChickButton10 to indexButton(27)
  447.   set gChickButton11 to indexButton(28)
  448.   set gChickButton12 to indexButton(29)
  449.   set gChickButton13 to indexButton(30)
  450.   puppetSprite(31, 1)
  451.   if gCFTBundle = 1 then
  452.     makeBookButtons()
  453.   end if
  454.   if objectp(gLastIndexButton) then
  455.     select(gLastIndexButton)
  456.   else
  457.     select(gChickButton1)
  458.   end if
  459. end
  460.  
  461. on makeAZButtons
  462.   global gCFTBundle, gAZButton1, gAZButton2, gAZButton3, gAZButton4, gAZButton5, gAZButton6, gAZButton7, gAZButton8, gAZButton9, gAZButton10, gAZButton11, gAZButton12, gAZButton13, gAZButton14, gLastIndexButton
  463.   set gAZButton1 to indexButton(18)
  464.   set gAZButton2 to indexButton(19)
  465.   set gAZButton3 to indexButton(20)
  466.   set gAZButton4 to indexButton(21)
  467.   set gAZButton5 to indexButton(22)
  468.   set gAZButton6 to indexButton(23)
  469.   set gAZButton7 to indexButton(24)
  470.   set gAZButton8 to indexButton(25)
  471.   set gAZButton9 to indexButton(26)
  472.   set gAZButton10 to indexButton(27)
  473.   set gAZButton11 to indexButton(28)
  474.   set gAZButton12 to indexButton(29)
  475.   set gAZButton13 to indexButton(30)
  476.   set gAZButton14 to indexButton(31)
  477.   if gCFTBundle = 1 then
  478.     makeBookButtons()
  479.   end if
  480.   if objectp(gLastIndexButton) then
  481.     select(gLastIndexButton)
  482.   else
  483.     select(gAZButton1)
  484.   end if
  485. end
  486.  
  487. on makeBookButtons
  488.   global gPastaButton, gVegiButton, gChickButton, gStirButton, gAZButton
  489.   set gPastaButton to radioButton(40)
  490.   set gVegiButton to radioButton(42)
  491.   set gStirButton to radioButton(41)
  492.   set gChickButton to radioButton(39)
  493.   set gAZButton to radioButton(43)
  494. end
  495.  
  496. on cleanButtons
  497.   global gLastIndexButton
  498.   set gLastIndexButton to EMPTY
  499. end
  500.  
  501. on goCredits
  502.   cleanLegos()
  503.   set the visible of sprite 44 to 0
  504.   go("credits")
  505.   puppetSprite(2, 1)
  506.   startTimer()
  507. end
  508.  
  509. on credits
  510.   global gOriginalColorDepth
  511.   if the mouseDown and (the mouseH < 5) and (the mouseV < 5) then
  512.     set the visible of sprite 44 to 1
  513.   else
  514.     if the mouseDown then
  515.       set the colorDepth to gOriginalColorDepth
  516.       clearGlobals()
  517.       DBEndSession()
  518.       quit()
  519.     else
  520.       if the timer > 540 then
  521.         set current to the castNum of sprite 2
  522.         if current = 454 then
  523.           set the colorDepth to gOriginalColorDepth
  524.           clearGlobals()
  525.           DBEndSession()
  526.         else
  527.           set the castNum of sprite 2 to current + 1
  528.         end if
  529.         startTimer()
  530.       else
  531.         set the visible of sprite 44 to 0
  532.       end if
  533.     end if
  534.   end if
  535. end
  536.  
  537. on helpOn
  538.   global gLastHelp, gHelpLinks, gHelpActive, gHelpSprite
  539.   if gHelpActive then
  540.     helpOff()
  541.   else
  542.     set gHelpActive to 1
  543.     set gLastHelp to 0
  544.     set gHelpLinks to [3: 9, 4: 5, 5: 13, 6: 14, 7: 16, 8: 17, 9: 12, 10: 7, 11: 1]
  545.     puppetSprite(gHelpSprite, 1)
  546.   end if
  547. end
  548.