diff --git a/Overlay/Functions.cs b/Overlay/Functions.cs index d873f8a..baa2b7d 100644 --- a/Overlay/Functions.cs +++ b/Overlay/Functions.cs @@ -14,6 +14,9 @@ namespace Overlay { public static class Exports { + internal static bool OverlayVisible = false; + internal static bool Initialized = false; + public static bool TextOnly = true; internal static IOverlay DefaultInstance { get { @@ -39,8 +42,18 @@ public static string SetDialogue(string text) { } - if (EventList.Length == 0 || HookText) + if (EventList.Length == 0) { + OverlayVisible = true; + } + + if (!Initialized && OverlayVisible) { + Initialized = true; + DefaultInstance.Show(); + } + + if (EventList.Length == 0 || HookText) { DefaultInstance.Text = text; + } } catch (Exception ex) { #if DEBUG MessageBox.Show(ex.ToString()); @@ -139,7 +152,6 @@ public static bool HookWindow(IntPtr WindowHandler) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - DefaultInstance.Show(); new Thread(() => { SetDialogue("::EVENT0::"); }).Start(); @@ -299,6 +311,7 @@ internal static void TriggerEvent(uint ID) { case "subtitle": case "set text": case "text": + OverlayVisible = true; DefaultInstance.Text = CMDV.Replace("\\n", "\n"); break; case "clear": @@ -311,6 +324,7 @@ internal static void TriggerEvent(uint ID) { case "close": case "hide overlay": case "close overlay": + OverlayVisible = false; DefaultInstance.Invoke(new MethodInvoker(() => { DefaultInstance.Opacity = 0; DefaultInstance?.Close(); @@ -320,6 +334,7 @@ internal static void TriggerEvent(uint ID) { case "open": case "show overlay": case "open overlay": + OverlayVisible = true; DefaultInstance.Invoke(new MethodInvoker(() => { DefaultInstance.Opacity = 1.0d; DefaultInstance.Show(); diff --git a/Overlay/Overlay.cs b/Overlay/Overlay.cs index b34411a..56587ce 100644 --- a/Overlay/Overlay.cs +++ b/Overlay/Overlay.cs @@ -106,8 +106,8 @@ public static Overlay DefaultInstance { Application.DoEvents(); } - if (_DefaultInstance == null || !_DefaultInstance.CanInvoke()) { - if (Exports.TextOnly) + if (Exports.OverlayVisible && (_DefaultInstance == null || !_DefaultInstance.CanInvoke())) { + if (Exports.TextOnly || !Exports.OverlayVisible) return null; Initializing = true; _DefaultInstance = new Overlay(); diff --git a/Overlay/TextOverlay.cs b/Overlay/TextOverlay.cs index ae55080..5f100d1 100644 --- a/Overlay/TextOverlay.cs +++ b/Overlay/TextOverlay.cs @@ -32,7 +32,7 @@ public static TextOverlay DefaultInstance { Application.DoEvents(); } - if (_DefaultInstance == null || !_DefaultInstance.CanInvoke()) { + if (Exports.OverlayVisible && (_DefaultInstance == null || !_DefaultInstance.CanInvoke())) { if (!Exports.TextOnly) return null; Initializing = true; diff --git a/SRL/Output.cs b/SRL/Output.cs index e84a9bd..5b944c7 100644 --- a/SRL/Output.cs +++ b/SRL/Output.cs @@ -37,10 +37,12 @@ internal static void ShowLoading() { PrintMessage(string.Format(WaitMsg, string.IsNullOrWhiteSpace(CustomCredits) ? string.Empty : "\n" + CustomCredits), -1); if (Title != ConsoleTitle) { - SetWindowText(GameHandler, Title + " - [SRL Initialized]"); + string NewTitle = Title + " - [SRL Initialized]"; + SetWindowText(GameHandler, NewTitle); Thread.Sleep(4000); - SetWindowText(GameHandler, Title); + if (WindowTitle == NewTitle) + SetWindowText(GameHandler, Title); } }