Remove ToolMenuButton and dispose captured viewport images
Tools no longer have main menu launchers; the game menu quits through ApplicationExit.
This commit is contained in:
1 parent
307da15a12
commit
7cd7be0c59
3 files changed
+3
-35
No files matched your search
@@ -140,7 +140,7 @@ namespace Cthangover.Mods.Interface.Menu
|
|||||||
|
|
||||||
private void OnExitClick()
|
private void OnExitClick()
|
||||||
{
|
{
|
||||||
GetTree().Quit();
|
Cthangover.Core.Bootstrap.ApplicationExit.Quit(GetTree());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
using Cthangover.Core.UI.Tool;
|
|
||||||
|
|
||||||
namespace Cthangover.Mods.Interface.Tool
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Shared factory for the launcher buttons that tools contribute to the main
|
|
||||||
/// menu's tool block. Keeps the standard presentation (localized caption),
|
|
||||||
/// the translation-key metadata used for live language switching, and the
|
|
||||||
/// window-opening action in one place, so <see cref="IToolProvider.AddMenuButton"/>
|
|
||||||
/// implementations stay focused while remaining free to append extra controls.
|
|
||||||
/// </summary>
|
|
||||||
public static class ToolMenuButton
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a button labelled with the tool's <see cref="IToolProvider.LocaleKey"/>,
|
|
||||||
/// wires it to open a fresh window via <see cref="ToolWindow.ShowWindow"/>, and adds
|
|
||||||
/// it to <paramref name="container"/>. Returns the created button so a tool can
|
|
||||||
/// decorate it further (icon, tooltip, extra handlers).
|
|
||||||
/// </summary>
|
|
||||||
public static Button Attach(Container container, IToolProvider tool)
|
|
||||||
{
|
|
||||||
var button = new Button
|
|
||||||
{
|
|
||||||
Text = TranslationServer.Translate(tool.LocaleKey),
|
|
||||||
};
|
|
||||||
button.SetMeta(Menu.MenuBuilder.LocaleMetaKey, tool.LocaleKey);
|
|
||||||
button.Pressed += () => ToolWindow.ShowWindow(tool.CreateWindow());
|
|
||||||
container.AddChild(button);
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,7 @@ namespace Cthangover.Mods.Interface.View
|
|||||||
if (image == null || !viewport.UseHdr2D)
|
if (image == null || !viewport.UseHdr2D)
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
|
using var source = image;
|
||||||
image.Convert(Image.Format.Rgbaf);
|
image.Convert(Image.Format.Rgbaf);
|
||||||
var floats = MemoryMarshal.Cast<byte, float>(image.GetData());
|
var floats = MemoryMarshal.Cast<byte, float>(image.GetData());
|
||||||
var bytes = new byte[floats.Length];
|
var bytes = new byte[floats.Length];
|
||||||
@@ -39,7 +40,7 @@ namespace Cthangover.Mods.Interface.View
|
|||||||
/// <summary>Saves the current frame of <paramref name="viewport"/> as a PNG; false without a frame.</summary>
|
/// <summary>Saves the current frame of <paramref name="viewport"/> as a PNG; false without a frame.</summary>
|
||||||
public static bool SavePng(Viewport viewport, string path)
|
public static bool SavePng(Viewport viewport, string path)
|
||||||
{
|
{
|
||||||
var image = Take(viewport);
|
using var image = Take(viewport);
|
||||||
return image != null && image.SavePng(path) == Error.Ok;
|
return image != null && image.SavePng(path) == Error.Ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user