home *** CD-ROM | disk | FTP | other *** search
/ Comic Book Maker: The Smurfs / COMIC.iso / mac / data_m / CBA2_40 / 00001_ProgramScript.ls next >
Encoding:
Text File  |  2001-02-22  |  12.4 KB  |  404 lines

  1. global gObjList, gObj1, gObj2, gObj3, gObj4, gObj5, gObj6, gPlatForm, gItemSeparator, gTaskBarStatus, gOldColorDepth, gLangCode, gFontName, keyFileFound, g68KThumbnailPatch, traceList
  2.  
  3. on startMovie
  4.   set traceList to []
  5.   repeat with i = 1 to 2066
  6.     if not (the type of member i of castLib "screenGraphics" = #bitmap) then
  7.       add(traceList, 0)
  8.       next repeat
  9.     end if
  10.     add(traceList, the loaded of member i of castLib "screenGraphics")
  11.   end repeat
  12.   if not (the frame = 1) then
  13.     exit
  14.   end if
  15.   set gFontName to "Comicbook"
  16.   set gItemSeparator to numToChar(1)
  17.   set the windowList to []
  18.   set the visible of window "dialog" to 0
  19.   set the windowType of window 1 to 2
  20.   repeat with i = 1 to 4
  21.     set the media of member (i + 10) of castLib 2 to the media of member (3150 + i) of castLib 3
  22.   end repeat
  23.   repeat with i = 1 to 7
  24.     set the media of member (i + 3) of castLib 2 to the media of member (3156 + i) of castLib 3
  25.     if not (the depth of member (i + 3) of castLib 2 = 1) then
  26.       set alertWrongDepth to the depth of member (i + 3) of castLib 2
  27.     end if
  28.   end repeat
  29.   if alertWrongDepth then
  30.     alert("Balloon dialogMembers are of wrong colordepth!" & RETURN & RETURN & alertWrongDepth)
  31.   end if
  32.   if not (the paletteRef of member the member of sprite 2 = #systemWin) then
  33.     alert("Publisher logo at startup is not in Windows palette!")
  34.   end if
  35.   set the idleHandlerPeriod to 0
  36.   set the exitLock to 1
  37.   set the stageColor to 0
  38.   repeat with i = 201 to 212
  39.     erase(member i of castLib 2)
  40.   end repeat
  41.   set gLangCode to the name of member 1 of castLib 2
  42.   if (gLangCode = EMPTY) or not (length(gLangCode) = 3) then
  43.     alert("No language code present!" & RETURN & RETURN & "member 1")
  44.   end if
  45.   if the platform contains "Mac" then
  46.     set gPlatForm to 1
  47.     if the platform contains "68" then
  48.       set g68KThumbnailPatch to 1
  49.     end if
  50.     if not (the runMode = "author") then
  51.       if not (the number of xtras = 6) then
  52.         alert("CBA2 internal error: Application will only run from original CD!" & RETURN & RETURN & 4 & RETURN & RETURN & the number of xtras)
  53.         quit()
  54.       end if
  55.       OSRegister(454303137, 1046276000)
  56.       if voidp(keyFileFound) and ((OSVolumeFree(getNthOfPath(the moviePath)) / 1024) > 60) then
  57.         alert("CBA2 internal error: Application will only run from original CD!" & RETURN & RETURN & 3)
  58.         quit()
  59.       end if
  60.     else
  61.       if not (the fileName of castLib 4 contains "fileLib") then
  62.         alert("Verkeerde castlib op 4")
  63.       end if
  64.     end if
  65.   else
  66.     set gPlatForm to 0
  67.     if not (the runMode = "author") then
  68.       if not (the number of xtras = 5) then
  69.         alert("CBA2 internal error: Application will only run from original CD!" & RETURN & RETURN & "5" & RETURN & RETURN & "Total:" && the number of xtras)
  70.         quit()
  71.       end if
  72.       baRegister("LASCAUX", 2197975)
  73.       set the media of member 141 of castLib 1 to the media of member 147 of castLib 1
  74.       set the media of member 142 of castLib 1 to the media of member 148 of castLib 1
  75.     end if
  76.   end if
  77.   castFX_register("CFX-ALL-2-19980219-09200303-05647")
  78.   register(xtra("PrintOMatic"), "PMAT155-401-12661")
  79.   set gObj2 to new(script "gObj2 layout")
  80.   set gObj5 to new(script "gObj5 file")
  81.   fontChecks()
  82.   screenChecks()
  83.   updateVersionNo()
  84. end
  85.  
  86. on fontChecks
  87.   if gPlatForm then
  88.     set the textFont of member "textClipTestField" to gFontName
  89.     if not (the textFont of member "textClipTestField" = gFontName) then
  90.       openXLib("@:supportM:comicbook")
  91.       set the textFont of member "textClipTestField" to gFontName
  92.       if not (the textFont of member "textClipTestField" = gFontName) then
  93.         alert("CBA/2 internal error: could not open font! The font will be copied to the system volume and the application will quit." & RETURN & "Please drag the " & QUOTE & gFontName & QUOTE & "font to your System folder and relaunch this application.")
  94.         set fontDir to getNthOfPath(getOSDirectory())
  95.         set sourceFontDir to the moviePath & "supportM:comicbook"
  96.         set OSerror to OSFileCopy(sourceFontDir, fontDir)
  97.         if OSerror then
  98.           alert("CBA/2 internal error: OS error" && OSerror)
  99.         end if
  100.         quit()
  101.       end if
  102.     end if
  103.   else
  104.     set the textFont of member "textClipTestField" to gFontName
  105.     if not (the textFont of member "textClipTestField" = gFontName) then
  106.       set error to baInstallFont(the moviePath & "supportW\cmicbook.ttf", gFontName)
  107.       if error then
  108.         alert("CBA/2 internal error: Windows font install problem!" & RETURN & RETURN & error)
  109.       end if
  110.       set the textFont of member "textClipTestField" to gFontName
  111.       if not (the textFont of member "textClipTestField" = gFontName) and not error then
  112.         set the locH of sprite 2 to 9000
  113.         puppetPalette("runtimePaletteWin", 60)
  114.         updateStage()
  115.         tell window 1
  116.           displayDialog(16)
  117.         end tell
  118.       end if
  119.     end if
  120.   end if
  121.   repeat with c = 1 to 3
  122.     repeat with i = the number of castMembers of castLib c down to 2
  123.       if the type of member i of castLib c = #field then
  124.         if not (the textFont of member i of castLib c = gFontName) then
  125.           set the textFont of member i of castLib c to gFontName
  126.         end if
  127.       end if
  128.     end repeat
  129.   end repeat
  130.   tell window 1
  131.     repeat with i = 1 to the number of castMembers of castLib 1
  132.       if the type of member i = #field then
  133.         if not (the textFont of member i = gFontName) then
  134.           set the textFont of member i to gFontName
  135.         end if
  136.       end if
  137.     end repeat
  138.   end tell
  139. end
  140.  
  141. on screenChecks x, fromDialog, mode
  142.   if not fromDialog then
  143.     if not (the colorDepth = 8) then
  144.       if gPlatForm then
  145.         set gOldColorDepth to the colorDepth
  146.         set the locH of sprite 2 to 9000
  147.         updateStage()
  148.         set the colorDepth to 8
  149.         Del(60)
  150.         if not (the colorDepth = 8) then
  151.           tell window 1
  152.             displayDialog(14)
  153.           end tell
  154.         end if
  155.       else
  156.         set currentWidth to baScreenInfo("width")
  157.         set currentHeight to baScreenInfo("height")
  158.         set canBeChanged to baSetDisplay(currentWidth, currentHeight, 8, "test", 0)
  159.         if canBeChanged = 0 then
  160.           tell window 1
  161.             displayDialog(12)
  162.           end tell
  163.         else
  164.           if canBeChanged = 1 then
  165.             tell window 1
  166.               displayDialog(13)
  167.             end tell
  168.           else
  169.             if canBeChanged < 0 then
  170.               tell window 1
  171.                 displayDialog(14)
  172.               end tell
  173.             end if
  174.           end if
  175.         end if
  176.       end if
  177.     end if
  178.   else
  179.     if gPlatForm then
  180.       alert("Burp!")
  181.     end if
  182.     set currentWidth to baScreenInfo("width")
  183.     set currentHeight to baScreenInfo("height")
  184.     set oldDepth to the colorDepth
  185.     set isNotChanged to baSetDisplay(currentWidth, currentHeight, 8, mode, 0)
  186.     if isNotChanged = 0 then
  187.       set gOldColorDepth to oldDepth
  188.     else
  189.       if isNotChanged = 1 then
  190.         baExitWindows("reboot")
  191.       else
  192.         if not (isNotChanged = 0) then
  193.           alert("CBA/2 internal error: problem changing monitor depth!" & RETURN & RETURN & isNotChanged)
  194.         end if
  195.       end if
  196.     end if
  197.   end if
  198. end
  199.  
  200. on startProgram
  201.   cursor(4)
  202.   set gObjList to [new(script "selectRects&cursor")]
  203.   set gObj1 to new(script "gObj1 graphics")
  204.   set gObj3 to new(script "gObj3 balloons")
  205.   set gObj4 to new(script "gObj4 rows")
  206.   set gObj6 to new(script "gObj6 print")
  207.   set the timeoutLength to 120
  208.   set the timeoutScript to "checkThumbs(gObj2)"
  209.   sound fadeOut 3, 80
  210. end
  211.  
  212. on stopMovie
  213.   if the runMode = "Author" then
  214.     set the trace to 0
  215.     repeat with i = 201 to 212
  216.       duplicate(member 143, member i of castLib 2)
  217.     end repeat
  218.     erase(member 200)
  219.     repeat with i = 1 to 13
  220.       erase(member i of castLib 4)
  221.     end repeat
  222.     repeat with i = 1 to 4
  223.       set the media of member (i + 10) of castLib 2 to the media of member 143 of castLib 1
  224.       set the regPoint of member (i + 10) of castLib 2 to point(20, 40)
  225.     end repeat
  226.     repeat with i = 1 to 7
  227.       set the media of member (i + 3) of castLib 2 to the media of member 143 of castLib 1
  228.     end repeat
  229.     repeat with i = 2000 to 3000
  230.       if the type of member i of castLib 3 = #field then
  231.         put "dummyText" && i into field i of castLib 3
  232.       end if
  233.     end repeat
  234.     set the windowList to []
  235.     set gObjList to 0
  236.     set the stageColor to 255
  237.     set the text of member "title" to "..."
  238.     set the text of member "name" to "..."
  239.     set the text of member "vers" to "..."
  240.     clearGlobals()
  241.   end if
  242.   castFX_shutdown()
  243.   closeXLib()
  244. end
  245.  
  246. on clearPageLayout
  247.   repeat with i = 1 to 12
  248.     set the locH of sprite (100 + i) to 9000
  249.   end repeat
  250.   set the locH of sprite 114 to 9000
  251. end
  252.  
  253. on clearFrameLayout me
  254.   repeat with i = 1 to the spriteCount of gObj1
  255.     add(the pUnloadList of gObj2, the memberNum of sprite i)
  256.     set the locH of sprite i to 9000
  257.   end repeat
  258. end
  259.  
  260. on makeNumber input, pos
  261.   set output to string(input)
  262.   repeat with i = pos - length(output) down to 1
  263.     put 0 before output
  264.   end repeat
  265.   return char 1 to pos of output
  266. end
  267.  
  268. on Del t
  269.   set stopTime to the ticks + t
  270.   repeat while the ticks < stopTime
  271.   end repeat
  272. end
  273.  
  274. on clipText theString, theWidth
  275.   set the text of member "textClipTestField" to theString
  276.   set stringRight to the locH of charPosToLoc(member "textClipTestField", length(theString))
  277.   if stringRight > theWidth then
  278.     set theString to char 1 to locToCharPos(member "textClipTestField", point(theWidth, 0)) - 1 of theString & "..."
  279.   end if
  280.   return theString
  281. end
  282.  
  283. on getNthOfPath theString, itemOffset
  284.   if gPlatForm then
  285.     set the itemDelimiter to ":"
  286.   else
  287.     set the itemDelimiter to "\"
  288.   end if
  289.   if itemOffset then
  290.     set pathNameSeparator to the itemDelimiter
  291.   end if
  292.   if voidp(itemOffset) then
  293.     return item 1 of theString & the itemDelimiter
  294.   end if
  295.   return item the number of items in theString - itemOffset of theString & pathNameSeparator
  296. end
  297.  
  298. on changePalette platFormID
  299.   set paletteNumber to the number of member ("RuntimePalette" & platFormID) of castLib 3
  300.   if paletteNumber = -1 then
  301.     alert("CBA2 internal error: no runtime palette present!" & RETURN & RETURN & "RuntimePalette" & platFormID)
  302.     exit
  303.   end if
  304.   set the locH of sprite 2 to 9000
  305.   updateStage()
  306.   set the media of member "activePalette" to the media of member paletteNumber
  307. end
  308.  
  309. on modKeyPressed
  310.   if gPlatForm then
  311.     return the commandDown
  312.   else
  313.     return the controlDown
  314.   end if
  315. end
  316.  
  317. on checkOrder
  318.   exit
  319.   set the textFont of member "order" to "geneva"
  320.   set s to EMPTY
  321.   repeat with i = 1 to 50
  322.     if the locH of sprite i < 640 then
  323.       if the isBalloon of sprite(i) then
  324.         put "=" & RETURN after s
  325.       else
  326.         put "ΓÇó" & RETURN after s
  327.       end if
  328.       next repeat
  329.     end if
  330.     put "o" & RETURN after s
  331.   end repeat
  332.   set the foreColor of field "order" to 255
  333.   put s into field "order"
  334.   repeat with i in the theSelection of gObj1
  335.     set the foreColor of line i of field "order" to 14
  336.   end repeat
  337. end
  338.  
  339. on convert str, whichChar
  340.   repeat with i = 1 to length(str)
  341.     if charToNum(char i of str) = whichChar then
  342.       put "@" into char i of str
  343.     end if
  344.   end repeat
  345.   return str
  346. end
  347.  
  348. on stripReturns input, theReturnChar
  349.   repeat while 1
  350.     set returnPos to offset(RETURN, input)
  351.     if not returnPos then
  352.       exit repeat
  353.     end if
  354.     put theReturnChar into char returnPos of input
  355.   end repeat
  356.   repeat while 1
  357.     if the last char in input = theReturnChar then
  358.       delete char -30000 of input
  359.       next repeat
  360.     end if
  361.     exit repeat
  362.   end repeat
  363.   return input
  364. end
  365.  
  366. on addReturns input, theReturnChar
  367.   repeat while 1
  368.     set returnPos to offset(theReturnChar, input)
  369.     if not returnPos then
  370.       exit repeat
  371.     end if
  372.     put RETURN into char returnPos of input
  373.   end repeat
  374.   return input
  375. end
  376.  
  377. on OpenDocs thePathsList
  378.   if listp(thePathsList) then
  379.     if count(thePathsList) then
  380.       if not (the frameLabel = "CBA2") then
  381.         changePalette("Mac")
  382.         startProgram()
  383.         go("CBA2")
  384.         cursor(0)
  385.       end if
  386.       openFile(gObj5, 1, 1, getAt(thePathsList, 1))
  387.     end if
  388.   end if
  389. end
  390.  
  391. on updateVersionNo
  392.   if the movieName contains ".dir" then
  393.     set vers to char offset("_", the movieName) + 1 to length(the movieName) - 4 of the movieName
  394.   else
  395.     set vers to char length(the movieName) - 1 to length(the movieName) of the movieName
  396.   end if
  397.   put "v." & vers into field "vers"
  398.   if gPlatForm then
  399.     set the textFont of field "vers" to "Geneva"
  400.   else
  401.     set the textFont of field "vers" to "Arial"
  402.   end if
  403. end
  404.