def rename_original_to_wwise(obj):
    if obj['type'] != 'Sound':
        return

    original_wave_path = WaapiTools.get_original_wave_path(obj)
    new_wave_name = obj['name'] + '.wav'
    language = WaapiTools.get_sound_language(obj)
    # 当前不包含源文件,直接根据名称导入
    if language == '':
        if 'SFX' in original_wave_path:
            language = 'SFX'
        else:
            language = WaapiTools.get_default_language()

    if original_wave_path != '':
        original_wave_name = os.path.basename(original_wave_path)
        # 同名不用修改
        if original_wave_name == new_wave_name:
            return
        new_wave_path = original_wave_path.replace(original_wave_name,
                                                   new_wave_name)
        # 重命名源文件
        if not os.path.exists(new_wave_path):
            os.rename(original_wave_path, new_wave_path)
        # 删除旧资源
        delete_audio_sources(obj)
    # 找不到源文件,直接导入新的
    else:
        if language != 'SFX':
            language = os.path.join('Voice', language)
        new_wave_path = os.path.join(ScriptingTools.get_originals_folder(),
                                     language, new_wave_name)
    # 导入新资源
    WaapiTools.import_audio_file(new_wave_path, obj, obj['name'], language)
    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 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)