Added Video Export feature with according Options in the Options Menu

Fixed Linear Interpolation
This commit is contained in:
Marius Metzger
2015-02-08 12:40:37 +01:00
parent 0fc9662449
commit 03f6ba1ade
39 changed files with 1235 additions and 456 deletions

View File

@@ -1,4 +1,4 @@
package eu.crushedpixel.replaymod.gui.replaymanager;
package eu.crushedpixel.replaymod.gui;
import java.awt.image.BufferedImage;
import java.io.File;
@@ -18,6 +18,7 @@ import net.minecraft.client.gui.GuiListExtended.IGuiListEntry;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation;
import eu.crushedpixel.replaymod.gui.replaymanager.ResourceHelper;
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
public class GuiReplayListEntry implements IGuiListEntry {
@@ -66,7 +67,7 @@ public class GuiReplayListEntry implements IGuiListEntry {
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) {
try {
minecraft.fontRendererObj.drawString(fileName, x + 3, y + 1, 16777215);
if(y < -slotHeight || y > parent.height) {
if(registered) {
registered = false;
@@ -79,7 +80,11 @@ public class GuiReplayListEntry implements IGuiListEntry {
} else {
if(!registered) {
textureResource = new ResourceLocation("thumbs/"+fileName);
image = ImageIO.read(imageFile);
if(imageFile == null) {
image = ResourceHelper.getDefaultThumbnail();
} else {
image = ImageIO.read(imageFile);
}
dynTex = new DynamicTexture(image);
minecraft.getTextureManager().loadTexture(textureResource, dynTex);
dynTex.updateDynamicTexture();

View File

@@ -1,4 +1,4 @@
package eu.crushedpixel.replaymod.gui.replaymanager;
package eu.crushedpixel.replaymod.gui;
import java.io.File;
import java.util.ArrayList;
@@ -15,29 +15,21 @@ import org.lwjgl.input.Mouse;
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
public class GuiReplayListExtended extends GuiListExtended {
public abstract class GuiReplayListExtended extends GuiListExtended {
private GuiReplayManager parent;
public int selected = -1;
public GuiReplayListExtended(GuiReplayManager parent, Minecraft mcIn, int p_i45010_2_,
public GuiReplayListExtended(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_, p_i45010_6_);
this.parent = parent;
}
public int selected = -1;
@Override
protected void elementClicked(int slotIndex, boolean isDoubleClick,
int mouseX, int mouseY) {
super.elementClicked(slotIndex, isDoubleClick, mouseX, mouseY);
this.selected = slotIndex;
parent.setButtonsEnabled(true);
if(isDoubleClick) {
parent.loadReplay(slotIndex);
}
}
@Override
protected void drawSelectionBox(int p_148120_1_, int p_148120_2_, int p_148120_3_, int p_148120_4_)

View File

@@ -22,12 +22,14 @@ public class GuiReplaySettings extends GuiScreen {
private GuiScreen parentGuiScreen;
protected String screenTitle = "Replay Mod Settings";
private static final int MAXSIZE_SLIDER_ID = 9003;
//TODO: Move to GuiConstants
private static final int QUALITY_SLIDER_ID = 9003;
private static final int RECORDSERVER_ID = 9004;
private static final int RECORDSP_ID = 9005;
private static final int SEND_CHAT = 9006;
private static final int FORCE_LINEAR = 9007;
private static final int ENABLE_LIGHTING = 9008;
private static final int FRAMERATE_SLIDER_ID = 9009;
private GuiButton recordServerButton, recordSPButton, sendChatButton, linearButton, lightingButton;
@@ -47,18 +49,11 @@ public class GuiReplaySettings extends GuiScreen {
int i = 0;
for (Entry<String, Object> e : aoptions.entrySet()) {
/*
if(e.getKey().equals("Maximum File Size")) {
float minValue = -1;
float maxValue = 10000;
float valueSteps = 1;
int val = (Integer)e.getValue();
this.buttonList.add(new GuiSizeLimitOptionSlider(MAXSIZE_SLIDER_ID, this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), 0, 39, 1, val, e.getKey()));
} else
*/
if(e.getKey().equals("Enable Notifications")) {
if(e.getKey().equals("Video Quality")) {
this.buttonList.add(new GuiVideoQualitySlider(QUALITY_SLIDER_ID, this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), (Float)e.getValue(), "Video Quality"));
} else if(e.getKey().equals("Video Framerate")) {
this.buttonList.add(new GuiVideoFramerateSlider(FRAMERATE_SLIDER_ID, this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), (Integer)e.getValue(), "Video Framerate"));
} else if(e.getKey().equals("Enable Notifications")) {
sendChatButton = new GuiButton(SEND_CHAT, this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), 150, 20, "Enable Notifications: "+onOff((Boolean)e.getValue()));
this.buttonList.add(sendChatButton);
} else if(e.getKey().equals("Record Server")) {

View File

@@ -1,185 +0,0 @@
package eu.crushedpixel.replaymod.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.MathHelper;
import eu.crushedpixel.replaymod.ReplayMod;
public class GuiSizeLimitOptionSlider extends GuiButton {
public GuiSizeLimitOptionSlider(int buttonId, int p_i45017_2_, int p_i45017_3_, float valueMin, float valueMax, float valueStep, int sliderValue, String displayKey)
{
super(buttonId, p_i45017_2_, p_i45017_3_, 150, 20, "");
this.valueMin = valueMin;
this.valueMax = valueMax;
this.valueStep = valueStep;
this.sliderValue = sliderValue;
this.displayString = displayKey+": "+translate(sliderValue);
this.displayKey = displayKey;
float val = realToNormalized(convertScaleRet(sliderValue));
this.sliderValue = val;
}
private float sliderValue;
public boolean dragging;
private GameSettings.Options options;
private float valueStep, valueMin, valueMax;
private String displayKey;
protected int getHoverState(boolean mouseOver) {
return 0;
}
@Override
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
if (this.dragging) {
sliderValue = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
sliderValue = MathHelper.clamp_float(sliderValue, 0.0F, 1.0F);
float f = denormalizeValue(sliderValue);
sliderValue = normalizeValue(f);
this.displayString = displayKey+": "+translate(convertScale(normalizedToReal(sliderValue)));
ReplayMod.replaySettings.setMaximumFileSize(convertScale(normalizedToReal(sliderValue)));
}
mc.getTextureManager().bindTexture(buttonTextures);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.xPosition + (int)(sliderValue * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20);
this.drawTexturedModalRect(this.xPosition + (int)(sliderValue * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
}
}
public static String translate(int value) {
if(value == 0) {
return "Unlimited";
} else {
return convertToStringRepresentation(value);
}
}
public static int convertScale(float value) {
if(value == 0) {
return 0;
} else {
if(value > 20) {
value = 1024+((value-20)*1024);
} else {
value = value*50;
}
if(value == 1000) {
value = 1024;
}
return Math.round(value);
}
}
public static int convertScaleRet(float value) {
if(value == 0) {
return 0;
} else {
if(value >= 1024) {
value = 20+((value-1024)/1024);
} else {
value = value/50;
}
if(value == 1024) {
value = 1000;
}
return Math.round(value);
}
}
public static String convertToStringRepresentation(final long value){
long M = 1;
long G = 1024;
long T = G * 1024;
final long[] dividers = new long[] { T, G, M};
final String[] units = new String[] { "TB", "GB", "MB"};
if(value < 1)
throw new IllegalArgumentException("Invalid file size: " + value);
String result = null;
for(int i = 0; i < dividers.length; i++){
final long divider = dividers[i];
if(value >= divider){
result = format(value, divider, units[i]);
break;
}
}
return result;
}
private static String format(final long value,
final long divider,
final String unit){
final double result =
divider > 1 ? (double) value / (double) divider : (double) value;
return String.format("%.0f %s", Double.valueOf(result), unit);
}
public float normalizedToReal(float value) {
float min = 0 - valueMin;
float max = valueMax + min;
return Math.round(value*(max) - min);
}
public float realToNormalized(float value) {
float min = 0 - valueMin;
float max = valueMax + min;
return value/(max) - min;
}
public float normalizeValue(float p_148266_1_)
{
return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F);
}
public float denormalizeValue(float p_148262_1_)
{
return this.snapToStepClamp(this.valueMin + (this.valueMax - this.valueMin) * MathHelper.clamp_float(p_148262_1_, 0.0F, 1.0F));
}
public float snapToStepClamp(float p_148268_1_)
{
p_148268_1_ = this.snapToStep(p_148268_1_);
return MathHelper.clamp_float(p_148268_1_, this.valueMin, this.valueMax);
}
protected float snapToStep(float p_148264_1_)
{
if (this.valueStep > 0.0F)
{
p_148264_1_ = this.valueStep * (float)Math.round(p_148264_1_ / this.valueStep);
}
return p_148264_1_;
}
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if (super.mousePressed(mc, mouseX, mouseY))
{
this.dragging = true;
return true;
}
else
{
return false;
}
}
public void mouseReleased(int mouseX, int mouseY)
{
this.dragging = false;
}
}

View File

@@ -0,0 +1,71 @@
package eu.crushedpixel.replaymod.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.MathHelper;
import eu.crushedpixel.replaymod.ReplayMod;
public class GuiVideoFramerateSlider extends GuiButton {
public GuiVideoFramerateSlider(int buttonId, int p_i45017_2_, int p_i45017_3_, int initialFramerate, String displayKey) {
super(buttonId, p_i45017_2_, p_i45017_3_, 150, 20, "");
this.sliderValue = normalizeValue(initialFramerate);
this.displayString = displayKey+": "+translate(initialFramerate);
this.displayKey = displayKey;
}
private String displayKey;
private float sliderValue;
public boolean dragging;
private String translate(int value) {
return String.valueOf(value);
}
protected int getHoverState(boolean mouseOver) {
return 0;
}
@Override
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
if (this.dragging) {
sliderValue = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
sliderValue = MathHelper.clamp_float(sliderValue, 0.0F, 1.0F);
int f = denormalizeValue(sliderValue);
this.displayString = displayKey+": "+translate(f);
ReplayMod.replaySettings.setVideoFramerate(f);
}
mc.getTextureManager().bindTexture(buttonTextures);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.xPosition + (int)(sliderValue * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20);
this.drawTexturedModalRect(this.xPosition + (int)(sliderValue * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
}
}
private float normalizeValue(int val) {
return (val-10)/110f;
}
private int denormalizeValue(float val) {
//Transfers the value ranging from 0.0 to 1.0 to the scale of 10 to 120
float r = 110f*val;
return Math.round(10+r);
}
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
if (super.mousePressed(mc, mouseX, mouseY)) {
this.dragging = true;
return true;
} else {
return false;
}
}
public void mouseReleased(int mouseX, int mouseY) {
this.dragging = false;
}
}

View File

@@ -0,0 +1,85 @@
package eu.crushedpixel.replaymod.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.MathHelper;
import eu.crushedpixel.replaymod.ReplayMod;
public class GuiVideoQualitySlider extends GuiButton {
public GuiVideoQualitySlider(int buttonId, int p_i45017_2_, int p_i45017_3_, float initialQuality, String displayKey) {
super(buttonId, p_i45017_2_, p_i45017_3_, 150, 20, "");
this.sliderValue = normalizeValue(initialQuality);
this.displayString = displayKey+": "+translate(initialQuality);
this.displayKey = displayKey;
}
private String displayKey;
private float sliderValue;
public boolean dragging;
private String translate(float value) {
if(value <= 0.3) {
return "Draft";
} else if(value <= 0.5) {
return "Normal";
} else if(value <= 0.7) {
return "Good";
}
return "Best";
}
protected int getHoverState(boolean mouseOver) {
return 0;
}
@Override
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
if (this.dragging) {
sliderValue = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
sliderValue = MathHelper.clamp_float(sliderValue, 0.0F, 1.0F);
float f = denormalizeValue(sliderValue);
f = snapValue(f);
sliderValue = normalizeValue(f);
this.displayString = displayKey+": "+translate(f);
ReplayMod.replaySettings.setVideoQuality(f);
}
mc.getTextureManager().bindTexture(buttonTextures);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.xPosition + (int)(sliderValue * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20);
this.drawTexturedModalRect(this.xPosition + (int)(sliderValue * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
}
}
private float snapValue(float val) {
int i = Math.round(val*10);
return i/10f;
}
private float normalizeValue(float val) {
return (val-0.1f)/0.8f;
}
private float denormalizeValue(float val) {
//Transfers the value ranging from 0.0 to 1.0 to the scale of 0.1 to 0.9
float r = 0.8f*val;
return 0.1f+r;
}
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
if (super.mousePressed(mc, mouseX, mouseY)) {
this.dragging = true;
return true;
} else {
return false;
}
}
public void mouseReleased(int mouseX, int mouseY) {
this.dragging = false;
}
}

View File

@@ -1,6 +1,7 @@
package eu.crushedpixel.replaymod.gui.online;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -14,19 +15,26 @@ import net.minecraft.client.resources.I18n;
import org.lwjgl.input.Keyboard;
import scala.actors.threadpool.Arrays;
import com.mojang.realmsclient.gui.GuiCallback;
import eu.crushedpixel.replaymod.ReplayMod;
import eu.crushedpixel.replaymod.api.client.ApiException;
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.online.authentication.AuthenticationHandler;
public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
private enum Tab {
RECENT_FILES, BEST_FILES, MY_FILES, SEARCH;
}
private GuiReplayListExtended currentList;
private ReplayFileList recentFileList, bestFileList, myFileList, searchFileList;
private Tab currentTab = Tab.RECENT_FILES;
@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
@@ -40,7 +48,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
GuiButton recentButton = new GuiButton(GuiConstants.CENTER_RECENT_BUTTON, 20, 30, "Newest Replays");
buttonBar.add(recentButton);
GuiButton bestButton = new GuiButton(GuiConstants.CENTER_BEST_BUTTON, 20, 30, "Best Replays");
buttonBar.add(bestButton);
@@ -70,7 +78,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");
bottomBar.add(managerButton);
@@ -91,7 +99,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
i++;
}
showOnlineRecent();
}
@@ -107,11 +115,11 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
} else if(button.id == GuiConstants.CENTER_RECENT_BUTTON) {
showOnlineRecent();
} else if(button.id == GuiConstants.CENTER_BEST_BUTTON) {
} else if(button.id == GuiConstants.CENTER_MY_REPLAYS_BUTTON) {
} else if(button.id == GuiConstants.CENTER_SEARCH_BUTTON) {
}
}
@@ -144,22 +152,66 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
this.drawDefaultBackground();
this.drawCenteredString(fontRendererObj, "Replay Center", this.width/2, 8, Color.WHITE.getRGB());
if(currentList != null) {
currentList.drawScreen(mouseX, mouseY, partialTicks);
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();
if(currentList != null) {
this.currentList.handleMouseInput();
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
if(currentList != null) {
this.currentList.mouseClicked(mouseX, mouseY, mouseButton);
}
}
@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
super.mouseReleased(mouseX, mouseY, state);
if(currentList != null) {
this.currentList.mouseReleased(mouseX, mouseY, state);
}
}
@Override
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
}
public void showOnlineRecent() {
mc.addScheduledTask(new Runnable() {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
if(recentFileList == null) {
recentFileList = new ReplayFileList(mc, width, height, 50, height-40, 36);
} else {
recentFileList.clearEntries();
recentFileList.width = width;
recentFileList.height = height;
recentFileList.top = 50;
recentFileList.bottom = height-40;
}
currentTab = Tab.RECENT_FILES;
currentList = recentFileList;
FileInfo[] files = ReplayMod.apiClient.getRecentFiles();
for(FileInfo i : files) {
//TODO: Display the Files
File tmp = null;
if(i.hasThumbnail()) {
tmp = File.createTempFile("thumb_online_"+i.getId(), "jpg");
ReplayMod.apiClient.downloadThumbnail(i.getId(), tmp);
}
recentFileList.addEntry(i.getName(), i.getMetadata(), tmp);
}
} catch (IOException e) {
e.printStackTrace();
@@ -168,7 +220,8 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
}
}
});
t.start();
}
}

