/** * Grasscutter Tools * Copyright (C) 2022 jie65535 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * **/ using System; namespace GrasscutterTools.Game { /// /// 命令版本 /// /// 用法: /// ver = Version.TryParse(input, out Version current) ? new CommandVersion(current) : CommandVersion.Latest(); /// /// internal class CommandVersion { /// /// 初始化当前版本 /// /// public CommandVersion(Version current) { this.current = current ?? throw new ArgumentNullException(nameof(current)); } private Version current; /// /// 当前命令版本 /// public Version Current { get => current; set { if (current != value) { current = value; OnVersionChanged(); } } } /// /// 选中版本改变事件 /// public event EventHandler VersionChanged; /// /// 触发版本更改事件 /// private void OnVersionChanged() => VersionChanged?.Invoke(this, EventArgs.Empty); /// /// 当前支持的最新版本 - 当未选择版本时,默认为最新版本 /// public static CommandVersion Latest() => new CommandVersion(List[List.Length - 1]); /// /// 检查命令版本 /// /// 最低要求版本 /// 当前版本是否满足 public bool Check(Version version) => Current >= version; #region - 版本列表 Version List - // 忽略更早以前的版本 /// /// v1.2.1 2022/6/18 /// git 30c7bb94439a123417a6a1e0116acd3c40f2d115 /// public static readonly Version V1_2_1 = new Version(1, 2, 1); /// /// v1.2.1 -> v1.2.2 2022/6/22 /// git aa43943025fefcda9739c9fcf242e67f1a7b83b4 /// public static readonly Version V1_2_2 = new Version(1, 2, 2); /// /// v1.2.2 -> v1.2.3 2022/7/21 /// git a07b3f21e6fbeb9abfad8862d6fa0dc4a1c3c1a3 /// public static readonly Version V1_2_3 = new Version(1, 2, 3); /// /// v1.2.3 -> v1.3.0 2022/9/3 - stable /// git 155501058fcce109489a19db37d0513d2235e08e /// public static readonly Version V1_3_0 = new Version(1, 3, 0); /// /// v1.3.0 -> v1.3.1 2022/9/3 /// git 6cf83b30eeaa98a68de2d786d7ca85ae21a95e32 /// public static readonly Version V1_3_1 = new Version(1, 3, 1); /// /// 2022/10/13 /// public static readonly Version V1_4_0 = new Version(1, 4, 0); /// /// 2022/10/18 /// public static readonly Version V1_4_1 = new Version(1, 4, 1); /// /// 2022/10/27 /// public static readonly Version V1_4_2 = new Version(1, 4, 2); /// /// 2022/11/15 /// public static readonly Version V1_4_3 = new Version(1, 4, 3); // More... /// /// Date /// //public static readonly Version V1_4_4 = new Version(1, 4, 4); public static Version[] List { get; } = new Version[] { V1_2_1, V1_2_2, V1_2_3, V1_3_0, V1_3_1, V1_4_0, V1_4_1, V1_4_2, V1_4_3, //V1_4_4, }; #endregion - 版本列表 Version List - } }