diff --git a/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs b/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs index 75290ebe1..e1799c1c6 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs @@ -17,13 +17,19 @@ public bool TryInvoke(out IAction newAction, out IAction gcdAction) UpdateInfo(); UpdateActions(ClassJob.GetJobRole()); - CountingOfNonRecommendedMembersUsing = 0; + CountingOfLastUsing = CountingOfCombatTimeUsing = 0; newAction = Invoke(out gcdAction); - if (InCombat || AverageCountOfNonRecommendedMembersUsing == 0) + if (InCombat || CountOfTracking == 0) { - AverageCountOfNonRecommendedMembersUsing = - (AverageCountOfNonRecommendedMembersUsing * CountOfTracking + CountingOfNonRecommendedMembersUsing) + AverageCountOfLastUsing = + (AverageCountOfLastUsing * CountOfTracking + CountingOfLastUsing) / ++CountOfTracking; + MaxCountOfLastUsing = Math.Max(MaxCountOfLastUsing, CountingOfLastUsing); + + AverageCountOfCombatTimeUsing = + (AverageCountOfCombatTimeUsing * (CountOfTracking -1)+ CountingOfCombatTimeUsing) + / CountOfTracking; + MaxCountOfCombatTimeUsing = Math.Max(MaxCountOfCombatTimeUsing, CountingOfCombatTimeUsing); } if (!IsValid) IsValid = true; diff --git a/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs b/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs index c5c867d87..531f39c5f 100644 --- a/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs +++ b/RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs @@ -265,37 +265,50 @@ public abstract partial class CustomRotation /// /// /// - public double AverageCountOfNonRecommendedMembersUsing { get; internal set; } = 0; - internal long CountOfTracking { get; set; } = 0; + public double AverageCountOfLastUsing { get; internal set; } = 0; - internal static float CountingOfNonRecommendedMembersUsing { get; set; } = 0; + /// + /// + /// + public int MaxCountOfLastUsing { get; internal set; } = 0; - private const float COMBAT_TIME_WEIGHT = 0.5f; + /// + /// + /// + public double AverageCountOfCombatTimeUsing { get; internal set; } = 0; + + /// + /// + /// + public int MaxCountOfCombatTimeUsing { get; internal set; } = 0; + internal long CountOfTracking { get; set; } = 0; + + internal static int CountingOfLastUsing { get; set; } = 0; + internal static int CountingOfCombatTimeUsing { get; set; } = 0; - private const string USE_LESS_WARNING = "Please use this as less as possible. If you use it too much, your rotation will be marked as not general."; /// /// The actions that were used by player successfully. The first one is the latest successfully used one. + ///
WARNING: Do Not make this method the main of your rotation.
///
- [Obsolete(USE_LESS_WARNING)] protected static ActionRec[] RecordActions { get { - CountingOfNonRecommendedMembersUsing++; + CountingOfLastUsing++; return DataCenter.RecordActions; } } /// /// How much time has passed since the last action was released. + ///
WARNING: Do Not make this method the main of your rotation.
///
- [Obsolete(USE_LESS_WARNING)] protected static TimeSpan TimeSinceLastAction { get { - CountingOfNonRecommendedMembersUsing++; + CountingOfLastUsing++; return DataCenter.TimeSinceLastAction; } } @@ -307,10 +320,9 @@ protected static TimeSpan TimeSinceLastAction /// Check for adjust id not raw id. /// True if any of this is matched. /// - [Obsolete(USE_LESS_WARNING)] public static bool IsLastGCD(bool isAdjust, params IAction[] actions) { - CountingOfNonRecommendedMembersUsing++; + CountingOfLastUsing++; return IActionHelper.IsLastGCD(isAdjust, actions); } @@ -320,10 +332,9 @@ public static bool IsLastGCD(bool isAdjust, params IAction[] actions) /// /// True if any of this is matched. /// - [Obsolete(USE_LESS_WARNING)] public static bool IsLastGCD(params ActionID[] ids) { - CountingOfNonRecommendedMembersUsing++; + CountingOfLastUsing++; return IActionHelper.IsLastGCD(ids); } @@ -334,10 +345,9 @@ public static bool IsLastGCD(params ActionID[] ids) /// Check for adjust id not raw id. /// True if any of this is matched. /// - [Obsolete(USE_LESS_WARNING)] public static bool IsLastAbility(bool isAdjust, params IAction[] actions) { - CountingOfNonRecommendedMembersUsing++; + CountingOfLastUsing++; return IActionHelper.IsLastAbility(isAdjust, actions); } @@ -347,10 +357,9 @@ public static bool IsLastAbility(bool isAdjust, params IAction[] actions) /// /// True if any of this is matched. /// - [Obsolete(USE_LESS_WARNING)] public static bool IsLastAbility(params ActionID[] ids) { - CountingOfNonRecommendedMembersUsing++; + CountingOfLastUsing++; return IActionHelper.IsLastAbility(ids); } @@ -361,10 +370,9 @@ public static bool IsLastAbility(params ActionID[] ids) /// Check for adjust id not raw id. /// True if any of this is matched. /// - [Obsolete(USE_LESS_WARNING)] public static bool IsLastAction(bool isAdjust, params IAction[] actions) { - CountingOfNonRecommendedMembersUsing++; + CountingOfLastUsing++; return IActionHelper.IsLastAction(isAdjust, actions); } @@ -374,10 +382,9 @@ public static bool IsLastAction(bool isAdjust, params IAction[] actions) /// /// True if any of this is matched. /// - [Obsolete(USE_LESS_WARNING)] public static bool IsLastAction(params ActionID[] ids) { - CountingOfNonRecommendedMembersUsing++; + CountingOfLastUsing++; return IActionHelper.IsLastAction(ids); } @@ -386,10 +393,9 @@ public static bool IsLastAction(params ActionID[] ids) /// /// /// - [Obsolete(USE_LESS_WARNING)] protected static bool CombatElapsedLessGCD(int GCD) { - CountingOfNonRecommendedMembersUsing += COMBAT_TIME_WEIGHT; + CountingOfCombatTimeUsing ++; return CombatElapsedLess(GCD * DataCenter.WeaponTotal); } @@ -399,22 +405,21 @@ protected static bool CombatElapsedLessGCD(int GCD) /// /// time in second. /// - [Obsolete(USE_LESS_WARNING)] protected static bool CombatElapsedLess(float time) { - CountingOfNonRecommendedMembersUsing += COMBAT_TIME_WEIGHT; + CountingOfCombatTimeUsing++; return CombatTime <= time; } /// /// The combat time. + ///
WARNING: Do Not make this method the main of your rotation.
///
- [Obsolete(USE_LESS_WARNING)] public static float CombatTime { get { - CountingOfNonRecommendedMembersUsing += COMBAT_TIME_WEIGHT; + CountingOfCombatTimeUsing++; return InCombat ? DataCenter.CombatTimeRaw + DataCenter.WeaponRemain : 0; } } @@ -434,7 +439,8 @@ public static float CombatTime protected static bool StopMovingElapsedLess(float time) => StopMovingTime <= time; /// - /// The time of stoping moving. + /// The time of stopping moving. + ///
WARNING: Do Not make this method the main of your rotation.
///
public static float StopMovingTime => IsMoving ? 0 : DataCenter.StopMovingRaw + DataCenter.WeaponRemain; @@ -449,7 +455,7 @@ protected static float GCDTime(uint gcdCount = 0, float offset = 0) #region Service /// - /// The countDond ahead. + /// The count down ahead. /// public static float CountDownAhead => Service.Config.GetValue(Configuration.PluginConfigFloat.CountDownAhead); diff --git a/RotationSolver.Basic/Rotations/ICustomRotation.cs b/RotationSolver.Basic/Rotations/ICustomRotation.cs index ba58278c3..428e2a2b6 100644 --- a/RotationSolver.Basic/Rotations/ICustomRotation.cs +++ b/RotationSolver.Basic/Rotations/ICustomRotation.cs @@ -9,9 +9,24 @@ namespace RotationSolver.Basic.Rotations; public interface ICustomRotation : ITexture { /// - /// The count of not recommend members using. + /// The average count of not recommend members using. /// - double AverageCountOfNonRecommendedMembersUsing { get; } + double AverageCountOfLastUsing { get; } + + /// + /// The max count of not recommend members using. + /// + int MaxCountOfLastUsing { get; } + + /// + /// The average count of not recommend members using. + /// + double AverageCountOfCombatTimeUsing { get; } + + /// + /// The max count of not recommend members using. + /// + int MaxCountOfCombatTimeUsing { get; } /// /// Whether show the status in the formal page. diff --git a/RotationSolver/Helpers/UIHelper.cs b/RotationSolver/Helpers/UIHelper.cs index 921534762..862669e78 100644 --- a/RotationSolver/Helpers/UIHelper.cs +++ b/RotationSolver/Helpers/UIHelper.cs @@ -18,7 +18,11 @@ public static void ShowWarning(this string message, int times = 3, DalamudLinkPa new TextPayload("Rotation Solver"), UIForegroundPayload.UIForegroundOff, RawPayload.LinkTerminator, - new TextPayload(": " + message)) + new TextPayload(": " + message), + + RotationSolverPlugin.HideWarningLinkPayload, + new TextPayload("(Hide Warning)"), + RawPayload.LinkTerminator) : new SeString( new IconPayload(BitmapFontIcon.DPS), @@ -29,6 +33,10 @@ public static void ShowWarning(this string message, int times = 3, DalamudLinkPa RawPayload.LinkTerminator, link, new TextPayload(": " + message), + RawPayload.LinkTerminator, + + RotationSolverPlugin.HideWarningLinkPayload, + new TextPayload("(Hide Warning)"), RawPayload.LinkTerminator); Svc.Chat.PrintChat(new Dalamud.Game.Text.XivChatEntry() diff --git a/RotationSolver/RotationSolverPlugin.cs b/RotationSolver/RotationSolverPlugin.cs index b2d90cae7..4491c9b49 100644 --- a/RotationSolver/RotationSolverPlugin.cs +++ b/RotationSolver/RotationSolverPlugin.cs @@ -32,6 +32,7 @@ public sealed class RotationSolverPlugin : IDalamudPlugin, IDisposable public string Name => "Rotation Solver"; public static DalamudLinkPayload OpenLinkPayload { get; private set; } + public static DalamudLinkPayload HideWarningLinkPayload { get; private set; } public RotationSolverPlugin(DalamudPluginInterface pluginInterface) { ECommonsMain.Init(pluginInterface, this, Module.DalamudReflector, Module.ObjectFunctions); @@ -89,7 +90,13 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface) { if (id == 0) OpenConfigWindow(); }); - + HideWarningLinkPayload = pluginInterface.AddChatLinkHandler(1, (id, str) => + { + if (id == 1) + { + Service.Config.SetValue(PluginConfigBool.HideWarning, true); + } + }); Task.Run(async () => { await DownloadHelper.DownloadAsync(); diff --git a/RotationSolver/UI/ControlWindow.cs b/RotationSolver/UI/ControlWindow.cs index 509b502f0..a8ad6f194 100644 --- a/RotationSolver/UI/ControlWindow.cs +++ b/RotationSolver/UI/ControlWindow.cs @@ -223,10 +223,14 @@ static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType c if(IconSet.GetTexture(gcd, out var texture)) { + var y = ImGui.GetCursorPosY(); + DrawIAction(texture.ImGuiHandle, baseId + nameof(gcd), gcdW, command, help); if (IconSet.GetTexture(ability, out texture)) { ImGui.SameLine(); + + ImGui.SetCursorPosY(y); DrawIAction(texture.ImGuiHandle, baseId + nameof(ability), abilityW, command, help); } } @@ -412,13 +416,17 @@ static unsafe void DrawNextAction(float gcd, float ability, float width) NextActionWindow.DrawGcdCooldown(width, true); + var y= ImGui.GetCursorPosY(); + DrawIAction(ActionUpdater.NextGCDAction, gcd, 1); var next = ActionUpdater.NextGCDAction != ActionUpdater.NextAction ? ActionUpdater.NextAction : null; ImGui.SameLine(); - DrawIAction(next, ability, -1); + ImGui.SetCursorPosY(y); + + DrawIAction(next, ability, 1); ImGui.EndGroup(); } } diff --git a/RotationSolver/UI/RotationConfigWindow.cs b/RotationSolver/UI/RotationConfigWindow.cs index 187a2877a..be73b21fd 100644 --- a/RotationSolver/UI/RotationConfigWindow.cs +++ b/RotationSolver/UI/RotationConfigWindow.cs @@ -20,6 +20,7 @@ using RotationSolver.UI.SearchableSettings; using RotationSolver.Updaters; using System.Diagnostics; +using System.Drawing; using GAction = Lumina.Excel.GeneratedSheets.Action; namespace RotationSolver.UI; @@ -611,7 +612,8 @@ private static void DrawRotation() var rotation = RotationUpdater.RightNowRotation; if (rotation == null) return; - ImGui.Text(rotation.AverageCountOfNonRecommendedMembersUsing.ToString("F2")); + ImGui.Text($"{rotation.AverageCountOfLastUsing:F2} / {rotation.MaxCountOfLastUsing}"); + ImGui.Text($"{rotation.AverageCountOfCombatTimeUsing:F2} / {rotation.MaxCountOfCombatTimeUsing}"); var desc = rotation.Description; if (!string.IsNullOrEmpty(desc)) @@ -644,6 +646,19 @@ private static void DrawRotation() _rotationHeader.Draw(); } + + private static void DrawRating(float value, float max) + { + value = float.Round(value, 2); + var text = value.ToString(); + + ImGui.PushFont(ImGuiHelper.GetFont(18)); + ImGui.PushStyleColor(ImGuiCol.Text, ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudYellow)); + ImGui.Text(text); + var size = ImGui.GetItemRectSize(); + ImGui.PopStyleColor(); + ImGui.PopFont(); + } private static readonly CollapsingHeaderGroup _rotationHeader = new(new() { @@ -1225,13 +1240,58 @@ private static void DrawRotationsLoaded() private static void DrawGitHubBadge(string userName, string repository, string id = "", string link = "", bool center = false) { - if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(repository) - && IconSet.GetTexture($"https://github-readme-stats.vercel.app/api/pin/?username={userName}&repo={repository}&theme=dark", out var icon) - && (center ? ImGuiHelper.TextureButton(icon, ImGui.GetWindowWidth(), icon.Width, id) + if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(repository)) return; + + var wholeWidth = ImGui.GetWindowWidth(); + + link = string.IsNullOrEmpty(link) ? $"https://GitHub.com/{userName}/{repository}" : link; + + if (IconSet.GetTexture($"https://github-readme-stats.vercel.app/api/pin/?username={userName}&repo={repository}&theme=dark", out var icon) + && (center ? ImGuiHelper.TextureButton(icon, wholeWidth, icon.Width, id) : ImGuiHelper.NoPaddingNoColorImageButton(icon.ImGuiHandle, new Vector2(icon.Width, icon.Height), id))) { - Util.OpenLink(string.IsNullOrEmpty(link) ? $"https://GitHub.com/{userName}/{repository}" : link); + Util.OpenLink(link); + } + + var hasDate = IconSet.GetTexture($"https://img.shields.io/github/release-date/{userName}/{repository}?style=for-the-badge", out var releaseDate); + + var hasCount = IconSet.GetTexture($"https://img.shields.io/github/downloads/{userName}/{repository}/latest/total?style=for-the-badge&label=", out var downloadCount); + + var style = ImGui.GetStyle(); + var spacing = style.ItemSpacing; + style.ItemSpacing = Vector2.Zero; + if (center) + { + float width = 0; + if (hasDate) width += releaseDate.Width; + if (hasCount) width += downloadCount.Width; + var ratio = MathF.Min(1, wholeWidth / width); + ImGuiHelper.DrawItemMiddle(() => + { + if(hasDate && ImGuiHelper.NoPaddingNoColorImageButton(releaseDate.ImGuiHandle, new Vector2(releaseDate.Width, releaseDate.Height) * ratio, id)) + { + Util.OpenLink(link); + } + if(hasDate && hasCount) ImGui.SameLine(); + if (hasCount && ImGuiHelper.NoPaddingNoColorImageButton(downloadCount.ImGuiHandle, new Vector2(downloadCount.Width, downloadCount.Height) * ratio, id)) + { + Util.OpenLink(link); + } + }, wholeWidth, width * ratio); + } + else + { + if (hasDate && ImGuiHelper.NoPaddingNoColorImageButton(releaseDate.ImGuiHandle, new Vector2(releaseDate.Width, releaseDate.Height), id)) + { + Util.OpenLink(link); + } + if (hasDate && hasCount) ImGui.SameLine(); + if (hasCount && ImGuiHelper.NoPaddingNoColorImageButton(downloadCount.ImGuiHandle, new Vector2(downloadCount.Width, downloadCount.Height), id)) + { + Util.OpenLink(link); + } } + style.ItemSpacing = spacing; } private static void DrawRotationsGitHub() @@ -1251,7 +1311,7 @@ private static void DrawRotationsGitHub() var repository = strs.Length > 1 ? strs[1] : string.Empty; var fileName = strs.LastOrDefault() ?? string.Empty; - DrawGitHubBadge(userName, repository, fileName); + DrawGitHubBadge(userName, repository, fileName, center:true); var changed = false;