Fix textbox and misc bugs

This commit is contained in:
catfoolyou 2025-05-20 11:08:24 -04:00
parent 931ceb9a6a
commit 08585d22d4
14 changed files with 39 additions and 6 deletions

Binary file not shown.

Binary file not shown.

View File

@ -98,6 +98,7 @@ public class GuiScreenEditProfile extends GuiScreen {
this.screenTitle = var1.translateKey("profile.title");
this.username = new GuiTextField(this.fontRenderer, this.width / 2 - 20 + 1, this.height / 6 + 24 + 1, 138, 20, EaglerProfile.username);
this.username.isEnabled = true;
this.username.setMaxStringLength(16);
selectedSlot = EaglerProfile.presetSkinId == -1 ? EaglerProfile.customSkinId : (EaglerProfile.presetSkinId + EaglerProfile.skins.size());
//this.buttonList.add(new GuiButton(0, this.width / 2 - 100, 140, "eeeee"));
this.controlList.add(button0 = new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done")));
@ -350,7 +351,7 @@ public class GuiScreenEditProfile extends GuiScreen {
String text = username.getText();
if(text.length() > 16) text = text.substring(0, 16);
text = text.replaceAll("[^A-Za-z0-9\\-_]", "_");
//text = text.replaceAll("[^A-Za-z0-9\\-_]", "_");
this.username.setText(text);
if(par2 == 200 && selectedSlot > 0) {

View File

@ -103,7 +103,19 @@ public class EaglercraftSaveManager implements ISaveFormat {
}
public void deleteWorldByDirectory(String s) {
new VFile2(directory + "/" + s, "Deleting World", "%i chunks").delete();
VFile2 var3 = new VFile2("saves", s);
System.out.println(var3.getPath());
if(var3.dirExists()) {
List<VFile2> files = var3.listFiles(true);
deleteWorldFiles(files.toArray(new VFile2[0]));
var3.delete();
}
}
protected static void deleteWorldFiles(VFile2[] var0) {
for(int var1 = 0; var1 < var0.length; ++var1) {
var0[var1].delete();
}
}
public boolean isOldMapFormat(String s) {

View File

@ -30,4 +30,24 @@ public class FontAllowedCharacters {
return var0;
}
public static final int[] allowedChars = new int[]{
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,
59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,
86,87,88,89,90,91,92,93,94,95,39,97,98,99,100,101,102,103,104,105,106,107,108,109,
110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,8962,199,252,
233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,
251,249,255,214,220,248,163,216,215,402,225,237,243,250,241,209,170,186,191,174,
172,189,188,161,171,187
};
public static int isAllowed(char c) {
int cc = (int) c;
for(int i = 0; i < allowedChars.length; ++i) {
if(cc == allowedChars[i]) {
return i;
}
}
return -1;
}
}

View File

@ -37,7 +37,7 @@ public class GuiMainMenu extends GuiScreen {
int var4 = this.height / 4 + 48;
this.controlList.add(new GuiButton(1, this.width / 2 - 100, var4, var2.translateKey("menu.singleplayer")));
this.controlList.add(this.guiButtonMP = new GuiButton(2, this.width / 2 - 100, var4 + 24, var2.translateKey("menu.multiplayer")));
//this.controlList.add(new GuiButton(3, this.width / 2 - 100, var4 + 48, var2.translateKey("menu.mods")));
this.controlList.add(new GuiButton(3, this.width / 2 - 100, var4 + 48, var2.translateKey("menu.mods")));
this.controlList.add(new GuiButton(0, this.width / 2 - 100, var4 + 72 + 12, 98, 20, var2.translateKey("menu.options")));
this.controlList.add(new GuiButton(4, this.width / 2 + 2, var4 + 72 + 12, 98, 20, var2.translateKey("Edit Profile")));

View File

@ -23,7 +23,7 @@ public class GuiRenameWorld extends GuiScreen {
this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, var1.translateKey("selectWorld.renameButton")));
this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, var1.translateKey("gui.cancel")));
ISaveFormat var2 = this.mc.getSaveLoader();
WorldInfo var3 = var2.getWorldInfoForWorld("saves/" + this.worldName + "/level.dat"); // FIX THIS SHIT
WorldInfo var3 = var2.getWorldInfoForWorld(worldName); // FIX THIS SHIT
String var4 = var3.getWorldName();
this.disableButton = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 60, 200, 20, var4);
this.disableButton.isFocused = true;

View File

@ -7,7 +7,7 @@ public class GuiTextField extends Gui {
private final int width;
private final int height;
private String text;
private int maxStringLength = 32;
private int maxStringLength;
private int cursorCounter;
public boolean isFocused = false;
public boolean isEnabled = true;
@ -56,7 +56,7 @@ public class GuiTextField extends Gui {
return;
}
if(this.text.length() < this.maxStringLength || this.maxStringLength == 0) {
if(FontAllowedCharacters.isAllowed(var1) >= 0 && (this.text.length() < this.maxStringLength || this.maxStringLength == 0)) {
this.text = this.text + var1;
}
}