本文整理汇总了Python中renpy.game.context函数的典型用法代码示例。如果您正苦于以下问题:Python context函数的具体用法?Python context怎么用?Python context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了context函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(restart):
"""
This is called during a single run of the script. Restarting the script
will cause this to change.
"""
# Reset the store to a clean version of itself.
renpy.python.clean_stores()
# Init translation.
renpy.translation.init_translation()
# Prepare the screens.
renpy.display.screen.prepare_screens()
# Rebuild the various style caches.
renpy.style.build_styles() # @UndefinedVariable
# Start the interface, if it hasn't been started already.
renpy.game.interface.start()
# Re-Initialize the log.
game.log = renpy.python.RollbackLog()
# Switch contexts, begin logging.
game.contexts = [ renpy.execution.Context(True) ]
# Jump to an appropriate start label.
if game.script.has_label("_start"):
start_label = '_start'
else:
start_label = 'start'
game.context().goto_label(start_label)
# Perhaps warp.
warp_label = renpy.warp.warp()
if warp_label is not None:
game.context().goto_label(warp_label)
game.context().call('_after_warp')
renpy.config.skipping = None
try:
renpy.exports.log("--- " + time.ctime())
renpy.exports.log("")
except:
pass
# Note if this is a restart.
renpy.store._restart = restart
# We run until we get an exception.
renpy.display.interface.enter_context()
renpy.execution.run_context(True)
示例2: run
def run(restart):
"""
This is called during a single run of the script. Restarting the script
will cause this to change.
"""
# Reset the store to a clean version of itself.
renpy.python.clean_stores()
# Re-Initialize the log.
game.log = renpy.python.RollbackLog()
# Switch contexts, begin logging.
game.contexts = [ renpy.execution.Context(True) ]
# Jump to an appropriate start label.
if game.script.has_label("_start"):
start_label = '_start'
else:
start_label = 'start'
game.context().goto_label(start_label)
# Perhaps warp.
warp_label = renpy.warp.warp()
if warp_label is not None:
game.context().goto_label(warp_label)
if game.script.has_label('after_warp'):
game.context().call('after_warp')
renpy.config.skipping = None
try:
renpy.exports.log("--- " + time.ctime())
renpy.exports.log("")
except:
pass
# Note if this is a restart.
renpy.store._restart = restart
# We run until we get an exception.
renpy.display.interface.enter_context()
renpy.execution.run_context(True)
示例3: run
def run(restart):
"""
This is called during a single run of the script. Restarting the script
will cause this to change.
"""
reset_clock()
# Reset the store to a clean version of itself.
renpy.python.clean_stores()
log_clock("Cleaning stores")
# Init translation.
renpy.translation.init_translation()
log_clock("Init translation")
# Rebuild the various style caches.
renpy.style.build_styles() # @UndefinedVariable
log_clock("Build styles")
renpy.sl2.slast.load_cache()
log_clock("Load screen analysis")
# Analyze the screens.
renpy.display.screen.analyze_screens()
log_clock("Analyze screens")
if not restart:
renpy.sl2.slast.save_cache()
log_clock("Save screen analysis")
# Prepare the screens.
renpy.display.screen.prepare_screens()
log_clock("Prepare screens")
if not restart:
renpy.pyanalysis.save_cache()
log_clock("Save pyanalysis.")
renpy.game.script.save_bytecode()
log_clock("Save bytecode.")
# Handle arguments and commands.
if not renpy.arguments.post_init():
renpy.exports.quit()
# Sleep to finish the presplash.
renpy.display.presplash.sleep()
# Re-Initialize the log.
game.log = renpy.python.RollbackLog()
# Switch contexts, begin logging.
game.contexts = [ renpy.execution.Context(True) ]
# Jump to an appropriate start label.
if game.script.has_label("_start"):
start_label = '_start'
else:
start_label = 'start'
game.context().goto_label(start_label)
# Perhaps warp.
warp_label = renpy.warp.warp()
if warp_label is not None:
game.context().goto_label(warp_label)
game.context().call('_after_warp')
renpy.config.skipping = None
try:
renpy.exports.log("--- " + time.ctime())
renpy.exports.log("")
except:
pass
# Note if this is a restart.
renpy.store._restart = restart
# We run until we get an exception.
renpy.display.interface.enter_context()
log_clock("Running {}".format(start_label))
renpy.execution.run_context(True)
示例4: main
def main():
log_clock("Bootstrap to the start of init.init")
renpy.game.exception_info = 'Before loading the script.'
# Get ready to accept new arguments.
renpy.arguments.pre_init()
# Init the screen language parser.
renpy.sl2.slparser.init()
# Init the config after load.
renpy.config.init()
# Set up variants.
choose_variants()
renpy.display.touch = "touch" in renpy.config.variants
log_clock("Early init")
# Note the game directory.
game.basepath = renpy.config.gamedir
renpy.config.searchpath = [ renpy.config.gamedir ]
# Find the common directory.
commondir = __main__.path_to_common(renpy.config.renpy_base) # E1101 @UndefinedVariable
if os.path.isdir(commondir):
renpy.config.searchpath.append(commondir)
renpy.config.commondir = commondir
else:
renpy.config.commondir = None
if renpy.android:
renpy.config.searchpath = [ ]
renpy.config.commondir = None
# Load Ren'Py extensions.
for dir in renpy.config.searchpath: #@ReservedAssignment
for fn in os.listdir(dir):
if fn.lower().endswith(".rpe"):
load_rpe(dir + "/" + fn)
# The basename is the final component of the path to the gamedir.
for i in sorted(os.listdir(renpy.config.gamedir)):
if not i.endswith(".rpa"):
continue
i = i[:-4]
renpy.config.archives.append(i)
renpy.config.archives.reverse()
# Initialize archives.
renpy.loader.index_archives()
# Start auto-loading.
renpy.loader.auto_init()
log_clock("Loader init")
# Initialize the log.
game.log = renpy.python.RollbackLog()
# Initialize the store.
renpy.store.store = sys.modules['store']
# Set up styles.
game.style = renpy.style.StyleManager() # @UndefinedVariable
renpy.store.style = game.style
# Run init code in its own context. (Don't log.)
game.contexts = [ renpy.execution.Context(False) ]
game.contexts[0].init_phase = True
renpy.execution.not_infinite_loop(60)
# Load the script.
renpy.game.exception_info = 'While loading the script.'
renpy.game.script = renpy.script.Script()
# Set up error handling.
renpy.exports.load_module("_errorhandling")
renpy.style.build_styles() # @UndefinedVariable
log_clock("Loading error handling")
# If recompiling everything, remove orphan .rpyc files.
# Otherwise, will fail in case orphan .rpyc have same
# labels as in other scripts (usually happens on script rename).
if renpy.game.args.command == 'compile':
for (fn, dir) in renpy.game.script.script_files:
if not os.path.isfile(os.path.join(dir, fn+".rpy")):
try:
name = os.path.join(dir, fn+".rpyc")
os.rename(name, name+".bak")
except OSError:
#.........这里部分代码省略.........
示例5: main
def main():
renpy.game.exception_info = 'Before loading the script.'
# Get ready to accept new arguments.
renpy.arguments.pre_init()
# Init the screen language parser.
renpy.sl2.slparser.init()
# Init the config after load.
renpy.config.init()
# Set up variants.
choose_variants()
renpy.display.touch = "touch" in renpy.config.variants
# Note the game directory.
game.basepath = renpy.config.gamedir
renpy.config.searchpath = [ renpy.config.gamedir ]
# Find the common directory.
commondir = __main__.path_to_common(renpy.config.renpy_base) # E1101 @UndefinedVariable
if os.path.isdir(commondir):
renpy.config.searchpath.append(commondir)
renpy.config.commondir = commondir
else:
renpy.config.commondir = None
if renpy.android:
renpy.config.searchpath = [ ]
renpy.config.commondir = None
# Load Ren'Py extensions.
for dir in renpy.config.searchpath: #@ReservedAssignment
for fn in os.listdir(dir):
if fn.lower().endswith(".rpe"):
load_rpe(dir + "/" + fn)
# The basename is the final component of the path to the gamedir.
for i in sorted(os.listdir(renpy.config.gamedir)):
if not i.endswith(".rpa"):
continue
i = i[:-4]
renpy.config.archives.append(i)
renpy.config.archives.reverse()
# Initialize archives.
renpy.loader.index_archives()
# Start auto-loading.
renpy.loader.auto_init()
# Initialize the log.
game.log = renpy.python.RollbackLog()
# Initialize the store.
renpy.store.store = sys.modules['store']
# Set up styles.
game.style = renpy.style.StyleManager() # @UndefinedVariable
renpy.store.style = game.style
# Run init code in its own context. (Don't log.)
game.contexts = [ renpy.execution.Context(False) ]
game.contexts[0].init_phase = True
# Load the script.
renpy.game.exception_info = 'While loading the script.'
renpy.game.script = renpy.script.Script()
# Set up error handling.
renpy.exports.load_module("_errorhandling")
renpy.style.build_styles() # @UndefinedVariable
# Load all .rpy files.
renpy.game.script.load_script() # sets renpy.game.script.
renpy.game.exception_info = 'After loading the script.'
# Find the save directory.
if renpy.config.savedir is None:
renpy.config.savedir = __main__.path_to_saves(renpy.config.gamedir) # E1101 @UndefinedVariable
if renpy.game.args.savedir: #@UndefinedVariable
renpy.config.savedir = renpy.game.args.savedir #@UndefinedVariable
# Init preferences.
game.persistent = renpy.persistent.init()
game.preferences = game.persistent._preferences
# Init save locations.
renpy.savelocation.init()
# We need to be 100% sure we kill the savelocation thread.
#.........这里部分代码省略.........
示例6: run
def run(restart):
"""
This is called during a single run of the script. Restarting the script
will cause this to change.
"""
# Reset the store to a clean version of itself.
renpy.python.clean_stores()
# Re-Initialize the log.
game.log = renpy.python.RollbackLog()
# Switch contexts, begin logging.
game.contexts = [ renpy.execution.Context(True) ]
# Jump to an appropriate start label.
if game.script.has_label("_start"):
start_label = '_start'
else:
start_label = 'start'
game.context().goto_label(start_label)
# Perhaps warp.
warp_label = renpy.warp.warp()
if warp_label is not None:
game.context().goto_label(warp_label)
if game.script.has_label('after_warp'):
game.context().call('after_warp')
# Run the game.
while True:
renpy.config.skipping = None
try:
renpy.exports.log("--- " + time.ctime())
renpy.exports.log("")
except:
pass
# Note if this is a restart.
renpy.store._restart = restart
restart = None
# We run until we get an exception.
try:
game.context().run()
game.context().pop_all_dynamic()
break
# We get this when the context has changed, and so we go and
# start running from the new context.
except game.RestartException, e:
renpy.game.contexts = e.contexts
label = e.label
if label:
if game.script.has_label(label):
game.context().call(label)
continue
示例7: main
def main():
renpy.game.exception_info = 'Before loading the script.'
# Get ready to accept new arguments.
renpy.arguments.pre_init()
# Init the config after load.
renpy.config.init()
# Set up variants.
choose_variants()
# Note the game directory.
game.basepath = renpy.config.gamedir
renpy.config.searchpath = [ renpy.config.gamedir ]
# Find the common directory.
commondir = __main__.path_to_common(renpy.config.renpy_base) # E1101 @UndefinedVariable
if os.path.isdir(commondir):
renpy.config.searchpath.append(commondir)
renpy.config.commondir = commondir
else:
renpy.config.commondir = None
# Load Ren'Py extensions.
for dir in renpy.config.searchpath: #@ReservedAssignment
for fn in os.listdir(dir):
if fn.lower().endswith(".rpe"):
load_rpe(dir + "/" + fn)
# The basename is the final component of the path to the gamedir.
for i in sorted(os.listdir(renpy.config.gamedir)):
if not i.endswith(".rpa"):
continue
i = i[:-4]
renpy.config.archives.append(i)
renpy.config.archives.reverse()
# Initialize archives.
renpy.loader.index_archives()
# Initialize the log.
game.log = renpy.python.RollbackLog()
# Initialize the store.
renpy.store.store = sys.modules['store']
# Set up styles.
renpy.style.reset()
game.style = renpy.style.StyleManager()
renpy.store.style = game.style
# Run init code in its own context. (Don't log.)
game.contexts = [ renpy.execution.Context(False) ]
game.contexts[0].init_phase = True
# Load the script.
renpy.game.exception_info = 'While loading the script.'
renpy.game.script = renpy.script.Script()
renpy.exports.load_module("_errorhandling")
renpy.game.script.load_script() # sets renpy.game.script.
renpy.game.exception_info = 'After loading the script.'
# Find the save directory.
if renpy.config.savedir is None:
renpy.config.savedir = __main__.path_to_saves(renpy.config.gamedir) # E1101 @UndefinedVariable
if renpy.game.args.savedir: #@UndefinedVariable
renpy.config.savedir = renpy.game.args.savedir #@UndefinedVariable
# Make the save directory.
try:
os.makedirs(renpy.config.savedir)
except:
pass
# Unserialize the persistent data.
try:
f = file(renpy.config.savedir + "/persistent", "rb")
s = f.read().decode("zlib")
f.close()
game.persistent = loads(s)
except:
game.persistent = game.Persistent()
# Initialize the set of statements seen ever.
if not game.persistent._seen_ever:
game.persistent._seen_ever = { }
game.seen_ever = game.persistent._seen_ever
# Initialize the set of images seen ever.
#.........这里部分代码省略.........
示例8: main
#.........这里部分代码省略.........
# Initialize the set of images seen ever.
if not game.persistent._seen_images:
game.persistent._seen_images = { }
# Initialize the set of chosen menu choices.
if not game.persistent._chosen:
game.persistent._chosen = { }
if not game.persistent._seen_audio:
game.persistent._seen_audio = { }
# Clear the list of seen statements in this game.
game.seen_session = { }
# Initialize the preferences.
if not game.persistent._preferences:
game.persistent._preferences = game.Preferences()
game.preferences = game.persistent._preferences
# Initialize persistent variables.
renpy.store.persistent = game.persistent
renpy.store._preferences = game.preferences
# Set up styles.
renpy.style.reset()
game.style = renpy.style.StyleManager()
renpy.store.style = game.style
renpy.game.exception_info = 'While executing init code:'
# Run init code in its own context. (Don't log.)
game.contexts = [ renpy.execution.Context(False) ]
# Run the init code.
game.init_phase = True
for prio, node in game.script.initcode:
game.context().run(node)
game.init_phase = False
renpy.game.exception_info = 'After initialization, but before game start.'
# Save the bytecode in a cache.
renpy.game.script.save_bytecode()
# Run the post init code, if any.
for i in renpy.game.post_init:
i()
# Rebuild the various style caches.
renpy.style.build_styles()
# Index the archive files. We should not have loaded an image
# before this point. (As pygame will not have been initialized.)
# We need to do this again because the list of known archives
# may have changed.
renpy.loader.index_archives()
# Make a clean copy of the store.
game.clean_store = renpy.store.__dict__.copy()
# Check some environment variables.
renpy.game.less_memory = "RENPY_LESS_MEMORY" in os.environ
renpy.game.less_mouse = "RENPY_LESS_MOUSE" in os.environ
示例9: run
def run(restart):
"""
This is called during a single run of the script. Restarting the script
will cause this to change.
"""
# Reset the store to a clean version of itself.
store = renpy.store.__dict__ #@UndefinedVariable
store.clear()
store.update(renpy.game.clean_store)
# Re-Initialize the log.
game.log = renpy.python.RollbackLog()
# Switch contexts, begin logging.
game.contexts = [ renpy.execution.Context(True) ]
# Jump to an appropriate start label.
if game.script.has_label("_start"):
start_label = '_start'
else:
start_label = 'start'
game.context().goto_label(start_label)
# Perhaps warp.
if renpy.game.options.warp: #@UndefinedVariable
label = renpy.warp.warp(renpy.game.options.warp) #@UndefinedVariable
renpy.game.options.warp = None
if not label:
raise Exception("Could not find line to warp to.")
game.context().goto_label(label)
if game.script.has_label('after_warp'):
game.context().call('after_warp')
# Run the game.
while True:
renpy.exports.log("--- " + time.ctime())
renpy.exports.log("")
# Note if this is a restart.
renpy.store._restart = restart
restart = None
# We run until we get an exception.
try:
game.context().run()
game.context().pop_all_dynamic()
break
# We get this when the context has changed, and so we go and
# start running from the new context.
except game.RestartException, e:
renpy.game.contexts = e.contexts
label = e.label
if label:
if game.script.has_label(label):
game.context().call(label)
continue