- Handle NBSP payloads

- Use ingame version of axis font
This commit is contained in:
Infi
2024-11-21 08:34:24 +01:00
parent 56eff572b7
commit 1a1995759a
14 changed files with 60 additions and 95 deletions
+4 -4
View File
@@ -877,7 +877,7 @@ public sealed class ChatLogWindow : Window
// registers stub handlers and actually processes its commands in a
// SendMessage detour.
var bytes = Encoding.UTF8.GetBytes(channel.Value.Prefix());
Plugin.Common.SendMessageUnsafe(bytes);
ChatBox.SendMessageUnsafe(bytes);
return;
}
@@ -921,7 +921,7 @@ public sealed class ChatLogWindow : Window
var tellBytes = Encoding.UTF8.GetBytes(trimmed);
AutoTranslate.ReplaceWithPayload(ref tellBytes);
Plugin.Common.SendMessageUnsafe(tellBytes);
ChatBox.SendMessageUnsafe(tellBytes);
Chat = string.Empty;
return;
@@ -949,14 +949,14 @@ public sealed class ChatLogWindow : Window
if (activeTab.CurrentChannel.UseTempChannel)
trimmed = $"{activeTab.CurrentChannel.TempChannel.Prefix()} {trimmed}";
else // (activeTab is { Channel: { } channel }) TODO Check this channel selection
else
trimmed = $"{activeTab.CurrentChannel.Channel.Prefix()} {trimmed}";
}
var bytes = Encoding.UTF8.GetBytes(trimmed);
AutoTranslate.ReplaceWithPayload(ref bytes);
Plugin.Common.SendMessageUnsafe(bytes);
ChatBox.SendMessageUnsafe(bytes);
}
Chat = string.Empty;
-1
View File
@@ -1,6 +1,5 @@
using System.Numerics;
using Dalamud.Interface.Windowing;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using ImGuiNET;
+17 -32
View File
@@ -1,12 +1,13 @@
using System.Numerics;
using System.Globalization;
using System.Numerics;
using System.Text;
using ChatTwo.Util;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using DalamudPartyFinderPayload = Dalamud.Game.Text.SeStringHandling.Payloads.PartyFinderPayload;
namespace ChatTwo.Ui;
@@ -15,7 +16,7 @@ public class SeStringDebugger : Window
{
private readonly Plugin Plugin;
public SeStringDebugger(Plugin plugin) : base($"SeString Debugger###chat2-sestringdebugger")
public SeStringDebugger(Plugin plugin) : base("SeString Debugger###chat2-sestringdebugger")
{
Plugin = plugin;
@@ -92,8 +93,8 @@ public class SeStringDebugger : Window
{ "TerritoryType.RowId", map.TerritoryType.RowId.ToString() },
{ "RawX", map.RawX.ToString() },
{ "RawY", map.RawY.ToString() },
{ "XCoord", map.XCoord.ToString() },
{ "YCoord", map.YCoord.ToString() },
{ "XCoord", map.XCoord.ToString(CultureInfo.InvariantCulture) },
{ "YCoord", map.YCoord.ToString(CultureInfo.InvariantCulture) },
{ "CoordinateString", map.CoordinateString },
{ "DataString", map.DataString },
});
@@ -160,7 +161,7 @@ public class SeStringDebugger : Window
}
case IconPayload icon:
{
var found = IconUtil.GfdFileView.TryGetEntry((uint) icon.Icon, out var entry);
var found = IconUtil.GfdFileView.TryGetEntry((uint) icon.Icon, out _);
RenderMetadataDictionary("Link IconPayload", new Dictionary<string, string?>
{
{ "Found", found.ToString() },
@@ -173,15 +174,12 @@ public class SeStringDebugger : Window
var colorPayload = ColorPayload.From(raw.Data);
if (colorPayload != null)
{
var push = colorPayload.Enabled && colorPayload.Color != 0;
// if (push) ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(colorPayload.U));
RenderMetadataDictionary("Link ColorPayload", new Dictionary<string, string?>
{
{ "Unshifted", colorPayload.UnshiftedColor.ToString("X8") },
{ "Color", colorPayload.Color.ToString("X8") },
{ "Enabled?", colorPayload.Enabled.ToString() },
});
// if (push) ImGui.PopStyleColor();
}
else
{
@@ -289,10 +287,8 @@ public class SeStringDebugger : Window
{
if (string.IsNullOrEmpty(original))
{
var str = original == null ? "(null)" : "(empty)";
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
ImGui.TextUnformatted(str);
ImGui.PopStyleColor();
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
ImGui.TextUnformatted(original == null ? "(null)" : "(empty)");
return;
}
@@ -300,46 +296,35 @@ public class SeStringDebugger : Window
var start = 0;
var end = text.Length;
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
using var pushedStyle = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
void WriteText(string text)
void WriteText(string wText)
{
if (wrap)
{
ImGui.TextWrapped(text);
}
ImGui.TextWrapped(wText);
else
{
ImGui.TextUnformatted(text);
}
ImGui.TextUnformatted(wText);
}
while (start < end && char.IsWhiteSpace(text[start]))
{
start++;
}
if (start > 0)
{
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
WriteText(new string('_', start));
ImGui.PopStyleColor();
ImGui.SameLine();
}
while (end > start && char.IsWhiteSpace(text[end - 1]))
{
end--;
}
WriteText(text[start..end]);
if (end < text.Length)
{
ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, new Vector4(1, 1, 1, 0.5f));
WriteText(new string('_', text.Length - end));
ImGui.PopStyleColor();
}
ImGui.PopStyleVar();
}
}
+6 -6
View File
@@ -31,21 +31,21 @@ public sealed class SettingsWindow : Window
Plugin = plugin;
Mutable = new Configuration();
Tabs = new List<ISettingsTab>
{
Tabs =
[
new Display(Mutable),
new ChatLog(Plugin, Mutable),
new Emote(Plugin, Mutable),
new Preview(Plugin, Mutable),
new Preview(Mutable),
new Fonts(Mutable),
new ChatColours(Plugin, Mutable),
new Tabs(Plugin, Mutable),
new Tabs(Mutable),
new Database(Plugin, Mutable),
new Webinterface(Plugin, Mutable),
new Miscellaneous(Mutable),
new Changelog(Mutable),
new About(),
};
new About()
];
RespectCloseHotkey = false;
DisableWindowSounds = true;
+3 -5
View File
@@ -13,7 +13,7 @@ internal sealed class About : ISettingsTab
{
public string Name => string.Format(Language.Options_About_Tab, Plugin.PluginName) + "###tabs-about";
private readonly List<string> _translators =
private readonly List<string> Translators =
[
"q673135110", "Akizem", "d0tiKs",
"Moonlight_Everlit", "Dark32", "andreycout",
@@ -28,7 +28,7 @@ internal sealed class About : ISettingsTab
internal About()
{
_translators.Sort((a, b) => string.Compare(a.ToLowerInvariant(), b.ToLowerInvariant(), StringComparison.Ordinal));
Translators.Sort((a, b) => string.Compare(a.ToLowerInvariant(), b.ToLowerInvariant(), StringComparison.Ordinal));
}
public void Draw(bool changed)
@@ -85,10 +85,8 @@ internal sealed class About : ISettingsTab
using var translatorChild = ImRaii.Child("translators");
if (translatorChild)
{
foreach (var translator in _translators)
{
foreach (var translator in Translators)
ImGui.TextUnformatted(translator);
}
}
}
}
+2 -4
View File
@@ -6,14 +6,12 @@ namespace ChatTwo.Ui.SettingsTabs;
internal sealed class Preview : ISettingsTab
{
private readonly Plugin Plugin;
private Configuration Mutable { get; }
public string Name => Language.Options_Preview_Tab + "###tabs-preview";
public string Name => $"{Language.Options_Preview_Tab}###tabs-preview";
internal Preview(Plugin plugin, Configuration mutable)
internal Preview(Configuration mutable)
{
Plugin = plugin;
Mutable = mutable;
}
+8 -10
View File
@@ -9,16 +9,14 @@ namespace ChatTwo.Ui.SettingsTabs;
internal sealed class Tabs : ISettingsTab
{
private Plugin Plugin { get; }
private Configuration Mutable { get; }
public string Name => Language.Options_Tabs_Tab + "###tabs-tabs";
private int _toOpen = -2;
private int ToOpen = -2;
internal Tabs(Plugin plugin, Configuration mutable)
internal Tabs(Configuration mutable)
{
Plugin = plugin;
Mutable = mutable;
}
@@ -47,13 +45,13 @@ internal sealed class Tabs : ISettingsTab
}
var toRemove = -1;
var doOpens = _toOpen > -2;
var doOpens = ToOpen > -2;
for (var i = 0; i < Mutable.Tabs.Count; i++)
{
var tab = Mutable.Tabs[i];
if (doOpens)
ImGui.SetNextItemOpen(i == _toOpen);
ImGui.SetNextItemOpen(i == ToOpen);
using var treeNode = ImRaii.TreeNode($"{tab.Name}###tab-{i}");
if (!treeNode.Success)
@@ -64,7 +62,7 @@ internal sealed class Tabs : ISettingsTab
if (ImGuiUtil.IconButton(FontAwesomeIcon.TrashAlt, tooltip: Language.Options_Tabs_Delete))
{
toRemove = i;
_toOpen = -1;
ToOpen = -1;
}
ImGui.SameLine();
@@ -72,7 +70,7 @@ internal sealed class Tabs : ISettingsTab
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowUp, tooltip: Language.Options_Tabs_MoveUp) && i > 0)
{
(Mutable.Tabs[i - 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i - 1]);
_toOpen = i - 1;
ToOpen = i - 1;
}
ImGui.SameLine();
@@ -80,7 +78,7 @@ internal sealed class Tabs : ISettingsTab
if (ImGuiUtil.IconButton(FontAwesomeIcon.ArrowDown, tooltip: Language.Options_Tabs_MoveDown) && i < Mutable.Tabs.Count - 1)
{
(Mutable.Tabs[i + 1], Mutable.Tabs[i]) = (Mutable.Tabs[i], Mutable.Tabs[i + 1]);
_toOpen = i + 1;
ToOpen = i + 1;
}
ImGui.InputText(Language.Options_Tabs_Name, ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue);
@@ -135,6 +133,6 @@ internal sealed class Tabs : ISettingsTab
Mutable.Tabs.RemoveAt(toRemove);
if (doOpens)
_toOpen = -2;
ToOpen = -2;
}
}