feat: screenshot mode

This commit is contained in:
Anna 2022-01-06 17:25:45 -05:00
parent 590a802bfd
commit e21ce6aa12
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
3 changed files with 20 additions and 1 deletions

View File

@ -232,6 +232,10 @@ internal sealed class PayloadHandler {
this.Ui.Plugin.TargetManager.SetTarget(obj);
}
ImGui.Separator();
ImGui.Checkbox("Screenshot mode", ref this.Ui.ScreenshotMode);
// Add to Blacklist 0x1C
// View Party Finder 0x2E
// Reply in Selected Chat Mode 0x64

View File

@ -11,6 +11,8 @@ internal sealed class PluginUi : IDisposable {
internal Plugin Plugin { get; }
internal bool SettingsVisible;
internal bool ScreenshotMode;
internal string Salt { get; }
internal ImFontPtr? RegularFont { get; private set; }
internal ImFontPtr? ItalicFont { get; private set; }
@ -42,6 +44,7 @@ internal sealed class PluginUi : IDisposable {
internal unsafe PluginUi(Plugin plugin) {
this.Plugin = plugin;
this.Salt = new Random().Next().ToString();
this.Components = new List<IUiComponent> {
new Settings(this),
new ChatLog(this),

View File

@ -1,6 +1,7 @@
using System.Numerics;
using ChatTwo.Code;
using ChatTwo.Util;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface;
using ImGuiNET;
using ImGuiScene;
@ -402,7 +403,18 @@ internal sealed class ChatLog : IUiComponent {
ImGui.PushFont(this.Ui.ItalicFont.Value);
}
ImGuiUtil.WrapText(text.Content, chunk, handler);
var content = text.Content;
if (this.Ui.ScreenshotMode) {
if (chunk.Link is PlayerPayload playerPayload) {
var hashCode = $"{this.Ui.Salt}{playerPayload.PlayerName}{playerPayload.World.RowId}".GetHashCode();
content = $"Player {hashCode:X8}";
} else if (this.Ui.Plugin.ClientState.LocalPlayer is { } player && content.Contains(player.Name.TextValue)) {
var hashCode = $"{this.Ui.Salt}{player.Name.TextValue}{player.HomeWorld.Id}".GetHashCode();
content = content.Replace(player.Name.TextValue, $"Player {hashCode:X8}");
}
}
ImGuiUtil.WrapText(content, chunk, handler);
if (text.Italic && this.Ui.ItalicFont.HasValue) {
ImGui.PopFont();