formatting
This commit is contained in:
+43
-43
@@ -38,78 +38,80 @@ public class FontManager
|
||||
_gameSymFont = new FaceData(gameSym);
|
||||
}
|
||||
|
||||
private byte[] GetResource(string name) {
|
||||
private byte[] GetResource(string name)
|
||||
{
|
||||
var stream = GetType().Assembly.GetManifestResourceStream(name)!;
|
||||
var memory = new MemoryStream();
|
||||
stream.CopyTo(memory);
|
||||
return memory.ToArray();
|
||||
}
|
||||
|
||||
private unsafe void SetUpRanges() {
|
||||
ushort[] BuildRange(IReadOnlyList<ushort>? chars, params IntPtr[] ranges) {
|
||||
private unsafe void SetUpRanges()
|
||||
{
|
||||
ushort[] BuildRange(IReadOnlyList<ushort>? chars, params IntPtr[] ranges)
|
||||
{
|
||||
var builder = new ImFontGlyphRangesBuilderPtr(ImGuiNative.ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder());
|
||||
// text
|
||||
foreach (var range in ranges) {
|
||||
foreach (var range in ranges)
|
||||
builder.AddRanges(range);
|
||||
}
|
||||
|
||||
// chars
|
||||
if (chars != null) {
|
||||
for (var i = 0; i < chars.Count; i += 2) {
|
||||
if (chars[i] == 0) {
|
||||
if (chars != null)
|
||||
{
|
||||
for (var i = 0; i < chars.Count; i += 2)
|
||||
{
|
||||
if (chars[i] == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
for (var j = (uint) chars[i]; j <= chars[i + 1]; j++) {
|
||||
for (var j = (uint) chars[i]; j <= chars[i + 1]; j++)
|
||||
builder.AddChar((ushort) j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// various symbols
|
||||
builder.AddText("←→↑↓《》■※☀★★☆♥♡ヅツッシ☀☁☂℃℉°♀♂♠♣♦♣♧®©™€$£♯♭♪✓√◎◆◇♦■□〇●△▽▼▲‹›≤≥<«“”─\~");
|
||||
// French
|
||||
builder.AddText("Œœ");
|
||||
// Romanian
|
||||
builder.AddText("←→↑↓《》■※☀★★☆♥♡ヅツッシ☀☁☂℃℉°♀♂♠♣♦♣♧®©™€$£♯♭♪✓√◎◆◇♦■□〇●△▽▼▲‹›≤≥<«“”─\~");
|
||||
builder.AddText("Œœ");
|
||||
builder.AddText("ĂăÂâÎîȘșȚț");
|
||||
|
||||
// "Enclosed Alphanumerics" (partial) https://www.compart.com/en/unicode/block/U+2460
|
||||
for (var i = 0x2460; i <= 0x24B5; i++) {
|
||||
for (var i = 0x2460; i <= 0x24B5; i++)
|
||||
builder.AddChar((char) i);
|
||||
}
|
||||
|
||||
builder.AddChar('⓪');
|
||||
return builder.BuildRangesToArray();
|
||||
}
|
||||
|
||||
var ranges = new List<IntPtr> {
|
||||
ImGui.GetIO().Fonts.GetGlyphRangesDefault(),
|
||||
};
|
||||
|
||||
foreach (var extraRange in Enum.GetValues<ExtraGlyphRanges>()) {
|
||||
if (Plugin.Config.ExtraGlyphRanges.HasFlag(extraRange)) {
|
||||
var ranges = new List<IntPtr> { ImGui.GetIO().Fonts.GetGlyphRangesDefault() };
|
||||
foreach (var extraRange in Enum.GetValues<ExtraGlyphRanges>())
|
||||
if (Plugin.Config.ExtraGlyphRanges.HasFlag(extraRange))
|
||||
ranges.Add(extraRange.Range());
|
||||
}
|
||||
}
|
||||
|
||||
_ranges = BuildRange(null, ranges.ToArray());
|
||||
_jpRange = BuildRange(GlyphRangesJapanese.GlyphRanges);
|
||||
}
|
||||
|
||||
private void SetUpUserFonts() {
|
||||
private void SetUpUserFonts()
|
||||
{
|
||||
FontData? fontData = null;
|
||||
if (Plugin.Config.GlobalFont.StartsWith(Fonts.IncludedIndicator)) {
|
||||
if (Plugin.Config.GlobalFont.StartsWith(Fonts.IncludedIndicator))
|
||||
{
|
||||
var globalFont = Fonts.GlobalFonts.FirstOrDefault(font => font.Name == Plugin.Config.GlobalFont);
|
||||
if (globalFont != null) {
|
||||
if (globalFont != null)
|
||||
{
|
||||
var regular = new FaceData(GetResource(globalFont.ResourcePath));
|
||||
var italic = new FaceData(GetResource(globalFont.ResourcePathItalic));
|
||||
fontData = new FontData(regular, italic);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
fontData = Fonts.GetFont(Plugin.Config.GlobalFont, true);
|
||||
}
|
||||
|
||||
if (fontData == null) {
|
||||
if (fontData == null)
|
||||
{
|
||||
Plugin.Config.GlobalFont = Fonts.GlobalFonts[0].Name;
|
||||
Plugin.SaveConfig();
|
||||
|
||||
@@ -123,33 +125,31 @@ public class FontManager
|
||||
_italicFont = fontData.Italic ?? null;
|
||||
|
||||
FontData? jpFontData = null;
|
||||
if (Plugin.Config.JapaneseFont.StartsWith(Fonts.IncludedIndicator)) {
|
||||
if (Plugin.Config.JapaneseFont.StartsWith(Fonts.IncludedIndicator))
|
||||
{
|
||||
var jpFont = Fonts.JapaneseFonts.FirstOrDefault(item => item.Item1 == Plugin.Config.JapaneseFont);
|
||||
if (jpFont != default) {
|
||||
jpFontData = new FontData(
|
||||
new FaceData(GetResource(jpFont.Item2)),
|
||||
null
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (jpFont != default)
|
||||
jpFontData = new FontData(new FaceData(GetResource(jpFont.Item2)), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
jpFontData = Fonts.GetFont(Plugin.Config.JapaneseFont, false);
|
||||
}
|
||||
|
||||
if (jpFontData == null) {
|
||||
if (jpFontData == null)
|
||||
{
|
||||
Plugin.Config.JapaneseFont = Fonts.JapaneseFonts[0].Item1;
|
||||
Plugin.SaveConfig();
|
||||
|
||||
var jpFont = Fonts.JapaneseFonts[0];
|
||||
jpFontData = new FontData(
|
||||
new FaceData(GetResource(jpFont.Item2)),
|
||||
null
|
||||
);
|
||||
jpFontData = new FontData(new FaceData(GetResource(jpFont.Item2)), null);
|
||||
}
|
||||
|
||||
_jpFont = jpFontData.Regular;
|
||||
}
|
||||
|
||||
public void BuildFonts() {
|
||||
public void BuildFonts()
|
||||
{
|
||||
SetUpRanges();
|
||||
SetUpUserFonts();
|
||||
|
||||
@@ -202,4 +202,4 @@ public class FontManager
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-7
@@ -5,16 +5,18 @@ using Dalamud.Plugin.Ipc;
|
||||
|
||||
namespace ChatTwo;
|
||||
|
||||
internal sealed class IpcManager : IDisposable {
|
||||
internal sealed class IpcManager : IDisposable
|
||||
{
|
||||
private DalamudPluginInterface Interface { get; }
|
||||
private ICallGateProvider<string> RegisterGate { get; }
|
||||
private ICallGateProvider<string, object?> UnregisterGate { get; }
|
||||
private ICallGateProvider<object?> AvailableGate { get; }
|
||||
private ICallGateProvider<string, PlayerPayload?, ulong, Payload?, SeString?, SeString?, object?> InvokeGate { get; }
|
||||
|
||||
internal List<string> Registered { get; } = new();
|
||||
internal List<string> Registered { get; } = [];
|
||||
|
||||
public IpcManager(DalamudPluginInterface pluginInterface) {
|
||||
public IpcManager(DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
Interface = pluginInterface;
|
||||
|
||||
RegisterGate = Interface.GetIpcProvider<string>("ChatTwo.Register");
|
||||
@@ -30,21 +32,25 @@ internal sealed class IpcManager : IDisposable {
|
||||
AvailableGate.SendMessage();
|
||||
}
|
||||
|
||||
internal void Invoke(string id, PlayerPayload? sender, ulong contentId, Payload? payload, SeString? senderString, SeString? content) {
|
||||
internal void Invoke(string id, PlayerPayload? sender, ulong contentId, Payload? payload, SeString? senderString, SeString? content)
|
||||
{
|
||||
InvokeGate.SendMessage(id, sender, contentId, payload, senderString, content);
|
||||
}
|
||||
|
||||
private string Register() {
|
||||
private string Register()
|
||||
{
|
||||
var id = Guid.NewGuid().ToString();
|
||||
Registered.Add(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
private void Unregister(string id) {
|
||||
private void Unregister(string id)
|
||||
{
|
||||
Registered.Remove(id);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
public void Dispose()
|
||||
{
|
||||
UnregisterGate.UnregisterFunc();
|
||||
RegisterGate.UnregisterFunc();
|
||||
Registered.Clear();
|
||||
|
||||
Reference in New Issue
Block a user