Browse Source

Merge branch 'master' into 4.0.0-beta

4.0.0-beta
Anairkoen Schno 5 years ago
parent
commit
7256ba3625
6 changed files with 41 additions and 27 deletions
  1. +7
    -3
      IPA.Injector/GameVersionEarly.cs
  2. +2
    -2
      IPA.Injector/Injector.cs
  3. +0
    -1
      IPA.Injector/Updates.cs
  4. +3
    -8
      IPA.Loader/Loader/PluginLoader.cs
  5. +13
    -0
      IPA.Loader/Utilities/BeatSaber.cs
  6. +16
    -13
      IPA/Program.cs

+ 7
- 3
IPA.Injector/GameVersionEarly.cs View File

@ -15,7 +15,7 @@ namespace IPA.Injector
{
internal static class GameVersionEarly
{
internal static string ResolveDataPath(string installDir) =>
internal static string ResolveDataPath(string installDir) =>
Directory.EnumerateDirectories(installDir, "*_Data").First();
internal static string GlobalGameManagers(string installDir) =>
@ -53,12 +53,16 @@ namespace IPA.Injector
internal static SemVer.Version SafeParseVersion() => new SemVer.Version(GetGameVersion(), true);
private static void _Load() => BeatSaber.SetEarlyGameVersion(SafeParseVersion());
private static void _Load()
{
BeatSaber.SetEarlyGameVersion(SafeParseVersion());
BeatSaber.CheckGameVersionBoundary();
}
internal static void Load()
{
// This exists for the same reason the wierdness in Injector.Main does
var unused = Type.GetType("SemVer.Version, SemVer", false);
_ = Type.GetType("SemVer.Version, SemVer", false);
_Load();
}


+ 2
- 2
IPA.Injector/Injector.cs View File

@ -90,12 +90,12 @@ namespace IPA.Injector
// updates backup
InstallBootstrapPatch();
GameVersionEarly.Load();
Updates.InstallPendingUpdates();
LibLoader.SetupAssemblyFilenames(true);
GameVersionEarly.Load();
pluginAsyncLoadTask = PluginLoader.LoadTask();
permissionFixTask = PermissionFix.FixPermissions(new DirectoryInfo(Environment.CurrentDirectory));
}


+ 0
- 1
IPA.Injector/Updates.cs View File

@ -37,7 +37,6 @@ namespace IPA.Injector
{
Process.Start(new ProcessStartInfo
{
// will never actually be null
FileName = path,
Arguments = $"\"-nw={Process.GetCurrentProcess().Id},s={string.Join(" ", Environment.GetCommandLineArgs().Skip(1).StrJP()).Replace("\\", "\\\\").Replace(",", "\\,")}\"",
UseShellExecute = false


+ 3
- 8
IPA.Loader/Loader/PluginLoader.cs View File

@ -142,14 +142,11 @@ namespace IPA.Loader
internal static void YeetIfNeeded()
{
string pluginDir = BeatSaber.PluginsPath;
var gameVer = BeatSaber.GameVersion;
var lastVerS = SelfConfig.LastGameVersion_;
var lastVer = lastVerS != null ? new AlmostVersion(lastVerS, gameVer) : null;
if (SelfConfig.YeetMods_ && lastVer != null && gameVer != lastVer)
if (SelfConfig.YeetMods_ && BeatSaber.IsGameVersionBoundary)
{
var oldPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {lastVer} Plugins");
var newPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {gameVer} Plugins");
var oldPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {BeatSaber.OldVersion} Plugins");
var newPluginsName = Path.Combine(BeatSaber.InstallPath, $"Old {BeatSaber.GameVersion} Plugins");
if (Directory.Exists(oldPluginsName))
Directory.Delete(oldPluginsName, true);
@ -159,8 +156,6 @@ namespace IPA.Loader
else
Directory.CreateDirectory(pluginDir);
}
SelfConfig.Instance.LastGameVersion = gameVer.ToString();
}
internal static List<PluginMetadata> PluginsMetadata = new List<PluginMetadata>();


+ 13
- 0
IPA.Loader/Utilities/BeatSaber.cs View File

@ -46,6 +46,19 @@ namespace IPA.Utilities
}
}
internal static bool IsGameVersionBoundary { get; private set; }
internal static AlmostVersion OldVersion { get; private set; }
internal static void CheckGameVersionBoundary()
{
var gameVer = GameVersion;
var lastVerS = SelfConfig.LastGameVersion_;
var OldVersion = lastVerS != null ? new AlmostVersion(lastVerS, gameVer) : null;
IsGameVersionBoundary = OldVersion != null && gameVer != OldVersion;
SelfConfig.Instance.LastGameVersion = gameVer.ToString();
}
/// <summary>
/// The different types of releases of the game.
/// </summary>


+ 16
- 13
IPA/Program.cs View File

@ -27,19 +27,19 @@ namespace IPA
public static Version Version => Assembly.GetEntryAssembly().GetName().Version;
public static readonly ArgumentFlag ArgHelp = new ArgumentFlag("--help", "-h") { DocString = "prints this message" };
public static readonly ArgumentFlag ArgWaitFor = new ArgumentFlag("--waitfor", "-w") { DocString = "waits for the specified PID to exit", ValueString = "PID" };
public static readonly ArgumentFlag ArgForce = new ArgumentFlag("--force", "-f") { DocString = "forces the operation to go through" };
public static readonly ArgumentFlag ArgRevert = new ArgumentFlag("--revert", "-r") { DocString = "reverts the IPA installation" };
public static readonly ArgumentFlag ArgNoWait = new ArgumentFlag("--nowait", "-n") { DocString = "doesn't wait for user input after the operation" };
public static readonly ArgumentFlag ArgStart = new ArgumentFlag("--start", "-s") { DocString = "uses value_ as arguments to start the game after the patch/unpatch", ValueString = "ARGUMENTS" };
public static readonly ArgumentFlag ArgLaunch = new ArgumentFlag("--launch", "-l") { DocString = "uses positional parameters as arguments to start the game after patch/unpatch" };
//public static readonly ArgumentFlag ArgDestructive = new ArgumentFlag("--destructive", "-d") { DocString = "patches the game using the now outdated destructive methods" };
public static readonly ArgumentFlag ArgHelp = new ArgumentFlag("--help", "-h") { DocString = "prints this message" };
public static readonly ArgumentFlag ArgWaitFor = new ArgumentFlag("--waitfor", "-w") { DocString = "waits for the specified PID to exit", ValueString = "PID" };
public static readonly ArgumentFlag ArgForce = new ArgumentFlag("--force", "-f") { DocString = "forces the operation to go through" };
public static readonly ArgumentFlag ArgRevert = new ArgumentFlag("--revert", "-r") { DocString = "reverts the IPA installation" };
public static readonly ArgumentFlag ArgNoRevert = new ArgumentFlag("--no-revert", "-R") { DocString = "prevents a normal installation from first reverting" };
public static readonly ArgumentFlag ArgNoWait = new ArgumentFlag("--nowait", "-n") { DocString = "doesn't wait for user input after the operation" };
public static readonly ArgumentFlag ArgStart = new ArgumentFlag("--start", "-s") { DocString = "uses the specified arguments to start the game after the patch/unpatch", ValueString = "ARGUMENTS" };
public static readonly ArgumentFlag ArgLaunch = new ArgumentFlag("--launch", "-l") { DocString = "uses positional parameters as arguments to start the game after patch/unpatch" };
[STAThread]
public static void Main(string[] args)
{
Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch/*, ArgDestructive*/).Process();
Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch, ArgNoRevert).Process();
if (ArgHelp)
{
@ -159,10 +159,13 @@ namespace IPA
{
var backup = new BackupUnit(context);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Restoring old version... ");
if (BackupManager.HasBackup(context))
BackupManager.Restore(context);
if (!ArgNoRevert)
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Restoring old version... ");
if (BackupManager.HasBackup(context))
BackupManager.Restore(context);
}
var nativePluginFolder = Path.Combine(context.DataPathDst, "Plugins");
bool isFlat = Directory.Exists(nativePluginFolder) &&


Loading…
Cancel
Save