improve logging/error display for lack of penumbra or glamourer

This commit is contained in:
Stanley Dimant
2024-07-19 10:46:29 +02:00
parent 0c47bf8ccd
commit c67add20d6
7 changed files with 60 additions and 10 deletions

View File

@@ -10,7 +10,7 @@ using Microsoft.Extensions.Logging;
namespace MareSynchronos.Interop.Ipc;
public sealed class IpcCallerGlamourer : IIpcCaller
public sealed class IpcCallerGlamourer : DisposableMediatorSubscriberBase, IIpcCaller
{
private readonly ILogger<IpcCallerGlamourer> _logger;
private readonly IDalamudPluginInterface _pi;
@@ -31,7 +31,7 @@ public sealed class IpcCallerGlamourer : IIpcCaller
private readonly uint LockCode = 0x6D617265;
public IpcCallerGlamourer(ILogger<IpcCallerGlamourer> logger, IDalamudPluginInterface pi, DalamudUtilService dalamudUtil, MareMediator mareMediator,
RedrawManager redrawManager)
RedrawManager redrawManager) : base(logger, mareMediator)
{
_glamourerApiVersions = new ApiVersion(pi);
_glamourerGetAllCustomization = new GetStateBase64(pi);
@@ -50,6 +50,15 @@ public sealed class IpcCallerGlamourer : IIpcCaller
_glamourerStateChanged = StateChanged.Subscriber(pi, GlamourerChanged);
_glamourerStateChanged.Enable();
Mediator.Subscribe<DalamudLoginMessage>(this, s => _shownGlamourerUnavailable = false);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_redrawManager.Cancel();
}
public bool APIAvailable { get; private set; }

View File

@@ -90,6 +90,8 @@ public sealed class IpcCallerPenumbra : DisposableMediatorSubscriberBase, IIpcCa
{
_penumbraRedraw.Invoke(msg.Character.ObjectIndex, RedrawType.AfterGPose);
});
Mediator.Subscribe<DalamudLoginMessage>(this, (msg) => _shownPenumbraUnavailable = false);
}
public bool APIAvailable { get; private set; } = false;

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Authors></Authors>
<Company></Company>
<Version>1.9.0</Version>
<Version>1.10.0</Version>
<Description></Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -107,7 +107,8 @@ public sealed class Plugin : IDalamudPlugin
s.GetRequiredService<IpcCallerCustomize>(), s.GetRequiredService<IpcCallerHeels>(), s.GetRequiredService<IpcCallerHonorific>(),
s.GetRequiredService<IpcCallerMoodles>()));
collection.AddSingleton((s) => new NotificationService(s.GetRequiredService<ILogger<NotificationService>>(),
s.GetRequiredService<MareMediator>(), notificationManager, chatGui, s.GetRequiredService<MareConfigService>()));
s.GetRequiredService<MareMediator>(), s.GetRequiredService<DalamudUtilService>(),
notificationManager, chatGui, s.GetRequiredService<MareConfigService>()));
collection.AddSingleton((s) => new MareConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new ServerConfigService(pluginInterface.ConfigDirectory.FullName));
collection.AddSingleton((s) => new NotesConfigService(pluginInterface.ConfigDirectory.FullName));

View File

