public static void PlayVoice(LoadAudioBase __instance) { if (Subtitles.SubtitleDictionary.TryGetValue(__instance.assetName, out string text)) { Caption.DisplaySubtitle(__instance, text); } }
internal static void DisplayHSubtitle(LoadAudioBase voice) { List <HActionBase> lstProc = (List <HActionBase>)AccessTools.Field(typeof(HSceneProc), "lstProc").GetValue(HSceneProcInstance); HActionBase mode = lstProc[(int)HSceneProcInstance.flags.mode]; HVoiceCtrl voicectrl = (HVoiceCtrl)AccessTools.Field(typeof(HActionBase), "voice").GetValue(mode); //At the start of the H scene, all the text was loaded. Look through the loaded stuff and find the text for the current spoken voice. string text = ""; FindText(); void FindText() { foreach (var a in voicectrl.dicVoiceIntos) { foreach (var b in a) { foreach (var c in b.Value) { text = c.Value.Where(x => x.Value.pathAsset == voice.assetBundleName && x.Value.nameFile == voice.assetName).Select(x => x.Value.word).FirstOrDefault(); if (!text.IsNullOrEmpty()) { return; } } } } } if (text.IsNullOrEmpty()) { return; } DisplaySubtitle(voice, text, init: false); }
internal static void DisplayHSubtitle(LoadAudioBase voice) { List <HActionBase> lstProc = (List <HActionBase>)AccessTools.Field(HSceneType, "lstProc").GetValue(HSceneInstance); HFlag flags = (HFlag)Traverse.Create(HSceneInstance).Field("flags").GetValue(); HActionBase mode = lstProc[(int)flags.mode]; HVoiceCtrl voicectrl = (HVoiceCtrl)AccessTools.Field(typeof(HActionBase), "voice").GetValue(mode); //At the start of the H scene, all the text was loaded. Look through the loaded stuff and find the text for the current spoken voice. foreach (var a in voicectrl.dicVoiceIntos) { foreach (var b in a) { foreach (var c in b.Value) { var text = c.Value.Where(x => x.Value.pathAsset == voice.assetBundleName && x.Value.nameFile == voice.assetName).Select(x => x.Value.word).FirstOrDefault(); if (!text.IsNullOrEmpty()) { if (HSceneType == typeof(HSceneProc)) { DisplaySubtitle(voice.gameObject, text); } else { DisplayVRSubtitle(voice.gameObject, text); } return; } } } } }
internal static void DisplayDialogueSubtitle(LoadAudioBase voice) { string text = ""; FindText(); void FindText() { foreach (var a in ActionGameInfoInstance.dicTalkInfo) { foreach (var b in a.Value) { foreach (var c in b.Value) { foreach (var d in c.Value.Where(x => x is ActionGame.Communication.Info.GenericInfo).Select(x => x as ActionGame.Communication.Info.GenericInfo)) { text = d.talk.Where(x => x.assetbundle == voice.assetBundleName && x.file == voice.assetName).Select(x => x.text).FirstOrDefault(); if (!text.IsNullOrEmpty()) { return; } } } } } } if (text.IsNullOrEmpty()) { return; } DisplaySubtitle(voice, text); }
public Transform SetParent( Transform parent, LoadAudioBase script, GameObject settingObject) { GameObject gameObject = (GameObject)Object.Instantiate <GameObject>((M0)settingObject, parent, false); gameObject.SetActive(true); script.Init((AudioSource)gameObject.GetComponent <AudioSource>()); return(gameObject.get_transform()); }
public override void OnStopVoice(LoadAudioBase v) { if (v == null || currentVoice == null || v != currentVoice) { return; } currentLine = null; currentJPLine = null; if (cfg.useCanvasRenderer && subtitleText != null) { subtitleText.text = ""; } }
public static void CatchVoice(LoadAudioBase __instance) { AudioSource audioSource = __instance.audioSource; if (audioSource == null || audioSource.clip == null || audioSource.loop) { return; } try { ShowSubtitle?.Invoke(audioSource); } catch (Exception ex) { Logger.Log(LogLevel.Error, ex); } }
private static IEnumerator _DisplaySubtitle(LoadAudioBase voice, string text, string speaker, bool init) { if (init) { InitGUI(); yield return(null); } Font fontFace = (Font)Resources.GetBuiltinResource(typeof(Font), $"{FontName.Value}.ttf"); int fsize = FontSize.Value; fsize = (int)(fsize < 0 ? (fsize * Screen.height / -100.0) : fsize); GameObject subtitle = new GameObject(voice.assetName); subtitle.transform.SetParent(Pane.transform); var rect = subtitle.GetComponent <RectTransform>() ?? subtitle.AddComponent <RectTransform>(); rect.pivot = new Vector2(0.5f, 0); rect.sizeDelta = new Vector2(Screen.width * 0.990f, fsize + (fsize * 0.05f)); var subtitleText = subtitle.GetComponent <Text>() ?? subtitle.AddComponent <Text>(); subtitleText.font = fontFace; subtitleText.fontSize = fsize; subtitleText.fontStyle = fontFace.dynamic ? FontStyle.Value : UnityEngine.FontStyle.Normal; subtitleText.alignment = TextAlign.Value; subtitleText.horizontalOverflow = HorizontalWrapMode.Wrap; subtitleText.verticalOverflow = VerticalWrapMode.Overflow; subtitleText.color = TextColor.Value; var subOutline = subtitle.GetComponent <Outline>() ?? subtitle.AddComponent <Outline>(); subOutline.effectColor = OutlineColor.Value; subOutline.effectDistance = new Vector2(OutlineThickness.Value, OutlineThickness.Value); subtitleText.text = speaker.IsNullOrEmpty() ? text : $"{speaker}:{text}"; Logger.LogDebug($"{text}"); voice.OnDestroyAsObservable().Subscribe(delegate(Unit _) { subtitle.transform.SetParent(null); Destroy(subtitle); }); }
public static void PlayVoice(LoadAudioBase __instance) { string[] assetNameSplit = __instance.assetName.Split('_'); if (assetNameSplit[0] == "he") { return; //Dialogue } if (assetNameSplit[0] == "hs" && assetNameSplit.Length >= 3 && int.TryParse(assetNameSplit[2], out int result) && result <= 226) { return; //Breath } if (SubtitleDictionary.TryGetValue(__instance.assetName, out string text)) { Caption.DisplaySubtitle(__instance, text); } }
public static void DisplaySubtitle(LoadAudioBase voice, string text, string speaker = "", bool init = true) { if (!ShowSubtitles.Value) { return; } if (text.IsNullOrWhiteSpace()) { return; } if (Pane == null && !init) { return; } voice.StartCoroutine(_DisplaySubtitle(voice, text, speaker, init)); }
public static void DisplaySubtitle(LoadAudioBase voice, string text, bool init = true) { if (!ShowSubtitles.Value) { return; } if (text.IsNullOrWhiteSpace()) { return; } if (Pane == null && !init) { return; } Instance.StartCoroutine(_DisplaySubtitle(voice.gameObject, voice.assetName, text, init)); }
public Transform FindAsset(Manager.Sound.Type type, string assetName, string assetBundleName = null) { if (this.typeObjects == null) { return((Transform)null); } Transform typeObject = this.typeObjects[(int)type]; for (int index = 0; index < typeObject.get_childCount(); ++index) { Transform child = typeObject.GetChild(index); LoadAudioBase componentInChildren = (LoadAudioBase)((Component)child).GetComponentInChildren <LoadAudioBase>(); if (Object.op_Inequality((Object)componentInChildren, (Object)null) && Object.op_Inequality((Object)componentInChildren.clip, (Object)null) && componentInChildren.assetName == assetName && ((assetBundleName == null || componentInChildren.assetBundleName == assetBundleName) && (type != Manager.Sound.Type.BGM || Object.op_Inequality((Object)((Component)child).get_gameObject(), (Object)this.oldBGM)))) { return(child); } } return((Transform)null); }
internal static void PlayVoice(LoadAudioBase __instance) { if (__instance.audioSource == null || __instance.audioSource.clip == null || __instance.audioSource.loop) { return; } if (HSceneProcInstance != null) { Caption.DisplayHSubtitle(__instance); } else if (ActionGameInfoInstance != null && GameObject.Find("ActionScene/ADVScene") == null) { Caption.DisplayDialogueSubtitle(__instance); } else if (SubtitleDictionary.TryGetValue(__instance.assetName, out string text)) { Caption.DisplaySubtitle(__instance, text); } }
internal static void DisplayDialogueSubtitle(LoadAudioBase voice) { foreach (var a in ActionGameInfoInstance.dicTalkInfo) { foreach (var b in a.Value) { foreach (var c in b.Value) { foreach (var d in c.Value.OfType <Info.GenericInfo>()) { var text = d.talk.Where(x => x.assetbundle == voice.assetBundleName && x.file == voice.assetName).Select(x => x.text).FirstOrDefault(); if (!text.IsNullOrEmpty()) { DisplaySubtitle(voice.gameObject, text); return; } } } } } }
public virtual void OnStopVoice(LoadAudioBase v) { }