diff --git a/src/Tool/ToolBox.cs b/src/Tool/ToolBox.cs
index 578c84a..462ff37 100644
--- a/src/Tool/ToolBox.cs
+++ b/src/Tool/ToolBox.cs
@@ -22,6 +22,10 @@ namespace Cthangover.Mods.Interface.Tool
///
public partial class ToolBox : Control, IToolbarHost, ISaveIconHost
{
+ /// Side of a toolbar button and its icon: the icons are 64 px pixel-art sprites (scaled x4), so a
+ /// 64 px slot shows every sprite pixel; at 60 px the nearest filter dropped rows of them.
+ private const int SlotSize = 64;
+
private HBoxContainer _buttons;
private TextureRect _saveIcon;
@@ -64,14 +68,14 @@ namespace Cthangover.Mods.Interface.Tool
{
var button = new Button
{
- CustomMinimumSize = new Vector2(60, 60),
+ CustomMinimumSize = new Vector2(SlotSize, SlotSize),
SizeFlagsVertical = SizeFlags.ShrinkCenter,
TooltipText = title,
};
if (icon != null)
{
- var iconRect = UiKit.Icon(icon, 60);
+ var iconRect = UiKit.Icon(icon, SlotSize);
button.AddChild(iconRect);
iconRect.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
}
@@ -92,7 +96,7 @@ namespace Cthangover.Mods.Interface.Tool
///
/// Adds one "tools" toolbar button whose popup lists every visible
/// . Tools used to get a text button each,
- /// which did not fit the 60×60 icon row and overlapped its icons; a
+ /// which did not fit the square icon row and overlapped its icons; a
/// single icon keeps the HUD row uniform no matter how many tools are
/// installed. Nothing is added when no tool button is visible.
///
diff --git a/src/View/ViewportCapture.cs b/src/View/ViewportCapture.cs
new file mode 100644
index 0000000..f211a3f
--- /dev/null
+++ b/src/View/ViewportCapture.cs
@@ -0,0 +1,46 @@
+namespace Cthangover.Mods.Interface.View
+{
+ using System;
+ using System.Runtime.InteropServices;
+ using Godot;
+
+ ///
+ /// Takes a screenshot of a viewport the way the player sees it.
+ ///
+ ///
+ /// The project renders 2D in HDR (rendering/viewport/hdr_2d): the viewport texture then holds linear
+ /// colour, and Godot converts it to sRGB only when it blits to the window. A plain
+ /// GetTexture().GetImage().SavePng() wrote those linear values, so every screenshot (the site's
+ /// gallery included) came out much darker than the game, shadows most of all. The conversion runs on
+ /// float data before the 8-bit quantisation, so dark gradients do not band.
+ ///
+ public static class ViewportCapture
+ {
+ /// The current frame of as RGBA8 sRGB, or null without a frame.
+ public static Image Take(Viewport viewport)
+ {
+ var image = viewport.GetTexture()?.GetImage();
+ if (image == null || !viewport.UseHdr2D)
+ return image;
+
+ image.Convert(Image.Format.Rgbaf);
+ var floats = MemoryMarshal.Cast(image.GetData());
+ var bytes = new byte[floats.Length];
+ for (var i = 0; i < floats.Length; i++)
+ {
+ var v = Math.Clamp(floats[i], 0f, 1f);
+ if (i % 4 != 3)
+ v = v <= 0.0031308f ? v * 12.92f : 1.055f * MathF.Pow(v, 1f / 2.4f) - 0.055f;
+ bytes[i] = (byte)MathF.Round(v * 255f);
+ }
+ return Image.CreateFromData(image.GetWidth(), image.GetHeight(), false, Image.Format.Rgba8, bytes);
+ }
+
+ /// Saves the current frame of as a PNG; false without a frame.
+ public static bool SavePng(Viewport viewport, string path)
+ {
+ var image = Take(viewport);
+ return image != null && image.SavePng(path) == Error.Ok;
+ }
+ }
+}
diff --git a/ui/icons/bag.png b/ui/icons/bag.png
index 1f515c5..bbe0e39 100644
Binary files a/ui/icons/bag.png and b/ui/icons/bag.png differ
diff --git a/ui/icons/cards.png b/ui/icons/cards.png
index 4df191b..556522c 100644
Binary files a/ui/icons/cards.png and b/ui/icons/cards.png differ
diff --git a/ui/icons/journal.png b/ui/icons/journal.png
index 42bff7f..88377b9 100644
Binary files a/ui/icons/journal.png and b/ui/icons/journal.png differ
diff --git a/ui/icons/lamp.png b/ui/icons/lamp.png
index b6ab086..561f0cd 100644
Binary files a/ui/icons/lamp.png and b/ui/icons/lamp.png differ
diff --git a/ui/icons/map.png b/ui/icons/map.png
index 5731c3e..42b85c7 100644
Binary files a/ui/icons/map.png and b/ui/icons/map.png differ
diff --git a/ui/icons/save.png b/ui/icons/save.png
index 72e1d5b..93c7f35 100644
Binary files a/ui/icons/save.png and b/ui/icons/save.png differ
diff --git a/ui/icons/settings.png b/ui/icons/settings.png
index c82de78..9b6ec30 100644
Binary files a/ui/icons/settings.png and b/ui/icons/settings.png differ
diff --git a/ui/icons/skills.png b/ui/icons/skills.png
index 234b3df..2684f7a 100644
Binary files a/ui/icons/skills.png and b/ui/icons/skills.png differ
diff --git a/ui/icons/tools.png b/ui/icons/tools.png
index 85f407f..f789fbd 100644
Binary files a/ui/icons/tools.png and b/ui/icons/tools.png differ