build abbreviated own username in chat self
This commit is contained in:
74
PlayerTags/Configuration/GameConfig/GameConfigHelper.cs
Normal file
74
PlayerTags/Configuration/GameConfig/GameConfigHelper.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlayerTags.Configuration.GameConfig
|
||||
{
|
||||
public class GameConfigHelper
|
||||
{
|
||||
private static GameConfigHelper instance = null;
|
||||
private unsafe static ConfigModule* configModule = null;
|
||||
|
||||
public static GameConfigHelper Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
instance ??= new GameConfigHelper();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private GameConfigHelper()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
configModule = ConfigModule.Instance();
|
||||
}
|
||||
}
|
||||
|
||||
private int? GetIntValue(ConfigOption option)
|
||||
{
|
||||
int? value = null;
|
||||
|
||||
unsafe
|
||||
{
|
||||
var index = configModule->GetIndex(option);
|
||||
if (index.HasValue)
|
||||
value = configModule->GetIntValue(index.Value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public LogNameType? GetLogNameType()
|
||||
{
|
||||
LogNameType? logNameType = null;
|
||||
int? value = GetIntValue(ConfigOption.LogNameType);
|
||||
|
||||
if (value.HasValue)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
logNameType = LogNameType.FullName;
|
||||
break;
|
||||
case 1:
|
||||
logNameType = LogNameType.LastNameShorted;
|
||||
break;
|
||||
case 2:
|
||||
logNameType = LogNameType.FirstNameShorted;
|
||||
break;
|
||||
case 3:
|
||||
logNameType = LogNameType.Initials;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return logNameType;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
PlayerTags/Configuration/GameConfig/LogNameType.cs
Normal file
16
PlayerTags/Configuration/GameConfig/LogNameType.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlayerTags.Configuration.GameConfig
|
||||
{
|
||||
public enum LogNameType
|
||||
{
|
||||
FullName,
|
||||
LastNameShorted,
|
||||
FirstNameShorted,
|
||||
Initials
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,14 @@ using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using PlayerTags.Configuration;
|
||||
using PlayerTags.Configuration.GameConfig;
|
||||
using PlayerTags.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Action = System.Action;
|
||||
|
||||
@@ -179,6 +182,44 @@ namespace PlayerTags.Features
|
||||
return stringMatches;
|
||||
}
|
||||
|
||||
private string BuildPlayername(string name)
|
||||
{
|
||||
var logNameType = GameConfigHelper.Instance.GetLogNameType();
|
||||
var result = string.Empty;
|
||||
|
||||
if (logNameType != null)
|
||||
{
|
||||
var nameSplitted = name.Split(' ');
|
||||
|
||||
if (nameSplitted.Length > 1)
|
||||
{
|
||||
var firstName = nameSplitted[0];
|
||||
var lastName = nameSplitted[1];
|
||||
|
||||
switch (logNameType)
|
||||
{
|
||||
case LogNameType.FullName:
|
||||
result = $"{firstName} {lastName}";
|
||||
break;
|
||||
case LogNameType.LastNameShorted:
|
||||
result = $"{firstName} {lastName[..1]}.";
|
||||
break;
|
||||
case LogNameType.FirstNameShorted:
|
||||
result = $"{firstName[..1]}. {lastName}";
|
||||
break;
|
||||
case LogNameType.Initials:
|
||||
result = $"{firstName[..1]}. {lastName[..1]}.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(result))
|
||||
result = name;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void SplitOffPartyNumberPrefix(SeString sender, XivChatType type)
|
||||
{
|
||||
if (type == XivChatType.Party || type == XivChatType.Alliance)
|
||||
@@ -223,7 +264,8 @@ namespace PlayerTags.Features
|
||||
if (textPayload.Text == playerName)
|
||||
{
|
||||
playerTextPayloads.Add(textPayload);
|
||||
textPayload.Text = textPayload.Text;
|
||||
//textPayload.Text = textPayload.Text;
|
||||
textPayload.Text = playerName;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -264,6 +306,9 @@ namespace PlayerTags.Features
|
||||
|
||||
foreach (var playerTextPayload in playerTextPayloads)
|
||||
{
|
||||
// Fix displaying of abbreviated own player name as the game does this after the chat message handler
|
||||
playerTextPayload.Text = BuildPlayername(playerTextPayload.Text);
|
||||
|
||||
// This does some dodgy shit for an unknown reason.
|
||||
// Typically when you receive a player payload followed by a text payload, it displays the text
|
||||
// and links it with the player payload. When trying to make one of these manually, it displays the player payload separately,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
using PlayerTags.Configuration;
|
||||
using PlayerTags.Data;
|
||||
using PlayerTags.Features;
|
||||
|
||||
Reference in New Issue
Block a user