Merge pull request #8
fix: avoid double-up player names in screenshot mode, censor tell target
This commit is contained in:
@@ -472,6 +472,10 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
|||||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
||||||
try {
|
try {
|
||||||
if (_tellTarget != null) {
|
if (_tellTarget != null) {
|
||||||
|
var playerName = _tellTarget.Name;
|
||||||
|
if (ScreenshotMode)
|
||||||
|
playerName = HashPlayer(_tellTarget.Name, _tellTarget.World);
|
||||||
|
|
||||||
var world = Plugin.DataManager.GetExcelSheet<World>()
|
var world = Plugin.DataManager.GetExcelSheet<World>()
|
||||||
?.GetRow(_tellTarget.World)
|
?.GetRow(_tellTarget.World)
|
||||||
?.Name
|
?.Name
|
||||||
@@ -479,7 +483,7 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
|||||||
|
|
||||||
DrawChunks(new Chunk[] {
|
DrawChunks(new Chunk[] {
|
||||||
new TextChunk(ChunkSource.None, null, "Tell "),
|
new TextChunk(ChunkSource.None, null, "Tell "),
|
||||||
new TextChunk(ChunkSource.None, null, _tellTarget.Name),
|
new TextChunk(ChunkSource.None, null, playerName),
|
||||||
new IconChunk(ChunkSource.None, null, BitmapFontIcon.CrossWorld),
|
new IconChunk(ChunkSource.None, null, BitmapFontIcon.CrossWorld),
|
||||||
new TextChunk(ChunkSource.None, null, world),
|
new TextChunk(ChunkSource.None, null, world),
|
||||||
});
|
});
|
||||||
@@ -1423,12 +1427,13 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
|||||||
|
|
||||||
var content = text.Content;
|
var content = text.Content;
|
||||||
if (ScreenshotMode) {
|
if (ScreenshotMode) {
|
||||||
if (chunk.Link is PlayerPayload playerPayload) {
|
// Check for contains here as sometimes there are multiple
|
||||||
var hashCode = $"{Salt}{playerPayload.PlayerName}{playerPayload.World.RowId}".GetHashCode();
|
// TextChunks with the same PlayerPayload but only one has the name.
|
||||||
content = $"Player {hashCode:X8}";
|
// E.g. party chat with cross world players adds extra chunks.
|
||||||
|
if (chunk.Link is PlayerPayload playerPayload && content.Contains(playerPayload.PlayerName)) {
|
||||||
|
content = content.Replace(playerPayload.PlayerName, HashPlayer(playerPayload.PlayerName, playerPayload.World.RowId));
|
||||||
} else if (Plugin.ClientState.LocalPlayer is { } player && content.Contains(player.Name.TextValue)) {
|
} else if (Plugin.ClientState.LocalPlayer is { } player && content.Contains(player.Name.TextValue)) {
|
||||||
var hashCode = $"{Salt}{player.Name.TextValue}{player.HomeWorld.Id}".GetHashCode();
|
content = content.Replace(player.Name.TextValue, HashPlayer(player.Name.TextValue, player.HomeWorld.Id));
|
||||||
content = content.Replace(player.Name.TextValue, $"Player {hashCode:X8}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1447,4 +1452,9 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
|||||||
ImGui.PopStyleColor();
|
ImGui.PopStyleColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string HashPlayer(string playerName, uint worldId) {
|
||||||
|
var hashCode = $"{Salt}{playerName}{worldId}".GetHashCode();
|
||||||
|
return $"Player {hashCode:X8}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user