Merge branch 'master' into master

This commit is contained in:
MidoriKami 2023-01-26 19:10:52 -08:00 committed by GitHub
commit 63ff09de5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
662 changed files with 80934 additions and 15717 deletions

View file

@ -144,8 +144,8 @@ internal class DalamudInterface : IDisposable, IServiceType
this.tsmLogoTexture = tsmLogoTex;
var tsm = Service<TitleScreenMenu>.Get();
tsm.AddEntryCore(Loc.Localize("TSMDalamudPlugins", "Plugin Installer"), this.tsmLogoTexture, () => this.pluginWindow.IsOpen = true);
tsm.AddEntryCore(Loc.Localize("TSMDalamudSettings", "Dalamud Settings"), this.tsmLogoTexture, () => this.settingsWindow.IsOpen = true);
tsm.AddEntryCore(Loc.Localize("TSMDalamudPlugins", "Plugin Installer"), this.tsmLogoTexture, this.OpenPluginInstaller);
tsm.AddEntryCore(Loc.Localize("TSMDalamudSettings", "Dalamud Settings"), this.tsmLogoTexture, this.OpenSettings);
if (!configuration.DalamudBetaKind.IsNullOrEmpty())
{
@ -239,47 +239,83 @@ internal class DalamudInterface : IDisposable, IServiceType
/// <summary>
/// Opens the <see cref="ConsoleWindow"/>.
/// </summary>
public void OpenLogWindow() => this.consoleWindow.IsOpen = true;
public void OpenLogWindow()
{
this.consoleWindow.IsOpen = true;
this.consoleWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="PluginStatWindow"/>.
/// </summary>
public void OpenPluginStats() => this.pluginStatWindow.IsOpen = true;
public void OpenPluginStats()
{
this.pluginStatWindow.IsOpen = true;
this.pluginStatWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/>.
/// </summary>
public void OpenPluginInstaller() => this.pluginWindow.IsOpen = true;
public void OpenPluginInstaller()
{
this.pluginWindow.IsOpen = true;
this.pluginWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="PluginInstallerWindow"/> on the plugin changelogs.
/// </summary>
public void OpenPluginInstallerPluginChangelogs() => this.pluginWindow.OpenPluginChangelogs();
public void OpenPluginInstallerPluginChangelogs()
{
this.pluginWindow.OpenPluginChangelogs();
this.pluginWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="SettingsWindow"/>.
/// </summary>
public void OpenSettings() => this.settingsWindow.IsOpen = true;
public void OpenSettings()
{
this.settingsWindow.IsOpen = true;
this.settingsWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="SelfTestWindow"/>.
/// </summary>
public void OpenSelfTest() => this.selfTestWindow.IsOpen = true;
public void OpenSelfTest()
{
this.selfTestWindow.IsOpen = true;
this.selfTestWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="StyleEditorWindow"/>.
/// </summary>
public void OpenStyleEditor() => this.styleEditorWindow.IsOpen = true;
public void OpenStyleEditor()
{
this.styleEditorWindow.IsOpen = true;
this.styleEditorWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="ProfilerWindow"/>.
/// </summary>
public void OpenProfiler() => this.profilerWindow.IsOpen = true;
public void OpenProfiler()
{
this.profilerWindow.IsOpen = true;
this.profilerWindow.BringToFront();
}
/// <summary>
/// Opens the <see cref="BranchSwitcherWindow"/>.
/// </summary>
public void OpenBranchSwitcher() => this.branchSwitcherWindow.IsOpen = true;
public void OpenBranchSwitcher()
{
this.branchSwitcherWindow.IsOpen = true;
this.branchSwitcherWindow.BringToFront();
}
#endregion

View file

@ -45,6 +45,9 @@ internal class PluginImageCache : IDisposable, IServiceType
private const string MainRepoImageUrl = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api6/{0}/{1}/images/{2}";
private const string MainRepoDip17ImageUrl = "https://raw.githubusercontent.com/goatcorp/PluginDistD17/main/{0}/{1}/images/{2}";
[ServiceManager.ServiceDependency]
private readonly InterfaceManager.InterfaceManagerWithScene imWithScene = Service<InterfaceManager.InterfaceManagerWithScene>.Get();
private readonly BlockingCollection<Tuple<ulong, Func<Task>>> downloadQueue = new();
private readonly BlockingCollection<Func<Task>> loadQueue = new();
private readonly CancellationTokenSource cancelToken = new();
@ -68,9 +71,8 @@ internal class PluginImageCache : IDisposable, IServiceType
[ServiceManager.ServiceConstructor]
private PluginImageCache(Dalamud dalamud)
{
var imwst = Service<InterfaceManager.InterfaceManagerWithScene>.GetAsync();
Task<TextureWrap>? TaskWrapIfNonNull(TextureWrap? tw) => tw == null ? null : Task.FromResult(tw!);
var imwst = Task.Run(() => this.imWithScene);
this.emptyTextureTask = imwst.ContinueWith(task => task.Result.Manager.LoadImageRaw(new byte[64], 8, 8, 4)!);
this.defaultIconTask = imwst.ContinueWith(task => TaskWrapIfNonNull(task.Result.Manager.LoadImage(Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "defaultIcon.png"))) ?? this.emptyTextureTask).Unwrap();
@ -297,7 +299,7 @@ internal class PluginImageCache : IDisposable, IServiceType
return false;
}
private static async Task<TextureWrap?> TryLoadImage(
private async Task<TextureWrap?> TryLoadImage(
byte[]? bytes,
string name,
string? loc,
@ -309,7 +311,7 @@ internal class PluginImageCache : IDisposable, IServiceType
if (bytes == null)
return null;
var interfaceManager = (await Service<InterfaceManager.InterfaceManagerWithScene>.GetAsync()).Manager;
var interfaceManager = this.imWithScene.Manager;
var framework = await Service<Framework>.GetAsync();
TextureWrap? image;
@ -453,8 +455,6 @@ internal class PluginImageCache : IDisposable, IServiceType
private async Task LoadTask(int concurrency)
{
await Service<InterfaceManager.InterfaceManagerWithScene>.GetAsync();
var token = this.cancelToken.Token;
var runningTasks = new List<Task>();
while (true)
@ -500,7 +500,7 @@ internal class PluginImageCache : IDisposable, IServiceType
() => File.ReadAllBytesAsync(file.FullName),
requestedFrame);
var fileIcon = await this.RunInLoadQueue(
() => TryLoadImage(
() => this.TryLoadImage(
fileBytes,
"icon",
file.FullName,
@ -548,7 +548,7 @@ internal class PluginImageCache : IDisposable, IServiceType
return null;
var icon = await this.RunInLoadQueue(
() => TryLoadImage(bytes, "icon", url, manifest, PluginIconWidth, PluginIconHeight, true));
() => this.TryLoadImage(bytes, "icon", url, manifest, PluginIconWidth, PluginIconHeight, true));
if (icon != null)
Log.Verbose($"Plugin icon for {manifest.InternalName} loaded");
return icon;
@ -573,7 +573,7 @@ internal class PluginImageCache : IDisposable, IServiceType
() => File.ReadAllBytesAsync(file.FullName),
requestedFrame);
var image = await this.RunInLoadQueue(
() => TryLoadImage(
() => this.TryLoadImage(
bytes,
$"image{i2 + 1}",
file.FullName,
@ -639,7 +639,7 @@ internal class PluginImageCache : IDisposable, IServiceType
if (bytes == null)
return;
var image = await TryLoadImage(
var image = await this.TryLoadImage(
bytes,
$"image{i2 + 1}",
"queue",

View file

@ -15,6 +15,7 @@ public abstract class Window
private bool internalLastIsOpen = false;
private bool internalIsOpen = false;
private bool nextFrameBringToFront = false;
/// <summary>
/// Initializes a new instance of the <see cref="Window"/> class.
@ -126,6 +127,17 @@ public abstract class Window
this.IsOpen ^= true;
}
/// <summary>
/// Bring this window to the front.
/// </summary>
public void BringToFront()
{
if (!this.IsOpen)
return;
this.nextFrameBringToFront = true;
}
/// <summary>
/// Code to always be executed before the open-state of the window is checked.
/// </summary>
@ -241,6 +253,12 @@ public abstract class Window
ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, focusedHeaderColor);
}
if (this.nextFrameBringToFront)
{
ImGui.SetNextWindowFocus();
this.nextFrameBringToFront = false;
}
if (this.ShowCloseButton ? ImGui.Begin(this.WindowName, ref this.internalIsOpen, this.Flags) : ImGui.Begin(this.WindowName, this.Flags))
{
// Draw the actual window contents

View file

@ -62,6 +62,8 @@ public class WindowSystem
/// <summary>
/// Add a window to this <see cref="WindowSystem"/>.
/// The window system doesn't own your window, it just renders it
/// You need to store a reference to it to use it later.
/// </summary>
/// <param name="window">The window to add.</param>
public void AddWindow(Window window)
@ -74,6 +76,7 @@ public class WindowSystem
/// <summary>
/// Remove a window from this <see cref="WindowSystem"/>.
/// Will not dispose your window, if it is disposable.
/// </summary>
/// <param name="window">The window to remove.</param>
public void RemoveWindow(Window window)
@ -81,31 +84,21 @@ public class WindowSystem
if (!this.windows.Contains(window))
throw new ArgumentException("This window is not registered on this WindowSystem.");
if (window is IDisposable disposable)
disposable.Dispose();
this.windows.Remove(window);
}
/// <summary>
/// Remove all windows from this <see cref="WindowSystem"/>.
/// Will not dispose your windows, if they are disposable.
/// </summary>
public void RemoveAllWindows()
{
foreach (var window in this.windows)
{
if (window is IDisposable disposable)
disposable.Dispose();
}
this.windows.Clear();
}
public void RemoveAllWindows() => this.windows.Clear();
/// <summary>
/// Get a window by name.
/// </summary>
/// <param name="windowName">The name of the <see cref="Window"/>.</param>
/// <returns>The <see cref="Window"/> object with matching name or null.</returns>
[Obsolete("WindowSystem does not own your window - you should store a reference to it and use that instead.")]
public Window? GetWindow(string windowName) => this.windows.FirstOrDefault(w => w.WindowName == windowName);
/// <summary>