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 float ClearDelaySeconds = 10;
|
||||||
public bool UseEvaluatorNpc;
|
public bool UseEvaluatorNpc;
|
||||||
public Guid EvaluatorId = Guid.Empty;
|
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 {
|
public enum MeterMode {
|
||||||
|
37
Plugin.cs
37
Plugin.cs
@ -188,23 +188,26 @@ public class Plugin : IDalamudPlugin {
|
|||||||
.ToList();
|
.ToList();
|
||||||
combatants.Sort((a, b) => a.EncDps.CompareTo(b.EncDps));
|
combatants.Sort((a, b) => a.EncDps.CompareTo(b.EncDps));
|
||||||
var rank = (float) (combatants.FindIndex(combatant => combatant.Name == "YOU") + 1) / combatants.Count;
|
var rank = (float) (combatants.FindIndex(combatant => combatant.Name == "YOU") + 1) / combatants.Count;
|
||||||
var evaluation = rank switch {
|
var thresholds = this.Config.EvaluationThresholds.ToList();
|
||||||
>= .85f => Evaluation.Best,
|
thresholds.Sort((a, b) => b.Value.CompareTo(a.Value));
|
||||||
>= .65f => Evaluation.Good,
|
foreach (var threshold in thresholds) {
|
||||||
>= .45f => Evaluation.Fair,
|
if (rank < threshold.Value) {
|
||||||
>= .25f => Evaluation.Poor,
|
continue;
|
||||||
_ => Evaluation.Awful,
|
}
|
||||||
};
|
|
||||||
var msg = evaluator.GetLineFor(evaluation);
|
var msg = evaluator.GetLineFor(threshold.Key);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
var bytes = msg.EncodeWithNullTerminator();
|
var bytes = msg.EncodeWithNullTerminator();
|
||||||
UIModule.Instance()->ShowBattleTalkImage(
|
UIModule.Instance()->ShowBattleTalkImage(
|
||||||
Encoding.UTF8.GetBytes(evaluator.Name),
|
Encoding.UTF8.GetBytes(evaluator.Name),
|
||||||
bytes,
|
bytes,
|
||||||
5f,
|
5f,
|
||||||
evaluator.BattleTalkImage,
|
evaluator.BattleTalkImage,
|
||||||
0
|
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