Rename ChatService and move some support buttons to OtterGui.

This commit is contained in:
Ottermandias 2023-06-18 13:24:13 +02:00
parent 3f1d84343a
commit 5f916efb13
22 changed files with 56 additions and 104 deletions

@ -1 +1 @@
Subproject commit ced7068b8bf9729018c9f03f9a8e9354b9e7ca3e
Subproject commit a79abe203da2673f71a4e31422c6058375fb8dec

View file

@ -50,7 +50,7 @@ public static class ActiveCollectionMigration
{
if (!storage.ByName(collectionName, out var collection))
{
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Last choice of <{player}>'s Collection {collectionName} is not available, reset to {ModCollection.Empty.Name}.", "Load Failure",
NotificationType.Warning);
dict.Add(player, ModCollection.Empty);

View file

@ -335,7 +335,7 @@ public class ActiveCollections : ISavable, IDisposable
?? (configChanged ? ModCollection.DefaultCollectionName : ModCollection.Empty.Name);
if (!_storage.ByName(defaultName, out var defaultCollection))
{
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Last choice of {TutorialService.DefaultCollection} {defaultName} is not available, reset to {ModCollection.Empty.Name}.",
"Load Failure",
NotificationType.Warning);
@ -351,7 +351,7 @@ public class ActiveCollections : ISavable, IDisposable
var interfaceName = jObject[nameof(Interface)]?.ToObject<string>() ?? Default.Name;
if (!_storage.ByName(interfaceName, out var interfaceCollection))
{
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Last choice of {TutorialService.InterfaceCollection} {interfaceName} is not available, reset to {ModCollection.Empty.Name}.",
"Load Failure", NotificationType.Warning);
Interface = ModCollection.Empty;
@ -366,7 +366,7 @@ public class ActiveCollections : ISavable, IDisposable
var currentName = jObject[nameof(Current)]?.ToObject<string>() ?? Default.Name;
if (!_storage.ByName(currentName, out var currentCollection))
{
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Last choice of {TutorialService.SelectedCollection} {currentName} is not available, reset to {ModCollection.DefaultCollectionName}.",
"Load Failure", NotificationType.Warning);
Current = _storage.DefaultNamed;
@ -385,7 +385,7 @@ public class ActiveCollections : ISavable, IDisposable
{
if (!_storage.ByName(typeName, out var typeCollection))
{
Penumbra.ChatService.NotificationMessage($"Last choice of {name} Collection {typeName} is not available, removed.",
Penumbra.Chat.NotificationMessage($"Last choice of {name} Collection {typeName} is not available, removed.",
"Load Failure",
NotificationType.Warning);
configChanged = true;

View file

@ -107,7 +107,7 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable
{
if (!CanAddCollection(name, out var fixedName))
{
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"The new collection {name} would lead to the same path {fixedName} as one that already exists.", "Warning",
NotificationType.Warning);
return false;
@ -118,7 +118,7 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable
_collections.Add(newCollection);
_saveService.ImmediateSave(new ModCollectionSave(_modStorage, newCollection));
Penumbra.ChatService.NotificationMessage($"Created new collection {newCollection.AnonymizedName}.", "Success",
Penumbra.Chat.NotificationMessage($"Created new collection {newCollection.AnonymizedName}.", "Success",
NotificationType.Success);
_communicator.CollectionChange.Invoke(CollectionType.Inactive, null, newCollection, string.Empty);
return true;
@ -131,13 +131,13 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable
{
if (collection.Index <= ModCollection.Empty.Index || collection.Index >= _collections.Count)
{
Penumbra.ChatService.NotificationMessage("Can not remove the empty collection.", "Error", NotificationType.Error);
Penumbra.Chat.NotificationMessage("Can not remove the empty collection.", "Error", NotificationType.Error);
return false;
}
if (collection.Index == DefaultNamed.Index)
{
Penumbra.ChatService.NotificationMessage("Can not remove the default collection.", "Error", NotificationType.Error);
Penumbra.Chat.NotificationMessage("Can not remove the default collection.", "Error", NotificationType.Error);
return false;
}
@ -147,7 +147,7 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable
for (var i = collection.Index; i < Count; ++i)
_collections[i].Index = i;
Penumbra.ChatService.NotificationMessage($"Deleted collection {collection.AnonymizedName}.", "Success", NotificationType.Success);
Penumbra.Chat.NotificationMessage($"Deleted collection {collection.AnonymizedName}.", "Success", NotificationType.Success);
_communicator.CollectionChange.Invoke(CollectionType.Inactive, collection, null, string.Empty);
return true;
}
@ -190,14 +190,14 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable
if (!IsValidName(name))
{
// TODO: handle better.
Penumbra.ChatService.NotificationMessage($"Collection of unsupported name found: {name} is not a valid collection name.",
Penumbra.Chat.NotificationMessage($"Collection of unsupported name found: {name} is not a valid collection name.",
"Warning", NotificationType.Warning);
continue;
}
if (ByName(name, out _))
{
Penumbra.ChatService.NotificationMessage($"Duplicate collection found: {name} already exists. Import skipped.",
Penumbra.Chat.NotificationMessage($"Duplicate collection found: {name} already exists. Import skipped.",
"Warning", NotificationType.Warning);
continue;
}
@ -205,7 +205,7 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable
var collection = ModCollection.CreateFromData(_saveService, _modStorage, name, version, Count, settings, inheritance);
var correctName = _saveService.FileNames.CollectionFile(collection);
if (file.FullName != correctName)
Penumbra.ChatService.NotificationMessage($"Collection {file.Name} does not correspond to {collection.Name}.", "Warning",
Penumbra.Chat.NotificationMessage($"Collection {file.Name} does not correspond to {collection.Name}.", "Warning",
NotificationType.Warning);
_collections.Add(collection);
}
@ -226,7 +226,7 @@ public class CollectionStorage : IReadOnlyList<ModCollection>, IDisposable
if (AddCollection(ModCollection.DefaultCollectionName, null))
return _collections[^1];
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Unknown problem creating a collection with the name {ModCollection.DefaultCollectionName}, which is required to exist.", "Error",
NotificationType.Error);
return Count > 1 ? _collections[1] : _collections[0];

View file

@ -57,7 +57,7 @@ public partial class IndividualCollections
if (group.Length == 0 || group.Any(i => !i.IsValid))
{
changes = true;
Penumbra.ChatService.NotificationMessage("Could not load an unknown individual collection, removed.", "Load Failure",
Penumbra.Chat.NotificationMessage("Could not load an unknown individual collection, removed.", "Load Failure",
NotificationType.Warning);
continue;
}
@ -66,7 +66,7 @@ public partial class IndividualCollections
if (collectionName.Length == 0 || !storage.ByName(collectionName, out var collection))
{
changes = true;
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Could not load the collection \"{collectionName}\" as individual collection for {identifier}, set to None.",
"Load Failure",
NotificationType.Warning);
@ -76,7 +76,7 @@ public partial class IndividualCollections
if (!Add(group, collection))
{
changes = true;
Penumbra.ChatService.NotificationMessage($"Could not add an individual collection for {identifier}, removed.",
Penumbra.Chat.NotificationMessage($"Could not add an individual collection for {identifier}, removed.",
"Load Failure",
NotificationType.Warning);
}
@ -84,7 +84,7 @@ public partial class IndividualCollections
catch (Exception e)
{
changes = true;
Penumbra.ChatService.NotificationMessage($"Could not load an unknown individual collection, removed:\n{e}", "Load Failure",
Penumbra.Chat.NotificationMessage($"Could not load an unknown individual collection, removed:\n{e}", "Load Failure",
NotificationType.Error);
}
}
@ -124,7 +124,7 @@ 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.ChatService.NotificationMessage(
Penumbra.Chat.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);
}
@ -140,13 +140,13 @@ public partial class IndividualCollections
}, collection))
Penumbra.Log.Information($"Migrated {shortName} ({collection.AnonymizedName}) to Player Identifier.");
else
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Could not migrate {shortName} ({collection.AnonymizedName}), please look through your individual collections.",
"Migration Failure", NotificationType.Error);
}
else
{
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.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);
}

View file

@ -146,12 +146,12 @@ public class InheritanceManager : IDisposable
continue;
changes = true;
Penumbra.ChatService.NotificationMessage($"{collection.Name} can not inherit from {subCollection.Name}, removed.", "Warning",
Penumbra.Chat.NotificationMessage($"{collection.Name} can not inherit from {subCollection.Name}, removed.", "Warning",
NotificationType.Warning);
}
else
{
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Inherited collection {subCollectionName} for {collection.AnonymizedName} does not exist, it was removed.", "Warning",
NotificationType.Warning);
changes = true;

View file

@ -84,7 +84,7 @@ public class ModMerger : IDisposable
catch (Exception ex)
{
Error = ex;
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Could not merge {MergeFromMod!.Name} into {MergeToMod!.Name}, cleaning up changes.:\n{ex}", "Failure",
NotificationType.Error);
FailureCleanup();

View file

@ -77,7 +77,7 @@ public class ModNormalizer
}
catch (Exception e)
{
Penumbra.ChatService.NotificationMessage($"Could not normalize mod:\n{e}", "Failure", NotificationType.Error);
Penumbra.Chat.NotificationMessage($"Could not normalize mod:\n{e}", "Failure", NotificationType.Error);
}
finally
{
@ -90,7 +90,7 @@ public class ModNormalizer
{
if (Directory.Exists(_normalizationDirName))
{
Penumbra.ChatService.NotificationMessage("Could not normalize mod:\n"
Penumbra.Chat.NotificationMessage("Could not normalize mod:\n"
+ "The directory TmpNormalization may not already exist when normalizing a mod.", "Failure",
NotificationType.Error);
return false;
@ -98,7 +98,7 @@ public class ModNormalizer
if (Directory.Exists(_oldDirName))
{
Penumbra.ChatService.NotificationMessage("Could not normalize mod:\n"
Penumbra.Chat.NotificationMessage("Could not normalize mod:\n"
+ "The directory TmpNormalizationOld may not already exist when normalizing a mod.", "Failure",
NotificationType.Error);
return false;
@ -204,7 +204,7 @@ public class ModNormalizer
}
catch (Exception e)
{
Penumbra.ChatService.NotificationMessage($"Could not normalize mod:\n{e}", "Failure", NotificationType.Error);
Penumbra.Chat.NotificationMessage($"Could not normalize mod:\n{e}", "Failure", NotificationType.Error);
}
return false;
@ -232,7 +232,7 @@ public class ModNormalizer
}
catch (Exception e)
{
Penumbra.ChatService.NotificationMessage($"Could not move old files out of the way while normalizing mod mod:\n{e}", "Failure",
Penumbra.Chat.NotificationMessage($"Could not move old files out of the way while normalizing mod mod:\n{e}", "Failure",
NotificationType.Error);
}
@ -256,7 +256,7 @@ public class ModNormalizer
}
catch (Exception e)
{
Penumbra.ChatService.NotificationMessage($"Could not move new files into the mod while normalizing mod mod:\n{e}", "Failure",
Penumbra.Chat.NotificationMessage($"Could not move new files into the mod while normalizing mod mod:\n{e}", "Failure",
NotificationType.Error);
foreach (var dir in Mod.ModPath.EnumerateDirectories())
{

View file

@ -48,7 +48,7 @@ public class ModImportManager : IDisposable
if (File.Exists(s))
return true;
Penumbra.ChatService.NotificationMessage($"Failed to import queued mod at {s}, the file does not exist.", "Warning",
Penumbra.Chat.NotificationMessage($"Failed to import queued mod at {s}, the file does not exist.", "Warning",
NotificationType.Warning);
return false;
}).Select(s => new FileInfo(s)).ToArray();

View file

@ -398,7 +398,7 @@ public class ModOptionEditor
return true;
if (message)
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Could not name option {newName} because option with same filename {path} already exists.",
"Warning", NotificationType.Warning);

View file

@ -51,7 +51,7 @@ public partial class ModCreator
}
catch (Exception e)
{
Penumbra.ChatService.NotificationMessage($"Could not create directory for new Mod {newName}:\n{e}", "Failure",
Penumbra.Chat.NotificationMessage($"Could not create directory for new Mod {newName}:\n{e}", "Failure",
NotificationType.Error);
return null;
}

View file

@ -59,7 +59,7 @@ public sealed class MultiModGroup : IModGroup
{
if (ret.PrioritizedOptions.Count == IModGroup.MaxMultiOptions)
{
Penumbra.ChatService.NotificationMessage(
Penumbra.Chat.NotificationMessage(
$"Multi Group {ret.Name} has more than {IModGroup.MaxMultiOptions} options, ignoring excessive options.", "Warning",
NotificationType.Warning);
break;

View file

@ -31,7 +31,7 @@ public class Penumbra : IDalamudPlugin
=> "Penumbra";
public static readonly Logger Log = new();
public static ChatService ChatService { get; private set; } = null!;
public static ChatService Chat { 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);
ChatService = _services.GetRequiredService<ChatService>();
Chat = _services.GetRequiredService<ChatService>();
_validityChecker = _services.GetRequiredService<ValidityChecker>();
var startup = _services.GetRequiredService<DalamudServices>().GetDalamudConfig(DalamudServices.WaitingForPluginsOption, out bool s)
? s.ToString()
@ -115,7 +115,7 @@ public class Penumbra : IDalamudPlugin
_communicatorService.ChangedItemClick.Subscribe((button, it) =>
{
if (button == MouseButton.Left && it is Item item)
ChatService.LinkItem(item);
Chat.LinkItem(item);
}, ChangedItemClick.Priority.Link);
}

View file

@ -38,7 +38,7 @@ public class ValidityChecker
public void LogExceptions()
{
if( ImcExceptions.Count > 0 )
Penumbra.ChatService.NotificationMessage( $"{ImcExceptions} IMC Exceptions thrown during Penumbra load. Please repair your game files.", "Warning", NotificationType.Warning );
Penumbra.Chat.NotificationMessage( $"{ImcExceptions} IMC Exceptions thrown during Penumbra load. Please repair your game files.", "Warning", NotificationType.Warning );
}
// Because remnants of penumbra in devPlugins cause issues, we check for them to warn users to remove them.

View file

@ -129,7 +129,7 @@ public class FileEditor<T> where T : class, IWritable
}
catch (Exception e)
{
Penumbra.ChatService.NotificationMessage($"Could not export {_defaultPath}:\n{e}", "Error", NotificationType.Error);
Penumbra.Chat.NotificationMessage($"Could not export {_defaultPath}:\n{e}", "Error", NotificationType.Error);
}
}, _getInitialPath(), false);

View file

@ -327,7 +327,7 @@ public class ItemSwapTab : IDisposable, ITab
}
catch (Exception e)
{
Penumbra.ChatService.NotificationMessage($"Could not create new Swap Option:\n{e}", "Error", NotificationType.Error);
Penumbra.Chat.NotificationMessage($"Could not create new Swap Option:\n{e}", "Error", NotificationType.Error);
try
{
if (optionCreated && _selectedGroup != null)

View file

@ -90,7 +90,7 @@ public partial class ModEditWindow
LoadedShpkPath = FullPath.Empty;
LoadedShpkPathName = string.Empty;
AssociatedShpk = null;
Penumbra.ChatService.NotificationMessage( $"Could not load {LoadedShpkPath.ToPath()}:\n{e}", "Penumbra Advanced Editing", NotificationType.Error );
Penumbra.Chat.NotificationMessage( $"Could not load {LoadedShpkPath.ToPath()}:\n{e}", "Penumbra Advanced Editing", NotificationType.Error );
}
Update();

View file

@ -80,12 +80,12 @@ public partial class ModEditWindow
}
catch( Exception e )
{
Penumbra.ChatService.NotificationMessage( $"Could not export {defaultName}{tab.Extension} to {name}:\n{e.Message}", "Penumbra Advanced Editing",
Penumbra.Chat.NotificationMessage( $"Could not export {defaultName}{tab.Extension} to {name}:\n{e.Message}", "Penumbra Advanced Editing",
NotificationType.Error );
return;
}
Penumbra.ChatService.NotificationMessage( $"Shader Program Blob {defaultName}{tab.Extension} exported successfully to {Path.GetFileName( name )}",
Penumbra.Chat.NotificationMessage( $"Shader Program Blob {defaultName}{tab.Extension} exported successfully to {Path.GetFileName( name )}",
"Penumbra Advanced Editing", NotificationType.Success );
}, null, false );
}
@ -110,7 +110,7 @@ public partial class ModEditWindow
}
catch( Exception e )
{
Penumbra.ChatService.NotificationMessage( $"Could not import {name}:\n{e.Message}", "Penumbra Advanced Editing", NotificationType.Error );
Penumbra.Chat.NotificationMessage( $"Could not import {name}:\n{e.Message}", "Penumbra Advanced Editing", NotificationType.Error );
return;
}
@ -122,7 +122,7 @@ public partial class ModEditWindow
catch( Exception e )
{
tab.Shpk.SetInvalid();
Penumbra.ChatService.NotificationMessage( $"Failed to update resources after importing {name}:\n{e.Message}", "Penumbra Advanced Editing",
Penumbra.Chat.NotificationMessage( $"Failed to update resources after importing {name}:\n{e.Message}", "Penumbra Advanced Editing",
NotificationType.Error );
return;
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using OtterGui.Custom;
namespace Penumbra.UI.Classes;
@ -31,13 +32,13 @@ public static class Colors
public const uint RegexWarningBorder = 0xFF0000B0;
public const uint MetaInfoText = 0xAAFFFFFF;
public const uint RedTableBgTint = 0x40000080;
public const uint DiscordColor = 0xFFDA8972;
public const uint DiscordColor = CustomGui.DiscordColor;
public const uint FilterActive = 0x807070FF;
public const uint TutorialMarker = 0xFF20FFFF;
public const uint TutorialBorder = 0xD00000FF;
public const uint ReniColorButton = 0xFFCC648D;
public const uint ReniColorHovered = 0xFFB070B0;
public const uint ReniColorActive = 0xFF9070E0;
public const uint ReniColorButton = CustomGui.ReniColorButton;
public const uint ReniColorHovered = CustomGui.ReniColorHovered;
public const uint ReniColorActive = CustomGui.ReniColorActive ;
public static (uint DefaultColor, string Name, string Description) Data(this ColorId color)
=> color switch

View file

@ -4,6 +4,7 @@ using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using ImGuiNET;
using OtterGui;
using OtterGui.Custom;
using OtterGui.Raii;
using Penumbra.Services;
using Penumbra.UI.Classes;
@ -143,7 +144,7 @@ public sealed class ConfigWindow : Window
ImGui.NewLine();
ImGui.NewLine();
UiHelpers.DrawDiscordButton(0);
CustomGui.DrawDiscordButton(Penumbra.ChatService, 0);
ImGui.SameLine();
UiHelpers.DrawSupportButton(_penumbra!);
ImGui.NewLine();

View file

@ -7,6 +7,7 @@ using Dalamud.Interface.Components;
using Dalamud.Utility;
using ImGuiNET;
using OtterGui;
using OtterGui.Custom;
using OtterGui.Raii;
using OtterGui.Widgets;
using Penumbra.Api;
@ -790,10 +791,10 @@ public class SettingsTab : ITab
UiHelpers.DrawSupportButton(_penumbra);
ImGui.SetCursorPos(new Vector2(xPos, 0));
UiHelpers.DrawDiscordButton(width);
CustomGui.DrawDiscordButton(Penumbra.Chat, width);
ImGui.SetCursorPos(new Vector2(xPos, 2 * ImGui.GetFrameHeightWithSpacing()));
UiHelpers.DrawGuideButton(width);
CustomGui.DrawGuideButton(Penumbra.Chat, width);
ImGui.SetCursorPos(new Vector2(xPos, 3 * ImGui.GetFrameHeightWithSpacing()));
if (ImGui.Button("Restart Tutorial", new Vector2(width, 0)))

View file

@ -8,7 +8,6 @@ using OtterGui;
using OtterGui.Raii;
using Penumbra.Interop.Structs;
using Penumbra.String;
using Penumbra.UI.Classes;
namespace Penumbra.UI;
@ -46,29 +45,6 @@ public static class UiHelpers
ImGui.SetTooltip("Click to copy to clipboard.");
}
/// <summary> Draw a button to open the official discord server. </summary>
/// <param name="width">The desired width of the button.</param>
public static void DrawDiscordButton(float width)
{
const string address = @"https://discord.gg/kVva7DHV4r";
using var color = ImRaii.PushColor(ImGuiCol.Button, Colors.DiscordColor);
if (ImGui.Button("Join Discord for Support", new Vector2(width, 0)))
try
{
var process = new ProcessStartInfo(address)
{
UseShellExecute = true,
};
Process.Start(process);
}
catch
{
Penumbra.ChatService.NotificationMessage($"Unable to open Discord at {address}.", "Error", NotificationType.Error);
}
ImGuiUtil.HoverTooltip($"Open {address}");
}
/// <summary> The longest support button text. </summary>
public const string SupportInfoButtonText = "Copy Support Info to Clipboard";
@ -101,33 +77,6 @@ public static class UiHelpers
});
}
/// <summary> Draw the button that opens the ReniGuide. </summary>
public static void DrawGuideButton(float width)
{
const string address = @"https://reniguide.info/";
using var color = ImRaii.PushColor(ImGuiCol.Button, Colors.ReniColorButton)
.Push(ImGuiCol.ButtonHovered, Colors.ReniColorHovered)
.Push(ImGuiCol.ButtonActive, Colors.ReniColorActive);
if (ImGui.Button("Beginner's Guides", new Vector2(width, 0)))
try
{
var process = new ProcessStartInfo(address)
{
UseShellExecute = true,
};
Process.Start(process);
}
catch
{
Penumbra.ChatService.NotificationMessage($"Could not open guide at {address} in external browser.", "Error",
NotificationType.Error);
}
ImGuiUtil.HoverTooltip(
$"Open {address}\nImage and text based guides for most functionality of Penumbra made by Serenity.\n"
+ "Not directly affiliated and potentially, but not usually out of date.");
}
/// <summary> Draw default vertical space. </summary>
public static void DefaultLineSpace()
=> ImGui.Dummy(DefaultSpace);