Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refractor/status.js #2785

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 27 additions & 30 deletions js/widgets/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// This widget makes displays the status of selected parameters and
// notes as they are being played.

/* exported StatusMatrix */
class StatusMatrix {
static BUTTONDIVWIDTH = 128;
static BUTTONSIZE = 53;
Expand All @@ -21,12 +22,12 @@ class StatusMatrix {
static INNERWINDOWWIDTH = StatusMatrix.OUTERWINDOWWIDTH - StatusMatrix.BUTTONSIZE * 1.5;
static FONTSCALEFACTOR = 75;

/**
* Initializes the status matrix. First removes the
* previous matrix and them make another one in DOM (document
* object model)
*/
init() {
let x, y; //Drop coordinates of statusDiv
// Initializes the status matrix. First removes the
// previous matrix and them make another one in DOM (document
// object model)

this.isOpen = true;

this._cellScale = window.innerWidth / 1200;
Expand Down Expand Up @@ -100,7 +101,7 @@ class StatusMatrix {
cell.className = "headcol";
}

console.debug("active turtles: " + turtles.turtleList.length);
// console.debug("active turtles: " + turtles.turtleList.length);

// One row per field, one column per mouse (plus the labels)
let label;
Expand All @@ -110,7 +111,7 @@ class StatusMatrix {
cell = row.insertCell(); // i + 1);
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";

console.debug(statusField[1]);
// console.debug(statusField[1]);

switch (statusField[1]) {
case "plus":
Expand All @@ -132,17 +133,15 @@ class StatusMatrix {
if (localStorage.languagePreference === "ja") {
label = _("beats per minute2");
} else {
label = logo.blocks.blockList[statusField[0]]
.protoblock.staticLabels[0];
label = logo.blocks.blockList[statusField[0]].protoblock.staticLabels[0];
}
console.debug(label);
// console.debug(label);
break;
case "outputtools":
label = logo.blocks.blockList[statusField[0]].privateData;
break;
default:
label = logo.blocks.blockList[statusField[0]].protoblock
.staticLabels[0];
label = logo.blocks.blockList[statusField[0]].protoblock.staticLabels[0];
break;
}

Expand All @@ -153,11 +152,12 @@ class StatusMatrix {
turtles.turtleList.forEach(() => {
cell = row.insertCell();
cell.style.backgroundColor = platformColor.selectorBackground;
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";
cell.innerHTML = "";
cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px";
cell.style.textAlign = "center";
})
});
}

if (_THIS_IS_MUSIC_BLOCKS_) {
Expand All @@ -168,18 +168,23 @@ class StatusMatrix {
cell.style.height = Math.floor(MATRIXBUTTONHEIGHT * this._cellScale) + "px";
cell.style.backgroundColor = platformColor.selectorBackground;

turtles.turtleList.forEach(()=>{
turtles.turtleList.forEach(() => {
cell = row.insertCell();
cell.style.backgroundColor = platformColor.selectorBackground;
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";
cell.innerHTML = "";
cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px";
cell.style.textAlign = "center";
})
});
}
this.widgetWindow.sendToCenter();
}

/**
* @public
* @returns {void}
*/
updateAll() {
// Update status of all of the voices in the matrix.
logo.updatingStatusMatrix = true;
Expand Down Expand Up @@ -214,29 +219,22 @@ class StatusMatrix {
value = logo.blocks.blockList[statusField[0]].value.toFixed(0);
break;
case "mynotevalue":
value = mixedNumber(
logo.blocks.blockList[statusField[0]].value
);
value = mixedNumber(logo.blocks.blockList[statusField[0]].value);
break;
case "elapsednotes2":
blk = statusField[0];
cblk = logo.blocks.blockList[blk].connections[1];
noteValue = logo.parseArg(logo, t, cblk, blk, null);
value =
mixedNumber(
logo.blocks.blockList[statusField[0]].value
) +
mixedNumber(logo.blocks.blockList[statusField[0]].value) +
" × " +
mixedNumber(noteValue);
break;
case "elapsednotes":
value = mixedNumber(
logo.blocks.blockList[statusField[0]].value
);
value = mixedNumber(logo.blocks.blockList[statusField[0]].value);
break;
case "namedbox":
name = logo.blocks.blockList[statusField[0]]
.privateData;
name = logo.blocks.blockList[statusField[0]].privateData;
if (name in logo.boxes) {
value = logo.boxes[name];
} else {
Expand Down Expand Up @@ -316,6 +314,5 @@ class StatusMatrix {
}

logo.updatingStatusMatrix = false;
};

}
}