@@ -12,13 +12,17 @@ namespace MareSynchronos.Services;
public class NotificationService : DisposableMediatorSubscriberBase, IHostedService
{
private readonly DalamudUtilService _dalamudUtilService;
private readonly INotificationManager _notificationManager;
private readonly IChatGui _chatGui;
private readonly MareConfigService _configurationService;
public NotificationService(ILogger<NotificationService> logger, MareMediator mediator, INotificationManager notificationManager,
public NotificationService(ILogger<NotificationService> logger, MareMediator mediator,
DalamudUtilService dalamudUtilService,
INotificationManager notificationManager,
IChatGui chatGui, MareConfigService configurationService) : base(logger, mediator)
{
_dalamudUtilService = dalamudUtilService;
_notificationManager = notificationManager;
_chatGui = chatGui;
_configurationService = configurationService;
@@ -75,6 +79,8 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
{
Logger.LogInformation("{msg}", msg.ToString());
if (!_dalamudUtilService.IsLoggedIn) return;
switch (msg.Type)
{
case NotificationType.Info:
@@ -117,9 +123,9 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
{
Dalamud.Interface.ImGuiNotification.NotificationType dalamudType = msg.Type switch
{
MareConfiguration.Models.NotificationType.Error => Dalamud.Interface.ImGuiNotification.NotificationType.Error,
MareConfiguration.Models.NotificationType.Warning => Dalamud.Interface.ImGuiNotification.NotificationType.Warning,
MareConfiguration.Models.NotificationType.Info => Dalamud.Interface.ImGuiNotification.NotificationType.Info,
NotificationType.Error => Dalamud.Interface.ImGuiNotification.NotificationType.Error,
NotificationType.Warning => Dalamud.Interface.ImGuiNotification.NotificationType.Warning,
NotificationType.Info => Dalamud.Interface.ImGuiNotification.NotificationType.Info,
_ => Dalamud.Interface.ImGuiNotification.NotificationType.Info
};

View File

@@ -103,7 +103,7 @@ public class ServerConfigurationManager
var auth = currentServer.Authentications.FindAll(f => string.Equals(f.CharacterName, charaName, StringComparison.Ordinal) && f.WorldId == worldId);
if (auth.Count >= 2)
{
_mareMediator.Publish(new NotificationMessage("Multiple Identical Characters detected", "Your Service configuration has multiple characters with the same name and world set up. Please delete the duplicates in the character configuration.",
_mareMediator.Publish(new NotificationMessage("Multiple Identical Characters detected", "Your Service configuration has multiple characters with the same name and world set up. Please delete the duplicates in the character management.",
NotificationType.Error));
_logger.LogTrace("GetSecretKey accessed, returning null because multiple ({count}) identical characters.", auth.Count);
return null;

View File

@@ -6,6 +6,7 @@ using Dalamud.Utility;
using ImGuiNET;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto.Group;
using MareSynchronos.Interop.Ipc;
using MareSynchronos.MareConfiguration;
using MareSynchronos.PlayerData.Handlers;
using MareSynchronos.PlayerData.Pairs;
@@ -37,6 +38,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private readonly PairManager _pairManager;
private readonly SelectTagForPairUi _selectGroupForPairUi;
private readonly SelectPairForTagUi _selectPairsForGroupUi;
private readonly IpcManager _ipcManager;
private readonly ServerConfigurationManager _serverManager;
private readonly TopTabMenu _tabMenu;
private readonly TagHandler _tagHandler;
@@ -55,7 +57,7 @@ public class CompactUi : WindowMediatorSubscriberBase
public CompactUi(ILogger<CompactUi> logger, UiSharedService uiShared, MareConfigService configService, ApiController apiController, PairManager pairManager,
ServerConfigurationManager serverManager, MareMediator mediator, FileUploadManager fileTransferManager,
TagHandler tagHandler, DrawEntityFactory drawEntityFactory, SelectTagForPairUi selectTagForPairUi, SelectPairForTagUi selectPairForTagUi,
PerformanceCollectorService performanceCollectorService)
PerformanceCollectorService performanceCollectorService, IpcManager ipcManager)
: base(logger, mediator, "###MareSynchronosMainUI", performanceCollectorService)
{
_uiSharedService = uiShared;
@@ -68,6 +70,7 @@ public class CompactUi : WindowMediatorSubscriberBase
_drawEntityFactory = drawEntityFactory;
_selectGroupForPairUi = selectTagForPairUi;
_selectPairsForGroupUi = selectPairForTagUi;
_ipcManager = ipcManager;
_tabMenu = new TopTabMenu(Mediator, _apiController, _pairManager, _uiSharedService);
AllowPinning = false;
@@ -152,6 +155,35 @@ public class CompactUi : WindowMediatorSubscriberBase
$"It is highly recommended to keep Mare Synchronos up to date. Open /xlplugins and update the plugin.", ImGuiColors.DalamudRed);
}
if (!_ipcManager.Initialized)
{
var unsupported = "MISSING ESSENTIAL PLUGINS";
using (_uiSharedService.UidFont.Push())
{
var uidTextSize = ImGui.CalcTextSize(unsupported);
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMax().X + ImGui.GetWindowContentRegionMin().X) / 2 - uidTextSize.X / 2);
ImGui.AlignTextToFramePadding();
ImGui.TextColored(ImGuiColors.DalamudRed, unsupported);
}
var penumAvailable = _ipcManager.Penumbra.APIAvailable;
var glamAvailable = _ipcManager.Glamourer.APIAvailable;
UiSharedService.ColorTextWrapped($"One or more Plugins essential for Mare operation are unavailable. Enable or update following plugins:", ImGuiColors.DalamudRed);
using var indent = ImRaii.PushIndent(10f);
if (!penumAvailable)
{
UiSharedService.TextWrapped("Penumbra");
_uiSharedService.BooleanToColoredIcon(penumAvailable, true);
}
if (!glamAvailable)
{
UiSharedService.TextWrapped("Glamourer");
_uiSharedService.BooleanToColoredIcon(glamAvailable, true);
}
ImGui.Separator();
}
using (ImRaii.PushId("header")) DrawUIDHeader();
ImGui.Separator();
using (ImRaii.PushId("serverstatus")) DrawServerStatus();