diff --git a/.gitmodules b/.gitmodules index 124f5f86b..873dc9569 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "lib/Hexa.NET.ImGui"] path = lib/Hexa.NET.ImGui url = https://github.com/HexaEngine/Hexa.NET.ImGui.git +[submodule "lib/ImGui.NET"] + path = lib/ImGui.NET + url = https://github.com/goatcorp/ImGui.NET.git diff --git a/Dalamud.sln b/Dalamud.sln index f469adee7..3d371c3d4 100644 --- a/Dalamud.sln +++ b/Dalamud.sln @@ -72,6 +72,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bindings", "Bindings", "{A2 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StandaloneImGuiTestbed", "imgui\StandaloneImGuiTestbed\StandaloneImGuiTestbed.csproj", "{4702A911-2513-478C-A434-2776393FDE77}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGui.NET-472", "lib\ImGui.NET\src\ImGui.NET-472\ImGui.NET-472.csproj", "{FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -162,6 +164,10 @@ Global {4702A911-2513-478C-A434-2776393FDE77}.Debug|Any CPU.Build.0 = Debug|x64 {4702A911-2513-478C-A434-2776393FDE77}.Release|Any CPU.ActiveCfg = Release|x64 {4702A911-2513-478C-A434-2776393FDE77}.Release|Any CPU.Build.0 = Release|x64 + {FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}.Debug|Any CPU.ActiveCfg = Debug|x64 + {FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}.Debug|Any CPU.Build.0 = Debug|x64 + {FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}.Release|Any CPU.ActiveCfg = Release|x64 + {FAD7F842-2E81-456F-8AE8-DFFEDC258EC3}.Release|Any CPU.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -184,6 +190,7 @@ Global {5E6EDD75-AE95-43A6-9D67-95B840EB4B71} = {A217B3DF-607A-4EFB-B107-3C4809348043} {9C70BD06-D52C-425E-9C14-5D66BC6046EF} = {A217B3DF-607A-4EFB-B107-3C4809348043} {4702A911-2513-478C-A434-2776393FDE77} = {A217B3DF-607A-4EFB-B107-3C4809348043} + {FAD7F842-2E81-456F-8AE8-DFFEDC258EC3} = {DBE5345E-6594-4A59-B183-1C3D5592269D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {79B65AC9-C940-410E-AB61-7EA7E12C7599} diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index 5456d2fac..5eb8a3471 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -112,6 +112,7 @@ + diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs index a15fce906..ed45ec7fc 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Numerics; using Dalamud.Bindings.ImGui; +using Dalamud.Interface.Internal; using Dalamud.Interface.Utility; using Dalamud.Utility; @@ -152,7 +153,7 @@ public partial class FileDialog private void DrawPathComposer() { - ImGui.PushFont(UiBuilder.IconFont); + ImGui.PushFont(InterfaceManager.IconFont); if (ImGui.Button(this.pathInputActivated ? FontAwesomeIcon.Times.ToIconString() : FontAwesomeIcon.Edit.ToIconString())) { this.pathInputActivated = !this.pathInputActivated; @@ -205,7 +206,7 @@ public partial class FileDialog private void DrawSearchBar() { - ImGui.PushFont(UiBuilder.IconFont); + ImGui.PushFont(InterfaceManager.IconFont); if (ImGui.Button(FontAwesomeIcon.Home.ToIconString())) { this.SetPath("."); @@ -239,7 +240,7 @@ public partial class FileDialog { if (this.flags.HasFlag(ImGuiFileDialogFlags.DisableCreateDirectoryButton)) return; - ImGui.PushFont(UiBuilder.IconFont); + ImGui.PushFont(InterfaceManager.IconFont); if (ImGui.Button(FontAwesomeIcon.FolderPlus.ToIconString()) && !this.createDirectoryMode) { this.createDirectoryMode = true; @@ -328,7 +329,7 @@ public partial class FileDialog this.selectedSideBar = qa.Text; } - ImGui.PushFont(UiBuilder.IconFont); + ImGui.PushFont(InterfaceManager.IconFont); ImGui.SameLine(); ImGui.SetCursorPosX(0); ImGui.TextUnformatted(qa.Icon.ToIconString()); @@ -493,7 +494,7 @@ public partial class FileDialog { const ImGuiSelectableFlags flags = ImGuiSelectableFlags.AllowDoubleClick | ImGuiSelectableFlags.SpanAllColumns; - ImGui.PushFont(UiBuilder.IconFont); + ImGui.PushFont(InterfaceManager.IconFont); ImGui.TextUnformatted(icon.ToIconString()); ImGui.PopFont(); diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index 736f0072c..d392403be 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -720,7 +720,7 @@ internal partial class InterfaceManager : IInternalDisposableService // NOTE (Chiv) Explicitly deactivate on dalamud boot ImGui.GetIO().ConfigFlags &= ~ImGuiConfigFlags.NavEnableGamepad; - ImGuiHelpers.MainViewport = ImGui.GetMainViewport(); + ImGuiHelpers.MainViewportNew = ImGui.GetMainViewport(); Log.Information("[IM] Scene & ImGui setup OK!"); } diff --git a/Dalamud/Interface/Internal/UiDebug.cs b/Dalamud/Interface/Internal/UiDebug.cs index 2c78457e7..9410bb371 100644 --- a/Dalamud/Interface/Internal/UiDebug.cs +++ b/Dalamud/Interface/Internal/UiDebug.cs @@ -672,6 +672,6 @@ internal unsafe class UiDebug position += ImGuiHelpers.MainViewport.Pos; - ImGui.GetForegroundDrawList(ImGuiHelpers.MainViewport).AddRect(position, position + size, nodeVisible ? 0xFF00FF00 : 0xFF0000FF); + ImGui.GetForegroundDrawList(ImGuiHelpers.MainViewportNew).AddRect(position, position + size, nodeVisible ? 0xFF00FF00 : 0xFF0000FF); } } diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 929c2afa6..20e7c564c 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -3885,7 +3885,7 @@ internal class PluginInstallerWindow : Window, IDisposable { var positionOffset = ImGuiHelpers.ScaledVector2(0.0f, 1.0f); var cursorStart = ImGui.GetCursorPos() + positionOffset; - ImGui.PushFont(UiBuilder.IconFont); + ImGui.PushFont(InterfaceManager.IconFont); ImGui.PushStyleColor(ImGuiCol.Text, outline); foreach (var x in Enumerable.Range(-1, 3)) diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs index ff1df30c5..ee3d75ff0 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs @@ -56,7 +56,7 @@ public class SettingsTabDtr : SettingsTab // TODO: Maybe we can also resort the rest of the bar in the future? // var isRequired = search is Configuration.SearchSetting.Internal or Configuration.SearchSetting.MacroLinks; - ImGui.PushFont(UiBuilder.IconFont); + ImGui.PushFont(UiBuilder.IconFontNew); var arrowUpText = $"{FontAwesomeIcon.ArrowUp.ToIconString()}##{title}"; if (i == 0) diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index 3193cb6bc..dbcda7022 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -333,19 +333,67 @@ public sealed class UiBuilder : IDisposable, IUiBuilder /// Gets the default Dalamud font - supporting all game languages and icons.
/// Accessing this static property outside of is dangerous and not supported. /// - public static ImFontPtr DefaultFont => InterfaceManager.DefaultFont; + public static ImFontPtr DefaultFontNew => InterfaceManager.DefaultFont; /// /// Gets the default Dalamud icon font based on FontAwesome 5 Free solid.
/// Accessing this static property outside of is dangerous and not supported. ///
- public static ImFontPtr IconFont => InterfaceManager.IconFont; + public static ImFontPtr IconFontNew => InterfaceManager.IconFont; /// /// Gets the default Dalamud monospaced font based on Inconsolata Regular.
/// Accessing this static property outside of is dangerous and not supported. ///
- public static ImFontPtr MonoFont => InterfaceManager.MonoFont; + public static ImFontPtr MonoFontNew => InterfaceManager.MonoFont; + + /// + /// Gets the default Dalamud font - supporting all game languages and icons.
+ /// Accessing this static property outside of is dangerous and not supported. + ///
+ [ImGuiBindingsToDo("Remove, rename New variant.")] + public static ImGuiNET.ImFontPtr DefaultFont + { + get + { + unsafe + { + return new ImGuiNET.ImFontPtr((nint)InterfaceManager.DefaultFont.Handle); + } + } + } + + /// + /// Gets the default Dalamud icon font based on FontAwesome 5 Free solid.
+ /// Accessing this static property outside of is dangerous and not supported. + ///
+ [ImGuiBindingsToDo("Remove, rename New variant.")] + public static ImGuiNET.ImFontPtr IconFont + { + get + { + unsafe + { + return new ImGuiNET.ImFontPtr((nint)InterfaceManager.IconFont.Handle); + } + } + } + + /// + /// Gets the default Dalamud monospaced font based on Inconsolata Regular.
+ /// Accessing this static property outside of is dangerous and not supported. + ///
+ [ImGuiBindingsToDo("Remove, rename New variant.")] + public static ImGuiNET.ImFontPtr MonoFont + { + get + { + unsafe + { + return new ImGuiNET.ImFontPtr((nint)InterfaceManager.MonoFont.Handle); + } + } + } /// /// Gets the default font specifications. diff --git a/Dalamud/Interface/Utility/ImGuiHelpers.cs b/Dalamud/Interface/Utility/ImGuiHelpers.cs index ac3cfff47..9a5fa16be 100644 --- a/Dalamud/Interface/Utility/ImGuiHelpers.cs +++ b/Dalamud/Interface/Utility/ImGuiHelpers.cs @@ -18,7 +18,9 @@ using Dalamud.Interface.ImGuiSeStringRenderer.Internal; using Dalamud.Interface.ManagedFontAtlas; using Dalamud.Interface.ManagedFontAtlas.Internals; using Dalamud.Interface.Utility.Raii; +using Dalamud.Utility; +using ImGuiViewport = ImGuiNET.ImGuiViewport; using VirtualKey = Dalamud.Game.ClientState.Keys.VirtualKey; namespace Dalamud.Interface.Utility; @@ -31,7 +33,22 @@ public static partial class ImGuiHelpers /// /// Gets the main viewport. /// - public static ImGuiViewportPtr MainViewport { get; internal set; } + public static ImGuiViewportPtr MainViewportNew { get; internal set; } + + /// + /// Gets the main viewport. + /// + [ImGuiBindingsToDo("Remove and rename MainViewportNew to MainViewport")] + public static ImGuiNET.ImGuiViewportPtr MainViewport + { + get + { + unsafe + { + return new ImGuiNET.ImGuiViewportPtr((nint)MainViewportNew.Handle); + } + } + } /// /// Gets the global Dalamud scale. diff --git a/Dalamud/Interface/Utility/Raii/Color.cs b/Dalamud/Interface/Utility/Raii/Color.cs index 98a09d4f8..36c10acf3 100644 --- a/Dalamud/Interface/Utility/Raii/Color.cs +++ b/Dalamud/Interface/Utility/Raii/Color.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Numerics; using Dalamud.Bindings.ImGui; +using Dalamud.Utility; namespace Dalamud.Interface.Utility.Raii; @@ -16,6 +17,14 @@ public static partial class ImRaii public static Color PushColor(ImGuiCol idx, Vector4 color, bool condition = true) => new Color().Push(idx, color, condition); + [ImGuiBindingsToDo("Remove.")] + public static Color PushColor(ImGuiNET.ImGuiCol idx, uint color, bool condition = true) + => new Color().Push(idx, color, condition); + + [ImGuiBindingsToDo("Remove.")] + public static Color PushColor(ImGuiNET.ImGuiCol idx, Vector4 color, bool condition = true) + => new Color().Push(idx, color, condition); + // Push colors that revert all current color changes made temporarily. public static Color DefaultColors() { @@ -31,6 +40,7 @@ public static partial class ImRaii internal static readonly List<(ImGuiCol, uint)> Stack = new(); private int count; + [ImGuiBindingsToDo("Remove.")] public Color Push(ImGuiCol idx, uint color, bool condition = true) { if (condition) @@ -43,6 +53,7 @@ public static partial class ImRaii return this; } + [ImGuiBindingsToDo("Remove.")] public Color Push(ImGuiCol idx, Vector4 color, bool condition = true) { if (condition) @@ -55,6 +66,12 @@ public static partial class ImRaii return this; } + public Color Push(ImGuiNET.ImGuiCol idx, uint color, bool condition = true) + => this.Push((ImGuiCol)idx, color, condition); + + public Color Push(ImGuiNET.ImGuiCol idx, Vector4 color, bool condition = true) + => this.Push((ImGuiCol)idx, color, condition); + public void Pop(int num = 1) { num = Math.Min(num, this.count); diff --git a/Dalamud/Interface/Utility/Raii/Font.cs b/Dalamud/Interface/Utility/Raii/Font.cs index 1b5e8cc58..18c1ce94e 100644 --- a/Dalamud/Interface/Utility/Raii/Font.cs +++ b/Dalamud/Interface/Utility/Raii/Font.cs @@ -1,4 +1,5 @@ using Dalamud.Bindings.ImGui; +using Dalamud.Utility; namespace Dalamud.Interface.Utility.Raii; @@ -9,6 +10,10 @@ public static partial class ImRaii public static Font PushFont(ImFontPtr font, bool condition = true) => condition ? new Font().Push(font) : new Font(); + [ImGuiBindingsToDo("Remove.")] + public static Font PushFont(ImGuiNET.ImFontPtr font, bool condition = true) + => condition ? new Font().Push(font) : new Font(); + // Push the default font if any other font is currently pushed. public static Font DefaultFont() => new Font().Push(Font.DefaultPushed, Font.FontPushCounter > 0); @@ -36,6 +41,12 @@ public static partial class ImRaii return this; } + [ImGuiBindingsToDo("Remove.")] + public unsafe Font Push(ImGuiNET.ImFontPtr font, bool condition = true) + { + return this.Push(new ImFontPtr((ImFont*)font.NativePtr), condition); + } + public void Pop(int num = 1) { num = Math.Min(num, this.count); diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index 2694d63fd..2ba1e9925 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -14,6 +14,8 @@ using Dalamud.Interface.Internal; using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing.Persistence; using Dalamud.Logging.Internal; +using Dalamud.Utility; + using FFXIVClientStructs.FFXIV.Client.UI; using PInvoke; @@ -56,6 +58,34 @@ public abstract class Window this.ForceMainWindow = forceMainWindow; } + /// + /// Initializes a new instance of the class. + /// + /// The name/ID of this window. + /// If you have multiple windows with the same name, you will need to + /// append a unique ID to it by specifying it after "###" behind the window title. + /// + /// The of this window. + /// Whether this window should be limited to the main game window. + [ImGuiBindingsToDo("Remove.")] + protected Window( + string name, ImGuiNET.ImGuiWindowFlags flags = ImGuiNET.ImGuiWindowFlags.None, bool forceMainWindow = false) + : this(name, (ImGuiWindowFlags)flags, forceMainWindow) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The name/ID of this window. + /// If you have multiple windows with the same name, you will need to + /// append a unique ID to it by specifying it after "###" behind the window title. + /// + protected Window(string name) + : this(name, ImGuiWindowFlags.None) + { + } + /// /// Flags to control window behavior. /// diff --git a/Dalamud/Utility/ImGuiBindingsToDoAttribute.cs b/Dalamud/Utility/ImGuiBindingsToDoAttribute.cs new file mode 100644 index 000000000..60f15c056 --- /dev/null +++ b/Dalamud/Utility/ImGuiBindingsToDoAttribute.cs @@ -0,0 +1,24 @@ +namespace Dalamud.Utility; + +/// +/// Utility class for marking something to be changed for when the new bindings are fully adopted, for ease of lookup. +/// +[AttributeUsage(AttributeTargets.All, Inherited = false)] +internal sealed class ImGuiBindingsToDoAttribute : Attribute +{ + /// + /// Marks that this should be made internal. + /// + public const string MakeInternal = "Make internal."; + + /// + /// Initializes a new instance of the class. + /// + /// The explanation. + /// The explanation 2. + public ImGuiBindingsToDoAttribute(string what, string what2 = "") + { + _ = what; + _ = what2; + } +} diff --git a/lib/ImGui.NET b/lib/ImGui.NET new file mode 160000 index 000000000..98304cfd0 --- /dev/null +++ b/lib/ImGui.NET @@ -0,0 +1 @@ +Subproject commit 98304cfd0bf86cf176732d60eb5dba6fc351f737