Disallow creation of replays with negative duration

This commit is contained in:
johni0702
2015-08-13 17:56:57 +02:00
parent 0106e9beac
commit 49f7e07fad
3 changed files with 12 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ public class GuiReplayEditor extends GuiScreen {
public static GuiReplayEditor instance = null; public static GuiReplayEditor instance = null;
private StudioTab currentTab = StudioTab.TRIM; private StudioTab currentTab = StudioTab.TRIM;
private GuiDropdown<GuiEntryListStringEntry> replayDropdown; private GuiDropdown<GuiEntryListStringEntry> replayDropdown;
private GuiButton saveButton;
private GuiButton saveModeButton; private GuiButton saveModeButton;
private boolean overrideSave = false; private boolean overrideSave = false;
private boolean initialized = false; private boolean initialized = false;
@@ -105,7 +106,7 @@ public class GuiReplayEditor extends GuiScreen {
backButton.width = 70; backButton.width = 70;
buttonList.add(backButton); buttonList.add(backButton);
GuiButton saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save")); saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save"));
saveButton.width = 70; saveButton.width = 70;
buttonList.add(saveButton); buttonList.add(saveButton);
@@ -162,6 +163,7 @@ public class GuiReplayEditor extends GuiScreen {
@Override @Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void drawScreen(int mouseX, int mouseY, float partialTicks) {
saveButton.enabled = currentTab.getStudioPart().validateInputs();
drawDefaultBackground(); drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks); super.drawScreen(mouseX, mouseY, partialTicks);
currentTab.getStudioPart().drawScreen(mouseX, mouseY, partialTicks); currentTab.getStudioPart().drawScreen(mouseX, mouseY, partialTicks);

View File

@@ -52,4 +52,8 @@ public abstract class GuiStudioPart extends GuiScreen implements ProgressUpdateL
this.progress = progress; this.progress = progress;
} }
public boolean validateInputs() {
return true;
}
} }

View File

@@ -33,6 +33,11 @@ public class GuiTrimPart extends GuiStudioPart {
fontRendererObj = mc.fontRendererObj; fontRendererObj = mc.fontRendererObj;
} }
@Override
public boolean validateInputs() {
return getEndTimestamp() == 0 || getEndTimestamp() > getStartTimestamp();
}
@Override @Override
public void applyFilters(final File replayFile, final File outputFile) { public void applyFilters(final File replayFile, final File outputFile) {
this.outputFile = outputFile; this.outputFile = outputFile;