add disable autologon on a per character basis
add automatic notes population on empty notes adjust mare command help text
This commit is contained in:
@@ -56,6 +56,7 @@ public class MareConfig : IMareConfiguration
|
||||
public bool UseAlternativeFileUpload { get; set; } = false;
|
||||
public bool UseCompactor { get; set; } = false;
|
||||
public bool DebugStopWhining { get; set; } = false;
|
||||
public bool AutoPopulateEmptyNotesFromCharaName { get; set; } = false;
|
||||
public int Version { get; set; } = 1;
|
||||
public NotificationLocation WarningNotification { get; set; } = NotificationLocation.Both;
|
||||
}
|
||||
@@ -7,4 +7,5 @@ public record Authentication
|
||||
public uint WorldId { get; set; } = 0;
|
||||
public int SecretKeyIdx { get; set; } = -1;
|
||||
public string? UID { get; set; }
|
||||
public bool AutoLogin { get; set; } = true;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using MareSynchronos.PlayerData.Handlers;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -20,12 +21,14 @@ public class PairHandlerFactory
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly PlayerPerformanceService _playerPerformanceService;
|
||||
private readonly ServerConfigurationManager _serverConfigManager;
|
||||
private readonly PluginWarningNotificationService _pluginWarningNotificationManager;
|
||||
|
||||
public PairHandlerFactory(ILoggerFactory loggerFactory, GameObjectHandlerFactory gameObjectHandlerFactory, IpcManager ipcManager,
|
||||
FileDownloadManagerFactory fileDownloadManagerFactory, DalamudUtilService dalamudUtilService,
|
||||
PluginWarningNotificationService pluginWarningNotificationManager, IHostApplicationLifetime hostApplicationLifetime,
|
||||
FileCacheManager fileCacheManager, MareMediator mareMediator, PlayerPerformanceService playerPerformanceService)
|
||||
FileCacheManager fileCacheManager, MareMediator mareMediator, PlayerPerformanceService playerPerformanceService,
|
||||
ServerConfigurationManager serverConfigManager)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_gameObjectHandlerFactory = gameObjectHandlerFactory;
|
||||
@@ -37,12 +40,13 @@ public class PairHandlerFactory
|
||||
_fileCacheManager = fileCacheManager;
|
||||
_mareMediator = mareMediator;
|
||||
_playerPerformanceService = playerPerformanceService;
|
||||
_serverConfigManager = serverConfigManager;
|
||||
}
|
||||
|
||||
public PairHandler Create(Pair pair)
|
||||
{
|
||||
return new PairHandler(_loggerFactory.CreateLogger<PairHandler>(), pair, _gameObjectHandlerFactory,
|
||||
_ipcManager, _fileDownloadManagerFactory.Create(), _pluginWarningNotificationManager, _dalamudUtilService, _hostApplicationLifetime,
|
||||
_fileCacheManager, _mareMediator, _playerPerformanceService);
|
||||
_fileCacheManager, _mareMediator, _playerPerformanceService, _serverConfigManager);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Events;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI.Files;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
@@ -27,6 +28,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
private readonly IpcManager _ipcManager;
|
||||
private readonly IHostApplicationLifetime _lifetime;
|
||||
private readonly PlayerPerformanceService _playerPerformanceService;
|
||||
private readonly ServerConfigurationManager _serverConfigManager;
|
||||
private readonly PluginWarningNotificationService _pluginWarningNotificationManager;
|
||||
private CancellationTokenSource? _applicationCancellationTokenSource = new();
|
||||
private Guid _applicationId;
|
||||
@@ -47,7 +49,8 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
PluginWarningNotificationService pluginWarningNotificationManager,
|
||||
DalamudUtilService dalamudUtil, IHostApplicationLifetime lifetime,
|
||||
FileCacheManager fileDbManager, MareMediator mediator,
|
||||
PlayerPerformanceService playerPerformanceService) : base(logger, mediator)
|
||||
PlayerPerformanceService playerPerformanceService,
|
||||
ServerConfigurationManager serverConfigManager) : base(logger, mediator)
|
||||
{
|
||||
Pair = pair;
|
||||
_gameObjectHandlerFactory = gameObjectHandlerFactory;
|
||||
@@ -58,6 +61,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
_lifetime = lifetime;
|
||||
_fileDbManager = fileDbManager;
|
||||
_playerPerformanceService = playerPerformanceService;
|
||||
_serverConfigManager = serverConfigManager;
|
||||
_penumbraCollection = _ipcManager.Penumbra.CreateTemporaryCollectionAsync(logger, Pair.UserData.UID).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
|
||||
Mediator.Subscribe<FrameworkUpdateMessage>(this, (_) => FrameworkUpdate());
|
||||
@@ -451,7 +455,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
_applicationTask = ApplyCharacterDataAsync(applicationBase, charaData, updatedData, updateModdedPaths, updateManip, moddedPaths, token);
|
||||
}
|
||||
|
||||
private async Task ApplyCharacterDataAsync(Guid applicationBase, CharacterData charaData, Dictionary<ObjectKind, HashSet<PlayerChanges>> updatedData, bool updateModdedPaths, bool updateManip,
|
||||
private async Task ApplyCharacterDataAsync(Guid applicationBase, CharacterData charaData, Dictionary<ObjectKind, HashSet<PlayerChanges>> updatedData, bool updateModdedPaths, bool updateManip,
|
||||
Dictionary<(string GamePath, string? Hash), string> moddedPaths, CancellationToken token)
|
||||
{
|
||||
try
|
||||
@@ -557,6 +561,8 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
PlayerName = name;
|
||||
_charaHandler = _gameObjectHandlerFactory.Create(ObjectKind.Player, () => _dalamudUtil.GetPlayerCharacterFromCachedTableByIdent(Pair.Ident), isWatched: false).GetAwaiter().GetResult();
|
||||
|
||||
_serverConfigManager.AutoPopulateNoteForUid(Pair.UserData.UID, name);
|
||||
|
||||
Mediator.Subscribe<HonorificReadyMessage>(this, async (_) =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(_cachedData?.HonorificData)) return;
|
||||
|
||||
@@ -36,7 +36,13 @@ public sealed class CommandManagerService : IDisposable
|
||||
_mareConfigService = mareConfigService;
|
||||
_commandManager.AddHandler(_commandName, new CommandInfo(OnCommand)
|
||||
{
|
||||
HelpMessage = "Opens the Mare Synchronos UI"
|
||||
HelpMessage = "Opens the Mare Synchronos UI" + Environment.NewLine + Environment.NewLine +
|
||||
"Additionally possible commands:" + Environment.NewLine +
|
||||
"\t /mare toggle - Disconnects from Mare, if connected. Connects to Mare, if disconnected" + Environment.NewLine +
|
||||
"\t /mare toggle on|off - Connects or disconnects to Mare respectively" + Environment.NewLine +
|
||||
"\t /mare gpose - Opens the GPose MCDF import window (only works in GPose)" + Environment.NewLine +
|
||||
"\t /mare analyze - Opens the Mare Character Data Analysis window" + Environment.NewLine +
|
||||
"\t /mare settings - Opens the Mare Settings window"
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,6 +65,9 @@ public sealed class CommandManagerService : IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_mareConfigService.Current.HasValidSetup())
|
||||
return;
|
||||
|
||||
if (string.Equals(splitArgs[0], "toggle", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (_apiController.ServerState == WebAPI.SignalR.Utils.ServerState.Disconnecting)
|
||||
@@ -109,5 +118,9 @@ public sealed class CommandManagerService : IDisposable
|
||||
{
|
||||
_mediator.Publish(new UiToggleMessage(typeof(DataAnalysisUi)));
|
||||
}
|
||||
else if (string.Equals(splitArgs[0], "settings", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_mediator.Publish(new UiToggleMessage(typeof(SettingsUi)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,6 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
private readonly List<string> _notUpdatedCharas = [];
|
||||
private bool _sentBetweenAreas = false;
|
||||
|
||||
|
||||
public DalamudUtilService(ILogger<DalamudUtilService> logger, IClientState clientState, IObjectTable objectTable, IFramework framework,
|
||||
IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager,
|
||||
BlockedCharacterHandler blockedCharacterHandler, MareMediator mediator, PerformanceCollectorService performanceCollector)
|
||||
|
||||
@@ -17,6 +17,7 @@ public class ServerConfigurationManager
|
||||
{
|
||||
private readonly ServerConfigService _configService;
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly ILogger<ServerConfigurationManager> _logger;
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly NotesConfigService _notesConfig;
|
||||
@@ -24,6 +25,7 @@ public class ServerConfigurationManager
|
||||
|
||||
public ServerConfigurationManager(ILogger<ServerConfigurationManager> logger, ServerConfigService configService,
|
||||
ServerTagConfigService serverTagConfig, NotesConfigService notesConfig, DalamudUtilService dalamudUtil,
|
||||
MareConfigService mareConfigService,
|
||||
MareMediator mareMediator)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -31,6 +33,7 @@ public class ServerConfigurationManager
|
||||
_serverTagConfig = serverTagConfig;
|
||||
_notesConfig = notesConfig;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_mareConfigService = mareConfigService;
|
||||
_mareMediator = mareMediator;
|
||||
EnsureMainExists();
|
||||
}
|
||||
@@ -438,6 +441,15 @@ public class ServerConfigurationManager
|
||||
_notesConfig.Save();
|
||||
}
|
||||
|
||||
internal void AutoPopulateNoteForUid(string uid, string note)
|
||||
{
|
||||
if (!_mareConfigService.Current.AutoPopulateEmptyNotesFromCharaName
|
||||
|| GetNoteForUid(uid) != null)
|
||||
return;
|
||||
|
||||
SetNoteForUid(uid, note, save: true);
|
||||
}
|
||||
|
||||
private ServerNotesStorage CurrentNotesStorage()
|
||||
{
|
||||
TryCreateCurrentNotesStorage();
|
||||
|
||||
@@ -328,8 +328,9 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ((userSize.Y + textSize.Y) / 2 + shardTextSize.Y) / 2 - ImGui.GetStyle().ItemSpacing.Y + buttonSize.Y / 2);
|
||||
}
|
||||
var color = UiSharedService.GetBoolColor(!_serverManager.CurrentServer!.FullPause);
|
||||
var connectedIcon = !_serverManager.CurrentServer.FullPause ? FontAwesomeIcon.Link : FontAwesomeIcon.Unlink;
|
||||
bool isConnectingOrConnected = _apiController.ServerState is ServerState.Connected or ServerState.Connecting or ServerState.Reconnecting;
|
||||
var color = UiSharedService.GetBoolColor(!isConnectingOrConnected);
|
||||
var connectedIcon = isConnectingOrConnected ? FontAwesomeIcon.Unlink : FontAwesomeIcon.Link;
|
||||
|
||||
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
|
||||
if (printShard)
|
||||
@@ -343,13 +344,22 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
if (_uiSharedService.IconButton(connectedIcon))
|
||||
{
|
||||
_serverManager.CurrentServer.FullPause = !_serverManager.CurrentServer.FullPause;
|
||||
_serverManager.Save();
|
||||
if (isConnectingOrConnected && !_serverManager.CurrentServer.FullPause)
|
||||
{
|
||||
_serverManager.CurrentServer.FullPause = true;
|
||||
_serverManager.Save();
|
||||
}
|
||||
else if (!isConnectingOrConnected && _serverManager.CurrentServer.FullPause)
|
||||
{
|
||||
_serverManager.CurrentServer.FullPause = false;
|
||||
_serverManager.Save();
|
||||
}
|
||||
|
||||
_ = _apiController.CreateConnectionsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
UiSharedService.AttachToolTip(!_serverManager.CurrentServer.FullPause ? "Disconnect from " + _serverManager.CurrentServer.ServerName : "Connect to " + _serverManager.CurrentServer.ServerName);
|
||||
UiSharedService.AttachToolTip(isConnectingOrConnected ? "Disconnect from " + _serverManager.CurrentServer.ServerName : "Connect to " + _serverManager.CurrentServer.ServerName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,6 +621,7 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
ServerState.MultiChara => "Your Character Configuration has multiple characters configured with same name and world. You will not be able to connect until you fix this issue. Remove the duplicates from the configuration in Settings -> Service Settings -> Character Management and reconnect manually after.",
|
||||
ServerState.OAuthMisconfigured => "OAuth2 is enabled but not fully configured, verify in the Settings -> Service Settings that you have OAuth2 connected and, importantly, a UID assigned to your current character.",
|
||||
ServerState.OAuthLoginTokenStale => "Your OAuth2 login token is stale and cannot be used to renew. Go to the Settings -> Service Settings and unlink then relink your OAuth2 configuration.",
|
||||
ServerState.NoAutoLogon => "This character has automatic login into Mare disabled. Press the connect button to connect to Mare.",
|
||||
_ => string.Empty
|
||||
};
|
||||
}
|
||||
@@ -632,6 +643,7 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
ServerState.MultiChara => ImGuiColors.DalamudYellow,
|
||||
ServerState.OAuthMisconfigured => ImGuiColors.DalamudRed,
|
||||
ServerState.OAuthLoginTokenStale => ImGuiColors.DalamudRed,
|
||||
ServerState.NoAutoLogon => ImGuiColors.DalamudYellow,
|
||||
_ => ImGuiColors.DalamudRed
|
||||
};
|
||||
}
|
||||
@@ -652,6 +664,7 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
ServerState.MultiChara => "Duplicate Characters",
|
||||
ServerState.OAuthMisconfigured => "Misconfigured OAuth2",
|
||||
ServerState.OAuthLoginTokenStale => "Stale OAuth2",
|
||||
ServerState.NoAutoLogon => "Auto Login disabled",
|
||||
ServerState.Connected => _apiController.DisplayName,
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
@@ -759,6 +759,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
_uiShared.DrawHelpText("This will open a popup that allows you to set the notes for a user after successfully adding them to your individual pairs.");
|
||||
|
||||
var autoPopulateNotes = _configService.Current.AutoPopulateEmptyNotesFromCharaName;
|
||||
if (ImGui.Checkbox("Automatically populate notes using player names", ref autoPopulateNotes))
|
||||
{
|
||||
_configService.Current.AutoPopulateEmptyNotesFromCharaName = autoPopulateNotes;
|
||||
_configService.Save();
|
||||
}
|
||||
_uiShared.DrawHelpText("This will automatically populate user notes using the first encountered player name if the note was not set prior");
|
||||
|
||||
ImGui.Separator();
|
||||
_uiShared.BigText("UI");
|
||||
var showNameInsteadOfNotes = _configService.Current.ShowCharacterNameInsteadOfNotesForVisible;
|
||||
@@ -1369,6 +1377,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
_uiShared.DrawUIDComboForAuthentication(i, item, selectedServer.ServerUri, _logger);
|
||||
}
|
||||
bool isAutoLogin = item.AutoLogin;
|
||||
if (ImGui.Checkbox("Automatically login to Mare", ref isAutoLogin))
|
||||
{
|
||||
item.AutoLogin = isAutoLogin;
|
||||
_serverConfigurationManager.Save();
|
||||
}
|
||||
_uiShared.DrawHelpText("When enabled and logging into this character in XIV, Mare will automatically connect to the current service.");
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete Character") && UiSharedService.CtrlPressed())
|
||||
_serverConfigurationManager.RemoveCharacterFromServer(idx, item);
|
||||
UiSharedService.AttachToolTip("Hold CTRL to delete this entry.");
|
||||
|
||||
@@ -371,7 +371,19 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
|
||||
|
||||
private void DalamudUtilOnLogIn()
|
||||
{
|
||||
_ = Task.Run(() => CreateConnectionsAsync());
|
||||
var charaName = _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult();
|
||||
var worldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult();
|
||||
var auth = _serverManager.CurrentServer.Authentications.Find(f => string.Equals(f.CharacterName, charaName, StringComparison.Ordinal) && f.WorldId == worldId);
|
||||
if (auth?.AutoLogin ?? false)
|
||||
{
|
||||
Logger.LogInformation("Logging into {chara}", charaName);
|
||||
_ = Task.Run(CreateConnectionsAsync);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("Not logging into {chara}, auto login disabled", charaName);
|
||||
_ = Task.Run(async () => await StopConnectionAsync(ServerState.NoAutoLogon).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
private void DalamudUtilOnLogOut()
|
||||
|
||||
@@ -14,5 +14,6 @@ public enum ServerState
|
||||
NoSecretKey,
|
||||
MultiChara,
|
||||
OAuthMisconfigured,
|
||||
OAuthLoginTokenStale
|
||||
OAuthLoginTokenStale,
|
||||
NoAutoLogon
|
||||
}
|
||||
Reference in New Issue
Block a user