Add pre-testing version of the webinterface

This commit is contained in:
Infi
2024-08-24 03:05:33 +02:00
parent 117d9fc45c
commit 5e93732183
27 changed files with 1498 additions and 129 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Numerics;
namespace ChatTwo.Util;
internal static class ColourUtil {
private static (byte r, byte g, byte b, byte a) RgbaToComponents(uint rgba) {
internal static (byte r, byte g, byte b, byte a) RgbaToComponents(uint rgba) {
var r = (byte) ((rgba & 0xFF000000) >> 24);
var g = (byte) ((rgba & 0xFF0000) >> 16);
var b = (byte) ((rgba & 0xFF00) >> 8);
+9
View File
@@ -1,5 +1,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
namespace ChatTwo.Util;
@@ -145,4 +147,11 @@ internal static class IconUtil {
return new GfdFileView(new ReadOnlySpan<byte>(Unsafe.AsPointer(ref GfdFile[0]), GfdFile.Length));
}
}
public static byte[] ImageToRaw(this Image<Rgba32> image)
{
var data = new byte[4 * image.Width * image.Height];
image.CopyPixelDataTo(data);
return data;
}
}
+8
View File
@@ -668,6 +668,14 @@ internal static class ImGuiUtil
}
}
public static void WrappedTextWithColor(Vector4 color, string text)
{
using (ImRaii.PushColor(ImGuiCol.Text, color))
{
ImGui.TextWrapped(text);
}
}
// Used to avoid pops if condition is false for Push.
private static void Nop() { }
}
+11
View File
@@ -0,0 +1,11 @@
namespace ChatTwo.Util;
public class WebinterfaceUtil
{
private static readonly Random Rng = new();
public static string GenerateSimpleAuthCode()
{
return (100000 + Rng.Next() % 100000).ToString()[1..];
}
}