rename error system to popup system

This commit is contained in:
jill 2021-09-03 07:00:03 +03:00
parent 0f0e828c52
commit 9fe6f36c1d

View file

@ -52,7 +52,7 @@ let displaytitle = '';
let displayalbum = '';
// type: 0 = error, 1 = warning, 2 = info
let errors = [];
let popups = [];
function transform(old, n) {
if (old.length < n.length) {
@ -142,18 +142,18 @@ function render(artist, album, title, songStart, songEnd, pauseSpot, paused) {
}
let i = 0;
for (let err of errors) {
err.timer -= dt;
if (err.timer < 0) {
errors.splice(i, 1);
for (let popup of popups) {
popup.timer -= dt;
if (popup.timer < 0) {
popups.splice(i, 1);
} else {
let symbol = ['⚠️', '⚠️', ''][err.type];
let color = ['\033[41;37m', '\033[43;37m', '\033[44;37m'][err.type];
let text = ` ${symbol} ${err.text} `;
let symbol = ['⚠️', '⚠️', ''][popup.type];
let color = ['\033[41;37m', '\033[43;37m', '\033[44;37m'][popup.type];
let text = ` ${symbol} ${popup.text} `;
texts.push({
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,
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 warning(content) {errors.push({text: content, timer: errorDuration, type: 1});}
function info(content) {errors.push({text: content, timer: errorDuration, type: 2});}
function error(content) {popups.push({text: content, timer: errorDuration, type: 0});}
function warning(content) {popups.push({text: content, timer: errorDuration, type: 1});}
function info(content) {popups.push({text: content, timer: errorDuration, type: 2});}
module.exports.render = render;
module.exports.refreshrate = refreshrate;