home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 39 / PCGAMER39.bin / games / amber / amberhub.dxr / 00019_cPuppeteer.2.ls < prev    next >
Encoding:
Text File  |  1996-11-08  |  15.7 KB  |  463 lines

  1. on moveMovies me
  2.   global gOriginPoint, gCPU
  3.   if gCPU = #PC then
  4.     exit
  5.   end if
  6.   alert("Hm, we're using moveMovies() on a PC... (tsk)")
  7.   if (the castNum of sprite 44 = 7) and (the puppet of sprite 44 = 0) then
  8.     set move_44 to 1
  9.   end if
  10.   if (the castNum of sprite 45 = 7) and (the puppet of sprite 45 = 0) then
  11.     set move_45 to 1
  12.   end if
  13.   if move_44 = 1 then
  14.     set oldLoc_44 to the loc of sprite 44
  15.   end if
  16.   if move_45 = 1 then
  17.     set oldLoc_45 to the loc of sprite 45
  18.   end if
  19.   if move_44 = 1 then
  20.     puppetSprite(44, 1)
  21.   end if
  22.   if move_45 = 1 then
  23.     puppetSprite(45, 1)
  24.   end if
  25.   if move_44 = 1 then
  26.     set the loc of sprite 44 to point(-3, -3) + gOriginPoint
  27.   end if
  28.   if move_45 = 1 then
  29.     set the loc of sprite 45 to point(-3, -3) + gOriginPoint
  30.   end if
  31.   updateStage()
  32.   if move_44 = 1 then
  33.     set the loc of sprite 44 to oldLoc_44
  34.   end if
  35.   if move_45 = 1 then
  36.     set the loc of sprite 45 to oldLoc_45
  37.   end if
  38.   updateStage()
  39.   if move_44 = 1 then
  40.     puppetSprite(44, 0)
  41.   end if
  42.   if move_45 = 1 then
  43.     puppetSprite(45, 0)
  44.   end if
  45. end
  46.  
  47. on showCreditScreen me, optionSwitch
  48.   global gCPU, domainIsReady, gOriginPoint, oMemory, gAmberPath, thisCursor, lastCursor, gFadeStash, gSoundStash, gSoundsSuspended
  49.   set endGame to 0
  50.   set gCurrentHotspot to #None
  51.   set thisCursor to #pointer
  52.   set lastCursor to #bogus
  53.   cursorDance()
  54.   installMenu(0)
  55.   set domainIsReady to 0
  56.   set the keyDownScript to "creditScreenKeys(oPuppeteer)"
  57.   if voidp(the lsForegroundData of me) then
  58.     set creditScreen to 26
  59.     set creditMovie to 25
  60.     set creditButtons to [#load: 27, #quit: 30, #resume: 29, #save: 28]
  61.   else
  62.     set creditScreen to getaProp(the lsForegroundData of me, #creditScreen)
  63.     set creditMovie to getaProp(the lsForegroundData of me, #creditMovie)
  64.     set creditButtons to getaProp(the lsForegroundData of me, #creditButtons)
  65.     if gCPU = #PC then
  66.       set pathDelim to "\"
  67.     end if
  68.     if gCPU = #Mac then
  69.       set pathDelim to ":"
  70.     end if
  71.     set the fileName of cast creditMovie to gAmberPath & "ROXY" & pathDelim & "movies" & pathDelim & "credits.mov"
  72.     if getState(oStoryteller, #currentLocation) = #garageEscape then
  73.       set endGame to 1
  74.       set blackBar to getaProp(the lsForegroundData of me, #blackBar)
  75.     end if
  76.     if voidp(creditScreen) then
  77.       put "<!> showCreditScreens( oPuppeteer ): HEY! This domain seems to lack foreground data for the credit screen!"
  78.       exit
  79.     end if
  80.   end if
  81.   set mainVideo to 44
  82.   set movieSprite to 45
  83.   set bgSprite to 47
  84.   puppetSprite(bgSprite, 1)
  85.   set buttonSprite to 48
  86.   puppetSprite(buttonSprite, 1)
  87.   if optionSwitch <> #endGame then
  88.     stashVidSprite(me)
  89.   end if
  90.   if optionSwitch = #endGame then
  91.     set gFadeStash to #None
  92.   else
  93.     gammaFade(#down, #slow)
  94.   end if
  95.   set gSoundStash to gSoundsSuspended
  96.   suspendSounds(#fadeOut)
  97.   puppetSprite(movieSprite, 1)
  98.   if endGame = 0 then
  99.     set the loc of sprite mainVideo to point(-1000, -1000)
  100.   end if
  101.   set the volume of sprite mainVideo to 0
  102.   installMenu(0)
  103.   if endGame = 1 then
  104.     unLoadCast()
  105.   end if
  106.   if objectp(oMemory) and (gCPU = #Mac) then
  107.     oMemory(mCompact)
  108.   end if
  109.   set the castNum of sprite bgSprite to creditScreen
  110.   set the loc of sprite bgSprite to point(320, 240) + gOriginPoint
  111.   set the movieRate of sprite movieSprite to 0
  112.   set the sound of cast creditMovie to 1
  113.   set the castNum of sprite movieSprite to creditMovie
  114.   set the loc of sprite movieSprite to point(320, 240) + gOriginPoint
  115.   if endGame = 1 then
  116.     set the castNum of sprite buttonSprite to blackBar
  117.     set the loc of sprite buttonSprite to point(320, 450) + gOriginPoint
  118.   else
  119.     set the loc of sprite buttonSprite to point(-1000, -1000) + gOriginPoint
  120.     repeat with cNum in creditButtons
  121.       preLoadCast(cNum)
  122.     end repeat
  123.   end if
  124.   gammaFade(#up, #slow)
  125.   set the visible of sprite movieSprite to 1
  126.   set the volume of sprite movieSprite to 255
  127.   wait(60)
  128.   set the movieTime of sprite movieSprite to 0
  129.   updateStage()
  130.   set the movieRate of sprite movieSprite to 1
  131.   updateStage()
  132. end
  133.  
  134. on resumeCurrentGame me
  135.   global gCPU, domainIsReady, oMemory, gSoundStash
  136.   if voidp(the lsForegroundData of me) then
  137.     set creditScreen to 26
  138.     set creditMovie to 25
  139.     set creditButtons to [#load: 27, #quit: 30, #resume: 29, #save: 28]
  140.   else
  141.     set creditScreen to getaProp(the lsForegroundData of me, #creditScreen)
  142.     set creditMovie to getaProp(the lsForegroundData of me, #creditMovie)
  143.     set creditButtons to getaProp(the lsForegroundData of me, #creditButtons)
  144.     if voidp(creditScreen) then
  145.       put "<!> showCreditScreens( oPuppeteer ): HEY! This domain seems to lack foreground data for the credit screen!"
  146.       exit
  147.     end if
  148.   end if
  149.   set movieSprite to 45
  150.   set bgSprite to 47
  151.   set buttonSprite to 48
  152.   set the movieRate of sprite movieSprite to 0
  153.   installMenu(0)
  154.   puppetSprite(movieSprite, 0)
  155.   set the loc of sprite bgSprite to point(-1000, -1000)
  156.   set the loc of sprite buttonSprite to point(-1000, -1000)
  157.   puppetSprite(bgSprite, 0)
  158.   puppetSprite(buttonSprite, 0)
  159.   gammaFade(#down, #slow)
  160.   go(the frame)
  161.   unLoadCast(creditScreen)
  162.   unLoadCast(creditMovie)
  163.   repeat with cNum in creditButtons
  164.     unLoadCast(cNum)
  165.   end repeat
  166.   if objectp(oMemory) and (gCPU = #Mac) then
  167.     oMemory(mCompact)
  168.   end if
  169.   set the visible of sprite 44 to 0
  170.   set the visible of sprite 45 to 0
  171.   restoreVidSprite(me)
  172.   gammaFade(#up, #slow, #resumeGame)
  173.   if gSoundStash = 0 then
  174.     restoreSounds(#fadeIn)
  175.   end if
  176.   cursorDance()
  177. end
  178.  
  179. on buildProfile me, param, value
  180.   alert("Hey! The buildProfile() method isn't done yet!")
  181. end
  182.  
  183. on loadProfile me
  184.   alert("Hey! The loadProfile() method isn't done yet!")
  185. end
  186.  
  187. on saveProfile me
  188.   alert("Hey! The saveProfile() method isn't done yet!")
  189. end
  190.  
  191. on refreshVidSprites me
  192.   set the visible of sprite 44 to not (the visible of sprite 44)
  193.   set the visible of sprite 45 to not (the visible of sprite 45)
  194.   set the visible of sprite 44 to not (the visible of sprite 44)
  195.   set the visible of sprite 45 to not (the visible of sprite 45)
  196.   updateStage()
  197. end
  198.  
  199. on clickOnCreditScreen me, btnName
  200.   global gOriginPoint, oStoryteller, gDeferredTransit
  201.   set clickLoc to point(the mouseH, the mouseV)
  202.   if getState(oStoryteller, #currentLocation) = #garageEscape then
  203.     fadeCredits(me, #down)
  204.     quitGame(oStoryteller)
  205.   else
  206.     if voidp(the lsForegroundData of me) then
  207.       set creditButtons to [#load: 27, #save: 28, #resume: 29, #quit: 30]
  208.     else
  209.       set creditButtons to getProp(the lsForegroundData of me, #creditButtons)
  210.     end if
  211.     set buttonSprite to 48
  212.     set offScreen to the loc of sprite buttonSprite
  213.     set theButton to #None
  214.     if the paramCount = 1 then
  215.       set buttonArea to rect(126, 395, 501, 418)
  216.       if inside(clickLoc, buttonArea) then
  217.         set theButton to #load
  218.         set xCoord to getAt(clickLoc, 1)
  219.         if xCoord > 218 then
  220.           set theButton to #save
  221.         end if
  222.         if xCoord > 314 then
  223.           set theButton to #resume
  224.         end if
  225.         if xCoord > 408 then
  226.           set theButton to #quit
  227.         end if
  228.       else
  229.         exit
  230.       end if
  231.     else
  232.       set theButton to btnName
  233.     end if
  234.     set the castNum of sprite buttonSprite to getProp(creditButtons, theButton)
  235.     if theButton = #load then
  236.       set the loc of sprite buttonSprite to point(169, 405)
  237.       repeat while the mouseDown
  238.         updateStage()
  239.       end repeat
  240.       set the loc of sprite buttonSprite to offScreen
  241.       fadeCredits(me, #down)
  242.       set the keyDownScript to EMPTY
  243.       set gDeferredTransit to "-- dontIdle"
  244.       set loadStatus to loadSavedGame(oStoryteller)
  245.       if loadStatus = #cancelled then
  246.         set the keyDownScript to "creditScreenKeys(oPuppeteer)"
  247.         fadeCredits(me, #up)
  248.       end if
  249.     end if
  250.     if theButton = #save then
  251.       set the loc of sprite buttonSprite to point(263, 405)
  252.       repeat while the mouseDown
  253.         updateStage()
  254.       end repeat
  255.       set the loc of sprite buttonSprite to offScreen
  256.       fadeCredits(me, #down)
  257.       saveCurrentGame(oStoryteller, #saveAs)
  258.       fadeCredits(me, #up)
  259.     end if
  260.     if theButton = #resume then
  261.       set the loc of sprite buttonSprite to point(358, 405)
  262.       repeat while the mouseDown
  263.         updateStage()
  264.       end repeat
  265.       set the loc of sprite buttonSprite to offScreen
  266.       fadeCredits(me, #down)
  267.       set the keyDownScript to EMPTY
  268.       resumeCurrentGame(me)
  269.     end if
  270.     if theButton = #quit then
  271.       set the loc of sprite buttonSprite to point(452, 405)
  272.       repeat while the mouseDown
  273.         updateStage()
  274.       end repeat
  275.       set the loc of sprite buttonSprite to offScreen
  276.       fadeCredits(me, #down)
  277.       quitGame(oStoryteller)
  278.     end if
  279.     set the loc of sprite buttonSprite to point(-1000, -1000) + gOriginPoint
  280.   end if
  281. end
  282.  
  283. on stashVidSprite me
  284.   global gStashedVideoProps, gVidViz
  285.   set gStashedVideoProps to [:]
  286.   set mainVideo to 44
  287.   set vidSprite to 45
  288.   set movieCastNum to the castNum of sprite vidSprite
  289.   setaProp(gStashedVideoProps, #castNum, movieCastNum)
  290.   setaProp(gStashedVideoProps, #puppeted, the puppet of sprite vidSprite)
  291.   setaProp(gStashedVideoProps, #visible, the visible of sprite vidSprite)
  292.   setaProp(gStashedVideoProps, #loc, the loc of sprite vidSprite)
  293.   setaProp(gStashedVideoProps, #ink, the ink of sprite vidSprite)
  294.   setaProp(gStashedVideoProps, #volume, the volume of sprite vidSprite)
  295.   setaProp(gStashedVideoProps, #startTime, the startTime of sprite vidSprite)
  296.   setaProp(gStashedVideoProps, #stopTime, the stopTime of sprite vidSprite)
  297.   setaProp(gStashedVideoProps, #movieTime, the movieTime of sprite vidSprite)
  298.   setaProp(gStashedVideoProps, #movieRate, the movieRate of sprite vidSprite)
  299.   setaProp(gStashedVideoProps, #c_directToStage, the directToStage of cast movieCastNum)
  300.   setaProp(gStashedVideoProps, #c_loop, the loop of cast movieCastNum)
  301.   setaProp(gStashedVideoProps, #c_pausedAtStart, the pausedAtStart of cast movieCastNum)
  302.   setaProp(gStashedVideoProps, #c_sound, the sound of cast movieCastNum)
  303.   setaProp(gStashedVideoProps, #mainVideoLoc, the loc of sprite mainVideo)
  304.   setaProp(gStashedVideoProps, #mainVideoVol, the volume of sprite mainVideo)
  305.   setaProp(gStashedVideoProps, #mainVideoVisible, the visible of sprite mainVideo)
  306.   set gVidViz to [the visible of sprite 44, the visible of sprite 45, the movieTime of sprite 45]
  307. end
  308.  
  309. on restoreVidSprite me
  310.   global gStashedVideoProps, gVoid
  311.   set mainVideo to 44
  312.   set vidSprite to 45
  313.   puppetSprite(vidSprite, 1)
  314.   set movieCastNum to getProp(gStashedVideoProps, #castNum)
  315.   set the castNum of sprite vidSprite to movieCastNum
  316.   set the loc of sprite vidSprite to point(-1000, -1000)
  317.   set the visible of sprite vidSprite to 0
  318.   set the ink of sprite vidSprite to getProp(gStashedVideoProps, #ink)
  319.   set the volume of sprite vidSprite to getProp(gStashedVideoProps, #volume)
  320.   set the startTime of sprite vidSprite to getProp(gStashedVideoProps, #startTime)
  321.   set the stopTime of sprite vidSprite to getProp(gStashedVideoProps, #stopTime)
  322.   set the movieRate of sprite vidSprite to getProp(gStashedVideoProps, #movieRate)
  323.   set the movieTime of sprite vidSprite to getProp(gStashedVideoProps, #movieTime)
  324.   set the directToStage of cast movieCastNum to getProp(gStashedVideoProps, #c_directToStage)
  325.   set the loop of cast movieCastNum to getProp(gStashedVideoProps, #c_loop)
  326.   set the pausedAtStart of cast movieCastNum to getProp(gStashedVideoProps, #c_pausedAtStart)
  327.   set the sound of cast movieCastNum to getProp(gStashedVideoProps, #c_sound)
  328.   set the loc of sprite vidSprite to getProp(gStashedVideoProps, #loc)
  329.   set the movieTime of sprite vidSprite to getProp(gStashedVideoProps, #movieTime)
  330.   set the puppet of sprite vidSprite to getProp(gStashedVideoProps, #puppeted)
  331.   set the loc of sprite mainVideo to getProp(gStashedVideoProps, #mainVideoLoc)
  332.   set the volume of sprite mainVideo to getProp(gStashedVideoProps, #mainVideoVol)
  333.   moveMovies(me)
  334.   set gStashedVideoProps to gVoid
  335. end
  336.  
  337. on fadeCredits me, upOrDown
  338.   set movieSprite to 45
  339.   if upOrDown = #down then
  340.     repeat while the volume of sprite movieSprite > 10
  341.       wait(5)
  342.       set the volume of sprite movieSprite to the volume of sprite movieSprite * 0.80000000000000004
  343.       updateStage()
  344.     end repeat
  345.     set the volume of sprite movieSprite to 0
  346.     set the movieRate of sprite movieSprite to 0
  347.     updateStage()
  348.   else
  349.     set the visible of sprite movieSprite to 1
  350.     set the movieRate of sprite movieSprite to 1
  351.     set the volume of sprite movieSprite to 10
  352.     updateStage()
  353.     repeat while the volume of sprite movieSprite < 100
  354.       wait(5)
  355.       set the volume of sprite movieSprite to the volume of sprite movieSprite * 1.25
  356.       updateStage()
  357.     end repeat
  358.     set the volume of sprite movieSprite to 255
  359.     updateStage()
  360.   end if
  361. end
  362.  
  363. on creditScreenKeys me
  364.   if charToNum(the key) = 27 then
  365.     dontPassEvent()
  366.     exit
  367.   end if
  368.   if the commandDown then
  369.     set foo to the key
  370.     if "Nn" contains the key then
  371.       nothing()
  372.     end if
  373.     if "Ll" contains the key then
  374.       clickOnCreditScreen(me, #load)
  375.     end if
  376.     if "SsAa" contains the key then
  377.       clickOnCreditScreen(me, #save)
  378.     end if
  379.     if "Qq" contains the key then
  380.       clickOnCreditScreen(me, #quit)
  381.     end if
  382.   end if
  383.   dontPassEvent()
  384. end
  385.  
  386. on readPrefsFile me
  387.   global gProjectorPath, gGammaLevel, gCurrentGamma, gStopTransitions, gHorsepower
  388.   set pFileName to "AMBERpref.ini"
  389.   set fTest to new(xtra("fileio"))
  390.   if not objectp(fTest) then
  391.     exit
  392.   end if
  393.   put "<i> looking for .INI file in '" & getOSDirectory() & "'"
  394.   openFile(fTest, getOSDirectory() & "\" & pFileName, 1)
  395.   if error(fTest, status(fTest)) <> "OK" then
  396.     put "<i>  hmm, problem opening prefs file: " & error(fTest, status(fTest))
  397.     set gHorsepower to #high
  398.   else
  399.     set prefsField to readFile(fTest)
  400.     closefile(fTest)
  401.     set iDelim to the itemDelimiter
  402.     set the itemDelimiter to "="
  403.     set storedVolume to value(the last item in line 1 of prefsField)
  404.     if integerp(storedVolume) then
  405.       if (storedVolume >= 0) and (storedVolume <= 7) then
  406.         set the soundLevel to storedVolume
  407.       end if
  408.     end if
  409.     set storedTransQuality to value("#" & the last item in line 2 of prefsField)
  410.     if getPos([#Best, #Better, #None], storedTransQuality) <> 0 then
  411.       toggleTransitions(storedTransQuality)
  412.     end if
  413.     set gHorsepower to #high
  414.     set storedHorsepower to value(the last item in line 3 of prefsField)
  415.     put "storedHorsepower = "
  416.     put storedHorsepower
  417.     if storedHorsepower = 1 then
  418.       set gHorsepower to #low
  419.     end if
  420.     put "gHorsepower set to " & gHorsepower
  421.     set the itemDelimiter to iDelim
  422.   end if
  423.   set fTest to 0
  424. end
  425.  
  426. on writePrefsFile me
  427.   global gProjectorPath, gTransQuality, gHorsepower
  428.   set pFileName to "AMBERpref.ini"
  429.   set outFile to new(xtra("fileio"))
  430.   if not objectp(outFile) then
  431.     exit
  432.   end if
  433.   createFile(outFile, getOSDirectory() & "\" & pFileName)
  434.   set errMsg to error(outFile, status(outFile))
  435.   if errMsg <> "OK" then
  436.     if errMsg = "File already exists" then
  437.       openFile(outFile, getOSDirectory() & "\" & pFileName, 0)
  438.       delete(outFile)
  439.       createFile(outFile, getOSDirectory() & "\" & pFileName)
  440.     else
  441.       put "<!>  Error creating file: " & errMsg
  442.     end if
  443.   end if
  444.   openFile(outFile, getOSDirectory() & "\" & pFileName, 2)
  445.   set errMsg to error(outFile, status(outFile))
  446.   if errMsg <> "OK" then
  447.     put "<!>  Error opening file: " & errMsg
  448.   end if
  449.   set currentPrefs to "volume = " & the soundLevel & RETURN & numToChar(10) & "transition = " & gTransQuality & RETURN & numToChar(10) & "performance = " & getPos([#low, #high], gHorsepower)
  450.   put currentPrefs
  451.   writeString(outFile, currentPrefs)
  452.   set errMsg to error(outFile, status(outFile))
  453.   if errMsg <> "OK" then
  454.     put "<!>  Error writing file: " & errMsg
  455.   end if
  456.   closefile(outFile)
  457.   set errMsg to error(outFile, status(outFile))
  458.   if errMsg <> "OK" then
  459.     put "<!>  Error closing file: " & errMsg
  460.   end if
  461.   set outFile to 0
  462. end
  463.