forked from aly/qstbak
muffin v7.4.6
This commit is contained in:
parent
bb09805213
commit
1cc65e495d
13 changed files with 1291 additions and 949 deletions
|
|
@ -1,7 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Questionable.Controller;
|
||||
using Questionable.Model;
|
||||
using Questionable.Model.Questing;
|
||||
|
|
@ -12,6 +14,8 @@ internal sealed class QuestSelector(QuestRegistry questRegistry)
|
|||
{
|
||||
private string _searchString = string.Empty;
|
||||
|
||||
private bool _comboJustOpened;
|
||||
|
||||
public Predicate<Quest>? SuggestionPredicate { private get; set; }
|
||||
|
||||
public Predicate<Quest>? DefaultPredicate { private get; set; }
|
||||
|
|
@ -27,12 +31,18 @@ internal sealed class QuestSelector(QuestRegistry questRegistry)
|
|||
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
|
||||
if (ImGui.BeginCombo("##QuestSelection", "Add Quest...", ImGuiComboFlags.HeightLarge))
|
||||
{
|
||||
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
|
||||
bool flag = ImGui.InputTextWithHint("", "Filter...", ref _searchString, 256, ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
if (!_comboJustOpened)
|
||||
{
|
||||
ImGui.SetKeyboardFocusHere();
|
||||
_comboJustOpened = true;
|
||||
}
|
||||
ImGui.SetNextItemWidth(-1f);
|
||||
bool flag = ImGui.InputTextWithHint("##QuestSearch", "Search quests...", ref _searchString, 256, ImGuiInputTextFlags.AutoSelectAll | ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
ImGui.Separator();
|
||||
IEnumerable<Quest> enumerable;
|
||||
if (!string.IsNullOrEmpty(_searchString))
|
||||
{
|
||||
enumerable = Enumerable.Where(predicate: (!ElementId.TryFromString(_searchString, out ElementId elementId)) ? new Func<Quest, bool>(DefaultPredicate) : ((Func<Quest, bool>)((Quest x) => DefaultPredicate(x) || x.Id == elementId)), source: questRegistry.AllQuests.Where(delegate(Quest x)
|
||||
enumerable = Enumerable.Where(predicate: (!ElementId.TryFromString(_searchString, out ElementId elementId)) ? new Func<Quest, bool>(SearchPredicate) : ((Func<Quest, bool>)((Quest x) => SearchPredicate(x) || x.Id == elementId)), source: questRegistry.AllQuests.Where(delegate(Quest x)
|
||||
{
|
||||
ElementId id = x.Id;
|
||||
return !(id is SatisfactionSupplyNpcId) && !(id is AlliedSocietyDailyId);
|
||||
|
|
@ -40,24 +50,35 @@ internal sealed class QuestSelector(QuestRegistry questRegistry)
|
|||
}
|
||||
else
|
||||
{
|
||||
enumerable = questRegistry.AllQuests.Where((Quest x) => this.DefaultPredicate?.Invoke(x) ?? true);
|
||||
enumerable = questRegistry.AllQuests.Where((Quest x) => DefaultPredicate?.Invoke(x) ?? true);
|
||||
}
|
||||
foreach (Quest item in enumerable)
|
||||
using (ImRaii.IEndObject endObject = ImRaii.Child("##QuestScrollArea", new Vector2(0f, 300f), border: false))
|
||||
{
|
||||
if ((SuggestionPredicate == null || SuggestionPredicate(item)) && (ImGui.Selectable(item.Info.Name) || flag))
|
||||
if (endObject)
|
||||
{
|
||||
QuestSelected(item);
|
||||
if (flag)
|
||||
foreach (Quest item in enumerable)
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
flag = false;
|
||||
if ((SuggestionPredicate == null || SuggestionPredicate(item)) && (ImGui.Selectable(item.Info.Name) || flag))
|
||||
{
|
||||
QuestSelected(item);
|
||||
_searchString = string.Empty;
|
||||
if (flag)
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
else
|
||||
{
|
||||
_comboJustOpened = false;
|
||||
}
|
||||
ImGui.Spacing();
|
||||
bool DefaultPredicate(Quest x)
|
||||
bool SearchPredicate(Quest x)
|
||||
{
|
||||
return x.Info.Name.Contains(_searchString, StringComparison.CurrentCultureIgnoreCase);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue