From af68745560b0de838dfc2b8396b715237a81b940 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Wed, 3 Apr 2019 19:21:38 -0500 Subject: [PATCH] Made patcher behave sanely if no console is present Removed auto-updater from execution path until BeatMods' API is finalized --- IPA.Loader/Loader/PluginComponent.cs | 3 +- IPA/Program.cs | 43 +++++++++++++++++++++++---- Refs/UnityEngine.CoreModule.dll | Bin 613888 -> 613888 bytes 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/IPA.Loader/Loader/PluginComponent.cs b/IPA.Loader/Loader/PluginComponent.cs index ec02f6de..5ab3c2cb 100644 --- a/IPA.Loader/Loader/PluginComponent.cs +++ b/IPA.Loader/Loader/PluginComponent.cs @@ -27,7 +27,8 @@ namespace IPA.Loader ipaPlugins = new CompositeIPAPlugin(PluginManager.Plugins); #pragma warning restore 618 - gameObject.AddComponent(); + /* kill this for now, until theres a new system */ + //gameObject.AddComponent(); bsPlugins.OnApplicationStart(); ipaPlugins.OnApplicationStart(); diff --git a/IPA/Program.cs b/IPA/Program.cs index 120ad5f8..05c6abb7 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -283,10 +283,13 @@ namespace IPA public static void ClearLine() { - Console.SetCursorPosition(0, Console.CursorTop); - int tpos = Console.CursorTop; - Console.Write(new string(' ', Console.WindowWidth)); - Console.SetCursorPosition(0, tpos); + if (IsConsole) + { + Console.SetCursorPosition(0, Console.CursorTop); + int tpos = Console.CursorTop; + Console.Write(new string(' ', Console.WindowWidth)); + Console.SetCursorPosition(0, tpos); + } } private static IEnumerable PassThroughInterceptor(FileInfo from, FileInfo to) @@ -313,7 +316,7 @@ namespace IPA Debug.Assert(targetFile.Directory != null, "targetFile.Directory != null"); targetFile.Directory?.Create(); - Console.CursorTop--; + LineBack(); ClearLine(); Console.WriteLine(@"Copying {0}", targetFile.FullName); backup.Add(targetFile); @@ -387,6 +390,36 @@ namespace IPA } } + public static void ResetLine() + { + if (IsConsole) + Console.CursorLeft = 0; + else + Console.Write("\r"); + } + + public static void LineBack() + { + if (IsConsole) + Console.CursorTop--; + else + Console.Write("\x1b[1A"); + } + + [DllImport("kernel32.dll")] + private static extern IntPtr GetConsoleWindow(); + + private static bool? isConsole; + public static bool IsConsole + { + get + { + if (isConsole == null) + isConsole = GetConsoleWindow() != IntPtr.Zero; + return isConsole.Value; + } + } + public abstract class Keyboard { [Flags] diff --git a/Refs/UnityEngine.CoreModule.dll b/Refs/UnityEngine.CoreModule.dll index 51fc9d873e42ba6acda77aea156cc603d6dec1bb..2f7c7acf6ee897c160bc86860ca5f55368fbcc8d 100644 GIT binary patch delta 43 scmZqJquKyOEsQNpEzB(}TUf)w7+KoG!&rfs4T#x+m}7f*80SiM06{Me&Hw-a delta 43 scmZqJquKyOEsQNpEzB(}TUf)w7@69`!&rfs4T#x+m}7f*80SiM06_r_%m4rY