diff --git a/src/main/java/de/zonlykroks/advancedscripts/screen/ScriptEditScreen.java b/src/main/java/de/zonlykroks/advancedscripts/screen/ScriptEditScreen.java index 582f3b1..d98db9f 100644 --- a/src/main/java/de/zonlykroks/advancedscripts/screen/ScriptEditScreen.java +++ b/src/main/java/de/zonlykroks/advancedscripts/screen/ScriptEditScreen.java @@ -34,6 +34,7 @@ public class ScriptEditScreen extends Screen { private Hand hand; private List lines = new ArrayList<>(); + private int scroll = 0; private int cursorY = 0; private int cursorX = 0; @@ -113,10 +114,10 @@ public class ScriptEditScreen extends Screen { int lineNumberLength = textRenderer.getWidth(lines.size() + ""); - int lineNumberText = 1; + int lineNumberText = scroll + 1; MutableInt lineNumber = new MutableInt(); TextHandler textHandler = this.textRenderer.getTextHandler(); - for (int i = 0; i < lines.size(); i++) { + for (int i = scroll; i < lines.size(); i++) { String s = lines.get(i); if (lineNumber.getValue() * 9 + 25 > this.height - 66) { @@ -350,6 +351,23 @@ public class ScriptEditScreen extends Screen { return cursorX == lines.get(cursorY).length(); } + @Override + public boolean mouseScrolled(double mouseX, double mouseY, double amount) { + scroll -= amount / 10; + if (scroll > lines.size() - 1) { + scroll = lines.size() - 1; + } + if (scroll < 0) { + scroll = 0; + } + return true; + } + + @Override + public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { + return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); + } + @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { return super.mouseClicked(mouseX, mouseY, button);