diff --git a/src/main/java/autostore/client/gui/AutoStoreGui.java b/src/main/java/autostore/client/gui/AutoStoreGui.java index c6de140..f1ae133 100644 --- a/src/main/java/autostore/client/gui/AutoStoreGui.java +++ b/src/main/java/autostore/client/gui/AutoStoreGui.java @@ -28,6 +28,7 @@ import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.CheckboxWidget; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.StringVisitable; +import net.minecraft.text.OrderedText; @Environment(value=EnvType.CLIENT) /** @@ -470,13 +471,26 @@ extends Screen { context.drawTextWithShadow(this.textRenderer, "\u72b6\u6001\u4fe1\u606f", statusX, infoTop, -5592406); context.fill(statusX - 12, infoTop - 1, statusX - 11, infoTop + 58, -12761518); - // 运行日志:最多 4 条,最新日志在最下方 + // 运行日志:使用较小字体并自动换行,最新日志在最上方,逐行向下显示直到填满可视高度 List logs = this.controller.logs(); - int shown = Math.min(4, logs.size()); - for (int i = 0; i < shown; ++i) { - String trimmed = this.textRenderer.trimToWidth(logs.get(logs.size() - shown + i), logWidth - 4); - context.drawTextWithShadow(this.textRenderer, trimmed, this.mapX + 2, infoTop + 12 + i * 12, -6577233); + float logScale = 0.75f; // 日志字号缩放(比默认小一号) + int logAreaTop = infoTop + 12; + int logAreaBottom = infoTop + 56; // 与竖向分隔线底部对齐 + int wrapWidth = (int)((logWidth - 4) / logScale); // 缩放后的可用换行宽度(按未缩放坐标计算) + context.getMatrices().push(); + context.getMatrices().scale(logScale, logScale, 1.0f); + int lineY = logAreaTop; + outer: + for (int i = logs.size() - 1; i >= 0; --i) { + for (OrderedText line : this.textRenderer.wrapLines(Text.literal(logs.get(i)), wrapWidth)) { + if (lineY + 9 > logAreaBottom) { + break outer; + } + context.drawTextWithShadow(this.textRenderer, line, (int)((this.mapX + 2) / logScale), (int)(lineY / logScale), -6577233); + lineY += 9; + } } + context.getMatrices().pop(); // 状态信息:单行截断 + 固定 12px 行距,彻底消除换行重叠 int target = this.config.targetCount;