Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/discord-bot/src/commands/quests/quests.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@ const NormalTable = ({ quests, t, gameIcons, colorPalette, time }: NormalTablePr
boxColor = useGradient(
"horizontal",
[GRADIENT_OFFSET, BOX_COLOR],
[1, "hsla(120, 100%, 30%, 0.5)"]
[1, "hsla(145, 45%, 44%, 0.5)"]
);
} else if (completed >= 1) {
textColor = "§6";
boxColor = useGradient(
"horizontal",
[GRADIENT_OFFSET, BOX_COLOR],
[1, "hsla(40, 100%, 30%, 0.5)"]
[1, "hsla(42, 17%, 48%, 0.5)"]
);
} else {
textColor = "§c";
boxColor = useGradient(
"horizontal",
[GRADIENT_OFFSET, BOX_COLOR],
[1, "hsla(0, 100%, 30%, 0.5)"]
[1, "hsla(337, 31%, 43%, 0.5)"]
);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/discord-bot/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const Footer = ({ logo, user, border }: FooterProps) => {
break;

case UserLogo.DEFAULT:
text = "§#D6DEF1s§#B0DBC5t§#8BD799a§#65D46Ct§#3FD040s§#71D57Bi§#A4D9B6f§#D6DEF1y§#D1B0C4.§#CC8196n§#C65369e§#C1243Bt";
text = "§#6799E1s§#71A2E9t§#7AABF0a§#84B3F8t§#8DBCFFs§#A3C9FFi§#B9D6FFf§#CFE3FFy§#D5E7FF.§#DBEAFFn§#E0EEFFe§#E6F1FFt";
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion apps/discord-bot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { FontLoaderService } from "#services";
import { InteractionServer, RestClient, WebsocketShard } from "tiny-discord";
import { Logger } from "@statsify/logger";
import { VerifyCommand } from "#commands/verify.command";
import { WinterThemeService } from "@statsify/rendering";
import { config } from "@statsify/util";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
Expand All @@ -39,7 +40,7 @@ if (sentryDsn) {
}

await Promise.all(
[I18nLoaderService, FontLoaderService].map((service) => Container.get(service).init())
[I18nLoaderService, FontLoaderService, WinterThemeService].map((service) => Container.get(service).init())
);

const rest = new RestClient({ token: config("discordBot.token"), timeout: 60 * 1000 });
Expand Down
14 changes: 12 additions & 2 deletions apps/discord-bot/src/lib/convert-color-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

export const convertColorCodes = (content: string) =>
content
import { minecraftColors } from "@statsify/util";

export const convertColorCodes = (content: string) => {
content = content
.replaceAll(String.raw`\&`, "󰀀")
.replace(/&\S/g, (m) => m.replace("&", "§"))
.replaceAll("󰀀", "&");

for (const color of minecraftColors) {
content = content.replaceAll(color.code, `§${color.hex}`);
}

return `§#FFFFFF${content}`;
};

166 changes: 37 additions & 129 deletions apps/discord-bot/src/themes/boxes/hd.box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import { Box, Render } from "@statsify/rendering";
import { CanvasRenderingContext2D } from "skia-canvas";

export const render: Render<Box.BoxRenderProps> = (
ctx,
Expand All @@ -19,10 +18,11 @@ export const render: Render<Box.BoxRenderProps> = (
outline,
outlineSize,
},
{ x, y, width, height, padding }
{ x, y, width, height, padding },
{ winterTheme }
) => {
const fill = Box.resolveFill(color, ctx, x, y, width, height);
ctx.fillStyle = fill;
ctx.fillStyle = winterTheme.getIce(ctx);

width = width + padding.left + padding.right;
height = height + padding.top + padding.bottom;
Expand All @@ -42,17 +42,42 @@ export const render: Render<Box.BoxRenderProps> = (
border.topLeft /= 2;
border.topRight /= 2;

boxPath(ctx, x, y, width, height, border, 0);
ctx.beginPath();
ctx.moveTo(x, y + border.topLeft + border.topLeft);
ctx.lineTo(x + border.topLeft, y + border.topLeft + border.topLeft);
ctx.lineTo(x + border.topLeft, y + border.topLeft);
ctx.lineTo(x + border.topLeft + border.topLeft, y + border.topLeft);
ctx.lineTo(x + border.topLeft + border.topLeft, y);
ctx.lineTo(x + width - border.topRight - border.topRight, y);
ctx.lineTo(x + width - border.topRight - border.topRight, y + border.topRight);
ctx.lineTo(x + width - border.topRight, y + border.topRight);
ctx.lineTo(x + width - border.topRight, y + border.topRight + border.topRight);
ctx.lineTo(x + width, y + border.topRight + border.topRight);
ctx.lineTo(x + width, y + height - border.bottomRight - border.bottomRight);
ctx.lineTo(
x + width - border.bottomRight,
y + height - border.bottomRight - border.bottomRight
);
ctx.lineTo(x + width - border.bottomRight, y + height - border.bottomRight);
ctx.lineTo(
x + width - border.bottomRight - border.bottomRight,
y + height - border.bottomRight
);
ctx.lineTo(x + width - border.bottomRight - border.bottomRight, y + height);
ctx.lineTo(x + border.bottomLeft + border.bottomLeft, y + height);
ctx.lineTo(x + border.bottomLeft + border.bottomLeft, y + height - border.bottomLeft);
ctx.fill();

ctx.globalCompositeOperation = "overlay";
ctx.filter = "none";

const overlay = ctx.createLinearGradient(x, y, x, y + height);
overlay.addColorStop(0, "rgba(255, 255, 255, 0.15)");
overlay.addColorStop(1, "rgba(0, 0, 0, 0.15)");
ctx.fillStyle = overlay;
if (fill !== Box.DEFAULT_COLOR) {
ctx.fillStyle = fill;
ctx.fill();
}

ctx.fill();
ctx.globalCompositeOperation = "overlay";

Box.renderOverlay(ctx, x, y, height);

ctx.globalCompositeOperation = "source-over";

Expand All @@ -63,22 +88,6 @@ export const render: Render<Box.BoxRenderProps> = (
ctx.stroke();
}

boxPath(ctx, x, y, width, height, border, 2);
ctx.strokeStyle = Box.BORDER;
ctx.lineWidth = 4;
ctx.stroke();

boxPath(ctx, x, y, width, height, border, 1);
ctx.strokeStyle = Box.BORDER_HIGHLIGHT;
ctx.lineWidth = 2;
ctx.stroke();

drawPattern(ctx, "horizontal", x + (2 * border.topLeft), y, width - (2 * border.topRight) - (2 * border.topLeft));
drawPattern(ctx, "horizontal", x + (2 * border.bottomLeft), y + height - 4, width - (2 * border.bottomRight) - (2 * border.bottomLeft));

drawPattern(ctx, "vertical", x, y + (2 * border.topLeft), height - (2 * border.topLeft) - (2 * border.bottomLeft));
drawPattern(ctx, "vertical", x + width - 4, y + (2 * border.topRight), height - (2 * border.topRight) - (2 * border.bottomRight));

if (!shadowDistance) return;
shadowDistance /= 2;

Expand Down Expand Up @@ -130,107 +139,6 @@ export const render: Render<Box.BoxRenderProps> = (
}

ctx.globalAlpha = 1;
};

function drawPattern(ctx: CanvasRenderingContext2D, direction: "horizontal" | "vertical", x: number, y: number, length: number) {
if (direction === "horizontal") {
const patternWidth = 60;

for (let i = 0; i < length; i += patternWidth) {
const width = Math.min(patternWidth, length - i);

if (width < 30) continue;

const center = (width - 30) / 2;
horizontalSquiggle(ctx, x + i + center, y, Box.SQUIGGLE, Box.SQUIGGLE_HIGHLIGHT);
}
} else {
const patternHeight = 60;

for (let i = 0; i < length; i += patternHeight) {
const height = Math.min(patternHeight, length - i);

if (height < 30) continue;

const center = (height - 30) / 2;
verticalSquiggle(ctx, x, y + i + center, Box.SQUIGGLE, Box.SQUIGGLE_HIGHLIGHT);
}
}
}

function horizontalSquiggle(ctx: CanvasRenderingContext2D, x: number, y: number, color: string, highlight: string) {
ctx.fillStyle = color;
ctx.fillRect(x + 3, y + 2, 12, 2);
ctx.fillRect(x + 9, y, 12, 2);

ctx.fillRect(x + 15, y + 2, 3, 1);

ctx.fillStyle = highlight;
ctx.fillRect(x + 3, y + 2, 1, 2);
ctx.fillRect(x + 3, y + 2, 4, 1);
ctx.fillRect(x + 9, y, 12, 1);

ctx.fillRect(x + 6, y + 1, 4, 1);
ctx.fillRect(x + 21, y, 3, 1);
ctx.fillRect(x, y + 3, 3, 1);
}

function verticalSquiggle(ctx: CanvasRenderingContext2D, x: number, y: number, color: string, highlight: string) {
ctx.fillStyle = color;
ctx.fillRect(x, y + 3, 2, 12);
ctx.fillRect(x + 2, y + 9, 2, 12);
ctx.fillRect(x + 2, y + 6, 1, 3);

ctx.fillStyle = highlight;
ctx.fillRect(x, y + 3, 1, 12);
ctx.fillRect(x + 2, y + 17, 1, 4);
ctx.fillRect(x + 2, y + 20, 2, 1);

ctx.fillRect(x, y, 1, 3);
ctx.fillRect(x + 1, y + 14, 1, 4);
ctx.fillRect(x + 3, y + 21, 1, 3);
}

function boxPath(
ctx: CanvasRenderingContext2D,
x: number,
y: number,
width: number,
height: number,
border: Box.BoxBorderRadius,
offset: number
) {
x += offset;
y += offset;
width -= 2 * offset;
height -= 2 * offset;

ctx.beginPath();
ctx.moveTo(x, y + border.topLeft + border.topLeft);
ctx.lineTo(x + border.topLeft, y + border.topLeft + border.topLeft);
ctx.lineTo(x + border.topLeft, y + border.topLeft);
ctx.lineTo(x + border.topLeft + border.topLeft, y + border.topLeft);
ctx.lineTo(x + border.topLeft + border.topLeft, y);
ctx.lineTo(x + width - border.topRight - border.topRight, y);
ctx.lineTo(x + width - border.topRight - border.topRight, y + border.topRight);
ctx.lineTo(x + width - border.topRight, y + border.topRight);
ctx.lineTo(x + width - border.topRight, y + border.topRight + border.topRight);
ctx.lineTo(x + width, y + border.topRight + border.topRight);
ctx.lineTo(x + width, y + height - border.bottomRight - border.bottomRight);
ctx.lineTo(
x + width - border.bottomRight,
y + height - border.bottomRight - border.bottomRight
);
ctx.lineTo(x + width - border.bottomRight, y + height - border.bottomRight);
ctx.lineTo(
x + width - border.bottomRight - border.bottomRight,
y + height - border.bottomRight
);
ctx.lineTo(x + width - border.bottomRight - border.bottomRight, y + height);
ctx.lineTo(x + border.bottomLeft + border.bottomLeft, y + height);
ctx.lineTo(x + border.bottomLeft + border.bottomLeft, y + height - border.bottomLeft);
ctx.lineTo(x + border.bottomLeft, y + height - border.bottomLeft);
ctx.lineTo(x + border.bottomLeft, y + height - border.bottomLeft - border.bottomLeft);
ctx.lineTo(x, y + height - border.bottomLeft - border.bottomLeft);
ctx.closePath();
}
Box.renderSnow(ctx, winterTheme, x, y, width);
};
Loading