global mapDataTable, mapMenuButtonList, mapTextObjectList, mapArrowObjectList, mapMenuObject, slideShiftH, mapMenuSprites, mapMaxColumns, mapHeadingSprite
set tempMenuName to menuName
repeat while 1
set nextOffset to offset(" ", tempMenuName)
if nextOffset <= 0 then
exit repeat
end if
put "_" into char nextOffset of tempMenuName
end repeat
if offset(RETURN & tempMenuName & " ", the text of field mapDataTable) <= 0 then
return
end if
if (count(mapMenuButtonList) >= 1) and (not forceChange or voidp(forceChange)) then
set currentMenu to getPropAt(mapMenuButtonList, count(mapMenuButtonList))
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
return
end if
end if
set newMenuButtonList to [:]
repeat with k = 1 to the number of words in menuName
set nextName to word 1 to k of menuName
addProp(newMenuButtonList, nextName, getMapButtonData(nextName, the number of words in menuName))
end repeat
set oldMenuCount to count(mapMenuButtonList)
set mapMenuButtonList to duplicate(newMenuButtonList)
set menuCount to count(mapMenuButtonList)
if (menuCount <> oldMenuCount) and (menuCount <> 1) then
if (menuCount > mapMaxColumns) and (menuCount > oldMenuCount) then
mapSlide(1, menuName)
else
if (oldMenuCount > mapMaxColumns) and (menuCount < oldMenuCount) then
mapSlide(-1, menuName)
end if
end if
end if
if menuCount > mapMaxColumns then
set numberOfColumns to mapMaxColumns
else
set numberOfColumns to menuCount
end if
set tempTextList to []
set tempArrowList to []
set startPoint to menuCount - 1
if startPoint <= 0 then
set startPoint to 1
end if
repeat with k = startPoint to menuCount
set nextMenuData to getAt(mapMenuButtonList, k)
set textInfo to getAt(nextMenuData, 1)
set arrowInfo to getAt(nextMenuData, 2)
repeat with m = 1 to count(textInfo)
append(tempTextList, getAt(textInfo, m))
end repeat
repeat with m = 1 to count(arrowInfo)
append(tempArrowList, getAt(arrowInfo, m))
end repeat
end repeat
death(mapMenuObject)
if count(tempTextList) >= 1 then
set mapMenuObject to new(script "mapMenuObject", tempTextList, tempArrowList, 15, 16)
end if
repeat with k = 1 to numberOfColumns
set nextSprite to getAt(mapMenuSprites, k)
set nextMenuName to word 1 to k + startPoint - 1 of menuName
set menuGraphicName to nextMenuName & " m u"
puppetSprite(nextSprite, 1)
set the castNum of sprite nextSprite to the number of member menuGraphicName
set nextShift to getShiftAmount(nextMenuName, the number of words in menuName)
set the locH of sprite nextSprite to getAt(mapRegPoint, 1) + (nextShift * slideShiftH)
end repeat
if numberOfColumns >= 1 then
puppetSprite(mapHeadingSprite, 1)
set the castNum of sprite mapHeadingSprite to the number of member (word 1 of menuName & " heading")
else
set the castNum of sprite mapHeadingSprite to the number of member "NULL"
end if
repeat with k = numberOfColumns + 1 to mapMaxColumns