`);
});
return output.join("\n");
}
/**
* Gets the tick/cross used in the mod list.
*/
function getTickCross(bool: boolean): string {
if (bool) {
return '
✔
';
}
return '
✖
';
}
const bgImageNamespace = "minecraft";
const bgImagePath = "textures/gui/title/background";
const mainMenuConfigPath = "config/CustomMainMenu/mainmenu.json";
/**
* Minifies (converts to jpeg) main menu files so they don't take up 60% of the pack size.
*/
async function compressMainMenuImages() {
const mainMenuImages = [];
const bgImagePathReal = upath.join("resources", bgImageNamespace, bgImagePath);
// Convert each slideshow image to 80% jpg.
await new Promise((resolve) => {
gulp
.src(upath.join(sharedDestDirectory, overridesFolder, bgImagePathReal, "**/*"))
.pipe(imagemin([pngToJpeg({ quality: buildConfig.screenshotsQuality })]))
.pipe(
rename((f) => {
// xd
f.extname = ".jpg";
// Ping back the file name so we don't have to scan the folder again.
mainMenuImages.push(`${f.basename}${f.extname}`);
}),
)
.pipe(gulp.dest(upath.join(clientDestDirectory, overridesFolder, bgImagePathReal)))
.on("end", resolve);
});
if (mainMenuImages.length > 0) {
// Read the CustomMainMenu config and parse it.
const mainMenuConfig: MainMenuConfig = JSON.parse(
(await fs.promises.readFile(upath.join(clientDestDirectory, overridesFolder, mainMenuConfigPath))).toString(),
);
// Fill the config with image paths using the weird "namespace:path" scheme.
mainMenuConfig.other.background.slideshow.images = mainMenuImages.map(
(img) => bgImageNamespace + ":" + upath.join(bgImagePath, img),
);
// Write it back.
return fs.promises.writeFile(
upath.join(clientDestDirectory, overridesFolder, mainMenuConfigPath),
JSON.stringify(mainMenuConfig, null, " "),
);
}
}
export default gulp.series(
clientCleanUp,
createClientDirs,
copyClientOverrides,
exportModpackManifest,
copyClientLicense,
copyClientOverrides,
copyClientChangelog,
copyClientUpdateNotes,
fetchModList,
compressMainMenuImages,
);