Refactored and reformatted code to use less static variables

This commit is contained in:
CrushedPixel
2015-04-23 14:09:54 +02:00
parent f22416be2c
commit 0003f040ed
109 changed files with 9037 additions and 10229 deletions

View File

@@ -1,40 +1,33 @@
package eu.crushedpixel.replaymod.gui.replayviewer;
import java.io.File;
import java.io.IOException;
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import org.apache.commons.io.FilenameUtils;
import org.lwjgl.input.Keyboard;
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
import java.io.File;
import java.io.IOException;
public class GuiRenameReplay extends GuiScreen
{
public class GuiRenameReplay extends GuiScreen {
private static final String __OBFID = "CL_00000709";
private GuiScreen field_146585_a;
private GuiTextField field_146583_f;
private static final String __OBFID = "CL_00000709";
private File file;
public GuiRenameReplay(GuiScreen parent, File file)
{
public GuiRenameReplay(GuiScreen parent, File file) {
this.field_146585_a = parent;
this.file = file;
}
public void updateScreen()
{
public void updateScreen() {
this.field_146583_f.updateCursorCounter();
}
public void initGui()
{
public void initGui() {
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("Rename", new Object[0])));
@@ -45,29 +38,23 @@ public class GuiRenameReplay extends GuiScreen
this.field_146583_f.setText(s);
}
public void onGuiClosed()
{
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
}
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 1)
{
protected void actionPerformed(GuiButton button) throws IOException {
if(button.enabled) {
if(button.id == 1) {
this.mc.displayGuiScreen(this.field_146585_a);
}
else if (button.id == 0)
{
File folder = ReplayFileIO.getReplayFolder();
} else if(button.id == 0) {
File folder = ReplayFileIO.getReplayFolder();
File initRenamed = new File(folder, this.field_146583_f.getText().trim()+ConnectionEventHandler.ZIP_FILE_EXTENSION.replaceAll("[^a-zA-Z0-9\\.\\-]", "_"));
File renamed = initRenamed;
int i=1;
File initRenamed = new File(folder, this.field_146583_f.getText().trim() + ConnectionEventHandler.ZIP_FILE_EXTENSION.replaceAll("[^a-zA-Z0-9\\.\\-]", "_"));
File renamed = initRenamed;
int i = 1;
while(renamed.isFile()) {
renamed = new File(initRenamed.getAbsolutePath()+"_"+i);
i++;
renamed = new File(initRenamed.getAbsolutePath() + "_" + i);
i++;
}
file.renameTo(renamed);
this.mc.displayGuiScreen(this.field_146585_a);
@@ -75,25 +62,21 @@ public class GuiRenameReplay extends GuiScreen
}
}
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
protected void keyTyped(char typedChar, int keyCode) throws IOException {
this.field_146583_f.textboxKeyTyped(typedChar, keyCode);
((GuiButton)this.buttonList.get(0)).enabled = this.field_146583_f.getText().trim().length() > 0;
((GuiButton) this.buttonList.get(0)).enabled = this.field_146583_f.getText().trim().length() > 0;
if (keyCode == 28 || keyCode == 156)
{
this.actionPerformed((GuiButton)this.buttonList.get(0));
if(keyCode == 28 || keyCode == 156) {
this.actionPerformed((GuiButton) this.buttonList.get(0));
}
}
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
this.field_146583_f.mouseClicked(mouseX, mouseY, mouseButton);
}
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, I18n.format("Rename World", new Object[0]), this.width / 2, 20, 16777215);
this.drawString(this.fontRendererObj, I18n.format("Replay Name", new Object[0]), this.width / 2 - 100, 47, 10526880);