Browse Source

Made patcher behave sanely if no console is present

Removed auto-updater from execution path until BeatMods' API is finalized
pull/46/head
Anairkoen Schno 5 years ago
parent
commit
af68745560
3 changed files with 40 additions and 6 deletions
  1. +2
    -1
      IPA.Loader/Loader/PluginComponent.cs
  2. +38
    -5
      IPA/Program.cs
  3. BIN
      Refs/UnityEngine.CoreModule.dll

+ 2
- 1
IPA.Loader/Loader/PluginComponent.cs View File

@ -27,7 +27,8 @@ namespace IPA.Loader
ipaPlugins = new CompositeIPAPlugin(PluginManager.Plugins); ipaPlugins = new CompositeIPAPlugin(PluginManager.Plugins);
#pragma warning restore 618 #pragma warning restore 618
gameObject.AddComponent<Updating.ModSaber.Updater>();
/* kill this for now, until theres a new system */
//gameObject.AddComponent<Updating.ModSaber.Updater>();
bsPlugins.OnApplicationStart(); bsPlugins.OnApplicationStart();
ipaPlugins.OnApplicationStart(); ipaPlugins.OnApplicationStart();


+ 38
- 5
IPA/Program.cs View File

@ -283,10 +283,13 @@ namespace IPA
public static void ClearLine() 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<FileInfo> PassThroughInterceptor(FileInfo from, FileInfo to) private static IEnumerable<FileInfo> PassThroughInterceptor(FileInfo from, FileInfo to)
@ -313,7 +316,7 @@ namespace IPA
Debug.Assert(targetFile.Directory != null, "targetFile.Directory != null"); Debug.Assert(targetFile.Directory != null, "targetFile.Directory != null");
targetFile.Directory?.Create(); targetFile.Directory?.Create();
Console.CursorTop--;
LineBack();
ClearLine(); ClearLine();
Console.WriteLine(@"Copying {0}", targetFile.FullName); Console.WriteLine(@"Copying {0}", targetFile.FullName);
backup.Add(targetFile); 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 public abstract class Keyboard
{ {
[Flags] [Flags]


BIN
Refs/UnityEngine.CoreModule.dll View File


Loading…
Cancel
Save