update sln picker color random logic

This commit is contained in:
Matt Parker
2025-10-03 19:48:42 +10:00
parent 45d632d41f
commit 583a0a0aa9
2 changed files with 8 additions and 3 deletions

View File

@@ -33,10 +33,14 @@ public static class RandomRecentSlnColours
{
var hashBytes = MD5.HashData(Encoding.UTF8.GetBytes(filePath));
// Convert first 4 bytes to an int
var hash = BitConverter.ToInt32(hashBytes, 0);
// Use all 16 bytes instead of just the first 4
var hash = BitConverter.ToUInt32(hashBytes, 12) ^
BitConverter.ToUInt32(hashBytes, 8) ^
BitConverter.ToUInt32(hashBytes, 4) ^
BitConverter.ToUInt32(hashBytes, 0);
var index = Math.Abs(hash) % AllColours.Count;
var random = new Random((int)hash);
var index = random.Next(AllColours.Count);
return AllColours[index];
}
}

View File

@@ -107,6 +107,7 @@ layout_mode = 2
[node name="ScrollContainer" type="ScrollContainer" parent="VSplitContainer/Panel/MarginContainer2/VBoxContainer2"]
layout_mode = 2
size_flags_vertical = 3
follow_focus = true
[node name="PreviousSlnsVBoxContainer" type="VBoxContainer" parent="VSplitContainer/Panel/MarginContainer2/VBoxContainer2/ScrollContainer"]
unique_name_in_owner = true