Skip to content

Commit

Permalink
Fix for Singleton<HSceneProc> not working for some people
Browse files Browse the repository at this point in the history
  • Loading branch information
DeathWeasel1337 committed Jan 9, 2019
1 parent 8acf6b4 commit fb3dc00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions KK_Subtitles/KK_Subtitles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class KK_Subtitles : BaseUnityPlugin
public const string GUID = "com.deathweasel.bepinex.subtitles";
public const string Version = "1.0";
internal static Info ActionGameInfoInstance;
internal static HSceneProc HSceneProcInstance;
public static bool WasTouched = false;

#region ConfigMgr
Expand Down Expand Up @@ -102,7 +103,7 @@ public static void PlayVoice(LoadVoice __instance)
if (__instance.audioSource == null || __instance.audioSource.clip == null || __instance.audioSource.loop)
return;

if (Singleton<HSceneProc>.IsInstance())
if (HSceneProcInstance != null)
Caption.DisplayHSubtitle(__instance);
else if (ActionGameInfoInstance != null && WasTouched)
Caption.DisplayDialogueSubtitle(__instance);
Expand All @@ -124,7 +125,11 @@ public static void InfoInit(Info __instance)

[HarmonyPostfix]
[HarmonyPatch(typeof(HVoiceCtrl), "Init")]
public static void HVoiceCtrlInit() => Caption.InitGUI();
public static void HVoiceCtrlInit()
{
Caption.InitGUI();
HSceneProcInstance = FindObjectOfType<HSceneProc>();
}
}
}

4 changes: 2 additions & 2 deletions KK_Subtitles/KK_Subtitles_Caption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ void FindText()

internal static void DisplayHSubtitle(LoadVoice voice)
{
List<HActionBase> lstProc = (List<HActionBase>)AccessTools.Field(typeof(HSceneProc), "lstProc").GetValue(Singleton<HSceneProc>.Instance);
HActionBase mode = lstProc[(int)Singleton<HSceneProc>.Instance.flags.mode];
List<HActionBase> lstProc = (List<HActionBase>)AccessTools.Field(typeof(HSceneProc), "lstProc").GetValue(KK_Subtitles.HSceneProcInstance);
HActionBase mode = lstProc[(int)KK_Subtitles.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.
Expand Down

0 comments on commit fb3dc00

Please sign in to comment.