diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index 1166c24c0..890202967 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -6,7 +6,7 @@ XIV Launcher addon framework - 13.0.0.8 + 13.0.0.7 $(DalamudVersion) $(DalamudVersion) $(DalamudVersion) diff --git a/Dalamud/Game/Gui/Dtr/DtrBar.cs b/Dalamud/Game/Gui/Dtr/DtrBar.cs index 2235c5ade..bd8d8e1d7 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBar.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBar.cs @@ -257,7 +257,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar /// The resources to remove. internal void RemoveEntry(DtrBarEntry toRemove) { - this.RemoveNode(toRemove); + this.RemoveNode(toRemove.TextNode); if (toRemove.Storage != null) { @@ -378,12 +378,12 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar var isHide = !data.Shown || data.UserHidden; var node = data.TextNode; - var nodeHidden = !node->IsVisible(); + var nodeHidden = !node->AtkResNode.IsVisible(); if (!isHide) { if (nodeHidden) - node->ToggleVisibility(true); + node->AtkResNode.ToggleVisibility(true); if (data is { Added: true, Text: not null, TextNode: not null } && (data.Dirty || nodeHidden)) { @@ -397,27 +397,27 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar ushort w = 0, h = 0; node->GetTextDrawSize(&w, &h, node->NodeText.StringPtr); - node->SetWidth(w); + node->AtkResNode.SetWidth(w); } - var elementWidth = data.TextNode->Width + this.configuration.DtrSpacing; + var elementWidth = data.TextNode->AtkResNode.Width + this.configuration.DtrSpacing; if (this.configuration.DtrSwapDirection) { - data.TextNode->SetPositionFloat(runningXPos + this.configuration.DtrSpacing, 2); + data.TextNode->AtkResNode.SetPositionFloat(runningXPos + this.configuration.DtrSpacing, 2); runningXPos += elementWidth; } else { runningXPos -= elementWidth; - data.TextNode->SetPositionFloat(runningXPos, 2); + data.TextNode->AtkResNode.SetPositionFloat(runningXPos, 2); } } else if (!nodeHidden) { // If we want the node hidden, shift it up, to prevent collision conflicts - node->SetYFloat(-collisionNode->Height * dtr->RootNode->ScaleX); - node->ToggleVisibility(false); + node->AtkResNode.SetYFloat(-collisionNode->Height * dtr->RootNode->ScaleX); + node->AtkResNode.ToggleVisibility(false); } data.Dirty = false; @@ -516,8 +516,8 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar var node = data.TextNode = this.MakeNode(++this.runningNodeIds); - this.eventHandles.TryAdd(node->NodeId, new List()); - this.eventHandles[node->NodeId].AddRange(new List + this.eventHandles.TryAdd(node->AtkResNode.NodeId, new List()); + this.eventHandles[node->AtkResNode.NodeId].AddRange(new List { this.uiEventManager.AddEvent(AddonEventManager.DalamudInternalKey, (nint)dtr, (nint)node, AddonEventType.MouseOver, this.DtrEventHandler), this.uiEventManager.AddEvent(AddonEventManager.DalamudInternalKey, (nint)dtr, (nint)node, AddonEventType.MouseOut, this.DtrEventHandler), @@ -528,8 +528,8 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar while (lastChild->PrevSiblingNode != null) lastChild = lastChild->PrevSiblingNode; Log.Debug($"Found last sibling: {(ulong)lastChild:X}"); lastChild->PrevSiblingNode = (AtkResNode*)node; - node->ParentNode = lastChild->ParentNode; - node->NextSiblingNode = lastChild; + node->AtkResNode.ParentNode = lastChild->ParentNode; + node->AtkResNode.NextSiblingNode = lastChild; dtr->RootNode->ChildCount = (ushort)(dtr->RootNode->ChildCount + 1); Log.Debug("Set last sibling of DTR and updated child count"); @@ -542,31 +542,22 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar return true; } - private void RemoveNode(DtrBarEntry data) + private void RemoveNode(AtkTextNode* node) { var dtr = this.GetDtr(); - var node = data.TextNode; if (dtr == null || dtr->RootNode == null || dtr->UldManager.NodeList == null || node == null) return; - if (this.eventHandles.TryGetValue(node->NodeId, out var eventHandles)) - { - eventHandles.ForEach(handle => this.uiEventManager.RemoveEvent(AddonEventManager.DalamudInternalKey, handle)); - eventHandles.Clear(); - } - else - { - Log.Warning("Could not find AtkResNode with NodeId {nodeId} in eventHandles", node->NodeId); - } + this.eventHandles[node->AtkResNode.NodeId].ForEach(handle => this.uiEventManager.RemoveEvent(AddonEventManager.DalamudInternalKey, handle)); + this.eventHandles[node->AtkResNode.NodeId].Clear(); - var tmpPrevNode = node->PrevSiblingNode; - var tmpNextNode = node->NextSiblingNode; + var tmpPrevNode = node->AtkResNode.PrevSiblingNode; + var tmpNextNode = node->AtkResNode.NextSiblingNode; // if (tmpNextNode != null) tmpNextNode->PrevSiblingNode = tmpPrevNode; if (tmpPrevNode != null) tmpPrevNode->NextSiblingNode = tmpNextNode; - node->Destroy(true); - data.TextNode = null; + node->AtkResNode.Destroy(true); dtr->RootNode->ChildCount = (ushort)(dtr->RootNode->ChildCount - 1); Log.Debug("Set last sibling of DTR and updated child count"); @@ -584,13 +575,13 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar return null; } - newTextNode->NodeId = nodeId; - newTextNode->Type = NodeType.Text; - newTextNode->NodeFlags = NodeFlags.AnchorLeft | NodeFlags.AnchorTop | NodeFlags.Enabled | NodeFlags.RespondToMouse | NodeFlags.HasCollision | NodeFlags.EmitsEvents; - newTextNode->DrawFlags = 12; - newTextNode->SetWidth(22); - newTextNode->SetHeight(22); - newTextNode->SetPositionFloat(-200, 2); + newTextNode->AtkResNode.NodeId = nodeId; + newTextNode->AtkResNode.Type = NodeType.Text; + newTextNode->AtkResNode.NodeFlags = NodeFlags.AnchorLeft | NodeFlags.AnchorTop | NodeFlags.Enabled | NodeFlags.RespondToMouse | NodeFlags.HasCollision | NodeFlags.EmitsEvents; + newTextNode->AtkResNode.DrawFlags = 12; + newTextNode->AtkResNode.SetWidth(22); + newTextNode->AtkResNode.SetHeight(22); + newTextNode->AtkResNode.SetPositionFloat(-200, 2); newTextNode->LineSpacing = 12; newTextNode->AlignmentFontType = 5; diff --git a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs index f5b7011fe..6fdc504ca 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs @@ -1,6 +1,4 @@ -using System.Numerics; - -using Dalamud.Configuration.Internal; +using Dalamud.Configuration.Internal; using Dalamud.Game.Addon.Events.EventDataTypes; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Plugin.Internal.Types; @@ -50,11 +48,6 @@ public interface IReadOnlyDtrBarEntry /// Gets an action to be invoked when the user clicks on the dtr entry. /// public Action? OnClick { get; } - - /// - /// Gets the axis-aligned bounding box of this entry, in screen coordinates. - /// - public (Vector2 Min, Vector2 Max) ScreenBounds { get; } } /// @@ -153,17 +146,6 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry [Api13ToDo("Maybe make this config scoped to internal name?")] public bool UserHidden => this.configuration.DtrIgnore?.Contains(this.Title) ?? false; - /// - public (Vector2 Min, Vector2 Max) ScreenBounds - => this.TextNode switch - { - null => default, - var node => node->IsVisible() - ? (new(node->ScreenX, node->ScreenY), - new(node->ScreenX + node->GetWidth(), node->ScreenY + node->GetHeight())) - : default, - }; - /// /// Gets or sets the internal text node of this entry. /// diff --git a/Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs b/Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs index f7250e528..5caf8b5be 100644 --- a/Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs +++ b/Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs @@ -83,12 +83,25 @@ public class BranchSwitcherWindow : Window ImGuiHelpers.ScaledDummy(5); - if (ImGui.Button("Pick & Restart"u8)) + void Pick() { var config = Service.Get(); config.DalamudBetaKind = pickedBranch.Key; config.DalamudBetaKey = pickedBranch.Value.Key; config.QueueSave(); + } + + if (ImGui.Button("Pick"u8)) + { + Pick(); + this.IsOpen = false; + } + + ImGui.SameLine(); + + if (ImGui.Button("Pick & Restart"u8)) + { + Pick(); // If we exit immediately, we need to write out the new config now Service.Get().ForceSave(); @@ -98,16 +111,7 @@ public class BranchSwitcherWindow : Window if (File.Exists(xlPath)) { - var ps = new ProcessStartInfo - { - FileName = xlPath, - UseShellExecute = false, - }; - - ps.ArgumentList.Add($"--dalamud-beta-kind={config.DalamudBetaKind}"); - ps.ArgumentList.Add($"--dalamud-beta-key={config.DalamudBetaKey}"); - - Process.Start(ps); + Process.Start(xlPath); Environment.Exit(0); } } diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index 8455ce164..39a4e7e4b 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -5,7 +5,6 @@ using System.Globalization; using System.IO; using System.Linq; using System.Reflection; -using System.Runtime.Loader; using System.Threading.Tasks; using Dalamud.Configuration; @@ -104,7 +103,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa /// /// Gets a value indicating whether auto-updates have already completed this session. /// - public bool IsAutoUpdateComplete => Service.GetNullable()?.IsAutoUpdateComplete ?? false; + public bool IsAutoUpdateComplete => Service.Get().IsAutoUpdateComplete; /// /// Gets the repository from which this plugin was installed. @@ -270,30 +269,6 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa return true; } - /// - /// Gets the plugin the given assembly is part of. - /// - /// The assembly to check. - /// The plugin the given assembly is part of, or null if this is a shared assembly or if this information cannot be determined. - public IExposedPlugin? GetPlugin(Assembly assembly) - => AssemblyLoadContext.GetLoadContext(assembly) switch - { - null => null, - var context => this.GetPlugin(context), - }; - - /// - /// Gets the plugin that loads in the given context. - /// - /// The context to check. - /// The plugin that loads in the given context, or null if this isn't a plugin's context or if this information cannot be determined. - public IExposedPlugin? GetPlugin(AssemblyLoadContext context) - => Service.Get().InstalledPlugins.FirstOrDefault(p => p.LoadsIn(context)) switch - { - null => null, - var p => new ExposedPlugin(p), - }; - #region IPC /// diff --git a/Dalamud/Plugin/IDalamudPluginInterface.cs b/Dalamud/Plugin/IDalamudPluginInterface.cs index e1dd34f87..b8ab55450 100644 --- a/Dalamud/Plugin/IDalamudPluginInterface.cs +++ b/Dalamud/Plugin/IDalamudPluginInterface.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; -using System.Reflection; -using System.Runtime.Loader; using System.Threading.Tasks; using Dalamud.Configuration; @@ -182,20 +180,6 @@ public interface IDalamudPluginInterface /// Returns false if the DalamudInterface was null. bool OpenDeveloperMenu(); - /// - /// Gets the plugin the given assembly is part of. - /// - /// The assembly to check. - /// The plugin the given assembly is part of, or null if this is a shared assembly or if this information cannot be determined. - IExposedPlugin? GetPlugin(Assembly assembly); - - /// - /// Gets the plugin that loads in the given context. - /// - /// The context to check. - /// The plugin that loads in the given context, or null if this isn't a plugin's context or if this information cannot be determined. - IExposedPlugin? GetPlugin(AssemblyLoadContext context); - /// T GetOrCreateData(string tag, Func dataGenerator) where T : class; diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs index 0197683ef..da8ec8ff9 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using System.Reflection; using System.Runtime.ExceptionServices; -using System.Runtime.Loader; using System.Threading; using System.Threading.Tasks; @@ -554,14 +553,6 @@ internal class LocalPlugin : IAsyncDisposable }); } - /// - /// Checks whether this plugin loads in the given load context. - /// - /// The load context to check. - /// Whether this plugin loads in the given load context. - public bool LoadsIn(AssemblyLoadContext context) - => this.loader?.LoadContext == context; - /// /// Save this plugin manifest. ///