Exemplo n.º 1
0
 internal void Exit(LaunchHandle handle, int code)
 {
     if (GameExit != null)
     {
         GameExit(handle, code);
     }
 }
Exemplo n.º 2
0
 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
         });
     }
 }
Exemplo n.º 3
0
 internal void Log(LaunchHandle handle, string line)
 {
     if (GameLog != null)
     {
         GameLog(handle, line);
     }
 }
 internal void YLaunch(LaunchHandle yhandle)
 {
     if (YGameLaunch != null)
     {
         YGameLaunch(yhandle);
     }
 }
Exemplo n.º 5
0
 internal void Exit(LaunchHandle handle, int code)
 {
     if (GameExit != null)
     {
         GameExit(handle, code);
     }
 }
Exemplo n.º 6
0
 internal void Log(LaunchHandle handle, string line)
 {
     if (GameLog != null)
     {
         //Console.WriteLine(line);
         GameLog(handle, line);
     }
 }
Exemplo n.º 7
0
 public static string GetTile(this LaunchHandle handle)
 {
     try
     {
         return(handle.Process.MainWindowTitle);
     }
     catch
     {
         return(null);
     }
 }
Exemplo n.º 8
0
 public static bool SetTitle(this LaunchHandle handle, string title)
 {
     try
     {
         SetWindowText(handle.Process.MainWindowHandle, title);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
 private void OnExit(LaunchHandle handle, int code)
 {
     Dispatcher.Invoke((Action<int>) OnGameExit, code);
 }
Exemplo n.º 11
0
 private static void OnLog(LaunchHandle handle, string line)
 {
     Logger.Log(line);
 }
Exemplo n.º 12
0
		internal void Log(LaunchHandle handle, string line)
		{
			if (GameLog != null)
			{
				GameLog(handle, line);
			}
		}
Exemplo n.º 13
0
		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};
			}
		}
Exemplo n.º 14
0
 public static void Kill(this LaunchHandle handle)
 {
     handle.Process.Kill();
 }