Skip to content

Commit

Permalink
cache in chat list
Browse files Browse the repository at this point in the history
  • Loading branch information
skuqre committed Dec 18, 2023
1 parent 97441f3 commit f395bef
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/scripts/blabla.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,10 @@ function generateBlabla() {
ctx.font = "18px PR";
ctx.fillText(item.message, curx + 123, cury + 50);

let pfpImg = new Image();
pfpImg.crossOrigin = "anonymous";
pfpImg.src = item.image;
let pfpy = cury;
pfpImg.onload = function() {
if (loaded[item.name] != null) {
let pfpImg = loaded[item.name];
let pfpy = cury;

chatterCtx.drawImage(chatter_mask, 0, 0);
chatterCtx.globalCompositeOperation = 'source-in';

Expand All @@ -535,11 +534,20 @@ function generateBlabla() {
let diff = 233 - pfpy;
let cond = (diff > 0 ? diff : 0);

// ctx.drawImage(pfpCanvas, 0, diff > 0 ? diff : 0, 74, 74 - cond, 107 - 74 - 19, pfpy - 19 + cond, 74, 74 - cond)
ctx.drawImage(chatterCanvas, 0, cond, chatterCanvas.width, chatterCanvas.height - cond, 18, pfpy + cond, chatterCanvas.width, chatterCanvas.height - cond);
}
pfpImg.onerror = function() {
pfpImg.src = '/nikke-font-generator/images/blabla/blabla_icon.png';
} else {
let pfpImg = new Image();
pfpImg.crossOrigin = "anonymous";
pfpImg.src = item.image;
pfpImg.onload = function() {
if (loaded[item.name] == null) {
loaded[item.name] = pfpImg;
generateBlabla();
}
}
pfpImg.onerror = function() {
pfpImg.src = '/nikke-font-generator/images/blabla/blabla_icon.png';
}
}

cury += 90;
Expand Down Expand Up @@ -658,7 +666,7 @@ document.getElementById("set-com").onclick = (e) => {
if (document.getElementById("charname").value.toLowerCase() != 'commander') {
prevChat = document.getElementById("charname").value;
}

document.getElementById("charname").value = 'Commander';
document.getElementById("color").value = document.getElementById("com-color").value;
}
Expand Down

0 comments on commit f395bef

Please sign in to comment.