fixed spacing for multi-line logwindows

This commit is contained in:
onms 2025-12-27 23:53:58 -06:00
parent 7c8cfb0b58
commit b70f17ef46

View file

@ -550,17 +550,47 @@ Imported.TMLogWindow = true;
}
};
// リフレッシュ
Window_MapLog.prototype.refresh = function () {
this.contents.clear();
let actionLog = $gameSystem.actionLog();
let lh = this.lineHeight();
let n = Math.min(logWindowLines, actionLog.length);
for (let i = 0; i < n; i++) {
// this.drawTextEx(actionLog[actionLog.length - n + i], 0, lh * i);
this.drawTextEx('\\FS[' + String(logWindowFontSize) + ']' + actionLog[actionLog.length - n + i], 0, lh * i);
}
};
// リフレッシュ (Universal dynamic spacing)
Window_MapLog.prototype.refresh = function () {
this.contents.clear();
const actionLog = $gameSystem.actionLog();
const lh = this.lineHeight();
let startIndex = actionLog.length;
let linesUsed = 0;
// 1. Determine which entries fit
for (let i = actionLog.length - 1; i >= 0; i--) {
const lineCount = actionLog[i].split(/\n/).length;
if (linesUsed + lineCount > logWindowLines) {
break;
}
linesUsed += lineCount;
startIndex = i;
}
// 2. Draw entries
let currentY = 0;
for (let i = startIndex; i < actionLog.length; i++) {
const text = actionLog[i];
const linesInThisEntry = text.split(/\n/).length;
this.drawTextEx(
'\\FS[' + logWindowFontSize + ']' + text,
0,
currentY
);
// 3. Universal Logic:
// Calculate total height (lh * lines)
// Then subtract 12 pixels for EVERY newline after the first one.
const totalHeight = lh * linesInThisEntry;
const correction = (linesInThisEntry - 1) * 12;
currentY += (totalHeight - correction);
}
};
//-----------------------------------------------------------------------------
// Window_MenuLog