Added Video Export feature with according Options in the Options Menu
Fixed Linear Interpolation
This commit is contained in:
@@ -15,11 +15,11 @@ import net.minecraft.client.gui.GuiVideoSettings;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings.Options;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
@@ -32,8 +32,9 @@ import eu.crushedpixel.replaymod.gui.replaymanager.GuiReplayManager;
|
||||
import eu.crushedpixel.replaymod.gui.replaymanager.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||
import eu.crushedpixel.replaymod.registry.ReplayGuiRegistry;
|
||||
import eu.crushedpixel.replaymod.replay.MCTimerHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplaySender;
|
||||
import eu.crushedpixel.replaymod.video.VideoWriter;
|
||||
|
||||
public class GuiEventHandler {
|
||||
|
||||
@@ -51,6 +52,11 @@ public class GuiEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGui(GuiOpenEvent event) {
|
||||
if(VideoWriter.isRecording()) {
|
||||
event.gui = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(event.gui instanceof GuiReplayManager || event.gui instanceof GuiUploadFile)) ResourceHelper.freeAllResources();
|
||||
|
||||
if(event.gui instanceof GuiMainMenu) {
|
||||
@@ -60,8 +66,7 @@ public class GuiEventHandler {
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
Timer timer = (Timer)ReplaySender.mcTimer.get(mc);
|
||||
timer.timerSpeed = 1f;
|
||||
MCTimerHandler.setTimerSpeed(1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -46,9 +46,11 @@ import eu.crushedpixel.replaymod.holders.PositionKeyframe;
|
||||
import eu.crushedpixel.replaymod.holders.TimeKeyframe;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.registry.ReplayGuiRegistry;
|
||||
import eu.crushedpixel.replaymod.replay.MCTimerHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayProcess;
|
||||
import eu.crushedpixel.replaymod.replay.screenshot.ReplayScreenshot;
|
||||
import eu.crushedpixel.replaymod.video.ReplayScreenshot;
|
||||
import eu.crushedpixel.replaymod.video.VideoWriter;
|
||||
|
||||
public class GuiReplayOverlay extends Gui {
|
||||
|
||||
@@ -58,7 +60,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
private int sliderY = 10;
|
||||
|
||||
private int timelineX = sliderX+100+5;
|
||||
private int realTimelineX = 10 + 3*25;
|
||||
private int realTimelineX = 10 + 4*25;
|
||||
private int realTimelineY = 33+10;
|
||||
|
||||
private int ppButtonX = 10;
|
||||
@@ -67,10 +69,13 @@ public class GuiReplayOverlay extends Gui {
|
||||
private int r_ppButtonX = 10;
|
||||
private int r_ppButtonY = realTimelineY+1;
|
||||
|
||||
private int place_ButtonX = 35;
|
||||
private int exportButtonX = 35;
|
||||
private int exportButtonY = realTimelineY+1;
|
||||
|
||||
private int place_ButtonX = 60;
|
||||
private int place_ButtonY = realTimelineY+1;
|
||||
|
||||
private int time_ButtonX = 60;
|
||||
private int time_ButtonX = 85;
|
||||
private int time_ButtonY = realTimelineY+1;
|
||||
|
||||
private long lastSystemTime = System.currentTimeMillis();
|
||||
@@ -109,11 +114,12 @@ public class GuiReplayOverlay extends Gui {
|
||||
@SubscribeEvent
|
||||
public void tick(TickEvent event) {
|
||||
if(!ReplayHandler.replayActive()) return;
|
||||
if(ReplayHandler.isReplaying() && !ReplayProcess.isVideoRecording()) ReplayProcess.tickReplay();
|
||||
ReplayProcess.unblock();
|
||||
if(ReplayHandler.getCameraEntity() != null)
|
||||
ReplayHandler.getCameraEntity().updateMovement();
|
||||
onMouseMove(new MouseEvent());
|
||||
if(!ReplayHandler.isReplaying()) onMouseMove(new MouseEvent());
|
||||
FMLCommonHandler.instance().bus().post(new InputEvent.KeyInputEvent());
|
||||
if(ReplayHandler.isReplaying()) ReplayProcess.tickReplay();
|
||||
}
|
||||
|
||||
private double lastX, lastY, lastZ;
|
||||
@@ -129,7 +135,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
if(mc != null && mc.thePlayer != null)
|
||||
MinecraftTicker.runMouseKeyboardTick(mc);
|
||||
}
|
||||
if(mc.getRenderViewEntity() == mc.thePlayer) {
|
||||
if(mc.getRenderViewEntity() == mc.thePlayer || !mc.getRenderViewEntity().isEntityAlive()) {
|
||||
ReplayHandler.spectateCamera();
|
||||
ReplayHandler.getCameraEntity().movePath(new Position(lastX, lastY, lastZ, lastPitch, lastYaw));
|
||||
} else if(!ReplayHandler.isCamera()) {
|
||||
@@ -153,12 +159,22 @@ public class GuiReplayOverlay extends Gui {
|
||||
speedSlider = new GuiReplaySpeedSlider(1, sliderX, sliderY, "Speed");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderGui(RenderGameOverlayEvent event) {
|
||||
if(VideoWriter.isRecording()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderGui(RenderGameOverlayEvent.Post event) throws IllegalArgumentException, IllegalAccessException {
|
||||
if(!ReplayHandler.replayActive() || FMLClientHandler.instance().isGUIOpen(GuiSpectateSelection.class)) {
|
||||
if(!ReplayHandler.replayActive() || FMLClientHandler.instance().isGUIOpen(GuiSpectateSelection.class) || VideoWriter.isRecording()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//System.out.println(System.currentTimeMillis()+" | "+MCTimerHandler.getTicks()+" | "+MCTimerHandler.getPartialTicks());
|
||||
|
||||
if(!ReplayGuiRegistry.hidden) ReplayGuiRegistry.hide();
|
||||
|
||||
if(event.type == ElementType.PLAYER_LIST) {
|
||||
@@ -227,6 +243,8 @@ public class GuiReplayOverlay extends Gui {
|
||||
ReplayHandler.setSpeed(speedSlider.getSliderValue());
|
||||
}
|
||||
|
||||
} else if(mouseX >= exportButtonX && mouseX <= exportButtonX+20 && mouseY >= exportButtonY && exportButtonY <= exportButtonY+20) {
|
||||
ReplayHandler.startPath(true);
|
||||
}
|
||||
|
||||
if(mouseX >= timelineX+4 && mouseX <= width - 18 && mouseY >= 11 && mouseY <= 29) {
|
||||
@@ -256,6 +274,28 @@ public class GuiReplayOverlay extends Gui {
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
//TODO: Save Video Button
|
||||
hover = false;
|
||||
x = 0;
|
||||
y = 18;
|
||||
|
||||
if(FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class)) {
|
||||
if(mouseX >= exportButtonX && mouseX <= exportButtonX+20
|
||||
&& mouseY >= exportButtonY && mouseY <= exportButtonY+20) {
|
||||
hover = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(hover) {
|
||||
x = 20;
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(timelineLocation);
|
||||
|
||||
GlStateManager.resetColor();
|
||||
this.drawModalRectWithCustomSizedTexture(exportButtonX, exportButtonY, x, y, 20, 20, 64, 64);
|
||||
|
||||
//GlStateManager.resetColor();
|
||||
|
||||
//Place Keyframe Button
|
||||
hover = false;
|
||||
@@ -703,7 +743,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
if(ReplayHandler.isReplaying()) {
|
||||
ReplayHandler.interruptReplay();
|
||||
} else {
|
||||
ReplayHandler.startPath();
|
||||
ReplayHandler.startPath(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import eu.crushedpixel.replaymod.entities.CameraEntity.MoveDirection;
|
||||
import eu.crushedpixel.replaymod.gui.GuiMouseInput;
|
||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.replay.screenshot.ReplayScreenshot;
|
||||
import eu.crushedpixel.replaymod.replay.spectate.SpectateHandler;
|
||||
import eu.crushedpixel.replaymod.video.ReplayScreenshot;
|
||||
|
||||
public class KeyInputHandler {
|
||||
|
||||
@@ -25,7 +25,9 @@ public class KeyInputHandler {
|
||||
if(mc.currentScreen != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean found = false;
|
||||
|
||||
KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings;
|
||||
for(KeyBinding kb : keyBindings) {
|
||||
if(!kb.isKeyDown()) {
|
||||
@@ -36,27 +38,22 @@ public class KeyInputHandler {
|
||||
if(ReplayHandler.isCamera()) {
|
||||
if(kb.getKeyDescription().equals("key.forward")) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.FORWARD);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.back")) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.BACKWARD);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.jump")) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.UP);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.left")) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.LEFT);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.right")) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.RIGHT);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(kb.getKeyDescription().equals("key.sneak")) {
|
||||
@@ -65,35 +62,31 @@ public class KeyInputHandler {
|
||||
} else {
|
||||
ReplayHandler.spectateCamera();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.chat")) {
|
||||
mc.displayGuiScreen(new GuiMouseInput());
|
||||
continue;
|
||||
}
|
||||
|
||||
//Custom registered handlers
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_THUMBNAIL) && kb.isPressed()) {
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_THUMBNAIL) && kb.isPressed() && !found) {
|
||||
System.out.println("thumbnail key pressed");
|
||||
ReplayScreenshot.prepareScreenshot();
|
||||
GuiReplayOverlay.requestScreenshot();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_SPECTATE) && kb.isPressed()) {
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_SPECTATE) && kb.isPressed() && !found) {
|
||||
SpectateHandler.openSpectateSelection();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && kb.isPressed()) {
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && kb.isPressed() && !found) {
|
||||
ReplayMod.replaySettings.setLightingEnabled(!ReplayMod.replaySettings.isLightingEnabled());
|
||||
continue;
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ public class MinecraftTicker {
|
||||
|
||||
public static void runMouseKeyboardTick(Minecraft mc) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException {
|
||||
|
||||
if(mc.thePlayer == null) return;
|
||||
try {
|
||||
mc.mcProfiler.endStartSection("mouse");
|
||||
int i;
|
||||
@@ -435,8 +436,6 @@ public class MinecraftTicker {
|
||||
|
||||
if(mc != null)
|
||||
systemTime.set(mc, getSystemTime.invoke(mc));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user