Exemple #1
0
def add_tile_colliders(script_settings):
    try:
        # instantiate the msfsProject and create the necessary resources if it does not exist
        msfs_project = MsfsProject(script_settings.projects_path,
                                   script_settings.project_name,
                                   script_settings.definition_file,
                                   script_settings.author_name,
                                   script_settings.sources_path)

        check_configuration(script_settings, msfs_project)

        if script_settings.backup_enabled:
            msfs_project.backup(
                Path(os.path.abspath(__file__)).stem.replace(
                    SCRIPT_PREFIX, str()))

        isolated_print(EOL)
        msfs_project.add_tile_colliders()

        if script_settings.build_package_enabled:
            build_package(msfs_project, script_settings)

        pr_bg_green("Script correctly applied" + constants.CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + constants.CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + constants.CEND)
def compress_built_package(script_settings):
    try:
        # instantiate the msfsProject and create the necessary resources if it does not exist
        msfs_project = MsfsProject(script_settings.projects_path,
                                   script_settings.project_name,
                                   script_settings.definition_file,
                                   script_settings.author_name,
                                   script_settings.sources_path,
                                   fast_init=True)

        check_configuration(script_settings,
                            msfs_project,
                            check_built_package=True,
                            check_compressonator=True)

        isolated_print(EOL)
        print_title("COMPRESS BUILT PACKAGE")

        msfs_project.compress_built_package(script_settings)

        if script_settings.build_package_enabled:
            build_package(msfs_project, script_settings)

        pr_bg_green("Script correctly applied" + constants.CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + constants.CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + constants.CEND)
def optimize_scenery(script_settings):
    try:
        # instantiate the msfsProject and create the necessary resources if it does not exist
        msfs_project = MsfsProject(script_settings.projects_path,
                                   script_settings.project_name,
                                   script_settings.definition_file,
                                   script_settings.author_name,
                                   script_settings.sources_path)

        check_configuration(
            script_settings,
            msfs_project,
            check_optimisation=True,
            check_lily_texture_packer=script_settings.bake_textures_enabled)

        if script_settings.backup_enabled:
            msfs_project.backup(
                Path(os.path.abspath(__file__)).stem.replace(
                    SCRIPT_PREFIX, str()))

        clean_scene()
        msfs_project.optimize(script_settings)

        if script_settings.build_package_enabled:
            build_package(msfs_project, script_settings)

        pr_bg_green("Script correctly applied" + CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + CEND)
def init_msfs_scenery_project(script_settings):
    try:
        print_title("INIT SCENERY PROJECT")

        # instantiate the msfsProject and create the necessary resources if it does not exist
        MsfsProject(script_settings.projects_path,
                    script_settings.project_name,
                    script_settings.definition_file,
                    script_settings.author_name,
                    script_settings.sources_path,
                    init_structure=True)

        pr_bg_green("Script correctly applied" + constants.CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + constants.CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + constants.CEND)
def merge_sceneries(script_settings):
    try:
        # instantiate the msfsProject and create the necessary resources if it does not exist
        msfs_project = MsfsProject(script_settings.projects_path,
                                   script_settings.project_name,
                                   script_settings.definition_file,
                                   script_settings.author_name,
                                   script_settings.sources_path)
        project_folder_to_merge = os.path.dirname(
            script_settings.project_path_to_merge) + os.path.sep
        project_name_to_merge = os.path.relpath(
            script_settings.project_path_to_merge,
            start=project_folder_to_merge)
        msfs_project_to_merge = MsfsProject(
            script_settings.projects_path, project_name_to_merge,
            script_settings.definition_file_to_merge,
            script_settings.author_name, script_settings.sources_path)

        check_configuration(script_settings, msfs_project)
        check_configuration(script_settings, msfs_project_to_merge)

        if script_settings.backup_enabled:
            msfs_project.backup(
                Path(os.path.abspath(__file__)).stem.replace(
                    SCRIPT_PREFIX, str()))

        msfs_project.merge(msfs_project_to_merge)

        if script_settings.build_package_enabled:
            build_package(msfs_project, script_settings)

        pr_bg_green("Script correctly applied" + CEND)

    except ScriptError as ex:
        error_report = "".join(ex.value)
        isolated_print(constants.EOL + error_report)
        pr_bg_red("Script aborted" + CEND)
    except RuntimeError as ex:
        isolated_print(constants.EOL + str(ex))
        pr_bg_red("Script aborted" + CEND)