Пример #1
0
def update_traffic_rules_library_rel_path(scs_traffic_rules_inventory, traffic_rules_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Traffic Rules names in inventory. It also updates corresponding record in config file.

    :param traffic_rules_library_rel_path: Relative path to the directory with Traffic Rules files
    :type traffic_rules_library_rel_path: str
    """
    traffic_rules_library_filepath = _path.get_abs_path(traffic_rules_library_rel_path)
    if traffic_rules_library_filepath:
        trul_container = _sii.get_data_from_file(traffic_rules_library_filepath)
        if trul_container:

            # CLEAR INVENTORY
            scs_traffic_rules_inventory.clear()

            # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
            for item in trul_container:
                if item.type == 'traffic_rule_data':
                    if item.id.startswith('traffic_rule.'):
                        traffic_rule_item = scs_traffic_rules_inventory.add()
                        traffic_rule_item.name = item.id[13:]
                        # traffic_rule_item.item_id = item.id[13:]

                        if 'rule' in item.props:
                            traffic_rule_item.rule = item.props['rule']

                        if 'num_params' in item.props:
                            traffic_rule_item.num_params = str(item.props['num_params'])

        else:
            print('   traffic_rules_library_rel_path: "%s"' % str(traffic_rules_library_rel_path))

    if not readonly:
        update_item_in_file('Paths.TrafficRulesRelFilePath', traffic_rules_library_rel_path)
Пример #2
0
def update_matsubs_inventory(scs_matsubs_inventory, matsubs_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Material Substance names in inventory. It also updates corresponding record in config file.

    :param matsubs_library_rel_path: Relative path to the directory with Material Substance files
    :type matsubs_library_rel_path: str
    """
    matsubs_library_filepath = _path_utils.get_abs_path(matsubs_library_rel_path)
    if matsubs_library_filepath:
        matsubs_container = _sii.get_data_from_file(matsubs_library_filepath)
        if matsubs_container:

            # CLEAR INVENTORY
            scs_matsubs_inventory.clear()

            # ADD "NONE" ITEM IN INVENTORY
            matsubs_item = scs_matsubs_inventory.add()
            matsubs_item.name = "None"
            matsubs_item.item_id = 'none'
            matsubs_item.item_description = "No Material Substance"

            # ADD ALL THE OTHER ITEMS FROM CONTAINER INTO INVENTORY
            for item in matsubs_container:
                if item.type == 'game_substance':
                    if item.id.startswith('.'):
                        if 'name' in item.props:
                            matsubs_name = item.props['name']
                        else:
                            continue
                        matsubs_item = scs_matsubs_inventory.add()
                        matsubs_item.name = matsubs_name
                        matsubs_item.item_id = item.id[1:]
                        # matsubs_item.item_description = ""

    if not readonly:
        update_item_in_file('Paths.MatSubsRelFilePath', matsubs_library_rel_path)
Пример #3
0
def update_matsubs_inventory(scs_matsubs_inventory, matsubs_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Material Substance names in inventory. It also updates corresponding record in config file.

    :param matsubs_library_rel_path: Relative path to the directory with Material Substance files
    :type matsubs_library_rel_path: str
    """
    matsubs_library_filepath = _path_utils.get_abs_path(matsubs_library_rel_path)
    if matsubs_library_filepath:
        matsubs_container = _sii.get_data_from_file(matsubs_library_filepath)
        if matsubs_container:

            # CLEAR INVENTORY
            scs_matsubs_inventory.clear()

            # ADD "NONE" ITEM IN INVENTORY
            matsubs_item = scs_matsubs_inventory.add()
            matsubs_item.name = "None"
            matsubs_item.item_id = 'none'
            matsubs_item.item_description = "No Material Substance"

            # ADD ALL THE OTHER ITEMS FROM CONTAINER INTO INVENTORY
            for item in matsubs_container:
                if item.type == 'game_substance':
                    if item.id.startswith('.'):
                        if 'name' in item.props:
                            matsubs_name = item.props['name']
                        else:
                            continue
                        matsubs_item = scs_matsubs_inventory.add()
                        matsubs_item.name = matsubs_name
                        matsubs_item.item_id = item.id[1:]
                        # matsubs_item.item_description = ""

    if not readonly:
        update_item_in_file('Paths.MatSubsRelFilePath', matsubs_library_rel_path)
Пример #4
0
def update_hookup_library_rel_path(scs_hookup_inventory, hookup_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Hookup names in inventory. It also updates corresponding record in config file.

    :param hookup_library_rel_path: Relative path to the directory with Hookup files
    :type hookup_library_rel_path: str
    """
    abs_path = _path_utils.get_abs_path(hookup_library_rel_path, is_dir=True)
    if abs_path:

        # CLEAR INVENTORY
        scs_hookup_inventory.clear()

        # READ ALL "SII" FILES IN INVENTORY FOLDER
        for root, dirs, files in os.walk(abs_path):
            # print('   root: "%s"\n  dirs: "%s"\n files: "%s"' % (root, dirs, files))
            for file in files:
                if file.endswith(".sii"):
                    filepath = os.path.join(root, file)
                    # print('   filepath: "%s"' % str(filepath))
                    hookup_container = _sii.get_data_from_file(filepath)

                    # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                    if hookup_container:
                        for item in hookup_container:
                            # if item.type == 'sign_model':
                            if item.id.startswith('_'):
                                continue
                            else:
                                hookup_file = scs_hookup_inventory.add()
                                hookup_file.name = str(item.type + " : " + item.id)
                                hookup_file.item_id = item.id

                                if 'model' in item.props:
                                    # if model is defined as array ( appears if additional lod models are defined )
                                    # then use first none lod model
                                    if isinstance(item.props['model'], type(list())):
                                        hookup_file.model = item.props['model'][0]
                                    else:
                                        hookup_file.model = item.props['model']

                                if 'brand_idx' in item.props:
                                    try:
                                        hookup_file.brand_idx = int(item.props['brand_idx'])
                                    except:
                                        pass

                                if 'dir_type' in item.props:
                                    hookup_file.dir_type = item.props['dir_type']

                                if 'low_poly_only' in item.props:
                                    if item.props['low_poly_only'] == 'true':
                                        hookup_file.low_poly_only = True

            if '.svn' in dirs:
                dirs.remove('.svn')  # ignore SVN

    if not readonly:
        update_item_in_file('Paths.HookupRelDirPath', hookup_library_rel_path)
Пример #5
0
def update_hookup_library_rel_path(scs_hookup_inventory, hookup_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Hookup names in inventory. It also updates corresponding record in config file.

    :param hookup_library_rel_path: Relative path to the directory with Hookup files
    :type hookup_library_rel_path: str
    """
    abs_path = _path_utils.get_abs_path(hookup_library_rel_path, is_dir=True)
    if abs_path:

        # CLEAR INVENTORY
        scs_hookup_inventory.clear()

        # READ ALL "SII" FILES IN INVENTORY FOLDER
        for root, dirs, files in os.walk(abs_path):
            # print('   root: "%s"\n  dirs: "%s"\n files: "%s"' % (root, dirs, files))
            for file in files:
                if file.endswith(".sii"):
                    filepath = os.path.join(root, file)
                    # print('   filepath: "%s"' % str(filepath))
                    hookup_container = _sii.get_data_from_file(filepath)

                    # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                    if hookup_container:
                        for item in hookup_container:
                            # if item.type == 'sign_model':
                            if item.id.startswith('_'):
                                continue
                            else:
                                hookup_file = scs_hookup_inventory.add()
                                hookup_file.name = str(item.type + " : " + item.id)
                                hookup_file.item_id = item.id

                                if 'model' in item.props:
                                    # if model is defined as array ( appears if additional lod models are defined )
                                    # then use first none lod model
                                    if isinstance(item.props['model'], type(list())):
                                        hookup_file.model = item.props['model'][0]
                                    else:
                                        hookup_file.model = item.props['model']

                                if 'brand_idx' in item.props:
                                    try:
                                        hookup_file.brand_idx = int(item.props['brand_idx'])
                                    except:
                                        pass

                                if 'dir_type' in item.props:
                                    hookup_file.dir_type = item.props['dir_type']

                                if 'low_poly_only' in item.props:
                                    if item.props['low_poly_only'] == 'true':
                                        hookup_file.low_poly_only = True

            if '.svn' in dirs:
                dirs.remove('.svn')  # ignore SVN

    if not readonly:
        update_item_in_file('Paths.HookupRelDirPath', hookup_library_rel_path)
Пример #6
0
def update_sign_library_rel_path(scs_sign_model_inventory,
                                 sign_library_rel_path,
                                 readonly=False):
    """The function deletes and populates again a list of Sign names in inventory. It also updates corresponding record in config file.

    :param sign_library_rel_path: Relative path to the directory with Sign files
    :type sign_library_rel_path: str
    """
    sign_library_filepath = _path_utils.get_abs_path(sign_library_rel_path)
    if sign_library_filepath:

        if _get_scs_globals().sign_library_use_infixed:
            sign_library_filepaths = _path_utils.get_all_infixed_file_paths(
                sign_library_filepath)
        else:
            sign_library_filepaths = [sign_library_filepath]

        # CLEAR INVENTORY
        scs_sign_model_inventory.clear()

        for sign_library_filepath in sign_library_filepaths:

            sign_container = _sii.get_data_from_file(sign_library_filepath)
            if sign_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in sign_container:
                    if item.type == 'sign_model':
                        if item.id.startswith('sign.'):
                            if 'sign_name' in item.props:
                                sign_name = item.props['sign_name']
                            else:
                                continue

                            sign_item = scs_sign_model_inventory.add()
                            sign_item.name = sign_name + " : " + item.id[5:]
                            sign_item.item_id = item.id[5:]

                            if 'model_desc' in item.props:
                                sign_item.model_desc = item.props['model_desc']

                            if 'look_name' in item.props:
                                sign_item.look_name = item.props['look_name']

                            if 'category' in item.props:
                                sign_item.category = item.props['category']

                            if 'dynamic' in item.props:
                                if item.props['dynamic'] == 'true':
                                    sign_item.dynamic = True

    if not readonly:
        update_item_in_file('Paths.SignRelFilePath', sign_library_rel_path)
Пример #7
0
def update_sign_library_rel_path(scs_sign_model_inventory, sign_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Sign names in inventory. It also updates corresponding record in config file.

    :param sign_library_rel_path: Relative path to the directory with Sign files
    :type sign_library_rel_path: str
    """
    sign_library_filepath = _path_utils.get_abs_path(sign_library_rel_path)
    if sign_library_filepath:

        if _get_scs_globals().sign_library_use_infixed:
            sign_library_filepaths = _path_utils.get_all_infixed_file_paths(sign_library_filepath)
        else:
            sign_library_filepaths = [sign_library_filepath]

        # CLEAR INVENTORY
        scs_sign_model_inventory.clear()

        for sign_library_filepath in sign_library_filepaths:

            sign_container = _sii.get_data_from_file(sign_library_filepath)
            if sign_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in sign_container:
                    if item.type == 'sign_model':
                        if item.id.startswith('sign.'):
                            if 'sign_name' in item.props:
                                sign_name = item.props['sign_name']
                            else:
                                continue

                            sign_item = scs_sign_model_inventory.add()
                            sign_item.name = sign_name + " : " + item.id[5:]
                            sign_item.item_id = item.id[5:]

                            if 'model_desc' in item.props:
                                sign_item.model_desc = item.props['model_desc']

                            if 'look_name' in item.props:
                                sign_item.look_name = item.props['look_name']

                            if 'category' in item.props:
                                sign_item.category = item.props['category']

                            if 'dynamic' in item.props:
                                if item.props['dynamic'] == 'true':
                                    sign_item.dynamic = True

    if not readonly:
        update_item_in_file('Paths.SignRelFilePath', sign_library_rel_path)
Пример #8
0
def update_traffic_rules_library_rel_path(scs_traffic_rules_inventory,
                                          traffic_rules_library_rel_path,
                                          readonly=False):
    """The function deletes and populates again a list of Traffic Rules names in inventory. It also updates corresponding record in config file.

    :param traffic_rules_library_rel_path: Relative path to the directory with Traffic Rules files
    :type traffic_rules_library_rel_path: str
    """
    traffic_rules_library_filepath = _path_utils.get_abs_path(
        traffic_rules_library_rel_path)
    if traffic_rules_library_filepath:

        if _get_scs_globals().traffic_rules_library_use_infixed:
            traffic_rules_library_filepaths = _path_utils.get_all_infixed_file_paths(
                traffic_rules_library_filepath)
        else:
            traffic_rules_library_filepaths = [traffic_rules_library_filepath]

        # CLEAR INVENTORY
        scs_traffic_rules_inventory.clear()

        for traffic_rules_library_filepath in traffic_rules_library_filepaths:

            trul_container = _sii.get_data_from_file(
                traffic_rules_library_filepath)
            if trul_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in trul_container:
                    if item.type == 'traffic_rule_data':
                        if item.id.startswith('traffic_rule.'):
                            traffic_rule_item = scs_traffic_rules_inventory.add(
                            )
                            traffic_rule_item.name = item.id[13:]
                            # traffic_rule_item.item_id = item.id[13:]

                            if 'rule' in item.props:
                                traffic_rule_item.rule = item.props['rule']

                            if 'num_params' in item.props:
                                traffic_rule_item.num_params = str(
                                    item.props['num_params'])

    if not readonly:
        update_item_in_file('Paths.TrafficRulesRelFilePath',
                            traffic_rules_library_rel_path)
Пример #9
0
def update_tsem_library_rel_path(scs_tsem_profile_inventory,
                                 tsem_library_rel_path,
                                 readonly=False):
    """The function deletes and populates again a list of Traffic Semaphore Profile names in inventory. It also updates corresponding record in
    config file.

    :param tsem_library_rel_path: Relative path to the directory with Traffic Semaphore Profile files
    :type tsem_library_rel_path: str
    """
    tsem_library_filepath = _path_utils.get_abs_path(tsem_library_rel_path)
    if tsem_library_filepath:

        if _get_scs_globals().tsem_library_use_infixed:
            tsem_library_filepaths = _path_utils.get_all_infixed_file_paths(
                tsem_library_filepath)
        else:
            tsem_library_filepaths = [tsem_library_filepath]

        # CLEAR INVENTORY
        scs_tsem_profile_inventory.clear()

        for tsem_library_filepath in tsem_library_filepaths:

            tsem_container = _sii.get_data_from_file(tsem_library_filepath)
            if tsem_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in tsem_container:
                    if item.type == 'tr_semaphore_profile':
                        if item.id.startswith('tr_sem_prof.'):
                            if 'name' in item.props:
                                tsem_name = item.props['name']
                            else:
                                continue

                            tsem_item = scs_tsem_profile_inventory.add()
                            tsem_item.name = tsem_name + " : " + item.id[12:]
                            tsem_item.item_id = item.id[12:]

                            if 'model' in item.props:
                                tsem_item.model = item.props['model'][0]

    if not readonly:
        update_item_in_file('Paths.TSemProfileRelFilePath',
                            tsem_library_rel_path)
Пример #10
0
def update_trigger_actions_rel_path(scs_trigger_actions_inventory,
                                    trigger_actions_rel_path,
                                    readonly=False):
    """The function deletes and populates again a list of Trigger Actions in inventory. It also updates corresponding record in config file.

    :param trigger_actions_rel_path: Relative path to the directory with Trigger Action files
    :type trigger_actions_rel_path: str
    """
    trig_actions_path = _path_utils.get_abs_path(trigger_actions_rel_path)
    if trig_actions_path:

        if _get_scs_globals().trigger_actions_use_infixed:
            trig_actions_paths = _path_utils.get_all_infixed_file_paths(
                trig_actions_path)
        else:
            trig_actions_paths = [trig_actions_path]

        # CLEAR INVENTORY
        scs_trigger_actions_inventory.clear()

        for trig_actions_path in trig_actions_paths:

            trig_actions_container = _sii.get_data_from_file(trig_actions_path)
            if trig_actions_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in trig_actions_container:
                    if item.type == 'trigger_action':
                        if item.id.startswith('trig_action.'):
                            if 'name' in item.props:
                                trg_action_name = item.props['name']
                            else:
                                continue

                            trig_item = scs_trigger_actions_inventory.add()
                            trig_item.name = trg_action_name + " : " + item.id[
                                12:]
                            trig_item.item_id = item.id[12:]

    if not readonly:
        update_item_in_file('Paths.TriggerActionsRelFilePath',
                            trigger_actions_rel_path)
Пример #11
0
def update_tsem_library_rel_path(scs_tsem_profile_inventory, tsem_library_rel_path, readonly=False):
    """The function deletes and populates again a list of Traffic Semaphore Profile names in inventory. It also updates corresponding record in
    config file.

    :param tsem_library_rel_path: Relative path to the directory with Traffic Semaphore Profile files
    :type tsem_library_rel_path: str
    """
    tsem_library_filepath = _path_utils.get_abs_path(tsem_library_rel_path)
    if tsem_library_filepath:

        if _get_scs_globals().tsem_library_use_infixed:
            tsem_library_filepaths = _path_utils.get_all_infixed_file_paths(tsem_library_filepath)
        else:
            tsem_library_filepaths = [tsem_library_filepath]

        # CLEAR INVENTORY
        scs_tsem_profile_inventory.clear()

        for tsem_library_filepath in tsem_library_filepaths:

            tsem_container = _sii.get_data_from_file(tsem_library_filepath)
            if tsem_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in tsem_container:
                    if item.type == 'tr_semaphore_profile':
                        if item.id.startswith('tr_sem_prof.'):
                            if 'name' in item.props:
                                tsem_name = item.props['name']
                            else:
                                continue

                            tsem_item = scs_tsem_profile_inventory.add()
                            tsem_item.name = tsem_name + " : " + item.id[12:]
                            tsem_item.item_id = item.id[12:]

                            if 'model' in item.props:
                                tsem_item.model = item.props['model'][0]

    if not readonly:
        update_item_in_file('Paths.TSemProfileRelFilePath', tsem_library_rel_path)
Пример #12
0
def update_trigger_actions_rel_path(scs_trigger_actions_inventory, trigger_actions_rel_path, readonly=False):
    """The function deletes and populates again a list of Trigger Actions in inventory. It also updates corresponding record in config file.

    :param trigger_actions_rel_path: Relative path to the directory with Trigger Action files
    :type trigger_actions_rel_path: str
    """
    trig_actions_path = _path_utils.get_abs_path(trigger_actions_rel_path)
    if trig_actions_path:

        if _get_scs_globals().trigger_actions_use_infixed:
            trig_actions_paths = _path_utils.get_all_infixed_file_paths(trig_actions_path)
        else:
            trig_actions_paths = [trig_actions_path]

        # CLEAR INVENTORY
        scs_trigger_actions_inventory.clear()

        for trig_actions_path in trig_actions_paths:

            trig_actions_container = _sii.get_data_from_file(trig_actions_path)
            if trig_actions_container:

                # ADD ALL ITEMS FROM CONTAINER INTO INVENTORY
                for item in trig_actions_container:
                    if item.type == 'trigger_action':
                        if item.id.startswith('trig_action.'):
                            if 'name' in item.props:
                                trg_action_name = item.props['name']
                            else:
                                continue

                            trig_item = scs_trigger_actions_inventory.add()
                            trig_item.name = trg_action_name + " : " + item.id[12:]
                            trig_item.item_id = item.id[12:]

    if not readonly:
        update_item_in_file('Paths.TriggerActionsRelFilePath', trigger_actions_rel_path)