Implementation of Old Level Color Analysis

This commit is contained in:
zmxhawrhbg 2019-11-20 15:18:12 -07:00 committed by Colon
parent 39e61951b8
commit 9e92b92be0
2 changed files with 93 additions and 1 deletions

View file

@ -106,6 +106,55 @@ Object.keys(data[0]).forEach(x => {
else if (val[1] == "bump") val = Number(property) + 1
else if (val[1] == "bool") val = property != "0"
// you can only imagine my fear when i discovered this was a thing
// these literally are keys set the value, and to convert this to the color list we have to do this fun messy thing that shouldn't exist
else if (val[1] == 'extra-legacy-color') {
// since i wrote the 1.9 color before this, a lot of explaination will be there instead
const colorInfo = name.split('-');
const color = colorInfo[2]; // r,g,b
const channel = colorInfo[1];
if (color == 'r') {
// first we create the color object
response.colors.push({"channel": channel, "opacity": 1});
}
// from here we touch the color object
let currentChannel = response.colors.find(k => k.channel == channel);
if (color == 'blend') {
currentChannel.blending = true; // only one color has blending though lol
} else if (color == 'pcol' && property != 0) {
currentChannel.pColor = property;
}
currentChannel[color] = property;
}
// if a level has a legacy color, we can assume that it does not have a kS38 at all
else if (val[1] == "legacy-color") {
color = app.parseResponse(property, "_");
const keys = Object.keys(color)
let colorObj = {}
// so here we parse the color to something understandable by the rest
// slightly smart naming but it is also pretty gross
// in a sense - the name would be something like legacy-G -> G
const colorVal = name.split('-').pop()
keys.forEach(k => {if (colorStuff.properties[k]) colorObj[colorStuff.properties[k]] = color[k]})
colorObj.channel = colorVal
// from here stuff can continue as normal, ish
if (colorObj.pColor == "-1" || colorObj.pColor == "0") delete colorObj.pColor;
colorObj.opacity = 1; // 1.9 colors don't have this!
if (colorObj.blending && colorObj.blending == '1') colorObj.blending = true; // 1.9 colors manage to always think they're blending - they're not
else delete colorObj.blending;
if (colorVal == '3DL') { response.colors.splice(4, 0, colorObj); } // hardcode the position of 3DL, it typically goes at the end due to how RobTop make the headers
else if (colorVal == 'Line') { colorObj.blending = true; response.colors.push(colorObj); } // in line with 2.1 behavior
else { response.colors.push(colorObj); } // bruh whatever was done to make the color list originally was long
}
else if (val[1] == "colors") {
let colorList = property.split("|")
colorList.forEach((x, y) => {
@ -113,7 +162,7 @@ Object.keys(data[0]).forEach(x => {
let keys = Object.keys(color)
let colorObj = {}
if (!color['6']) return colorList = colorList.filter((h, i) => y != i)
keys.forEach(k => {if (colorStuff.properties[k]) colorObj[colorStuff.properties[k]] = color[k]})
if (colorStuff.channels[colorObj.channel]) colorObj.channel = colorStuff.channels[colorObj.channel]
if (colorObj.channel > 1000) return;
@ -144,6 +193,11 @@ if (!response.settings.font) response.settings.font = 1
if (response.settings.alternateLine == 2) response.settings.alternateLine = true
else response.settings.alternateLine = false
Object.keys(response.settings).filter(k => {
// this should be parsed into color list instead
if (k.includes('legacy')) delete response.settings[k];
});
delete response.settings['colors']
response.text = data.filter(x => x.message).sort(function (a, b) {return parseInt(a.x) - parseInt(b.x)}).map(x => [Buffer.from(x.message, 'base64').toString(), Math.round(x.x / last * 99) + "%"])
response.dataLength = rawData.length

View file

@ -15,6 +15,44 @@
"kA16": ["fadeOut", "bool"],
"kA17": ["alternateLine", "number"],
"kS1": ["legacy-BG-r", "extra-legacy-color"],
"kS2": ["legacy-BG-g", "extra-legacy-color"],
"kS3": ["legacy-BG-b", "extra-legacy-color"],
"kS4": ["legacy-G-r", "extra-legacy-color"],
"kS5": ["legacy-G-g", "extra-legacy-color"],
"kS6": ["legacy-G-b", "extra-legacy-color"],
"kS7": ["legacy-Line-r", "extra-legacy-color"],
"kS8": ["legacy-Line-g", "extra-legacy-color"],
"kS9": ["legacy-Line-b", "extra-legacy-color"],
"kS10": ["legacy-Obj-r", "extra-legacy-color"],
"kS11": ["legacy-Obj-g", "extra-legacy-color"],
"kS12": ["legacy-Obj-b", "extra-legacy-color"],
"kS13": ["legacy-1-r", "extra-legacy-color"],
"kS14": ["legacy-1-g", "extra-legacy-color"],
"kS15": ["legacy-1-b", "extra-legacy-color"],
"kA5": ["legacy-1-blend", "extra-legacy-color"],
"kS16": ["legacy-BG-pcol", "extra-legacy-color"],
"kS17": ["legacy-G-pcol", "extra-legacy-color"],
"kS18": ["legacy-Line-pcol", "extra-legacy-color"],
"kS19": ["legacy-Obj-pcol", "extra-legacy-color"],
"kS20": ["legacy-1-pcol", "extra-legacy-color"],
"kS29": ["legacy-BG", "legacy-color"],
"kS30": ["legacy-G", "legacy-color"],
"kS31": ["legacy-Line", "legacy-color"],
"kS32": ["legacy-Obj", "legacy-color"],
"kS33": ["legacy-1", "legacy-color"],
"kS34": ["legacy-2", "legacy-color"],
"kS35": ["legacy-3", "legacy-color"],
"kS36": ["legacy-4", "legacy-color"],
"kS37": ["legacy-3DL", "legacy-color"],
"kS38": ["colors", "colors"]
},