Remove lots of old code
Add some additional config settings Update jGui and ReplayStudio
This commit is contained in:
@@ -3,7 +3,7 @@ package com.replaymod.render;
|
||||
import com.replaymod.render.frame.RGBFrame;
|
||||
import com.replaymod.render.rendering.FrameConsumer;
|
||||
import com.replaymod.render.utils.ByteBufferPool;
|
||||
import eu.crushedpixel.replaymod.utils.StreamPipe;
|
||||
import com.replaymod.render.utils.StreamPipe;
|
||||
import eu.crushedpixel.replaymod.utils.StringUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.replaymod.render.gui;
|
||||
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import com.replaymod.render.frame.RGBFrame;
|
||||
import com.replaymod.render.rendering.VideoRenderer;
|
||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||
@@ -12,7 +13,6 @@ import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||
import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import eu.crushedpixel.replaymod.utils.BoundingUtils;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -257,7 +257,7 @@ public class GuiVideoRenderer extends GuiScreen {
|
||||
|
||||
private void renderPreviewTexture(GuiRenderer guiRenderer, ReadableDimension size,
|
||||
int videoWidth, int videoHeight) {
|
||||
Dimension dimension = BoundingUtils.fitIntoBounds(new Dimension(videoWidth, videoHeight), size);
|
||||
Dimension dimension = Utils.fitIntoBounds(new Dimension(videoWidth, videoHeight), size);
|
||||
|
||||
int width = dimension.getWidth();
|
||||
int height = dimension.getHeight();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.replaymod.render.hooks;
|
||||
|
||||
import eu.crushedpixel.replaymod.utils.JailingQueue;
|
||||
import com.replaymod.render.utils.JailingQueue;
|
||||
import net.minecraft.client.renderer.RegionRenderCacheBuilder;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.chunk.ChunkCompileTaskGenerator;
|
||||
|
||||
120
src/main/java/com/replaymod/render/utils/JailingQueue.java
Normal file
120
src/main/java/com/replaymod/render/utils/JailingQueue.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package com.replaymod.render.utils;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class JailingQueue<T> extends AbstractQueue<T> implements BlockingQueue<T> {
|
||||
private final BlockingQueue<T> delegate;
|
||||
private final Set<Thread> jailed = new HashSet<Thread>();
|
||||
|
||||
public JailingQueue(BlockingQueue<T> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public synchronized void jail(int atLeast) {
|
||||
while (jailed.size() < atLeast) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.interrupted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void free(Thread thread) {
|
||||
Preconditions.checkState(jailed.remove(thread), "Thread is not jailed.");
|
||||
thread.interrupt();
|
||||
}
|
||||
|
||||
public synchronized void freeAll() {
|
||||
jailed.clear();
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
private synchronized void tryAccess() {
|
||||
jailed.add(Thread.currentThread());
|
||||
notifyAll();
|
||||
while (jailed.contains(Thread.currentThread())) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.interrupted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
tryAccess();
|
||||
return delegate.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
tryAccess();
|
||||
return delegate.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(T t) throws InterruptedException {
|
||||
tryAccess();
|
||||
delegate.put(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offer(T t, long timeout, TimeUnit unit) throws InterruptedException {
|
||||
tryAccess();
|
||||
return delegate.offer(t, timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T take() throws InterruptedException {
|
||||
tryAccess();
|
||||
return delegate.take();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T poll(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
tryAccess();
|
||||
return delegate.poll(timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remainingCapacity() {
|
||||
tryAccess();
|
||||
return delegate.remainingCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drainTo(Collection<? super T> c) {
|
||||
tryAccess();
|
||||
return delegate.drainTo(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drainTo(Collection<? super T> c, int maxElements) {
|
||||
tryAccess();
|
||||
return delegate.drainTo(c, maxElements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offer(T t) {
|
||||
tryAccess();
|
||||
return delegate.offer(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T poll() {
|
||||
tryAccess();
|
||||
return delegate.poll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T peek() {
|
||||
tryAccess();
|
||||
return delegate.peek();
|
||||
}
|
||||
}
|
||||
39
src/main/java/com/replaymod/render/utils/SoundHandler.java
Normal file
39
src/main/java/com/replaymod/render/utils/SoundHandler.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.replaymod.render.utils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.Clip;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class SoundHandler {
|
||||
|
||||
private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod", "renderSuccess.wav");
|
||||
|
||||
public void playRenderSuccessSound() {
|
||||
playSound(successSoundLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays a <b>.wav</b> Sound from a ResourceLocation. This method does <b>not</b> respect Game Settings like Audio Volume.
|
||||
* @param loc The Sound File's ResourceLocation
|
||||
*/
|
||||
public void playSound(ResourceLocation loc) {
|
||||
try {
|
||||
InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream();
|
||||
byte[] bytes = IOUtils.toByteArray(is);
|
||||
is.close();
|
||||
AudioInputStream ais = AudioSystem.getAudioInputStream(new ByteArrayInputStream(bytes));
|
||||
|
||||
Clip clip = AudioSystem.getClip();
|
||||
clip.open(ais);
|
||||
clip.start();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/main/java/com/replaymod/render/utils/StreamPipe.java
Normal file
28
src/main/java/com/replaymod/render/utils/StreamPipe.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.replaymod.render.utils;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class StreamPipe extends Thread {
|
||||
private final InputStream in;
|
||||
private final OutputStream out;
|
||||
|
||||
public StreamPipe(InputStream in, OutputStream out) {
|
||||
super("StreamPipe from " + in + " to " + out);
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
IOUtils.copy(in, out);
|
||||
} catch (IOException ignored) {
|
||||
// We don't care
|
||||
// Note: Once we use this for something important, we should probably care!
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user