namespace KMCCC.Launcher { #region using System; using System.Diagnostics; using Authentication; #endregion /// /// 启动选项 /// public sealed class LaunchOptions { /// /// 最大内存 /// public int MaxMemory { get; set; } /// /// 最小内存 /// public int MinMemory { get; set; } /// /// 启动的版本 /// public Version Version { get; set; } /// /// 使用的验证器 /// public IAuthenticator Authenticator { get; set; } /// /// 启动模式 /// public LaunchMode Mode { get; set; } /// /// 直接连接的服务器 /// public ServerInfo Server { get; set; } /// /// 设置窗口大小 /// public WindowSize Size { get; set; } } /// /// 启动句柄,基本上也就比较用 /// public sealed class LaunchHandle { /// /// 只读的验证信息 /// public readonly AuthenticationInfo Info; internal int Code; internal LauncherCore Core; internal Process Process; internal MinecraftLaunchArguments Arguments { get; set; } internal LaunchHandle(AuthenticationInfo info) { Info = info; } private void Output(object sender, DataReceivedEventArgs e) { if (e.Data == null) { Process.OutputDataReceived -= Output; } else { Core.Log(this, e.Data); } } private void Error(object sender, DataReceivedEventArgs e) { if (e.Data == null) { Process.OutputDataReceived -= Error; } else { Core.Log(this, e.Data); } } internal void Work() { Process.BeginOutputReadLine(); Process.OutputDataReceived += Output; Process.BeginErrorReadLine(); Process.ErrorDataReceived += Error; } } /// /// 启动异常(未启用) /// public class LaunchException : Exception { /// /// 启动异常 /// /// 异常类型 /// 异常信息 public LaunchException(LaunchExceptionType type, string message) : base(message) { Type = type; } /// /// 启动异常 /// /// 异常类型 /// 异常信息 /// 内部异常 public LaunchException(LaunchExceptionType type, string message, Exception innerException) : base(message, innerException) { Type = type; } /// /// 异常类型 /// public LaunchExceptionType Type { get; private set; } } /// /// 异常类型 /// public enum LaunchExceptionType { /// /// 验证器错误 /// Authenticator, /// /// 启动参数操作器错误 /// ArguementsOperator, /// /// 启动时错误 /// LaunchTime, /// /// 未知 /// Unknow } }