mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge pull request #1131 from kalilistic/fa6
This commit is contained in:
commit
103333252e
11 changed files with 12944 additions and 7087 deletions
3
Dalamud/Dalamud.csproj.DotSettings
Normal file
3
Dalamud/Dalamud.csproj.DotSettings
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=interface_005Cfontawesome/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Int64 x:Key="/Default/PerformanceThreshold/AnalysisFileSizeThreshold/=CSHARP/@EntryIndexedValue">300000</s:Int64>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
|
||||
namespace Dalamud.Interface;
|
||||
|
||||
/// <summary>
|
||||
/// Set categories associated with a font awesome icon.
|
||||
/// </summary>
|
||||
public class FontAwesomeCategoriesAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FontAwesomeCategoriesAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="categories">categories for enum member.</param>
|
||||
public FontAwesomeCategoriesAttribute(string[] categories) => this.Categories = categories;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets categories.
|
||||
/// </summary>
|
||||
public string[] Categories { get; set; }
|
||||
}
|
||||
53
Dalamud/Interface/FontAwesome/FontAwesomeExtensions.cs
Normal file
53
Dalamud/Interface/FontAwesome/FontAwesomeExtensions.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using Dalamud.Utility;
|
||||
|
||||
namespace Dalamud.Interface;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="FontAwesomeIcon"/>.
|
||||
/// </summary>
|
||||
public static class FontAwesomeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert the FontAwesomeIcon to a <see cref="char"/> type.
|
||||
/// </summary>
|
||||
/// <param name="icon">The icon to convert.</param>
|
||||
/// <returns>The converted icon.</returns>
|
||||
public static char ToIconChar(this FontAwesomeIcon icon)
|
||||
{
|
||||
return (char)icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the FontAwesomeIcon to a <see cref="string"/> type.
|
||||
/// </summary>
|
||||
/// <param name="icon">The icon to convert.</param>
|
||||
/// <returns>The converted icon.</returns>
|
||||
public static string ToIconString(this FontAwesomeIcon icon)
|
||||
{
|
||||
return string.Empty + (char)icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get FontAwesome search terms.
|
||||
/// </summary>
|
||||
/// <param name="icon">The icon to pull search terms from.</param>
|
||||
/// <returns>string array of search terms or empty array if none.</returns>
|
||||
public static IEnumerable<string> GetSearchTerms(this FontAwesomeIcon icon)
|
||||
{
|
||||
var searchTermsAttribute = icon.GetAttribute<FontAwesomeSearchTermsAttribute>();
|
||||
return searchTermsAttribute == null ? new string[] { } : searchTermsAttribute.SearchTerms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get FontAwesome categories.
|
||||
/// </summary>
|
||||
/// <param name="icon">The icon to pull categories from.</param>
|
||||
/// <returns>string array of categories or empty array if none.</returns>
|
||||
public static IEnumerable<string> GetCategories(this FontAwesomeIcon icon)
|
||||
{
|
||||
var categoriesAttribute = icon.GetAttribute<FontAwesomeCategoriesAttribute>();
|
||||
return categoriesAttribute == null ? new string[] { } : categoriesAttribute.Categories;
|
||||
}
|
||||
}
|
||||
117
Dalamud/Interface/FontAwesome/FontAwesomeHelpers.cs
Normal file
117
Dalamud/Interface/FontAwesome/FontAwesomeHelpers.cs
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Dalamud.Utility;
|
||||
|
||||
namespace Dalamud.Interface;
|
||||
|
||||
/// <summary>
|
||||
/// Class containing various helper methods for use with Font Awesome inside Dalamud.
|
||||
/// </summary>
|
||||
public static class FontAwesomeHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Get all non-obsolete icons.
|
||||
/// </summary>
|
||||
/// <returns>list of font awesome icons.</returns>
|
||||
public static List<FontAwesomeIcon> GetIcons()
|
||||
{
|
||||
var icons = new List<FontAwesomeIcon>();
|
||||
foreach (var icon in Enum.GetValues(typeof(FontAwesomeIcon)).Cast<FontAwesomeIcon>().ToList())
|
||||
{
|
||||
if (icon.IsObsolete()) continue;
|
||||
icons.Add(icon);
|
||||
}
|
||||
|
||||
return icons;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all categories available on non-obsolete icons.
|
||||
/// </summary>
|
||||
/// <returns>list of font awesome icons.</returns>
|
||||
public static string[] GetCategories()
|
||||
{
|
||||
var icons = GetIcons();
|
||||
var result = new List<string>();
|
||||
foreach (var icon in icons)
|
||||
{
|
||||
var categories = icon.GetCategories();
|
||||
foreach (var category in categories)
|
||||
{
|
||||
if (!result.Contains(category))
|
||||
{
|
||||
result.Add(category);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.Sort();
|
||||
result.Insert(0, string.Empty);
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get icons by search term.
|
||||
/// </summary>
|
||||
/// <param name="search">search term string.</param>
|
||||
/// <param name="category">name of category to filter by.</param>
|
||||
/// <returns>list array of font awesome icons matching search term.</returns>
|
||||
public static List<FontAwesomeIcon> SearchIcons(string search, string category)
|
||||
{
|
||||
var icons = GetIcons();
|
||||
var result = new List<FontAwesomeIcon>();
|
||||
|
||||
// if no filters
|
||||
if (string.IsNullOrEmpty(search) && string.IsNullOrEmpty(category))
|
||||
{
|
||||
return icons;
|
||||
}
|
||||
|
||||
// if search with only search term
|
||||
if (!string.IsNullOrEmpty(search) && string.IsNullOrEmpty(category))
|
||||
{
|
||||
foreach (var icon in icons)
|
||||
{
|
||||
var name = Enum.GetName(icon)?.ToLower();
|
||||
var searchTerms = icon.GetSearchTerms();
|
||||
if (name!.Contains(search.ToLower()) || searchTerms.Contains(search.ToLower()))
|
||||
{
|
||||
result.Add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// if search with only category
|
||||
if (string.IsNullOrEmpty(search) && !string.IsNullOrEmpty(category))
|
||||
{
|
||||
foreach (var icon in icons)
|
||||
{
|
||||
var categories = icon.GetCategories();
|
||||
if (categories.Contains(category))
|
||||
{
|
||||
result.Add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// search by both terms and category
|
||||
foreach (var icon in icons)
|
||||
{
|
||||
var name = Enum.GetName(icon)?.ToLower();
|
||||
var searchTerms = icon.GetSearchTerms();
|
||||
var categories = icon.GetCategories();
|
||||
if ((name!.Contains(search.ToLower()) || searchTerms.Contains(search.ToLower())) && categories.Contains(category))
|
||||
{
|
||||
result.Add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
12669
Dalamud/Interface/FontAwesome/FontAwesomeIcon.cs
Normal file
12669
Dalamud/Interface/FontAwesome/FontAwesomeIcon.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
|
||||
namespace Dalamud.Interface;
|
||||
|
||||
/// <summary>
|
||||
/// Set search terms associated with a font awesome icon.
|
||||
/// </summary>
|
||||
public class FontAwesomeSearchTermsAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FontAwesomeSearchTermsAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="searchTerms">search terms for enum member.</param>
|
||||
public FontAwesomeSearchTermsAttribute(string[] searchTerms) => this.SearchTerms = searchTerms;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets search terms.
|
||||
/// </summary>
|
||||
public string[] SearchTerms { get; set; }
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
// Font-Awesome - Version 5.0.9
|
||||
|
||||
namespace Dalamud.Interface;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="FontAwesomeIcon"/>.
|
||||
/// </summary>
|
||||
public static class FontAwesomeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert the FontAwesomeIcon to a <see cref="char"/> type.
|
||||
/// </summary>
|
||||
/// <param name="icon">The icon to convert.</param>
|
||||
/// <returns>The converted icon.</returns>
|
||||
public static char ToIconChar(this FontAwesomeIcon icon)
|
||||
{
|
||||
return (char)icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Conver the FontAwesomeIcon to a <see cref="string"/> type.
|
||||
/// </summary>
|
||||
/// <param name="icon">The icon to convert.</param>
|
||||
/// <returns>The converted icon.</returns>
|
||||
public static string ToIconString(this FontAwesomeIcon icon)
|
||||
{
|
||||
return string.Empty + (char)icon;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -733,7 +733,7 @@ internal class InterfaceManager : IDisposable, IServiceType
|
|||
// FontAwesome icon font
|
||||
Log.Verbose("[FONT] SetupFonts - FontAwesome icon font");
|
||||
{
|
||||
var fontPathIcon = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "FontAwesome5FreeSolid.otf");
|
||||
var fontPathIcon = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "FontAwesomeFreeSolid.otf");
|
||||
if (!File.Exists(fontPathIcon))
|
||||
ShowFontError(fontPathIcon);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,14 @@ internal class DataWindow : Window
|
|||
private Hook<MessageBoxWDelegate>? messageBoxMinHook;
|
||||
private bool hookUseMinHook = false;
|
||||
|
||||
// FontAwesome
|
||||
private List<FontAwesomeIcon>? icons;
|
||||
private List<string> iconNames;
|
||||
private string[]? iconCategories;
|
||||
private int selectedIconCategory;
|
||||
private string iconSearchInput = string.Empty;
|
||||
private bool iconSearchChanged = true;
|
||||
|
||||
// IPC
|
||||
private ICallGateProvider<string, string> ipcPub;
|
||||
private ICallGateSubscriber<string, string> ipcSub;
|
||||
|
|
@ -149,7 +157,8 @@ internal class DataWindow : Window
|
|||
Address,
|
||||
Object_Table,
|
||||
Fate_Table,
|
||||
Font_Test,
|
||||
SE_Font_Test,
|
||||
FontAwesome_Test,
|
||||
Party_List,
|
||||
Buddy_List,
|
||||
Plugin_IPC,
|
||||
|
|
@ -270,8 +279,12 @@ internal class DataWindow : Window
|
|||
this.DrawFateTable();
|
||||
break;
|
||||
|
||||
case DataKind.Font_Test:
|
||||
this.DrawFontTest();
|
||||
case DataKind.SE_Font_Test:
|
||||
this.DrawSEFontTest();
|
||||
break;
|
||||
|
||||
case DataKind.FontAwesome_Test:
|
||||
this.DrawFontAwesomeTest();
|
||||
break;
|
||||
|
||||
case DataKind.Party_List:
|
||||
|
|
@ -573,7 +586,7 @@ internal class DataWindow : Window
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawFontTest()
|
||||
private void DrawSEFontTest()
|
||||
{
|
||||
var specialChars = string.Empty;
|
||||
|
||||
|
|
@ -581,15 +594,45 @@ internal class DataWindow : Window
|
|||
specialChars += $"0x{i:X} - {(SeIconChar)i} - {(char)i}\n";
|
||||
|
||||
ImGui.TextUnformatted(specialChars);
|
||||
}
|
||||
|
||||
foreach (var fontAwesomeIcon in Enum.GetValues(typeof(FontAwesomeIcon)).Cast<FontAwesomeIcon>())
|
||||
private void DrawFontAwesomeTest()
|
||||
{
|
||||
ImGui.Text(((int)fontAwesomeIcon.ToIconChar()).ToString("X") + " - ");
|
||||
ImGui.SameLine();
|
||||
this.iconCategories ??= FontAwesomeHelpers.GetCategories();
|
||||
|
||||
if (this.iconSearchChanged)
|
||||
{
|
||||
this.icons = FontAwesomeHelpers.SearchIcons(this.iconSearchInput, this.iconCategories[this.selectedIconCategory]);
|
||||
this.iconNames = this.icons.Select(icon => Enum.GetName(icon)!).ToList();
|
||||
this.iconSearchChanged = false;
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth(160f);
|
||||
var categoryIndex = this.selectedIconCategory;
|
||||
if (ImGui.Combo("####FontAwesomeCategorySearch", ref categoryIndex, this.iconCategories, this.iconCategories.Length))
|
||||
{
|
||||
this.selectedIconCategory = categoryIndex;
|
||||
this.iconSearchChanged = true;
|
||||
}
|
||||
|
||||
ImGui.SameLine(170f);
|
||||
ImGui.SetNextItemWidth(180f);
|
||||
if (ImGui.InputTextWithHint($"###FontAwesomeInputSearch", "search icons", ref this.iconSearchInput, 50))
|
||||
{
|
||||
this.iconSearchChanged = true;
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(10f);
|
||||
for (var i = 0; i < this.icons?.Count; i++)
|
||||
{
|
||||
ImGui.Text($"0x{(int)this.icons[i].ToIconChar():X}");
|
||||
ImGuiHelpers.ScaledRelativeSameLine(50f);
|
||||
ImGui.Text($"{this.iconNames[i]}");
|
||||
ImGuiHelpers.ScaledRelativeSameLine(280f);
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.Text(fontAwesomeIcon.ToIconString());
|
||||
ImGui.Text(this.icons[i].ToIconString());
|
||||
ImGui.PopFont();
|
||||
ImGuiHelpers.ScaledDummy(2f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,4 +27,14 @@ public static class EnumExtensions
|
|||
.OfType<TAttribute>()
|
||||
.SingleOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an indicator if enum has been flagged as obsolete (deprecated).
|
||||
/// </summary>
|
||||
/// <param name="value">The enum value that has an attached attribute.</param>
|
||||
/// <returns>Indicator if enum has been flagged as obsolete.</returns>
|
||||
public static bool IsObsolete(this Enum value)
|
||||
{
|
||||
return GetAttribute<ObsoleteAttribute>(value) != null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue