diff --git a/Evaluator.cs b/Evaluator.cs index 0952e32..719ecaa 100644 --- a/Evaluator.cs +++ b/Evaluator.cs @@ -3,6 +3,7 @@ using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; namespace PartyDamage; + public class Evaluator { public required Guid Id { get; init; } public required string Name { get; init; } @@ -21,16 +22,23 @@ public class Evaluator { } foreach (var payload in line.Payloads) { - if (payload is TextPayload text) { - var newText = new StringBuilder(); - var upper = true; - foreach (var ch in text.Text!) { - newText.Append(upper ? char.ToUpperInvariant(ch) : char.ToLowerInvariant(ch)); - upper = !upper; + if (payload is not TextPayload text) { + continue; + } + + var newText = new StringBuilder(); + var upper = true; + foreach (var ch in text.Text!) { + if (!char.IsLetter(ch)) { + newText.Append(ch); + continue; } - text.Text = newText.ToString(); + newText.Append(upper ? char.ToUpperInvariant(ch) : char.ToLowerInvariant(ch)); + upper = !upper; } + + text.Text = newText.ToString(); } return line; @@ -80,10 +88,8 @@ public class Evaluator { Name = "G'raha Tia", BattleTalkImage = 73012, Lines = new Dictionary { - }, }, - ]; } @@ -369,4 +375,4 @@ public enum Evaluation { // 272 good Otis in machine form // 273 Sphene final boss form // 274 looks like Zero kind of -// "73" + str(number) for index \ No newline at end of file +// "73" + str(number) for index diff --git a/Plugin.cs b/Plugin.cs index e8ee692..60fe02d 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -47,6 +47,9 @@ public class Plugin : IDalamudPlugin { [PluginService] internal IDataManager DataManager { get; init; } + // [PluginService] + // internal ITextureProvider TextureProvider { get; init; } + internal Configuration Config { get; } private Client Client { get; } internal PluginUi Ui { get; } @@ -177,7 +180,7 @@ public class Plugin : IDalamudPlugin { var job = this.DataManager.GetExcelSheet()! .FirstOrDefault(j => j.Abbreviation.RawString.Equals(combatant.JobAbbr, StringComparison.InvariantCultureIgnoreCase)); - return job?.ClassJobCategory.Row == player.ClassJob.GameData?.ClassJobCategory.Row; + return job?.Role == player.ClassJob.GameData?.Role; }) .ToList(); combatants.Sort((a, b) => a.EncDps.CompareTo(b.EncDps)); @@ -300,10 +303,11 @@ public class Plugin : IDalamudPlugin { AddonPartyList* list, BattleChara* chara, int listIndex, + bool includeBar, bool includeTargeted ) { var unit = list->PartyMembers[listIndex]; - if (unit.TargetGlow != null && (includeTargeted || list->TargetedIndex != listIndex)) { + if (includeBar && unit.TargetGlow != null && (includeTargeted || list->TargetedIndex != listIndex)) { unit.TargetGlow->SetAlpha(255); unit.TargetGlow->SetScaleX(0); unit.TargetGlow->AddRed = 0; @@ -388,7 +392,7 @@ public class Plugin : IDalamudPlugin { private unsafe void ResetMembers(AddonPartyList* list) { var members = AgentHUD.Instance()->PartyMembers; for (var i = 0; i < members.Length && i < list->PartyMembers.Length; i++) { - this.ResetMember(list, members[i].Object, i, false); + this.ResetMember(list, members[i].Object, i, true, false); } } @@ -430,7 +434,7 @@ public class Plugin : IDalamudPlugin { if (this.Config.Alternate && !this._showDps) { var isCaster = hasChara && Array.IndexOf(this._manaUsers, chara->ClassJob) != -1; if (!this.Config.ManaModeAlternateOnlyManaUsers || isCaster) { - this.ResetMember(list, chara, listIndex, true); + this.ResetMember(list, chara, listIndex, false, false); return; } } diff --git a/PluginUi.cs b/PluginUi.cs index a0daa8b..e4f99a8 100644 --- a/PluginUi.cs +++ b/PluginUi.cs @@ -30,95 +30,132 @@ public class PluginUi : IDisposable { var anyChanged = false; - // ImGui.TextUnformatted("Meter mode"); - // if (ImGui.BeginCombo("##mode", Enum.GetName(this.Plugin.Config.Mode))) { - // using var endCombo = new OnDispose(ImGui.EndCombo); - - // foreach (var mode in Enum.GetValues()) { - // if (ImGui.Selectable(Enum.GetName(mode), mode == this.Plugin.Config.Mode)) { - // anyChanged = true; - // this.Plugin.Config.Mode = mode; - // } - // } - // } - - 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); + if (!ImGui.BeginTabBar("##main-tab-bar")) { + return; } - if (ImGui.TreeNodeEx("Advanced colour options")) { - using var treePop = new OnDispose(ImGui.TreePop); + using var endTabBar = new OnDispose(ImGui.EndTabBar); - 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.BeginTabItem("Meter")) { + using var endTabItem = new OnDispose(ImGui.EndTabItem); + + // ImGui.TextUnformatted("Meter mode"); + // if (ImGui.BeginCombo("##mode", Enum.GetName(this.Plugin.Config.Mode))) { + // using var endCombo = new OnDispose(ImGui.EndCombo); + + // foreach (var mode in Enum.GetValues()) { + // if (ImGui.Selectable(Enum.GetName(mode), mode == this.Plugin.Config.Mode)) { + // anyChanged = true; + // this.Plugin.Config.Mode = mode; + // } + // } + // } + + 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); + } + + 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(); + + anyChanged |= ImGui.Checkbox("Alternate between values", ref this.Plugin.Config.Alternate); + using (ImGuiHelper.DisabledUnless(this.Plugin.Config.Alternate)) { + anyChanged |= ImGui.SliderFloat("Seconds before alternating", ref this.Plugin.Config.AlternateSeconds, 0.1f, 60f); + } + + using (ImGuiHelper.DisabledUnless(this.Plugin.Config is { Alternate: true, Mode: MeterMode.Mana })) { + anyChanged |= ImGui.Checkbox("Only alternate on jobs that use mana", ref this.Plugin.Config.ManaModeAlternateOnlyManaUsers); + } + + ImGui.Spacing(); + + var textColour = ConvertRgba(this.Plugin.Config.TextColour); + if (ImGui.ColorEdit3("DPS text colour", ref textColour)) { + anyChanged = true; + this.Plugin.Config.TextColour = ConvertRgba(textColour); + } + + if (ImGui.TreeNodeEx("Advanced colour options##text")) { + using var treePop = new OnDispose(ImGui.TreePop); + + anyChanged |= ImGui.SliderInt("Add red", ref this.Plugin.Config.TextAddRed, 0, 255); + anyChanged |= ImGui.SliderInt("Add green", ref this.Plugin.Config.TextAddGreen, 0, 255); + anyChanged |= ImGui.SliderInt("Add blue", ref this.Plugin.Config.TextAddBlue, 0, 255); + anyChanged |= ImGui.SliderInt("Multiply red", ref this.Plugin.Config.TextMulRed, 0, 100); + anyChanged |= ImGui.SliderInt("Multiply green", ref this.Plugin.Config.TextMulGreen, 0, 100); + anyChanged |= ImGui.SliderInt("Multiply blue", ref this.Plugin.Config.TextMulBlue, 0, 100); + } + + ImGui.Spacing(); + + anyChanged |= ImGui.Checkbox("Clear results after encounter ends", ref this.Plugin.Config.ClearResultsOnInactive); + using (ImGuiHelper.DisabledUnless(this.Plugin.Config.ClearResultsOnInactive)) { + anyChanged |= ImGui.SliderFloat("Seconds to delay before clearing", ref this.Plugin.Config.ClearDelaySeconds, 0, 300); + } } - anyChanged |= ImGui.Checkbox("Alternate between values", ref this.Plugin.Config.Alternate); - using (ImGuiHelper.DisabledUnless(this.Plugin.Config.Alternate)) { - anyChanged |= ImGui.SliderFloat("Seconds before alternating", ref this.Plugin.Config.AlternateSeconds, 0.1f, 60f); - } + if (ImGui.BeginTabItem("Evaluations")) { + using var endTabItem = new OnDispose(ImGui.EndTabItem); - using (ImGuiHelper.DisabledUnless(this.Plugin.Config is { Alternate: true, Mode: MeterMode.Mana })) { - anyChanged |= ImGui.Checkbox("Only alternate on jobs that use mana", ref this.Plugin.Config.ManaModeAlternateOnlyManaUsers); - } + ImGui.PushTextWrapPos(); + using var popTextWrapPos = new OnDispose(ImGui.PopTextWrapPos); - var textColour = ConvertRgba(this.Plugin.Config.TextColour); - if (ImGui.ColorEdit3("DPS text colour", ref textColour)) { - anyChanged = true; - this.Plugin.Config.TextColour = ConvertRgba(textColour); - } + ImGui.TextUnformatted("These evaluations are based on your relative rank compared to other players playing the same role (tank, healer, melee, magical ranged, physical ranged). This means that you will always receive the highest evaluation if you are the only member of your role. These evaluations should not be taken too seriously."); + ImGui.Separator(); - if (ImGui.TreeNodeEx("Advanced colour options##text")) { - using var treePop = new OnDispose(ImGui.TreePop); + anyChanged |= ImGui.Checkbox("Show an NPC text bubble rating your performance after an encounter", ref this.Plugin.Config.UseEvaluatorNpc); + using (ImGuiHelper.DisabledUnless(this.Plugin.Config.UseEvaluatorNpc)) { + var current = Evaluator.Evaluators.FirstOrDefault(e => e.Id == this.Plugin.Config.EvaluatorId); + var preview = current == null + ? "None" + : current.Name; + if (ImGui.BeginCombo("Evaluator", preview)) { + using var endCombo = new OnDispose(ImGui.EndCombo); - anyChanged |= ImGui.SliderInt("Add red", ref this.Plugin.Config.TextAddRed, 0, 255); - anyChanged |= ImGui.SliderInt("Add green", ref this.Plugin.Config.TextAddGreen, 0, 255); - anyChanged |= ImGui.SliderInt("Add blue", ref this.Plugin.Config.TextAddBlue, 0, 255); - anyChanged |= ImGui.SliderInt("Multiply red", ref this.Plugin.Config.TextMulRed, 0, 100); - anyChanged |= ImGui.SliderInt("Multiply green", ref this.Plugin.Config.TextMulGreen, 0, 100); - anyChanged |= ImGui.SliderInt("Multiply blue", ref this.Plugin.Config.TextMulBlue, 0, 100); - } - - anyChanged |= ImGui.Checkbox("Clear results after encounter ends", ref this.Plugin.Config.ClearResultsOnInactive); - using (ImGuiHelper.DisabledUnless(this.Plugin.Config.ClearResultsOnInactive)) { - anyChanged |= ImGui.SliderFloat("Seconds to delay before clearing", ref this.Plugin.Config.ClearDelaySeconds, 0, 300); - } - - anyChanged |= ImGui.Checkbox("Show an NPC text bubble rating your performance after an encounter", ref this.Plugin.Config.UseEvaluatorNpc); - using (ImGuiHelper.DisabledUnless(this.Plugin.Config.UseEvaluatorNpc)) { - var current = Evaluator.Evaluators.FirstOrDefault(e => e.Id == this.Plugin.Config.EvaluatorId); - var preview = current == null - ? "None" - : current.Name; - if (ImGui.BeginCombo("Evaluator", preview)) { - using var endCombo = new OnDispose(ImGui.EndCombo); - - if (ImGui.Selectable("None", this.Plugin.Config.EvaluatorId == Guid.Empty)) { - anyChanged = true; - this.Plugin.Config.EvaluatorId = Guid.Empty; - } - - foreach (var evaluator in Evaluator.Evaluators) { - if (ImGui.Selectable(evaluator.Name, this.Plugin.Config.EvaluatorId == evaluator.Id)) { + if (ImGui.Selectable("None", this.Plugin.Config.EvaluatorId == Guid.Empty)) { anyChanged = true; - this.Plugin.Config.EvaluatorId = evaluator.Id; + this.Plugin.Config.EvaluatorId = Guid.Empty; + } + + foreach (var evaluator in Evaluator.Evaluators) { + if (ImGui.Selectable(evaluator.Name, this.Plugin.Config.EvaluatorId == evaluator.Id)) { + anyChanged = true; + this.Plugin.Config.EvaluatorId = evaluator.Id; + } } } } } + + if (anyChanged) { this.Plugin.SaveConfig(); } + + // ImGui.InputInt("image id", ref this._imageId); + // if (this.Plugin.TextureProvider.TryGetFromGameIcon(new GameIconLookup((uint) this._imageId), out var tex)) { + // if (tex.TryGetWrap(out var wrap, out _)) { + // ImGui.Image(wrap.ImGuiHandle, new Vector2(wrap.Width, wrap.Height)); + // } + // } } + // private int _imageId = 73000; + private static Vector3 ConvertRgba(uint colour) { var red = colour >> 24; var green = (colour >> 16) & 0xFF;