feat: expose AddNotification API on UiBuilder

This commit is contained in:
goat 2021-08-24 14:39:39 +02:00
parent 66daa03da3
commit 33cbad9f16
No known key found for this signature in database
GPG key ID: F18F057873895461
7 changed files with 90 additions and 78 deletions

View file

@ -22,6 +22,7 @@ using Dalamud.Game.Gui;
using Dalamud.Game.Gui.FlyText;
using Dalamud.Game.Gui.Toast;
using Dalamud.Game.Text;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.Windowing;
using Dalamud.Memory;
using Dalamud.Plugin;
@ -1056,6 +1057,7 @@ namespace Dalamud.Interface.Internal.Windows
private void DrawImGui()
{
var interfaceManager = Service<InterfaceManager>.Get();
var notifications = Service<NotificationManager>.Get();
ImGui.Text("Monitor count: " + ImGui.GetPlatformIO().Monitors.Size);
ImGui.Text("OverrideGameCursor: " + interfaceManager.OverrideGameCursor);
@ -1082,17 +1084,17 @@ namespace Dalamud.Interface.Internal.Windows
var type = rand.Next(0, 4) switch
{
0 => Notifications.Notification.Type.Error,
1 => Notifications.Notification.Type.Warning,
2 => Notifications.Notification.Type.Info,
3 => Notifications.Notification.Type.Success,
4 => Notifications.Notification.Type.None,
_ => Notifications.Notification.Type.None,
0 => Notifications.NotificationType.Error,
1 => Notifications.NotificationType.Warning,
2 => Notifications.NotificationType.Info,
3 => Notifications.NotificationType.Success,
4 => Notifications.NotificationType.None,
_ => Notifications.NotificationType.None,
};
var text = "Bla bla bla bla bla bla bla bla bla bla bla.\nBla bla bla bla bla bla bla bla bla bla bla bla bla bla.";
interfaceManager.Notifications.AddNotification(text, title, type);
notifications.AddNotification(text, title, type);
}
}

View file

@ -15,6 +15,7 @@ using Dalamud.Configuration.Internal;
using Dalamud.Game.Command;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.Windowing;
using Dalamud.Logging.Internal;
using Dalamud.Plugin;
@ -321,9 +322,8 @@ namespace Dalamud.Interface.Internal.Windows
private void DrawUpdatePluginsButton()
{
var interfaceManager = Service<InterfaceManager>.Get();
var pluginManager = Service<PluginManager>.Get();
var notifications = Service<Notifications>.Get();
var notifications = Service<NotificationManager>.Get();
var ready = pluginManager.PluginsReady && pluginManager.ReposReady;
@ -379,11 +379,11 @@ namespace Dalamud.Interface.Internal.Windows
if (this.updatePluginCount > 0)
{
pluginManager.PrintUpdatedPlugins(this.updatedPlugins, Locs.PluginUpdateHeader_Chatbox);
notifications.AddNotification(Locs.Notifications_UpdatesInstalled(this.updatePluginCount), Locs.Notifications_UpdatesInstalledTitle, Notifications.Notification.Type.Success);
notifications.AddNotification(Locs.Notifications_UpdatesInstalled(this.updatePluginCount), Locs.Notifications_UpdatesInstalledTitle, NotificationType.Success);
}
else if (this.updatePluginCount == 0)
{
notifications.AddNotification(Locs.Notifications_NoUpdatesFound, Locs.Notifications_NoUpdatesFoundTitle, Notifications.Notification.Type.Info);
notifications.AddNotification(Locs.Notifications_NoUpdatesFound, Locs.Notifications_NoUpdatesFoundTitle, NotificationType.Info);
}
}
});
@ -898,8 +898,7 @@ namespace Dalamud.Interface.Internal.Windows
private void DrawAvailablePlugin(RemotePluginManifest manifest, int index)
{
var configuration = Service<DalamudConfiguration>.Get();
var interfaceManager = Service<InterfaceManager>.Get();
var notifications = Service<Notifications>.Get();
var notifications = Service<NotificationManager>.Get();
var pluginManager = Service<PluginManager>.Get();
var useTesting = pluginManager.UseTesting(manifest);
@ -976,11 +975,11 @@ namespace Dalamud.Interface.Internal.Windows
{
if (task.Result.State == PluginState.Loaded)
{
notifications.AddNotification(Locs.Notifications_PluginInstalled(manifest.Name), Locs.Notifications_PluginInstalledTitle, Notifications.Notification.Type.Success);
notifications.AddNotification(Locs.Notifications_PluginInstalled(manifest.Name), Locs.Notifications_PluginInstalledTitle, NotificationType.Success);
}
else
{
notifications.AddNotification(Locs.Notifications_PluginNotInstalled(manifest.Name), Locs.Notifications_PluginNotInstalledTitle, Notifications.Notification.Type.Error);
notifications.AddNotification(Locs.Notifications_PluginNotInstalled(manifest.Name), Locs.Notifications_PluginNotInstalledTitle, NotificationType.Error);
this.ShowErrorModal(Locs.ErrorModal_InstallFail(manifest.Name));
}
}
@ -1248,7 +1247,7 @@ namespace Dalamud.Interface.Internal.Windows
private void DrawPluginControlButton(LocalPlugin plugin)
{
var configuration = Service<DalamudConfiguration>.Get();
var notifications = Service<Notifications>.Get();
var notifications = Service<NotificationManager>.Get();
var pluginManager = Service<PluginManager>.Get();
var startInfo = Service<DalamudStartInfo>.Get();
@ -1293,7 +1292,7 @@ namespace Dalamud.Interface.Internal.Windows
pluginManager.RemovePlugin(plugin);
}
notifications.AddNotification(Locs.Notifications_PluginDisabled(plugin.Manifest.Name), Locs.Notifications_PluginDisabledTitle, Notifications.Notification.Type.Success);
notifications.AddNotification(Locs.Notifications_PluginDisabled(plugin.Manifest.Name), Locs.Notifications_PluginDisabledTitle, NotificationType.Success);
});
}
}