feat: add configurable thresholds
This commit is contained in:
parent
98b06cf34b
commit
5efc92e093
@ -28,6 +28,13 @@ public class Configuration : IPluginConfiguration {
|
||||
public float ClearDelaySeconds = 10;
|
||||
public bool UseEvaluatorNpc;
|
||||
public Guid EvaluatorId = Guid.Empty;
|
||||
public Dictionary<Evaluation, float> EvaluationThresholds = new() {
|
||||
[Evaluation.Best] = 0.85f,
|
||||
[Evaluation.Good] = 0.65f,
|
||||
[Evaluation.Fair] = 0.45f,
|
||||
[Evaluation.Poor] = 0.25f,
|
||||
[Evaluation.Awful] = 0f,
|
||||
};
|
||||
}
|
||||
|
||||
public enum MeterMode {
|
||||
|
37
Plugin.cs
37
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18
PluginUi.cs
18
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<Evaluation>()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user