qstbak/Questionable/Questionable.Windows.ConfigComponents/NotificationConfigComponent.cs
2025-10-09 07:47:19 +10:00

72 lines
2.3 KiB
C#

using System;
using System.Linq;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Text;
using Dalamud.Interface.Components;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Plugin;
using Dalamud.Utility;
using Questionable.External;
namespace Questionable.Windows.ConfigComponents;
internal sealed class NotificationConfigComponent : ConfigComponent
{
private readonly NotificationMasterIpc _notificationMasterIpc;
public NotificationConfigComponent(IDalamudPluginInterface pluginInterface, Configuration configuration, NotificationMasterIpc notificationMasterIpc)
: base(pluginInterface, configuration)
{
_notificationMasterIpc = notificationMasterIpc;
}
public override void DrawTab()
{
using ImRaii.IEndObject endObject = ImRaii.TabItem("Notifications###Notifications");
if (!endObject)
{
return;
}
bool v = base.Configuration.Notifications.Enabled;
if (ImGui.Checkbox("Enable notifications when manual interaction is required", ref v))
{
base.Configuration.Notifications.Enabled = v;
Save();
}
using (ImRaii.Disabled(!base.Configuration.Notifications.Enabled))
{
using (ImRaii.PushIndent())
{
XivChatType[] array = (from x in Enum.GetValues<XivChatType>()
where x != XivChatType.StandardEmote
select x).ToArray();
int currentItem = Array.IndexOf(array, base.Configuration.Notifications.ChatType);
string[] items = array.Select((XivChatType t) => t.GetAttribute<XivChatTypeInfoAttribute>()?.FancyName ?? t.ToString()).ToArray();
if (ImGui.Combo("Chat channel", ref currentItem, in items, items.Length))
{
base.Configuration.Notifications.ChatType = array[currentItem];
Save();
}
ImGui.Separator();
ImGui.Text("NotificationMaster settings");
ImGui.SameLine();
ImGuiComponents.HelpMarker("Requires the plugin 'NotificationMaster' to be installed.");
using (ImRaii.Disabled(!_notificationMasterIpc.Enabled))
{
bool v2 = base.Configuration.Notifications.ShowTrayMessage;
if (ImGui.Checkbox("Show tray notification", ref v2))
{
base.Configuration.Notifications.ShowTrayMessage = v2;
Save();
}
bool v3 = base.Configuration.Notifications.FlashTaskbar;
if (ImGui.Checkbox("Flash taskbar icon", ref v3))
{
base.Configuration.Notifications.FlashTaskbar = v3;
Save();
}
}
}
}
}
}