Fix all warnings
Add and make use of Lombok Remove Mojang API Remove ZipFileUtils Remove StreamTools in favor of Apache IOUtils Keyframe should be abstract all derivatives final Replace clone in Keyframe with copy Move some constants from GuiReplaySetttings to GuiConstants
This commit is contained in:
@@ -15,16 +15,10 @@ public class GuiConstants {
|
||||
public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011;
|
||||
public static final int CENTER_FAVORITED_REPLAYS_BUTTON = 2012;
|
||||
|
||||
public static final int UPLOAD_NAME_INPUT = 3001;
|
||||
public static final int UPLOAD_CATEGORY_BUTTON = 3002;
|
||||
public static final int UPLOAD_START_BUTTON = 3003;
|
||||
public static final int UPLOAD_CANCEL_BUTTON = 3004;
|
||||
public static final int UPLOAD_BACK_BUTTON = 3005;
|
||||
public static final int UPLOAD_INFO_FIELD = 3006;
|
||||
public static final int UPLOAD_TAG_INPUT = 3007;
|
||||
public static final int UPLOAD_TAG_PLACEHOLDER = 3008;
|
||||
public static final int UPLOAD_HIDE_SERVER_IP = 3009;
|
||||
public static final int UPLOAD_NAME_PLACEHOLDER = 3010;
|
||||
|
||||
public static final int EXIT_REPLAY_BUTTON = 4001;
|
||||
|
||||
@@ -33,8 +27,6 @@ public class GuiConstants {
|
||||
public static final int REPLAY_MANAGER_BUTTON_ID = 9001;
|
||||
public static final int REPLAY_EDITOR_BUTTON_ID = 9002;
|
||||
public static final int REPLAY_CENTER_BUTTON_ID = 9003;
|
||||
public static final int REPLAY_CENTER_LOGIN_TEXT_ID = 9004;
|
||||
public static final int REPLAY_CENTER_PASSWORD_TEXT_ID = 9005;
|
||||
|
||||
public static final int LOGIN_OKAY_BUTTON = 1100;
|
||||
public static final int LOGIN_CANCEL_BUTTON = 1101;
|
||||
@@ -79,16 +71,11 @@ public class GuiConstants {
|
||||
public static final int KEYFRAME_EDITOR_PITCH_INPUT = 6007;
|
||||
public static final int KEYFRAME_EDITOR_YAW_INPUT = 6008;
|
||||
public static final int KEYFRAME_EDITOR_ROLL_INPUT = 6009;
|
||||
public static final int KEYFRAME_EDITOR_MIN_INPUT = 6010;
|
||||
public static final int KEYFRAME_EDITOR_SEC_INPUT = 6011;
|
||||
public static final int KEYFRAME_EDITOR_MS_INPUT = 6012;
|
||||
public static final int KEYFRAME_EDITOR_REAL_MIN_INPUT = 6013;
|
||||
public static final int KEYFRAME_EDITOR_REAL_SEC_INPUT = 6014;
|
||||
public static final int KEYFRAME_EDITOR_REAL_MS_INPUT = 6015;
|
||||
public static final int KEYFRAME_EDITOR_MARKER_NAME_INPUT = 6016;
|
||||
|
||||
public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010;
|
||||
public static final int PLAYER_OVERVIEW_SHOW_ALL = 0101;
|
||||
public static final int PLAYER_OVERVIEW_SHOW_ALL = 101;
|
||||
public static final int PLAYER_OVERVIEW_REMEMBER = -10;
|
||||
|
||||
public static final int RENDER_SETTINGS_RENDERER_DROPDOWN = 9001;
|
||||
@@ -106,4 +93,13 @@ public class GuiConstants {
|
||||
public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013;
|
||||
public static final int RENDER_SETTINGS_COLOR_PICKER = 9014;
|
||||
public static final int RENDER_SETTINGS_ENABLE_GREENSCREEN = 9015;
|
||||
|
||||
public static final int REPLAY_SETTINGS_RECORDSERVER_ID = 9004;
|
||||
public static final int REPLAY_SETTINGS_RECORDSP_ID = 9005;
|
||||
public static final int REPLAY_SETTINGS_SEND_CHAT = 9006;
|
||||
public static final int REPLAY_SETTINGS_FORCE_LINEAR = 9007;
|
||||
public static final int REPLAY_SETTINGS_ENABLE_LIGHTING = 9008;
|
||||
public static final int REPLAY_SETTINGS_RESOURCEPACK_ID = 9010;
|
||||
public static final int REPLAY_SETTINGS_INDICATOR_ID = 9012;
|
||||
public static final int REPLAY_SETTINGS_PATHPREVIEW_ID = 9013;
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
private Keyframe keyframeBackup;
|
||||
private boolean save;
|
||||
private boolean posKeyframe;
|
||||
private boolean timeKeyframe;
|
||||
private boolean markerKeyframe;
|
||||
|
||||
private Keyframe previous, next;
|
||||
|
||||
private int w, w2, w3;
|
||||
private int w2;
|
||||
private int w3;
|
||||
private int totalWidth;
|
||||
private int left;
|
||||
|
||||
@@ -55,9 +55,9 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
|
||||
public GuiEditKeyframe(Keyframe keyframe) {
|
||||
this.keyframe = keyframe;
|
||||
this.keyframeBackup = keyframe.clone();
|
||||
this.keyframeBackup = keyframe.copy();
|
||||
this.posKeyframe = keyframe instanceof PositionKeyframe;
|
||||
this.timeKeyframe = keyframe instanceof TimeKeyframe;
|
||||
boolean timeKeyframe = keyframe instanceof TimeKeyframe;
|
||||
this.markerKeyframe = keyframe instanceof MarkerKeyframe;
|
||||
|
||||
ReplayHandler.selectKeyframe(null);
|
||||
@@ -152,14 +152,14 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-65;
|
||||
|
||||
if(posKeyframe) {
|
||||
w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
||||
int w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
||||
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.ypos")),
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.zpos"))));
|
||||
w2 = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camyaw")),
|
||||
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")),
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camroll"))));
|
||||
|
||||
totalWidth = w+100+w2+100+5+5+10;
|
||||
totalWidth = w +100+w2+100+5+5+10;
|
||||
left = (this.width - totalWidth)/2;
|
||||
|
||||
int x = w + left + 5;
|
||||
@@ -178,6 +178,9 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
saveButton.xPosition = this.width - 100 - 5 - 10;
|
||||
cancelButton.xPosition = saveButton.xPosition - 100 - 5;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
|
||||
buttonList.add(saveButton);
|
||||
buttonList.add(cancelButton);
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
public class GuiHelpOverlay {
|
||||
}
|
||||
@@ -121,6 +121,9 @@ public class GuiKeyframeRepository extends GuiScreen implements GuiReplayOverlay
|
||||
saveButton.yPosition = keyframeSetList.yPosition+keyframeSetList.height-20;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
|
||||
buttonList.add(removeButton);
|
||||
buttonList.add(loadButton);
|
||||
buttonList.add(saveButton);
|
||||
|
||||
@@ -26,9 +26,7 @@ import org.lwjgl.input.Mouse;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
||||
@@ -150,6 +148,9 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
upperPlayer = 0;
|
||||
lowerBound = this.height - 10;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
|
||||
int i = 0;
|
||||
for(GuiCheckBox checkBox : checkBoxes) {
|
||||
checkBox.xPosition = (int)(this.width*0.7)-5;
|
||||
@@ -235,6 +236,8 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
GlStateManager.resetColor();
|
||||
if(fitting >= checkBoxes.size()) {
|
||||
checkBoxes.add(new GuiCheckBox(checkBoxes.size(), (int)(this.width*0.7)-5, l2+3, "", true));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
buttonList.add(checkBoxes.get(checkBoxes.size() - 1));
|
||||
}
|
||||
checkBoxes.get(fitting).setIsChecked(!PlayerHandler.isHidden(p.first().getUniqueID()));
|
||||
@@ -294,7 +297,8 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
}
|
||||
|
||||
private PlayerVisibility getVisibilityInstance() {
|
||||
return new PlayerVisibility(PlayerHandler.getHiddenPlayers());
|
||||
Set<UUID> hidden = PlayerHandler.getHiddenPlayers();
|
||||
return new PlayerVisibility(hidden.toArray(new UUID[hidden.size()]));
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +306,7 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
if(rememberHidden.isChecked()) {
|
||||
try {
|
||||
File f = File.createTempFile(ReplayFile.ENTRY_VISIBILITY, "json");
|
||||
ReplayFileIO.writePlayerVisibilityToFile(getVisibilityInstance(), f);
|
||||
ReplayFileIO.write(getVisibilityInstance(), f);
|
||||
ReplayMod.replayFileAppender.registerModifiedFile(f, ReplayFile.ENTRY_VISIBILITY, ReplayHandler.getReplayFile());
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -22,12 +22,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiRenderSettings extends GuiScreen {
|
||||
private static final int LEFT_BORDER = 10;
|
||||
|
||||
private GuiButton renderButton, cancelButton, advancedButton;
|
||||
private GuiDropdown<RendererSettings> rendererDropdown;
|
||||
|
||||
private int virtualY, virtualHeight;
|
||||
private int leftBorder = 10;
|
||||
|
||||
private GuiCheckBox customResolution, ignoreCamDir, youtubeExport, enableGreenscreen;
|
||||
private GuiNumberInput xRes, yRes;
|
||||
@@ -42,7 +42,7 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
|
||||
private boolean advancedTab = false;
|
||||
|
||||
private int w1, w2, w3;
|
||||
private int w1;
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
@@ -170,18 +170,18 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
rendererDropdown.yPosition = virtualY + 15 + 15;
|
||||
rendererDropdown.xPosition = (width-w1)/2 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.rendersettings.renderer") + ":")+10;
|
||||
|
||||
w2 = customResolution.width+5+xRes.width+5+fontRendererObj.getStringWidth("*")+5+yRes.width;
|
||||
int w2 = customResolution.width + 5 + xRes.width + 5 + fontRendererObj.getStringWidth("*") + 5 + yRes.width;
|
||||
|
||||
customResolution.yPosition = virtualY + 15 + 5 + 20 + 10 +5+fontRendererObj.getStringWidth("*")+5;
|
||||
customResolution.xPosition = (width-w2)/2;
|
||||
customResolution.xPosition = (width- w2)/2;
|
||||
|
||||
xRes.xPosition = customResolution.xPosition + customResolution.width + 5;
|
||||
yRes.xPosition = xRes.xPosition+xRes.width+5+fontRendererObj.getStringWidth("*")+5;
|
||||
xRes.yPosition = yRes.yPosition = customResolution.yPosition-3;
|
||||
|
||||
w3 = interpolation.width + 10 + forceChunks.width;
|
||||
int w3 = interpolation.width + 10 + forceChunks.width;
|
||||
|
||||
interpolation.xPosition = (width-w3)/2;
|
||||
interpolation.xPosition = (width- w3)/2;
|
||||
interpolation.yPosition = xRes.yPosition+20+10;
|
||||
|
||||
forceChunks.xPosition = interpolation.xPosition+interpolation.width+10;
|
||||
@@ -224,7 +224,7 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawGradientRect(leftBorder, virtualY, width - leftBorder, virtualY + virtualHeight, -1072689136, -804253680);
|
||||
drawGradientRect(LEFT_BORDER, virtualY, width - LEFT_BORDER, virtualY + virtualHeight, -1072689136, -804253680);
|
||||
|
||||
this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.title"),
|
||||
this.width / 2, virtualY + 5, Color.WHITE.getRGB());
|
||||
@@ -252,7 +252,7 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if(!rendererDropdown.mouseClickedResult(mouseX, mouseY, mouseButton)) {
|
||||
if(!rendererDropdown.mouseClickedResult(mouseX, mouseY)) {
|
||||
xRes.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
yRes.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
|
||||
@@ -12,21 +12,11 @@ import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiReplaySettings extends GuiScreen {
|
||||
import static eu.crushedpixel.replaymod.gui.GuiConstants.*;
|
||||
|
||||
//TODO: Move to GuiConstants
|
||||
private static final int RECORDSERVER_ID = 9004;
|
||||
private static final int RECORDSP_ID = 9005;
|
||||
private static final int SEND_CHAT = 9006;
|
||||
private static final int FORCE_LINEAR = 9007;
|
||||
private static final int ENABLE_LIGHTING = 9008;
|
||||
private static final int RESOURCEPACK_ID = 9010;
|
||||
private static final int INDICATOR_ID = 9012;
|
||||
private static final int PATHPREVIEW_ID = 9013;
|
||||
public class GuiReplaySettings extends GuiScreen {
|
||||
protected String screenTitle = I18n.format("replaymod.gui.settings.title");
|
||||
private GuiScreen parentGuiScreen;
|
||||
private GuiToggleButton recordServerButton, recordSPButton, sendChatButton, linearButton, lightingButton,
|
||||
resourcePackButton, showIndicatorButton, pathPreviewButton;
|
||||
|
||||
public GuiReplaySettings(GuiScreen parentGuiScreen) {
|
||||
this.parentGuiScreen = parentGuiScreen;
|
||||
@@ -34,8 +24,12 @@ public class GuiReplaySettings extends GuiScreen {
|
||||
|
||||
public void initGui() {
|
||||
this.screenTitle = I18n.format("replaymod.gui.settings.title");
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done")));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.List<GuiButton> buttonList = this.buttonList;
|
||||
|
||||
buttonList.clear();
|
||||
buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done")));
|
||||
|
||||
int i = 0;
|
||||
|
||||
@@ -45,20 +39,20 @@ public class GuiReplaySettings extends GuiScreen {
|
||||
int yPos = this.height / 6 + 24 * (i >> 1);
|
||||
|
||||
if(o == RecordingOptions.notifications) {
|
||||
sendChatButton = new GuiSettingsOnOffButton(SEND_CHAT, xPos, yPos, 150, 20, o);
|
||||
this.buttonList.add(sendChatButton);
|
||||
GuiToggleButton sendChatButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_SEND_CHAT, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(sendChatButton);
|
||||
|
||||
} else if(o == RecordingOptions.recordServer) {
|
||||
recordServerButton = new GuiSettingsOnOffButton(RECORDSERVER_ID, xPos, yPos, 150, 20, o);
|
||||
this.buttonList.add(recordServerButton);
|
||||
GuiToggleButton recordServerButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSERVER_ID, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(recordServerButton);
|
||||
|
||||
} else if(o == RecordingOptions.recordSingleplayer) {
|
||||
recordSPButton = new GuiSettingsOnOffButton(RECORDSP_ID, xPos, yPos, 150, 20, o);
|
||||
this.buttonList.add(recordSPButton);
|
||||
GuiToggleButton recordSPButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSP_ID, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(recordSPButton);
|
||||
|
||||
} else if(o == RecordingOptions.indicator) {
|
||||
showIndicatorButton = new GuiSettingsOnOffButton(INDICATOR_ID, xPos, yPos, 150, 20, o);
|
||||
this.buttonList.add(showIndicatorButton);
|
||||
GuiToggleButton showIndicatorButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_INDICATOR_ID, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(showIndicatorButton);
|
||||
}
|
||||
|
||||
++i;
|
||||
@@ -75,21 +69,21 @@ public class GuiReplaySettings extends GuiScreen {
|
||||
int yPos = this.height / 6 + 24 * (i >> 1);
|
||||
|
||||
if(o == ReplayOptions.lighting) {
|
||||
lightingButton = new GuiSettingsOnOffButton(ENABLE_LIGHTING, xPos, yPos, 150, 20, o);
|
||||
this.buttonList.add(lightingButton);
|
||||
GuiToggleButton lightingButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_ENABLE_LIGHTING, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(lightingButton);
|
||||
|
||||
} else if(o == ReplayOptions.linear) {
|
||||
linearButton = new GuiSettingsOnOffButton(FORCE_LINEAR, xPos, yPos, 150, 20, o,
|
||||
GuiToggleButton linearButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_FORCE_LINEAR, xPos, yPos, 150, 20, o,
|
||||
I18n.format("replaymod.gui.settings.interpolation.linear"), I18n.format("replaymod.gui.settings.interpolation.cubic"));
|
||||
this.buttonList.add(linearButton);
|
||||
buttonList.add(linearButton);
|
||||
|
||||
} else if(o == ReplayOptions.useResources) {
|
||||
resourcePackButton = new GuiSettingsOnOffButton(RESOURCEPACK_ID, xPos, yPos, 150, 20, o);
|
||||
this.buttonList.add(resourcePackButton);
|
||||
GuiToggleButton resourcePackButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RESOURCEPACK_ID, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(resourcePackButton);
|
||||
|
||||
} else if(o == ReplayOptions.previewPath) {
|
||||
pathPreviewButton = new GuiSettingsOnOffButton(PATHPREVIEW_ID, xPos, yPos, 150, 20, o);
|
||||
this.buttonList.add(pathPreviewButton);
|
||||
GuiToggleButton pathPreviewButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_PATHPREVIEW_ID, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(pathPreviewButton);
|
||||
}
|
||||
|
||||
++i;
|
||||
|
||||
@@ -39,14 +39,6 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement {
|
||||
displayString = displayKey + ": 1x";
|
||||
}
|
||||
|
||||
public static float convertScaleRet(float value) {
|
||||
if(value <= 1) {
|
||||
return Math.round(value * 10);
|
||||
}
|
||||
float steps = value - 1;
|
||||
return Math.round(steps / 0.25f);
|
||||
}
|
||||
|
||||
public static float convertScale(float value) {
|
||||
if(value == 10) {
|
||||
return 1;
|
||||
@@ -89,6 +81,7 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement {
|
||||
|
||||
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
|
||||
} catch(Exception e) {
|
||||
// TODO: Fix exception
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,6 +114,7 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement {
|
||||
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20);
|
||||
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
|
||||
} catch(Exception e) {
|
||||
// TODO: Fix exception
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,13 +123,6 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement {
|
||||
return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
public float realToNormalized(float value) {
|
||||
float min = 0 - valueMin;
|
||||
float max = valueMax + min;
|
||||
|
||||
return value / (max) - min;
|
||||
}
|
||||
|
||||
public float denormalizeValue(float p_148262_1_) {
|
||||
return this.snapToStepClamp(this.valueMin + (this.valueMax - this.valueMin) * MathHelper.clamp_float(p_148262_1_, 0.0F, 1.0F));
|
||||
}
|
||||
|
||||
@@ -5,22 +5,10 @@ import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
public class GuiAdvancedButton extends GuiButton implements GuiElement {
|
||||
|
||||
public GuiAdvancedButton(int x, int y, String buttonText) {
|
||||
this(0, x, y, buttonText);
|
||||
}
|
||||
|
||||
public GuiAdvancedButton(int x, int y, int widthIn, int heightIn, String buttonText) {
|
||||
this(0, x, y, widthIn, heightIn, buttonText);
|
||||
}
|
||||
|
||||
public GuiAdvancedButton(int id, int x, int y, String buttonText) {
|
||||
super(id, x, y, buttonText);
|
||||
}
|
||||
|
||||
public GuiAdvancedButton(int id, int x, int y, int widthIn, int heightIn, String buttonText) {
|
||||
super(id, x, y, widthIn, heightIn, buttonText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
||||
drawButton(mc, mouseX, mouseY);
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.awt.*;
|
||||
public class GuiArrowButton extends GuiButton {
|
||||
|
||||
public enum Direction {
|
||||
UP, DOWN, RIGHT, LEFT;
|
||||
UP, DOWN, RIGHT, LEFT
|
||||
}
|
||||
|
||||
private Direction dir;
|
||||
|
||||
@@ -134,11 +134,11 @@ public class GuiDropdown<T> extends GuiTextField {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int xPos, int yPos, int mouseButton) {
|
||||
mouseClickedResult(xPos, yPos, mouseButton);
|
||||
mouseClickedResult(xPos, yPos);
|
||||
}
|
||||
|
||||
|
||||
public boolean mouseClickedResult(int xPos, int yPos, int mouseButton) {
|
||||
public boolean mouseClickedResult(int xPos, int yPos) {
|
||||
boolean success = false;
|
||||
if(xPos > xPosition + width - height && xPos < xPosition + width && yPos > yPosition && yPos < yPosition + height) {
|
||||
open = !open;
|
||||
@@ -146,8 +146,7 @@ public class GuiDropdown<T> extends GuiTextField {
|
||||
if(xPos > xPosition && xPos < xPosition + width && open) {
|
||||
int requiredHeight = Math.min(maxDropoutHeight, elements.size() * dropoutElementHeight);
|
||||
if(yPos > yPosition + height && yPos < yPosition + height + requiredHeight) {
|
||||
int clickedIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex;
|
||||
this.selectionIndex = clickedIndex;
|
||||
this.selectionIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex;
|
||||
success = true;
|
||||
fireSelectionChangeEvent();
|
||||
}
|
||||
@@ -217,10 +216,6 @@ public class GuiDropdown<T> extends GuiTextField {
|
||||
this.selectionListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeSelectionListener(SelectionListener listener) {
|
||||
this.selectionListeners.remove(listener);
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return open;
|
||||
}
|
||||
|
||||
@@ -118,11 +118,6 @@ public class GuiEntryList<T> extends GuiTextField {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearElements() {
|
||||
this.elements = new ArrayList<T>();
|
||||
selectionIndex = -1;
|
||||
}
|
||||
|
||||
public void addElement(T element) {
|
||||
this.elements.add(element);
|
||||
if(selectionIndex == -1) {
|
||||
@@ -172,8 +167,4 @@ public class GuiEntryList<T> extends GuiTextField {
|
||||
this.selectionListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeSelectionListener(SelectionListener listener) {
|
||||
this.selectionListeners.remove(listener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -185,11 +185,8 @@ public class GuiKeyframeTimeline extends GuiTimeline {
|
||||
|
||||
|
||||
//Draw Keyframe logos
|
||||
ListIterator<Keyframe> iterator = ReplayHandler.getKeyframes().listIterator();
|
||||
while(iterator.hasNext()) {
|
||||
Keyframe kf = iterator.next();
|
||||
|
||||
if(kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
|
||||
for (Keyframe kf : ReplayHandler.getKeyframes()) {
|
||||
if (kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
|
||||
drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.awt.*;
|
||||
|
||||
public class GuiLoadingListEntry implements IGuiListEntry {
|
||||
|
||||
boolean registered = false;
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private final String message = I18n.format("replaymod.gui.loading")+"...";
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class GuiNumberInput extends GuiTextField {
|
||||
|
||||
public GuiNumberInput(int id, FontRenderer fontRenderer,
|
||||
int xPos, int yPos, int width, int minimum, int maximum, int defaultValue, boolean acceptFloats) {
|
||||
this(id, fontRenderer, xPos, yPos, width, new Double(minimum), new Double(maximum), new Double(defaultValue), acceptFloats);
|
||||
this(id, fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,15 +42,12 @@ public class GuiNumberInput extends GuiTextField {
|
||||
} else {
|
||||
val = Integer.valueOf(getText());
|
||||
}
|
||||
if(minimum != null && val < minimum) {
|
||||
setText(acceptFloats ? minimum.toString() : new Integer((int)Math.round(minimum)).toString());
|
||||
return;
|
||||
}
|
||||
if(maximum != null && val > maximum) {
|
||||
setText(acceptFloats ? maximum.toString() : new Integer((int)Math.round(maximum)).toString());
|
||||
return;
|
||||
}
|
||||
|
||||
if(minimum != null && val < minimum) {
|
||||
setText(acceptFloats ? minimum.toString() : Integer.toString((int) Math.round(minimum)));
|
||||
} else if(maximum != null && val > maximum) {
|
||||
setText(acceptFloats ? maximum.toString() : Integer.toString((int) Math.round(maximum)));
|
||||
}
|
||||
} catch(NumberFormatException e) {
|
||||
setText(textBefore);
|
||||
setCursorPosition(cursorPositionBefore);
|
||||
@@ -81,12 +78,4 @@ public class GuiNumberInput extends GuiTextField {
|
||||
}
|
||||
}
|
||||
|
||||
public Double getPreciseValueNullable() {
|
||||
try {
|
||||
return Double.valueOf(getText());
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ public class GuiOnOffButton extends GuiToggleButton {
|
||||
|
||||
private static final String[] values = new String[] {I18n.format("options.on"), I18n.format("options.off")};
|
||||
|
||||
public GuiOnOffButton(int buttonId, int x, int y, String buttonText) {
|
||||
super(buttonId, x, y, buttonText, values);
|
||||
}
|
||||
|
||||
public GuiOnOffButton(int buttonId, int x, int y, int width, int height, String buttonText) {
|
||||
super(buttonId, x, y, width, height, buttonText, values);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public class GuiReplayListEntry implements IGuiListEntry {
|
||||
private ResourceLocation textureResource;
|
||||
private DynamicTexture dynTex = null;
|
||||
private File imageFile;
|
||||
private BufferedImage image = null;
|
||||
private GuiReplayListExtended parent;
|
||||
|
||||
public GuiReplayListEntry(GuiReplayListExtended parent, FileInfo fileInfo, File imageFile) {
|
||||
@@ -60,13 +59,13 @@ public class GuiReplayListEntry implements IGuiListEntry {
|
||||
registered = false;
|
||||
ResourceHelper.freeResource(textureResource);
|
||||
textureResource = null;
|
||||
image = null;
|
||||
dynTex = null;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if(!registered) {
|
||||
textureResource = new ResourceLocation("thumbs/" + fileInfo.getName() + fileInfo.getId());
|
||||
BufferedImage image;
|
||||
if(imageFile == null) {
|
||||
image = ResourceHelper.getDefaultThumbnail();
|
||||
} else {
|
||||
@@ -122,7 +121,9 @@ public class GuiReplayListEntry implements IGuiListEntry {
|
||||
|
||||
if(online) {
|
||||
Category category = Category.fromId(fileInfo.getCategory());
|
||||
|
||||
if (category == null) {
|
||||
category = Category.MISCELLANEOUS;
|
||||
}
|
||||
mc.fontRendererObj.drawStringWithShadow(ChatFormatting.ITALIC.toString()+category.toNiceString(), x + 3, y + slotHeight - mc.fontRendererObj.FONT_HEIGHT, Color.GRAY.getRGB());
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class GuiSettingsOnOffButton extends GuiOnOffButton {
|
||||
super(buttonId, x, y, width, height, toChange.getName()+": ");
|
||||
this.toChange = toChange;
|
||||
if(toChange.getValue() instanceof Boolean) {
|
||||
this.setValue((Boolean) toChange.getValue() == true ? 0 : 1);
|
||||
this.setValue((Boolean) toChange.getValue() ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class GuiSettingsOnOffButton extends GuiOnOffButton {
|
||||
super(buttonId, x, y, width, height, toChange.getName()+": ", onValue, offValue);
|
||||
this.toChange = toChange;
|
||||
if(toChange.getValue() instanceof Boolean) {
|
||||
this.setValue((Boolean) toChange.getValue() == true ? 0 : 1);
|
||||
this.setValue((Boolean) toChange.getValue() ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,6 @@ public class GuiTexturedButton extends GuiButton implements GuiElement {
|
||||
private final Runnable action;
|
||||
private final String hoverText;
|
||||
|
||||
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
|
||||
int u, int v, int textureWidth, int textureHeight, Runnable action) {
|
||||
this(buttonId, x, y, width, height, texture, u, v, textureWidth, textureHeight, action, null);
|
||||
}
|
||||
|
||||
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
|
||||
int u, int v, int textureWidth, int textureHeight, Runnable action, String hoverText) {
|
||||
super(buttonId, x, y, width, height, "");
|
||||
|
||||
@@ -212,7 +212,6 @@ public class GuiTimeline extends Gui implements GuiElement {
|
||||
|
||||
int distance;
|
||||
int smallDistance;
|
||||
int maximum = 10;
|
||||
|
||||
MarkerType(int minimum, int smallDistance) {
|
||||
this.distance = minimum;
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiLoginPrompt extends GuiScreen {
|
||||
|
||||
@@ -78,12 +79,12 @@ public class GuiLoginPrompt extends GuiScreen {
|
||||
int tw = 150+5+strwidth;
|
||||
registerButton.xPosition = (width/2) - (tw/2) + strwidth+5;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
buttonList.add(loginButton);
|
||||
buttonList.add(cancelButton);
|
||||
buttonList.add(registerButton);
|
||||
|
||||
strwidth2 = Math.max(fontRendererObj.getStringWidth(usernameLabel), fontRendererObj.getStringWidth(passwordLabel));
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@@ -126,7 +127,6 @@ public class GuiLoginPrompt extends GuiScreen {
|
||||
|
||||
private String usernameLabel = I18n.format("replaymod.gui.username");
|
||||
private String passwordLabel = I18n.format("replaymod.gui.password");
|
||||
private int strwidth2 = 100;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
|
||||
@@ -26,9 +26,6 @@ public class GuiRegister extends GuiScreen {
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
private int strwidth = 0;
|
||||
private int totalwidth = 0;
|
||||
|
||||
private String[] labels = new String[]{I18n.format("replaymod.gui.username"), I18n.format("replaymod.gui.mail"), I18n.format("replaymod.gui.password"),
|
||||
I18n.format("replaymod.gui.register.confirmpw")};
|
||||
|
||||
@@ -71,14 +68,16 @@ public class GuiRegister extends GuiScreen {
|
||||
inputFields.add(passwordInput);
|
||||
inputFields.add(passwordConfirmation);
|
||||
|
||||
strwidth = Math.max(Math.max(fontRendererObj.getStringWidth(labels[0]), fontRendererObj.getStringWidth(labels[1])),
|
||||
int strwidth = Math.max(Math.max(fontRendererObj.getStringWidth(labels[0]), fontRendererObj.getStringWidth(labels[1])),
|
||||
Math.max(fontRendererObj.getStringWidth(labels[2]), fontRendererObj.getStringWidth(labels[3])));
|
||||
|
||||
totalwidth = 145+10+strwidth;
|
||||
int totalwidth = 145 + 10 + strwidth;
|
||||
|
||||
for(GuiTextField f : inputFields)
|
||||
f.xPosition = (width/2) - (totalwidth/2) + strwidth+5;
|
||||
f.xPosition = (width/2) - (totalwidth /2) + strwidth +5;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
buttonList.add(registerButton);
|
||||
buttonList.add(cancelButton);
|
||||
|
||||
|
||||
@@ -32,16 +32,13 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
null, null, null, null);
|
||||
private static final int LOGOUT_CALLBACK_ID = 1;
|
||||
private ReplayFileList currentList;
|
||||
private Tab currentTab = Tab.RECENT_FILES;
|
||||
private GuiButton loadButton, favButton, likeButton, dislikeButton;
|
||||
private List<GuiButton> replayButtonBar, bottomBar, topBar;
|
||||
private GuiLoadingListEntry loadingListEntry;
|
||||
|
||||
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, int p_152129_2_) {
|
||||
String s1 = I18n.format("replaymod.gui.center.logoutcallback");
|
||||
GuiYesNo guiyesno = new GuiYesNo(p_152129_0_, s1, "", I18n.format("replaymod.gui.logout"),
|
||||
return new GuiYesNo(p_152129_0_, s1, "", I18n.format("replaymod.gui.logout"),
|
||||
I18n.format("replaymod.gui.cancel"), p_152129_2_);
|
||||
return guiyesno;
|
||||
}
|
||||
|
||||
private boolean initialized = false;
|
||||
@@ -110,6 +107,9 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
currentList.height = height-60;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
|
||||
int i = 0;
|
||||
for(GuiButton b : topBar) {
|
||||
int w = this.width - 30;
|
||||
@@ -355,7 +355,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
private void updateCurrentList(Pagination pagination) {
|
||||
elementSelected(-1);
|
||||
currentList = new ReplayFileList(mc, width, height, 50, height - 60, this);
|
||||
loadingListEntry = new GuiLoadingListEntry();
|
||||
GuiLoadingListEntry loadingListEntry = new GuiLoadingListEntry();
|
||||
currentList.addEntry(loadingListEntry);
|
||||
|
||||
if(pagination.getLoadedPages() < 0) {
|
||||
@@ -381,7 +381,14 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
private Thread currentListLoader;
|
||||
|
||||
private void cancelCurrentListLoader() {
|
||||
if(currentListLoader != null && currentListLoader.isAlive()) currentListLoader.stop();
|
||||
if(currentListLoader != null && currentListLoader.isAlive()) {
|
||||
currentListLoader.interrupt();
|
||||
try {
|
||||
currentListLoader.join();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showOnlineRecent() {
|
||||
@@ -389,7 +396,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
currentListLoader = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentTab = Tab.RECENT_FILES;
|
||||
updateCurrentList(new SearchPagination(recentFileSearchQuery));
|
||||
}
|
||||
}, "replaymod-list-loader");
|
||||
@@ -401,7 +407,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
currentListLoader = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentTab = Tab.BEST_FILES;
|
||||
updateCurrentList(new SearchPagination(bestFileSearchQuery));
|
||||
}
|
||||
}, "replaymod-list-loader");
|
||||
@@ -413,7 +418,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
currentListLoader = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentTab = Tab.DOWNLOADED_FILES;
|
||||
updateCurrentList(new DownloadedFilePagination());
|
||||
}
|
||||
}, "replaymod-list-loader");
|
||||
@@ -425,27 +429,10 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
currentListLoader = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentTab = Tab.FAVORITED_FILES;
|
||||
ReplayMod.favoritedFileHandler.reloadFavorites();
|
||||
updateCurrentList(new FavoritedFilePagination());
|
||||
}
|
||||
}, "replaymod-list-loader");
|
||||
currentListLoader.start();
|
||||
}
|
||||
|
||||
private enum Tab {
|
||||
RECENT_FILES("replaymod.gui.center.tab.recent"),
|
||||
BEST_FILES("replaymod.gui.center.tab.best"),
|
||||
DOWNLOADED_FILES("replaymod.gui.center.tab.downloaded"),
|
||||
FAVORITED_FILES("replaymod.gui.center.tab.favorited"),
|
||||
SEARCH("replaymod.gui.center.tab.search");
|
||||
|
||||
private String title;
|
||||
|
||||
Tab(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle() { return I18n.format(title); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,11 @@ import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -54,7 +56,8 @@ public class GuiUploadFile extends GuiScreen {
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
private int columnWidth, columnLeft, columnMiddle, columnRight;
|
||||
private int columnWidth;
|
||||
private int columnRight;
|
||||
|
||||
private GuiAdvancedTextField name, tags;
|
||||
private GuiToggleButton category;
|
||||
@@ -80,8 +83,6 @@ public class GuiUploadFile extends GuiScreen {
|
||||
|
||||
private boolean lockUploadButton = false;
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public GuiUploadFile(File file, GuiReplayViewer parent) {
|
||||
this.parent = parent;
|
||||
|
||||
@@ -109,17 +110,15 @@ public class GuiUploadFile extends GuiScreen {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(archive != null) {
|
||||
try {
|
||||
archive.close();
|
||||
} catch(IOException e) {
|
||||
}
|
||||
IOUtils.closeQuietly(archive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!correctFile) {
|
||||
Logger logger = LogManager.getLogger();
|
||||
logger.error("Invalid file provided to upload");
|
||||
mc.displayGuiScreen(parent); //TODO: Error message
|
||||
mc.displayGuiScreen(parent);
|
||||
replayFile = null;
|
||||
return;
|
||||
}
|
||||
@@ -190,8 +189,8 @@ public class GuiUploadFile extends GuiScreen {
|
||||
}
|
||||
|
||||
columnWidth = Math.min(200, (width - 60) / 3);
|
||||
columnLeft = width / 2 - columnWidth / 2 * 3 - 10;
|
||||
columnMiddle = width / 2 - columnWidth / 2;
|
||||
int columnLeft = width / 2 - columnWidth / 2 * 3 - 10;
|
||||
int columnMiddle = width / 2 - columnWidth / 2;
|
||||
columnRight = width / 2 + columnWidth / 2 + 10;
|
||||
|
||||
name.xPosition = columnLeft;
|
||||
@@ -218,6 +217,8 @@ public class GuiUploadFile extends GuiScreen {
|
||||
}
|
||||
content = new ComposedElement(elements.toArray(new GuiElement[elements.size()]));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
if(startUploadButton == null) {
|
||||
List<GuiButton> bottomBar = new ArrayList<GuiButton>();
|
||||
startUploadButton = new GuiButton(GuiConstants.UPLOAD_START_BUTTON, 0, 0, I18n.format("replaymod.gui.upload.start"));
|
||||
@@ -316,7 +317,7 @@ public class GuiUploadFile extends GuiScreen {
|
||||
|
||||
ReplayMetaData newMetaData = metaData.copy();
|
||||
newMetaData.removeServer();
|
||||
ReplayFileIO.writeReplayMetaDataToFile(newMetaData, tmpMeta);
|
||||
ReplayFileIO.write(newMetaData, tmpMeta);
|
||||
|
||||
HashMap<String, File> toAdd = new HashMap<String, File>();
|
||||
toAdd.put(ReplayFile.ENTRY_METADATA, tmpMeta);
|
||||
@@ -326,8 +327,8 @@ public class GuiUploadFile extends GuiScreen {
|
||||
|
||||
uploader.uploadFile(GuiUploadFile.this, AuthenticationHandler.getKey(), name, tags, tmp, category, desc);
|
||||
|
||||
tmpMeta.delete();
|
||||
tmp.delete();
|
||||
FileUtils.deleteQuietly(tmpMeta);
|
||||
FileUtils.deleteQuietly(tmp);
|
||||
} else {
|
||||
uploader.uploadFile(GuiUploadFile.this, AuthenticationHandler.getKey(), name, tags, replayFile, category, desc);
|
||||
}
|
||||
@@ -365,8 +366,9 @@ public class GuiUploadFile extends GuiScreen {
|
||||
Gui.drawScaledCustomSizeModalRect(columnRight, 20, 0, 0, 1280, 720, columnWidth, height, 1280, 720);
|
||||
|
||||
if (!hasThumbnail) {
|
||||
KeyBinding keyBinding = KeybindRegistry.getKeyBinding(KeybindRegistry.KEY_THUMBNAIL);
|
||||
String str = I18n.format("replaymod.gui.upload.nothumbnail",
|
||||
GameSettings.getKeyDisplayString(KeybindRegistry.getKeyBinding(KeybindRegistry.KEY_THUMBNAIL).getKeyCode()));
|
||||
keyBinding == null ? "???" : GameSettings.getKeyDisplayString(keyBinding.getKeyCode()));
|
||||
int y = 20 + height + 10;
|
||||
fontRendererObj.drawSplitString(str, columnRight, y, columnWidth, Color.RED.getRGB());
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
/**
|
||||
* Dummy interface for GUI on which this replay overlay shall not be rendered.
|
||||
*/
|
||||
public static interface NoOverlay {
|
||||
public interface NoOverlay {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class GuiConnectPart extends GuiStudioPart {
|
||||
@Override
|
||||
public void initGui() {
|
||||
if(!initialized) {
|
||||
concatList = new GuiEntryList(1, fontRendererObj, 30, yPos, 150, 0);
|
||||
concatList = new GuiEntryList<String>(1, fontRendererObj, 30, yPos, 150, 0);
|
||||
filesToConcat = new ArrayList<String>();
|
||||
String selectedName = FilenameUtils.getBaseName(GuiReplayEditor.instance.getSelectedFile().getAbsolutePath());
|
||||
filesToConcat.add(selectedName);
|
||||
@@ -82,7 +82,7 @@ public class GuiConnectPart extends GuiStudioPart {
|
||||
|
||||
concatList.setSelectionIndex(0);
|
||||
|
||||
replayDropdown = new GuiDropdown(1, fontRendererObj, 250, yPos + 5, 0, 4);
|
||||
replayDropdown = new GuiDropdown<String>(1, fontRendererObj, 250, yPos + 5, 0, 4);
|
||||
|
||||
replayDropdown.clearElements();
|
||||
replayFiles = ReplayFileIO.getAllReplayFiles();
|
||||
@@ -107,14 +107,15 @@ public class GuiConnectPart extends GuiStudioPart {
|
||||
filesToConcat.set(concatList.getSelectionIndex(), replayDropdown.getElement(selectionIndex));
|
||||
concatList.setElements(filesToConcat);
|
||||
} catch(Exception e) {
|
||||
} //Sorry, too lazy to properly avoid this Exception here
|
||||
// TODO Prevent exception
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
concatList.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void onSelectionChanged(int selectionIndex) {
|
||||
String selName = (String) concatList.getElement(selectionIndex);
|
||||
String selName = concatList.getElement(selectionIndex);
|
||||
int i = 0;
|
||||
for(Object s : replayDropdown.getAllElements()) {
|
||||
String str = (String) s;
|
||||
@@ -130,14 +131,15 @@ public class GuiConnectPart extends GuiStudioPart {
|
||||
}
|
||||
});
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
|
||||
upButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_UP_BUTTON, 195, yPos + 40, "", GuiArrowButton.Direction.UP);
|
||||
buttonList.add(upButton);
|
||||
|
||||
downButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_DOWN_BUTTON, 219, yPos + 40, "", GuiArrowButton.Direction.DOWN);
|
||||
buttonList.add(downButton);
|
||||
|
||||
int w = GuiReplayEditor.instance.width - 243 - 20 - 4;
|
||||
|
||||
removeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_REMOVE_BUTTON, 249, yPos + 40, I18n.format("replaymod.gui.remove"));
|
||||
buttonList.add(removeButton);
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ public class GuiReplayEditor extends GuiScreen {
|
||||
private static final int tabYPos = 110;
|
||||
public static GuiReplayEditor instance = null;
|
||||
private StudioTab currentTab = StudioTab.TRIM;
|
||||
private GuiDropdown replayDropdown;
|
||||
private GuiButton saveModeButton, saveButton;
|
||||
private GuiDropdown<String> replayDropdown;
|
||||
private GuiButton saveModeButton;
|
||||
private boolean overrideSave = false;
|
||||
private boolean initialized = false;
|
||||
private List<File> replayFiles = new ArrayList<File>();
|
||||
@@ -56,6 +56,8 @@ public class GuiReplayEditor extends GuiScreen {
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
List<GuiButton> tabButtons = new ArrayList<GuiButton>();
|
||||
|
||||
tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_TRIM_TAB, 0, 0, I18n.format("replaymod.gui.editor.trim.title")));
|
||||
@@ -79,7 +81,7 @@ public class GuiReplayEditor extends GuiScreen {
|
||||
int modeWidth = tabButtons.get(0).width;
|
||||
|
||||
if(!initialized) {
|
||||
replayDropdown = new GuiDropdown(1, fontRendererObj, 15 + 2 + 1 + 80, 60, this.width - 30 - 8 - 80 - modeWidth - 4, 5);
|
||||
replayDropdown = new GuiDropdown<String>(1, fontRendererObj, 15 + 2 + 1 + 80, 60, this.width - 30 - 8 - 80 - modeWidth - 4, 5);
|
||||
refreshReplayDropdown();
|
||||
} else {
|
||||
replayDropdown.width = this.width - 30 - 8 - 80 - modeWidth - 4;
|
||||
@@ -98,7 +100,7 @@ public class GuiReplayEditor extends GuiScreen {
|
||||
backButton.width = 70;
|
||||
buttonList.add(backButton);
|
||||
|
||||
saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save"));
|
||||
GuiButton saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save"));
|
||||
saveButton.width = 70;
|
||||
buttonList.add(saveButton);
|
||||
|
||||
@@ -113,8 +115,6 @@ public class GuiReplayEditor extends GuiScreen {
|
||||
return overrideSave ? I18n.format("replaymod.gui.editor.savemode.override") : I18n.format("replaymod.gui.editor.savemode.newfile");
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
if(!button.enabled) return;
|
||||
@@ -194,7 +194,7 @@ public class GuiReplayEditor extends GuiScreen {
|
||||
|
||||
private GuiStudioPart studioPart;
|
||||
|
||||
private StudioTab(GuiStudioPart part) {
|
||||
StudioTab(GuiStudioPart part) {
|
||||
this.studioPart = part;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@ 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.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiRenameReplay extends GuiScreen {
|
||||
private GuiScreen field_146585_a;
|
||||
@@ -28,9 +30,11 @@ public class GuiRenameReplay extends GuiScreen {
|
||||
|
||||
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("replaymod.gui.rename")));
|
||||
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("replaymod.gui.cancel")));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
buttonList.clear();
|
||||
buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("replaymod.gui.rename")));
|
||||
buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("replaymod.gui.cancel")));
|
||||
String s = FilenameUtils.getBaseName(file.getAbsolutePath());
|
||||
this.field_146583_f = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20);
|
||||
this.field_146583_f.setFocused(true);
|
||||
@@ -55,7 +59,7 @@ public class GuiRenameReplay extends GuiScreen {
|
||||
renamed = new File(initRenamed.getAbsolutePath() + "_" + i);
|
||||
i++;
|
||||
}
|
||||
file.renameTo(renamed);
|
||||
FileUtils.moveFile(file, renamed);
|
||||
this.mc.displayGuiScreen(this.field_146585_a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.Util;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -29,7 +31,6 @@ import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@@ -45,7 +46,10 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
||||
private boolean initialized;
|
||||
private GuiReplayListExtended replayGuiList;
|
||||
private List<Pair<Pair<File, ReplayMetaData>, File>> replayFileList = new ArrayList<Pair<Pair<File, ReplayMetaData>, File>>();
|
||||
private GuiButton loadButton, uploadButton, folderButton, renameButton, deleteButton, cancelButton, settingsButton;
|
||||
private GuiButton loadButton;
|
||||
private GuiButton uploadButton;
|
||||
private GuiButton renameButton;
|
||||
private GuiButton deleteButton;
|
||||
private boolean delete_file = false;
|
||||
|
||||
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, String file, int p_152129_2_) {
|
||||
@@ -53,8 +57,7 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
||||
String s2 = "\'" + file + "\' " + I18n.format("replaymod.gui.viewer.delete.lineb");
|
||||
String s3 = I18n.format("replaymod.gui.delete");
|
||||
String s4 = I18n.format("replaymod.gui.cancel");
|
||||
GuiYesNo guiyesno = new GuiYesNo(p_152129_0_, s1, s2, s3, s4, p_152129_2_);
|
||||
return guiyesno;
|
||||
return new GuiYesNo(p_152129_0_, s1, s2, s3, s4, p_152129_2_);
|
||||
}
|
||||
|
||||
private void reloadFiles() {
|
||||
@@ -132,13 +135,15 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
||||
}
|
||||
|
||||
private void createButtons() {
|
||||
this.buttonList.add(loadButton = new GuiButton(LOAD_BUTTON_ID, this.width / 2 - 154, this.height - 52, 73, 20, I18n.format("replaymod.gui.load")));
|
||||
this.buttonList.add(uploadButton = new GuiButton(UPLOAD_BUTTON_ID, this.width / 2 - 154 + 78, this.height - 52, 73, 20, I18n.format("replaymod.gui.upload")));
|
||||
this.buttonList.add(folderButton = new GuiButton(FOLDER_BUTTON_ID, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("replaymod.gui.viewer.replayfolder")));
|
||||
this.buttonList.add(renameButton = new GuiButton(RENAME_BUTTON_ID, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("replaymod.gui.rename")));
|
||||
this.buttonList.add(deleteButton = new GuiButton(DELETE_BUTTON_ID, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("replaymod.gui.delete")));
|
||||
this.buttonList.add(settingsButton = new GuiButton(SETTINGS_BUTTON_ID, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("replaymod.gui.settings")));
|
||||
this.buttonList.add(cancelButton = new GuiButton(CANCEL_BUTTON_ID, this.width / 2 + 4 + 78, this.height - 28, 72, 20, I18n.format("replaymod.gui.cancel")));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
buttonList.add(loadButton = new GuiButton(LOAD_BUTTON_ID, this.width / 2 - 154, this.height - 52, 73, 20, I18n.format("replaymod.gui.load")));
|
||||
buttonList.add(uploadButton = new GuiButton(UPLOAD_BUTTON_ID, this.width / 2 - 154 + 78, this.height - 52, 73, 20, I18n.format("replaymod.gui.upload")));
|
||||
buttonList.add(new GuiButton(FOLDER_BUTTON_ID, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("replaymod.gui.viewer.replayfolder")));
|
||||
buttonList.add(renameButton = new GuiButton(RENAME_BUTTON_ID, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("replaymod.gui.rename")));
|
||||
buttonList.add(deleteButton = new GuiButton(DELETE_BUTTON_ID, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("replaymod.gui.delete")));
|
||||
buttonList.add(new GuiButton(SETTINGS_BUTTON_ID, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("replaymod.gui.settings")));
|
||||
buttonList.add(new GuiButton(CANCEL_BUTTON_ID, this.width / 2 + 4 + 78, this.height - 28, 72, 20, I18n.format("replaymod.gui.cancel")));
|
||||
setButtonsEnabled(false);
|
||||
}
|
||||
|
||||
@@ -207,24 +212,24 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[]{"/usr/bin/open", s});
|
||||
return;
|
||||
} catch(IOException ioexception1) {
|
||||
} catch (IOException e) {
|
||||
LogManager.getLogger().error("Cannot open file", e);
|
||||
}
|
||||
} else if(Util.getOSType() == Util.EnumOS.WINDOWS) {
|
||||
String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[]{s});
|
||||
String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", s);
|
||||
|
||||
try {
|
||||
Runtime.getRuntime().exec(s1);
|
||||
return;
|
||||
} catch(IOException ioexception) {
|
||||
} catch(IOException e) {
|
||||
LogManager.getLogger().error("Cannot open file", e);
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
try {
|
||||
Class oclass = Class.forName("java.awt.Desktop");
|
||||
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]);
|
||||
oclass.getMethod("browse", new Class[]{URI.class}).invoke(object, new Object[]{file1.toURI()});
|
||||
Desktop.getDesktop().browse(file1.toURI());
|
||||
} catch(Throwable throwable) {
|
||||
flag = true;
|
||||
}
|
||||
@@ -241,7 +246,11 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
||||
this.delete_file = false;
|
||||
|
||||
if(result) {
|
||||
replayFileList.get(replayGuiList.selected).first().first().delete();
|
||||
try {
|
||||
FileUtils.forceDelete(replayFileList.get(replayGuiList.selected).first().first());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
replayFileList.remove(replayGuiList.selected);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user