diff --git a/RotationSolver.Basic/DataCenter.cs b/RotationSolver.Basic/DataCenter.cs index 7aa8e6d24..0fe806c18 100644 --- a/RotationSolver.Basic/DataCenter.cs +++ b/RotationSolver.Basic/DataCenter.cs @@ -104,8 +104,20 @@ public static unsafe ushort FateId #endregion public static uint[] BluSlots { get; set; } = new uint[24]; - public static SpecialCommandType SpecialType { get; set; } + static DateTime _specialStateStartTime = DateTime.MinValue; + public static double SpecialTimeLeft => Service.Config.SpecialDuration - (DateTime.Now - _specialStateStartTime).TotalSeconds; + + static SpecialCommandType _specialType = SpecialCommandType.EndSpecial; + public static SpecialCommandType SpecialType => + SpecialTimeLeft < 0 ? SpecialCommandType.EndSpecial : _specialType; public static StateCommandType StateType { get; set; } + + public static void SetSpecialType(SpecialCommandType specialType) + { + _specialType = specialType; + _specialStateStartTime = specialType == SpecialCommandType.EndSpecial ? DateTime.MinValue : DateTime.Now; + } + public static bool InCombat { get; set; } public static float CombatTime { get; set; } diff --git a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs index ddf65983f..22e480bc9 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs @@ -18,9 +18,6 @@ public abstract partial class CustomRotation : ICustomRotation public string Name => Job.Abbreviation + " - " + Job.Name; - /// - /// 作者 - /// public abstract string RotationName { get; } public bool IsEnabled @@ -67,4 +64,6 @@ protected virtual IRotationConfigSet CreateConfiguration() /// Update your customized field. /// protected virtual void UpdateInfo() { } + + public override string ToString() => RotationName; } diff --git a/RotationSolver/Commands/RSCommands_Actions.cs b/RotationSolver/Commands/RSCommands_Actions.cs index bf3ec89ed..b883f0800 100644 --- a/RotationSolver/Commands/RSCommands_Actions.cs +++ b/RotationSolver/Commands/RSCommands_Actions.cs @@ -14,7 +14,7 @@ public static partial class RSCommands static readonly TimeSpan _fastSpan = new TimeSpan(0, 0, 0, 0, 200); internal static unsafe void DoAnAction(bool isGCD) { - if (StateType == StateCommandType.Cancel) return; + if (DataCenter.StateType == StateCommandType.Cancel) return; var localPlayer = Service.Player; if (localPlayer == null) return; @@ -61,7 +61,7 @@ internal static unsafe void DoAnAction(bool isGCD) internal static void ResetSpecial() => DoSpecialCommandType(SpecialCommandType.EndSpecial, false); private static void CancelState() { - if (StateType != StateCommandType.Cancel) DoStateCommandType(StateCommandType.Cancel); + if (DataCenter.StateType != StateCommandType.Cancel) DoStateCommandType(StateCommandType.Cancel); } internal static void UpdateRotationState() @@ -89,7 +89,7 @@ internal static void UpdateRotationState() //Auto start at count Down. else if (Service.Config.StartOnCountdown && Service.CountDownTime > 0) { - if (StateType == StateCommandType.Cancel) + if (DataCenter.StateType == StateCommandType.Cancel) { DoStateCommandType(StateCommandType.Smart); } diff --git a/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs b/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs index 0ed553707..a1f6a79af 100644 --- a/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs +++ b/RotationSolver/Commands/RSCommands_StateSpecialCommand.cs @@ -10,19 +10,9 @@ namespace RotationSolver.Commands { public static partial class RSCommands { - private static DateTime _specialStateStartTime = DateTime.MinValue; - private static double SpecialTimeLeft => Service.Config.SpecialDuration - (DateTime.Now - _specialStateStartTime).TotalSeconds; - - private static SpecialCommandType _specialType = SpecialCommandType.EndSpecial; - public static SpecialCommandType SpecialType => - SpecialTimeLeft < 0 ? SpecialCommandType.EndSpecial : _specialType; - - public static StateCommandType StateType { get; private set; } = StateCommandType.Cancel; - - private static string _stateString = "Off", _specialString = string.Empty; internal static string EntryString => - _stateString + (SpecialTimeLeft < 0 ? string.Empty : $" - {_specialString}: {SpecialTimeLeft:F2}s"); + _stateString + (DataCenter.SpecialTimeLeft < 0 ? string.Empty : $" - {_specialString}: {DataCenter.SpecialTimeLeft:F2}s"); private static void UpdateToast() { @@ -36,14 +26,14 @@ private static void UpdateToast() private static unsafe void DoStateCommandType(StateCommandType stateType) => DoOneCommandType(stateType, EnumTranslations.ToSayout, role => { - if (StateType == StateCommandType.Smart + if (DataCenter.StateType == StateCommandType.Smart && stateType == StateCommandType.Smart) { Service.Config.TargetingIndex += 1; Service.Config.TargetingIndex %= Service.Config.TargetingTypes.Count; } - StateType = stateType; + DataCenter.StateType = stateType; UpdateStateNamePlate(); @@ -56,15 +46,13 @@ public static unsafe void UpdateStateNamePlate() if (Service.Player == null) return; Service.Player.SetNamePlateIcon( - StateType == StateCommandType.Cancel ? 0u : (uint)Service.Config.NamePlateIconId); + DataCenter.StateType == StateCommandType.Cancel ? 0u : (uint)Service.Config.NamePlateIconId); } private static void DoSpecialCommandType(SpecialCommandType specialType, bool sayout = true) => DoOneCommandType(specialType, sayout ? EnumTranslations.ToSayout : (s, r) => string.Empty, role => { - _specialType = specialType; _specialString = specialType.ToSpecialString(role); - - _specialStateStartTime = specialType == SpecialCommandType.EndSpecial ? DateTime.MinValue : DateTime.Now; + DataCenter.SetSpecialType(specialType); if (sayout) UpdateToast(); }); diff --git a/RotationSolver/RotationHelper.cs b/RotationSolver/RotationHelper.cs index 6f305efb3..0f7c5252f 100644 --- a/RotationSolver/RotationHelper.cs +++ b/RotationSolver/RotationHelper.cs @@ -21,14 +21,21 @@ public static bool IsDefault(this ICustomRotation rotation) public static bool IsAllowed(this ICustomRotation rotation, out string name) { name = rotation.GetType().Assembly.GetName().Name; - return _allowedAssembly.Contains(rotation.GetType().Assembly.GetName().Name); + return _allowedAssembly.Contains(name); } public static Vector4 GetColor(this ICustomRotation rotation) - => rotation.IsAllowed(out _) ? ImGuiColors.DalamudWhite : ImGuiColors.DalamudViolet; + => rotation.IsAllowed(out _) ? ImGuiColors.DalamudWhite : ImGuiColors.DalamudViolet; public static string GetAuthor(this ICustomRotation rotation) { - return FileVersionInfo.GetVersionInfo(rotation.GetType().Assembly.Location)?.CompanyName ?? "Unnamed"; + try + { + return FileVersionInfo.GetVersionInfo(rotation.GetType().Assembly.Location)?.CompanyName ?? "Unknown"; + } + catch + { + return "Unknown"; + } } } diff --git a/RotationSolver/UI/ImGuiHelper.cs b/RotationSolver/UI/ImGuiHelper.cs index bf94c82ec..920216c7a 100644 --- a/RotationSolver/UI/ImGuiHelper.cs +++ b/RotationSolver/UI/ImGuiHelper.cs @@ -442,18 +442,18 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation ImGui.TextDisabled(" - "); ImGui.SameLine(); - var isAllowed = rotation.IsAllowed(out _); - ImGui.TextColored(rotation.GetColor(), - rotation.GetAuthor()); - if (!isAllowed) + ImGui.PushStyleColor(ImGuiCol.Text, rotation.GetColor()); + ImGui.Text(rotation.GetAuthor()); + if (!rotation.IsAllowed(out _)) { - var showStr = "This rotation is not allowed to be used in High-end Duty!" + var showStr = $"This `{rotation}` rotation is not allowed to be used in High-end Duty!" + string.Join("", SocialUpdater.HighEndDuties.Select(x => x.PlaceName?.Value?.Name.ToString()) .Where(s => !string.IsNullOrEmpty(s)).Select(t => "\n - " + t)); HoveredString(showStr); } - + ImGui.PopStyleColor(); + ImGui.SameLine(); ImGui.TextDisabled(" - " + LocalizationManager.RightLang.ConfigWindow_Helper_GameVersion + ": "); ImGui.SameLine(); diff --git a/RotationSolver/UI/RotationConfigWindow_Debug.cs b/RotationSolver/UI/RotationConfigWindow_Debug.cs index e7e87b555..866ffac49 100644 --- a/RotationSolver/UI/RotationConfigWindow_Debug.cs +++ b/RotationSolver/UI/RotationConfigWindow_Debug.cs @@ -113,7 +113,7 @@ private unsafe void DrawTargetData() private void DrawNextAction() { ImGui.Text(RotationUpdater.RightNowRotation.RotationName); - ImGui.Text(RSCommands.SpecialType.ToString()); + ImGui.Text(DataCenter.SpecialType.ToString()); ActionUpdater.NextAction?.Display(false); ImGui.Text("Ability Remain: " + DataCenter.AbilityRemain.ToString());