Record into separate folder so replays only show once fully saved
This commit is contained in:
@@ -109,13 +109,7 @@ public class GuiSavingReplay {
|
||||
.addElements(null, textField, clearButton);
|
||||
panel.addElements(new VerticalLayout.Data(0.5), row);
|
||||
|
||||
apply.add(() -> {
|
||||
String newName = textField.getText();
|
||||
if (newName.equals(originalName)) {
|
||||
return;
|
||||
}
|
||||
applyOutput(path, newName);
|
||||
});
|
||||
apply.add(() -> applyOutput(path, textField.getText()));
|
||||
|
||||
return textField;
|
||||
}
|
||||
@@ -151,12 +145,12 @@ public class GuiSavingReplay {
|
||||
return;
|
||||
}
|
||||
|
||||
Path newPath = path.resolveSibling(Utils.replayNameToFileName(newName));
|
||||
if (Files.exists(newPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Path replaysFolder = core.getReplayFolder();
|
||||
Path newPath = replaysFolder.resolve(Utils.replayNameToFileName(newName));
|
||||
for (int i = 1; Files.exists(newPath); i++) {
|
||||
newPath = replaysFolder.resolve(Utils.replayNameToFileName(newName + " (" + i + ")"));
|
||||
}
|
||||
Files.move(path, newPath);
|
||||
} catch (IOException e) {
|
||||
logger.error("Renaming replay file:", e);
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.minecraft.world.World;
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
@@ -121,11 +121,9 @@ public class ConnectionEventHandler {
|
||||
autoStart = true;
|
||||
}
|
||||
|
||||
File folder = core.getReplayFolder();
|
||||
|
||||
String name = sdf.format(Calendar.getInstance().getTime());
|
||||
File currentFile = new File(folder, Utils.replayNameToFileName(name));
|
||||
ReplayFile replayFile = new ZipReplayFile(new ReplayStudio(), currentFile);
|
||||
Path outputPath = core.getRecordingFolder().resolve(Utils.replayNameToFileName(name));
|
||||
ReplayFile replayFile = new ZipReplayFile(new ReplayStudio(), outputPath.toFile());
|
||||
|
||||
replayFile.writeModInfo(ModCompat.getInstalledNetworkMods());
|
||||
|
||||
@@ -135,7 +133,7 @@ public class ConnectionEventHandler {
|
||||
metaData.setGenerator("ReplayMod v" + ReplayMod.instance.getVersion());
|
||||
metaData.setDate(System.currentTimeMillis());
|
||||
metaData.setMcVersion(ReplayMod.getMinecraftVersion());
|
||||
packetListener = new PacketListener(core, currentFile.toPath(), replayFile, metaData);
|
||||
packetListener = new PacketListener(core, outputPath, replayFile, metaData);
|
||||
Channel channel = ((NetworkManagerAccessor) networkManager).getChannel();
|
||||
channel.pipeline().addBefore(packetHandlerKey, "replay_recorder", packetListener);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user