Beispiel #1
0
def main(args):
	if args:
		error('Unrecognized argument(s): ' % ' '.join(args))
		csp.base.app.usage()
		return 1

	options = csp.base.app.options
	config = findConfig('sim.ini', prefer=options.ini)
	if config is None:
		fail('Try setting --ini')

	loadExtensionModules()
	setDefaultJoystick()

	if options.pause:
		pauseForDebugger()

	csp.cspsim.openConfig(config, True)
	cachepath = csp.cspsim.getCachePath()
	dar = os.path.join(cachepath, "sim.dar")

	if options.dumpdata:
		dumpDataArchive(dar)
		return 0

	sim = csp.cspsim.CSPSim()

	# logging will have already been configured from the ini file at this point,
	# so we can safely override the settings.
	setLogCategory(options.logcat)
	setLogPriority(options.logpri)

	if options.compile or options.rebuild or not os.path.exists(dar):
		level = max(0, 2 - parseLogPriority(options.logpri))
		compileData(options.xml, dar, rebuild=options.rebuild, level=level)
		if options.compile or options.rebuild: return 0

	ensureDefaultHID('aircraft')
	ensureDefaultHID('gamescreen')

	try:
		sim.init()
		if options.loadsimulation:
			sim.displayLogoScreen()
			sim.loadSimulation()
			createTestObjects(sim, options.objects)
		else:
			sim.displayLogoScreen()
			from csp.data.ui.scripts.startup import UserInterfaceStartup
			userInterface = UserInterfaceStartup(sim)
			userInterface.run();
			sim.run()
	finally:
		sim.cleanup()

	print 'Normal exit.'
	return 0
Beispiel #2
0
 def end_simulation_Click(self):
     # Start by changing the screen. This makes it possible for us to 
     # display the main menu and the desktop.
     self.getWindowManager().closeAll()
     self.cspsim.displayMenuScreen()
     # End the simulation by unloading everything.
     self.cspsim.unloadSimulation()
     
     # Use the UserInterfaceStartup class to return to the main menu
     # and the desktop.
     from csp.data.ui.scripts.startup import UserInterfaceStartup
     startup = UserInterfaceStartup(self.cspsim) # TODO: the UserInterfaceStartup object created in sim.py still exist !!!
     startup.run()