feat: add random evaluator option

This commit is contained in:
Anna 2024-07-27 21:15:28 -04:00
parent 8c7222b6ef
commit eed90f2ded
Signed by: anna
GPG Key ID: D0943384CD9F87D1
3 changed files with 43 additions and 33 deletions

View File

@ -44,6 +44,8 @@ public class Evaluator {
return line;
}
public static readonly Guid RandomId = new("00000000-0000-0000-0000-000000000001");
public static readonly Evaluator[] Evaluators = [
new Evaluator {
Id = new Guid("ebbccc44-13b5-4843-a635-3b693fe47840"),
@ -117,8 +119,7 @@ public class Evaluator {
Lines = new Dictionary<Evaluation, SeString[]> {
[Evaluation.Best] = [
new SeStringBuilder()
.AddItalics("Incredible!")
.AddText(" You have ")
.AddText("Incredible! You have ")
.AddItalics("got")
.AddText(" to show me how to do that sometime!")
.Build(),

View File

@ -173,8 +173,11 @@ public class Plugin : IDalamudPlugin {
this.Config.UseEvaluatorNpc
&& this.ClientState.LocalPlayer is { } player
&& this.Client.Data != null
&& Evaluator.Evaluators.FirstOrDefault(e => e.Id == this.Config.EvaluatorId) is { } evaluator
) {
var evaluator = this.Config.EvaluatorId == Evaluator.RandomId
? Random.Shared.GetItems(Evaluator.Evaluators, 1)[0]
: Evaluator.Evaluators.FirstOrDefault(e => e.Id == this.Config.EvaluatorId);
if (evaluator != null) {
var combatants = this.Client.Data.Combatants.Values
.Where(combatant => {
var job = this.DataManager.GetExcelSheet<ClassJob>()!
@ -203,7 +206,7 @@ public class Plugin : IDalamudPlugin {
0
);
}
}
}
}

View File

@ -120,7 +120,9 @@ public class PluginUi : IDisposable {
using (ImGuiHelper.DisabledUnless(this.Plugin.Config.UseEvaluatorNpc)) {
var current = Evaluator.Evaluators.FirstOrDefault(e => e.Id == this.Plugin.Config.EvaluatorId);
var preview = current == null
? "None"
? this.Plugin.Config.EvaluatorId == Evaluator.RandomId
? "Random"
: "None"
: current.Name;
if (ImGui.BeginCombo("Evaluator", preview)) {
using var endCombo = new OnDispose(ImGui.EndCombo);
@ -130,6 +132,11 @@ public class PluginUi : IDisposable {
this.Plugin.Config.EvaluatorId = Guid.Empty;
}
if (ImGui.Selectable("Random", this.Plugin.Config.EvaluatorId == Evaluator.RandomId)) {
anyChanged = true;
this.Plugin.Config.EvaluatorId = Evaluator.RandomId;
}
foreach (var evaluator in Evaluator.Evaluators) {
if (ImGui.Selectable(evaluator.Name, this.Plugin.Config.EvaluatorId == evaluator.Id)) {
anyChanged = true;
@ -141,7 +148,6 @@ public class PluginUi : IDisposable {
}
if (anyChanged) {
this.Plugin.SaveConfig();
}