Started adding support for downloading online files
This commit is contained in:
@@ -24,7 +24,7 @@ group= "eu.crushedpixel.replaymod"
|
||||
archivesBaseName = "replaymod"
|
||||
|
||||
minecraft {
|
||||
version = "1.8-11.14.0.1255-1.8"
|
||||
version = "1.8-11.14.1.1402"
|
||||
runDir = "eclipse"
|
||||
|
||||
// the mappings can be changed at any time, and must be in the following format.
|
||||
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Wed Jul 02 15:54:47 CDT 2014
|
||||
#Sun May 10 21:57:58 CEST 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-bin.zip
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-all.zip
|
||||
|
||||
@@ -140,18 +140,18 @@ public class ReplayMod {
|
||||
|
||||
/*
|
||||
boolean auth = false;
|
||||
try {
|
||||
auth = AuthenticationHandler.hasDonated(Minecraft.getMinecraft().getSession().getPlayerID());
|
||||
} catch(Exception e) {
|
||||
JOptionPane.showMessageDialog(null, "Couldn't connect to the Replay Mod Server to verify whether you donated!");
|
||||
FMLCommonHandler.instance().exitJava(0, false);
|
||||
}
|
||||
try {
|
||||
auth = AuthenticationHandler.hasDonated(Minecraft.getMinecraft().getSession().getPlayerID());
|
||||
} catch(Exception e) {
|
||||
JOptionPane.showMessageDialog(null, "Couldn't connect to the Replay Mod Server to verify whether you donated!");
|
||||
FMLCommonHandler.instance().exitJava(0, false);
|
||||
}
|
||||
|
||||
if(!auth) {
|
||||
JOptionPane.showMessageDialog(null, "It seems like you didn't donate, so you can't use the Replay Mod yet.");
|
||||
FMLCommonHandler.instance().exitJava(0, false);
|
||||
}
|
||||
*/
|
||||
if(!auth) {
|
||||
JOptionPane.showMessageDialog(null, "It seems like you didn't donate, so you can't use the Replay Mod yet.");
|
||||
FMLCommonHandler.instance().exitJava(0, false);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void removeTmcprFiles() {
|
||||
|
||||
@@ -9,6 +9,10 @@ public class GuiConstants {
|
||||
public static final int CENTER_RECENT_BUTTON = 2005;
|
||||
public static final int CENTER_BEST_BUTTON = 2006;
|
||||
public static final int CENTER_MANAGER_BUTTON = 2007;
|
||||
public static final int CENTER_LOAD_REPLAY_BUTTON = 2008;
|
||||
public static final int CENTER_FAV_REPLAY_BUTTON = 2009;
|
||||
public static final int CENTER_LIKE_REPLAY_BUTTON = 2010;
|
||||
public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011;
|
||||
|
||||
public static final int UPLOAD_NAME_INPUT = 3001;
|
||||
public static final int UPLOAD_CATEGORY_BUTTON = 3002;
|
||||
|
||||
@@ -82,6 +82,10 @@ public abstract class GuiReplayListExtended extends GuiListExtended {
|
||||
return entries.get(index);
|
||||
}
|
||||
|
||||
public List<GuiReplayListEntry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return entries.size();
|
||||
|
||||
@@ -5,7 +5,7 @@ import eu.crushedpixel.replaymod.api.client.SearchPagination;
|
||||
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.elements.GuiReplayListExtended;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiReplayListEntry;
|
||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||
import net.minecraft.client.gui.*;
|
||||
@@ -27,10 +27,12 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
private static final int LOGOUT_CALLBACK_ID = 1;
|
||||
private final SearchPagination recentFilePagination = new SearchPagination(recentFileSearchQuery);
|
||||
private final SearchPagination bestFilePagination = new SearchPagination(bestFileSearchQuery);
|
||||
private GuiReplayListExtended currentList;
|
||||
private ReplayFileList currentList;
|
||||
private ReplayFileList recentFileList, bestFileList, myFileList, searchFileList;
|
||||
private Tab currentTab = Tab.RECENT_FILES;
|
||||
private SearchPagination myFilePagination;
|
||||
private GuiButton loadButton, favButton, likeButton, dislikeButton;
|
||||
private List<GuiButton> replayButtonBar;
|
||||
|
||||
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, int p_152129_2_) {
|
||||
String s1 = I18n.format("replaymod.gui.center.logoutcallback");
|
||||
@@ -81,6 +83,38 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
i++;
|
||||
}
|
||||
|
||||
//Replay specific actions (load, rate, etc)
|
||||
replayButtonBar = new ArrayList<GuiButton>();
|
||||
|
||||
loadButton = new GuiButton(GuiConstants.CENTER_LOAD_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.download"));
|
||||
replayButtonBar.add(loadButton);
|
||||
|
||||
favButton = new GuiButton(GuiConstants.CENTER_FAV_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.center.favorite"));
|
||||
replayButtonBar.add(favButton);
|
||||
|
||||
likeButton = new GuiButton(GuiConstants.CENTER_LIKE_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.like"));
|
||||
replayButtonBar.add(likeButton);
|
||||
|
||||
dislikeButton = new GuiButton(GuiConstants.CENTER_DISLIKE_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.dislike"));
|
||||
replayButtonBar.add(dislikeButton);
|
||||
|
||||
i = 0;
|
||||
for(GuiButton b : replayButtonBar) {
|
||||
int w = this.width - 30;
|
||||
int w2 = w / replayButtonBar.size();
|
||||
|
||||
int x = 15 + (w2 * i);
|
||||
b.xPosition = x + 2;
|
||||
b.yPosition = height - 55;
|
||||
b.width = w2 - 4;
|
||||
|
||||
b.enabled = false;
|
||||
|
||||
buttonList.add(b);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
//Bottom Button Bar (dat alliteration)
|
||||
List<GuiButton> bottomBar = new ArrayList<GuiButton>();
|
||||
|
||||
@@ -111,6 +145,20 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
showOnlineRecent();
|
||||
}
|
||||
|
||||
public void elementSelected(int index) {
|
||||
GuiReplayListEntry entry = currentList.getListEntry(index);
|
||||
FileInfo info = entry.getFileInfo();
|
||||
if(info != null) {
|
||||
boolean downloaded = false;
|
||||
loadButton.displayString = downloaded ? I18n.format("replaymod.gui.load") : I18n.format("replaymod.gui.download");
|
||||
loadButton.enabled = true;
|
||||
} else {
|
||||
for(GuiButton b : replayButtonBar) {
|
||||
b.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws java.io.IOException {
|
||||
if(!button.enabled) return;
|
||||
@@ -128,6 +176,8 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
showOnlineOwnFiles();
|
||||
} else if(button.id == GuiConstants.CENTER_SEARCH_BUTTON) {
|
||||
|
||||
} else if(button.id == GuiConstants.CENTER_LOAD_REPLAY_BUTTON) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,13 +242,13 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
||||
private void updateCurrentList(ReplayFileList list, SearchPagination pagination) {
|
||||
currentList = list;
|
||||
if(currentList == null) {
|
||||
currentList = new ReplayFileList(mc, width, height, 50, height - 40, 36);
|
||||
currentList = new ReplayFileList(mc, width, height, 50, height - 70, 36, this);
|
||||
} else {
|
||||
currentList.clearEntries();
|
||||
currentList.width = width;
|
||||
currentList.height = height;
|
||||
currentList.top = 50;
|
||||
currentList.bottom = height - 40;
|
||||
currentList.bottom = height - 70;
|
||||
}
|
||||
|
||||
if(pagination.getLoadedPages() < 0) {
|
||||
|
||||
@@ -5,8 +5,17 @@ import net.minecraft.client.Minecraft;
|
||||
|
||||
public class ReplayFileList extends GuiReplayListExtended {
|
||||
|
||||
private GuiReplayCenter parent;
|
||||
|
||||
public ReplayFileList(Minecraft mcIn, int p_i45010_2_, int p_i45010_3_,
|
||||
int p_i45010_4_, int p_i45010_5_, int p_i45010_6_) {
|
||||
int p_i45010_4_, int p_i45010_5_, int p_i45010_6_, GuiReplayCenter parent) {
|
||||
super(mcIn, p_i45010_2_, p_i45010_3_, p_i45010_4_, p_i45010_5_, p_i45010_6_);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY) {
|
||||
super.elementClicked(slotIndex, isDoubleClick, mouseX, mouseY);
|
||||
parent.elementSelected(slotIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package eu.crushedpixel.replaymod.registry;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DownloadedFileHandler {
|
||||
|
||||
private HashMap<Integer, File> downloadedFiles = new HashMap<Integer, File>();
|
||||
|
||||
private File downloadFolder;
|
||||
|
||||
public DownloadedFileHandler() {
|
||||
downloadFolder = new File(ReplayMod.replaySettings.getDownloadPath());
|
||||
downloadFolder.mkdirs();
|
||||
|
||||
for(File f : downloadFolder.listFiles()) {
|
||||
try {
|
||||
Integer i = Integer.valueOf(FilenameUtils.getBaseName(f.getAbsolutePath()));
|
||||
if(i != null) {
|
||||
downloadedFiles.put(i, f);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addToIndex(int id) {
|
||||
try {
|
||||
File f = new File(downloadFolder, id+"."+ConnectionEventHandler.ZIP_FILE_EXTENSION);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public File getFileForID(int id) {
|
||||
return downloadedFiles.get(id);
|
||||
}
|
||||
}
|
||||
@@ -83,12 +83,15 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
int i=0;
|
||||
|
||||
try {
|
||||
while(ctx == null && !terminate) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
while(!terminate) {
|
||||
if(startFromBeginning) {
|
||||
System.out.println("start from beginning");
|
||||
hasRestarted = true;
|
||||
hasWorldLoaded = false;
|
||||
currentTimeStamp = 0;
|
||||
@@ -100,6 +103,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
while(!terminate && !startFromBeginning && (!paused() || !hasWorldLoaded)) {
|
||||
//System.out.println("read");
|
||||
try {
|
||||
/*
|
||||
* LOGIC:
|
||||
@@ -133,7 +137,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
lastTimeStamp = currentTimeStamp;
|
||||
|
||||
if(hurryToTimestamp && currentTimeStamp >= desiredTimeStamp && !startFromBeginning) {
|
||||
hurryToTimestamp = false;
|
||||
System.out.println("STOPPED HURRYING");
|
||||
stopHurrying();
|
||||
if(!ReplayHandler.isInPath() || hasRestarted) {
|
||||
MCTimerHandler.advanceRenderPartialTicks(5);
|
||||
MCTimerHandler.advancePartialTicks(5);
|
||||
@@ -164,7 +169,9 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
System.out.println("STOPPED FOREVER");
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -245,23 +252,26 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
public void jumpToTime(int millis) {
|
||||
System.out.println("Jumped to "+millis);
|
||||
if(!(ReplayHandler.isInPath() && ReplayProcess.isVideoRecording())) setReplaySpeed(replaySpeed);
|
||||
|
||||
if((millis < currentTimeStamp && !isHurrying())) {
|
||||
if(ReplayHandler.isInPath()) {
|
||||
if(millis >= toleratedTimeStamp && toleratedTimeStamp >= 0) {
|
||||
System.out.println("tolerated: "+toleratedTimeStamp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
startFromBeginning = true;
|
||||
System.out.println("has to start from beginning");
|
||||
}
|
||||
|
||||
desiredTimeStamp = millis;
|
||||
System.out.println("Set desired Timestamp");
|
||||
if(ReplayHandler.isInPath()) {
|
||||
toleratedTimeStamp = millis;
|
||||
}
|
||||
hurryToTimestamp = true;
|
||||
|
||||
}
|
||||
|
||||
//private static Field dataWatcherField;
|
||||
|
||||
@@ -56,6 +56,8 @@ public class ReplaySettings {
|
||||
return (String) AdvancedOptions.renderPath.getValue();
|
||||
}
|
||||
|
||||
public String getDownloadPath() { return (String) AdvancedOptions.downloadPath.getValue(); }
|
||||
|
||||
public int getVideoFramerate() {
|
||||
return (Integer) RenderOptions.videoFramerate.getValue();
|
||||
}
|
||||
@@ -270,7 +272,7 @@ public class ReplaySettings {
|
||||
}
|
||||
|
||||
public enum AdvancedOptions implements ValueEnum {
|
||||
recordingPath("./replay_recordings/"), renderPath("./replay_videos/");
|
||||
recordingPath("./replay_recordings/"), renderPath("./replay_videos/"), downloadPath("./replay_downloads");
|
||||
|
||||
private Object value;
|
||||
|
||||
@@ -287,9 +289,9 @@ public class ReplaySettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static interface ValueEnum {
|
||||
public Object getValue();
|
||||
public interface ValueEnum {
|
||||
Object getValue();
|
||||
|
||||
public void setValue(Object value);
|
||||
void setValue(Object value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,9 @@ replaymod.gui.password=Password
|
||||
replaymod.gui.back=Back
|
||||
replaymod.gui.duration=Duration
|
||||
replaymod.gui.load=Load
|
||||
replaymod.gui.download=Download
|
||||
replaymod.gui.like=Like
|
||||
replaymod.gui.dislike=Dislike
|
||||
replaymod.gui.save=Save
|
||||
replaymod.gui.upload=Upload
|
||||
replaymod.gui.rename=Rename
|
||||
@@ -121,6 +124,9 @@ replaymod.gui.center.best=Best Replays
|
||||
replaymod.gui.center.my=My Replays
|
||||
replaymod.gui.center.search=Search Replays
|
||||
|
||||
replaymod.gui.center.favorite=Favorite
|
||||
replaymod.gui.center.favorites=Favorites
|
||||
|
||||
#Upload GUI
|
||||
replaymod.gui.upload.title=Upload File
|
||||
replaymod.gui.upload.start=Start Upload
|
||||
|
||||
Reference in New Issue
Block a user