automatic default StartInfo creation if not found

This commit is contained in:
liam 2020-02-16 19:51:10 -05:00
parent 85ca70f96e
commit 5aed3d615a

View file

@ -42,9 +42,17 @@ namespace Dalamud.Injector {
break; break;
} }
if (args.Length == 1) {
var defaultStartInfo = GetDefaultStartInfo();
Console.WriteLine("\nA Dalamud start info was not found in the program arguments. One has been generated for you.");
Console.WriteLine("\nCopy the following contents into the program arguments:");
Console.WriteLine(defaultStartInfo);
return;
}
var startInfo = JsonConvert.DeserializeObject<DalamudStartInfo>(Encoding.UTF8.GetString(Convert.FromBase64String(args[1]))); var startInfo = JsonConvert.DeserializeObject<DalamudStartInfo>(Encoding.UTF8.GetString(Convert.FromBase64String(args[1])));
startInfo.WorkingDirectory = Directory.GetCurrentDirectory(); startInfo.WorkingDirectory = Directory.GetCurrentDirectory();
// Seems to help with the STATUS_INTERNAL_ERROR condition // Seems to help with the STATUS_INTERNAL_ERROR condition
Thread.Sleep(1000); Thread.Sleep(1000);
@ -63,8 +71,34 @@ namespace Dalamud.Injector {
} }
RemoteHooking.Inject(process.Id, InjectionOptions.DoNotRequireStrongName, libPath, libPath, info); RemoteHooking.Inject(process.Id, InjectionOptions.DoNotRequireStrongName, libPath, libPath, info);
Console.WriteLine("Injected"); Console.WriteLine("Injected");
} }
private static string GetDefaultStartInfo() {
DalamudStartInfo startInfo = new DalamudStartInfo();
startInfo.WorkingDirectory = null;
startInfo.ConfigurationPath =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
@"\XIVLauncher\dalamudConfig.json";
startInfo.PluginDirectory =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XIVLauncher\plugins";
startInfo.DefaultPluginDirectory =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XIVLauncher\defaultplugins";
startInfo.Language = ClientLanguage.English;
Console.WriteLine("Creating a StartInfo with:\n" +
$"ConfigurationPath: {startInfo.ConfigurationPath}\n" +
$"PluginDirectory: {startInfo.PluginDirectory}\n" +
$"DefaultPluginDirectory: {startInfo.DefaultPluginDirectory}\n" +
$"Language: {startInfo.Language}");
return Convert.ToBase64String(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(startInfo)));
}
} }
} }