mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-31 14:39:51 +01:00
scratched flags
This commit is contained in:
1 parent
9813459310
commit
1a7a1223d5
2 files changed
+40
-73
No files matched your search
@@ -1,73 +0,0 @@
|
|||||||
import sharp from "sharp";
|
|
||||||
import { AssetUploader } from "../core/github/assetUploader";
|
|
||||||
import { vfs } from "./constants";
|
|
||||||
|
|
||||||
export async function flags() {
|
|
||||||
console.log("Building flags...");
|
|
||||||
|
|
||||||
using uploader = new AssetUploader("flags");
|
|
||||||
const circleFiles = await vfs
|
|
||||||
.dir(`Data/Gfx/Lobby/flags`)
|
|
||||||
.then((files) =>
|
|
||||||
files.filter(
|
|
||||||
(flag) =>
|
|
||||||
flag.startsWith("flag_profile-stat_") &&
|
|
||||||
!flag.endsWith("@2x.packed.webp"),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const scratchedFiles = await vfs
|
|
||||||
.dir(`Data/Gfx/Lobby/flags`)
|
|
||||||
.then((files) =>
|
|
||||||
files.filter(
|
|
||||||
(flag) =>
|
|
||||||
flag.startsWith("flag_tutor-tank_") &&
|
|
||||||
!flag.endsWith("@2x.packed.webp"),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const fadedFiles = await vfs
|
|
||||||
.dir(`Data/Gfx/Lobby/flags`)
|
|
||||||
.then((files) =>
|
|
||||||
files.filter(
|
|
||||||
(flag) =>
|
|
||||||
flag.startsWith("flag_filter_") && flag.endsWith("@2x.packed.webp"),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const flag of circleFiles) {
|
|
||||||
const image = sharp(await vfs.file(`Data/Gfx/Lobby/flags/${flag}`));
|
|
||||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
|
||||||
const name = flag.match(/flag_profile-stat_(.+)\.packed\.webp/)![1];
|
|
||||||
|
|
||||||
uploader.add({
|
|
||||||
content,
|
|
||||||
path: `flags/circle/${name}.webp`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const flag of scratchedFiles) {
|
|
||||||
const content = await vfs.file(`Data/Gfx/Lobby/flags/${flag}`);
|
|
||||||
const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1];
|
|
||||||
|
|
||||||
uploader.add({
|
|
||||||
path: `flags/scratched/${name}.webp`,
|
|
||||||
content,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const flag of fadedFiles) {
|
|
||||||
const content = await sharp(await vfs.file(`Data/Gfx/Lobby/flags/${flag}`))
|
|
||||||
.trim({
|
|
||||||
threshold: 100,
|
|
||||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
|
||||||
})
|
|
||||||
.toBuffer();
|
|
||||||
const name = flag.match(/flag_filter_(.+)@2x\.packed\.webp/)![1];
|
|
||||||
|
|
||||||
uploader.add({
|
|
||||||
content,
|
|
||||||
path: `flags/fade_small/${name}.webp`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await uploader.flush();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import type { APIContext, GetStaticPathsItem } from "astro";
|
||||||
|
import { mixStaticPaths } from "../../../../core/blitzkit/mixStaticPaths";
|
||||||
|
import { vfs } from "../../../../core/blitzkit/vfs";
|
||||||
|
import { getStaticPaths as _getStaticPaths } from "../../_index";
|
||||||
|
|
||||||
|
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||||
|
const paths: GetStaticPathsItem[] = [];
|
||||||
|
|
||||||
|
const scratchedFiles = await vfs
|
||||||
|
.dir("Data/Gfx/Lobby/flags")
|
||||||
|
.then((files) =>
|
||||||
|
files.filter(
|
||||||
|
(flag) =>
|
||||||
|
flag.startsWith("flag_tutor-tank_") &&
|
||||||
|
!flag.endsWith("@2x.packed.webp"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const flag of scratchedFiles) {
|
||||||
|
const path = `Data/Gfx/Lobby/flags/${flag}`;
|
||||||
|
const id = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1];
|
||||||
|
|
||||||
|
paths.push({
|
||||||
|
params: { id },
|
||||||
|
props: { path },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths;
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function GET({ props }: APIContext<{ path: string }>) {
|
||||||
|
const bytes = new Uint8Array(await vfs.file(props.path));
|
||||||
|
|
||||||
|
return new Response(bytes, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "image/webp",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in new issue
Block a user