home *** CD-ROM | disk | FTP | other *** search
/ LineOne ISP Sign-Up 5 / LineOne.iso / assets / cxt / scripts / parentScripts.cst / 00075_mainLogoService parent.ls < prev    next >
Encoding:
Text File  |  2001-01-27  |  4.7 KB  |  153 lines

  1. -- 2000.02.26
  2. -- Clive Green <clivegreen@atlas.co.uk>
  3.  
  4. ------------------------------------------------------------------------------------------------------
  5.  
  6. -- this displays the main logo within MIAW, using some positional data stored in the data castlib.
  7.  
  8. ------------------------------------------------------------------------------------------------------
  9.  
  10. -- declare properties:
  11. property main           -- main code directory object
  12. property logoName       -- the reference symbol for the logo to be used
  13. property maskSuffix     -- suffix string used to identify windowType mask bitmaps
  14. property miawFileName   -- the director movie file name to open
  15. property miawMaskName   -- the member name of a 1-bit bitmap used to define a custom windowType
  16. property miawMaskMember -- the member number of miawMaskName
  17. property miawRect       -- the onscreen position of the miaw
  18. property logoVisible    -- boolean indicating whether logoMiaw is currently visible
  19. property miaw           -- a reference to the Director MIAW entity
  20.  
  21. ------------------------------------------------------------------------------------------------------
  22.  
  23. on new me,L
  24.   
  25.   -- (1) extract and check arguments:
  26.   
  27.   -- check for a parameter list:
  28.   if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"mainLogoService:new"]
  29.   
  30.   -- a reference to the parent codebase is REQUIRED:
  31.   main = L[#main]
  32.   if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"mainLogoService:new"]
  33.   
  34.   --------------------
  35.   
  36.   -- (2) how are my logo elements named and numbered?
  37.   logoName   = #mainLogo
  38.   maskSuffix = "MiawMask"
  39.   
  40.   miawMaskName   = logoName & maskSuffix
  41.   miawMaskMember = member(miawMaskName).number
  42.   
  43.   --------------------
  44.   
  45.   -- (3) set/obtain my logo's positioning data:
  46.   
  47.   dm = main.getDataManager()
  48.   L = dm.getData([#set:#settings, #item:#mainLogo])
  49.   
  50.   if ilk(L) <> #propList then L = [:]
  51.   
  52.   -- what is the top-left corner of my miaw? 
  53.   x = L[#top]
  54.   if voidP(x) then x = 0
  55.   
  56.   y = L[#left]   
  57.   if voidP(y) then y = 0
  58.   
  59.   --------------------
  60.   
  61.   -- (4) obtain my logo's filepath:
  62.   
  63.   -- what is the reference to the miaw filePath to be used?
  64.   n = L[#filePathRef]
  65.   
  66.   -- resolve n to the filePath string of the miaw we want:
  67.   dL = dm.getData([#set:#filePaths, #item:n])
  68.   f = dL[#filePath]
  69.   
  70.   -- parse filepath for the current platform:
  71.   um = main.getUtilityMethods()
  72.   f = um.parseFilePath(f)
  73.   
  74.   -- prefix the filePath with the root directory path:
  75.   r = dm.getRootPath()
  76.   
  77.   -- finally - store the compiled filePath:
  78.   miawFileName = (r & f)
  79.   
  80.   --------------------
  81.   
  82.   -- (5) use the windowMask bitmap to determine the window dimensions:
  83.   n = member(miawMaskName).number
  84.   dx = member(n).width
  85.   dy = member(n).height
  86.   
  87.   -- store the miaw onscreen position to be used:
  88.   miawRect = rect(x,y,x+dx,y+dy)
  89.   
  90.   --------------------
  91.   
  92.   -- (6) initialise the logo miaw visibility flags:
  93.   logoVisible = 0
  94.   
  95.   -- pass back my address:
  96.   return me
  97.   
  98.   ----------------------------------------------------------------------------------------------------
  99.   
  100. on showLogo me
  101.   
  102.   -- first check that there is enough room for the logo to be safely shown:
  103.   
  104.   -- assume the logo goes in the extreme topleft corner of the screen -- is there enough space there?
  105.   if (miawRect.width > the stageLeft) and (miawRect.height > the stageTop) then
  106.     
  107.     -- the logo miaw can be taller than the vertical gap above the stage, OR
  108.     -- wider than the horizontal gap to the left of the stage - but not both:
  109.     return [#error:#notEnoughRoomForMiaw, #msg:"mainLogoService:showLogo"]
  110.     
  111.   end if
  112.   
  113.   --------------------
  114.   
  115.   -- use buddyAPI to verify the existence of the miaw file:
  116.   xm = main.getXtrasManager()
  117.   buddy = xm.getBuddyAPIxtra()
  118.   if (ilk(buddy) <> #instance) then return ┬¼
  119.   [#error:#xtraControllerMissing, #msg:"mainLogoService:showLogo needs buddyAPIxtra"]
  120.   
  121.   -- now check that the miaw file exists -- exit WITHOUT ERROR if it doesn't:
  122.   f = buddy.fileExists(miawFileName)
  123.   if not stringP(f) then return 0
  124.   
  125.   --------------------
  126.   
  127.   -- reference the logo miaw movie:
  128.   miaw = window(miawFileName)
  129.   
  130.   -- use a custom windowType (this works in Projectors only):
  131.   miaw.windowType = member(miawMaskMember)
  132.   
  133.   -- position window area, and open:
  134.   miaw.rect = miawRect
  135.   open miaw
  136.   
  137.   -- flag logo is 'visible':
  138.   logoVisible = 1
  139.   
  140.   ----------------------------------------------------------------------------------------------------
  141.   
  142. on clearLogo
  143.   
  144.   -- clean up and close logo window as neeeded:
  145.   if not(logoVisible) then return 0
  146.   
  147.   close miaw
  148.   forget miaw
  149.   
  150.   -- flag logo is 'invisible':
  151.   logoVisible = 0
  152.   
  153.   ----------------------------------------------------------------------------------------------------