Add compatibility checking to ReplayViewer and ReplayCenter (fixes #7)
This commit is contained in:
Submodule ReplayStudio updated: f98b781f30...809832efa0
@@ -20,6 +20,7 @@ import com.replaymod.online.api.replay.pagination.FavoritedFilePagination;
|
||||
import com.replaymod.online.api.replay.pagination.Pagination;
|
||||
import com.replaymod.online.api.replay.pagination.SearchPagination;
|
||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiContainer;
|
||||
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||
@@ -115,6 +116,9 @@ public class GuiReplayCenter extends GuiScreen {
|
||||
boolean disliked = dislikedReplays.contains(replayId);
|
||||
|
||||
loadButton.setI18nLabel(selected.downloaded ? "replaymod.gui.load" : "replaymod.gui.download");
|
||||
if (selected.incompatible) {
|
||||
loadButton.setDisabled();
|
||||
}
|
||||
|
||||
favoriteButton.setI18nLabel("replaymod.gui.center." + (favorited ? "unfavorite" : "favorite"));
|
||||
// Only allow button usage for either unfavorite or favorite after they've actually downloaded it
|
||||
@@ -339,6 +343,7 @@ public class GuiReplayCenter extends GuiScreen {
|
||||
public final GuiLabel author = new GuiLabel();
|
||||
public final GuiLabel date = new GuiLabel().setColor(Colors.LIGHT_GRAY);
|
||||
public final GuiLabel server = new GuiLabel().setColor(Colors.LIGHT_GRAY);
|
||||
public final GuiLabel version = new GuiLabel().setColor(Colors.RED);
|
||||
public final GuiLabel category = new GuiLabel().setColor(Colors.GREY);
|
||||
public final GuiPanel stats = new GuiPanel().setLayout(new HorizontalLayout().setSpacing(3));
|
||||
public final GuiLabel favorites = new GuiLabel(stats).setColor(Colors.ORANGE);
|
||||
@@ -353,9 +358,10 @@ public class GuiReplayCenter extends GuiScreen {
|
||||
pos(category, 0, y(server) + height(server) + 3);
|
||||
|
||||
pos(date, width - width(date), y(author));
|
||||
pos(version, width - width(version), y(server));
|
||||
pos(stats, width - width(stats), y(category));
|
||||
}
|
||||
}).addElements(null, name, author, date, server, category, stats);
|
||||
}).addElements(null, name, author, date, server, version, category, stats);
|
||||
public final GuiImage thumbnail;
|
||||
public final GuiLabel duration = new GuiLabel();
|
||||
public final GuiPanel durationPanel = new GuiPanel().setBackgroundColor(Colors.HALF_TRANSPARENT)
|
||||
@@ -389,6 +395,7 @@ public class GuiReplayCenter extends GuiScreen {
|
||||
private final long dateMillis;
|
||||
private final int sortId;
|
||||
private final boolean downloaded;
|
||||
private final boolean incompatible;
|
||||
|
||||
public GuiReplayEntry(FileInfo fileInfo, BufferedImage thumbImage, int sortId, boolean downloaded) {
|
||||
this.fileInfo = fileInfo;
|
||||
@@ -404,6 +411,10 @@ public class GuiReplayCenter extends GuiScreen {
|
||||
} else {
|
||||
server.setText(metaData.getServerName());
|
||||
}
|
||||
incompatible = !new ReplayStudio().isCompatible(fileInfo.getMetadata().getFileFormatVersion());
|
||||
if (incompatible) {
|
||||
version.setText("Minecraft " + fileInfo.getMetadata().getMcVersion());
|
||||
}
|
||||
dateMillis = metaData.getDate();
|
||||
date.setText(new SimpleDateFormat().format(new Date(dateMillis)));
|
||||
if (thumbImage == null) {
|
||||
|
||||
@@ -6,7 +6,12 @@ import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import com.replaymod.core.gui.GuiReplaySettings;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiContainer;
|
||||
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||
@@ -20,11 +25,6 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.Util;
|
||||
@@ -54,6 +54,9 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
@Override
|
||||
public void run() {
|
||||
replayButtonPanel.forEach(IGuiButton.class).setEnabled(list.getSelected() != null);
|
||||
if (list.getSelected() != null && list.getSelected().incompatible) {
|
||||
loadButton.setDisabled();
|
||||
}
|
||||
}
|
||||
}).onLoad(new Consumer<Consumer<Supplier<GuiReplayEntry>>> () {
|
||||
@Override
|
||||
@@ -270,6 +273,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
public final GuiLabel date = new GuiLabel().setColor(Colors.LIGHT_GRAY);
|
||||
public final GuiPanel infoPanel = new GuiPanel(this).setLayout(new VerticalLayout().setSpacing(2))
|
||||
.addElements(null, name, server, date);
|
||||
public final GuiLabel version = new GuiLabel(this).setColor(Colors.RED);
|
||||
public final GuiImage thumbnail;
|
||||
public final GuiLabel duration = new GuiLabel();
|
||||
public final GuiPanel durationPanel = new GuiPanel().setBackgroundColor(Colors.HALF_TRANSPARENT)
|
||||
@@ -287,6 +291,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
});
|
||||
|
||||
private final long dateMillis;
|
||||
private final boolean incompatible;
|
||||
|
||||
public GuiReplayEntry(File file, ReplayMetaData metaData, BufferedImage thumbImage) {
|
||||
this.file = file;
|
||||
@@ -297,6 +302,10 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
} else {
|
||||
server.setText(metaData.getServerName());
|
||||
}
|
||||
incompatible = !new ReplayStudio().isCompatible(metaData.getFileFormatVersion());
|
||||
if (incompatible) {
|
||||
version.setText("Minecraft " + metaData.getMcVersion());
|
||||
}
|
||||
dateMillis = metaData.getDate();
|
||||
date.setText(new SimpleDateFormat().format(new Date(dateMillis)));
|
||||
if (thumbImage == null) {
|
||||
@@ -316,6 +325,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
y(durationPanel, height(thumbnail) - height(durationPanel));
|
||||
|
||||
pos(infoPanel, width(thumbnail) + 5, 0);
|
||||
pos(version, width - width(version), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user