diff --git a/Configuration.cs b/Configuration.cs index d1035dc..b52ed0c 100644 --- a/Configuration.cs +++ b/Configuration.cs @@ -28,6 +28,13 @@ public class Configuration : IPluginConfiguration { public float ClearDelaySeconds = 10; public bool UseEvaluatorNpc; public Guid EvaluatorId = Guid.Empty; + public Dictionary EvaluationThresholds = new() { + [Evaluation.Best] = 0.85f, + [Evaluation.Good] = 0.65f, + [Evaluation.Fair] = 0.45f, + [Evaluation.Poor] = 0.25f, + [Evaluation.Awful] = 0f, + }; } public enum MeterMode { diff --git a/Plugin.cs b/Plugin.cs index d196304..5de175e 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -188,23 +188,26 @@ public class Plugin : IDalamudPlugin { .ToList(); combatants.Sort((a, b) => a.EncDps.CompareTo(b.EncDps)); var rank = (float) (combatants.FindIndex(combatant => combatant.Name == "YOU") + 1) / combatants.Count; - var evaluation = rank switch { - >= .85f => Evaluation.Best, - >= .65f => Evaluation.Good, - >= .45f => Evaluation.Fair, - >= .25f => Evaluation.Poor, - _ => Evaluation.Awful, - }; - var msg = evaluator.GetLineFor(evaluation); - if (msg != null) { - var bytes = msg.EncodeWithNullTerminator(); - UIModule.Instance()->ShowBattleTalkImage( - Encoding.UTF8.GetBytes(evaluator.Name), - bytes, - 5f, - evaluator.BattleTalkImage, - 0 - ); + var thresholds = this.Config.EvaluationThresholds.ToList(); + thresholds.Sort((a, b) => b.Value.CompareTo(a.Value)); + foreach (var threshold in thresholds) { + if (rank < threshold.Value) { + continue; + } + + var msg = evaluator.GetLineFor(threshold.Key); + if (msg != null) { + var bytes = msg.EncodeWithNullTerminator(); + UIModule.Instance()->ShowBattleTalkImage( + Encoding.UTF8.GetBytes(evaluator.Name), + bytes, + 5f, + evaluator.BattleTalkImage, + 0 + ); + } + + break; } } } diff --git a/PluginUi.cs b/PluginUi.cs index 85d8b6c..2aec218 100644 --- a/PluginUi.cs +++ b/PluginUi.cs @@ -144,6 +144,24 @@ public class PluginUi : IDisposable { } } } + + if (ImGui.TreeNodeEx("Evaluation thresholds")) { + using var treePop = new OnDispose(ImGui.TreePop); + ImGui.TextUnformatted("If your rank is equal to or above the thresholds defined below, you will get the ranking specified. For example, if best is set to 85% and good is set to 65% and you were 3/4 (75%), you would be evaluated as good."); + ImGui.Spacing(); + + foreach (var evaluation in Enum.GetValues()) { + if (!this.Plugin.Config.EvaluationThresholds.TryGetValue(evaluation, out var threshold)) { + threshold = 0f; + } + + threshold *= 100f; + if (ImGui.SliderFloat(Enum.GetName(evaluation), ref threshold, 0, 100)) { + anyChanged = true; + this.Plugin.Config.EvaluationThresholds[evaluation] = Math.Clamp(threshold / 100, 0, 1); + } + } + } } }