/// <summary> /// 构造函数 /// </summary> /// <param name="rootPath"></param> /// <param name="clientToken"></param> public DefaultVersionLocator(string rootPath, Guid clientToken) { RootPath = rootPath; LauncherProfileParser = new DefaultLauncherProfileParser(rootPath, clientToken); if (!Directory.Exists(GamePathHelper.GetVersionPath(RootPath))) { Directory.CreateDirectory(GamePathHelper.GetVersionPath(RootPath)); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="launchSettings">启动设置</param> /// <param name="launcherProfileParser">Mojang官方launcher_profiles.json适配组件</param> /// <param name="versionLocator"></param> /// <param name="authResult"></param> /// <param name="rootPath"></param> /// <param name="rootVersion"></param> public DefaultLaunchArgumentParser(LaunchSettings launchSettings, ILauncherProfileParser launcherProfileParser, IVersionLocator versionLocator, AuthResult authResult, string rootPath, string rootVersion) { if (launchSettings == null || launcherProfileParser == null) { throw new ArgumentNullException(); } AuthResult = authResult; VersionLocator = versionLocator; RootPath = rootPath; LaunchSettings = launchSettings; LauncherProfileParser = launcherProfileParser; VersionInfo = LaunchSettings.VersionLocator.GetGame(LaunchSettings.Version); GameProfile = LauncherProfileParser.GetGameProfile(LaunchSettings.GameName); ClassPath = string.Join(string.Empty, VersionInfo.Libraries.Select(l => $"{GamePathHelper.GetLibraryPath(launchSettings.GameResourcePath, l.Path.Replace('/', '\\'))};")); ClassPath += string.IsNullOrEmpty(rootVersion) ? GamePathHelper.GetGameExecutablePath(rootPath, launchSettings.Version) : GamePathHelper.GetGameExecutablePath(rootPath, rootVersion); LastAuthResult = LaunchSettings.Authenticator.GetLastAuthResult(); }