rename error system to popup system
This commit is contained in:
parent
0f0e828c52
commit
9fe6f36c1d
1 changed files with 12 additions and 12 deletions
24
render.js
24
render.js
|
@ -52,7 +52,7 @@ let displaytitle = '';
|
||||||
let displayalbum = '';
|
let displayalbum = '';
|
||||||
|
|
||||||
// type: 0 = error, 1 = warning, 2 = info
|
// type: 0 = error, 1 = warning, 2 = info
|
||||||
let errors = [];
|
let popups = [];
|
||||||
|
|
||||||
function transform(old, n) {
|
function transform(old, n) {
|
||||||
if (old.length < n.length) {
|
if (old.length < n.length) {
|
||||||
|
@ -142,18 +142,18 @@ function render(artist, album, title, songStart, songEnd, pauseSpot, paused) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (let err of errors) {
|
for (let popup of popups) {
|
||||||
err.timer -= dt;
|
popup.timer -= dt;
|
||||||
if (err.timer < 0) {
|
if (popup.timer < 0) {
|
||||||
errors.splice(i, 1);
|
popups.splice(i, 1);
|
||||||
} else {
|
} else {
|
||||||
let symbol = ['⚠️', '⚠️', 'ℹ'][err.type];
|
let symbol = ['⚠️', '⚠️', 'ℹ'][popup.type];
|
||||||
let color = ['\033[41;37m', '\033[43;37m', '\033[44;37m'][err.type];
|
let color = ['\033[41;37m', '\033[43;37m', '\033[44;37m'][popup.type];
|
||||||
let text = ` ${symbol} ${err.text} `;
|
let text = ` ${symbol} ${popup.text} `;
|
||||||
|
|
||||||
texts.push({
|
texts.push({
|
||||||
value: ' '.repeat(text.length) + text,
|
value: ' '.repeat(text.length) + text,
|
||||||
x: -text.length * 2 + Math.round((text.length + 3) * outCirc(Math.min(err.timer, 1))),
|
x: -text.length * 2 + Math.round((text.length + 3) * outCirc(Math.min(popup.timer, 1))),
|
||||||
y: 3 + i,
|
y: 3 + i,
|
||||||
color: color
|
color: color
|
||||||
});
|
});
|
||||||
|
@ -245,9 +245,9 @@ function render(artist, album, title, songStart, songEnd, pauseSpot, paused) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(content) {errors.push({text: content, timer: errorDuration, type: 0});}
|
function error(content) {popups.push({text: content, timer: errorDuration, type: 0});}
|
||||||
function warning(content) {errors.push({text: content, timer: errorDuration, type: 1});}
|
function warning(content) {popups.push({text: content, timer: errorDuration, type: 1});}
|
||||||
function info(content) {errors.push({text: content, timer: errorDuration, type: 2});}
|
function info(content) {popups.push({text: content, timer: errorDuration, type: 2});}
|
||||||
|
|
||||||
module.exports.render = render;
|
module.exports.render = render;
|
||||||
module.exports.refreshrate = refreshrate;
|
module.exports.refreshrate = refreshrate;
|
||||||
|
|
Loading…
Reference in a new issue