From eccfc5b3f0e81638b02a1823c6b140ff9636734c Mon Sep 17 00:00:00 2001 From: "N. Lo." Date: Sat, 16 Aug 2025 23:17:18 +0200 Subject: [PATCH] Add option to set visible pairs as focus targets (#85) --- .../MareConfiguration/Configurations/MareConfig.cs | 1 + MareSynchronos/Plugin.cs | 3 ++- MareSynchronos/Services/DalamudUtilService.cs | 12 ++++++++++-- MareSynchronos/UI/SettingsUi.cs | 7 +++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs b/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs index 82a8b0f..f1887a3 100644 --- a/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs +++ b/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs @@ -59,4 +59,5 @@ public class MareConfig : IMareConfiguration public bool AutoPopulateEmptyNotesFromCharaName { get; set; } = false; public int Version { get; set; } = 1; public NotificationLocation WarningNotification { get; set; } = NotificationLocation.Both; + public bool UseFocusTarget { get; set; } = false; } \ No newline at end of file diff --git a/MareSynchronos/Plugin.cs b/MareSynchronos/Plugin.cs index 182c2a6..3fb245b 100644 --- a/MareSynchronos/Plugin.cs +++ b/MareSynchronos/Plugin.cs @@ -134,7 +134,8 @@ public sealed class Plugin : IDalamudPlugin s.GetRequiredService>(), s.GetRequiredService())); collection.AddSingleton((s) => new DalamudUtilService(s.GetRequiredService>(), clientState, objectTable, framework, gameGui, condition, gameData, targetManager, gameConfig, - s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService())); + s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), + s.GetRequiredService())); collection.AddSingleton((s) => new DtrEntry(s.GetRequiredService>(), dtrBar, s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService())); collection.AddSingleton(s => new PairManager(s.GetRequiredService>(), s.GetRequiredService(), diff --git a/MareSynchronos/Services/DalamudUtilService.cs b/MareSynchronos/Services/DalamudUtilService.cs index bdbb846..5450328 100644 --- a/MareSynchronos/Services/DalamudUtilService.cs +++ b/MareSynchronos/Services/DalamudUtilService.cs @@ -13,6 +13,7 @@ using FFXIVClientStructs.FFXIV.Client.UI.Agent; using Lumina.Excel.Sheets; using MareSynchronos.API.Dto.CharaData; using MareSynchronos.Interop; +using MareSynchronos.MareConfiguration; using MareSynchronos.PlayerData.Handlers; using MareSynchronos.Services.Mediator; using MareSynchronos.Utils; @@ -38,6 +39,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber private readonly ILogger _logger; private readonly IObjectTable _objectTable; private readonly PerformanceCollectorService _performanceCollector; + private readonly MareConfigService _configService; private uint? _classJobId = 0; private DateTime _delayedFrameworkUpdateCheck = DateTime.UtcNow; private string _lastGlobalBlockPlayer = string.Empty; @@ -50,7 +52,8 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber public DalamudUtilService(ILogger logger, IClientState clientState, IObjectTable objectTable, IFramework framework, IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager, IGameConfig gameConfig, - BlockedCharacterHandler blockedCharacterHandler, MareMediator mediator, PerformanceCollectorService performanceCollector) + BlockedCharacterHandler blockedCharacterHandler, MareMediator mediator, PerformanceCollectorService performanceCollector, + MareConfigService configService) { _logger = logger; _clientState = clientState; @@ -63,6 +66,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber _blockedCharacterHandler = blockedCharacterHandler; Mediator = mediator; _performanceCollector = performanceCollector; + _configService = configService; WorldData = new(() => { return gameData.GetExcelSheet(Dalamud.Game.ClientLanguage.English)! @@ -118,9 +122,13 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber if (string.IsNullOrEmpty(name)) return; var addr = _playerCharas.FirstOrDefault(f => string.Equals(f.Value.Name, name, StringComparison.Ordinal)).Value.Address; if (addr == nint.Zero) return; + var useFocusTarget = _configService.Current.UseFocusTarget; _ = RunOnFrameworkThread(() => { - targetManager.Target = CreateGameObject(addr); + if (useFocusTarget) + targetManager.FocusTarget = CreateGameObject(addr); + else + targetManager.Target = CreateGameObject(addr); }).ConfigureAwait(false); }); IsWine = Util.IsWine(); diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index 31f2075..77954c4 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -895,6 +895,7 @@ public class SettingsUi : WindowMediatorSubscriberBase var dtrColorsNotConnected = _configService.Current.DtrColorsNotConnected; var dtrColorsPairsInRange = _configService.Current.DtrColorsPairsInRange; var preferNotesInsteadOfName = _configService.Current.PreferNotesOverNamesForVisible; + var useFocusTarget = _configService.Current.UseFocusTarget; var groupUpSyncshells = _configService.Current.GroupUpSyncshells; var groupInVisible = _configService.Current.ShowSyncshellUsersInVisible; var syncshellOfflineSeparate = _configService.Current.ShowSyncshellOfflineUsersSeparately; @@ -1025,6 +1026,12 @@ public class SettingsUi : WindowMediatorSubscriberBase if (!_configService.Current.ShowCharacterNameInsteadOfNotesForVisible) ImGui.EndDisabled(); ImGui.Unindent(); + if (ImGui.Checkbox("Set visible pairs as focus targets when clicking the eye", ref useFocusTarget)) + { + _configService.Current.UseFocusTarget = useFocusTarget; + _configService.Save(); + } + if (ImGui.Checkbox("Show Mare Profiles on Hover", ref showProfiles)) { Mediator.Publish(new ClearProfileDataMessage());