1
0
Fork 0
forked from aly/qstbak

muffin v7.4.6

This commit is contained in:
alydev 2025-12-24 05:01:16 +10:00
parent bb09805213
commit 1cc65e495d
13 changed files with 1291 additions and 949 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Text;
using Dalamud.Interface.Utility.Raii;
@ -10,9 +11,21 @@ namespace Questionable.Windows.ConfigComponents;
internal sealed class NotificationConfigComponent : ConfigComponent
{
private readonly XivChatType[] _xivChatTypes;
private readonly string[] _chatTypeNames;
private string _chatChannelSearchText = string.Empty;
private bool _chatChannelComboJustOpened;
public NotificationConfigComponent(IDalamudPluginInterface pluginInterface, Configuration configuration)
: base(pluginInterface, configuration)
{
_xivChatTypes = (from x in Enum.GetValues<XivChatType>()
where x != XivChatType.StandardEmote
select x).ToArray();
_chatTypeNames = _xivChatTypes.Select((XivChatType t) => t.GetAttribute<XivChatTypeInfoAttribute>()?.FancyName ?? t.ToString()).ToArray();
}
public override void DrawTab()
@ -32,15 +45,52 @@ internal sealed class NotificationConfigComponent : ConfigComponent
{
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[] array2 = array.Select((XivChatType t) => t.GetAttribute<XivChatTypeInfoAttribute>()?.FancyName ?? t.ToString()).ToArray();
if (ImGui.Combo((ImU8String)"Chat channel", ref currentItem, (ReadOnlySpan<string>)array2, array2.Length))
int num = Array.IndexOf(_xivChatTypes, base.Configuration.Notifications.ChatType);
if (num == -1)
{
base.Configuration.Notifications.ChatType = array[currentItem];
Save();
num = 0;
}
string text = ((num >= 0 && num < _chatTypeNames.Length) ? _chatTypeNames[num] : "Unknown");
if (ImGui.BeginCombo("Chat channel", text, ImGuiComboFlags.HeightLarge))
{
if (!_chatChannelComboJustOpened)
{
ImGui.SetKeyboardFocusHere();
_chatChannelComboJustOpened = true;
}
ImGui.SetNextItemWidth(-1f);
ImGui.InputTextWithHint("##ChatChannelSearch", "Search chat channels...", ref _chatChannelSearchText, 256);
ImGui.Separator();
using (ImRaii.IEndObject endObject2 = ImRaii.Child("##ChatChannelScrollArea", new Vector2(0f, 300f), border: false))
{
if (endObject2)
{
string value = _chatChannelSearchText.ToUpperInvariant();
for (int i = 0; i < _chatTypeNames.Length; i++)
{
if (string.IsNullOrEmpty(_chatChannelSearchText) || _chatTypeNames[i].ToUpperInvariant().Contains(value, StringComparison.Ordinal))
{
bool flag = i == num;
if (ImGui.Selectable(_chatTypeNames[i], flag))
{
base.Configuration.Notifications.ChatType = _xivChatTypes[i];
Save();
_chatChannelSearchText = string.Empty;
ImGui.CloseCurrentPopup();
}
if (flag)
{
ImGui.SetItemDefaultFocus();
}
}
}
}
}
ImGui.EndCombo();
}
else
{
_chatChannelComboJustOpened = false;
}
}
}