From 779d6b37a55c753e5a8ea8ae52adf971874ee9af Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 5 Oct 2023 18:20:41 +0200 Subject: [PATCH] Improved messaging. --- OtterGui | 2 +- Penumbra.Api | 2 +- .../Manager/ActiveCollectionMigration.cs | 7 ++--- .../Collections/Manager/ActiveCollections.cs | 20 +++++-------- .../Collections/Manager/CollectionStorage.cs | 29 ++++++++----------- .../Manager/IndividualCollections.Files.cs | 24 +++++++-------- .../Collections/Manager/InheritanceManager.cs | 9 +++--- Penumbra/Configuration.cs | 4 +-- Penumbra/Mods/Editor/ModMerger.cs | 5 ++-- Penumbra/Mods/Editor/ModNormalizer.cs | 21 ++++++-------- Penumbra/Mods/Manager/ModImportManager.cs | 4 +-- Penumbra/Mods/Manager/ModOptionEditor.cs | 5 ++-- Penumbra/Mods/ModCreator.cs | 4 +-- Penumbra/Mods/Subclasses/MultiModGroup.cs | 6 ++-- Penumbra/Penumbra.cs | 6 ++-- Penumbra/Services/BackupService.cs | 2 +- .../{ChatService.cs => MessageService.cs} | 14 ++++----- Penumbra/Services/ServiceManager.cs | 3 +- Penumbra/Services/ValidityChecker.cs | 4 +-- Penumbra/UI/AdvancedWindow/FileEditor.cs | 2 +- Penumbra/UI/AdvancedWindow/ItemSwapTab.cs | 3 +- .../ModEditWindow.Materials.MtrlTab.cs | 3 +- .../ModEditWindow.ShaderPackages.cs | 20 ++++++------- Penumbra/UI/ConfigWindow.cs | 2 +- Penumbra/UI/ModsTab/ModFileSystemSelector.cs | 14 ++++----- Penumbra/UI/ModsTab/ModPanelEditTab.cs | 25 ++++++++-------- Penumbra/UI/Tabs/ConfigTabBar.cs | 17 +++++++---- Penumbra/UI/Tabs/MessagesTab.cs | 21 ++++++++++++++ Penumbra/UI/Tabs/SettingsTab.cs | 4 +-- Penumbra/UI/UiHelpers.cs | 3 +- 30 files changed, 146 insertions(+), 139 deletions(-) rename Penumbra/Services/{ChatService.cs => MessageService.cs} (80%) create mode 100644 Penumbra/UI/Tabs/MessagesTab.cs diff --git a/OtterGui b/OtterGui index df07c4ed..96c9055a 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit df07c4ed08e8e6c1188867c7863a19e02c8adb53 +Subproject commit 96c9055a1d8a19d9cdb61f41ddfb372871e204ac diff --git a/Penumbra.Api b/Penumbra.Api index bc9bd5f6..839cc8f2 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit bc9bd5f6bb06e61069704733841868307aed7a5c +Subproject commit 839cc8f270abb6a938d71596bef05b4a9b3ab0ea diff --git a/Penumbra/Collections/Manager/ActiveCollectionMigration.cs b/Penumbra/Collections/Manager/ActiveCollectionMigration.cs index 5872dea1..2f9e9b15 100644 --- a/Penumbra/Collections/Manager/ActiveCollectionMigration.cs +++ b/Penumbra/Collections/Manager/ActiveCollectionMigration.cs @@ -1,6 +1,7 @@ using Dalamud.Interface.Internal.Notifications; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using OtterGui.Classes; using Penumbra.Services; namespace Penumbra.Collections.Manager; @@ -46,10 +47,8 @@ public static class ActiveCollectionMigration { if (!storage.ByName(collectionName, out var collection)) { - Penumbra.Chat.NotificationMessage( - $"Last choice of <{player}>'s Collection {collectionName} is not available, reset to {ModCollection.Empty.Name}.", - "Load Failure", - NotificationType.Warning); + Penumbra.Messager.NotificationMessage( + $"Last choice of <{player}>'s Collection {collectionName} is not available, reset to {ModCollection.Empty.Name}.", NotificationType.Warning); dict.Add(player, ModCollection.Empty); } else diff --git a/Penumbra/Collections/Manager/ActiveCollections.cs b/Penumbra/Collections/Manager/ActiveCollections.cs index 7e6d691e..3da009a3 100644 --- a/Penumbra/Collections/Manager/ActiveCollections.cs +++ b/Penumbra/Collections/Manager/ActiveCollections.cs @@ -2,6 +2,7 @@ using Dalamud.Interface.Internal.Notifications; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; +using OtterGui.Classes; using Penumbra.Communication; using Penumbra.GameData.Actors; using Penumbra.GameData.Enums; @@ -331,10 +332,8 @@ public class ActiveCollections : ISavable, IDisposable ?? (configChanged ? ModCollection.DefaultCollectionName : ModCollection.Empty.Name); if (!_storage.ByName(defaultName, out var defaultCollection)) { - Penumbra.Chat.NotificationMessage( - $"Last choice of {TutorialService.DefaultCollection} {defaultName} is not available, reset to {ModCollection.Empty.Name}.", - "Load Failure", - NotificationType.Warning); + Penumbra.Messager.NotificationMessage( + $"Last choice of {TutorialService.DefaultCollection} {defaultName} is not available, reset to {ModCollection.Empty.Name}.", NotificationType.Warning); Default = ModCollection.Empty; configChanged = true; } @@ -347,9 +346,8 @@ public class ActiveCollections : ISavable, IDisposable var interfaceName = jObject[nameof(Interface)]?.ToObject() ?? Default.Name; if (!_storage.ByName(interfaceName, out var interfaceCollection)) { - Penumbra.Chat.NotificationMessage( - $"Last choice of {TutorialService.InterfaceCollection} {interfaceName} is not available, reset to {ModCollection.Empty.Name}.", - "Load Failure", NotificationType.Warning); + Penumbra.Messager.NotificationMessage( + $"Last choice of {TutorialService.InterfaceCollection} {interfaceName} is not available, reset to {ModCollection.Empty.Name}.", NotificationType.Warning); Interface = ModCollection.Empty; configChanged = true; } @@ -362,9 +360,8 @@ public class ActiveCollections : ISavable, IDisposable var currentName = jObject[nameof(Current)]?.ToObject() ?? Default.Name; if (!_storage.ByName(currentName, out var currentCollection)) { - Penumbra.Chat.NotificationMessage( - $"Last choice of {TutorialService.SelectedCollection} {currentName} is not available, reset to {ModCollection.DefaultCollectionName}.", - "Load Failure", NotificationType.Warning); + Penumbra.Messager.NotificationMessage( + $"Last choice of {TutorialService.SelectedCollection} {currentName} is not available, reset to {ModCollection.DefaultCollectionName}.", NotificationType.Warning); Current = _storage.DefaultNamed; configChanged = true; } @@ -381,8 +378,7 @@ public class ActiveCollections : ISavable, IDisposable { if (!_storage.ByName(typeName, out var typeCollection)) { - Penumbra.Chat.NotificationMessage($"Last choice of {name} Collection {typeName} is not available, removed.", - "Load Failure", + Penumbra.Messager.NotificationMessage($"Last choice of {name} Collection {typeName} is not available, removed.", NotificationType.Warning); configChanged = true; } diff --git a/Penumbra/Collections/Manager/CollectionStorage.cs b/Penumbra/Collections/Manager/CollectionStorage.cs index e50b9bdb..70b2cd13 100644 --- a/Penumbra/Collections/Manager/CollectionStorage.cs +++ b/Penumbra/Collections/Manager/CollectionStorage.cs @@ -1,5 +1,6 @@ using Dalamud.Interface.Internal.Notifications; using OtterGui; +using OtterGui.Classes; using OtterGui.Filesystem; using Penumbra.Communication; using Penumbra.Mods; @@ -102,9 +103,8 @@ public class CollectionStorage : IReadOnlyList, IDisposable { if (!CanAddCollection(name, out var fixedName)) { - Penumbra.Chat.NotificationMessage( - $"The new collection {name} would lead to the same path {fixedName} as one that already exists.", "Warning", - NotificationType.Warning); + Penumbra.Messager.NotificationMessage( + $"The new collection {name} would lead to the same path {fixedName} as one that already exists.", NotificationType.Warning, false); return false; } @@ -113,8 +113,7 @@ public class CollectionStorage : IReadOnlyList, IDisposable _collections.Add(newCollection); _saveService.ImmediateSave(new ModCollectionSave(_modStorage, newCollection)); - Penumbra.Chat.NotificationMessage($"Created new collection {newCollection.AnonymizedName}.", "Success", - NotificationType.Success); + Penumbra.Messager.NotificationMessage($"Created new collection {newCollection.AnonymizedName}.", NotificationType.Success, false); _communicator.CollectionChange.Invoke(CollectionType.Inactive, null, newCollection, string.Empty); return true; } @@ -126,13 +125,13 @@ public class CollectionStorage : IReadOnlyList, IDisposable { if (collection.Index <= ModCollection.Empty.Index || collection.Index >= _collections.Count) { - Penumbra.Chat.NotificationMessage("Can not remove the empty collection.", "Error", NotificationType.Error); + Penumbra.Messager.NotificationMessage("Can not remove the empty collection.", NotificationType.Error, false); return false; } if (collection.Index == DefaultNamed.Index) { - Penumbra.Chat.NotificationMessage("Can not remove the default collection.", "Error", NotificationType.Error); + Penumbra.Messager.NotificationMessage("Can not remove the default collection.", NotificationType.Error, false); return false; } @@ -142,7 +141,7 @@ public class CollectionStorage : IReadOnlyList, IDisposable for (var i = collection.Index; i < Count; ++i) _collections[i].Index = i; - Penumbra.Chat.NotificationMessage($"Deleted collection {collection.AnonymizedName}.", "Success", NotificationType.Success); + Penumbra.Messager.NotificationMessage($"Deleted collection {collection.AnonymizedName}.", NotificationType.Success, false); _communicator.CollectionChange.Invoke(CollectionType.Inactive, collection, null, string.Empty); return true; } @@ -185,23 +184,20 @@ public class CollectionStorage : IReadOnlyList, IDisposable if (!IsValidName(name)) { // TODO: handle better. - Penumbra.Chat.NotificationMessage($"Collection of unsupported name found: {name} is not a valid collection name.", - "Warning", NotificationType.Warning); + Penumbra.Messager.NotificationMessage($"Collection of unsupported name found: {name} is not a valid collection name.", NotificationType.Warning); continue; } if (ByName(name, out _)) { - Penumbra.Chat.NotificationMessage($"Duplicate collection found: {name} already exists. Import skipped.", - "Warning", NotificationType.Warning); + Penumbra.Messager.NotificationMessage($"Duplicate collection found: {name} already exists. Import skipped.", NotificationType.Warning); continue; } var collection = ModCollection.CreateFromData(_saveService, _modStorage, name, version, Count, settings, inheritance); var correctName = _saveService.FileNames.CollectionFile(collection); if (file.FullName != correctName) - Penumbra.Chat.NotificationMessage($"Collection {file.Name} does not correspond to {collection.Name}.", "Warning", - NotificationType.Warning); + Penumbra.Messager.NotificationMessage($"Collection {file.Name} does not correspond to {collection.Name}.", NotificationType.Warning); _collections.Add(collection); } @@ -221,9 +217,8 @@ public class CollectionStorage : IReadOnlyList, IDisposable if (AddCollection(ModCollection.DefaultCollectionName, null)) return _collections[^1]; - Penumbra.Chat.NotificationMessage( - $"Unknown problem creating a collection with the name {ModCollection.DefaultCollectionName}, which is required to exist.", "Error", - NotificationType.Error); + Penumbra.Messager.NotificationMessage( + $"Unknown problem creating a collection with the name {ModCollection.DefaultCollectionName}, which is required to exist.", NotificationType.Error); return Count > 1 ? _collections[1] : _collections[0]; } diff --git a/Penumbra/Collections/Manager/IndividualCollections.Files.cs b/Penumbra/Collections/Manager/IndividualCollections.Files.cs index 21a0c730..fa6019c6 100644 --- a/Penumbra/Collections/Manager/IndividualCollections.Files.cs +++ b/Penumbra/Collections/Manager/IndividualCollections.Files.cs @@ -1,6 +1,7 @@ using Dalamud.Game.ClientState.Objects.Enums; using Dalamud.Interface.Internal.Notifications; using Newtonsoft.Json.Linq; +using OtterGui.Classes; using Penumbra.GameData.Actors; using Penumbra.Services; using Penumbra.String; @@ -56,7 +57,7 @@ public partial class IndividualCollections if (group.Length == 0 || group.Any(i => !i.IsValid)) { changes = true; - Penumbra.Chat.NotificationMessage("Could not load an unknown individual collection, removed.", "Load Failure", + Penumbra.Messager.NotificationMessage("Could not load an unknown individual collection, removed.", NotificationType.Warning); continue; } @@ -65,9 +66,8 @@ public partial class IndividualCollections if (collectionName.Length == 0 || !storage.ByName(collectionName, out var collection)) { changes = true; - Penumbra.Chat.NotificationMessage( + Penumbra.Messager.NotificationMessage( $"Could not load the collection \"{collectionName}\" as individual collection for {identifier}, set to None.", - "Load Failure", NotificationType.Warning); continue; } @@ -75,16 +75,14 @@ public partial class IndividualCollections if (!Add(group, collection)) { changes = true; - Penumbra.Chat.NotificationMessage($"Could not add an individual collection for {identifier}, removed.", - "Load Failure", + Penumbra.Messager.NotificationMessage($"Could not add an individual collection for {identifier}, removed.", NotificationType.Warning); } } catch (Exception e) { changes = true; - Penumbra.Chat.NotificationMessage($"Could not load an unknown individual collection, removed:\n{e}", "Load Failure", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not load an unknown individual collection, removed.", NotificationType.Error); } } @@ -124,9 +122,9 @@ public partial class IndividualCollections if (Add($"{_actorService.AwaitedService.Data.ToName(kind, dataId)} ({kind.ToName()})", group, collection)) Penumbra.Log.Information($"Migrated {name} ({kind.ToName()}) to NPC Identifiers [{ids}]."); else - Penumbra.Chat.NotificationMessage( + Penumbra.Messager.NotificationMessage( $"Could not migrate {name} ({collection.AnonymizedName}) which was assumed to be a {kind.ToName()} with IDs [{ids}], please look through your individual collections.", - "Migration Failure", NotificationType.Error); + NotificationType.Error); } // If it is not a valid NPC name, check if it can be a player name. else if (ActorManager.VerifyPlayerName(name)) @@ -140,15 +138,15 @@ public partial class IndividualCollections }, collection)) Penumbra.Log.Information($"Migrated {shortName} ({collection.AnonymizedName}) to Player Identifier."); else - Penumbra.Chat.NotificationMessage( + Penumbra.Messager.NotificationMessage( $"Could not migrate {shortName} ({collection.AnonymizedName}), please look through your individual collections.", - "Migration Failure", NotificationType.Error); + NotificationType.Error); } else { - Penumbra.Chat.NotificationMessage( + Penumbra.Messager.NotificationMessage( $"Could not migrate {name} ({collection.AnonymizedName}), which can not be a player name nor is it a known NPC name, please look through your individual collections.", - "Migration Failure", NotificationType.Error); + NotificationType.Error); } } } diff --git a/Penumbra/Collections/Manager/InheritanceManager.cs b/Penumbra/Collections/Manager/InheritanceManager.cs index 4c1bdc5a..771f9463 100644 --- a/Penumbra/Collections/Manager/InheritanceManager.cs +++ b/Penumbra/Collections/Manager/InheritanceManager.cs @@ -1,5 +1,6 @@ using Dalamud.Interface.Internal.Notifications; using OtterGui; +using OtterGui.Classes; using OtterGui.Filesystem; using Penumbra.Communication; using Penumbra.Mods.Manager; @@ -143,14 +144,12 @@ public class InheritanceManager : IDisposable continue; changes = true; - Penumbra.Chat.NotificationMessage($"{collection.Name} can not inherit from {subCollection.Name}, removed.", "Warning", - NotificationType.Warning); + Penumbra.Messager.NotificationMessage($"{collection.Name} can not inherit from {subCollection.Name}, removed.", NotificationType.Warning); } else { - Penumbra.Chat.NotificationMessage( - $"Inherited collection {subCollectionName} for {collection.AnonymizedName} does not exist, it was removed.", "Warning", - NotificationType.Warning); + Penumbra.Messager.NotificationMessage( + $"Inherited collection {subCollectionName} for {collection.AnonymizedName} does not exist, it was removed.", NotificationType.Warning); changes = true; } } diff --git a/Penumbra/Configuration.cs b/Penumbra/Configuration.cs index 7c9ae665..d221b4a2 100644 --- a/Penumbra/Configuration.cs +++ b/Penumbra/Configuration.cs @@ -137,9 +137,9 @@ public class Configuration : IPluginConfiguration, ISavable } catch (Exception ex) { - Penumbra.Chat.NotificationMessage(ex, + Penumbra.Messager.NotificationMessage(ex, "Error reading Configuration, reverting to default.\nYou may be able to restore your configuration using the rolling backups in the XIVLauncher/backups/Penumbra directory.", - "Error reading Configuration", "Error", NotificationType.Error); + "Error reading Configuration", NotificationType.Error); } migrator.Migrate(utility, this); diff --git a/Penumbra/Mods/Editor/ModMerger.cs b/Penumbra/Mods/Editor/ModMerger.cs index f90f6c0a..37ffdcfe 100644 --- a/Penumbra/Mods/Editor/ModMerger.cs +++ b/Penumbra/Mods/Editor/ModMerger.cs @@ -1,6 +1,7 @@ using Dalamud.Interface.Internal.Notifications; using Dalamud.Utility; using OtterGui; +using OtterGui.Classes; using Penumbra.Api.Enums; using Penumbra.Communication; using Penumbra.Meta.Manipulations; @@ -81,9 +82,7 @@ public class ModMerger : IDisposable catch (Exception ex) { Error = ex; - Penumbra.Chat.NotificationMessage( - $"Could not merge {MergeFromMod!.Name} into {MergeToMod!.Name}, cleaning up changes.:\n{ex}", "Failure", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(ex, $"Could not merge {MergeFromMod!.Name} into {MergeToMod!.Name}, cleaning up changes.", NotificationType.Error, false); FailureCleanup(); DataCleanup(); } diff --git a/Penumbra/Mods/Editor/ModNormalizer.cs b/Penumbra/Mods/Editor/ModNormalizer.cs index eebc8ab4..3610c99a 100644 --- a/Penumbra/Mods/Editor/ModNormalizer.cs +++ b/Penumbra/Mods/Editor/ModNormalizer.cs @@ -1,5 +1,6 @@ using Dalamud.Interface.Internal.Notifications; using OtterGui; +using OtterGui.Classes; using OtterGui.Tasks; using Penumbra.Mods.Manager; using Penumbra.Mods.Subclasses; @@ -74,7 +75,7 @@ public class ModNormalizer } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not normalize mod:\n{e}", "Failure", NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not normalize mod {Mod.Name}.", NotificationType.Error, false); } finally { @@ -87,17 +88,15 @@ public class ModNormalizer { if (Directory.Exists(_normalizationDirName)) { - Penumbra.Chat.NotificationMessage("Could not normalize mod:\n" - + "The directory TmpNormalization may not already exist when normalizing a mod.", "Failure", - NotificationType.Error); + Penumbra.Messager.NotificationMessage($"Could not normalize mod {Mod.Name}:\n" + + "The directory TmpNormalization may not already exist when normalizing a mod.", NotificationType.Error, false); return false; } if (Directory.Exists(_oldDirName)) { - Penumbra.Chat.NotificationMessage("Could not normalize mod:\n" - + "The directory TmpNormalizationOld may not already exist when normalizing a mod.", "Failure", - NotificationType.Error); + Penumbra.Messager.NotificationMessage($"Could not normalize mod {Mod.Name}:\n" + + "The directory TmpNormalizationOld may not already exist when normalizing a mod.", NotificationType.Error, false); return false; } @@ -201,7 +200,7 @@ public class ModNormalizer } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not normalize mod:\n{e}", "Failure", NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not normalize mod {Mod.Name}.", NotificationType.Error, false); } return false; @@ -229,8 +228,7 @@ public class ModNormalizer } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not move old files out of the way while normalizing mod mod:\n{e}", "Failure", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not move old files out of the way while normalizing mod {Mod.Name}.", NotificationType.Error, false); } return false; @@ -253,8 +251,7 @@ public class ModNormalizer } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not move new files into the mod while normalizing mod mod:\n{e}", "Failure", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not move new files into the mod while normalizing mod {Mod.Name}.", NotificationType.Error, false); foreach (var dir in Mod.ModPath.EnumerateDirectories()) { if (dir.FullName.Equals(_oldDirName, StringComparison.OrdinalIgnoreCase) diff --git a/Penumbra/Mods/Manager/ModImportManager.cs b/Penumbra/Mods/Manager/ModImportManager.cs index 96cf146b..73571ea4 100644 --- a/Penumbra/Mods/Manager/ModImportManager.cs +++ b/Penumbra/Mods/Manager/ModImportManager.cs @@ -1,4 +1,5 @@ using Dalamud.Interface.Internal.Notifications; +using OtterGui.Classes; using Penumbra.Import; using Penumbra.Mods.Editor; @@ -42,8 +43,7 @@ public class ModImportManager : IDisposable if (File.Exists(s)) return true; - Penumbra.Chat.NotificationMessage($"Failed to import queued mod at {s}, the file does not exist.", "Warning", - NotificationType.Warning); + Penumbra.Messager.NotificationMessage($"Failed to import queued mod at {s}, the file does not exist.", NotificationType.Warning, false); return false; }).Select(s => new FileInfo(s)).ToArray(); diff --git a/Penumbra/Mods/Manager/ModOptionEditor.cs b/Penumbra/Mods/Manager/ModOptionEditor.cs index 3eeb13c6..0a3034fc 100644 --- a/Penumbra/Mods/Manager/ModOptionEditor.cs +++ b/Penumbra/Mods/Manager/ModOptionEditor.cs @@ -1,5 +1,6 @@ using Dalamud.Interface.Internal.Notifications; using OtterGui; +using OtterGui.Classes; using OtterGui.Filesystem; using Penumbra.Api.Enums; using Penumbra.Meta.Manipulations; @@ -395,9 +396,9 @@ public class ModOptionEditor return true; if (message) - Penumbra.Chat.NotificationMessage( + Penumbra.Messager.NotificationMessage( $"Could not name option {newName} because option with same filename {path} already exists.", - "Warning", NotificationType.Warning); + NotificationType.Warning, false); return false; } diff --git a/Penumbra/Mods/ModCreator.cs b/Penumbra/Mods/ModCreator.cs index 236f1539..98770edc 100644 --- a/Penumbra/Mods/ModCreator.cs +++ b/Penumbra/Mods/ModCreator.cs @@ -2,6 +2,7 @@ using Dalamud.Interface.Internal.Notifications; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; +using OtterGui.Classes; using OtterGui.Filesystem; using Penumbra.Api.Enums; using Penumbra.GameData; @@ -45,8 +46,7 @@ public partial class ModCreator } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not create directory for new Mod {newName}:\n{e}", "Failure", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not create directory for new Mod {newName}.", NotificationType.Error, false); return null; } } diff --git a/Penumbra/Mods/Subclasses/MultiModGroup.cs b/Penumbra/Mods/Subclasses/MultiModGroup.cs index 4d29c58d..07f84722 100644 --- a/Penumbra/Mods/Subclasses/MultiModGroup.cs +++ b/Penumbra/Mods/Subclasses/MultiModGroup.cs @@ -2,6 +2,7 @@ using Dalamud.Interface.Internal.Notifications; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OtterGui; +using OtterGui.Classes; using OtterGui.Filesystem; using Penumbra.Api.Enums; @@ -54,9 +55,8 @@ public sealed class MultiModGroup : IModGroup { if (ret.PrioritizedOptions.Count == IModGroup.MaxMultiOptions) { - Penumbra.Chat.NotificationMessage( - $"Multi Group {ret.Name} has more than {IModGroup.MaxMultiOptions} options, ignoring excessive options.", "Warning", - NotificationType.Warning); + Penumbra.Messager.NotificationMessage( + $"Multi Group {ret.Name} in {mod.Name} has more than {IModGroup.MaxMultiOptions} options, ignoring excessive options.", NotificationType.Warning); break; } diff --git a/Penumbra/Penumbra.cs b/Penumbra/Penumbra.cs index 0519baae..73d1013e 100644 --- a/Penumbra/Penumbra.cs +++ b/Penumbra/Penumbra.cs @@ -31,7 +31,7 @@ public class Penumbra : IDalamudPlugin => "Penumbra"; public static readonly Logger Log = new(); - public static ChatService Chat { get; private set; } = null!; + public static MessageService Messager { get; private set; } = null!; private readonly ValidityChecker _validityChecker; private readonly ResidentResourceManager _residentResources; @@ -55,7 +55,7 @@ public class Penumbra : IDalamudPlugin var startTimer = new StartTracker(); using var timer = startTimer.Measure(StartTimeType.Total); _services = ServiceManager.CreateProvider(this, pluginInterface, Log, startTimer); - Chat = _services.GetRequiredService(); + Messager = _services.GetRequiredService(); _validityChecker = _services.GetRequiredService(); var startup = _services.GetRequiredService().GetDalamudConfig(DalamudServices.WaitingForPluginsOption, out bool s) ? s.ToString() @@ -118,7 +118,7 @@ public class Penumbra : IDalamudPlugin _communicatorService.ChangedItemClick.Subscribe((button, it) => { if (button == MouseButton.Left && it is Item item) - Chat.LinkItem(item); + Messager.LinkItem(item); }, ChangedItemClick.Priority.Link); } diff --git a/Penumbra/Services/BackupService.cs b/Penumbra/Services/BackupService.cs index f6e2c3e4..e623be3e 100644 --- a/Penumbra/Services/BackupService.cs +++ b/Penumbra/Services/BackupService.cs @@ -41,7 +41,7 @@ public class BackupService { Penumbra.Log.Error($"Failed to load {fileName}, trying to restore from backup:\n{ex}"); Backup.TryGetFile(new DirectoryInfo(fileNames.ConfigDirectory), fileName, out ret, out var messages, JObject.Parse); - Penumbra.Chat.NotificationMessage(messages); + Penumbra.Messager.NotificationMessage(messages); } return ret; diff --git a/Penumbra/Services/ChatService.cs b/Penumbra/Services/MessageService.cs similarity index 80% rename from Penumbra/Services/ChatService.cs rename to Penumbra/Services/MessageService.cs index 3e715a4f..c893b00f 100644 --- a/Penumbra/Services/ChatService.cs +++ b/Penumbra/Services/MessageService.cs @@ -1,20 +1,18 @@ using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; -using Dalamud.Plugin; +using Dalamud.Interface; using Dalamud.Plugin.Services; using Lumina.Excel.GeneratedSheets; using OtterGui.Log; namespace Penumbra.Services; -public class ChatService : OtterGui.Classes.ChatService +public class MessageService : OtterGui.Classes.MessageService { - private readonly IChatGui _chat; - - public ChatService(Logger log, DalamudPluginInterface pi, IChatGui chat) - : base(log, pi) - => _chat = chat; + public MessageService(Logger log, UiBuilder uiBuilder, IChatGui chat) + : base(log, uiBuilder, chat) + { } public void LinkItem(Item item) { @@ -37,7 +35,7 @@ public class ChatService : OtterGui.Classes.ChatService var payload = new SeString(payloadList); - _chat.Print(new XivChatEntry + Chat.Print(new XivChatEntry { Message = payload, }); diff --git a/Penumbra/Services/ServiceManager.cs b/Penumbra/Services/ServiceManager.cs index 9e3b9b1a..84f89f6d 100644 --- a/Penumbra/Services/ServiceManager.cs +++ b/Penumbra/Services/ServiceManager.cs @@ -65,7 +65,7 @@ public static class ServiceManager .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton(); @@ -165,6 +165,7 @@ public static class ServiceManager .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() diff --git a/Penumbra/Services/ValidityChecker.cs b/Penumbra/Services/ValidityChecker.cs index b8d9b30a..749da5b9 100644 --- a/Penumbra/Services/ValidityChecker.cs +++ b/Penumbra/Services/ValidityChecker.cs @@ -1,5 +1,6 @@ using Dalamud.Interface.Internal.Notifications; using Dalamud.Plugin; +using OtterGui.Classes; namespace Penumbra.Services; @@ -33,8 +34,7 @@ public class ValidityChecker public void LogExceptions() { if (ImcExceptions.Count > 0) - Penumbra.Chat.NotificationMessage($"{ImcExceptions} IMC Exceptions thrown during Penumbra load. Please repair your game files.", - "Warning", NotificationType.Warning); + Penumbra.Messager.NotificationMessage($"{ImcExceptions} IMC Exceptions thrown during Penumbra load. Please repair your game files.", NotificationType.Warning); } // Because remnants of penumbra in devPlugins cause issues, we check for them to warn users to remove them. diff --git a/Penumbra/UI/AdvancedWindow/FileEditor.cs b/Penumbra/UI/AdvancedWindow/FileEditor.cs index 9354afaf..b84fa84c 100644 --- a/Penumbra/UI/AdvancedWindow/FileEditor.cs +++ b/Penumbra/UI/AdvancedWindow/FileEditor.cs @@ -137,7 +137,7 @@ public class FileEditor : IDisposable where T : class, IWritable } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not export {_defaultPath}:\n{e}", "Error", NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not export {_defaultPath}.", NotificationType.Error); } }, _getInitialPath(), false); diff --git a/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs b/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs index 967e8d01..8597bc0c 100644 --- a/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs +++ b/Penumbra/UI/AdvancedWindow/ItemSwapTab.cs @@ -4,6 +4,7 @@ using Dalamud.Utility; using ImGuiNET; using Lumina.Excel.GeneratedSheets; using OtterGui; +using OtterGui.Classes; using OtterGui.Raii; using OtterGui.Widgets; using Penumbra.Api.Enums; @@ -321,7 +322,7 @@ public class ItemSwapTab : IDisposable, ITab } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not create new Swap Option:\n{e}", "Error", NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, "Could not create new Swap Option.", NotificationType.Error, false); try { if (optionCreated && _selectedGroup != null) diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.MtrlTab.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.MtrlTab.cs index ebe980d7..20efe757 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.MtrlTab.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Materials.MtrlTab.cs @@ -113,8 +113,7 @@ public partial class ModEditWindow LoadedShpkPath = FullPath.Empty; LoadedShpkPathName = string.Empty; AssociatedShpk = null; - Penumbra.Chat.NotificationMessage($"Could not load {LoadedShpkPath.ToPath()}:\n{e}", "Penumbra Advanced Editing", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not load {LoadedShpkPath.ToPath()}.", NotificationType.Error, false); } if (LoadedShpkPath.InternalName.IsEmpty) diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.ShaderPackages.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.ShaderPackages.cs index 6b867b27..804feae1 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.ShaderPackages.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.ShaderPackages.cs @@ -4,6 +4,7 @@ using ImGuiNET; using Lumina.Misc; using OtterGui.Raii; using OtterGui; +using OtterGui.Classes; using Penumbra.GameData; using Penumbra.GameData.Data; using Penumbra.GameData.Files; @@ -87,15 +88,14 @@ public partial class ModEditWindow } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not export {defaultName}{tab.Extension} to {name}:\n{e.Message}", - "Penumbra Advanced Editing", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not export {defaultName}{tab.Extension} to {name}.", + NotificationType.Error, false); return; } - Penumbra.Chat.NotificationMessage( - $"Shader Program Blob {defaultName}{tab.Extension} exported successfully to {Path.GetFileName(name)}", - "Penumbra Advanced Editing", NotificationType.Success); + Penumbra.Messager.NotificationMessage( + $"Shader Program Blob {defaultName}{tab.Extension} exported successfully to {Path.GetFileName(name)}.", + NotificationType.Success, false); }, null, false); } @@ -116,8 +116,7 @@ public partial class ModEditWindow } catch (Exception e) { - Penumbra.Chat.NotificationMessage($"Could not import {name}:\n{e.Message}", "Penumbra Advanced Editing", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Could not import {name}.", NotificationType.Error, false); return; } @@ -129,9 +128,8 @@ public partial class ModEditWindow catch (Exception e) { tab.Shpk.SetInvalid(); - Penumbra.Chat.NotificationMessage($"Failed to update resources after importing {name}:\n{e.Message}", - "Penumbra Advanced Editing", - NotificationType.Error); + Penumbra.Messager.NotificationMessage(e, $"Failed to update resources after importing {name}.", NotificationType.Error, + false); return; } diff --git a/Penumbra/UI/ConfigWindow.cs b/Penumbra/UI/ConfigWindow.cs index 5cedd824..0f209686 100644 --- a/Penumbra/UI/ConfigWindow.cs +++ b/Penumbra/UI/ConfigWindow.cs @@ -142,7 +142,7 @@ public sealed class ConfigWindow : Window ImGui.NewLine(); ImGui.NewLine(); - CustomGui.DrawDiscordButton(Penumbra.Chat, 0); + CustomGui.DrawDiscordButton(Penumbra.Messager, 0); ImGui.SameLine(); UiHelpers.DrawSupportButton(_penumbra!); ImGui.NewLine(); diff --git a/Penumbra/UI/ModsTab/ModFileSystemSelector.cs b/Penumbra/UI/ModsTab/ModFileSystemSelector.cs index 215a0269..cc4ceb55 100644 --- a/Penumbra/UI/ModsTab/ModFileSystemSelector.cs +++ b/Penumbra/UI/ModsTab/ModFileSystemSelector.cs @@ -18,14 +18,14 @@ using Penumbra.Mods.Manager; using Penumbra.Mods.Subclasses; using Penumbra.Services; using Penumbra.UI.Classes; -using ChatService = Penumbra.Services.ChatService; +using MessageService = Penumbra.Services.MessageService; namespace Penumbra.UI.ModsTab; public sealed class ModFileSystemSelector : FileSystemSelector { private readonly CommunicatorService _communicator; - private readonly ChatService _chat; + private readonly MessageService _messager; private readonly Configuration _config; private readonly FileDialogService _fileDialog; private readonly ModManager _modManager; @@ -37,7 +37,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector Penumbra.Chat.NotificationMessage(e.Message, "Failure", NotificationType.Warning); + => Penumbra.Messager.NotificationMessage(e, e.Message, NotificationType.Warning); #endregion diff --git a/Penumbra/UI/ModsTab/ModPanelEditTab.cs b/Penumbra/UI/ModsTab/ModPanelEditTab.cs index 44c40247..18d0e613 100644 --- a/Penumbra/UI/ModsTab/ModPanelEditTab.cs +++ b/Penumbra/UI/ModsTab/ModPanelEditTab.cs @@ -6,6 +6,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Widgets; +using OtterGui.Classes; using Penumbra.Api.Enums; using Penumbra.Mods; using Penumbra.Mods.Editor; @@ -18,15 +19,15 @@ namespace Penumbra.UI.ModsTab; public class ModPanelEditTab : ITab { - private readonly ChatService _chat; - private readonly FilenameService _filenames; - private readonly ModManager _modManager; - private readonly ModExportManager _modExportManager; - private readonly ModFileSystem _fileSystem; - private readonly ModFileSystemSelector _selector; - private readonly ModEditWindow _editWindow; - private readonly ModEditor _editor; - private readonly Configuration _config; + private readonly Services.MessageService _messager; + private readonly FilenameService _filenames; + private readonly ModManager _modManager; + private readonly ModExportManager _modExportManager; + private readonly ModFileSystem _fileSystem; + private readonly ModFileSystemSelector _selector; + private readonly ModEditWindow _editWindow; + private readonly ModEditor _editor; + private readonly Configuration _config; private readonly TagButtons _modTags = new(); @@ -35,13 +36,13 @@ public class ModPanelEditTab : ITab private ModFileSystem.Leaf _leaf = null!; private Mod _mod = null!; - public ModPanelEditTab(ModManager modManager, ModFileSystemSelector selector, ModFileSystem fileSystem, ChatService chat, + public ModPanelEditTab(ModManager modManager, ModFileSystemSelector selector, ModFileSystem fileSystem, Services.MessageService messager, ModEditWindow editWindow, ModEditor editor, FilenameService filenames, ModExportManager modExportManager, Configuration config) { _modManager = modManager; _selector = selector; _fileSystem = fileSystem; - _chat = chat; + _messager = messager; _editWindow = editWindow; _editor = editor; _filenames = filenames; @@ -75,7 +76,7 @@ public class ModPanelEditTab : ITab } catch (Exception e) { - _chat.NotificationMessage(e.Message, "Warning", NotificationType.Warning); + _messager.NotificationMessage(e.Message, NotificationType.Warning, false); } UiHelpers.DefaultLineSpace(); diff --git a/Penumbra/UI/Tabs/ConfigTabBar.cs b/Penumbra/UI/Tabs/ConfigTabBar.cs index ee66ca86..1cc29d88 100644 --- a/Penumbra/UI/Tabs/ConfigTabBar.cs +++ b/Penumbra/UI/Tabs/ConfigTabBar.cs @@ -19,7 +19,8 @@ public class ConfigTabBar : IDisposable public readonly DebugTab Debug; public readonly ResourceTab Resource; public readonly Watcher Watcher; - public readonly OnScreenTab OnScreenTab; + public readonly OnScreenTab OnScreen; + public readonly MessagesTab Messages; public readonly ITab[] Tabs; @@ -28,7 +29,7 @@ public class ConfigTabBar : IDisposable public ConfigTabBar(CommunicatorService communicator, SettingsTab settings, ModsTab mods, CollectionsTab collections, ChangedItemsTab changedItems, EffectiveTab effective, DebugTab debug, ResourceTab resource, Watcher watcher, - OnScreenTab onScreenTab) + OnScreenTab onScreen, MessagesTab messages) { _communicator = communicator; @@ -40,7 +41,8 @@ public class ConfigTabBar : IDisposable Debug = debug; Resource = resource; Watcher = watcher; - OnScreenTab = onScreenTab; + OnScreen = onScreen; + Messages = messages; Tabs = new ITab[] { Settings, @@ -48,10 +50,11 @@ public class ConfigTabBar : IDisposable Mods, ChangedItems, Effective, - OnScreenTab, + OnScreen, Debug, Resource, Watcher, + Messages, }; _communicator.SelectTab.Subscribe(OnSelectTab, Communication.SelectTab.Priority.ConfigTabBar); } @@ -75,10 +78,11 @@ public class ConfigTabBar : IDisposable TabType.Collections => Collections.Label, TabType.ChangedItems => ChangedItems.Label, TabType.EffectiveChanges => Effective.Label, - TabType.OnScreen => OnScreenTab.Label, + TabType.OnScreen => OnScreen.Label, TabType.ResourceWatcher => Watcher.Label, TabType.Debug => Debug.Label, TabType.ResourceManager => Resource.Label, + TabType.Messages => Messages.Label, _ => ReadOnlySpan.Empty, }; @@ -90,7 +94,8 @@ public class ConfigTabBar : IDisposable if (label == Settings.Label) return TabType.Settings; if (label == ChangedItems.Label) return TabType.ChangedItems; if (label == Effective.Label) return TabType.EffectiveChanges; - if (label == OnScreenTab.Label) return TabType.OnScreen; + if (label == OnScreen.Label) return TabType.OnScreen; + if (label == Messages.Label) return TabType.Messages; if (label == Watcher.Label) return TabType.ResourceWatcher; if (label == Debug.Label) return TabType.Debug; if (label == Resource.Label) return TabType.ResourceManager; diff --git a/Penumbra/UI/Tabs/MessagesTab.cs b/Penumbra/UI/Tabs/MessagesTab.cs new file mode 100644 index 00000000..e834a4b4 --- /dev/null +++ b/Penumbra/UI/Tabs/MessagesTab.cs @@ -0,0 +1,21 @@ +using OtterGui.Widgets; +using Penumbra.Services; + +namespace Penumbra.UI.Tabs; + +public class MessagesTab : ITab +{ + public ReadOnlySpan Label + => "Messages"u8; + + private readonly MessageService _messages; + + public MessagesTab(MessageService messages) + => _messages = messages; + + public bool IsVisible + => _messages.Count > 0; + + public void DrawContent() + => _messages.Draw(); +} diff --git a/Penumbra/UI/Tabs/SettingsTab.cs b/Penumbra/UI/Tabs/SettingsTab.cs index 7c350106..32bd6b8f 100644 --- a/Penumbra/UI/Tabs/SettingsTab.cs +++ b/Penumbra/UI/Tabs/SettingsTab.cs @@ -851,10 +851,10 @@ public class SettingsTab : ITab UiHelpers.DrawSupportButton(_penumbra); ImGui.SetCursorPos(new Vector2(xPos, 0)); - CustomGui.DrawDiscordButton(Penumbra.Chat, width); + CustomGui.DrawDiscordButton(Penumbra.Messager, width); ImGui.SetCursorPos(new Vector2(xPos, 2 * ImGui.GetFrameHeightWithSpacing())); - CustomGui.DrawGuideButton(Penumbra.Chat, width); + CustomGui.DrawGuideButton(Penumbra.Messager, width); ImGui.SetCursorPos(new Vector2(xPos, 3 * ImGui.GetFrameHeightWithSpacing())); if (ImGui.Button("Restart Tutorial", new Vector2(width, 0))) diff --git a/Penumbra/UI/UiHelpers.cs b/Penumbra/UI/UiHelpers.cs index a37d8e77..6c64bd55 100644 --- a/Penumbra/UI/UiHelpers.cs +++ b/Penumbra/UI/UiHelpers.cs @@ -2,6 +2,7 @@ using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Utility; using ImGuiNET; using OtterGui; +using OtterGui.Classes; using OtterGui.Raii; using Penumbra.Interop.Structs; using Penumbra.String; @@ -56,7 +57,7 @@ public static class UiHelpers var text = penumbra.GatherSupportInformation(); ImGui.SetClipboardText(text); - Penumbra.Chat.NotificationMessage($"Copied Support Info to Clipboard.", "Success", NotificationType.Success); + Penumbra.Messager.NotificationMessage($"Copied Support Info to Clipboard.", NotificationType.Success, false); } /// Draw a button to open a specific directory in a file explorer.