internal void Exit(LaunchHandle handle, int code) { if (GameExit != null) { GameExit(handle, code); } }
internal void Log(LaunchHandle handle, string line) { if (GameLog != null) { GameLog(handle, line); } }
private LaunchResult LaunchGame(MinecraftLaunchArguments args) { try { var handle = new LaunchHandle(args.Authentication) { Code = CurrentCode, Core = this, Arguments = args, Process = Process.Start(new ProcessStartInfo(JavaPath) { Arguments = args.ToArguments(), UseShellExecute = false, WorkingDirectory = GameRootPath, RedirectStandardError = true, RedirectStandardOutput = true }) }; handle.Work(); Task.Factory.StartNew(handle.Process.WaitForExit).ContinueWith(t => Exit(handle, handle.Process.ExitCode)); return(new LaunchResult { Success = true, Handle = handle }); } catch (Exception exp) { return(new LaunchResult { Success = false, ErrorType = ErrorType.Unknown, ErrorMessage = "启动时出现了异常", Exception = exp }); } }
public static string GetTile(this LaunchHandle handle) { try { return(handle.Process.MainWindowTitle); } catch { return(null); } }
public static bool SetTitle(this LaunchHandle handle, string title) { try { SetWindowText(handle.Process.MainWindowHandle, title); return(true); } catch { return(false); } }
public static void Kill(this LaunchHandle handle) { handle.Process.Kill(); }