Added a configurable expansion to scripts' length, adding 65535 more characters with every additional increase.

This commit is contained in:
c0508383 committed 2022-07-12 11:58:54 -05:00
1 parent b4f112ee89
commit 9fc408e598
4 files changed
+68 -12

No files matched your search

@@ -27,7 +27,8 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
private int startClick = -1;
private boolean clickVerticalBar = false;
private boolean wrapLine = true;
private List<String> lines = new ArrayList<>();
public GuiNpcTextArea(int id,GuiScreen guiscreen, int i, int j, int k, int l, String s) {
super(id,guiscreen, i, j, k, l, s);
posX = i;
@@ -39,6 +40,24 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
this.setText(s);
}
@Override
public void setText(String text) {
super.setText(text);
List<String> list = new ArrayList<String>();
StringBuilder line = new StringBuilder();
for(char c : getText().toCharArray()){
if(c == '\r' || c == '\n'){
list.add(line.toString());
line = new StringBuilder();
}
else
line.append(c);
}
list.add(line.toString());
lines = list;
}
@Override
public void updateCursorCounter(){
cursorCounter++;
@@ -52,10 +71,12 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
if(c == '\r' || c == '\n'){
this.setText(originalText.substring(0, cursorPosition) + c + originalText.substring(cursorPosition));
}
this.setCursorPositionZero();
boolean bo = super.textboxKeyTyped(c, i);
String newText = getText();
this.setText(newText);
this.setCursorPositionZero();
this.moveCursorBy(cursorPosition);
boolean bo = super.textboxKeyTyped(c, i);
String newText = getText();
if(i != Keyboard.KEY_DELETE)
cursorPosition += newText.length() - originalText.length();
if(i == Keyboard.KEY_LEFT && cursorPosition > 0)
@@ -63,7 +84,6 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
if(i == Keyboard.KEY_RIGHT && cursorPosition < newText.length())
cursorPosition++;
return bo;
}
return false;
}
@@ -84,7 +104,6 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
int x = i - posX;
int y = (j - posY - 4) / font.height() + getStartLineY();
cursorPosition = 0;
List<String> lines = getLines();
int charCount = 0;
int lineCount = 0;
int maxSize = width - (isScrolling()?14:4);
@@ -153,8 +172,7 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
int startLine = getStartLineY();
int maxLine = height / font.height() + startLine;
List<String> lines = getLines();
int charCount = 0;
int lineCount = 0;
int maxSize = width - (isScrolling()?14:4);