Random user colours

This commit is contained in:
Natsumi
2022-05-14 18:23:00 +12:00
parent cc31ee38c3
commit 6edd271e88
3 changed files with 151 additions and 38 deletions

View File

@@ -19,6 +19,8 @@ using Windows.UI.Notifications;
using Windows.Data.Xml.Dom;
using librsync.net;
using System.Net.Sockets;
using System.Text;
using System.Collections.Generic;
namespace VRCX
{
@@ -433,6 +435,23 @@ namespace VRCX
}
}
private static readonly MD5 _hasher = MD5.Create();
public int GetColourFromUserID(string userId)
{
var hash = _hasher.ComputeHash(Encoding.UTF8.GetBytes(userId));
return hash[3] << 8 | hash[4];
}
public Dictionary<string, int> GetColourBulk(List<Object> userIds)
{
Dictionary<string, int> output = new Dictionary<string, int>();
foreach (string userId in userIds)
{
output.Add(userId, GetColourFromUserID(userId));
}
return output;
}
public void SetStartup(bool enabled)
{
try