feat: add scaling modes and filters
This commit is contained in:
parent
67bacae629
commit
41884b05ac
@ -6,6 +6,8 @@ public class Configuration : IPluginConfiguration {
|
|||||||
public int Version { get; set; } = 1;
|
public int Version { get; set; } = 1;
|
||||||
|
|
||||||
public bool UseDpsBar = true;
|
public bool UseDpsBar = true;
|
||||||
|
public DpsBarMode DpsBarMode = DpsBarMode.Party;
|
||||||
|
public bool DpsBarScaleToMax = true;
|
||||||
public float BarAlpha = 0.5f;
|
public float BarAlpha = 0.5f;
|
||||||
public int BarAddRed;
|
public int BarAddRed;
|
||||||
public int BarAddGreen;
|
public int BarAddGreen;
|
||||||
@ -28,6 +30,7 @@ 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() {
|
public Dictionary<Evaluation, float> EvaluationThresholds = new() {
|
||||||
[Evaluation.Best] = 0.85f,
|
[Evaluation.Best] = 0.85f,
|
||||||
[Evaluation.Good] = 0.65f,
|
[Evaluation.Good] = 0.65f,
|
||||||
@ -35,12 +38,15 @@ public class Configuration : IPluginConfiguration {
|
|||||||
[Evaluation.Poor] = 0.25f,
|
[Evaluation.Poor] = 0.25f,
|
||||||
[Evaluation.Awful] = 0f,
|
[Evaluation.Awful] = 0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
public int EvaluationMinCombatants = 4;
|
public int EvaluationMinCombatants = 4;
|
||||||
public int EvaluationMinSameRole;
|
public int EvaluationMinSameRole;
|
||||||
|
|
||||||
public Dictionary<Guid, bool> EvaluatorsRandomEnabled = Evaluator.Evaluators.ToDictionary(
|
public Dictionary<Guid, bool> EvaluatorsRandomEnabled = Evaluator.Evaluators.ToDictionary(
|
||||||
e => e.Id,
|
e => e.Id,
|
||||||
e => e.Default
|
e => e.Default
|
||||||
);
|
);
|
||||||
|
|
||||||
public float EvaluationLength = 5f;
|
public float EvaluationLength = 5f;
|
||||||
public bool BlendEvaluations;
|
public bool BlendEvaluations;
|
||||||
}
|
}
|
||||||
@ -49,3 +55,9 @@ public enum MeterMode {
|
|||||||
Name,
|
Name,
|
||||||
Mana,
|
Mana,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum DpsBarMode {
|
||||||
|
Encounter,
|
||||||
|
Party,
|
||||||
|
Alliance,
|
||||||
|
}
|
||||||
|
65
Plugin.cs
65
Plugin.cs
@ -333,7 +333,7 @@ public class Plugin : IDalamudPlugin {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.UpdateMember(list, i, member.Object, data.Encounter, combatant);
|
this.UpdateMember(list, i, member.Object, data.Encounter, combatant, data.Combatants.Values);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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(
|
private unsafe void UpdateMember(
|
||||||
AddonPartyList* list,
|
AddonPartyList* list,
|
||||||
int listIndex,
|
int listIndex,
|
||||||
BattleChara* chara,
|
BattleChara* chara,
|
||||||
Encounter encounter,
|
Encounter encounter,
|
||||||
Combatant combatant
|
Combatant combatant,
|
||||||
|
IEnumerable<Combatant> combatants
|
||||||
) {
|
) {
|
||||||
var member = list->PartyMembers[listIndex];
|
var member = list->PartyMembers[listIndex];
|
||||||
if (this.Config.UseDpsBar && member.TargetGlow != null) {
|
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->ToggleVisibility(true);
|
||||||
member.TargetGlow->SetAlpha((byte) Math.Round(this.Config.BarAlpha * 255));
|
member.TargetGlow->SetAlpha((byte) Math.Round(this.Config.BarAlpha * 255));
|
||||||
member.TargetGlow->SetScaleX(
|
member.TargetGlow->SetScaleX(
|
||||||
encounter.EncDps == 0
|
denominator == 0
|
||||||
? 0
|
? 0
|
||||||
: combatant.EncDps / encounter.EncDps
|
: combatant.EncDps / denominator
|
||||||
);
|
);
|
||||||
member.TargetGlow->AddRed = (byte) Math.Clamp(this.Config.BarAddRed, 0, 255);
|
member.TargetGlow->AddRed = (byte) Math.Clamp(this.Config.BarAddRed, 0, 255);
|
||||||
member.TargetGlow->AddGreen = (byte) Math.Clamp(this.Config.BarAddGreen, 0, 255);
|
member.TargetGlow->AddGreen = (byte) Math.Clamp(this.Config.BarAddGreen, 0, 255);
|
||||||
|
66
PluginUi.cs
66
PluginUi.cs
@ -55,22 +55,60 @@ public class PluginUi : IDisposable {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
anyChanged |= ImGui.Checkbox("Use DPS bars behind party list", ref this.Plugin.Config.UseDpsBar);
|
anyChanged |= ImGui.Checkbox("Use DPS bars behind party list", ref this.Plugin.Config.UseDpsBar);
|
||||||
var barAlpha = this.Plugin.Config.BarAlpha * 100;
|
using (ImGuiHelper.DisabledUnless(this.Plugin.Config.UseDpsBar)) {
|
||||||
if (ImGui.SliderFloat("Bar opacity", ref barAlpha, 0, 100, "%.2f%%")) {
|
if (ImGui.BeginCombo("Bar mode", Enum.GetName(this.Plugin.Config.DpsBarMode))) {
|
||||||
anyChanged = true;
|
using var endCombo = new OnDispose(ImGui.EndCombo);
|
||||||
this.Plugin.Config.BarAlpha = Math.Clamp(barAlpha / 100, 0, 1);
|
|
||||||
|
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();
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user