internal void Exit(LaunchHandle handle, int code) { if (GameExit != null) { GameExit(handle, code); } }
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 }); } }
internal void Log(LaunchHandle handle, string line) { if (GameLog != null) { GameLog(handle, line); } }
internal void YLaunch(LaunchHandle yhandle) { if (YGameLaunch != null) { YGameLaunch(yhandle); } }
internal void Log(LaunchHandle handle, string line) { if (GameLog != null) { //Console.WriteLine(line); GameLog(handle, line); } }
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 bool Setloc(this LaunchHandle handle, int x, int y, int width, int height) { try { if (MoveWindow(handle.Process.MainWindowHandle, x, y, width, height, true) != 0) { return(true); } else { return(false); } } catch { return(false); } }
private void OnExit(LaunchHandle handle, int code) { Dispatcher.Invoke((Action<int>) OnGameExit, code); }
private static void OnLog(LaunchHandle handle, string line) { Logger.Log(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 void Kill(this LaunchHandle handle) { handle.Process.Kill(); }