Pushed missing files
Started adding Replay Editor using johni0702's excellent ReplayStudio Library Added fully functional GuiDropdown GUI Element (useable in other projects as well)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package eu.crushedpixel.replaymod.events;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,15 +15,11 @@ import net.minecraft.client.gui.GuiOptions;
|
||||
import net.minecraft.client.gui.GuiVideoSettings;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings.Options;
|
||||
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.FMLCommonHandler;
|
||||
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;
|
||||
@@ -31,12 +28,15 @@ import eu.crushedpixel.replaymod.gui.GuiReplaySettings;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiLoginPrompt;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiReplayCenter;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
|
||||
import eu.crushedpixel.replaymod.gui.replaymanager.GuiReplayManager;
|
||||
import eu.crushedpixel.replaymod.gui.replaymanager.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||
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.studio.GuiReplayStudio;
|
||||
import eu.crushedpixel.replaymod.studio.VersionValidator;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import eu.crushedpixel.replaymod.utils.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.video.VideoWriter;
|
||||
|
||||
public class GuiEventHandler {
|
||||
@@ -60,7 +60,7 @@ public class GuiEventHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(event.gui instanceof GuiReplayManager || event.gui instanceof GuiUploadFile)) ResourceHelper.freeAllResources();
|
||||
if(!(event.gui instanceof GuiReplayViewer || event.gui instanceof GuiUploadFile)) ResourceHelper.freeAllResources();
|
||||
|
||||
if(event.gui instanceof GuiMainMenu) {
|
||||
if(ReplayMod.firstMainMenu) {
|
||||
@@ -106,9 +106,18 @@ public class GuiEventHandler {
|
||||
} else {
|
||||
e.gui.drawString(mc.fontRendererObj, "LOGGED OUT", 5, 15, DARK_RED.getRGB());
|
||||
}
|
||||
|
||||
if(!VersionValidator.isValid) {
|
||||
if(editorButton.isMouseOver()) {
|
||||
Point mouse = MouseUtils.getMousePos();
|
||||
e.gui.drawCenteredString(mc.fontRendererObj, "Java 1.7 or newer required", (int)mouse.getX(), (int)mouse.getY()+4, Color.RED.getRGB());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GuiButton editorButton;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onInit(InitGuiEvent event) {
|
||||
if(event.gui instanceof GuiIngameMenu && ReplayHandler.isInReplay()) {
|
||||
@@ -124,23 +133,30 @@ public class GuiEventHandler {
|
||||
}
|
||||
}
|
||||
} else if(event.gui instanceof GuiMainMenu) {
|
||||
int i1 = event.gui.height / 4 + 48;
|
||||
int i1 = event.gui.height / 4 + 24 + 10;
|
||||
|
||||
for(GuiButton b : (List<GuiButton>)event.buttonList) {
|
||||
if(b.id != 0 && b.id != 4 && b.id != 5) {
|
||||
b.yPosition = b.yPosition - 24;
|
||||
b.yPosition = b.yPosition - 2*24 + 10;
|
||||
}
|
||||
}
|
||||
|
||||
GuiButton rm = new GuiButton(GuiConstants.REPLAY_MANAGER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 2*24, I18n.format("Replay Manager", new Object[0]));
|
||||
GuiButton rm = new GuiButton(GuiConstants.REPLAY_MANAGER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 2*24, "Replay Viewer");
|
||||
rm.width = rm.width/2 - 2;
|
||||
//rm.enabled = AuthenticationHandler.isAuthenticated();
|
||||
event.buttonList.add(rm);
|
||||
|
||||
GuiButton rc = new GuiButton(GuiConstants.REPLAY_CENTER_BUTTON_ID, event.gui.width / 2 + 2, i1 + 2*24, I18n.format("Replay Center", new Object[0]));
|
||||
rc.width = rc.width/2 - 2;
|
||||
GuiButton re = new GuiButton(GuiConstants.REPLAY_EDITOR_BUTTON_ID, event.gui.width / 2 + 2, i1 + 2*24, "Replay Editor");
|
||||
re.width = re.width/2 - 2;
|
||||
re.enabled = VersionValidator.isValid;
|
||||
event.buttonList.add(re);
|
||||
|
||||
editorButton = re;
|
||||
|
||||
GuiButton rc = new GuiButton(GuiConstants.REPLAY_CENTER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 3*24, "Replay Center");
|
||||
rc.enabled = true;
|
||||
event.buttonList.add(rc);
|
||||
|
||||
} else if(event.gui instanceof GuiOptions) {
|
||||
event.buttonList.add(new GuiButton(GuiConstants.REPLAY_OPTIONS_BUTTON_ID,
|
||||
event.gui.width / 2 - 155, event.gui.height / 6 + 48 - 6 - 24, 310, 20, "Replay Mod Settings..."));
|
||||
@@ -152,13 +168,15 @@ public class GuiEventHandler {
|
||||
if(!event.button.enabled) return;
|
||||
if(event.gui instanceof GuiMainMenu) {
|
||||
if(event.button.id == GuiConstants.REPLAY_MANAGER_BUTTON_ID) {
|
||||
mc.displayGuiScreen(new GuiReplayManager());
|
||||
mc.displayGuiScreen(new GuiReplayViewer());
|
||||
} else if(event.button.id == GuiConstants.REPLAY_CENTER_BUTTON_ID) {
|
||||
if(AuthenticationHandler.isAuthenticated()) {
|
||||
mc.displayGuiScreen(new GuiReplayCenter());
|
||||
} else {
|
||||
mc.displayGuiScreen(new GuiLoginPrompt(event.gui, new GuiReplayCenter()));
|
||||
}
|
||||
} else if(event.button.id == GuiConstants.REPLAY_EDITOR_BUTTON_ID) {
|
||||
mc.displayGuiScreen(new GuiReplayStudio());
|
||||
}
|
||||
} else if(event.gui instanceof GuiOptions && event.button.id == GuiConstants.REPLAY_OPTIONS_BUTTON_ID) {
|
||||
mc.displayGuiScreen(new GuiReplaySettings(event.gui));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package eu.crushedpixel.replaymod.events;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -11,12 +12,9 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
@@ -24,20 +22,15 @@ import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.entities.CameraEntity;
|
||||
import eu.crushedpixel.replaymod.entities.CameraEntity.MoveDirection;
|
||||
import eu.crushedpixel.replaymod.gui.GuiMouseInput;
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplaySpeedSlider;
|
||||
import eu.crushedpixel.replaymod.gui.GuiSpectateSelection;
|
||||
@@ -47,9 +40,9 @@ 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.utils.MouseUtils;
|
||||
import eu.crushedpixel.replaymod.video.ReplayScreenshot;
|
||||
import eu.crushedpixel.replaymod.video.VideoWriter;
|
||||
|
||||
@@ -217,13 +210,14 @@ public class GuiReplayOverlay extends Gui {
|
||||
return;
|
||||
}
|
||||
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
final int width = sr.getScaledWidth();
|
||||
final int height = sr.getScaledHeight();
|
||||
|
||||
final int mouseX = (Mouse.getX() * width / mc.displayWidth);
|
||||
final int mouseY = (height - Mouse.getY() * height / mc.displayHeight);
|
||||
Point mousePoint = MouseUtils.getMousePos();
|
||||
final int mouseX = (int) mousePoint.getX();
|
||||
final int mouseY = (int) mousePoint.getY();
|
||||
|
||||
Point scaled = MouseUtils.getScaledDimensions();
|
||||
final int width = (int)scaled.getX();
|
||||
final int height = (int)scaled.getY();
|
||||
|
||||
//Draw Timeline
|
||||
drawTimeline(timelineX, width - 14, 9);
|
||||
drawRealTimeline(realTimelineX, width - 14 - 11, realTimelineY, mouseX, mouseY);
|
||||
|
||||
@@ -24,11 +24,15 @@ public class GuiConstants {
|
||||
public static final int REPLAY_OPTIONS_BUTTON_ID = 8000;
|
||||
|
||||
public static final int REPLAY_MANAGER_BUTTON_ID = 9001;
|
||||
|
||||
public static final int REPLAY_CENTER_BUTTON_ID = 1000;
|
||||
public static final int REPLAY_CENTER_LOGIN_TEXT_ID = 1001;
|
||||
public static final int REPLAY_CENTER_PASSWORD_TEXT_ID = 1002;
|
||||
public static final int REPLAY_EDITOR_BUTTON_ID = 9002;
|
||||
public static final int REPLAY_CENTER_BUTTON_ID = 9003;
|
||||
public static final int REPLAY_CENTER_LOGIN_TEXT_ID = 9004;
|
||||
public static final int REPLAY_CENTER_PASSWORD_TEXT_ID = 9005;
|
||||
|
||||
public static final int LOGIN_OKAY_BUTTON = 1100;
|
||||
public static final int LOGIN_CANCEL_BUTTON = 1101;
|
||||
|
||||
public static final int REPLAY_EDITOR_TRIM_TAB = 5000;
|
||||
public static final int REPLAY_EDITOR_CONNECT_TAB = 5001;
|
||||
public static final int REPLAY_EDITOR_MODIFY_TAB = 5002;
|
||||
}
|
||||
|
||||
156
src/main/java/eu/crushedpixel/replaymod/gui/GuiDropdown.java
Normal file
156
src/main/java/eu/crushedpixel/replaymod/gui/GuiDropdown.java
Normal file
@@ -0,0 +1,156 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
public class GuiDropdown extends GuiTextField {
|
||||
|
||||
private int selectionIndex = 0;
|
||||
private boolean open = false;
|
||||
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private final int visibleDropout = 5;
|
||||
private final int dropoutElementHeight = 14;
|
||||
private final int maxDropoutHeight = dropoutElementHeight*visibleDropout;
|
||||
|
||||
private int upperIndex = 0;
|
||||
|
||||
public GuiDropdown(int id, FontRenderer fontRenderer,
|
||||
int xPos, int yPos, int width) {
|
||||
super(id, fontRenderer, xPos, yPos, width, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox() {
|
||||
|
||||
if(elements.size() > selectionIndex) {
|
||||
setText(elements.get(selectionIndex).toString());
|
||||
} else {
|
||||
setText("");
|
||||
}
|
||||
super.drawTextBox();
|
||||
|
||||
//Draw the right part of the Dropdown
|
||||
drawRect(xPosition+width-height, yPosition, xPosition+width, yPosition+height, -16777216);
|
||||
drawRect(xPosition+width-height, yPosition, this.xPosition+width-height+1, yPosition+height, -6250336);
|
||||
|
||||
//heroically draw the triangle line by line instead of using a texture
|
||||
for(int i=0; i<=Math.ceil(height/2)-4; i++) {
|
||||
drawHorizontalLine(xPosition+width-height+i+4, xPosition+width-i-4, yPosition+(height/4)+i+2, -6250336);
|
||||
}
|
||||
|
||||
if(open) {
|
||||
//draw the dropout part when opened
|
||||
|
||||
boolean drawScrollBar = false;
|
||||
|
||||
int requiredHeight = elements.size()*dropoutElementHeight;
|
||||
if(requiredHeight > maxDropoutHeight) {
|
||||
requiredHeight = maxDropoutHeight;
|
||||
drawScrollBar = true;
|
||||
}
|
||||
|
||||
//The light outline
|
||||
drawRect(xPosition-1, yPosition+height, xPosition+width+1, yPosition+height+requiredHeight+1, -6250336);
|
||||
|
||||
//The dark inside
|
||||
drawRect(xPosition, yPosition+height+1, xPosition+width, yPosition+height+requiredHeight, -16777216);
|
||||
|
||||
//The elements
|
||||
int y = 0;
|
||||
int i = 0;
|
||||
for(Object obj : elements) {
|
||||
if(i<upperIndex) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
drawHorizontalLine(xPosition, xPosition+width, yPosition+height+y, -6250336);
|
||||
drawString(mc.fontRendererObj, obj.toString(), xPosition+4, yPosition+height+y+4, Color.WHITE.getRGB());
|
||||
|
||||
y += dropoutElementHeight;
|
||||
i++;
|
||||
if(y >= requiredHeight) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(drawScrollBar) {
|
||||
//The scroll bar
|
||||
int dw = Mouse.getDWheel();
|
||||
if(dw > 0) {
|
||||
dw = -1;
|
||||
} else if(dw < 0) {
|
||||
dw = 1;
|
||||
}
|
||||
|
||||
upperIndex = Math.max(Math.min(upperIndex+dw, elements.size()-visibleDropout), 0);
|
||||
|
||||
drawRect(xPosition+width-3, yPosition+height+1, xPosition+width, yPosition+height+requiredHeight, Color.DARK_GRAY.getRGB());
|
||||
|
||||
float visiblePerc = ((float)visibleDropout)/elements.size();
|
||||
int barHeight = (int)(visiblePerc*(requiredHeight-1));
|
||||
|
||||
float posPerc = ((float)upperIndex)/elements.size();
|
||||
int barY = (int)(posPerc*(requiredHeight-1));
|
||||
|
||||
drawRect(xPosition+width-3, yPosition+height+1+barY, xPosition+width, yPosition+height+2+barY+barHeight, -6250336);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int xPos, int yPos, int mouseButton) {
|
||||
if(xPos > xPosition+width-height && xPos < xPosition+width && yPos > yPosition && yPos < yPosition+height) {
|
||||
open = !open;
|
||||
} else {
|
||||
if(xPos > xPosition && xPos < xPosition+width) {
|
||||
int requiredHeight = Math.min(maxDropoutHeight, elements.size()*dropoutElementHeight);
|
||||
if(yPos > yPosition+height && yPos < yPosition+height+requiredHeight) {
|
||||
int clickedIndex = (int)Math.floor((yPos - (yPosition+height)) / dropoutElementHeight) + upperIndex;
|
||||
this.selectionIndex = clickedIndex;
|
||||
}
|
||||
open = false;
|
||||
} else {
|
||||
open = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
if(!getText().equals(text)) {
|
||||
super.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object> elements = new ArrayList<Object>();
|
||||
|
||||
private void select(int index) {
|
||||
this.selectionIndex = index;
|
||||
}
|
||||
|
||||
public void setElements(List<Object> elements) {
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
public void addElement(Object element) {
|
||||
this.elements.add(element);
|
||||
}
|
||||
|
||||
public Object getElement(int index) {
|
||||
return elements.get(index);
|
||||
}
|
||||
|
||||
public int getSelectionIndex() {
|
||||
return selectionIndex;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import net.minecraft.client.gui.GuiListExtended.IGuiListEntry;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
||||
import eu.crushedpixel.replaymod.gui.replaymanager.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.utils.ResourceHelper;
|
||||
|
||||
public class GuiReplayListEntry implements IGuiListEntry {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import eu.crushedpixel.replaymod.gui.replaymanager.GuiReplayManager;
|
||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiIngameMenu;
|
||||
|
||||
@@ -22,7 +22,7 @@ import eu.crushedpixel.replaymod.api.client.SearchQuery;
|
||||
import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplayListExtended;
|
||||
import eu.crushedpixel.replaymod.gui.replaymanager.GuiReplayManager;
|
||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||
|
||||
public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
@@ -127,7 +127,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
} else if(button.id == GuiConstants.CENTER_LOGOUT_BUTTON) {
|
||||
mc.displayGuiScreen(getYesNoGui(this, LOGOUT_CALLBACK_ID));
|
||||
} else if(button.id == GuiConstants.CENTER_MANAGER_BUTTON) {
|
||||
mc.displayGuiScreen(new GuiReplayManager());
|
||||
mc.displayGuiScreen(new GuiReplayViewer());
|
||||
} else if(button.id == GuiConstants.CENTER_RECENT_BUTTON) {
|
||||
showOnlineRecent();
|
||||
} else if(button.id == GuiConstants.CENTER_BEST_BUTTON) {
|
||||
|
||||
@@ -35,12 +35,12 @@ 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.replaymanager.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.utils.ImageUtils;
|
||||
import eu.crushedpixel.replaymod.utils.ResourceHelper;
|
||||
|
||||
public class GuiUploadFile extends GuiScreen {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.crushedpixel.replaymod.gui.replaymanager;
|
||||
package eu.crushedpixel.replaymod.gui.replayviewer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.crushedpixel.replaymod.gui.replaymanager;
|
||||
package eu.crushedpixel.replaymod.gui.replayviewer;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
@@ -48,7 +48,7 @@ import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ImageUtils;
|
||||
|
||||
public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
|
||||
public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
||||
|
||||
private GuiScreen parentScreen;
|
||||
private GuiButton btnEditServer;
|
||||
@@ -144,7 +144,7 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
replayGuiList = new ReplayManagerReplayList(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
|
||||
replayGuiList = new ReplayList(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
this.buttonList.clear();
|
||||
|
||||
@@ -193,7 +193,7 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
|
||||
this.hoveringText = null;
|
||||
this.drawDefaultBackground();
|
||||
this.replayGuiList.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("Replay Manager", new Object[0]), this.width / 2, 20, 16777215);
|
||||
this.drawCenteredString(this.fontRendererObj, "Replay Viewer", this.width / 2, 20, 16777215);
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package eu.crushedpixel.replaymod.gui.replaymanager;
|
||||
package eu.crushedpixel.replaymod.gui.replayviewer;
|
||||
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplayListExtended;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class ReplayManagerReplayList extends GuiReplayListExtended {
|
||||
public class ReplayList extends GuiReplayListExtended {
|
||||
|
||||
private GuiReplayManager parent;
|
||||
private GuiReplayViewer parent;
|
||||
|
||||
public ReplayManagerReplayList(GuiReplayManager parent, Minecraft mcIn,
|
||||
public ReplayList(GuiReplayViewer parent, Minecraft mcIn,
|
||||
int p_i45010_2_, int p_i45010_3_, int p_i45010_4_, int p_i45010_5_,
|
||||
int p_i45010_6_) {
|
||||
super(mcIn, p_i45010_2_, p_i45010_3_, p_i45010_4_, p_i45010_5_,
|
||||
@@ -24,9 +24,9 @@ import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import eu.crushedpixel.replaymod.editor.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplaySaving;
|
||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
|
||||
public abstract class DataListener extends ChannelInboundHandlerAdapter {
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ import net.minecraft.network.play.server.S0DPacketCollectItem;
|
||||
import net.minecraft.network.play.server.S0FPacketSpawnMob;
|
||||
import eu.crushedpixel.replaymod.chat.ChatMessageRequests;
|
||||
import eu.crushedpixel.replaymod.chat.ChatMessageRequests.ChatMessageType;
|
||||
import eu.crushedpixel.replaymod.editor.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
|
||||
public class PacketListener extends DataListener {
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ import org.apache.commons.io.FilenameUtils;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.editor.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.entities.CameraEntity;
|
||||
import eu.crushedpixel.replaymod.events.RecordingHandler;
|
||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
||||
@@ -71,6 +70,7 @@ import eu.crushedpixel.replaymod.holders.Position;
|
||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
|
||||
@Sharable
|
||||
public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
@@ -396,7 +396,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
try {
|
||||
Packet p = ReplayFileIO.deserializePacket(ba);
|
||||
|
||||
if(hurryToTimestamp) { //If hurrying, ignore some packets
|
||||
if(hurryToTimestamp && !ReplayHandler.isInPath()) { //If hurrying, ignore some packets
|
||||
if(p instanceof S45PacketTitle ||
|
||||
p instanceof S29PacketSoundEffect ||
|
||||
p instanceof S2APacketParticles) return;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package eu.crushedpixel.replaymod.studio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import de.johni0702.replaystudio.studio.ReplayStudio;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.gui.GuiDropdown;
|
||||
|
||||
public class GuiReplayStudio extends GuiScreen {
|
||||
|
||||
private GuiDropdown replayDropdown;
|
||||
|
||||
private ReplayStudio studio = new ReplayStudio();
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
List<GuiButton> tabButtons = new ArrayList<GuiButton>();
|
||||
|
||||
tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_TRIM_TAB, 0, 0, "Trim Replay"));
|
||||
tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_CONNECT_TAB, 0, 0, "Connect Replays"));
|
||||
tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_MODIFY_TAB, 0, 0, "Modify Replay"));
|
||||
|
||||
int w = this.width - 30;
|
||||
int w2 = w/tabButtons.size();
|
||||
int i = 0;
|
||||
for(GuiButton b : tabButtons) {
|
||||
int x = 15+(w2*i);
|
||||
b.xPosition = x+2;
|
||||
b.yPosition = 30;
|
||||
b.width = w2-4;
|
||||
|
||||
buttonList.add(b);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
replayDropdown = new GuiDropdown(1, fontRendererObj, 15+2+1, 60, 100);
|
||||
replayDropdown.addElement("test1");
|
||||
replayDropdown.addElement("test2");
|
||||
replayDropdown.addElement("test3");
|
||||
replayDropdown.addElement("test4");
|
||||
replayDropdown.addElement("test5");
|
||||
replayDropdown.addElement("test6");
|
||||
replayDropdown.addElement("test7");
|
||||
replayDropdown.addElement("test8");
|
||||
replayDropdown.addElement("test9");
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
throws IOException {
|
||||
replayDropdown.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);
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
replayDropdown.drawTextBox();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package eu.crushedpixel.replaymod.studio;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import de.johni0702.replaystudio.Studio;
|
||||
import de.johni0702.replaystudio.collection.PacketData;
|
||||
import de.johni0702.replaystudio.filter.RemoveFilter;
|
||||
import de.johni0702.replaystudio.filter.SquashFilter;
|
||||
import de.johni0702.replaystudio.io.ReplayOutputStream;
|
||||
import de.johni0702.replaystudio.stream.PacketStream;
|
||||
import de.johni0702.replaystudio.studio.ReplayStudio;
|
||||
|
||||
public class StudioImplementation {
|
||||
|
||||
public static void trimReplay(InputStream replayFileStream, boolean isTmcpr, int beginning, int ending, File outputFile) throws IOException {
|
||||
ReplayStudio studio = new ReplayStudio();
|
||||
PacketStream stream = studio.createReplayStream(replayFileStream, isTmcpr);
|
||||
stream.addFilter(new SquashFilter(), -1, beginning);
|
||||
stream.addFilter(new RemoveFilter(), ending, -1);
|
||||
|
||||
outputFile.createNewFile();
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
ReplayOutputStream out = new ReplayOutputStream(studio, fos);
|
||||
PacketData packetData;
|
||||
|
||||
while((packetData = stream.next()) != null) {
|
||||
out.write(packetData);
|
||||
}
|
||||
for(PacketData data : stream.end()) {
|
||||
out.write(data);
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package eu.crushedpixel.replaymod.studio;
|
||||
|
||||
public class VersionValidator {
|
||||
|
||||
public static final boolean isValid;
|
||||
|
||||
static {
|
||||
String version = Runtime.class.getPackage().getSpecificationVersion();
|
||||
if(version != null) {
|
||||
String[] split = version.split("\\.");
|
||||
if(split.length > 1) {
|
||||
isValid = Integer.valueOf(split[1]) >= 7;
|
||||
} else {
|
||||
isValid = false;
|
||||
}
|
||||
} else {
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class MouseUtils {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static Point getMousePos() {
|
||||
Point scaled = getScaledDimensions();
|
||||
int width = (int)scaled.getX();
|
||||
int height = (int)scaled.getY();
|
||||
|
||||
final int mouseX = (Mouse.getX() * width / mc.displayWidth);
|
||||
final int mouseY = (height - Mouse.getY() * height / mc.displayHeight);
|
||||
|
||||
return new Point(mouseX, mouseY);
|
||||
}
|
||||
|
||||
public static Point getScaledDimensions() {
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
final int width = sr.getScaledWidth();
|
||||
final int heigth = sr.getScaledHeight();
|
||||
|
||||
return new Point(width, heigth);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package eu.crushedpixel.replaymod.gui.replaymanager;
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
Reference in New Issue
Block a user