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