def auto_assign_switch_mappings(obj): if obj['type'] != 'SwitchContainer' and obj[ 'type'] != 'MusicSwitchContainer': return # 获取分配的Switch Group get_args = { 'from': { 'id': [obj['id']] }, 'options': { 'return': ['@SwitchGroupOrStateGroup'] } } switch_group_objects = WaapiTools.Client.call('ak.wwise.core.object.get', get_args)['return'] if len(switch_group_objects) == 0: return switch_group_obj = switch_group_objects[0]['@SwitchGroupOrStateGroup'] # 获取Switch Group中所有可能值 switch_objects = WaapiTools.get_children_objects(switch_group_obj, False) # 找到Switch Container里面的所有子对象 switch_container_children = WaapiTools.get_children_objects(obj, False) for child in switch_container_children: for switch_obj in switch_objects: # 两者名字任一包括即符合 switch_name = switch_obj['name'] child_name = child['name'] if switch_name in child_name or child_name in switch_name: assign_switch_mapping(child, switch_obj)
def populate_from_wwise(self, objects: list): for obj in objects: if obj['type'] == 'Sound': self.add_file(WaapiTools.get_original_wave_path(obj)) else: self.populate_from_wwise( WaapiTools.get_children_objects(obj, False))
def apply_fader_edits_downstream(obj): volume_bias = WaapiTools.get_object_property(obj, '@Volume') pitch_bias = WaapiTools.get_object_property(obj, '@Pitch') low_pass_bias = WaapiTools.get_object_property(obj, '@Lowpass') high_pass_bias = WaapiTools.get_object_property(obj, '@Highpass') WaapiTools.set_object_property(obj, 'Volume', 0) WaapiTools.set_object_property(obj, 'Pitch', 0) WaapiTools.set_object_property(obj, 'Lowpass', 0) WaapiTools.set_object_property(obj, 'Highpass', 0) children = WaapiTools.get_children_objects(obj, False) for child in children: volume_base = WaapiTools.get_object_property(child, '@Volume') pitch_base = WaapiTools.get_object_property(child, '@Pitch') low_pass_base = WaapiTools.get_object_property(child, '@Lowpass') high_pass_base = WaapiTools.get_object_property(child, '@Highpass') WaapiTools.set_object_property(child, 'Volume', volume_base + volume_bias) WaapiTools.set_object_property(child, 'Pitch', pitch_base + pitch_bias) WaapiTools.set_object_property(child, 'Lowpass', low_pass_base + low_pass_bias) WaapiTools.set_object_property(child, 'Highpass', high_pass_base + high_pass_bias) # 递归应用编辑 if child['type'] != 'Sound': apply_fader_edits_downstream(child)
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 get_children_from_selection(self): selected_objects = WaapiTools.get_selected_objects() if len(selected_objects) == 0: return children = WaapiTools.get_children_objects(selected_objects[0], False) row = 0 for child in children: if row >= self.tblMatrix.rowCount(): self.tblMatrix.setRowCount(row + 1) self.tblMatrix.setItem(row, 0, QTableWidgetItem(child['name'])) row += 1
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 temp_tool(objects: list): for obj in objects: parent = WaapiTools.get_parent_objects(obj, False) new_obj = WaapiTools.create_object('Tail', 'SwitchContainer', parent, 'rename') WaapiTools.move_object(obj, new_obj) indoor_switch_group = WaapiTools.find_object_by_name( 'Indoor_Outdoor', 'SwitchGroup') WaapiTools.set_object_reference(new_obj, 'SwitchGroupOrStateGroup', indoor_switch_group) outdoor_switch = WaapiTools.get_children_objects( indoor_switch_group, False)[1] LogicContainerTools.assign_switch_mapping(obj, outdoor_switch) WaapiTools.set_object_reference(new_obj, 'DefaultSwitchOrState', outdoor_switch) if parent['type'] == 'SwitchContainer': loop_switch_group = WaapiTools.find_object_by_name( 'Gun_Shot_Loop_Mode', 'SwitchGroup') end_switch = WaapiTools.get_children_objects( loop_switch_group, False)[0] LogicContainerTools.assign_switch_mapping(new_obj, end_switch)
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 find_children(self): if WaapiTools.Client is None: return if self.cbxKeepSelf.isChecked(): all_children = self.activeObjects else: all_children = [] for obj in self.activeObjects: for child in WaapiTools.get_children_objects( obj, self.cbxRecursiveFind.isChecked()): all_children.append(child) self.cacheObjects = all_children self.reset_filter() self.filter_and_show_list()
def localize_language(obj): language_list = WaapiTools.get_language_list() sources = WaapiTools.get_children_objects(obj, False) existing_language = '' existing_source = None for source in sources: existing_language = WaapiTools.get_sound_language(source) existing_source = source break for language_obj in language_list: language = language_obj['name'] if language != existing_language: original_file_path = WaapiTools.get_original_wave_path( existing_source) WaapiTools.import_audio_file( original_file_path.replace(existing_language, language), obj, obj['name'], language)
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)
def get_switch_container_child_context(obj): get_args = { 'from': { 'id': [obj['id']] }, 'options': { 'return': ['switchContainerChild:context'] } } result = WaapiTools.Client.call('ak.wwise.core.object.get', get_args) context = result['return'][0]['switchContainerChild:context'] print(context) descendants = WaapiTools.get_children_objects(context, True) print(descendants) get_args = { 'from': { 'id': [context['id']] }, 'options': { 'return': ['@VoicePitch'] } } result = WaapiTools.Client.call('ak.wwise.core.object.get', get_args) print(result)
def iterate_child_sound_objects(obj, action): if obj['type'] == 'Sound': action(obj) else: for child in WaapiTools.get_children_objects(obj, False): iterate_child_sound_objects(child, action)
def iterate_through_children(self, obj): children = WaapiTools.get_children_objects(obj, False) for child in children: # 找不到就继续往里层找,直到Sound这一级为止 if not self.find_matching_bank(child) and child['type'] != 'Sound': self.iterate_through_children(child)
def delete_audio_sources(obj): audio_sources = WaapiTools.get_children_objects(obj, False) for audio_source in audio_sources: WaapiTools.delete_object(audio_source)
def break_container(obj): children = WaapiTools.get_children_objects(obj, False) parent = WaapiTools.get_parent_objects(obj, False) for child in children: WaapiTools.move_object(child, parent) WaapiTools.delete_object(obj)