home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Stickerpedia Stickerbook
/
Stickerbook.iso
/
pc
/
DATA
/
objects.cxt
/
00061_Script_oAssetHQ
< prev
next >
Wrap
Text File
|
2003-03-19
|
25KB
|
743 lines
--¨
oAssetHQ
global oHQ
global oAssetHQ
global oFileIO
global oMarvin
global gPathDelim -- "\" or ":" depending on the platform
global gCDPath
property pCallingSection -- can be: #themes, #index, #introduction, #maps, #timeline, #bookmark
property pChosenSelection -- can contain custom data, or default data, if user accesses datascreen for the first time
property pAssetPath -- the pathname to the assets folder
property pPictureBasicList -- Contains a list of all bitmap files in the assets\pictures\basic folder
property pPictureBookList -- Contains a list of all bitmap files in the assets\pictures\book folder
property pPictureLargeList -- Contains a list of all bitmap files in the assets\pictures\large folder
property pPictureTimeLineList -- Contains a list of all bitmap files in the assets\pictures\timeline folder
property pIconList -- Contains a list of all icon members in the 'icons' cast
property pVideoList -- Contains a list of all video files in the assets\video folder
property pAudioList -- Contains a list of all audio files in the assets\audio folder
property pTextList -- Contains a list of all text members in the 'text' cast
property pAssetIndex -- this list has an entry for every record as a property; the value assigned to it contains the assets associated to it
property pIndexErrorLog -- this variable contains a list of all erros that occur while trying to index the asset lists
property pNumOfRecs -- the number of records contained in the database, stored here once rather than doing lots of count(x)
property pCurRecDetailsLst -- If a record was selected, this list contains four properties
---------------------------------- #pictures, #au, #vi, #te
property pImpMbrTxt -- contains the member reference to the blank text member used for importfileInto
property pImpMbrPicBasic -- contains the member reference to the blank basic Picture member used for importfileInto
property pImpMbrPicLarge -- contains the member reference to the blank large Picture member used for importfileInto
property pImpMbrPicSino -- contains the member reference to the blank sino Picture member used for importfileInto
property pImpMbrVideo -- contains the member reference to the blank Video member used for importfileInto
property pImpMbrAudio -- contains the member reference to the blank Audio member used for importfileInto
property pImportMbrBookList -- contains a list of member references for book picture import
property pCurRecord -- the record number of the record currently being didplaued
on new me, updateMode
addObject me
pAssetPath = gCDPath & "assets" & gPathDelim
pIndexErrorLog = ""
pImpMbrTxt = member ("importText", "database")
pImpMbrPicBasic = member ("importPictureBasic", "database")
pImpMbrPicLarge = member ("importPictureLarge", "database")
pImpMbrPicSino = member ("importSino", "database")
pImpMbrVideo = member ("importvideo", "database")
pImpMbrAudio = member ("importaudio", "database")
pImportMbrBookList = [member ("importPictureBook 1", "database"), member ("importPictureBook 2", "database"), member ("importPictureBook 3", "database"), member ("importPictureBook 4", "database")]
if updateMode = #update then
initImportMembers me
-- uncomment the next to lines, when assets have changed:
makeAssetList me
createIndex me
writeAllListsToFile me
else
getAllListsFromFile
--fixAssetIndex me
end if
return me
end
on fixAssetIndex me
numOfEntries = pAssetIndex.count
-- repeat with n = 1 to 100
repeat with n = 1 to numOfEntries
theType = pAssetIndex[n][#type]
pics = pAssetIndex[n][#details][#ba]
if theType = #sino then
if pics.count >= 2 then
secondPic = pics[2]
-- put secondPic.char[8..11]
if secondPic.char[8..11] = "sino" then
put "secondPic: " & secondPic
else
put "theType: " & theType
put "pics: " & pics
put "secondPic: " & secondPic
end if
end if
end if
end repeat
end
on writeAllListsToFile me
loFileIO = new(script "oFileIO")
put "Writing pPictureBasicList.ini"
writeFile loFileIO, the pathname & "~lists:assethq:", "pPictureBasicList.ini", string(pPictureBasicList)
put "Done"
put "Writing pPictureBookList.ini"
writeFile loFileIO, the pathname & "~lists:assethq:", "pPictureBookList.ini", string(pPictureBookList)
put "Done"
put "Writing pPictureLargeList.ini"
writeFile loFileIO, the pathname & "~lists:assethq:", "pPictureLargeList.ini", string(pPictureLargeList)
put "Done"
put "Writing pPictureTimeLineList.ini"
writeFile loFileIO, the pathname & "~lists:assethq:", "pPictureTimeLineList.ini", string(pPictureTimeLineList)
put "Done"
put "Writing pIconList.ini"
writeFile loFileIO, the pathname & "~lists:assethq:", "pIconList.ini", string(pIconList)
put "Done"
put "Writing pVideoList.ini"
writeFile loFileIO, the pathname & "~lists:assethq:", "pVideoList.ini", string(pVideoList)
put "Done"
put "Writing pAudioList.ini"
writeFile loFileIO, the pathname & "~lists:assethq:", "pAudioList.ini", string(pAudioList)
put "Done"
put "Writing pTextList.ini"
writeFile loFileIO, the pathname & "~lists:assethq:", "pTextList.ini", string(pTextList)
put "Done"
put "Writing pAssetIndex.ini - please wait, this may take some time"
writeFile loFileIO, the pathname & "~lists:assethq:", "pAssetIndex.ini", string(pAssetIndex)
put "Done"
loFileIO = void
put "Updating oAssetHQ - Finished"
tempText = oHQ.pVersionInfoList[2] && oHQ.pVersionInfoList[3] && "UPDATE on" && the long date & RETURN& RETURN
tempText = tempText && "New oAssetHQ list files saved:" && the long time
member("updating log internal", "objects").text = tempText
end
on getAllListsFromFile
loFileIO = new(script "oFileIO")
pPictureBasicList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pPictureBasicList.ini"))
pPictureBookList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pPictureBookList.ini"))
pPictureLargeList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pPictureLargeList.ini"))
pPictureTimeLineList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pPictureTimeLineList.ini"))
pIconList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pIconList.ini"))
pVideoList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pVideoList.ini"))
pAudioList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pAudioList.ini"))
pTextList = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pTextList.ini"))
pAssetIndex = value(getFile (loFileIO, the pathname & "~lists" & gPathDelim & "assethq" & gPathDelim, "pAssetIndex.ini"))
loFileIO = void
end
on initImportMembers me
pImpMbrPicBasic.picture = member("importPictureBasicEmpty").picture
pImpMbrPicLarge.picture = member("importPictureLargeEmpty").picture
pImpMbrPicSino.picture = member("importPictureSinoEmpty").picture
repeat with n = 1 to 4
pImportMbrBookList[n].picture = member("importPictureBook Empty").picture
pImportMbrBookList[n].name = "importPictureBook" && string(n)
end repeat
-- importFileInto pImpMbrVideo, pAssetPath & "_video.mov"
-- importFileInto pImpMbrAudio, pAssetPath & "_audio.mov"
pImpMbrVideo.filename = pAssetPath & "_video.mov"
pImpMbrAudio.filename = pAssetPath & "_audio.mov"
pImpMbrVideo.name = "importvideo"
pImpMbrVideo.pausedAtStart = 1
pImpMbrAudio.name = "importaudio"
pImpMbrAudio.pausedAtStart = 1
member("importBookText 1", "database").text = " "
member("importBookText 2", "database").text = " "
member("importBookText 3", "database").text = " "
member("importBookText 4", "database").text = " "
member("importBookText 5", "database").text = " "
member("importBookText 6", "database").text = " "
member("importText", "database").text = " "
member("importTextSino", "database").text = " "
end
on getBookPicture me, aFilename, aPosition
importBitmap me, (pImportMbrBookList[aPosition]), pAssetPath & "pictures" & gPathDelim & "book" & gPathDelim & aFilename , ("importPictureBook" && string(aPosition))
end
on getTLPicture me, aFilename, aPosition
importBitmap me, (pImportMbrBookList[aPosition]), (pAssetPath & "pictures" & gPathDelim & "timeline" & gPathDelim & aFilename ), ("importPictureBook" && string(aPosition))
end
on getTimeLinePicture me, aFilename
importBitmap me, pImpMbrPicBasic, (pAssetPath & "pictures" & gPathDelim & "timeline" & gPathDelim & aFilename), "importPictureBasic"
end
on getBasicPicture me, aFilename
importBitmap me, pImpMbrPicBasic, (pAssetPath & "pictures" & gPathDelim & "basic" & gPathDelim & aFilename ), "importPictureBasic"
end
on getLargePicture me, aFilename
importBitmap me, pImpMbrPicLarge, (pAssetPath & "pictures" & gPathDelim & "large" & gPathDelim & aFilename), "importPictureLarge"
end
on getSinoPicture me, aFilename
importBitmap me, pImpMbrPicSino, (pAssetPath & "pictures" & gPathDelim & "basic" & gPathDelim & aFilename), "importSino"
end
on importBitmap me, theMember, pathAndFilename, originalMemberName
importFileInto theMember, pathAndFilename
theMember.name = originalMemberName
-- theMember.fileName = pathAndFilename
-- theMember.centerRegPoint = 1
end
on getVideo me, aFilename
-- importFileInto pImpMbrVideo, pAssetPath & "video" & gPathDelim & aFilename
pImpMbrVideo.fileName = pAssetPath & "video" & gPathDelim & aFilename
pImpMbrVideo.name = "importvideo"
pImpMbrVideo.pausedAtStart = 1
end
on getAudio me, aFilename
-- importFileInto pImpMbrAudio, pAssetPath & "audio" & gPathDelim & aFilename
pImpMbrAudio.fileName = pAssetPath & "audio" & gPathDelim & aFilename
pImpMbrAudio.name = "importaudio"
pImpMbrAudio.pausedAtStart = 1
end
on makeAssetList me
if gPathDelim = "\" then
-- yuck it's Windows:
pPictureBasicList = baFileList( pAssetPath & "pictures" & gPathDelim & "basic" & gPathDelim, "*.jpg" )
-- updateProgressBar ("makeAssetList: Pictures")
pPictureBookList = baFileList( pAssetPath & "pictures" & gPathDelim & "book" & gPathDelim, "*.jpg" )
-- updateProgressBar ("makeAssetList: BookPictures")
pPictureLargeList = baFileList( pAssetPath & "pictures" & gPathDelim & "large" & gPathDelim, "*.jpg" )
-- updateProgressBar ("makeAssetList: Large Pictures")
pPictureTimeLineList = baFileList( pAssetPath & "pictures" & gPathDelim & "timeline" & gPathDelim, "*.jpg" )
-- updateProgressBar ("makeAssetList: TimeLinePictures")
pVideoList = baFileList( pAssetPath & "video" & gPathDelim, "*.mov" )
-- updateProgressBar ("makeAssetList: Videos")
pAudioList = baFileList( pAssetPath & "audio" & gPathDelim, "*.mov" )
-- updateProgressBar ("makeAssetList: Audio files")
else
-- Mac:
pPictureBasicList = baFileList( pAssetPath & "pictures" & gPathDelim & "basic" & gPathDelim, "" )
-- updateProgressBar ("makeAssetList: Pictures")
pPictureBookList = baFileList( pAssetPath & "pictures" & gPathDelim & "book" & gPathDelim, "" )
-- updateProgressBar ("makeAssetList: BookPictures")
pPictureLargeList = baFileList( pAssetPath & "pictures" & gPathDelim & "large" & gPathDelim, "" )
-- updateProgressBar ("makeAssetList: Large Pictures")
pPictureTimeLineList = baFileList( pAssetPath & "pictures" & gPathDelim & "timeline" & gPathDelim, "" )
-- updateProgressBar ("makeAssetList: TimeLinePictures")
pVideoList = baFileList( pAssetPath & "video" & gPathDelim, "" )
-- updateProgressBar ("makeAssetList: Videos")
pAudioList = baFileList( pAssetPath & "audio" & gPathDelim, "" )
-- updateProgressBar ("makeAssetList: Audio files")
end if
--- text files and icon files are not external - they are already imported into the cast called "text" and 'icons' respectively:
-- updateProgressBar ("makeAssetList: Captions")
pTextList = []
set lastMember = the number of members of castlib "text"
repeat with n = 1 to lastMember
memberType = member(n,"text").type
if memberType = #text or memberType = #field then
add pTextList, member(n,"text").name
end if
end repeat
-- check whether text list contains incorrectly named files
result = checkIntegrityofTextFileNames(me, pTextList)
if result.count then
customAlert "There are some text files with incorrect names. See the message window for details."
put result
halt
end if
-- updateProgressBar ("makeAssetList: Icons")
pIconList = []
set lastMember = the number of members of castlib "icons"
repeat with n = 1 to lastMember
curMember = member(n,"icons")
if curMember.type = #bitmap then
add pIconList, curMember.name
end if
end repeat
-- the first member is a blank "missing" icon:
pIconList.deleteAt(1)
-- updateProgressBar ("makeAssetList: sorting lists")
-- sort all lists:
sort pPictureBasicList
-- updateProgressBar ("makeAssetList: sorting pPictureBasicList")
sort pPictureBookList
-- updateProgressBar ("makeAssetList: sorting pPictureBookList")
sort pPictureLargeList
-- updateProgressBar ("makeAssetList: sorting pPictureLargeList")
sort pPictureTimeLineList
-- updateProgressBar ("makeAssetList: sorting pPictureTimeLineList")
sort pIconList
-- updateProgressBar ("makeAssetList: sorting pIconList")
sort pVideoList
-- updateProgressBar ("makeAssetList: sorting pVideoList")
sort pAudioList
-- updateProgressBar ("makeAssetList: sorting pAudioList")
sort pTextList
-- updateProgressBar ("makeAssetList: sorting pTextList")
end
on checkIntegrityofTextFileNames me, theTextList
-- theTextList = typically this would be oAssetHQ.pTextList
-- there are two types of names for text files: "9853_1_basic_t" and "6551_5_time_t"
-- time texts are only in the six thousand range
numOfFiles = theTextList.count
problemFiles = []
repeat with curWord in theTextList
numOfChars = curWord.length
if not (numOfChars >= 13) then
problemFiles.add(curWord)
end if
end repeat
return problemFiles
end
on createIndex me
-- BytesAfter = the freebytes
-- every record must a caption and an icon
-- presuming that icons for all records are available
-- this handler goes through the icon list and finds material with correlating numbers
pAssetIndex = [:]
-- for now we take the icon lists as the measure -
-- we may get a better source of record numbers from somewhere else at some other point
-- updateProgressBar ("makeAssetList: creating index")
pNumOfRecs = count(pIconList)
repeat with n = 1 to pNumOfRecs
curRecord = pIconList[n].char[1..4]
foundDetails = getrecordDetails(me, curRecord)
addProp pAssetIndex, curRecord, foundDetails
end repeat
-- Bytesbefore = the freebytes
--
-- put "Bytesbefore: " & Bytesbefore
-- put "BytesAfter: " & BytesAfter
--
-- put "Difference:" && (BytesAfter - Bytesbefore)/1024
end
on getrecordDetails me, recordnumber
numberOfFoundAssets = 0
-- make 0001 out of 1 etc:
-- if integerP(recordnumber) then recordnumber = triplePad(oMarvin, recordnumber)
-- initialise pCurRecDetailsLst, which will be the return value:
curDetailsList = [#ba:[], #bo:[], #la:[], #tl:[], #vi:[], #te:[], #au:[]]
-- we will then search text, audio, video and pictures.
-- The result will go into 'currentFoundList' which gets re-initialised
-- after every search:
currentFoundList = []
-- search pictureLists:
currentFoundList = searchAssetList (me, pPictureBasicList, recordnumber)
curDetailsList[#ba] = currentFoundList
numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
currentFoundList = searchAssetList (me, pPictureBookList, recordnumber)
curDetailsList[#bo] = currentFoundList
numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
currentFoundList = searchAssetList (me, pPictureLargeList, recordnumber)
curDetailsList[#la] = currentFoundList
numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
currentFoundList = searchAssetList (me, pPictureTimeLineList, recordnumber)
curDetailsList[#tl] = currentFoundList
numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
-- search audioList:
currentFoundList = searchAssetList (me, pAudioList, recordnumber)
curDetailsList[#au] = currentFoundList
numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
-- search videoList:
currentFoundList = searchAssetList (me, pVideoList, recordnumber)
curDetailsList[#vi] = currentFoundList
numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
-- search textList:
currentFoundList = searchAssetList (me, pTextList, recordnumber)
curDetailsList[#te] = currentFoundList
numberOfFoundAssets = numberOfFoundAssets + count(currentFoundList)
if numberOfFoundAssets then
-- determine the recordtype:
recType = determineRecType(me, recordnumber, curDetailsList)
else
curDetailsList = #noAssetsFound
recType = #unkown
end if
return [#type: recType, #details: curDetailsList]
end
on determineRecType me, recordnumber, curDetailsList
retVal = #notFound
typeIdentifier = value(recordnumber)
numOfBasicPics = curDetailsList[#ba].count
if numOfBasicPics then
-- we have some basic sized pictures
-- it can only be a standard record or an audio or video record
if curDetailsList[#au].count then
retVal = #audio
else if curDetailsList[#vi].count then
retVal = #video
else
-- now determine whether the record is standard or sino:
-- we assume it is standard
retVal = #standard
-- unless proved otherwise:
-- the theory is that sino pictures always occupy place two in the list
if numOfBasicPics > 1 then
-- put (curDetailsList[#ba][2]).char[8..11]
if (curDetailsList[#ba][2]).char[8..11] = "sino" then
retVal = #sino
end if
--put "curDetailsList: " & curDetailsList
end if
end if
else if ( (typeIdentifier >= 8000) and (typeIdentifier < 9000) ) or curDetailsList[#bo].count then
-- it's a Book entry
retVal = #book
else if ( (typeIdentifier >= 6000) and (typeIdentifier < 7000) ) or curDetailsList[#tl].count then
-- it's a timeline entry
retVal = #timeLine
end if
if retVal = #notFound then
-- put recordnumber
end if
return retVal
end
on searchAssetList me, whichList, recordnumber
currentFoundList = []
maxPointer = count(whichList)
currentPointer = findPosNear(whichList, recordnumber)
if currentPointer > 0 and currentPointer <= maxPointer then
currentFoundTerm = whichList[currentPointer]
-- check wether this first found asset name is an exact match
-- or wether findposNear has simply returned three matching zeros:
if currentFoundTerm.char[1..4] = recordnumber then
-- found a record which matches exactly.
-- let's see wether there are more:
repeat while 1
-- add currentFoundList, currentFoundTerm
if currentFoundTerm.char[1..4] = recordnumber then
add currentFoundList, currentFoundTerm
else
exit repeat
end if
currentPointer = currentPointer + 1
if currentPointer > maxPointer then
exit repeat
end if
currentFoundTerm = whichList[currentPointer]
end repeat
end if
end if
return currentFoundList
end
on checkintegrity me
-- this hander checks whether the database, and asset information makes sense
put "Checking integrity..."
tempText = ""
repeat with n = 1 to pNumOfRecs
curDetails = pAssetIndex[n][#details]
if listP(curDetails) then
if count (curDetails[#te]) = 0 then
recordNumber = pAssetIndex.getPropAt(n)
if not recordNumber.char[1] = "6" then tempText = tempText & RETURN & recordNumber
end if
end if
end repeat
if tempText <> "" then
pIndexErrorLog = pIndexErrorLog & RETURN & tempText
pIndexErrorLog = pIndexErrorLog & RETURN & "-------------------------------------"
pIndexErrorLog = pIndexErrorLog & RETURN & "Text files with no icons:" & RETURN
else
pIndexErrorLog = pIndexErrorLog & RETURN & "All Icons have captions: OK" & RETURN
end if
tempText = ""
-- reverse lookup - go through text list and see whether there is an icon for every text file:
numOfTextMembers = pTextList.count
repeat with n = 1 to numOfTextMembers
curRec = pTextList[n].char[1..4]
if pAssetIndex.findPos(curRec) then
next repeat
else
if not curRec.char[1] = "6" then tempText = tempText & RETURN & curRec
end if
end repeat
if tempText <> "" then
pIndexErrorLog = pIndexErrorLog & RETURN & tempText
pIndexErrorLog = pIndexErrorLog & RETURN & "-------------------------------------"
pIndexErrorLog = pIndexErrorLog & RETURN & "The type of the following records couldn't be determined:" & RETURN
else
pIndexErrorLog = pIndexErrorLog & RETURN & "All Text files have icons: OK" & RETURN
end if
tempText = ""
-- now check whether there are any records where the type couldn't be determined:
repeat with n = 1 to pNumOfRecs
curType = pAssetIndex[n][#type]
-- put "curType: " & curType && "(" & pAssetIndex.getPropAt(n) & ")"
if curType = #notFound then
if not pAssetIndex.getPropAt(n).char[1] = "6" then tempText = tempText & RETURN & pAssetIndex.getPropAt(n)
end if
end repeat
if tempText <> "" then
pIndexErrorLog = pIndexErrorLog & RETURN & tempText
else
pIndexErrorLog = pIndexErrorLog & RETURN & "All record types could be determined: OK" & RETURN
end if
-- checking lists for duplicates:
tempText = ""
result = checkListForDuplicates (oMarvin, pIconList)
if result.count then
tempText = tempText & "pIconList contains the following duplicates:" & RETURN & result
else
tempText = tempText & "pIconList: OK"& RETURN
end if
result = checkListForDuplicates (oMarvin, pTextList)
if result.count then
tempText = tempText & "pTextList contains the following duplicates:" & RETURN & result
else
tempText = tempText & "pTextList: OK"& RETURN
end if
result = checkListForDuplicates (oMarvin, pAssetIndex)
if result.count then
tempText = tempText & "pAssetIndex contains the following duplicates:" & RETURN & result
else
tempText = tempText & "pAssetIndex: OK"& RETURN
end if
pIndexErrorLog = pIndexErrorLog & RETURN & tempText
put pIndexErrorLog
end
on showProps me
showProps oHQ, me
end