fixed combo colours

master
Avril 4 years ago
parent 9ed73e48fc
commit 9ddc430a8c
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -82,6 +82,15 @@
<div>TR: <span class='metadata' id='meta-diff-tr'></span></div>
</blockquote>
</article>
<article>
<header>
<span class='collapse'></span>
Colours
</header>
<ul class='metadata' id='meta-colours'>
</ul>
</article>
<article>
<header>
<span class='collapse'></span>

@ -53,11 +53,19 @@ function get_aggregate()
return OSU_FILES.where(x=> x)[0];
}
function clearChildren(node)
{
while(node.firstChild)
node.removeChild(node.firstChild);
}
function clear_sidebar() {
for(const elem of document.getElementsByClassName("metadata")) {
elem.innerText="";
removeClass(elem, "meta-dupe");
}
clearChildren( document.getElementById("meta-colours"));
}
function populate_sidebar(osu) {
@ -123,6 +131,27 @@ function populate_sidebar(osu) {
//Background
meta("background", "spec.Background");
//Colours
clearChildren(document.getElementById("meta-colours"));
if(osu.data.Colours) {
const colourList = document.getElementById("meta-colours");
const addColour = (rgb, combo) => {
const node = document.createElement("li");
node.setAttribute("class", "combo-colour");
node.setAttribute("id", "meta-colour-"+combo);
node.style.color = "rgb("+rgb.r+","+rgb.g+","+rgb.b+")";
node.innerText = rgb.toString();
colourList.appendChild(node);
};
console.log(osu.data.Colours);
for(let key in osu.data.Colours) {
if(osu.data.Colours.hasOwnProperty(key)) {
const rgb = osu.data.Colours[key];
addColour(rgb, key);
}
}
}
SIDEBAR_VIEWING = osu;
}
}

@ -27,6 +27,7 @@ OSU.LoadTokens = async function(tokens) {
"Metadata": new Stage(),
"Difficulty": new Stage(),
"Events": new Stage(),
"Colours": new Stage(),
"TimingPoints": new Stage(),
"HitObjects": new Stage(),
};
@ -43,6 +44,7 @@ OSU.LoadTokens = async function(tokens) {
this.han(stages["Editor"]);
this.meta(stages["Metadata"]);
this.muzukashisa(stages["Difficulty"]);
this.iro(stages["Colours"]);
this.jiken(stages["Events"]);
this.keiji(stages["TimingPoints"]);
this.maru(stages["HitObjects"]);
@ -173,6 +175,25 @@ OSU.muzukashisa = async function(tokens) {
};
OSU.iro = async function(tokens) {
const group = await tokens.take();
if(group) {
var data = this.data[group];
var tok;
while(tok = await tokens.take()) {
var match = tok.match(/^(Combo\d+)\s:\s(\d+),(\d+),(\d+)$/);
if(match && match[0])
{
data[match[1]] = {r: parseInt(match[2]), g: parseInt(match[3]), b: parseInt(match[4]), toString: function() {
return "#"+ this.r.toString(16)+this.g.toString(16)+this.b.toString(16);
}};
}
else this.errors.push("iso: parsing line `"+tok+"' failed.");
}
}
};
OSU.jiken = async function(tokens) {
const group = await tokens.take();
if(group) {

Loading…
Cancel
Save