aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-27 11:53:57 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-27 11:53:57 -0500
commitb09f774d422263ce15b97d6d0804beddf856176d (patch)
treee542258481d7496b15679f3c329ef9e087c7d8fc /src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java
parent22cb02adbeb24b7ec98f843bcaba99cebe3e4f03 (diff)
downloadnotenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.gz
notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.bz2
notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.zip
feat: improve formating :)
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java105
1 files changed, 58 insertions, 47 deletions
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);
+ }
}