home *** CD-ROM | disk | FTP | other *** search
- global delim, rootPath, contentPath, interfacePath, mainIndex, nextFreeTextCastIndex, nextFreeImageIndex, nextFreeThumbnailIndex, currentSection, currentThumbStart, defaultThumbnailMember, defaultImageMember, nextEnabled, backEnabled, mainMenuEnabled, contentBackEnabled, infoPopup, popupOpen, vlcpath, bannerUrl, showVLCLink
-
- on __init__
- rootPath = the moviePath
- delim = the last char in rootPath
- nextFreeTextCastIndex = 1
- nextFreeImageIndex = 1
- nextFreeThumbnailIndex = 1
- contentPath = pathJoin([rootPath, "DiscContents"])
- interfacePath = pathJoin([rootPath, "Interface"])
- menuIndexPath = pathJoin([interfacePath, "menu_items.txt"])
- defaultThumbnailMember = importDefaultThumbnail()
- defaultImageMember = importDefaultImage()
- if baFileExists(menuIndexPath) then
- createMenuObjects(menuIndexPath)
- getIssueNumber()
- else
- alert("No menu_items.txt found at: " & QUOTE & menuIndexPath & QUOTE)
- _player.quit()
- end if
- currentSection = mainIndex[1]
- bannerUrl = "http://www.google.com"
- loadBanner()
- nextEnabled = 0
- backEnabled = 0
- mainMenuEnabled = 0
- contentBackEnabled = 0
- popupOpen = 0
- showVLCLink = 0
- end
-
- on loadBanner
- banner_id_path = pathJoin([interfacePath, "banner.txt"])
- put banner_id_path
- t = getNetText(banner_id_path)
- if netDone(t) then
- ban = netTextResult(t)
- put ban
- banFile = ban.line[1]
- if (banFile contains "gif") or (banFile contains "GIF") then
- memNum = member("banner_gif_loader").memberNum
- member("banner_gif_loader").fileName = pathJoin([interfacePath, banFile])
- member(memNum).name = "banner_gif_loader"
- sprite(101).member = member(memNum)
- bannerUrl = ban.line[2]
- else
- memNum = member("banner_loader").memberNum
- member("banner_loader").importFileInto(pathJoin([interfacePath, banFile]))
- bannerUrl = ban.line[2]
- member(memNum).name = "banner_loader"
- sprite(101).member = member(memNum)
- end if
- end if
- end
-
- on getIssueNumber
- issuePath = pathJoin([interfacePath, "issue.txt"])
- if baFileExists(issuePath) then
- t = getNetText(issuePath)
- if netDone(t) then
- member("issue_number").text = netTextResult(t) & " "
- end if
- numchar = 0
- nums = "1234567890"
- repeat with c = 1 to the number of chars in the text of member "issue_number"
- if nums contains member("issue_number").char[c] then
- numchar = c - 1
- exit repeat
- end if
- end repeat
- if numchar > 0 then
- member("issue_number").char[1..numchar].color = rgb(145, 187, 1)
- member("issue_number").char[numchar + 1..member("issue_number").char.count].color = rgb(255, 255, 255)
- end if
- end if
- end
-
- on importDefaultImage
- iPath = pathJoin([interfacePath, "default_image.jpg"])
- defaultImageMember = member("default_image")
- if baFileExists(iPath) then
- defaultImageMember.importFileInto(iPath)
- end if
- return defaultImageMember
- end
-
- on importDefaultThumbnail
- tPath = pathJoin([interfacePath, "default_thumbnail.jpg"])
- defaultThumbnailMember = member("default_thumbnail")
- if baFileExists(tPath) then
- defaultThumbnailMember.importFileInto(tPath)
- end if
- return defaultThumbnailMember
- end
-
- on setMainMenuTitles
- spStart = 35
- repeat with i = spStart to 100
- sprite(i).visible = 0
- end repeat
- curSp = spStart
- repeat with i = 1 to mainIndex.count
- sprite(curSp).member.text = mainIndex[i].itemTitle
- sprite(curSp).visible = 1
- sprite(curSp).menuObject = mainIndex[i]
- if mainIndex[i].itemPath = EMPTY then
- sprite(curSp).Active = 0
- sprite(curSp).member.color = rgb(255, 255, 255)
- else
- sprite(curSp).Active = 1
- sprite(curSp).member.color = rgb(0, 0, 0)
- end if
- curSp = curSp + 1
- end repeat
- end
-
- on fallBackOpenFolder aPath
- if the last char in aPath = delim then
- Ok = baOpenFile(aPath, "normal")
- else
- lDel = 0
- repeat with i = 1 to aPath.char.count
- if aPath.char[i] = delim then
- lDel = i
- end if
- end repeat
- strippedPath = aPath.char[1..lDel]
- Ok = baOpenFile(strippedPath, "normal")
- end if
- end
-
- on playVideoVLC videoPath
- put videoPath
- put vlcpath
- sVideoPath = baShortFileName(videoPath)
- sVLCPath = baShortFileName(vlcpath)
- Ok = baShell("open", sVLCPath, sVideoPath, EMPTY, "normal")
- put "ok = " & Ok
- if Ok < 32 then
- fallBackOpenFolder(videoPath)
- end if
- end
-
- on createMenuObjects menuIndexPath
- mainIndex = []
- lastMenuObject = 0
- menuScriptLoader = getNetText(menuIndexPath)
- if netDone(menuScriptLoader) then
- menuScript = netTextResult(menuScriptLoader)
- repeat with i = 1 to menuScript.line.count
- thisLine = menuScript.line[i]
- if thisLine <> EMPTY then
- if thisLine.char[1..3] = "---" then
- atChar = 0
- repeat with a = 1 to thisLine.char.count
- if thisLine.char[a] = "@" then
- atChar = a
- exit repeat
- end if
- end repeat
- itemTitle = stripWhiteSpace(thisLine.char[4..atChar - 1])
- iPat = stripWhiteSpace(thisLine.char[atChar + 1..thisLine.length])
- if iPat.char.count > 0 then
- if iPat.char[1] <> "[" then
- itemPath = pathJoin([contentPath, stripWhiteSpace(thisLine.char[atChar + 1..thisLine.length])])
- else
- itemPath = iPat
- end if
- else
- itemPath = EMPTY
- end if
- mainIndex.append(createMenuNode(itemTitle, itemPath, i))
- lastMenuObject = mainIndex[mainIndex.count]
- next repeat
- end if
- if lastMenuObject = 0 then
- alert("Problem reading the menu_items.txt:: No main menu defined before" & QUOTE & thisLine & QUOTE & " at line: " & string(i))
- _player.quit()
- next repeat
- end if
- atChar = 0
- repeat with a = 1 to thisLine.char.count
- if thisLine.char[a] = "@" then
- atChar = a
- exit repeat
- end if
- end repeat
- itemTitle = stripWhiteSpace(thisLine.char[1..atChar - 1])
- itemPath = pathJoin([lastMenuObject.itemPath, stripWhiteSpace(thisLine.char[atChar + 1..thisLine.length])])
- lastMenuObject.children.append(createMenuNode(itemTitle, itemPath, i))
- end if
- end repeat
- end if
- end
-
- on gatherInfo aNode
- if aNode.infoText = 0 then
- if baFolderExists(aNode.itemPath) then
- txtLoader = getNetText(pathJoin([aNode.itemPath, "info.txt"]))
- txt = new(#text, castLib("text"))
- if netDone(txtLoader) then
- txt.text = netTextResult(txtLoader)
- end if
- aNode.infoText = txt
- parseFormattingInfo(aNode.infoText)
- imgPath = pathJoin([aNode.itemPath, "shot.jpg"])
- if baFileExists(imgPath) then
- member(nextFreeImageIndex, "images").importFileInto(imgPath)
- aNode.imageMember = member(nextFreeImageIndex, "images")
- nextFreeImageIndex = nextFreeImageIndex + 1
- end if
- cmsPath = pathJoin([aNode.itemPath, "cms.txt"])
- if baFileExists(cmsPath) then
- t = getNetText(cmsPath)
- if netDone(t) then
- res = netTextResult(t)
- parseContentButtons(res, aNode)
- end if
- end if
- end if
- end if
- end
-
- on parseContentButtons txt, node
- isVideo = 0
- repeat with i = 1 to txt.line.count
- vt = 0
- extra = EMPTY
- pType = txt.line[i].char[1]
- tail = txt.line[i].char[2..txt.line[i].char.count]
- if tail contains "[" then
- bs = 1
- repeat with j = 1 to tail.char.count
- if tail.char[j] = "[" then
- bs = j
- exit repeat
- end if
- end repeat
- extra = tail.char[bs + 1..tail.char.count]
- pContent = stripWhiteSpace(tail.char[1..bs - 1])
- else
- pContent = stripWhiteSpace(tail)
- end if
- if pType = "l" then
- vt = 1
- else
- if pType = "f" then
- vt = 2
- pContent = pathJoin([node.itemPath, pContent])
- else
- if pType = "v" then
- vt = 3
- isVideo = 1
- isVLC = baFindApp("mov")
- if isVLC <> EMPTY then
- if isVLC contains "vlc" then
- vt = 3
- vlcpath = isVLC
- pContent = validatePathName(pathJoin([node.itemPath, pContent]))
- else
- if the platform contains "mac" then
- vt = 2
- pContent = validatePathName(pathJoin([node.itemPath, pContent]))
- else
- vt = 2
- pContent = validatePathName(pathJoin([node.itemPath, stripFileName(pContent)]))
- end if
- end if
- else
- vt = 2
- pContent = validatePathName(pathJoin([node.itemPath, stripFileName(pContent)]))
- end if
- else
- if pType = "p" then
- vt = 4
- pContent = validatePathName(pathJoin([node.itemPath, pContent]))
- end if
- end if
- end if
- end if
- node.contentButtons.append(createContentItem(pContent, vt, extra, isVideo))
- isVideo = 0
- end repeat
- end
-
- on stripFileName aPath
- st = 1
- outPath = EMPTY
- delimChars = ":\/"
- if (aPath contains ":") or (aPath contains "/") or (aPath contains "\") then
- repeat with dd = 1 to the number of chars in aPath
- if delimChars contains aPath.char[dd] then
- st = dd
- end if
- end repeat
- outPath = aPath.char[1..st - 1]
- end if
- return outPath
- end
-
- on parseFormattingInfo aTxt
- greenStart = 0
- i = 1
- aTxt.fontSize = 14
- aTxt.antialias = 1
- aTxt.antiAliasThreshold = 1
- aTxt.font = "WeddingSans Medium *"
- aTxt.color = rgb(255, 255, 255)
- repeat while i <= aTxt.char.count
- if aTxt.char[i] = "<" then
- greenStart = i
- end if
- if aTxt.char[i] = ">" then
- if greenStart > 0 then
- aTxt.char[greenStart..i].color = rgb(145, 181, 1)
- delete aTxt.char[greenStart]
- delete aTxt.char[i - 1]
- greenStart = 0
- end if
- end if
- i = i + 1
- end repeat
- end
-
- on gatherThumbnails aNode
- if aNode.children.count > 0 then
- repeat with i = 1 to aNode.children.count
- if aNode.children[i].thumbnailMember = 0 then
- thumbPath = pathJoin([aNode.children[i].itemPath, "thumb.jpg"])
- if baFileExists(thumbPath) then
- member(nextFreeThumbnailIndex, "thumbnails").importFileInto(thumbPath)
- aNode.children[i].thumbnailMember = member(nextFreeThumbnailIndex, "thumbnails")
- nextFreeThumbnailIndex = nextFreeThumbnailIndex + 1
- next repeat
- end if
- aNode.children[i].thumbnailMember = defaultThumbnailMember
- end if
- end repeat
- end if
- end
-
- on loadSectionPage aNode
- currentThumbStart = 1
- gatherThumbnails(aNode)
- showThumbnails(currentThumbStart, aNode)
- currentSection = aNode
- end
-
- on showThumbnails thumbstart, node
- if node.children.count > 0 then
- member("section_title").text = EMPTY
- member("section_info").text = EMPTY
- go(marker("main"))
- baseSprite = 14
- contentBackEnabled = 1
- s = thumbstart
- e = min(thumbstart + 5, node.children.count)
- curSp = 1
- repeat while s <= e
- sendSprite(baseSprite, #setContentNode, node.children[s])
- sprite(baseSprite + 2).member = node.children[s].thumbnailMember
- sprite(baseSprite + 1).member.text = node.children[s].itemTitle
- sprite(baseSprite).visible = 1
- sprite(baseSprite + 1).visible = 1
- sprite(baseSprite + 2).visible = 1
- baseSprite = baseSprite + 3
- s = s + 1
- end repeat
- sprite(7).member.text = node.itemTitle
- gatherInfo(node)
- sprite(8).member.text = string(node.infoText.text)
- parseFormattingInfo(sprite(8).member)
- backEnabled = 0
- nextEnabled = 0
- if thumbstart > 1 then
- backEnabled = 1
- end if
- if (thumbstart + 5) < node.children.count then
- nextEnabled = 1
- end if
- if (thumbstart + 5) > node.children.count then
- diff = thumbstart + 5 - node.children.count
- startHidingSp = 14 + (3 * (6 - diff))
- repeat with i = 5 - diff to 5
- sprite(startHidingSp).visible = 0
- sprite(startHidingSp + 1).visible = 0
- sprite(startHidingSp + 2).visible = 0
- startHidingSp = startHidingSp + 3
- end repeat
- end if
- tEnd = min(thumbstart + 5, node.children.count)
- member("showing_txt").text = "Showing " & string(thumbstart) & "-" & string(tEnd) & " of " & string(node.children.count)
- nums = "0123456789"
- lastNum = 0
- repeat with c = 8 to member("showing_txt").char.count
- if member("showing_txt").char[c] = "f" then
- exit repeat
- end if
- if nums contains member("showing_txt").char[c] then
- lastNum = c
- end if
- end repeat
- member("showing_txt").char[8..lastNum].color = rgb(255, 255, 255)
- sprite(11).visible = 1
- sprite(12).visible = 1
- sprite(33).visible = 0
- else
- contentBackEnabled = 0
- showContentPage(node)
- end if
- end
-
- on showContentPage aNode
- showVLCLink = 0
- if aNode.isWebLink = 0 then
- member("product_title").text = EMPTY
- member("product_info").text = EMPTY
- repeat with k = 1 to 6
- member("cbutton_" & k).text = EMPTY
- end repeat
- go(marker("content"))
- sprite(32).visible = 0
- gatherInfo(aNode)
- member("product_title").text = aNode.itemTitle
- if aNode.infoText <> 0 then
- sprite(9).member = aNode.infoText
- else
- sprite(9).member.text = EMPTY
- end if
- sprite(10).member = aNode.imageMember
- spBut = 19
- repeat with i = spBut to spBut + 5
- sprite(i).visible = 0
- end repeat
- s = spBut
- lastBut = 5
- if aNode.contentButtons.count > 5 then
- lastBut = 5
- else
- lastBut = aNode.contentButtons.count
- end if
- lastBut = min(spBut + 5, lastBut)
- repeat with i = 1 to aNode.contentButtons.count
- sprite(s).visible = 1
- sprite(s).myType = aNode.contentButtons[i].itemType
- sprite(s).myLink = aNode.contentButtons[i].itemPath
- if aNode.contentButtons[i].hasVideo = 1 then
- showVLCLink = 1
- end if
- if aNode.contentButtons[i].extraTitle = EMPTY then
- if aNode.contentButtons[i].itemType = 1 then
- sprite(s).member.text = "+ Visit Website"
- else
- if aNode.contentButtons[i].itemType = 2 then
- sprite(s).member.text = "+ Open Folder"
- else
- if aNode.contentButtons[i].itemType = 3 then
- showVLCLink = 1
- put aNode.contentButtons[i].itemPath
- isVLC = baFindApp("mov")
- if isVLC contains "vlc" then
- sprite(s).member.text = "+ Play Video in VLC"
- sprite(32).visible = 1
- else
- sprite(s).member.text = "+ Open Folder"
- sprite(32).visible = 1
- end if
- end if
- end if
- end if
- else
- sprite(s).member.text = "+ " & aNode.contentButtons[i].extraTitle
- end if
- s = s - 1
- end repeat
- if aNode.itemTitle = "home" then
- sprite(11).visible = 0
- sprite(12).visible = 0
- else
- sprite(11).visible = 1
- sprite(12).visible = 1
- end if
- if showVLCLink = 1 then
- sprite(32).visible = 1
- else
- sprite(32).visible = 0
- end if
- else
- gotoNetPage(aNode.itemPath)
- end if
- end
-
- on showInfoPopup txtPath, aTitle
- put txtPath
- if baFileExists(txtPath) then
- infoPopup = window().new(pathJoin([interfacePath, "POPUP.dir"]))
- infoPopup.open()
- tell infoPopup
- loadTextFile(txtPath)
- end tell
- end if
- end
-
- on gatherContentItems aNode
- content = []
- end
-
- on createMenuNode itemTitle, itemPath, indexNum
- retObject = [:]
- retObject[#itemTitle] = itemTitle
- retObject[#indexNum] = indexNum
- retObject[#itemPath] = itemPath
- retObject[#children] = []
- retObject[#isWebLink] = 0
- retObject[#imageMember] = 0
- retObject[#thumbnailMember] = 0
- retObject[#infoText] = 0
- retObject[#contentButtons] = []
- put itemPath
- if itemPath.char[1] = "[" then
- put itemPath
- retObject[#isWebLink] = 1
- retObject[#itemPath] = stripWhiteSpace(retObject.itemPath.char[2..retObject.itemPath.length - 1])
- end if
- return retObject
- end
-
- on createContentItem itemPath, pType, extraTitle, isVideo
- retObject = [:]
- retObject[#itemPath] = itemPath
- retObject[#itemType] = pType
- retObject[#extraTitle] = extraTitle
- retObject[#hasVideo] = isVideo
- return retObject
- end
-
- on stripWhiteSpace aString
- repeat while aString.char[1] = SPACE
- delete char 1 of aString
- end repeat
- repeat while aString.char[aString.length] = SPACE
- delete char aString.length of aString
- end repeat
- return aString
- end
-
- on hideGreenHilight
- sprite(33).visible = 0
- end
-
- on setGreenHilight _loch, _locv
- sprite(33).locH = _loch
- sprite(33).locV = _locv
- sprite(33).visible = 1
- end
-
- on validatePathName aPath
- if the platform contains "mac" then
- wrongChars = "\/"
- rightChar = ":"
- else
- wrongChars = ":/"
- rightChar = "\"
- end if
- put aPath
- repeat with g = 1 to aPath.char.count
- if (wrongChars contains aPath.char[g]) and (g > 2) then
- outPath = outPath & rightChar
- next repeat
- end if
- outPath = outPath & aPath.char[g]
- end repeat
- put outPath
- return outPath
- end
-
- on pathJoin itemList
- retString = itemList[1]
- numChars = retString.char.count
- if retString.char[numChars] = delim then
- delete char -30000 of retString
- end if
- repeat with i = 2 to itemList.count
- fud = itemList[i]
- if the last char in fud = delim then
- delete char -30000 of fud
- end if
- retString = retString & delim & fud
- end repeat
- needsFinalDelim = 1
- finalPathElement = itemList[itemList.count]
- numChars = finalPathElement.char.count
- repeat with i = 1 to numChars
- if finalPathElement.char[i] = "." then
- needsFinalDelim = 0
- exit repeat
- end if
- end repeat
- if the last char in finalPathElement = delim then
- needsFinalDelim = 0
- end if
- if needsFinalDelim = 1 then
- retString = retString & delim
- end if
- return retString
- end
-
- on prepareMovie
- __init__()
- end
-