Example #1
0
 private LaunchResult LaunchGame(MinecraftLaunchArguments args)
 {
     try
     {
         var handle = new LaunchHandle(args.Authentication)
         {
             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 #2
0
        private static void core_GameLog(LaunchHandle handle, string line)
        {
            Console.WriteLine(line);
            _tw.WriteLine(line);

            //handle.SetTitle("啦啦啦");
        }
Example #3
0
 internal void Exit(LaunchHandle handle, int code)
 {
     if (GameExit != null)
     {
         GameExit(handle, code);
     }
 }
Example #4
0
		private static void core_GameLog(LaunchHandle handle, string line)
		{
			Console.WriteLine(line);
			_tw.WriteLine(line);

			handle.SetTitle("啦啦啦");
		}
Example #5
0
 internal void Log(LaunchHandle handle, string line)
 {
     if (GameLog != null)
     {
         //Console.WriteLine(line);
         GameLog(handle, line);
     }
 }
Example #6
0
        private void OnGameLaunch(LaunchHandle handle)
        {
            if (!string.IsNullOrWhiteSpace(App.Config.WindowTitle))
            {
                handle.SetTitle(App.Config.WindowTitle);
            }

            switch (App.Config.AfterLaunchBehavior)
            {
            case 0:
                Dispatcher.Invoke(() =>
                {
                    Application.Current.MainWindow.Hide();
                });
                break;

            case 1:
                Dispatcher.Invoke(() =>
                {
                    Application.Current.Shutdown();
                });
                break;

            case 2:
                Dispatcher.Invoke(() =>
                {
                    if (string.IsNullOrWhiteSpace(App.Config.UserName))
                    {
                        tb.Text = Excited[rand.Next(Excited.Length)];
                    }
                    else
                    {
                        tb.Text = "Hello " + App.Config.UserName;
                    }

                    LaunchButton.IsEnabled = true;
                    LaunchButton.Content   = "启动";
                    Launching = false;
                });
                break;
            }
        }
Example #7
0
        private void OnGameLaunch(LaunchHandle handle)
        {
            if (!string.IsNullOrWhiteSpace(Config.Args.GameWinTitle))
            {
                handle.SetTitle(Config.Args.GameWinTitle);
            }

            switch (Config.Args.AfterLaunchBehavior)
            {
            case 0:
                Dispatcher.Invoke(() =>
                {
                    Application.Current.MainWindow.Hide();
                });
                break;

            case 1:
                Dispatcher.Invoke(() =>
                {
                    Application.Current.Shutdown();
                });
                break;

            case 2:
                Dispatcher.Invoke(() =>
                {
                    if (string.IsNullOrWhiteSpace(Config.Args.UserName))
                    {
                        _titleBox.Text = KaomojiHelper.GetKaomoji();
                    }
                    else
                    {
                        _titleBox.Text = "Hello " + Config.Args.UserName;
                    }

                    _launchButton.IsEnabled = true;
                    _isLaunching            = false;
                });
                break;
            }
        }
        public void Begin(LaunchHandle lh)
        {
            _launchProgressWindow.LaunchHandle = lh;
            try
            {
                var processHandle = lh.GetPrivateField <Process>("Process");
                _launchProgressWindow.ProcessHandle = processHandle;
                if (Config.Instance.UseBoost)
                {
                    processHandle.ProcessorAffinity = (IntPtr)((1 << Environment.ProcessorCount) - 2);
                    processHandle.PriorityClass     = ProcessPriorityClass.RealTime;
                }

                //processHandle.PriorityBoostEnabled = true;
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
            }
            _launchProgressWindow.Begin();
            _launchProgressWindow.Show();
        }
Example #9
0
 private static void core_GameExit(LaunchHandle handle, int code)
 {
     Are.Set();
 }
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
 private void OnExit(LaunchHandle handle, int code)
 {
     object[] args = new object[] { code };
     base.Dispatcher.Invoke(new Action <int>(this.OnGameExit), args);
 }
Example #13
0
		private static void core_GameExit(LaunchHandle handle, int code)
		{
			Are.Set();
		}
 private void CloseGame(object sender, RoutedEventArgs e)
 {
     this.Flyout(Hide);
     AnimeTimer.Stop();
     LaunchHandle?.Kill();
 }