Miscellaneous improvements (#1537)

This commit is contained in:
srkizer 2023-11-27 06:58:26 +09:00 committed by GitHub
parent a6ea4aa56a
commit 7a0de45f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1136 additions and 279 deletions

View file

@ -28,8 +28,14 @@ public class AddonLifecycleWidget : IDataWindowWidget
/// <inheritdoc/>
public void Load()
{
this.AddonLifecycle = Service<AddonLifecycle>.GetNullable();
if (this.AddonLifecycle is not null) this.Ready = true;
Service<AddonLifecycle>
.GetAsync()
.ContinueWith(
r =>
{
this.AddonLifecycle = r.Result;
this.Ready = true;
});
}
/// <inheritdoc/>

View file

@ -38,12 +38,30 @@ internal class FontAwesomeTestWidget : IDataWindowWidget
public void Draw()
{
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
this.iconCategories ??= FontAwesomeHelpers.GetCategories();
this.iconCategories ??= new[] { "(Show All)", "(Undefined)" }
.Concat(FontAwesomeHelpers.GetCategories().Skip(1))
.ToArray();
if (this.iconSearchChanged)
{
this.icons = FontAwesomeHelpers.SearchIcons(this.iconSearchInput, this.iconCategories[this.selectedIconCategory]);
if (this.iconSearchInput == string.Empty && this.selectedIconCategory <= 1)
{
var en = InterfaceManager.IconFont.GlyphsWrapped()
.Select(x => (FontAwesomeIcon)x.Codepoint)
.Where(x => (ushort)x is >= 0xE000 and < 0xF000);
en = this.selectedIconCategory == 0
? en.Concat(FontAwesomeHelpers.SearchIcons(string.Empty, string.Empty))
: en.Except(FontAwesomeHelpers.SearchIcons(string.Empty, string.Empty));
this.icons = en.Distinct().Order().ToList();
}
else
{
this.icons = FontAwesomeHelpers.SearchIcons(
this.iconSearchInput,
this.selectedIconCategory <= 1 ? string.Empty : this.iconCategories[this.selectedIconCategory]);
}
this.iconNames = this.icons.Select(icon => Enum.GetName(icon)!).ToList();
this.iconSearchChanged = false;
}