Skip to content

Commit

Permalink
Fix Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcussacana committed Aug 4, 2018
1 parent 411d9d4 commit d4acbf3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
19 changes: 17 additions & 2 deletions Overlay/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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());
Expand Down Expand Up @@ -139,7 +152,6 @@ public static bool HookWindow(IntPtr WindowHandler) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
DefaultInstance.Show();
new Thread(() => { SetDialogue("::EVENT0::"); }).Start();
Expand Down Expand Up @@ -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":
Expand All @@ -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();
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Overlay/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Overlay/TextOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions SRL/Output.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit d4acbf3

Please sign in to comment.