feat: add scaling modes and filters

This commit is contained in:
Anna 2024-07-28 16:35:38 -04:00
parent 67bacae629
commit 41884b05ac
Signed by: anna
GPG Key ID: D0943384CD9F87D1
3 changed files with 125 additions and 18 deletions

View File

@ -6,6 +6,8 @@ public class Configuration : IPluginConfiguration {
public int Version { get; set; } = 1;
public bool UseDpsBar = true;
public DpsBarMode DpsBarMode = DpsBarMode.Party;
public bool DpsBarScaleToMax = true;
public float BarAlpha = 0.5f;
public int BarAddRed;
public int BarAddGreen;
@ -28,6 +30,7 @@ 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,
@ -35,12 +38,15 @@ public class Configuration : IPluginConfiguration {
[Evaluation.Poor] = 0.25f,
[Evaluation.Awful] = 0f,
};
public int EvaluationMinCombatants = 4;
public int EvaluationMinSameRole;
public Dictionary<Guid, bool> EvaluatorsRandomEnabled = Evaluator.Evaluators.ToDictionary(
e => e.Id,
e => e.Default
);
public float EvaluationLength = 5f;
public bool BlendEvaluations;
}
@ -49,3 +55,9 @@ public enum MeterMode {
Name,
Mana,
}
public enum DpsBarMode {
Encounter,
Party,
Alliance,
}

View File

