Add pre-testing version of the webinterface
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() { }
|
||||
}
|
||||
|
||||
@@ -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..];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user