Log when replays are opened (closes #565)

This commit is contained in:
Jonas Herzig
2022-03-02 18:10:52 +01:00
parent b8cf7e6df4
commit d178c0980e
3 changed files with 14 additions and 1 deletions

View File

@@ -56,11 +56,16 @@ public class RestoreReplayGui extends AbstractGuiScreen<RestoreReplayGui> {
new GuiLabel().setI18nText("replaymod.gui.restorereplay1"), new GuiLabel().setI18nText("replaymod.gui.restorereplay1"),
new GuiLabel().setI18nText("replaymod.gui.restorereplay2", Files.getNameWithoutExtension(file.getName())), new GuiLabel().setI18nText("replaymod.gui.restorereplay2", Files.getNameWithoutExtension(file.getName())),
new GuiLabel().setI18nText("replaymod.gui.restorereplay3")); new GuiLabel().setI18nText("replaymod.gui.restorereplay3"));
LOGGER.info("Found partially saved replay, offering recovery: " + file);
yesButton.onClick(() -> { yesButton.onClick(() -> {
LOGGER.info("Attempting recovery: " + file);
recoverInBackground(); recoverInBackground();
parent.display(); parent.display();
}); });
noButton.onClick(() -> { noButton.onClick(() -> {
LOGGER.info("Recovery rejected, marking for deletion: " + file);
try { try {
File tmp = new File(file.getParentFile(), file.getName() + ".tmp"); File tmp = new File(file.getParentFile(), file.getName() + ".tmp");
File deleted = new File(file.getParentFile(), file.getName() + ".del"); File deleted = new File(file.getParentFile(), file.getName() + ".del");

View File

@@ -21,6 +21,8 @@ import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
import de.johni0702.minecraft.gui.utils.lwjgl.Color; import de.johni0702.minecraft.gui.utils.lwjgl.Color;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension; import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
import net.minecraft.util.crash.CrashReport; import net.minecraft.util.crash.CrashReport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
@@ -31,6 +33,8 @@ import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class GuiEditReplay extends AbstractGuiPopup<GuiEditReplay> { public class GuiEditReplay extends AbstractGuiPopup<GuiEditReplay> {
private static final Logger LOGGER = LogManager.getLogger();
private final Path inputPath; private final Path inputPath;
private final EditTimeline timeline; private final EditTimeline timeline;
@@ -60,6 +64,8 @@ public class GuiEditReplay extends AbstractGuiPopup<GuiEditReplay> {
super(container); super(container);
this.inputPath = inputPath; this.inputPath = inputPath;
LOGGER.info("Opening replay in editor: " + inputPath);
try (ReplayFile replayFile = ReplayMod.instance.files.open(inputPath)) { try (ReplayFile replayFile = ReplayMod.instance.files.open(inputPath)) {
markers = replayFile.getMarkers().or(HashSet::new); markers = replayFile.getMarkers().or(HashSet::new);
timeline = new EditTimeline(new HashSet<>(markers), markers -> this.markers = markers); timeline = new EditTimeline(new HashSet<>(markers), markers -> this.markers = markers);

View File

@@ -95,8 +95,10 @@ public class GuiReplayViewer extends GuiScreen {
List<GuiReplayEntry> selected = list.getSelected(); List<GuiReplayEntry> selected = list.getSelected();
if (selected.size() == 1) { if (selected.size() == 1) {
File file = selected.get(0).file;
LOGGER.info("Opening replay in viewer: " + file);
try { try {
mod.startReplay(selected.get(0).file); mod.startReplay(file);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }