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, |     public Plugin(IDalamudPluginInterface pluginInterface, ICommandManager commandManager, IDataManager gameData, | ||||||
|         IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui, |         IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui, | ||||||
|         IGameGui gameGui, IDtrBar dtrBar, IToastGui toastGui, IPluginLog pluginLog, ITargetManager targetManager, INotificationManager notificationManager, |         IGameGui gameGui, IDtrBar dtrBar, IToastGui toastGui, IPluginLog pluginLog, ITargetManager targetManager, INotificationManager notificationManager, | ||||||
|         ITextureProvider textureProvider, IContextMenu contextMenu, |         ITextureProvider textureProvider, IContextMenu contextMenu, IGameInteropProvider gameInteropProvider, | ||||||
|         IGameInteropProvider gameInteropProvider, INamePlateGui namePlateGui) |         INamePlateGui namePlateGui, IGameConfig gameConfig, IPartyList partyList) | ||||||
|     { |     { | ||||||
|         Plugin.Self = this; |         Plugin.Self = this; | ||||||
|         _host = new HostBuilder() |         _host = new HostBuilder() | ||||||
| @@ -166,7 +166,7 @@ public sealed class Plugin : IDalamudPlugin | |||||||
|                 s.GetRequiredService<ILogger<GameChatHooks>>(), gameInteropProvider, chatGui, |                 s.GetRequiredService<ILogger<GameChatHooks>>(), gameInteropProvider, chatGui, | ||||||
|                 s.GetRequiredService<MareConfigService>(), s.GetRequiredService<ServerConfigurationManager>())); |                 s.GetRequiredService<MareConfigService>(), s.GetRequiredService<ServerConfigurationManager>())); | ||||||
|             collection.AddScoped((s) => new GuiHookService(s.GetRequiredService<ILogger<GuiHookService>>(), s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<MareMediator>(), |             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<MareMediator>()); | ||||||
|             collection.AddHostedService(p => p.GetRequiredService<NotificationService>()); |             collection.AddHostedService(p => p.GetRequiredService<NotificationService>()); | ||||||
|   | |||||||
| @@ -17,23 +17,31 @@ public class GuiHookService : DisposableMediatorSubscriberBase | |||||||
|     private readonly DalamudUtilService _dalamudUtil; |     private readonly DalamudUtilService _dalamudUtil; | ||||||
|     private readonly MareConfigService _configService; |     private readonly MareConfigService _configService; | ||||||
|     private readonly INamePlateGui _namePlateGui; |     private readonly INamePlateGui _namePlateGui; | ||||||
|  |     private readonly IGameConfig _gameConfig; | ||||||
|  |     private readonly IPartyList _partyList; | ||||||
|     private readonly PairManager _pairManager; |     private readonly PairManager _pairManager; | ||||||
|  |  | ||||||
|     private bool _isModified = false; |     private bool _isModified = false; | ||||||
|  |     private bool _namePlateRoleColorsEnabled = false; | ||||||
|  |  | ||||||
|     public GuiHookService(ILogger<GuiHookService> logger, DalamudUtilService dalamudUtil, MareMediator mediator, MareConfigService configService, |     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) |         : base(logger, mediator) | ||||||
|     { |     { | ||||||
|         _logger = logger; |         _logger = logger; | ||||||
|         _dalamudUtil = dalamudUtil; |         _dalamudUtil = dalamudUtil; | ||||||
|         _configService = configService; |         _configService = configService; | ||||||
|         _namePlateGui = namePlateGui; |         _namePlateGui = namePlateGui; | ||||||
|  |         _gameConfig = gameConfig; | ||||||
|  |         _partyList = partyList; | ||||||
|         _pairManager = pairManager; |         _pairManager = pairManager; | ||||||
|  |  | ||||||
|         _namePlateGui.OnNamePlateUpdate += OnNamePlateUpdate; |         _namePlateGui.OnNamePlateUpdate += OnNamePlateUpdate; | ||||||
|         _namePlateGui.RequestRedraw(); |         _namePlateGui.RequestRedraw(); | ||||||
|  |  | ||||||
|  |         gameConfig.TryGet(Dalamud.Game.Config.UiConfigOption.NamePlateSetRoleColor, out bool isNameplateSetRoleColor); | ||||||
|  |  | ||||||
|  |         Mediator.Subscribe<DelayedFrameworkUpdateMessage>(this, (_) => GameSettingsCheck()); | ||||||
|         Mediator.Subscribe<PairHandlerVisibleMessage>(this, (_) => RequestRedraw()); |         Mediator.Subscribe<PairHandlerVisibleMessage>(this, (_) => RequestRedraw()); | ||||||
|         Mediator.Subscribe<NameplateRedrawMessage>(this, (_) => RequestRedraw()); |         Mediator.Subscribe<NameplateRedrawMessage>(this, (_) => RequestRedraw()); | ||||||
|     } |     } | ||||||
| @@ -72,10 +80,17 @@ public class GuiHookService : DisposableMediatorSubscriberBase | |||||||
|  |  | ||||||
|         var visibleUsersDict = visibleUsers.ToDictionary(u => (ulong)u.PlayerCharacterId); |         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) |         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 pair = visibleUsersDict[handler.GameObjectId]; | ||||||
|                 var colors = !pair.IsApplicationBlocked ? _configService.Current.NameColors : _configService.Current.BlockedNameColors; |                 var colors = !pair.IsApplicationBlocked ? _configService.Current.NameColors : _configService.Current.BlockedNameColors; | ||||||
|                 handler.NameParts.TextWrap = ( |                 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 |     #region Colored SeString | ||||||
|     private const byte _colorTypeForeground = 0x13; |     private const byte _colorTypeForeground = 0x13; | ||||||
|     private const byte _colorTypeGlow = 0x14; |     private const byte _colorTypeGlow = 0x14; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Loporrit
					Loporrit