home *** CD-ROM | disk | FTP | other *** search
/ The Dynamic Human Version 2.0 / DH2_CD2.ISO / pc / files / map.dxr / Internal_12_openMapMenu.ls < prev    next >
Encoding:
Text File  |  1998-11-13  |  3.3 KB  |  83 lines

  1. on openMapMenu menuName, forceChange
  2.   global mapDataTable, mapMenuButtonList, mapTextObjectList, mapArrowObjectList, mapMenuObject, slideShiftH, mapMenuSprites, mapMaxColumns, mapHeadingSprite
  3.   set tempMenuName to menuName
  4.   repeat while 1
  5.     set nextOffset to offset(" ", tempMenuName)
  6.     if nextOffset <= 0 then
  7.       exit repeat
  8.     end if
  9.     put "_" into char nextOffset of tempMenuName
  10.   end repeat
  11.   if offset(RETURN & tempMenuName & " ", the text of field mapDataTable) <= 0 then
  12.     return 
  13.   end if
  14.   if (count(mapMenuButtonList) >= 1) and (not forceChange or voidp(forceChange)) then
  15.     set currentMenu to getPropAt(mapMenuButtonList, count(mapMenuButtonList))
  16.     if (menuName = currentMenu) or ((offset(menuName, currentMenu) = 1) and not (menuName = currentMenu) and ((word 1 of menuName = word 1 of currentMenu) or (length(menuName) = length(currentMenu)))) then
  17.       return 
  18.     end if
  19.   end if
  20.   set newMenuButtonList to [:]
  21.   repeat with k = 1 to the number of words in menuName
  22.     set nextName to word 1 to k of menuName
  23.     addProp(newMenuButtonList, nextName, getMapButtonData(nextName, the number of words in menuName))
  24.   end repeat
  25.   set oldMenuCount to count(mapMenuButtonList)
  26.   set mapMenuButtonList to duplicate(newMenuButtonList)
  27.   set menuCount to count(mapMenuButtonList)
  28.   if (menuCount <> oldMenuCount) and (menuCount <> 1) then
  29.     if (menuCount > mapMaxColumns) and (menuCount > oldMenuCount) then
  30.       mapSlide(1, menuName)
  31.     else
  32.       if (oldMenuCount > mapMaxColumns) and (menuCount < oldMenuCount) then
  33.         mapSlide(-1, menuName)
  34.       end if
  35.     end if
  36.   end if
  37.   if menuCount > mapMaxColumns then
  38.     set numberOfColumns to mapMaxColumns
  39.   else
  40.     set numberOfColumns to menuCount
  41.   end if
  42.   set tempTextList to []
  43.   set tempArrowList to []
  44.   set startPoint to menuCount - 1
  45.   if startPoint <= 0 then
  46.     set startPoint to 1
  47.   end if
  48.   repeat with k = startPoint to menuCount
  49.     set nextMenuData to getAt(mapMenuButtonList, k)
  50.     set textInfo to getAt(nextMenuData, 1)
  51.     set arrowInfo to getAt(nextMenuData, 2)
  52.     repeat with m = 1 to count(textInfo)
  53.       append(tempTextList, getAt(textInfo, m))
  54.     end repeat
  55.     repeat with m = 1 to count(arrowInfo)
  56.       append(tempArrowList, getAt(arrowInfo, m))
  57.     end repeat
  58.   end repeat
  59.   death(mapMenuObject)
  60.   if count(tempTextList) >= 1 then
  61.     set mapMenuObject to new(script "mapMenuObject", tempTextList, tempArrowList, 15, 16)
  62.   end if
  63.   repeat with k = 1 to numberOfColumns
  64.     set nextSprite to getAt(mapMenuSprites, k)
  65.     set nextMenuName to word 1 to k + startPoint - 1 of menuName
  66.     set menuGraphicName to nextMenuName & " m u"
  67.     puppetSprite(nextSprite, 1)
  68.     set the castNum of sprite nextSprite to the number of member menuGraphicName
  69.     set nextShift to getShiftAmount(nextMenuName, the number of words in menuName)
  70.     set the locH of sprite nextSprite to getAt(mapRegPoint, 1) + (nextShift * slideShiftH)
  71.   end repeat
  72.   if numberOfColumns >= 1 then
  73.     puppetSprite(mapHeadingSprite, 1)
  74.     set the castNum of sprite mapHeadingSprite to the number of member (word 1 of menuName & " heading")
  75.   else
  76.     set the castNum of sprite mapHeadingSprite to the number of member "NULL"
  77.   end if
  78.   repeat with k = numberOfColumns + 1 to mapMaxColumns
  79.     set nextSprite to getAt(mapMenuSprites, k)
  80.     puppetSprite(nextSprite, 0)
  81.   end repeat
  82. end
  83.