namespace KMCCC.Launcher
{
#region
using System;
using System.Collections.Generic;
using Tools;
#endregion
///
/// 版本定位器接口
///
public interface IVersionLocator
{
///
/// 设置定位器基于的核心
///
LauncherCore Core { set; }
///
/// 获取对应Id的Version,若不存在应返回null
///
/// 对应的Id
/// 对应的Version
Version Locate(string versionId);
///
/// 获取所有可找到Version
///
/// 所有Version
IEnumerable GetAllVersions();
}
///
/// 表示版本
///
public sealed class Version
{
///
/// ID
///
public string Id { get; set; }
///
/// 主启动参数
///
public string MinecraftArguments { get; set; }
///
/// 资源名
///
public string Assets { get; set; }
///
/// 主类
///
public string MainClass { get; set; }
///
/// 库列表
///
public List Libraries { get; set; }
///
/// 本地实现表
///
public List Natives { get; set; }
///
/// Jar文件(Id)
///
public string JarId { get; set; }
}
///
/// 表示库
///
public class Library
{
///
/// NS
///
public string NS { get; set; }
///
/// Name
///
public string Name { get; set; }
///
/// Version
///
public string Version { get; set; }
}
///
/// 表示本机实现
///
public class Native
{
///
/// NS
///
public string NS { get; set; }
///
/// Name
///
public string Name { get; set; }
///
/// Version
///
public string Version { get; set; }
///
/// 本机实现后缀
///
public string NativeSuffix { get; set; }
///
/// 解压参数
///
public UnzipOptions Options { get; set; }
}
///
/// 找Item,自己看我不加注释了
///
public static class LauncherCoreItemResolverExtensions
{
public static string GetVersionRootPath(this LauncherCore core, Version version)
{
return GetVersionRootPath(core, version.Id);
}
public static string GetVersionRootPath(this LauncherCore core, string versionId)
{
return String.Format(@"{0}\versions\{1}\", core.GameRootPath, versionId);
}
public static string GetVersionJarPath(this LauncherCore core, Version version)
{
return GetVersionJarPath(core, version.Id);
}
public static string GetVersionJarPath(this LauncherCore core, string versionId)
{
return String.Format(@"{0}\versions\{1}\{1}.jar", core.GameRootPath, versionId);
}
public static string GetVersionJsonPath(this LauncherCore core, Version version)
{
return GetVersionJsonPath(core, version.Id);
}
public static string GetVersionJsonPath(this LauncherCore core, string versionId)
{
return String.Format(@"{0}\versions\{1}\{1}.json", core.GameRootPath, versionId);
}
public static string GetLibPath(this LauncherCore core, Library lib)
{
return String.Format(@"{0}\libraries\{1}\{2}\{3}\{2}-{3}.jar", core.GameRootPath, lib.NS.Replace(".", "\\"), lib.Name, lib.Version);
}
public static string GetNativePath(this LauncherCore core, Native native)
{
return String.Format(@"{0}\libraries\{1}\{2}\{3}\{2}-{3}-{4}.jar", core.GameRootPath, native.NS.Replace(".", "\\"), native.Name, native.Version,
native.NativeSuffix);
}
}
}