From a38f87e3770bcbf681be5540513f4d0edd0133a8 Mon Sep 17 00:00:00 2001 From: Marius Metzger Date: Thu, 12 Mar 2015 12:56:37 +0100 Subject: [PATCH] Finished Trim Part for Replay Studio Fixed Scroll Bar for GuiSpectateSelection --- .../eu/crushedpixel/replaymod/ReplayMod.java | 4 + .../replaymod/gui/GuiConstants.java | 1 + .../replaymod/gui/GuiDropdown.java | 1 - .../replaymod/gui/GuiNumberInput.java | 26 ++++ .../replaymod/gui/GuiSpectateSelection.java | 22 +++- .../replaymod/gui/online/GuiReplayCenter.java | 2 +- .../replaymod/gui/online/GuiUploadFile.java | 11 +- .../gui/replaystudio/GuiReplayStudio.java | 115 +++++++++++++----- .../gui/replaystudio/GuiStudioPart.java | 16 ++- .../gui/replaystudio/GuiTrimPart.java | 91 +++++++++++++- .../gui/replayviewer/GuiReplayViewer.java | 2 +- .../replaymod/interpolation/LinearPoint.java | 9 +- .../replaymod/replay/ReplayProcess.java | 20 ++- .../replaymod/replay/ReplaySender.java | 3 +- src/main/resources/assets/replaymod/.DS_Store | Bin 0 -> 6148 bytes 15 files changed, 258 insertions(+), 65 deletions(-) create mode 100644 src/main/java/eu/crushedpixel/replaymod/gui/GuiNumberInput.java create mode 100644 src/main/resources/assets/replaymod/.DS_Store diff --git a/src/main/java/eu/crushedpixel/replaymod/ReplayMod.java b/src/main/java/eu/crushedpixel/replaymod/ReplayMod.java index 0548caba..1cf8b5b1 100644 --- a/src/main/java/eu/crushedpixel/replaymod/ReplayMod.java +++ b/src/main/java/eu/crushedpixel/replaymod/ReplayMod.java @@ -29,6 +29,10 @@ public class ReplayMod //TODO: Hide Titles upon hurrying //TODO: Override Enchantment Rendering for items when replaying (to adjust speed of animation) + //TODO: Show the player whether he has already uploaded a replay + + //TODO: Hinting to the b/v key feature + //XXX //Known Bugs // diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java index f1ea56c5..6249af90 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java @@ -38,4 +38,5 @@ public class GuiConstants { public static final int REPLAY_EDITOR_SAVEMODE_BUTTON = 5003; public static final int REPLAY_EDITOR_SAVE_BUTTON = 5004; + public static final int REPLAY_EDITOR_BACK_BUTTON = 5005; } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiDropdown.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiDropdown.java index c4e7a95c..1bfef9ab 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiDropdown.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiDropdown.java @@ -26,7 +26,6 @@ public class GuiDropdown extends GuiTextField { public GuiDropdown(int id, FontRenderer fontRenderer, int xPos, int yPos, int width) { super(id, fontRenderer, xPos, yPos, width, 20); - setCursorPositionZero(); } @Override diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiNumberInput.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiNumberInput.java new file mode 100644 index 00000000..f2040118 --- /dev/null +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiNumberInput.java @@ -0,0 +1,26 @@ +package eu.crushedpixel.replaymod.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiTextField; + +public class GuiNumberInput extends GuiTextField { + + private int limit; + + public GuiNumberInput(int id, FontRenderer fontRenderer, + int xPos, int yPos, int width, int limit) { + super(id, fontRenderer, xPos, yPos, width, 20); + this.limit = limit; + } + + @Override + public void writeText(String text) { + try { + Integer.valueOf(text); + if(limit > 0 && (getText()+text).length() > limit) return; + super.writeText(text); + } catch(NumberFormatException e) {} + } + +} diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiSpectateSelection.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiSpectateSelection.java index a0cbc390..c74bf388 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiSpectateSelection.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiSpectateSelection.java @@ -7,6 +7,8 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import org.lwjgl.input.Mouse; + import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; @@ -185,17 +187,25 @@ public class GuiSpectateSelection extends GuiScreen { break; } } + + int dw = Mouse.getDWheel(); + if(dw > 0) { + dw = -1; + } else if(dw < 0) { + dw = 1; + } + + upperPlayer = Math.max(Math.min(upperPlayer+dw, playerCount-fitting), 0); if(fitting < playerCount) { - float visiblePerc = (float)fitting/(float)playerCount; + float visiblePerc = ((float)fitting)/playerCount; + int barHeight = (int)(visiblePerc*(height-32-32)); - int h = this.height-32-32; - int offset = Math.round((upperPlayer/(fitting))*visiblePerc*h); - - int lower = Math.round(32+offset+(h*visiblePerc)); + float posPerc = ((float)upperPlayer)/playerCount; + int barY = (int)(posPerc*(height-32-32)); this.drawRect(k2-18, 30-2, k2-10, this.height-30-2, Color.BLACK.getRGB()); - this.drawRect(k2-16, 32-2+offset, k2-12, lower-2, Color.LIGHT_GRAY.getRGB()); + this.drawRect(k2-16, 32-2+barY, k2-12, 32-1+barY+barHeight, Color.LIGHT_GRAY.getRGB()); } else { } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiReplayCenter.java b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiReplayCenter.java index fcacd9af..32c84300 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiReplayCenter.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiReplayCenter.java @@ -95,7 +95,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback { GuiButton exitButton = new GuiButton(GuiConstants.CENTER_BACK_BUTTON, 20, 20, "Main Menu"); bottomBar.add(exitButton); - GuiButton managerButton = new GuiButton(GuiConstants.CENTER_MANAGER_BUTTON, 20, 20, "Replay Manager"); + GuiButton managerButton = new GuiButton(GuiConstants.CENTER_MANAGER_BUTTON, 20, 20, "Replay Viewer"); bottomBar.add(managerButton); GuiButton logoutButton = new GuiButton(GuiConstants.CENTER_LOGOUT_BUTTON, 20, 20, "Logout"); diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiUploadFile.java b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiUploadFile.java index 8b1bdefe..5567d566 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiUploadFile.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/online/GuiUploadFile.java @@ -35,6 +35,7 @@ import eu.crushedpixel.replaymod.api.client.ApiException; import eu.crushedpixel.replaymod.api.client.FileUploader; import eu.crushedpixel.replaymod.api.client.holders.Category; import eu.crushedpixel.replaymod.gui.GuiConstants; +import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer; import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler; import eu.crushedpixel.replaymod.recording.ConnectionEventHandler; import eu.crushedpixel.replaymod.recording.ReplayMetaData; @@ -65,7 +66,11 @@ public class GuiUploadFile extends GuiScreen { private static final Pattern p = Pattern.compile("[^a-z0-9 \\-_]", Pattern.CASE_INSENSITIVE); private static final Pattern pt = Pattern.compile("[^a-z0-9,]", Pattern.CASE_INSENSITIVE); - public GuiUploadFile(File file) { + private GuiReplayViewer parent; + + public GuiUploadFile(File file, GuiReplayViewer parent) { + this.parent = parent; + this.textureResource = new ResourceLocation("upload_thumbs/"+FilenameUtils.getBaseName(file.getAbsolutePath())); dynTex = null; @@ -111,7 +116,7 @@ public class GuiUploadFile extends GuiScreen { if(!correctFile) { System.out.println("Invalid file provided to upload"); - mc.displayGuiScreen(new GuiMainMenu()); //TODO: Error message + mc.displayGuiScreen(parent); //TODO: Error message replayFile = null; return; } @@ -236,7 +241,7 @@ public class GuiUploadFile extends GuiScreen { category = category.next(); categoryButton.displayString = "Category: "+category.toNiceString(); } else if(button.id == GuiConstants.UPLOAD_BACK_BUTTON) { - mc.displayGuiScreen(new GuiMainMenu()); + mc.displayGuiScreen(parent); } else if(button.id == GuiConstants.UPLOAD_START_BUTTON) { final String name = fileTitleInput.getText().trim(); new Thread(new Runnable() { diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiReplayStudio.java b/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiReplayStudio.java index f5858fe1..d4cdb6cb 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiReplayStudio.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiReplayStudio.java @@ -7,17 +7,33 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiScreen; import org.apache.commons.io.FilenameUtils; -import de.johni0702.replaystudio.studio.ReplayStudio; import eu.crushedpixel.replaymod.gui.GuiConstants; import eu.crushedpixel.replaymod.gui.GuiDropdown; import eu.crushedpixel.replaymod.utils.ReplayFileIO; public class GuiReplayStudio extends GuiScreen { + private enum StudioTab { + TRIM(new GuiTrimPart(110)), CONNECT(null), MODIFY(null); + + private GuiStudioPart studioPart; + + public GuiStudioPart getStudioPart() { + return studioPart; + } + + private StudioTab(GuiStudioPart part) { + this.studioPart = part; + } + } + + private StudioTab currentTab = StudioTab.TRIM; + private GuiDropdown replayDropdown; private GuiButton saveModeButton, saveButton; @@ -26,8 +42,6 @@ public class GuiReplayStudio extends GuiScreen { private boolean initialized = false; private List replayFiles = new ArrayList(); - - private GuiTrimPart trimPart = new GuiTrimPart(100); private void refreshReplayDropdown() { replayDropdown.clearElements(); @@ -60,40 +74,36 @@ public class GuiReplayStudio extends GuiScreen { i++; } + int modeWidth = tabButtons.get(0).width; + if(!initialized) { - replayDropdown = new GuiDropdown(1, fontRendererObj, 15+2+1+100, 60, this.width-30-8-100); + replayDropdown = new GuiDropdown(1, fontRendererObj, 15+2+1+80, 60, this.width-30-8-80-modeWidth-4); refreshReplayDropdown(); } else { - replayDropdown.width = this.width-30-8-100; + replayDropdown.width = this.width-30-8-80-modeWidth-4; } - - List saveButtons = new ArrayList(); if(!initialized) { - saveButtons.add(saveModeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVEMODE_BUTTON, 0, 0, getSaveModeLabel())); - saveButtons.add(saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, 0, 0, "Save Replay")); + saveModeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVEMODE_BUTTON, width-15-modeWidth-3, 60, getSaveModeLabel()); } else { - saveButtons.add(saveModeButton); - saveButtons.add(saveButton); + saveModeButton.xPosition = width-15-modeWidth-3; } + saveModeButton.width = modeWidth; + buttonList.add(saveModeButton); + + + GuiButton backButton = new GuiButton(GuiConstants.REPLAY_EDITOR_BACK_BUTTON, width-70-18, height-20-5, "Back"); + backButton.width = 70; + buttonList.add(backButton); + + saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width-70-18, height-(2*20)-5-3, "Save"); + saveButton.width = 70; + buttonList.add(saveButton); - w = this.width-30-100; - w2 = w/saveButtons.size(); - i = 0; - for(GuiButton b : saveButtons) { - int x = 15+100+(w2*i); - b.xPosition = x+2; - b.yPosition = 90; - b.width = w2-4; - - buttonList.add(b); - - i++; - } initialized = true; }; - + private String getSaveModeLabel() { return overrideSave ? "Replace Source File" : "Save to new File"; } @@ -104,25 +114,66 @@ public class GuiReplayStudio extends GuiScreen { if(button.id == GuiConstants.REPLAY_EDITOR_SAVEMODE_BUTTON) { overrideSave = !overrideSave; button.displayString = getSaveModeLabel(); + } else if(button.id == GuiConstants.REPLAY_EDITOR_BACK_BUTTON) { + mc.displayGuiScreen(new GuiMainMenu()); } } - + @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { replayDropdown.mouseClicked(mouseX, mouseY, mouseButton); + currentTab.getStudioPart().mouseClicked(mouseX, mouseY, mouseButton); super.mouseClicked(mouseX, mouseY, mouseButton); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { - this.drawDefaultBackground(); - this.drawCenteredString(this.fontRendererObj, "Replay Studio", this.width / 2, 10, 16777215); - this.drawString(fontRendererObj, "Replay File:", 30, 67, Color.WHITE.getRGB()); - this.drawString(fontRendererObj, "Save Mode:", 30, 97, Color.WHITE.getRGB()); + drawDefaultBackground(); + currentTab.getStudioPart().drawScreen(mouseX, mouseY, partialTicks); + + drawCenteredString(fontRendererObj, currentTab.getStudioPart().getTitle(), width/2, 92, Color.WHITE.getRGB()); + + List rows = new ArrayList(); + String remaining = currentTab.getStudioPart().getDescription(); + while(remaining.length() > 0) { + String[] split = remaining.split(" "); + String b = ""; + for(String sp : split) { + b += sp+" "; + if(fontRendererObj.getStringWidth(b.trim()) > width-30-70-20) { + b = b.substring(0, b.trim().length()-(sp.length())); + break; + } + } + String trimmed = b.trim(); + rows.add(trimmed); + try { + remaining = remaining.substring(trimmed.length()+1); + } catch(Exception e) {break;} + } + + int i=0; + for(String row : rows) { + drawString(fontRendererObj, row, 30, height-(15*(rows.size()-i)), Color.WHITE.getRGB()); + i++; + } + + drawCenteredString(fontRendererObj, "Replay Studio", this.width / 2, 10, 16777215); + drawString(fontRendererObj, "Replay File:", 30, 67, Color.WHITE.getRGB()); super.drawScreen(mouseX, mouseY, partialTicks); replayDropdown.drawTextBox(); - trimPart.drawScreen(mouseX, mouseY, partialTicks); - + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + currentTab.getStudioPart().keyTyped(typedChar, keyCode); + super.keyTyped(typedChar, keyCode); + } + + @Override + public void updateScreen() { + currentTab.getStudioPart().updateScreen(); + super.updateScreen(); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiStudioPart.java b/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiStudioPart.java index ec76c811..dee817b6 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiStudioPart.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiStudioPart.java @@ -1,6 +1,18 @@ package eu.crushedpixel.replaymod.gui.replaystudio; -public interface GuiStudioPart { +import net.minecraft.client.gui.GuiScreen; - public void applyFilters(); +public abstract class GuiStudioPart extends GuiScreen { + + public abstract void applyFilters(); + + public abstract String getDescription(); + + public abstract String getTitle(); + + @Override + public abstract void keyTyped(char typedChar, int keyCode); + + @Override + public abstract void mouseClicked(int mouseX, int mouseY, int mouseButton); } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiTrimPart.java b/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiTrimPart.java index 203770c4..efc0823d 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiTrimPart.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiTrimPart.java @@ -1,31 +1,112 @@ package eu.crushedpixel.replaymod.gui.replaystudio; import java.awt.Color; +import java.io.IOException; +import eu.crushedpixel.replaymod.gui.GuiNumberInput; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -public class GuiTrimPart extends GuiScreen implements GuiStudioPart{ +public class GuiTrimPart extends GuiStudioPart { private int yPos = 0; + + private Minecraft mc = Minecraft.getMinecraft(); + + private static final String DESCRIPTION = "Removes the beginning and end of a Replay File and only keeps the Replay between the given Timestamps"; + private static final String TITLE = "Trim Replay"; + private boolean initialized = false; + + private GuiNumberInput startMinInput, startSecInput, startMsInput; + private GuiNumberInput endMinInput, endSecInput, endMsInput; + public GuiTrimPart(int yPos) { this.yPos = yPos; + fontRendererObj = mc.fontRendererObj; + initGui(); } - + @Override public void applyFilters() { // TODO Auto-generated method stub } @Override - public void initGui() { - super.initGui(); + public String getDescription() { + return DESCRIPTION; } + @Override + public String getTitle() { + return TITLE; + } + + @Override + public void initGui() { + if(!initialized) { + startMinInput = new GuiNumberInput(1, fontRendererObj, 70, yPos, 30, 3); + startSecInput = new GuiNumberInput(1, fontRendererObj, 120, yPos, 25, 2); + startMsInput = new GuiNumberInput(1, fontRendererObj, 165, yPos, 30, 3); + + endMinInput = new GuiNumberInput(1, fontRendererObj, 70, yPos+30, 30, 3); + endSecInput = new GuiNumberInput(1, fontRendererObj, 120, yPos+30, 25, 2); + endMsInput = new GuiNumberInput(1, fontRendererObj, 165, yPos+30, 30, 3); + } + + initialized = true; + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseButton) { + startMinInput.mouseClicked(mouseX, mouseY, mouseButton); + startSecInput.mouseClicked(mouseX, mouseY, mouseButton); + startMsInput.mouseClicked(mouseX, mouseY, mouseButton); + endMinInput.mouseClicked(mouseX, mouseY, mouseButton); + endSecInput.mouseClicked(mouseX, mouseY, mouseButton); + endMsInput.mouseClicked(mouseX, mouseY, mouseButton); + } + @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { - drawString(fontRendererObj, "Start", 30, 10+yPos, Color.WHITE.getRGB()); + drawString(mc.fontRendererObj, "Start:", 30, yPos+7, Color.WHITE.getRGB()); + drawString(mc.fontRendererObj, "End:", 30, yPos+7+30, Color.WHITE.getRGB()); + drawString(mc.fontRendererObj, "m", 105, yPos+7, Color.WHITE.getRGB()); + drawString(mc.fontRendererObj, "m", 105, yPos+7+30, Color.WHITE.getRGB()); + drawString(mc.fontRendererObj, "s", 150, yPos+7, Color.WHITE.getRGB()); + drawString(mc.fontRendererObj, "s", 150, yPos+7+30, Color.WHITE.getRGB()); + drawString(mc.fontRendererObj, "ms", 200, yPos+7, Color.WHITE.getRGB()); + drawString(mc.fontRendererObj, "ms", 200, yPos+7+30, Color.WHITE.getRGB()); + + startMinInput.drawTextBox(); + startSecInput.drawTextBox(); + startMsInput.drawTextBox(); + endMinInput.drawTextBox(); + endSecInput.drawTextBox(); + endMsInput.drawTextBox(); + super.drawScreen(mouseX, mouseY, partialTicks); } + + @Override + public void updateScreen() { + if(initialized) { + startMinInput.updateCursorCounter(); + startSecInput.updateCursorCounter(); + startMsInput.updateCursorCounter(); + endMinInput.updateCursorCounter(); + endSecInput.updateCursorCounter(); + endMsInput.updateCursorCounter(); + } + } + @Override + public void keyTyped(char typedChar, int keyCode) { + startMinInput.textboxKeyTyped(typedChar, keyCode); + startSecInput.textboxKeyTyped(typedChar, keyCode); + startMsInput.textboxKeyTyped(typedChar, keyCode); + endMinInput.textboxKeyTyped(typedChar, keyCode); + endSecInput.textboxKeyTyped(typedChar, keyCode); + endMsInput.textboxKeyTyped(typedChar, keyCode); + } } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiReplayViewer.java b/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiReplayViewer.java index cdd91504..b6b5762c 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiReplayViewer.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replayviewer/GuiReplayViewer.java @@ -214,7 +214,7 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback { } else if(button.id == UPLOAD_BUTTON_ID) { File file = replayFileList.get(replayGuiList.selected).first().first(); - this.mc.displayGuiScreen(new GuiUploadFile(file)); + this.mc.displayGuiScreen(new GuiUploadFile(file, this)); } else if(button.id == FOLDER_BUTTON_ID) { File file1 = new File("./replay_recordings/"); diff --git a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java index c41b878e..c77f53cf 100644 --- a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java +++ b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java @@ -11,12 +11,7 @@ public class LinearPoint extends LinearInterpolation { if(pair == null) return null; float perc = pair.first(); - //float position = positionIn * (points.size()-1); - //int cubicNum = (int)Math.min(points.size()-1, position); - //float perc = (position - cubicNum); - - //System.out.println(cubicNum+" | "+perc+" | "+positionIn); - + Position first = pair.second().first(); Position second = pair.second().second(); @@ -28,7 +23,7 @@ public class LinearPoint extends LinearInterpolation { float yaw = (float)getInterpolatedValue(first.getYaw(), second.getYaw(), perc); Position inter = new Position(x, y, z, pitch, yaw); - //System.out.println(position+" | "+cubicNum+" | "+perc+" | "+first+" | "+second+" | "+inter); + return inter; } } diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java index f731b73a..9232a6cb 100644 --- a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java +++ b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java @@ -48,6 +48,7 @@ public class ReplayProcess { isVideoRecording = record; lastPosition = null; motionSpline = null; + motionLinear = null; timeLinear = null; calculated = false; requestFinish = false; @@ -239,14 +240,21 @@ public class ReplayProcess { } } - int currentDiff = nextPosStamp - lastPosStamp; - int current = curRealReplayTime - lastPosStamp; + int currentPosDiff = nextPosStamp - lastPosStamp; + int currentPos = curRealReplayTime - lastPosStamp; - float currentStepPerc = (float)current/(float)currentDiff; //The percentage of the travelled path between the current positions - if(Float.isInfinite(currentStepPerc)) currentStepPerc = 0; + float currentPosStepPerc = (float)currentPos/(float)currentPosDiff; //The percentage of the travelled path between the current positions + if(Float.isInfinite(currentPosStepPerc)) currentPosStepPerc = 0; + + int currentTimeDiff = nextTimeStamp - lastTimeStamp; + int currentTime = curRealReplayTime - lastTimeStamp; + + float currentTimeStepPerc = (float)currentTime/(float)currentTimeDiff; //The percentage of the travelled path between the current timestamps + if(Float.isInfinite(currentTimeStepPerc)) currentTimeStepPerc = 0; - float splinePos = ((float)ReplayHandler.getKeyframeIndex(lastPos) + currentStepPerc)/(float)(ReplayHandler.getPosKeyframeCount()-1); - float timePos = ((float)ReplayHandler.getKeyframeIndex(lastTime) + currentStepPerc)/(float)(ReplayHandler.getTimeKeyframeCount()-1); + float splinePos = ((float)ReplayHandler.getKeyframeIndex(lastPos) + currentPosStepPerc)/(float)(ReplayHandler.getPosKeyframeCount()-1); + + float timePos = ((float)ReplayHandler.getKeyframeIndex(lastTime) + currentTimeStepPerc)/(float)(ReplayHandler.getTimeKeyframeCount()-1); Position pos = null; if(!linear) { diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/ReplaySender.java b/src/main/java/eu/crushedpixel/replaymod/replay/ReplaySender.java index 3fe794db..d0548aa5 100644 --- a/src/main/java/eu/crushedpixel/replaymod/replay/ReplaySender.java +++ b/src/main/java/eu/crushedpixel/replaymod/replay/ReplaySender.java @@ -396,7 +396,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter { try { Packet p = ReplayFileIO.deserializePacket(ba); - if(hurryToTimestamp && !ReplayHandler.isInPath()) { //If hurrying, ignore some packets + //If hurrying, ignore some packets, unless during Replay Path and *not* in initial hurry + if(hurryToTimestamp && (!ReplayHandler.isInPath() || (desiredTimeStamp-currentTimeStamp > 1000))) { if(p instanceof S45PacketTitle || p instanceof S29PacketSoundEffect || p instanceof S2APacketParticles) return; diff --git a/src/main/resources/assets/replaymod/.DS_Store b/src/main/resources/assets/replaymod/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0