home *** CD-ROM | disk | FTP | other *** search
- # Created 3/7/2000 by Wolfson
- # Script handling data and procs needed to perform scripted animation skipping
- # cenerates .py files in the .\\pak directory
-
- import pickle
- import Bladex
- import AuxFuncs
- import Reference
-
- TempTime = 0
- TempName = 0
- SkipTimes = {}
-
- # To be Called at the deactivateinput() call level
- def SkipScriptStart(name):
- global TempName
- global TempTime
- global SkipTimes
-
- #print("oka, started")
-
- AuxFuncs.DeactivateKeyboard()
-
- # Open File w data
- opened = 1
-
- try:
- SkippingDataFile = open(".\\pak\\SDF.txt","r")
- except:
- opened = 0
-
- # Place Data in phython object
- if opened:
- SkipTimes = pickle.load(SkippingDataFile)
- SkippingDataFile.close()
-
- TempName = name
- TempTime = Bladex.GetTime()
-
- # To be Called at the activateinput() call level
- # In script end, we always save time data, but, since we alter the clock in the enter/esc call
- # the saved value still holds the correct timming data
-
- def SkipScriptEnd2():
- global TempTime
- global SkipTimes
- global TempName
-
- #print("oka, ended")
-
- AuxFuncs.ActivateKeyboard()
-
- TempTime = Bladex.GetTime() - TempTime # Elapsed time from script-begin to script-end
- SkipTimes[TempName] = TempTime
- TempName = "NonValidName" # Security lock, in case we call SkipCalled out-of-the-nest
-
- opened = 1
-
- try:
- SkippingDataFile = open(".\\pak\\SDF.txt","w")
- except:
- opened = 0
-
- # Place data in file
- if opened:
- pickle.dump(SkipTimes, SkippingDataFile, 0)
- SkippingDataFile.close()
-
-
- # To be Called on ESC event while input is deactivated
- def SkipCalled():
- global TempName
- global SkipTimes
- global TempTime
-
-
- if Reference.DEMO_MODE==1:
- return
-
- #print("Hello my baby, hello my good!!!")
-
- Bladex.ShutDownSoundChannels()
-
- if SkipTimes.has_key(TempName):
- TimeToSkip = SkipTimes[TempName] - (Bladex.GetTime() - TempTime)
- if TimeToSkip > 0: # Safety check
- Bladex.GoToTime(Bladex.GetTime() + TimeToSkip)
- else:
- print("Wolfson's Error: Negative index for script skipping, timing may be wrong")
- else:
- print("Wolfson's Error: SkipCalled called outta nest")
-
- def SkipScriptEnd():
- Bladex.AddScheduledFunc(Bladex.GetTime(), SkipScriptEnd2, (), "SkipScriptEnd2")
-