Make nameplate colors not override party role colors
This commit is contained in:
@@ -46,8 +46,8 @@ public sealed class Plugin : IDalamudPlugin
|
||||
public Plugin(IDalamudPluginInterface pluginInterface, ICommandManager commandManager, IDataManager gameData,
|
||||
IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui,
|
||||
IGameGui gameGui, IDtrBar dtrBar, IToastGui toastGui, IPluginLog pluginLog, ITargetManager targetManager, INotificationManager notificationManager,
|
||||
ITextureProvider textureProvider, IContextMenu contextMenu,
|
||||
IGameInteropProvider gameInteropProvider, INamePlateGui namePlateGui)
|
||||
ITextureProvider textureProvider, IContextMenu contextMenu, IGameInteropProvider gameInteropProvider,
|
||||
INamePlateGui namePlateGui, IGameConfig gameConfig, IPartyList partyList)
|
||||
{
|
||||
Plugin.Self = this;
|
||||
_host = new HostBuilder()
|
||||
@@ -166,7 +166,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
s.GetRequiredService<ILogger<GameChatHooks>>(), gameInteropProvider, chatGui,
|
||||
s.GetRequiredService<MareConfigService>(), s.GetRequiredService<ServerConfigurationManager>()));
|
||||
collection.AddScoped((s) => new GuiHookService(s.GetRequiredService<ILogger<GuiHookService>>(), s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<MareMediator>(),
|
||||
s.GetRequiredService<MareConfigService>(), namePlateGui, s.GetRequiredService<PairManager>()));
|
||||
s.GetRequiredService<MareConfigService>(), namePlateGui, gameConfig, partyList, s.GetRequiredService<PairManager>()));
|
||||
|
||||
collection.AddHostedService(p => p.GetRequiredService<MareMediator>());
|
||||
collection.AddHostedService(p => p.GetRequiredService<NotificationService>());
|
||||
|
||||
@@ -17,23 +17,31 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly INamePlateGui _namePlateGui;
|
||||
private readonly IGameConfig _gameConfig;
|
||||
private readonly IPartyList _partyList;
|
||||
private readonly PairManager _pairManager;
|
||||
|
||||
private bool _isModified = false;
|
||||
private bool _namePlateRoleColorsEnabled = false;
|
||||
|
||||
public GuiHookService(ILogger<GuiHookService> logger, DalamudUtilService dalamudUtil, MareMediator mediator, MareConfigService configService,
|
||||
INamePlateGui namePlateGui, PairManager pairManager)
|
||||
INamePlateGui namePlateGui, IGameConfig gameConfig, IPartyList partyList, PairManager pairManager)
|
||||
: base(logger, mediator)
|
||||
{
|
||||
_logger = logger;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_configService = configService;
|
||||
_namePlateGui = namePlateGui;
|
||||
_gameConfig = gameConfig;
|
||||
_partyList = partyList;
|
||||
_pairManager = pairManager;
|
||||
|
||||
_namePlateGui.OnNamePlateUpdate += OnNamePlateUpdate;
|
||||
_namePlateGui.RequestRedraw();
|
||||
|
||||
gameConfig.TryGet(Dalamud.Game.Config.UiConfigOption.NamePlateSetRoleColor, out bool isNameplateSetRoleColor);
|
||||
|
||||
Mediator.Subscribe<DelayedFrameworkUpdateMessage>(this, (_) => GameSettingsCheck());
|
||||
Mediator.Subscribe<PairHandlerVisibleMessage>(this, (_) => RequestRedraw());
|
||||
Mediator.Subscribe<NameplateRedrawMessage>(this, (_) => RequestRedraw());
|
||||
}
|
||||
@@ -72,10 +80,17 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
|
||||
var visibleUsersDict = visibleUsers.ToDictionary(u => (ulong)u.PlayerCharacterId);
|
||||
|
||||
var partyMembers = new nint[_partyList.Count];
|
||||
|
||||
for (int i = 0; i < _partyList.Count; ++i)
|
||||
partyMembers[i] = _partyList[i]?.GameObject?.Address ?? nint.MaxValue;
|
||||
|
||||
foreach (var handler in handlers)
|
||||
{
|
||||
if (visibleUsersIds.Contains(handler.GameObjectId))
|
||||
if (handler != null && visibleUsersIds.Contains(handler.GameObjectId))
|
||||
{
|
||||
if (_namePlateRoleColorsEnabled && partyMembers.Contains(handler.GameObject?.Address ?? nint.MaxValue))
|
||||
continue;
|
||||
var pair = visibleUsersDict[handler.GameObjectId];
|
||||
var colors = !pair.IsApplicationBlocked ? _configService.Current.NameColors : _configService.Current.BlockedNameColors;
|
||||
handler.NameParts.TextWrap = (
|
||||
@@ -87,6 +102,18 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
private void GameSettingsCheck()
|
||||
{
|
||||
if (!_gameConfig.TryGet(Dalamud.Game.Config.UiConfigOption.NamePlateSetRoleColor, out bool namePlateRoleColorsEnabled))
|
||||
return;
|
||||
|
||||
if (_namePlateRoleColorsEnabled != namePlateRoleColorsEnabled)
|
||||
{
|
||||
_namePlateRoleColorsEnabled = namePlateRoleColorsEnabled;
|
||||
RequestRedraw(force: true);
|
||||
}
|
||||
}
|
||||
|
||||
#region Colored SeString
|
||||
private const byte _colorTypeForeground = 0x13;
|
||||
private const byte _colorTypeGlow = 0x14;
|
||||
|
||||
Reference in New Issue
Block a user