mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Make ChatGui lazy dependency of PM
This commit is contained in:
parent
7f5ef03917
commit
be9216bbc5
2 changed files with 55 additions and 41 deletions
|
|
@ -29,9 +29,7 @@ namespace Dalamud.Game.Gui;
|
||||||
/// This class handles interacting with the native chat UI.
|
/// This class handles interacting with the native chat UI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[InterfaceVersion("1.0")]
|
[InterfaceVersion("1.0")]
|
||||||
[ServiceManager.BlockingEarlyLoadedService($"{nameof(PluginManager)} currently uses this.")]
|
[ServiceManager.EarlyLoadedService]
|
||||||
// ^ TODO: This seems unnecessary, remove the hard dependency at a later time.
|
|
||||||
// Otherwise, if PM eventually marks this class as required, note that in the comment above.
|
|
||||||
internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
|
internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
|
||||||
{
|
{
|
||||||
private static readonly ModuleLog Log = new("ChatGui");
|
private static readonly ModuleLog Log = new("ChatGui");
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ internal partial class PluginManager : IInternalDisposableService
|
||||||
private readonly List<RemotePluginManifest> availablePluginsList = new();
|
private readonly List<RemotePluginManifest> availablePluginsList = new();
|
||||||
private readonly List<AvailablePluginUpdate> updatablePluginsList = new();
|
private readonly List<AvailablePluginUpdate> updatablePluginsList = new();
|
||||||
|
|
||||||
private readonly DalamudLinkPayload openInstallerWindowPluginChangelogsLink;
|
private readonly Task<DalamudLinkPayload> openInstallerWindowPluginChangelogsLink;
|
||||||
|
|
||||||
[ServiceManager.ServiceDependency]
|
[ServiceManager.ServiceDependency]
|
||||||
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
|
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
|
||||||
|
|
@ -74,9 +74,6 @@ internal partial class PluginManager : IInternalDisposableService
|
||||||
[ServiceManager.ServiceDependency]
|
[ServiceManager.ServiceDependency]
|
||||||
private readonly HappyHttpClient happyHttpClient = Service<HappyHttpClient>.Get();
|
private readonly HappyHttpClient happyHttpClient = Service<HappyHttpClient>.Get();
|
||||||
|
|
||||||
[ServiceManager.ServiceDependency]
|
|
||||||
private readonly ChatGui chatGui = Service<ChatGui>.Get();
|
|
||||||
|
|
||||||
static PluginManager()
|
static PluginManager()
|
||||||
{
|
{
|
||||||
DalamudApiLevel = typeof(PluginManager).Assembly.GetName().Version!.Major;
|
DalamudApiLevel = typeof(PluginManager).Assembly.GetName().Version!.Major;
|
||||||
|
|
@ -125,10 +122,16 @@ internal partial class PluginManager : IInternalDisposableService
|
||||||
throw new InvalidDataException("Couldn't deserialize banned plugins manifest.");
|
throw new InvalidDataException("Couldn't deserialize banned plugins manifest.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.openInstallerWindowPluginChangelogsLink = this.chatGui.AddChatLinkHandler("Dalamud", 1003, (_, _) =>
|
this.openInstallerWindowPluginChangelogsLink =
|
||||||
{
|
Service<ChatGui>.GetAsync().ContinueWith(
|
||||||
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(PluginInstallerWindow.PluginInstallerOpenKind.Changelogs);
|
chatGuiTask => chatGuiTask.Result.AddChatLinkHandler(
|
||||||
});
|
"Dalamud",
|
||||||
|
1003,
|
||||||
|
(_, _) =>
|
||||||
|
{
|
||||||
|
Service<DalamudInterface>.GetNullable()?.OpenPluginInstallerTo(
|
||||||
|
PluginInstallerWindow.PluginInstallerOpenKind.Changelogs);
|
||||||
|
}));
|
||||||
|
|
||||||
this.configuration.PluginTestingOptIns ??= new();
|
this.configuration.PluginTestingOptIns ??= new();
|
||||||
this.MainRepo = PluginRepository.CreateMainRepo(this.happyHttpClient);
|
this.MainRepo = PluginRepository.CreateMainRepo(this.happyHttpClient);
|
||||||
|
|
@ -292,41 +295,54 @@ internal partial class PluginManager : IInternalDisposableService
|
||||||
/// <param name="updateMetadata">The list of updated plugin metadata.</param>
|
/// <param name="updateMetadata">The list of updated plugin metadata.</param>
|
||||||
/// <param name="header">The header text to send to chat prior to any update info.</param>
|
/// <param name="header">The header text to send to chat prior to any update info.</param>
|
||||||
public void PrintUpdatedPlugins(List<PluginUpdateStatus>? updateMetadata, string header)
|
public void PrintUpdatedPlugins(List<PluginUpdateStatus>? updateMetadata, string header)
|
||||||
{
|
=> Service<ChatGui>.GetAsync().ContinueWith(
|
||||||
if (updateMetadata is { Count: > 0 })
|
chatGuiTask =>
|
||||||
{
|
|
||||||
this.chatGui.Print(new XivChatEntry
|
|
||||||
{
|
{
|
||||||
Message = new SeString(new List<Payload>()
|
if (!chatGuiTask.IsCompletedSuccessfully)
|
||||||
{
|
return;
|
||||||
new TextPayload(header),
|
|
||||||
new TextPayload(" ["),
|
|
||||||
new UIForegroundPayload(500),
|
|
||||||
this.openInstallerWindowPluginChangelogsLink,
|
|
||||||
new TextPayload(Loc.Localize("DalamudInstallerPluginChangelogHelp", "Open plugin changelogs")),
|
|
||||||
RawPayload.LinkTerminator,
|
|
||||||
new UIForegroundPayload(0),
|
|
||||||
new TextPayload("]"),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var metadata in updateMetadata)
|
var chatGui = chatGuiTask.Result;
|
||||||
{
|
if (updateMetadata is { Count: > 0 })
|
||||||
if (metadata.Status == PluginUpdateStatus.StatusKind.Success)
|
|
||||||
{
|
{
|
||||||
this.chatGui.Print(Locs.DalamudPluginUpdateSuccessful(metadata.Name, metadata.Version));
|
chatGui.Print(
|
||||||
}
|
new XivChatEntry
|
||||||
else
|
{
|
||||||
{
|
Message = new SeString(
|
||||||
this.chatGui.Print(new XivChatEntry
|
new List<Payload>()
|
||||||
|
{
|
||||||
|
new TextPayload(header),
|
||||||
|
new TextPayload(" ["),
|
||||||
|
new UIForegroundPayload(500),
|
||||||
|
this.openInstallerWindowPluginChangelogsLink.Result,
|
||||||
|
new TextPayload(
|
||||||
|
Loc.Localize("DalamudInstallerPluginChangelogHelp", "Open plugin changelogs")),
|
||||||
|
RawPayload.LinkTerminator,
|
||||||
|
new UIForegroundPayload(0),
|
||||||
|
new TextPayload("]"),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var metadata in updateMetadata)
|
||||||
{
|
{
|
||||||
Message = Locs.DalamudPluginUpdateFailed(metadata.Name, metadata.Version, PluginUpdateStatus.LocalizeUpdateStatusKind(metadata.Status)),
|
if (metadata.Status == PluginUpdateStatus.StatusKind.Success)
|
||||||
Type = XivChatType.Urgent,
|
{
|
||||||
});
|
chatGui.Print(Locs.DalamudPluginUpdateSuccessful(metadata.Name, metadata.Version));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chatGui.Print(
|
||||||
|
new XivChatEntry
|
||||||
|
{
|
||||||
|
Message = Locs.DalamudPluginUpdateFailed(
|
||||||
|
metadata.Name,
|
||||||
|
metadata.Version,
|
||||||
|
PluginUpdateStatus.LocalizeUpdateStatusKind(metadata.Status)),
|
||||||
|
Type = XivChatType.Urgent,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For a given manifest, determine if the user opted into testing this plugin.
|
/// For a given manifest, determine if the user opted into testing this plugin.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue