diff --git a/Dalamud.Test/Storage/ReliableFileStorageTests.cs b/Dalamud.Test/Storage/ReliableFileStorageTests.cs index 6cea81aec..ff56293e0 100644 --- a/Dalamud.Test/Storage/ReliableFileStorageTests.cs +++ b/Dalamud.Test/Storage/ReliableFileStorageTests.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using System.Reactive.Disposables; using System.Threading.Tasks; using Dalamud.Storage; @@ -20,8 +21,7 @@ public class ReliableFileStorageTests public async Task IsConcurrencySafe() { var dbDir = CreateTempDir(); - using var rfs = new ReliableFileStorage(dbDir); - + var rfs = new DisposableReliableFileStorage(dbDir); var tempFile = Path.Combine(CreateTempDir(), TestFileName); // Do reads/writes/deletes on the same file on many threads at once and @@ -36,14 +36,14 @@ public class ReliableFileStorageTests if (i % 2 == 0) { // ReSharper disable once AccessToDisposedClosure - rfs.WriteAllText(tempFile, j.ToString()); + rfs.Instance.WriteAllText(tempFile, j.ToString()); } else if (i % 3 == 0) { try { // ReSharper disable once AccessToDisposedClosure - rfs.ReadAllText(tempFile); + rfs.Instance.ReadAllText(tempFile); } catch (FileNotFoundException) { @@ -64,7 +64,7 @@ public class ReliableFileStorageTests { var dbDir = CreateTempDir(); var dbPath = Path.Combine(dbDir, DbFileName); - using var rfs = new ReliableFileStorage(dbDir); + using var rfs = new DisposableReliableFileStorage(dbDir); Assert.True(File.Exists(dbPath)); } @@ -73,14 +73,14 @@ public class ReliableFileStorageTests public void Exists_ThrowsIfPathIsEmpty() { using var rfs = CreateRfs(); - Assert.Throws(() => rfs.Exists("")); + Assert.Throws(() => rfs.Instance.Exists("")); } [Fact] public void Exists_ThrowsIfPathIsNull() { using var rfs = CreateRfs(); - Assert.Throws(() => rfs.Exists(null!)); + Assert.Throws(() => rfs.Instance.Exists(null!)); } [Fact] @@ -89,7 +89,7 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateRfs(); - Assert.False(rfs.Exists(tempFile)); + Assert.False(rfs.Instance.Exists(tempFile)); } [Fact] @@ -98,7 +98,7 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateFailedRfs(); - Assert.False(rfs.Exists(tempFile)); + Assert.False(rfs.Instance.Exists(tempFile)); } [Fact] @@ -108,7 +108,7 @@ public class ReliableFileStorageTests await File.WriteAllTextAsync(tempFile, TestFileContent1); using var rfs = CreateRfs(); - Assert.True(rfs.Exists(tempFile)); + Assert.True(rfs.Instance.Exists(tempFile)); } [Fact] @@ -117,10 +117,10 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); File.Delete(tempFile); - Assert.True(rfs.Exists(tempFile)); + Assert.True(rfs.Instance.Exists(tempFile)); } [Fact] @@ -129,24 +129,24 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); File.Delete(tempFile); - Assert.False(rfs.Exists(tempFile, Guid.NewGuid())); + Assert.False(rfs.Instance.Exists(tempFile, Guid.NewGuid())); } [Fact] public void WriteAllText_ThrowsIfPathIsEmpty() { using var rfs = CreateRfs(); - Assert.Throws(() => rfs.WriteAllText("", TestFileContent1)); + Assert.Throws(() => rfs.Instance.WriteAllText("", TestFileContent1)); } [Fact] public void WriteAllText_ThrowsIfPathIsNull() { using var rfs = CreateRfs(); - Assert.Throws(() => rfs.WriteAllText(null!, TestFileContent1)); + Assert.Throws(() => rfs.Instance.WriteAllText(null!, TestFileContent1)); } [Fact] @@ -155,10 +155,10 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); Assert.True(File.Exists(tempFile)); - Assert.Equal(TestFileContent1, rfs.ReadAllText(tempFile, forceBackup: true)); + Assert.Equal(TestFileContent1, rfs.Instance.ReadAllText(tempFile, forceBackup: true)); Assert.Equal(TestFileContent1, await File.ReadAllTextAsync(tempFile)); } @@ -169,12 +169,12 @@ public class ReliableFileStorageTests var containerId = Guid.NewGuid(); using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); - rfs.WriteAllText(tempFile, TestFileContent2, containerId); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent2, containerId); File.Delete(tempFile); - Assert.Equal(TestFileContent1, rfs.ReadAllText(tempFile, forceBackup: true)); - Assert.Equal(TestFileContent2, rfs.ReadAllText(tempFile, forceBackup: true, containerId)); + Assert.Equal(TestFileContent1, rfs.Instance.ReadAllText(tempFile, forceBackup: true)); + Assert.Equal(TestFileContent2, rfs.Instance.ReadAllText(tempFile, forceBackup: true, containerId)); } [Fact] @@ -183,7 +183,7 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateFailedRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); Assert.True(File.Exists(tempFile)); Assert.Equal(TestFileContent1, await File.ReadAllTextAsync(tempFile)); @@ -195,11 +195,11 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); - rfs.WriteAllText(tempFile, TestFileContent2); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent2); Assert.True(File.Exists(tempFile)); - Assert.Equal(TestFileContent2, rfs.ReadAllText(tempFile, forceBackup: true)); + Assert.Equal(TestFileContent2, rfs.Instance.ReadAllText(tempFile, forceBackup: true)); Assert.Equal(TestFileContent2, await File.ReadAllTextAsync(tempFile)); } @@ -209,24 +209,24 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, null); + rfs.Instance.WriteAllText(tempFile, null); Assert.True(File.Exists(tempFile)); - Assert.Equal("", rfs.ReadAllText(tempFile)); + Assert.Equal("", rfs.Instance.ReadAllText(tempFile)); } [Fact] public void ReadAllText_ThrowsIfPathIsEmpty() { using var rfs = CreateRfs(); - Assert.Throws(() => rfs.ReadAllText("")); + Assert.Throws(() => rfs.Instance.ReadAllText("")); } [Fact] public void ReadAllText_ThrowsIfPathIsNull() { using var rfs = CreateRfs(); - Assert.Throws(() => rfs.ReadAllText(null!)); + Assert.Throws(() => rfs.Instance.ReadAllText(null!)); } [Fact] @@ -236,7 +236,7 @@ public class ReliableFileStorageTests await File.WriteAllTextAsync(tempFile, TestFileContent1); using var rfs = CreateRfs(); - Assert.Equal(TestFileContent1, rfs.ReadAllText(tempFile)); + Assert.Equal(TestFileContent1, rfs.Instance.ReadAllText(tempFile)); } [Fact] @@ -245,10 +245,10 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); File.Delete(tempFile); - Assert.Equal(TestFileContent1, rfs.ReadAllText(tempFile)); + Assert.Equal(TestFileContent1, rfs.Instance.ReadAllText(tempFile)); } [Fact] @@ -258,10 +258,10 @@ public class ReliableFileStorageTests var containerId = Guid.NewGuid(); using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); File.Delete(tempFile); - Assert.Throws(() => rfs.ReadAllText(tempFile, containerId: containerId)); + Assert.Throws(() => rfs.Instance.ReadAllText(tempFile, containerId: containerId)); } [Fact] @@ -269,7 +269,7 @@ public class ReliableFileStorageTests { var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateFailedRfs(); - Assert.Throws(() => rfs.ReadAllText(tempFile)); + Assert.Throws(() => rfs.Instance.ReadAllText(tempFile)); } [Fact] @@ -278,7 +278,7 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); await File.WriteAllTextAsync(tempFile, TestFileContent1); using var rfs = CreateRfs(); - rfs.ReadAllText(tempFile, text => Assert.Equal(TestFileContent1, text)); + rfs.Instance.ReadAllText(tempFile, text => Assert.Equal(TestFileContent1, text)); } [Fact] @@ -290,7 +290,7 @@ public class ReliableFileStorageTests var readerCalledOnce = false; using var rfs = CreateRfs(); - Assert.Throws(() => rfs.ReadAllText(tempFile, Reader)); + Assert.Throws(() => rfs.Instance.ReadAllText(tempFile, Reader)); return; @@ -311,10 +311,10 @@ public class ReliableFileStorageTests var assertionCalled = false; using var rfs = CreateRfs(); - rfs.WriteAllText(tempFile, TestFileContent1); + rfs.Instance.WriteAllText(tempFile, TestFileContent1); File.Delete(tempFile); - rfs.ReadAllText(tempFile, Reader); + rfs.Instance.ReadAllText(tempFile, Reader); Assert.True(assertionCalled); return; @@ -335,7 +335,7 @@ public class ReliableFileStorageTests var tempFile = Path.Combine(CreateTempDir(), TestFileName); await File.WriteAllTextAsync(tempFile, TestFileContent1); using var rfs = CreateRfs(); - Assert.Throws(() => rfs.ReadAllText(tempFile, _ => throw new FileNotFoundException())); + Assert.Throws(() => rfs.Instance.ReadAllText(tempFile, _ => throw new FileNotFoundException())); } [Theory] @@ -345,16 +345,16 @@ public class ReliableFileStorageTests { var tempFile = Path.Combine(CreateTempDir(), TestFileName); using var rfs = CreateRfs(); - Assert.Throws(() => rfs.ReadAllText(tempFile, forceBackup)); + Assert.Throws(() => rfs.Instance.ReadAllText(tempFile, forceBackup)); } - private static ReliableFileStorage CreateRfs() + private static DisposableReliableFileStorage CreateRfs() { var dbDir = CreateTempDir(); - return new ReliableFileStorage(dbDir); + return new(dbDir); } - private static ReliableFileStorage CreateFailedRfs() + private static DisposableReliableFileStorage CreateFailedRfs() { var dbDir = CreateTempDir(); var dbPath = Path.Combine(dbDir, DbFileName); @@ -367,7 +367,7 @@ public class ReliableFileStorageTests // Throws an SQLiteException initially, and then throws an // IOException when attempting to delete the file because // there's already an active handle associated with it - return new ReliableFileStorage(dbDir); + return new(dbDir); } private static string CreateTempDir() @@ -383,4 +383,13 @@ public class ReliableFileStorageTests Directory.CreateDirectory(tempDir); return tempDir; } + + private sealed class DisposableReliableFileStorage : IDisposable + { + public DisposableReliableFileStorage(string rfsDbPath) => this.Instance = new(rfsDbPath); + + public ReliableFileStorage Instance { get; } + + public void Dispose() => ((IInternalDisposableService)this.Instance).DisposeService(); + } } diff --git a/Dalamud/EntryPoint.cs b/Dalamud/EntryPoint.cs index ecf159eab..480e3c575 100644 --- a/Dalamud/EntryPoint.cs +++ b/Dalamud/EntryPoint.cs @@ -138,9 +138,7 @@ public sealed class EntryPoint SerilogEventSink.Instance.LogLine += SerilogOnLogLine; // Load configuration first to get some early persistent state, like log level -#pragma warning disable CS0618 // Type or member is obsolete var fs = new ReliableFileStorage(Path.GetDirectoryName(info.ConfigurationPath)!); -#pragma warning restore CS0618 // Type or member is obsolete var configuration = DalamudConfiguration.Load(info.ConfigurationPath!, fs); // Set the appropriate logging level from the configuration diff --git a/Dalamud/Game/ChatHandlers.cs b/Dalamud/Game/ChatHandlers.cs index 7043068c9..fa966f30a 100644 --- a/Dalamud/Game/ChatHandlers.cs +++ b/Dalamud/Game/ChatHandlers.cs @@ -12,9 +12,9 @@ using Dalamud.Game.Gui; using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; using Dalamud.Interface.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Internal.Windows; using Dalamud.Interface.Internal.Windows.PluginInstaller; using Dalamud.Logging.Internal; diff --git a/Dalamud/Game/ClientState/Objects/ObjectTable.cs b/Dalamud/Game/ClientState/Objects/ObjectTable.cs index 220321157..b36b3ce92 100644 --- a/Dalamud/Game/ClientState/Objects/ObjectTable.cs +++ b/Dalamud/Game/ClientState/Objects/ObjectTable.cs @@ -216,9 +216,6 @@ internal sealed partial class ObjectTable : IServiceType, IObjectTable /// internal sealed partial class ObjectTable { - /// - int IReadOnlyCollection.Count => this.Length; - /// public IEnumerator GetEnumerator() { diff --git a/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs b/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs index 9de11e3ec..407aada26 100644 --- a/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs +++ b/Dalamud/Game/ClientState/Objects/SubKinds/PlayerCharacter.cs @@ -31,5 +31,5 @@ public unsafe class PlayerCharacter : BattleChara /// /// Gets the target actor ID of the PlayerCharacter. /// - public override ulong TargetObjectId => this.Struct->Character.LookTargetId; + public override ulong TargetObjectId => this.Struct->Character.Gaze.Controller.GazesSpan[0].TargetInfo.TargetId; } diff --git a/Dalamud/Interface/GameFonts/GameFontHandle.cs b/Dalamud/Interface/GameFonts/GameFontHandle.cs deleted file mode 100644 index 2594eea0e..000000000 --- a/Dalamud/Interface/GameFonts/GameFontHandle.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System.Numerics; -using System.Threading.Tasks; - -using Dalamud.Interface.ManagedFontAtlas; -using Dalamud.Interface.ManagedFontAtlas.Internals; -using Dalamud.Utility; - -using ImGuiNET; - -namespace Dalamud.Interface.GameFonts; - -/// -/// ABI-compatible wrapper for . -/// -[Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] -public sealed class GameFontHandle : IFontHandle -{ - private readonly GamePrebakedFontHandle fontHandle; - private readonly FontAtlasFactory fontAtlasFactory; - - /// - /// Initializes a new instance of the class.
- /// Ownership of is transferred. - ///
- /// The wrapped . - /// An instance of . - internal GameFontHandle(GamePrebakedFontHandle fontHandle, FontAtlasFactory fontAtlasFactory) - { - this.fontHandle = fontHandle; - this.fontAtlasFactory = fontAtlasFactory; - } - - /// - public event IFontHandle.ImFontChangedDelegate ImFontChanged - { - add => this.fontHandle.ImFontChanged += value; - remove => this.fontHandle.ImFontChanged -= value; - } - - /// - public Exception? LoadException => this.fontHandle.LoadException; - - /// - public bool Available => this.fontHandle.Available; - - /// - /// Gets the font.
- /// Use of this properly is safe only from the UI thread.
- /// Use if the intended purpose of this property is .
- /// Futures changes may make simple not enough.
- /// If you need to access a font outside the UI thread, use . - ///
- [Obsolete($"Use {nameof(Push)}-{nameof(ImGui.GetFont)} or {nameof(Lock)} instead.", false)] - public ImFontPtr ImFont => this.fontHandle.LockUntilPostFrame(); - - /// - /// Gets the font style. Only applicable for . - /// - [Obsolete("If you use this, let the fact that you use this be known at Dalamud Discord.", false)] - public GameFontStyle Style => ((GamePrebakedFontHandle)this.fontHandle).FontStyle; - - /// - /// Gets the relevant .
- ///
- /// Only applicable for game fonts. Otherwise it will throw. - ///
- [Obsolete("If you use this, let the fact that you use this be known at Dalamud Discord.", false)] - public FdtReader FdtReader => this.fontAtlasFactory.GetFdtReader(this.Style.FamilyAndSize)!; - - /// - public void Dispose() => this.fontHandle.Dispose(); - - /// - public ILockedImFont Lock() => this.fontHandle.Lock(); - - /// - public IDisposable Push() => this.fontHandle.Push(); - - /// - public void Pop() => this.fontHandle.Pop(); - - /// - public Task WaitAsync() => this.fontHandle.WaitAsync(); - - /// - /// Creates a new .
- ///
- /// Only applicable for game fonts. Otherwise it will throw. - ///
- /// Text. - /// A new builder for GameFontLayoutPlan. - [Obsolete("If you use this, let the fact that you use this be known at Dalamud Discord.", false)] - public GameFontLayoutPlan.Builder LayoutBuilder(string text) => new(this.ImFont, this.FdtReader, text); - - /// - /// Draws text. - /// - /// Text to draw. - [Obsolete("If you use this, let the fact that you use this be known at Dalamud Discord.", false)] - public void Text(string text) - { - if (!this.Available) - { - ImGui.TextUnformatted(text); - } - else - { - var pos = ImGui.GetWindowPos() + ImGui.GetCursorPos(); - pos.X -= ImGui.GetScrollX(); - pos.Y -= ImGui.GetScrollY(); - - var layout = this.LayoutBuilder(text).Build(); - layout.Draw(ImGui.GetWindowDrawList(), pos, ImGui.GetColorU32(ImGuiCol.Text)); - ImGui.Dummy(new Vector2(layout.Width, layout.Height)); - } - } - - /// - /// Draws text in given color. - /// - /// Color. - /// Text to draw. - [Obsolete("If you use this, let the fact that you use this be known at Dalamud Discord.", false)] - public void TextColored(Vector4 col, string text) - { - ImGui.PushStyleColor(ImGuiCol.Text, col); - this.Text(text); - ImGui.PopStyleColor(); - } - - /// - /// Draws disabled text. - /// - /// Text to draw. - [Obsolete("If you use this, let the fact that you use this be known at Dalamud Discord.", false)] - public void TextDisabled(string text) - { - unsafe - { - this.TextColored(*ImGui.GetStyleColorVec4(ImGuiCol.TextDisabled), text); - } - } -} diff --git a/Dalamud/Interface/ImGuiFontChooserDialog/SingleFontChooserDialog.cs b/Dalamud/Interface/ImGuiFontChooserDialog/SingleFontChooserDialog.cs index 7636f22b6..c5c4581e7 100644 --- a/Dalamud/Interface/ImGuiFontChooserDialog/SingleFontChooserDialog.cs +++ b/Dalamud/Interface/ImGuiFontChooserDialog/SingleFontChooserDialog.cs @@ -89,30 +89,6 @@ public sealed class SingleFontChooserDialog : IDisposable private bool popupSizeChanged; private Vector2 popupPosition = new(float.NaN); private Vector2 popupSize = new(float.NaN); - - /// Initializes a new instance of the class. - /// A new instance of created using - /// as its auto-rebuild mode. - /// The passed instance of will be disposed after use. If you pass an atlas - /// that is already being used, then all the font handles under the passed atlas will be invalidated upon disposing - /// this font chooser. Consider using for automatic - /// handling of font atlas derived from a , or even for automatic - /// registration and unregistration of event handler in addition to automatic disposal of this - /// class and the temporary font atlas for this font chooser dialog. - [Obsolete("See remarks, and use the other constructor.", false)] - [Api10ToDo("Make private.")] - public SingleFontChooserDialog(IFontAtlas newAsyncAtlas) - { - this.counter = Interlocked.Increment(ref counterStatic); - this.title = "Choose a font..."; - this.popupImGuiName = $"{this.title}##{nameof(SingleFontChooserDialog)}[{this.counter}]"; - this.atlas = newAsyncAtlas; - this.selectedFont = new() { FontId = DalamudDefaultFontAndFamilyId.Instance }; - Encoding.UTF8.GetBytes("Font preview.\n0123456789!", this.fontPreviewText); - } - -#pragma warning disable CS0618 // Type or member is obsolete - // TODO: Api10ToDo; Remove this pragma warning disable line /// Initializes a new instance of the class. /// The relevant instance of UiBuilder. @@ -137,9 +113,25 @@ public sealed class SingleFontChooserDialog : IDisposable : this(factory.CreateFontAtlas(debugAtlasName, FontAtlasAutoRebuildMode.Async)) { } - -#pragma warning restore CS0618 // Type or member is obsolete - // TODO: Api10ToDo; Remove this pragma warning restore line + + /// Initializes a new instance of the class. + /// A new instance of created using + /// as its auto-rebuild mode. + /// The passed instance of will be disposed after use. If you pass an atlas + /// that is already being used, then all the font handles under the passed atlas will be invalidated upon disposing + /// this font chooser. Consider using for automatic + /// handling of font atlas derived from a , or even for automatic + /// registration and unregistration of event handler in addition to automatic disposal of this + /// class and the temporary font atlas for this font chooser dialog. + private SingleFontChooserDialog(IFontAtlas newAsyncAtlas) + { + this.counter = Interlocked.Increment(ref counterStatic); + this.title = "Choose a font..."; + this.popupImGuiName = $"{this.title}##{nameof(SingleFontChooserDialog)}[{this.counter}]"; + this.atlas = newAsyncAtlas; + this.selectedFont = new() { FontId = DalamudDefaultFontAndFamilyId.Instance }; + Encoding.UTF8.GetBytes("Font preview.\n0123456789!", this.fontPreviewText); + } /// Called when the selected font spec has changed. public event Action? SelectedFontSpecChanged; diff --git a/Dalamud/Interface/ImGuiNotification/INotification.cs b/Dalamud/Interface/ImGuiNotification/INotification.cs index af34e0a1b..ac1ac1beb 100644 --- a/Dalamud/Interface/ImGuiNotification/INotification.cs +++ b/Dalamud/Interface/ImGuiNotification/INotification.cs @@ -1,7 +1,6 @@ using System.Threading.Tasks; using Dalamud.Interface.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Plugin.Services; namespace Dalamud.Interface.ImGuiNotification; diff --git a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs index f1084fd20..e6bbfc591 100644 --- a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs +++ b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs @@ -5,7 +5,6 @@ using Dalamud.Configuration.Internal; using Dalamud.Interface.Animation; using Dalamud.Interface.Animation.EasingFunctions; using Dalamud.Interface.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Plugin.Internal.Types; using Dalamud.Utility; diff --git a/Dalamud/Interface/ImGuiNotification/Internal/NotificationConstants.cs b/Dalamud/Interface/ImGuiNotification/Internal/NotificationConstants.cs index 7811c1aaa..8b7ce7bfa 100644 --- a/Dalamud/Interface/ImGuiNotification/Internal/NotificationConstants.cs +++ b/Dalamud/Interface/ImGuiNotification/Internal/NotificationConstants.cs @@ -3,7 +3,6 @@ using System.Numerics; using CheapLoc; using Dalamud.Interface.Colors; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Utility; namespace Dalamud.Interface.ImGuiNotification.Internal; diff --git a/Dalamud/Interface/ImGuiNotification/Internal/NotificationManager.cs b/Dalamud/Interface/ImGuiNotification/Internal/NotificationManager.cs index 42aad2c45..06e3c5832 100644 --- a/Dalamud/Interface/ImGuiNotification/Internal/NotificationManager.cs +++ b/Dalamud/Interface/ImGuiNotification/Internal/NotificationManager.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Dalamud.Game.Gui; using Dalamud.Interface.GameFonts; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.ManagedFontAtlas; using Dalamud.Interface.ManagedFontAtlas.Internals; using Dalamud.Interface.Utility; diff --git a/Dalamud/Interface/ImGuiNotification/Notification.cs b/Dalamud/Interface/ImGuiNotification/Notification.cs index 0475628fd..a83b2e1a8 100644 --- a/Dalamud/Interface/ImGuiNotification/Notification.cs +++ b/Dalamud/Interface/ImGuiNotification/Notification.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using Dalamud.Interface.ImGuiNotification.Internal; using Dalamud.Interface.Internal; -using Dalamud.Interface.Internal.Notifications; namespace Dalamud.Interface.ImGuiNotification; diff --git a/Dalamud/Interface/Internal/Notifications/NotificationType.cs b/Dalamud/Interface/ImGuiNotification/NotificationType.cs similarity index 72% rename from Dalamud/Interface/Internal/Notifications/NotificationType.cs rename to Dalamud/Interface/ImGuiNotification/NotificationType.cs index 5fffbe9af..34d59f85e 100644 --- a/Dalamud/Interface/Internal/Notifications/NotificationType.cs +++ b/Dalamud/Interface/ImGuiNotification/NotificationType.cs @@ -1,9 +1,6 @@ -using Dalamud.Utility; - -namespace Dalamud.Interface.Internal.Notifications; +namespace Dalamud.Interface.ImGuiNotification; /// Possible notification types. -[Api10ToDo(Api10ToDoAttribute.MoveNamespace, nameof(ImGuiNotification.Internal))] public enum NotificationType { /// No special type. diff --git a/Dalamud/Interface/Internal/Windows/ConsoleWindow.cs b/Dalamud/Interface/Internal/Windows/ConsoleWindow.cs index 1405e078a..83d49456e 100644 --- a/Dalamud/Interface/Internal/Windows/ConsoleWindow.cs +++ b/Dalamud/Interface/Internal/Windows/ConsoleWindow.cs @@ -14,7 +14,6 @@ using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/DataShareWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/DataShareWidget.cs index 346255dfe..b1bd0f05c 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/DataShareWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/DataShareWidget.cs @@ -5,8 +5,8 @@ using System.Numerics; using System.Reflection; using System.Text; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin.Ipc.Internal; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/ImGuiWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/ImGuiWidget.cs index 6817c82b3..47f0dde64 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/ImGuiWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/ImGuiWidget.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Dalamud.Game.Text; using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Windowing; using Dalamud.Storage.Assets; using Dalamud.Utility; diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 80f821033..8647c3e00 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -15,8 +15,8 @@ using Dalamud.Game.Command; using Dalamud.Interface.Animation.EasingFunctions; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/ProfileManagerWidget.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/ProfileManagerWidget.cs index 6bee26755..81df0cd03 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/ProfileManagerWidget.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/ProfileManagerWidget.cs @@ -7,8 +7,8 @@ using CheapLoc; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin.Internal; diff --git a/Dalamud/Interface/Internal/Windows/PluginStatWindow.cs b/Dalamud/Interface/Internal/Windows/PluginStatWindow.cs index bfa30cafd..b3b5dfc8f 100644 --- a/Dalamud/Interface/Internal/Windows/PluginStatWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginStatWindow.cs @@ -7,8 +7,8 @@ using System.Reflection; using Dalamud.Game; using Dalamud.Hooking.Internal; using Dalamud.Interface.Components; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Windowing; using Dalamud.Plugin.Internal; using Dalamud.Plugin.Internal.Types; diff --git a/Dalamud/Interface/ManagedFontAtlas/IFontAtlas.cs b/Dalamud/Interface/ManagedFontAtlas/IFontAtlas.cs index 2feac8849..d622fbbb2 100644 --- a/Dalamud/Interface/ManagedFontAtlas/IFontAtlas.cs +++ b/Dalamud/Interface/ManagedFontAtlas/IFontAtlas.cs @@ -85,10 +85,9 @@ public interface IFontAtlas : IDisposable /// Creates a new from game's built-in fonts. /// Font to use. /// Handle to a font that may or may not be ready yet. - /// When called during , - /// , , and alike. Move the font handle - /// creating code outside those handlers, and only initialize them once. Call - /// on a previous font handle if you're replacing one. + /// When called during and alike. + /// Move the font handle creating code outside those handlers, and only initialize them once. + /// Call on a previous font handle if you're replacing one. /// This function does not throw. will be populated instead, if /// the build procedure has failed. can be used regardless of the state of the font /// handle. @@ -97,10 +96,9 @@ public interface IFontAtlas : IDisposable /// Creates a new IFontHandle using your own callbacks. /// Callback for . /// Handle to a font that may or may not be ready yet. - /// When called during , - /// , , and alike. Move the font handle - /// creating code outside those handlers, and only initialize them once. Call - /// on a previous font handle if you're replacing one. + /// When called during and alike. + /// Move the font handle creating code outside those handlers, and only initialize them once. + /// Call on a previous font handle if you're replacing one. /// Consider calling to /// support glyphs that are not supplied by the game by default; this mostly affects Chinese and Korean language /// users. diff --git a/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkit.cs b/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkit.cs index 158366b12..ae996a39c 100644 --- a/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkit.cs +++ b/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkit.cs @@ -1,8 +1,6 @@ using System.Runtime.InteropServices; -using Dalamud.Interface.ManagedFontAtlas.Internals; using Dalamud.Interface.Utility; -using Dalamud.Utility; using ImGuiNET; @@ -14,20 +12,6 @@ namespace Dalamud.Interface.ManagedFontAtlas; /// public interface IFontAtlasBuildToolkit { - /// - /// Functionalities for compatibility behavior.
- ///
- [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - internal interface IApi9Compat : IFontAtlasBuildToolkit - { - /// - /// Invokes , temporarily applying s.
- ///
- /// The action to invoke. - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public void FromUiBuilderObsoleteEventHandlers(Action action); - } - /// /// Gets or sets the font relevant to the call. /// diff --git a/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkitPostBuild.cs b/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkitPostBuild.cs index 2df0deae6..a1e97c288 100644 --- a/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkitPostBuild.cs +++ b/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkitPostBuild.cs @@ -1,5 +1,4 @@ using Dalamud.Interface.Internal; -using Dalamud.Utility; using ImGuiNET; @@ -11,11 +10,6 @@ namespace Dalamud.Interface.ManagedFontAtlas; /// public interface IFontAtlasBuildToolkitPostBuild : IFontAtlasBuildToolkit { - /// - [Obsolete($"Use {nameof(this.GetFontScaleMode)}")] - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - bool IsGlobalScaleIgnored(ImFontPtr fontPtr) => this.GetFontScaleMode(fontPtr) == FontScaleMode.UndoGlobalScale; - /// FontScaleMode GetFontScaleMode(ImFontPtr fontPtr); diff --git a/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkitPreBuild.cs b/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkitPreBuild.cs index b32e3db18..babe17fdd 100644 --- a/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkitPreBuild.cs +++ b/Dalamud/Interface/ManagedFontAtlas/IFontAtlasBuildToolkitPreBuild.cs @@ -44,25 +44,6 @@ public interface IFontAtlasBuildToolkitPreBuild : IFontAtlasBuildToolkit /// The action to run on dispose. void DisposeAfterBuild(Action action); - /// - /// Excludes given font from global scaling. - /// - /// The font. - /// Same with . - [Obsolete( - $"Use {nameof(this.SetFontScaleMode)} with {nameof(FontScaleMode)}.{nameof(FontScaleMode.UndoGlobalScale)}")] - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - ImFontPtr IgnoreGlobalScale(ImFontPtr fontPtr) => this.SetFontScaleMode(fontPtr, FontScaleMode.UndoGlobalScale); - - /// - /// Gets whether global scaling is ignored for the given font. - /// - /// The font. - /// True if ignored. - [Obsolete($"Use {nameof(this.GetFontScaleMode)}")] - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - bool IsGlobalScaleIgnored(ImFontPtr fontPtr) => this.GetFontScaleMode(fontPtr) == FontScaleMode.UndoGlobalScale; - /// /// Sets the scaling mode for the given font. /// diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/DelegateFontHandle.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/DelegateFontHandle.cs index b13c60a53..52939385b 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/DelegateFontHandle.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/DelegateFontHandle.cs @@ -132,14 +132,6 @@ internal sealed class DelegateFontHandle : FontHandle /// public IFontHandleManager Manager { get; } - /// - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public IFontAtlasBuildToolkitPreBuild? PreBuildToolkitForApi9Compat { get; set; } - - /// - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public bool CreateFontOnAccess { get; set; } - /// public void Dispose() { diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.BuildToolkit.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.BuildToolkit.cs index d05e5a2e7..fcb0c560d 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.BuildToolkit.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.BuildToolkit.cs @@ -33,7 +33,7 @@ internal sealed partial class FontAtlasFactory /// Implementations for and /// . /// - private class BuildToolkit : IFontAtlasBuildToolkit.IApi9Compat, IFontAtlasBuildToolkitPreBuild, IFontAtlasBuildToolkitPostBuild, IDisposable + private class BuildToolkit : IFontAtlasBuildToolkitPreBuild, IFontAtlasBuildToolkitPostBuild, IDisposable { private static readonly ushort FontAwesomeIconMin = (ushort)Enum.GetValues().Where(x => x > 0).Min(); @@ -111,34 +111,6 @@ internal sealed partial class FontAtlasFactory /// public void DisposeWithAtlas(Action action) => this.data.Garbage.Add(action); - /// - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public void FromUiBuilderObsoleteEventHandlers(Action action) - { - var previousSubstances = new IFontHandleSubstance[this.data.Substances.Count]; - for (var i = 0; i < previousSubstances.Length; i++) - { - previousSubstances[i] = this.data.Substances[i].Manager.Substance; - this.data.Substances[i].Manager.Substance = this.data.Substances[i]; - this.data.Substances[i].CreateFontOnAccess = true; - this.data.Substances[i].PreBuildToolkitForApi9Compat = this; - } - - try - { - action(); - } - finally - { - for (var i = 0; i < previousSubstances.Length; i++) - { - this.data.Substances[i].Manager.Substance = previousSubstances[i]; - this.data.Substances[i].CreateFontOnAccess = false; - this.data.Substances[i].PreBuildToolkitForApi9Compat = null; - } - } - } - /// public ImFontPtr GetFont(IFontHandle fontHandle) { diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.Implementation.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.Implementation.cs index 3c175ae3c..83ebac89e 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.Implementation.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.Implementation.cs @@ -435,7 +435,7 @@ internal sealed partial class FontAtlasFactory if (IsBuildInProgressForTask.Value) { throw new InvalidOperationException( - $"{nameof(this.NewGameFontHandle)} may not be called during {nameof(this.BuildStepChange)}, the callback of {nameof(this.NewDelegateFontHandle)}, {nameof(UiBuilder.BuildFonts)} or {nameof(UiBuilder.AfterBuildFonts)}."); + $"{nameof(this.NewGameFontHandle)} may not be called during {nameof(this.BuildStepChange)} or the callback of {nameof(this.NewDelegateFontHandle)}."); } return this.gameFontHandleManager.NewFontHandle(style); @@ -447,7 +447,7 @@ internal sealed partial class FontAtlasFactory if (IsBuildInProgressForTask.Value) { throw new InvalidOperationException( - $"{nameof(this.NewDelegateFontHandle)} may not be called during {nameof(this.BuildStepChange)} or the callback of {nameof(this.NewDelegateFontHandle)}, {nameof(UiBuilder.BuildFonts)} or {nameof(UiBuilder.AfterBuildFonts)}."); + $"{nameof(this.NewDelegateFontHandle)} may not be called during {nameof(this.BuildStepChange)} or the callback of {nameof(this.NewDelegateFontHandle)}."); } return this.delegateFontHandleManager.NewFontHandle(buildStepDelegate); diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs index 1101e7119..fc4e80889 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/GamePrebakedFontHandle.cs @@ -231,14 +231,6 @@ internal class GamePrebakedFontHandle : FontHandle /// public IFontHandleManager Manager => this.handleManager; - /// - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public IFontAtlasBuildToolkitPreBuild? PreBuildToolkitForApi9Compat { get; set; } - - /// - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public bool CreateFontOnAccess { get; set; } - /// public void Dispose() { @@ -295,27 +287,11 @@ internal class GamePrebakedFontHandle : FontHandle } } - // Use this on API 10. - // /// - // public ImFontPtr GetFontPtr(IFontHandle handle) => - // handle is GamePrebakedFontHandle ggfh - // ? this.fonts.GetValueOrDefault(ggfh.FontStyle)?.FullRangeFont ?? default - // : default; - /// - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public ImFontPtr GetFontPtr(IFontHandle handle) - { - if (handle is not GamePrebakedFontHandle ggfh) - return default; - if (this.fonts.GetValueOrDefault(ggfh.FontStyle)?.FullRangeFont is { } font) - return font; - if (!this.CreateFontOnAccess) - return default; - if (this.PreBuildToolkitForApi9Compat is not { } tk) - return default; - return this.GetOrCreateFont(ggfh.FontStyle, tk); - } + public ImFontPtr GetFontPtr(IFontHandle handle) => + handle is GamePrebakedFontHandle ggfh + ? this.fonts.GetValueOrDefault(ggfh.FontStyle)?.FullRangeFont ?? default + : default; /// public Exception? GetBuildException(IFontHandle handle) => diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/IFontHandleSubstance.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/IFontHandleSubstance.cs index 62c893a48..ef4150e33 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/IFontHandleSubstance.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/IFontHandleSubstance.cs @@ -21,19 +21,6 @@ internal interface IFontHandleSubstance : IDisposable /// IFontHandleManager Manager { get; } - /// - /// Gets or sets the relevant for this. - /// - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - IFontAtlasBuildToolkitPreBuild? PreBuildToolkitForApi9Compat { get; set; } - - /// - /// Gets or sets a value indicating whether to create a new instance of on first - /// access, for compatibility with API 9. - /// - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - bool CreateFontOnAccess { get; set; } - /// /// Gets the relevant handles. /// diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index c7b77c0c7..12a87a451 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -1,4 +1,3 @@ -using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; @@ -9,17 +8,10 @@ using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.Gui; using Dalamud.Interface.FontIdentifier; -using Dalamud.Interface.GameFonts; -using Dalamud.Interface.ImGuiNotification; -using Dalamud.Interface.ImGuiNotification.Internal; using Dalamud.Interface.Internal; using Dalamud.Interface.Internal.ManagedAsserts; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.ManagedFontAtlas; using Dalamud.Interface.ManagedFontAtlas.Internals; -using Dalamud.Plugin; -using Dalamud.Plugin.Internal.Types; -using Dalamud.Plugin.Services; using Dalamud.Utility; using ImGuiNET; @@ -38,13 +30,11 @@ namespace Dalamud.Interface; /// public sealed class UiBuilder : IDisposable { - private readonly LocalPlugin localPlugin; private readonly Stopwatch stopwatch; private readonly HitchDetector hitchDetector; private readonly string namespaceName; private readonly InterfaceManager interfaceManager = Service.Get(); private readonly Framework framework = Service.Get(); - private readonly ConcurrentDictionary notifications = new(); [ServiceManager.ServiceDependency] private readonly DalamudConfiguration configuration = Service.Get(); @@ -64,10 +54,8 @@ public sealed class UiBuilder : IDisposable /// You do not have to call this manually. /// /// The plugin namespace. - /// The relevant local plugin. - internal UiBuilder(string namespaceName, LocalPlugin localPlugin) + internal UiBuilder(string namespaceName) { - this.localPlugin = localPlugin; try { this.stopwatch = new Stopwatch(); @@ -85,9 +73,7 @@ public sealed class UiBuilder : IDisposable .Add( Service .Get() - .CreateFontAtlas(namespaceName, FontAtlasAutoRebuildMode.Disable)); - this.FontAtlas.BuildStepChange += this.PrivateAtlasOnBuildStepChange; - this.FontAtlas.RebuildRecommend += this.RebuildFonts; + .CreateFontAtlas(namespaceName, FontAtlasAutoRebuildMode.Async)); } catch { @@ -100,90 +86,34 @@ public sealed class UiBuilder : IDisposable /// The event that gets called when Dalamud is ready to draw your windows or overlays. /// When it is called, you can use static ImGui calls. /// - public event Action Draw; + public event Action? Draw; /// /// The event that is called when the game's DirectX device is requesting you to resize your buffers. /// - public event Action ResizeBuffers; + public event Action? ResizeBuffers; /// /// Event that is fired when the plugin should open its configuration interface. /// - public event Action OpenConfigUi; + public event Action? OpenConfigUi; /// /// Event that is fired when the plugin should open its main interface. /// - public event Action OpenMainUi; - - /// - /// Gets or sets an action that is called any time ImGui fonts need to be rebuilt.
- /// Any ImFontPtr objects that you store can be invalidated when fonts are rebuilt - /// (at any time), so you should both reload your custom fonts and restore those - /// pointers inside this handler. - ///
- /// - /// To add your custom font, use . or - /// .
- /// To be notified on font changes after fonts are built, use - /// ..
- /// For all other purposes, use ..
- ///
- /// Note that you will be calling above functions once, instead of every time inside a build step change callback. - /// For example, you can make all font handles from your plugin constructor, and then use the created handles during - /// event, by using in a scope.
- /// You may dispose your font handle anytime, as long as it's not in use in . - /// Font handles may be constructed anytime, as long as the owner or - /// is not disposed.
- ///
- /// If you were storing , consider if the job can be achieved solely by using - /// without directly using an instance of .
- /// If you do need it, evaluate if you need to access fonts outside the main thread.
- /// If it is the case, use to obtain a safe-to-access instance of - /// , once resolves.
- /// Otherwise, use , and obtain the instance of via - /// . Do not let the escape the using scope.
- ///
- /// If your plugin sets to a non-default value, then - /// should be accessed using - /// , as the font handle member variables are only available - /// once drawing facilities are available.
- ///
- /// Examples:
- /// * .
- /// * .
- /// * ctor.
- /// * : - /// note how the construction of a new instance of and - /// call of are done in different functions, - /// without having to manually initiate font rebuild process. - ///
- [Obsolete("See remarks.", false)] - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public event Action? BuildFonts; - - /// - /// Gets or sets an action that is called any time right after ImGui fonts are rebuilt.
- /// Any ImFontPtr objects that you store can be invalidated when fonts are rebuilt - /// (at any time), so you should both reload your custom fonts and restore those - /// pointers inside this handler. - ///
- [Obsolete($"See remarks for {nameof(BuildFonts)}.", false)] - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public event Action? AfterBuildFonts; + public event Action? OpenMainUi; /// /// Gets or sets an action that is called when plugin UI or interface modifications are supposed to be shown. /// These may be fired consecutively. /// - public event Action ShowUi; + public event Action? ShowUi; /// /// Gets or sets an action that is called when plugin UI or interface modifications are supposed to be hidden. /// These may be fired consecutively. /// - public event Action HideUi; + public event Action? HideUi; /// /// Gets the default Dalamud font size in points. @@ -291,12 +221,12 @@ public sealed class UiBuilder : IDisposable /// /// Gets the game's active Direct3D device. /// - public Device Device => this.InterfaceManagerWithScene.Device!; + public Device Device => this.InterfaceManagerWithScene!.Device!; /// /// Gets the game's main window handle. /// - public IntPtr WindowHandlePtr => this.InterfaceManagerWithScene.WindowHandlePtr; + public IntPtr WindowHandlePtr => this.InterfaceManagerWithScene!.WindowHandlePtr; /// /// Gets or sets a value indicating whether this plugin should hide its UI automatically when the game's UI is hidden. @@ -530,38 +460,6 @@ public sealed class UiBuilder : IDisposable } } - /// - /// Gets a game font. - /// - /// Font to get. - /// Handle to the game font which may or may not be available for use yet. - [Obsolete($"Use {nameof(this.FontAtlas)}.{nameof(IFontAtlas.NewGameFontHandle)} instead.", false)] - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - public GameFontHandle GetGameFontHandle(GameFontStyle style) - { - var prevValue = FontAtlasFactory.IsBuildInProgressForTask.Value; - FontAtlasFactory.IsBuildInProgressForTask.Value = false; - var v = new GameFontHandle( - (GamePrebakedFontHandle)this.FontAtlas.NewGameFontHandle(style), - Service.Get()); - FontAtlasFactory.IsBuildInProgressForTask.Value = prevValue; - return v; - } - - /// - /// Call this to queue a rebuild of the font atlas.
- /// This will invoke any and handlers and ensure that any - /// loaded fonts are ready to be used on the next UI frame. - ///
- public void RebuildFonts() - { - Log.Verbose("[FONT] {0} plugin is initiating FONT REBUILD", this.namespaceName); - if (this.AfterBuildFonts is null && this.BuildFonts is null) - this.FontAtlas.BuildFontsAsync(); - else - this.FontAtlas.BuildFontsOnNextFrame(); - } - /// /// Creates an isolated . /// @@ -635,16 +533,15 @@ public sealed class UiBuilder : IDisposable this.hitchDetector.Start(); var clientState = Service.Get(); - var configuration = Service.Get(); var gameGui = Service.GetNullable(); if (gameGui == null) return; - if ((gameGui.GameUiHidden && configuration.ToggleUiHide && + if ((gameGui.GameUiHidden && this.configuration.ToggleUiHide && !(this.DisableUserUiHide || this.DisableAutomaticUiHide)) || - (this.CutsceneActive && configuration.ToggleUiHideDuringCutscenes && + (this.CutsceneActive && this.configuration.ToggleUiHideDuringCutscenes && !(this.DisableCutsceneUiHide || this.DisableAutomaticUiHide)) || - (clientState.IsGPosing && configuration.ToggleUiHideDuringGpose && + (clientState.IsGPosing && this.configuration.ToggleUiHideDuringGpose && !(this.DisableGposeUiHide || this.DisableAutomaticUiHide))) { if (!this.lastFrameUiHideState) @@ -663,11 +560,8 @@ public sealed class UiBuilder : IDisposable } // just in case, if something goes wrong, prevent drawing; otherwise it probably will crash. - if (!this.FontAtlas.BuildTask.IsCompletedSuccessfully - && (this.BuildFonts is not null || this.AfterBuildFonts is not null)) - { + if (!this.FontAtlas.BuildTask.IsCompletedSuccessfully) return; - } ImGui.PushID(this.namespaceName); if (DoStats) @@ -688,11 +582,7 @@ public sealed class UiBuilder : IDisposable ImGui.End(); } - ImGuiManagedAsserts.ImGuiContextSnapshot snapshot = null; - if (this.Draw != null) - { - snapshot = ImGuiManagedAsserts.GetSnapshot(); - } + var snapshot = this.Draw is null ? null : ImGuiManagedAsserts.GetSnapshot(); try { @@ -708,10 +598,8 @@ public sealed class UiBuilder : IDisposable } // Only if Draw was successful - if (this.Draw != null) - { + if (this.Draw is not null && snapshot is not null) ImGuiManagedAsserts.ReportProblems(this.namespaceName, snapshot); - } this.FrameCount++; @@ -729,41 +617,6 @@ public sealed class UiBuilder : IDisposable this.hitchDetector.Stop(); } - [Api10ToDo(Api10ToDoAttribute.DeleteCompatBehavior)] - private unsafe void PrivateAtlasOnBuildStepChange(IFontAtlasBuildToolkit e) - { - if (e.IsAsyncBuildOperation) - return; - - ThreadSafety.AssertMainThread(); - - if (this.BuildFonts is not null) - { - e.OnPreBuild( - _ => - { - var prev = ImGui.GetIO().NativePtr->Fonts; - ImGui.GetIO().NativePtr->Fonts = e.NewImAtlas.NativePtr; - ((IFontAtlasBuildToolkit.IApi9Compat)e) - .FromUiBuilderObsoleteEventHandlers(() => this.BuildFonts?.InvokeSafely()); - ImGui.GetIO().NativePtr->Fonts = prev; - }); - } - - if (this.AfterBuildFonts is not null) - { - e.OnPostBuild( - _ => - { - var prev = ImGui.GetIO().NativePtr->Fonts; - ImGui.GetIO().NativePtr->Fonts = e.NewImAtlas.NativePtr; - ((IFontAtlasBuildToolkit.IApi9Compat)e) - .FromUiBuilderObsoleteEventHandlers(() => this.AfterBuildFonts?.InvokeSafely()); - ImGui.GetIO().NativePtr->Fonts = prev; - }); - } - } - private void OnResizeBuffers() { this.ResizeBuffers?.InvokeSafely(); diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index 364d65600..f35da0d7e 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -52,7 +52,7 @@ public sealed class DalamudPluginInterface : IDisposable var dataManager = Service.Get(); var localization = Service.Get(); - this.UiBuilder = new UiBuilder(plugin.Name, plugin); + this.UiBuilder = new UiBuilder(plugin.Name); this.configs = Service.Get().PluginConfigs; this.Reason = reason; diff --git a/Dalamud/Plugin/Internal/Types/LocalDevPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalDevPlugin.cs index 9f7c761de..3615f923b 100644 --- a/Dalamud/Plugin/Internal/Types/LocalDevPlugin.cs +++ b/Dalamud/Plugin/Internal/Types/LocalDevPlugin.cs @@ -6,8 +6,8 @@ using System.Threading; using System.Threading.Tasks; using Dalamud.Configuration.Internal; +using Dalamud.Interface.ImGuiNotification; using Dalamud.Interface.ImGuiNotification.Internal; -using Dalamud.Interface.Internal.Notifications; using Dalamud.Logging.Internal; using Dalamud.Plugin.Internal.Types.Manifest; diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs index 0c8777cfe..37d4393b0 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs @@ -4,11 +4,9 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; -using Dalamud.Common.Game; using Dalamud.Configuration.Internal; using Dalamud.Game; using Dalamud.Game.Gui.Dtr; -using Dalamud.Interface.GameFonts; using Dalamud.Interface.Internal; using Dalamud.IoC.Internal; using Dalamud.Logging.Internal; @@ -629,12 +627,6 @@ internal class LocalPlugin : IDisposable config.LoadInMemory = true; config.PreferSharedTypes = false; - // Pin Lumina and its dependencies recursively (compatibility behavior). - // It currently only pulls in System.* anyway. - // TODO(api10): Remove this. We don't want to pin Lumina anymore, plugins should be able to provide their own. - config.SharedAssemblies.Add((typeof(Lumina.GameData).Assembly.GetName(), true)); - config.SharedAssemblies.Add((typeof(Lumina.Excel.ExcelSheetImpl).Assembly.GetName(), true)); - // Make sure that plugins do not load their own Dalamud assembly. // We do not pin this recursively; if a plugin loads its own assembly of Dalamud, it is always wrong, // but plugins may load other versions of assemblies that Dalamud depends on. diff --git a/Dalamud/Plugin/Services/IObjectTable.cs b/Dalamud/Plugin/Services/IObjectTable.cs index e0f671b3c..d8d9fdb78 100644 --- a/Dalamud/Plugin/Services/IObjectTable.cs +++ b/Dalamud/Plugin/Services/IObjectTable.cs @@ -1,16 +1,13 @@ using System.Collections.Generic; using Dalamud.Game.ClientState.Objects.Types; -using Dalamud.Utility; namespace Dalamud.Plugin.Services; /// /// This collection represents the currently spawned FFXIV game objects. /// -[Api10ToDo( - "Make it an IEnumerable instead. Skipping null objects make IReadOnlyCollection.Count yield incorrect values.")] -public interface IObjectTable : IReadOnlyCollection +public interface IObjectTable : IEnumerable { /// /// Gets the address of the object table. diff --git a/Dalamud/Storage/ReliableFileStorage.cs b/Dalamud/Storage/ReliableFileStorage.cs index eab93269e..b78d16cc7 100644 --- a/Dalamud/Storage/ReliableFileStorage.cs +++ b/Dalamud/Storage/ReliableFileStorage.cs @@ -22,22 +22,18 @@ namespace Dalamud.Storage; /// This is not an early-loaded service, as it is needed before they are initialized. /// [ServiceManager.ProvidedService] -[Api10ToDo("Make internal and IInternalDisposableService, and remove #pragma guard from the caller.")] -public class ReliableFileStorage : IPublicDisposableService +internal class ReliableFileStorage : IInternalDisposableService { private static readonly ModuleLog Log = new("VFS"); private readonly object syncRoot = new(); private SQLiteConnection? db; - private bool isService; /// /// Initializes a new instance of the class. /// /// Path to the VFS. - [Obsolete("Dalamud internal use only.", false)] - [Api10ToDo("Make internal, and remove #pragma guard from the caller.")] public ReliableFileStorage(string vfsDbPath) { var databasePath = Path.Combine(vfsDbPath, "dalamudVfs.db"); @@ -290,23 +286,12 @@ public class ReliableFileStorage : IPublicDisposableService } } - /// - public void Dispose() - { - if (!this.isService) - this.DisposeCore(); - } - /// void IInternalDisposableService.DisposeService() { - if (this.isService) - this.DisposeCore(); + this.DisposeCore(); } - /// - void IPublicDisposableService.MarkDisposeOnlyFromService() => this.isService = true; - /// /// Replace possible non-portable parts of a path with portable versions. ///