using System.Numerics; using ImGuiNET; namespace PartyDamage; public class PluginUi : IDisposable { private Plugin Plugin { get; } internal bool Visible; public PluginUi(Plugin plugin) { this.Plugin = plugin; this.Plugin.Interface.UiBuilder.Draw += this.Draw; } public void Dispose() { this.Plugin.Interface.UiBuilder.Draw -= this.Draw; } private void Draw() { if (!this.Visible) { return; } ImGui.SetNextWindowSize(new Vector2(700, 300), ImGuiCond.FirstUseEver); using var end = new OnDispose(ImGui.End); if (!ImGui.Begin("Party Damage", ref this.Visible)) { return; } 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.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); } 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); } 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")) { 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); } if (anyChanged) { this.Plugin.SaveConfig(); } } private static Vector3 ConvertRgba(uint colour) { var red = colour >> 24; var green = (colour >> 16) & 0xFF; var blue = (colour >> 8) & 0xFF; // var alpha = colour & 0xFF; return new Vector3(red / 255f, green / 255f, blue / 255f); } private static uint ConvertRgba(Vector3 parts) { var red = (uint) Math.Round(parts.X * 255); var green = (uint) Math.Round(parts.Y * 255); var blue = (uint) Math.Round(parts.Z * 255); return (red << 24) | (green << 16) | (blue << 8) | 0xFF; } }