BIG heap of bugfixes. Deselecting tools, profile colour picker, player

name colour contrast, mutation pricing (not really a bug, but still an
issue).

Signed-off-by: Sarahtonin <[email protected]>
This commit is contained in:
sarah committed 2026-08-31 16:43:13 +02:00
1 parent a2e95d6712
commit 4d92455bf3
6 files changed
+174 -55

No files matched your search

+96 -7
View File
@@ -1,3 +1,89 @@
const DefaultPlayerColour = "#cdd6f4";
function IsValidPlayerColour(
Colour
) {
return (
typeof Colour === "string" &&
/^#[0-9A-Fa-f]{6}$/.test(
Colour
)
);
}
function GetPlayerColourOutline(
Colour
) {
const Red = parseInt(
Colour.slice(1, 3),
16
);
const Green = parseInt(
Colour.slice(3, 5),
16
);
const Blue = parseInt(
Colour.slice(5, 7),
16
);
const Brightness =
(
Red * 299 +
Green * 587 +
Blue * 114
) / 1000;
return Brightness < 150
? "var(--Text)"
: "var(--Crust)";
}
function ApplyPlayerColour(
Element,
Colour
) {
Element.style.removeProperty(
"color"
);
Element.style.removeProperty(
"text-shadow"
);
if (
!IsValidPlayerColour(
Colour
)
) {
return;
}
const Outline =
GetPlayerColourOutline(
Colour
);
Element.style.color =
Colour;
Element.style.textShadow =
`-1px -1px 0 ${Outline}, ` +
`0 -1px 0 ${Outline}, ` +
`1px -1px 0 ${Outline}, ` +
`-1px 0 0 ${Outline}, ` +
`1px 0 0 ${Outline}, ` +
`-1px 1px 0 ${Outline}, ` +
`0 1px 0 ${Outline}, ` +
`1px 1px 0 ${Outline}`;
}
async function GetProfile() {
const Response = await fetch(
ApiUrl + "/Profile.php",
@@ -89,14 +175,12 @@ async function RenderUser() {
UsernameDisplay.textContent =
Profile.Username;
if (
Profile.Colour !== null
) {
UsernameDisplay.style.color =
Profile.Colour;
}
ApplyPlayerColour(
UsernameDisplay,
Profile.Colour
);
UsernameForm.hidden = true;
UsernameForm.hidden = true;
return;
}
@@ -104,6 +188,11 @@ async function RenderUser() {
UsernameDisplay.textContent =
"Unnamed";
ApplyPlayerColour(
UsernameDisplay,
null
);
UsernameForm.hidden = false;
}