From b09f774d422263ce15b97d6d0804beddf856176d Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:53:57 -0500 Subject: feat: improve formating :) --- .../notenoughupdates/infopanes/TextInfoPane.java | 105 ++++++++++++--------- 1 file changed, 58 insertions(+), 47 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java index 663c1115..77d47a3d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java @@ -10,51 +10,62 @@ import net.minecraft.client.gui.ScaledResolution; import java.awt.*; public class TextInfoPane extends ScrollableInfoPane { - protected String title; - protected String text; - - public TextInfoPane(NEUOverlay overlay, NEUManager manager, String title, String text) { - super(overlay, manager); - this.title = title; - this.text = text; - } - - public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, int mouseY) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - - int paneWidth = (int) (width / 3 * overlay.getWidthMult()); - int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor()); - int leftSide = rightSide - paneWidth; - - int titleLen = fr.getStringWidth(title); - int yScroll = -scrollHeight.getValue(); - fr.drawString(title, (leftSide + rightSide - titleLen) / 2, yScroll + overlay.getBoxPadding() + 5, - Color.WHITE.getRGB()); - - int yOff = 20; - for (String line : text.split("\n")) { - yOff += Utils.renderStringTrimWidth(line, fr, false, leftSide + overlay.getBoxPadding() + 5, - yScroll + overlay.getBoxPadding() + 10 + yOff, - width * 1 / 3 - overlay.getBoxPadding() * 2 - 10, Color.WHITE.getRGB(), -1); - yOff += 16; - } - - int top = overlay.getBoxPadding() - 5; - int totalBoxHeight = yOff + 14; - int bottom = Math.max(top + totalBoxHeight, height - overlay.getBoxPadding() + 5); - - if (scrollHeight.getValue() > top + totalBoxHeight - (height - overlay.getBoxPadding() + 5)) { - scrollHeight.setValue(top + totalBoxHeight - (height - overlay.getBoxPadding() + 5)); - } - drawRect(leftSide + overlay.getBoxPadding() - 5, yScroll + overlay.getBoxPadding() - 5, - rightSide - overlay.getBoxPadding() + 5, yScroll + bottom, bg.getRGB()); - } - - public boolean keyboardInput() { - return false; - } - - public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) { - super.mouseInput(width, height, mouseX, mouseY, mouseDown); - } + protected String title; + protected String text; + + public TextInfoPane(NEUOverlay overlay, NEUManager manager, String title, String text) { + super(overlay, manager); + this.title = title; + this.text = text; + } + + public void render( + int width, + int height, + Color bg, + Color fg, + ScaledResolution scaledresolution, + int mouseX, + int mouseY + ) { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + int paneWidth = (int) (width / 3 * overlay.getWidthMult()); + int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor()); + int leftSide = rightSide - paneWidth; + + int titleLen = fr.getStringWidth(title); + int yScroll = -scrollHeight.getValue(); + fr.drawString(title, (leftSide + rightSide - titleLen) / 2, yScroll + overlay.getBoxPadding() + 5, + Color.WHITE.getRGB() + ); + + int yOff = 20; + for (String line : text.split("\n")) { + yOff += Utils.renderStringTrimWidth(line, fr, false, leftSide + overlay.getBoxPadding() + 5, + yScroll + overlay.getBoxPadding() + 10 + yOff, + width * 1 / 3 - overlay.getBoxPadding() * 2 - 10, Color.WHITE.getRGB(), -1 + ); + yOff += 16; + } + + int top = overlay.getBoxPadding() - 5; + int totalBoxHeight = yOff + 14; + int bottom = Math.max(top + totalBoxHeight, height - overlay.getBoxPadding() + 5); + + if (scrollHeight.getValue() > top + totalBoxHeight - (height - overlay.getBoxPadding() + 5)) { + scrollHeight.setValue(top + totalBoxHeight - (height - overlay.getBoxPadding() + 5)); + } + drawRect(leftSide + overlay.getBoxPadding() - 5, yScroll + overlay.getBoxPadding() - 5, + rightSide - overlay.getBoxPadding() + 5, yScroll + bottom, bg.getRGB() + ); + } + + public boolean keyboardInput() { + return false; + } + + public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) { + super.mouseInput(width, height, mouseX, mouseY, mouseDown); + } } -- cgit