Handle missing txt files in skins.

This commit is contained in:
Jordan Eldredge 2017-08-27 13:15:25 -07:00
parent c3a3614c2c
commit 27645c35e1

View file

@ -54,6 +54,41 @@ async function genSpriteUrisFromFilename(zip, fileName) {
return spriteUris;
}
const defaultVisColors = [
"rgb(0,0,0)",
"rgb(24,33,41)",
"rgb(239,49,16)",
"rgb(206,41,16)",
"rgb(214,90,0)",
"rgb(214,102,0)",
"rgb(214,115,0)",
"rgb(198,123,8)",
"rgb(222,165,24)",
"rgb(214,181,33)",
"rgb(189,222,41)",
"rgb(148,222,33)",
"rgb(41,206,16)",
"rgb(50,190,16)",
"rgb(57,181,16)",
"rgb(49,156,8)",
"rgb(41,148,0)",
"rgb(24,132,8)",
"rgb(255,255,255)",
"rgb(214,214,222)",
"rgb(181,189,189)",
"rgb(160,170,175)",
"rgb(148,156,165)",
"rgb(150,150,150)"
];
const defaultPlaylistStyle = {
Normal: "#00FF00",
Current: "#FFFFFF",
NormalBG: "#000000",
SelectedBG: "#0000FF",
Font: "Arial"
};
// A promise that, given a File object, returns a skin style object
async function parseSkin(zipFile) {
const buffer = await genBufferFromFile(zipFile);
@ -67,13 +102,15 @@ async function parseSkin(zipFile) {
// Merge all the objects into a single object. Tests assert that sprite keys are unique.
const images = imageObjs.reduce(Object.assign, {});
// TODO: Handle this being null.
const viscolorContent = await genFileFromZip(zip, "VISCOLOR", "txt", "text");
const colors = parseViscolors(viscolorContent);
const colors = viscolorContent
? parseViscolors(viscolorContent)
: defaultVisColors;
// TODO: Handle this being null.
const pleditContent = await genFileFromZip(zip, "PLEDIT", "txt", "text");
const playlistStyle = parseIni(pleditContent);
const playlistStyle = pleditContent
? parseIni(pleditContent)
: defaultPlaylistStyle;
return { colors, playlistStyle, images };
}