View File

@@ -0,0 +1,12 @@
package eu.crushedpixel.replaymod.gui.online;
import net.minecraft.client.Minecraft;
import eu.crushedpixel.replaymod.gui.GuiReplayListExtended;
public class ReplayFileList extends GuiReplayListExtended {
public ReplayFileList(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_, p_i45010_6_);
}
}

View File

@@ -37,6 +37,7 @@ import org.lwjgl.input.Keyboard;
import com.google.gson.Gson;
import com.mojang.realmsclient.util.Pair;
import eu.crushedpixel.replaymod.gui.GuiReplayListExtended;
import eu.crushedpixel.replaymod.gui.GuiReplaySettings;
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
@@ -95,16 +96,14 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
img = ImageUtils.scaleImage(bimg, new Dimension(1280, 720));
}
}
//If thumb is null, set image to placeholder
if(img == null) {
img = ImageIO.read(MCPNames.class.getClassLoader().getResourceAsStream("default_thumb.jpg"));
File tmp = null;
if(img != null) {
tmp = File.createTempFile(FilenameUtils.getBaseName(file.getAbsolutePath()), "jpg");
tmp.deleteOnExit();
ImageIO.write(img, "jpg", tmp);
}
File tmp = File.createTempFile(FilenameUtils.getBaseName(file.getAbsolutePath()), "jpg");
tmp.deleteOnExit();
ImageIO.write(img, "jpg", tmp);
InputStream is = archive.getInputStream(metadata);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
@@ -116,9 +115,7 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
replayFileList.add(Pair.of(Pair.of(file, metaData), tmp));
archive.close();
} catch(Exception e) {
e.printStackTrace();
}
} catch(Exception e) {}
}
}
@@ -144,7 +141,7 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
@Override
public void initGui() {
replayGuiList = new GuiReplayListExtended(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
replayGuiList = new ReplayManagerReplayList(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
@@ -170,26 +167,26 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
setButtonsEnabled(false);
}
public void handleMouseInput() throws IOException
{
@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();
this.replayGuiList.handleMouseInput();
}
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
this.replayGuiList.mouseClicked(mouseX, mouseY, mouseButton);
}
protected void mouseReleased(int mouseX, int mouseY, int state)
{
@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
super.mouseReleased(mouseX, mouseY, state);
this.replayGuiList.mouseReleased(mouseX, mouseY, state);
}
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.hoveringText = null;
this.drawDefaultBackground();
this.replayGuiList.drawScreen(mouseX, mouseY, partialTicks);
@@ -198,8 +195,7 @@ public class GuiReplayManager extends GuiScreen implements GuiYesNoCallback {
}
@Override
protected void actionPerformed(GuiButton button) throws IOException
{
protected void actionPerformed(GuiButton button) throws IOException {
if(button.enabled) {
if(button.id == LOAD_BUTTON_ID) {
loadReplay(replayGuiList.selected);

View File

@@ -0,0 +1,29 @@
package eu.crushedpixel.replaymod.gui.replaymanager;
import eu.crushedpixel.replaymod.gui.GuiReplayListExtended;
import net.minecraft.client.Minecraft;
public class ReplayManagerReplayList extends GuiReplayListExtended {
private GuiReplayManager parent;
public ReplayManagerReplayList(GuiReplayManager 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_,
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.setButtonsEnabled(true);
if(isDoubleClick) {
parent.loadReplay(slotIndex);
}
}
}

View File

@@ -1,29 +1,47 @@
package eu.crushedpixel.replaymod.gui.replaymanager;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import eu.crushedpixel.replaymod.reflection.MCPNames;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
public class ResourceHelper {
private static BufferedImage defaultThumb;
static {
try {
defaultThumb = ImageIO.read(MCPNames.class.getClassLoader().getResourceAsStream("default_thumb.jpg"));
} catch(Exception e) {
defaultThumb = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
e.printStackTrace();
}
}
private static List<ResourceLocation> openResources = new ArrayList<ResourceLocation>();
public static void registerResource(ResourceLocation loc) {
openResources.add(loc);
}
public static void freeResource(ResourceLocation loc) {
Minecraft.getMinecraft().getTextureManager().deleteTexture(loc);
openResources.remove(loc);
}
public static void freeAllResources() {
for(ResourceLocation loc : openResources) {
Minecraft.getMinecraft().getTextureManager().deleteTexture(loc);
}
openResources = new ArrayList<ResourceLocation>();
}
public static BufferedImage getDefaultThumbnail() {
return defaultThumb;
}
}