home *** CD-ROM | disk | FTP | other *** search
/ Exploring Aeronautics / NASA Exploring Aeronautics.iso / pc / source / visitor.dxr / Internal_3_resourceManagerObjectScript.ls < prev    next >
Encoding:
Text File  |  1998-06-02  |  6.9 KB  |  202 lines

  1. property categoryList, resourceCast, resourceIndex, currentCategory, currentEventIndex, previewSpriteList, pictureSprite, textSprite, dialSprite, categorySprite, entryPlaceholderSprite, boxSprite, barSprite, bottomBoxLimit, topBoxLimit
  2. global gSoundManager, gScrollingText
  3.  
  4. on new me, aCategoryList, aResourceCast, sortFlag
  5.   set resourceCast to the number of castLib aResourceCast
  6.   set resourceIndex to []
  7.   set previewSpriteList to [13, 14, 15, 16, 17]
  8.   set pictureSprite to 27
  9.   set textSprite to 20
  10.   set dialSprite to 4
  11.   set categorySprite to 3
  12.   set entryPlaceholderSprite to 12
  13.   mInit(me, aCategoryList, sortFlag)
  14.   mInitPreviewList(me)
  15.   return me
  16. end
  17.  
  18. on mShowCategories me
  19.   put categoryList
  20. end
  21.  
  22. on mInitPreviewList me
  23.   set boxSprite to 8
  24.   set barSprite to 5
  25.   puppetSprite(boxSprite, 1)
  26.   set bottomBoxLimit to the bottom of sprite barSprite - (the width of sprite boxSprite / 2)
  27.   set topBoxLimit to the top of sprite barSprite + (the width of sprite boxSprite / 2)
  28. end
  29.  
  30. on mInit me, alist, trueOrFalse
  31.   repeat with i = 1 to 100
  32.     set aMember to member ((i * 10) - 9) of castLib resourceCast
  33.     if the type of aMember <> #empty then
  34.       add(resourceIndex, the name of member ((i * 10) - 9) of castLib resourceCast)
  35.       next repeat
  36.     end if
  37.     exit repeat
  38.   end repeat
  39.   if trueOrFalse then
  40.     sort(resourceIndex)
  41.   end if
  42.   set categoryList to []
  43.   repeat with i = 1 to count(alist)
  44.     set categoryLimits to getAt(alist, i)
  45.     set categoryName to getPropAt(alist, i)
  46.     add(categoryList, new(script "categoryObjectScript", categoryName, categoryLimits))
  47.   end repeat
  48.   set currentCategory to getAt(categoryList, 1)
  49.   repeat with aSprite in previewSpriteList
  50.     puppetSprite(aSprite, 1)
  51.   end repeat
  52.   puppetSprite(pictureSprite, 1)
  53.   puppetSprite(textSprite, 1)
  54.   puppetSprite(dialSprite, 1)
  55.   puppetSprite(categorySprite, 1)
  56.   puppetSprite(entryPlaceholderSprite, 1)
  57.   mSetCategory(me, mGetName(currentCategory))
  58. end
  59.  
  60. on mReset me
  61.   set currentCategory to getAt(categoryList, 1)
  62.   mSetCategory(me, mGetName(currentCategory))
  63. end
  64.  
  65. on mSetCategory me, aCategoryName
  66.   repeat with aCategory in categoryList
  67.     if mGetName(aCategory) = aCategoryName then
  68.       set currentCategory to aCategory
  69.       exit repeat
  70.     end if
  71.   end repeat
  72.   set currentEventIndex to mGetLowerLimit(currentCategory)
  73.   set the member of sprite dialSprite to member (aCategoryName & "arrow")
  74.   set the member of sprite categorySprite to member (aCategoryName & "label")
  75.   mUpdatePreview(me)
  76. end
  77.  
  78. on mUpArrow me
  79.   set currentEventIndex to currentEventIndex - 1
  80.   set currentEventIndex to max(currentEventIndex, mGetLowerLimit(currentCategory))
  81.   mUpdatePreview(me)
  82.   mTopOfPage(gScrollingText)
  83. end
  84.  
  85. on mDownArrow me
  86.   set currentEventIndex to currentEventIndex + 1
  87.   set currentEventIndex to min(currentEventIndex, mGetUpperLimit(currentCategory))
  88.   mUpdatePreview(me)
  89.   mTopOfPage(gScrollingText)
  90. end
  91.  
  92. on mSlideBox me
  93.   repeat while the mouseDown
  94.     set v to the mouseV
  95.     set v to min(v, bottomBoxLimit)
  96.     set v to max(v, topBoxLimit)
  97.     set the locV of sprite boxSprite to v
  98.     updateStage()
  99.   end repeat
  100.   set currentEventIndex to mCalcIndex(me)
  101.   mUpdatePreview(me)
  102. end
  103.  
  104. on mCalcIndex me
  105.   set v to the locV of sprite boxSprite
  106.   set p to float((v - topBoxLimit) * 1.0 / (bottomBoxLimit - topBoxLimit) * 1.0)
  107.   set numEvents to mGetNumberOfEvents(currentCategory)
  108.   set index to mGetLowerLimit(currentCategory) + integer(p * numEvents)
  109.   return index
  110. end
  111.  
  112. on mPositionBox me
  113.   alert("obsolete function")
  114. end
  115.  
  116. on mUpdatePreview me
  117.   set oldTextDescriptionList to []
  118.   repeat with i = 1 to 5
  119.     add(oldTextDescriptionList, the member of sprite getAt(previewSpriteList, i))
  120.   end repeat
  121.   set offset to currentEventIndex - 3
  122.   repeat with i = 1 to 5
  123.     set textDescription to ((offset + i) * 10) - 9
  124.     set textDescription to mValidateTextDescription(me, textDescription, i)
  125.     if not (textDescription = -1) then
  126.       set the member of sprite getAt(previewSpriteList, i) to member textDescription of castLib resourceCast
  127.       next repeat
  128.     end if
  129.     set the member of sprite getAt(previewSpriteList, i) to member "dummyPixel"
  130.   end repeat
  131.   repeat with i = 1 to 5
  132.     unloadMember(getAt(oldTextDescriptionList, i))
  133.   end repeat
  134.   set previousPicture to the member of sprite pictureSprite
  135.   if (resourceCast = the number of castLib "timeline") or (resourceCast = the number of castLib "bookweblist") then
  136.     set eventPointer to (currentEventIndex * 10) - 9 + 1
  137.     set textPointer to eventPointer + 1
  138.     set the member of sprite pictureSprite to member eventPointer of castLib resourceCast
  139.     set the member of sprite textSprite to member textPointer of castLib resourceCast
  140.   else
  141.     set eventPointer to (currentEventIndex * 10) - 9 + 3
  142.     set textPointer to eventPointer - 1
  143.     set the member of sprite pictureSprite to member eventPointer of castLib resourceCast
  144.     set the scrollTop of member textPointer of castLib resourceCast to 1
  145.     set the member of sprite textSprite to member textPointer of castLib resourceCast
  146.   end if
  147.   mFillSpace(me)
  148.   unloadMember(previousPicture)
  149. end
  150.  
  151. on mValidateTextDescription me, textDescription, index
  152.   set n to the number of castMembers of castLib resourceCast
  153.   set endOfCategory to currentEventIndex = mGetUpperLimit(currentCategory)
  154.   set startOfCategory to currentEventIndex = mGetLowerLimit(currentCategory)
  155.   set nearEndCategory to (mGetUpperLimit(currentCategory) - currentEventIndex) = 1
  156.   set nearStartCategory to (currentEventIndex - mGetLowerLimit(currentCategory)) = 1
  157.   case 1 of
  158.     (textDescription < 0):
  159.       set textDescription to -1
  160.     (textDescription > n):
  161.       set textDescription to -1
  162.     startOfCategory:
  163.       if (index = 1) or (index = 2) then
  164.         set textDescription to -1
  165.       end if
  166.     endOfCategory:
  167.       if (index = 4) or (index = 5) then
  168.         set textDescription to -1
  169.       end if
  170.     nearEndCategory:
  171.       if index = 5 then
  172.         set textDescription to -1
  173.       end if
  174.     nearStartCategory:
  175.       if index = 1 then
  176.         set textDescription to -1
  177.       end if
  178.   end case
  179.   return textDescription
  180. end
  181.  
  182. on mFillSpace me
  183.   set catName to mGetName(currentCategory)
  184.   set endOfCategory to currentEventIndex = mGetUpperLimit(currentCategory)
  185.   set startOfCategory to currentEventIndex = mGetLowerLimit(currentCategory)
  186.   set nearEndCategory to (mGetUpperLimit(currentCategory) - currentEventIndex) = 1
  187.   set nearStartCategory to (currentEventIndex - mGetLowerLimit(currentCategory)) = 1
  188.   case 1 of
  189.     startOfCategory:
  190.       set the member of sprite entryPlaceholderSprite to member (catName & "startCategory")
  191.     endOfCategory:
  192.       set the member of sprite entryPlaceholderSprite to member (catName & "EndCategory")
  193.     nearEndCategory:
  194.       set the member of sprite entryPlaceholderSprite to member (catName & "almostEndCategory")
  195.     nearStartCategory:
  196.       set the member of sprite entryPlaceholderSprite to member (catName & "almostStartCategory")
  197.     otherwise:
  198.       set the member of sprite entryPlaceholderSprite to member "dummyPixel"
  199.   end case
  200.   return(textDescription)
  201. end
  202.