@ -333,7 +333,7 @@ public class Plugin : IDalamudPlugin {
continue;
}
this.UpdateMember(list, i, member.Object, data.Encounter, combatant);
this.UpdateMember(list, i, member.Object, data.Encounter, combatant, data.Combatants.Values);
}
return false;
@ -436,21 +436,78 @@ public class Plugin : IDalamudPlugin {
}
}
private unsafe string[] GetPartyNames(bool alliance) {
var group = GroupManager.Instance()->GetGroup();
if (group == null) {
return [];
}
var length = group->PartyMembers.Length;
if (alliance) {
length += group->AllianceMembers.Length;
}
var members = new string[length];
int i;
for (i = 0; i < group->PartyMembers.Length; i++) {
var member = group->PartyMembers[i];
members[i] = member.NameString;
}
if (alliance) {
for (var j = 0; j < group->AllianceMembers.Length; j++) {
var member = group->AllianceMembers[j];
members[i + j] = member.NameString;
}
}
return members;
}
private unsafe void UpdateMember(
AddonPartyList* list,
int listIndex,
BattleChara* chara,
Encounter encounter,
Combatant combatant
Combatant combatant,
IEnumerable<Combatant> combatants
) {
var member = list->PartyMembers[listIndex];
if (this.Config.UseDpsBar && member.TargetGlow != null) {
float denominator;
switch (this.Config.DpsBarMode) {
case DpsBarMode.Encounter: {
denominator = combatants.Select(c => c.EncDps).Max();
break;
}
case DpsBarMode.Party: {
var party = this.GetPartyNames(false);
denominator = combatants
.Where(c => c.Name == "YOU" || party.Contains(c.Name))
.Select(c => c.EncDps)
.Max();
break;
}
case DpsBarMode.Alliance: {
var alliance = this.GetPartyNames(true);
denominator = combatants
.Where(c => c.Name == "YOU" || alliance.Contains(c.Name))
.Select(c => c.EncDps)
.Max();
break;
}
default: {
denominator = encounter.EncDps;
break;
}
}
member.TargetGlow->ToggleVisibility(true);
member.TargetGlow->SetAlpha((byte) Math.Round(this.Config.BarAlpha * 255));
member.TargetGlow->SetScaleX(
encounter.EncDps == 0
denominator == 0
? 0
: combatant.EncDps / encounter.EncDps
: combatant.EncDps / denominator
);
member.TargetGlow->AddRed = (byte) Math.Clamp(this.Config.BarAddRed, 0, 255);
member.TargetGlow->AddGreen = (byte) Math.Clamp(this.Config.BarAddGreen, 0, 255);

View File

@ -55,22 +55,60 @@ public class PluginUi : IDisposable {
// }
anyChanged |= ImGui.Checkbox("Use DPS bars behind party list", ref this.Plugin.Config.UseDpsBar);
var barAlpha = this.Plugin.Config.BarAlpha * 100;
if (ImGui.SliderFloat("Bar opacity", ref barAlpha, 0, 100, "%.2f%%")) {
anyChanged = true;
this.Plugin.Config.BarAlpha = Math.Clamp(barAlpha / 100, 0, 1);
using (ImGuiHelper.DisabledUnless(this.Plugin.Config.UseDpsBar)) {
if (ImGui.BeginCombo("Bar mode", Enum.GetName(this.Plugin.Config.DpsBarMode))) {
using var endCombo = new OnDispose(ImGui.EndCombo);
foreach (var mode in Enum.GetValues<DpsBarMode>()) {
if (ImGui.Selectable(Enum.GetName(mode), this.Plugin.Config.DpsBarMode == mode)) {
anyChanged = true;
this.Plugin.Config.DpsBarMode = mode;
}
}
}
var scalePreview = this.Plugin.Config.DpsBarScaleToMax
? "Max DPS"
: "Total DPS";
if (ImGui.BeginCombo("Bar scale", scalePreview)) {
using var endCombo = new OnDispose(ImGui.EndCombo);
if (ImGui.Selectable("Max DPS", this.Plugin.Config.DpsBarScaleToMax)) {
anyChanged = true;
this.Plugin.Config.DpsBarScaleToMax = true;
}
if (ImGui.Selectable("Total DPS", !this.Plugin.Config.DpsBarScaleToMax)) {
anyChanged = true;
this.Plugin.Config.DpsBarScaleToMax = false;
}
foreach (var mode in Enum.GetValues<DpsBarMode>()) {
if (ImGui.Selectable(Enum.GetName(mode), this.Plugin.Config.DpsBarMode == mode)) {
anyChanged = true;
this.Plugin.Config.DpsBarMode = mode;
}
}
}
var barAlpha = this.Plugin.Config.BarAlpha * 100;
if (ImGui.SliderFloat("Bar opacity", ref barAlpha, 0, 100, "%.2f%%")) {
anyChanged = true;
this.Plugin.Config.BarAlpha = Math.Clamp(barAlpha / 100, 0, 1);
}
if (ImGui.TreeNodeEx("Advanced colour options")) {
using var treePop = new OnDispose(ImGui.TreePop);
anyChanged |= ImGui.SliderInt("Add red", ref this.Plugin.Config.BarAddRed, 0, 255);
anyChanged |= ImGui.SliderInt("Add green", ref this.Plugin.Config.BarAddGreen, 0, 255);
anyChanged |= ImGui.SliderInt("Add blue", ref this.Plugin.Config.BarAddBlue, 0, 255);
anyChanged |= ImGui.SliderInt("Multiply red", ref this.Plugin.Config.BarMulRed, 0, 100);
anyChanged |= ImGui.SliderInt("Multiply green", ref this.Plugin.Config.BarMulGreen, 0, 100);
anyChanged |= ImGui.SliderInt("Multiply blue", ref this.Plugin.Config.BarMulBlue, 0, 100);
}
}
if (ImGui.TreeNodeEx("Advanced colour options")) {
using var treePop = new OnDispose(ImGui.TreePop);
anyChanged |= ImGui.SliderInt("Add red", ref this.Plugin.Config.BarAddRed, 0, 255);
anyChanged |= ImGui.SliderInt("Add green", ref this.Plugin.Config.BarAddGreen, 0, 255);
anyChanged |= ImGui.SliderInt("Add blue", ref this.Plugin.Config.BarAddBlue, 0, 255);
anyChanged |= ImGui.SliderInt("Multiply red", ref this.Plugin.Config.BarMulRed, 0, 100);
anyChanged |= ImGui.SliderInt("Multiply green", ref this.Plugin.Config.BarMulGreen, 0, 100);
anyChanged |= ImGui.SliderInt("Multiply blue", ref this.Plugin.Config.BarMulBlue, 0, 100);
}
ImGui.Spacing();