def replace_parent(obj):
    parent = WaapiTools.get_parent_objects(obj, False)
    grand_parent = WaapiTools.get_parent_objects(parent, False)
    WaapiTools.move_object(obj, grand_parent)
    if grand_parent['type'] == 'SwitchContainer':
        mappings = get_switch_mapping(grand_parent)
        for mapping in mappings:
            if mapping['child'] == parent['id']:
                assign_switch_mapping(obj, mapping['stateOrSwitch'])
    WaapiTools.delete_object(parent)
    WaapiTools.rename_object(obj, parent['name'])
 def replace_event(self, event_obj):
     new_event_name = event_obj['name'].replace(self.__oldName,
                                                self.__newName).replace(
                                                    '_01', '')
     WaapiTools.rename_object(event_obj, new_event_name)
     for action in WaapiTools.get_children_objects(event_obj, False):
         target = WaapiTools.get_object_property(action, '@Target')
         target_full = WaapiTools.get_full_info_from_obj_id(target['id'])
         new_target_path = target_full['path'].replace(
             self.__oldName, self.__newName)
         new_target = WaapiTools.get_object_from_path(new_target_path)
         if new_target is not None:
             WaapiTools.set_object_reference(action, 'Target', new_target)
    def replace_source_wave(self, sound_obj):
        new_sound_name = sound_obj['name'].replace(self.__oldName,
                                                   self.__newName)
        WaapiTools.rename_object(sound_obj, new_sound_name)

        sources = WaapiTools.get_children_objects(sound_obj, False)
        for source in sources:
            original_path = WaapiTools.get_original_wave_path(source)
            language = WaapiTools.get_sound_language(source)
            new_wave_path = original_path.replace(self.__oldName,
                                                  self.__newName)
            WaapiTools.delete_object(source)
            WaapiTools.import_audio_file(new_wave_path, sound_obj,
                                         new_sound_name, language)
def split_by_net_role(obj):
    # Actor Mixer和Virtual Folder无法被放在SwitchContainer下面
    if obj['type'] == 'ActorMixer' or obj['type'] == 'Folder':
        return
    original_name = obj['name']
    # 拆分结构并重组到SwitchContainer下面
    old_parent = WaapiTools.get_parent_objects(obj, False)
    new_parent = WaapiTools.create_object(original_name + '_Temp',
                                          'SwitchContainer', old_parent,
                                          'rename')
    WaapiTools.move_object(obj, new_parent)
    obj_2p = WaapiTools.copy_object(obj, new_parent)
    obj_3p = WaapiTools.copy_object(obj, new_parent)
    WaapiTools.rename_object(obj, original_name + '_1P')
    WaapiTools.rename_object(obj_2p, original_name + '_2P')
    WaapiTools.rename_object(obj_3p, original_name + '_3P')
    WaapiTools.rename_object(new_parent, original_name)
    # 分配bus
    original_bus = WaapiTools.get_object_property(obj, '@OutputBus')
    original_bus_name = original_bus['name']
    bus_1p = WaapiTools.find_object_by_name(original_bus_name + '_1P', 'Bus')
    if bus_1p is None:
        bus_1p = WaapiTools.create_object(original_bus_name + '_1P', 'Bus',
                                          original_bus, 'replace')
    bus_2p = WaapiTools.find_object_by_name(original_bus_name + '_2P', 'Bus')
    if bus_2p is None:
        bus_2p = WaapiTools.create_object(original_bus_name + '_2P', 'Bus',
                                          original_bus, 'replace')
    bus_3p = WaapiTools.find_object_by_name(original_bus_name + '_3P', 'Bus')
    if bus_3p is None:
        bus_3p = WaapiTools.create_object(original_bus_name + '_3P', 'Bus',
                                          original_bus, 'replace')
    WaapiTools.set_object_property(obj, 'OverrideOutput', True)
    WaapiTools.set_object_reference(obj, 'OutputBus', bus_1p)
    WaapiTools.set_object_property(obj_2p, 'OverrideOutput', True)
    WaapiTools.set_object_reference(obj_2p, 'OutputBus', bus_2p)
    WaapiTools.set_object_property(obj_3p, 'OverrideOutput', True)
    WaapiTools.set_object_reference(obj_3p, 'OutputBus', bus_3p)
    net_role_switch_group = WaapiTools.find_object_by_name(
        'Net_Role', 'SwitchGroup')
    if net_role_switch_group is None:
        return
    WaapiTools.set_object_reference(new_parent, 'SwitchGroupOrStateGroup',
                                    net_role_switch_group)
    for switch_obj in WaapiTools.get_children_objects(net_role_switch_group,
                                                      False):
        if '1P' in switch_obj['name']:
            assign_switch_mapping(obj, switch_obj)
            WaapiTools.set_object_reference(new_parent, 'DefaultSwitchOrState',
                                            switch_obj)
        if '2P' in switch_obj['name']:
            assign_switch_mapping(obj_2p, switch_obj)
        if '3P' in switch_obj['name']:
            assign_switch_mapping(obj_3p, switch_obj)
 def replace_bank(self, bank_obj):
     new_bank_name = bank_obj['name'].replace(self.__oldName,
                                              self.__newName).replace(
                                                  '_01', '')
     WaapiTools.rename_object(bank_obj, new_bank_name)
     new_inclusion_objects = []
     for old_inclusion_obj in SoundBankTools.get_bank_inclusions(bank_obj):
         target_full = WaapiTools.get_full_info_from_obj_id(
             old_inclusion_obj['object'])
         new_target_path = target_full['path'].replace(
             self.__oldName, self.__newName)
         new_target = WaapiTools.get_object_from_path(new_target_path)
         if new_target is not None:
             inclusion = {
                 'object': new_target['id'],
                 'filter': old_inclusion_obj['filter']
             }
             new_inclusion_objects.append(inclusion)
     SoundBankTools.clear_bank_inclusions(bank_obj)
     SoundBankTools.add_objects_to_bank_with_individual_inclusion(
         bank_obj, new_inclusion_objects)
 def iterate_child_objects(self, obj):
     if self.cbxObjectType.currentText(
     ) == 'AudioSource' and obj['type'] == 'Sound':
         if self.__oldName in obj['name']:
             self.replace_source_wave(obj)
     elif self.cbxObjectType.currentText(
     ) == 'Event' and obj['type'] == 'Event':
         if self.__oldName in obj['name']:
             self.replace_event(obj)
     elif self.cbxObjectType.currentText(
     ) == 'SoundBank' and obj['type'] == 'SoundBank':
         if self.__oldName in obj['name']:
             self.replace_bank(obj)
     else:
         if self.__oldName in obj['name']:
             new_object_name = obj['name'].replace(self.__oldName,
                                                   self.__newName)
             # 音效不需要去除_01的后缀,事件和Bank需要
             if self.cbxObjectType.currentText() != 'AudioSource':
                 new_object_name = new_object_name.replace('_01', '')
             WaapiTools.rename_object(obj, new_object_name)
         for child in WaapiTools.get_children_objects(obj, False):
             self.iterate_child_objects(child)
Exemple #7
0
def rename_to_title_case(obj):
    new_name = obj['name'].title()
    if new_name != obj['name']:
        WaapiTools.rename_object(obj, new_name)
Exemple #8
0
def rename_to_lower_case(obj):
    new_name = obj['name'].lower()
    if new_name != obj['name']:
        WaapiTools.rename_object(obj, new_name)