home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Stickerpedia Stickerbook
/
Stickerbook.iso
/
pc
/
DATA
/
objects.cxt
/
00082_Script_oDataScreenBaby
< prev
Wrap
Text File
|
2003-03-19
|
10KB
|
364 lines
--¨
oDataScreenBaby
global oDataBase
global oDataScreen
global oMarvin
global gDisplayDebugSortOrder
on new me
return me
end
on reshuffleSimple me, kwp
put "kwp" && kwp
theKW = kwp[1]
if theKW = "k99" then
theKW = kwp[2]
end if
if theKW = "k99" then
put "nˆ nˆ"
exit
else
reshuffle me, kwp
end if
end
on reshuffleMultiple me, listOfKWPs
startTimer
numOfShuffles = listOfKWPs.count
-- repeat with pointer = 1 to numOfShuffles
-- thisKWP = listOfKWPs[pointer]
thisKWP = listOfKWPs[1]
reshuffle me, thisKWP
-- end repeat
-- put "reshuffleMultiple" && the timer/60
end
on reshuffle me, selectedKWPID
put "reshuffle"
-- startTimer
selectedKWPID = kwpLstToKWPStr(oDatabase, selectedKWPID)
-- increase hit counters:
-- sort order is based on the frequency with which which the second keyword has been hit:
oDatabase.pKWPairHits[selectedKWPID] = (oDatabase.pKWPairHits[selectedKWPID]) + 1
secondKeyWord = "k" & selectedKWPID.char[1..2]
numberOfHitsSecondKeyWord = oDatabase.pKWHits[secondKeyWord]
put "secondKeyWord" && secondKeyWord
put "numberOfHitsSecondKeyWord" && numberOfHitsSecondKeyWord
oDatabase.pKWHits[secondKeyWord] = numberOfHitsSecondKeyWord + 1
tempHitList = [:]
-- go through 'pKWHits' and use values as probs and vice versa
numOfEntries = oDatabase.pKWHits.count
put "numOfEntries" && numOfEntries
repeat with pointer = 1 to numOfEntries
tempHitList.addProp(oDatabase.pKWHits[pointer], (oDatabase.pKWHits.getPropAt(pointer)))
end repeat
sort tempHitList
put "tempHitList" && tempHitList
-- put "tempHitList: " & tempHitList
sortOrderOfSingleKeyWordsList = invertPropertyListSortOrder(oMarvin, tempHitList)
put "sortOrderOfSingleKeyWordsList" && sortOrderOfSingleKeyWordsList
-- put "XXX" && XXX
-- now kWPs must be resorted according to these preferences.
-- First of all, take the top keywords and find keyword pairs which start with them:
-- put the timer /60.0
topBananas = []
repeat with pointer = 1 to oDataScreen.pNumOfTopBananas
thisKW = sortOrderOfSingleKeyWordsList[pointer]
addThisListToTopBananas = []
-- first of all we will try and find a kwp which isn't visited yet:
if oDatabase.pNumOfKWPairs > oDatabase.pKWPSortOrder.count then
maxValue = oDatabase.pKWPSortOrder.count
else
maxValue = oDatabase.pNumOfKWPairs
end if
-- selectedKWPID = selectedKWP)
repeat with n = 1 to maxValue
thisKWPID = oDatabase.pKWPSortOrder[n]
if getKeyWordPairState (me, thisKWPID) = #std then
if ("k" & thisKWPID.char[1..2]) = thisKW then
addThisListToTopBananas.add(thisKWPID)
exit repeat
end if
end if
end repeat
if not addThisListToTopBananas.count then
-- repeat with n = 1 to oDatabase.pNumOfKWPairs
repeat with n = 1 to maxValue
thisKWPID = oDatabase.pKWPSortOrder[n]
if ("k" & thisKWPID.char[1..2]) = thisKW then
addThisListToTopBananas.add(thisKWPID)
exit repeat
end if
end repeat
end if
numOfItems = addThisListToTopBananas.count
repeat with bananaItems = 1 to numOfItems
topBananas.add(addThisListToTopBananas[bananaItems])
end repeat
end repeat
-- put "Banana shuffling" && the timer /60.0
-- check whether the selected keyword is contained in pNumOfTopBananas
-- and make sure it is in position 1
topBananasContainsSelectedKWP = getPos(topBananas, selectedKWPID)
if topBananasContainsSelectedKWP then
topBananas.deleteAt(topBananasContainsSelectedKWP)
topBananas.addAt(1, selectedKWPID)
else
topBananas.deleteAt(topBananas.count)
topBananas.addAt(1, selectedKWPID)
end if
-- now delete the keyWord pairs which are contained in 'topBananas' from
-- 'pKWPSortOrder' (wherever they are);
repeat with pointer = 1 to topBananas.count
posInList = getPos(oDatabase.pKWPSortOrder, topBananas[pointer])
if posInList then oDatabase.pKWPSortOrder.deleteAt(posInList)
end repeat
-- create a tempList to hold the future, updated pKWPSortOrder list, where these top KWPs will be placed at the begining, after the chosen KW
tempList = [:]
localNumOfTopBananas = topBananas.count
put "oDataScreen.pNumOfTopBananas" && oDataScreen.pNumOfTopBananas
put "localNumOfTopBananas" && localNumOfTopBananas
repeat with pointer = 1 to localNumOfTopBananas
-- repeat with pointer = 1 to oDataScreen.pNumOfTopBananas
tempList.addProp(symbol(string(pointer)), topBananas[pointer])
end repeat
-- now to the kwps which didn't make it into TopBananas, which we will now add to the tempList:
remainingKWPs = oDatabase.pKWPSortOrder.count
repeat with pointer = 1 to remainingKWPs
tempList.addProp(symbol(string(pointer+ oDataScreen.pNumOfTopBananas)), oDatabase.pKWPSortOrder[pointer])
end repeat
-- now all we have to do is put the contents of tempList into pKWPSortOrder, and dispose of tempList:
oDatabase.pKWPSortOrder = void
oDatabase.pKWPSortOrder = tempList.duplicate()
tempList = void
put "oDatabase.pKWPSortOrder" && oDatabase.pKWPSortOrder
if gDisplayDebugSortOrder then
-- show status info:
member("statusKWHits").text = listToText (oMarvin, oDatabase.pKWHits)
member("statusKWSortOrder").text = listToText (oMarvin, oDatabase.pKWPSortOrder)
end if
end
on indexToKeyWordPair me, indexScreenSelection
retval = void
if indexScreenSelection contains ":" then
saveDelimiter = the itemdelimiter
the itemdelimiter = ":"
set firstItem = item 1 of indexScreenSelection
set secondItem = item 2 of indexScreenSelection
retVal = [firstItem, secondItem]
else
-- retVal = ["Religion","Customs, Traditions & Festivals"]
end if
return retval
end
on getKeyWordPairState me, whichKeyWordPair
retVal = ""
if oDataBase.pKWPairHits[whichKeyWordPair] then
-- KWP was visited
retVal = #vtd
else
-- KWP has not been visited
retVal = #std
end if
return retVal
end
on printRecord me, showDetails
--pPrinting = 1
printList = []
case the frameLabel of
"book":
bookTextMbrNumber = 1
repeat with pointer = 1 to oDataScreen.pCurNumOfBookAssets
mbrType = member(oDataScreen.pBookAssetList[pointer], "database").type
case mbrType of
#bitmap:
printList.add( member (oDataScreen.pBookAssetList.getAt(pointer), "database") )
#text, #field:
fieldMember = member(("printBookText" && string(bookTextMbrNumber)), "database")
fieldMember.text = member(oDataScreen.pBookAssetList.getPropAt(pointer), "text").text
fieldMember.fontSize = member(oDataScreen.pBookAssetList.getPropAt(pointer), "text").fontSize
bookTextMbrNumber = bookTextMbrNumber + 1
printList.add( fieldMember )
end case
end repeat
"timeline":
TLTextMbrNumber = 1
repeat with pointer = 1 to oDataScreen.pCurNumOfTLAssets
mbrType = member(oDataScreen.pTLAssetList[pointer], "database").type
case mbrType of
#bitmap:
printList.add( member (oDataScreen.pTLAssetList.getAt(pointer), "database") )
#text, #field:
fieldMember = member(("printBookText" && string(TLTextMbrNumber)), "database")
fieldMember.text = member(oDataScreen.pTLAssetList.getPropAt(pointer), "text").text
fieldMember.fontSize = member(oDataScreen.pTLAssetList.getPropAt(pointer), "text").fontSize
TLTextMbrNumber = TLTextMbrNumber + 1
printList.add( fieldMember )
end case
end repeat
"standard":
fieldMember = member("printBookText 1", "database")
fieldMember.text = member("importText", "database").text
printList.add(member("importPictureBasic", "database"))
printList.add(fieldMember)
"sino":
fieldMember = member("printBookText 1", "database")
fieldMember.text = member("importText", "database").text
printList.add(member("importPictureBasic", "database"))
printList.add(member("importSino", "database"))
printList.add(fieldMember)
"video":
fieldMember = member("printBookText 1", "database")
fieldMember.text = member("importText", "database").text
printList.add(member ("importPictureBasic", "database"))
printList.add(fieldMember)
"audio":
fieldMember = member("printBookText 1", "database")
fieldMember.text = member("importText", "database").text
printList.add(member ("importPictureBasic", "database"))
printList.add(fieldMember)
end case
if showDetails then
customalert string(printList)
else
print printList
end if
end
on getBookPicV me, whichMember
return ((whichMember.height)/2) + 3
end
on getBasicPicV me, whichMember
-- this handler does some terribly clever things which are so smart that I forgot them five minutes later. But they work!
return ((whichMember.height)/2) + (160-((whichMember.height)/2)+13)
end
on getSinoPicV me, whichMember
-- the correct position for a sino record is 360 from left and so that the top is at 333, and the bottom is at 361
return ((whichMember.height)/2) + (160-((whichMember.height)/2)+13)
end