From b70f17ef46ee8ef9bd678229e3913919cf6b3f6a Mon Sep 17 00:00:00 2001 From: onms Date: Sat, 27 Dec 2025 23:53:58 -0600 Subject: [PATCH] fixed spacing for multi-line logwindows --- js/plugins/MNKR_TMLogWindowMZ.js | 52 +++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/js/plugins/MNKR_TMLogWindowMZ.js b/js/plugins/MNKR_TMLogWindowMZ.js index 90fa404..438d8ba 100644 --- a/js/plugins/MNKR_TMLogWindowMZ.js +++ b/js/plugins/MNKR_TMLogWindowMZ.js @@ -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