Esempio n. 1
0
def test_save_load_ticket_1421(gui):
	"""
	Boatbuilder crashes when saving/loading while a ship is being produced.
	"""

	# Select boat builder
	gui.cursor_click(64, 10, 'left')

	# Select trade ships tab
	gui.trigger('tab_base', '1')

	# Build huker
	gui.trigger('boatbuilder_showcase', 'ok_0')

	# Select war ships tab
	gui.trigger('tab_base', '2')

	# Build frigate
	gui.trigger('boatbuilder_showcase', 'ok_0')

	fd, filename = tempfile.mkstemp()
	os.close(fd)

	assert gui.session.save(savegamename=filename)

	options = StartGameOptions.create_load_game(filename, None)
	horizons.main.start_singleplayer(options)
Esempio n. 2
0
def _load_cmd_map(savegame, ai_players, force_player_id=None):
	"""Load a map specified by user.
	@param savegame: either the displayname of a savegame or a path to a savegame
	@return: bool, whether loading succeeded"""
	# first check for partial or exact matches in the normal savegame list
	savegames = SavegameManager.get_saves()
	map_file = _find_matching_map(savegame, savegames)
	if not map_file:
		return False

	options = StartGameOptions.create_load_game(map_file, force_player_id)
	start_singleplayer(options)
	return True
Esempio n. 3
0
def _load_cmd_map(savegame, ai_players, force_player_id=None):
	"""Load a map specified by user.
	@param savegame: either the displayname of a savegame or a path to a savegame
	@return: bool, whether loading succeeded"""
	# first check for partial or exact matches in the normal savegame list
	savegames = SavegameManager.get_saves()
	map_file = _find_map(savegame, savegames)
	if not map_file:
		return False

	options = StartGameOptions.create_load_game(map_file, force_player_id)
	start_singleplayer(options)
	return True
Esempio n. 4
0
def saveload(gui):
	"""Save and load the game (gui test version). Use like this:

	# For gui tests
	saveload(gui)
	"""
	fd, filename = tempfile.mkstemp()
	os.close(fd)
	assert gui.session.save(savegamename=filename)
	options = StartGameOptions.create_load_game(filename, None)
	# This hands out a new session, but `gui.session` is a property.
	horizons.main.start_singleplayer(options)
	# Restore some properties that were changed for tests:
	# Set game speed to maximum, and disable autoscroll.
	gui.setup()
Esempio n. 5
0
def _load_last_quicksave(session=None, force_player_id=None):
	"""Load last quicksave
	@param session: value of session
	@return: bool, whether loading succeeded"""
	save_files = SavegameManager.get_quicksaves()[0]
	if _modules.session is not None:
		if not save_files:
			_modules.session.ingame_gui.open_popup(_("No quicksaves found"),
			                                       _("You need to quicksave before you can quickload."))
			return False
	else:
		if not save_files:
			print "Error: No quicksave found."
			return False

	save = max(save_files)
	options = StartGameOptions.create_load_game(save, force_player_id)
	start_singleplayer(options)
	return True
Esempio n. 6
0
def _load_last_quicksave(session=None, force_player_id=None):
	"""Load last quicksave
	@param session: value of session
	@return: bool, whether loading succeeded"""
	save_files = SavegameManager.get_quicksaves()[0]
	if _modules.session is not None:
		if not save_files:
			_modules.session.ingame_gui.open_popup(T("No quicksaves found"),
			                                       T("You need to quicksave before you can quickload."))
			return False
	else:
		if not save_files:
			print("Error: No quicksave found.")
			return False

	save = max(save_files)
	options = StartGameOptions.create_load_game(save, force_player_id)
	start_singleplayer(options)
	return True
Esempio n. 7
0
def _load_last_quicksave(session=None, force_player_id=None):
    """Load last quicksave
	@param session: value of session
	@return: bool, whether loading succeded"""
    save_files = SavegameManager.get_quicksaves()[0]
    if session is not None:
        if not save_files:
            session.gui.show_popup(
                _("No quicksaves found"),
                _("You need to quicksave before you can quickload."))
            return False
        else:
            session.ingame_gui.on_escape()  # close widgets that might be open
    else:
        if not save_files:
            print "Error: No quicksave found."
            return False

    save = max(save_files)
    _modules.gui.show_loading_screen()
    options = StartGameOptions.create_load_game(save, force_player_id)
    start_singleplayer(options)
    return True