- Fixed bug in builder when no content files exist

This commit is contained in:
2024-07-12 23:10:44 +02:00
parent d45f7c3b8c
commit 1096597161
23 changed files with 1096 additions and 32 deletions
+35
View File
@@ -0,0 +1,35 @@
using Nerfed.Runtime.Graphics;
namespace Nerfed.Runtime.Gui;
public class GuiTextureStorage
{
private readonly Dictionary<IntPtr, WeakReference<Texture>> pointerToTexture = new Dictionary<IntPtr, WeakReference<Texture>>();
public IntPtr Add(Texture texture)
{
if (!pointerToTexture.ContainsKey(texture.Handle))
{
pointerToTexture.Add(texture.Handle, new WeakReference<Texture>(texture));
}
return texture.Handle;
}
public Texture GetTexture(IntPtr pointer)
{
if (!pointerToTexture.TryGetValue(pointer, out WeakReference<Texture> value))
{
return null;
}
WeakReference<Texture> result = value;
if (!result.TryGetTarget(out Texture texture))
{
pointerToTexture.Remove(pointer);
return null;
}
return texture;
}
}