Split mod into core, recording, replay, render[todo], paths[todo] and extras[wip] modules
Move everything to com.replaymod package Add KeyBindingRegistry and SettingsRegistry Recreate settings GUI with new GUI API and dynamically from SettingsRegistry Use ReplayFile from ReplayStudio ReplayHandler is now object oriented Add GuiOverlay, GuiSlider and GuiTexturedButton to GUI API Rewrite both overlays to use new GUI API Fix size capping in vertical and horizontal layout Allow CustomLayouts to have parents Fix tooltip rendering when close to screen border Allow changing of columns in GridLayout
This commit is contained in:
@@ -6,8 +6,6 @@ import eu.crushedpixel.replaymod.assets.ReplayAsset;
|
||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.FileChooseListener;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
||||
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -22,7 +20,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiAssetManager extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
||||
public class GuiAssetManager extends GuiScreen {
|
||||
|
||||
private String screenTitle;
|
||||
|
||||
@@ -43,8 +41,10 @@ public class GuiAssetManager extends GuiScreen implements GuiReplayOverlay.NoOve
|
||||
private ReplayAsset currentAsset;
|
||||
|
||||
public GuiAssetManager() {
|
||||
this.initialRepository = new AssetRepository(ReplayHandler.getAssetRepository());
|
||||
this.assetRepository = ReplayHandler.getAssetRepository();
|
||||
// TODO
|
||||
initialRepository = null;
|
||||
// this.initialRepository = new AssetRepository(ReplayHandler.getAssetRepository());
|
||||
// this.assetRepository = ReplayHandler.getAssetRepository();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,35 +1,30 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.NumberValueChangeListener;
|
||||
import eu.crushedpixel.replaymod.holders.*;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
|
||||
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import eu.crushedpixel.replaymod.utils.RoundUtils;
|
||||
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class GuiEditKeyframe<T extends KeyframeValue> extends GuiScreen {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static GuiEditKeyframe create(Keyframe kf) {
|
||||
if(kf.getValue() instanceof Marker) return new GuiEditKeyframeMarker(kf);
|
||||
if(kf.getValue() instanceof TimestampValue) return new GuiEditKeyframeTime(kf);
|
||||
if(kf.getValue() instanceof SpectatorData) return new GuiEditKeyframeSpectator(kf);
|
||||
if(kf.getValue() instanceof AdvancedPosition) return new GuiEditKeyframePosition(kf);
|
||||
// TODO
|
||||
// if(kf.getValue() instanceof TimestampValue) return new GuiEditKeyframeTime(kf);
|
||||
// if(kf.getValue() instanceof SpectatorData) return new GuiEditKeyframeSpectator(kf);
|
||||
// if(kf.getValue() instanceof AdvancedPosition) return new GuiEditKeyframePosition(kf);
|
||||
throw new UnsupportedOperationException("Keyframe type unknown: " + kf);
|
||||
}
|
||||
|
||||
@@ -156,13 +151,14 @@ public abstract class GuiEditKeyframe<T extends KeyframeValue> extends GuiScreen
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if(!save) {
|
||||
ReplayHandler.removeKeyframe(keyframe);
|
||||
ReplayHandler.addKeyframe(keyframeBackup);
|
||||
ReplayHandler.selectKeyframe(keyframeBackup);
|
||||
}
|
||||
ReplayHandler.fireKeyframesModifyEvent();
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
// TODO
|
||||
// if(!save) {
|
||||
// ReplayHandler.removeKeyframe(keyframe);
|
||||
// ReplayHandler.addKeyframe(keyframeBackup);
|
||||
// ReplayHandler.selectKeyframe(keyframeBackup);
|
||||
// }
|
||||
// ReplayHandler.fireKeyframesModifyEvent();
|
||||
// Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,300 +214,301 @@ public abstract class GuiEditKeyframe<T extends KeyframeValue> extends GuiScreen
|
||||
|
||||
protected void drawScreen0() {}
|
||||
|
||||
private static class GuiEditKeyframeMarker extends GuiEditKeyframe<Marker> {
|
||||
private GuiAdvancedTextField markerNameInput;
|
||||
|
||||
public GuiEditKeyframeMarker(Keyframe<Marker> keyframe) {
|
||||
super(keyframe, ReplayHandler.getMarkerKeyframes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
if (!initialized) {
|
||||
String name = keyframe.getValue().getName();
|
||||
if (name == null) name = "";
|
||||
markerNameInput = new GuiAdvancedTextField(fontRendererObj, 0, 0, 200, 20);
|
||||
markerNameInput.hint = I18n.format("replaymod.gui.editkeyframe.markername");
|
||||
markerNameInput.setText(name);
|
||||
|
||||
inputs.addPart(markerNameInput);
|
||||
|
||||
new KeyframeValueChangeListener(this);
|
||||
}
|
||||
|
||||
markerNameInput.xPosition = width/2 - 100;
|
||||
markerNameInput.yPosition = height/2-10;
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
keyframe.getValue().setName(markerNameInput.getText().trim());
|
||||
super.onGuiClosed();
|
||||
}
|
||||
}
|
||||
|
||||
private static class GuiEditKeyframeTime extends GuiEditKeyframe<TimestampValue> {
|
||||
private GuiNumberInput kfMin, kfSec, kfMs;
|
||||
|
||||
public GuiEditKeyframeTime(Keyframe<TimestampValue> keyframe) {
|
||||
super(keyframe, ReplayHandler.getTimeKeyframes());
|
||||
screenTitle = I18n.format("replaymod.gui.editkeyframe.title.time");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
if (!initialized) {
|
||||
int time = keyframe.getValue().asInt();
|
||||
|
||||
kfMin = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 30, 0d, null, (double)TimestampUtils.timestampToWholeMinutes(time), false, "", 1);
|
||||
kfSec = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 25, 0d, 59d, (double)TimestampUtils.getSecondsFromTimestamp(time), false, "", 1);
|
||||
kfMs = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 35, 0d, 999d, (double)TimestampUtils.getMillisecondsFromTimestamp(time), false, "", 1);
|
||||
|
||||
inputs.addPart(kfMin);
|
||||
inputs.addPart(kfSec);
|
||||
inputs.addPart(kfMs);
|
||||
|
||||
KeyframeValueChangeListener listener = new KeyframeValueChangeListener(this) {
|
||||
@Override
|
||||
public void onValueChange(double value) {
|
||||
keyframe.setValue(new TimestampValue(TimestampUtils.calculateTimestamp(
|
||||
kfMin.getIntValue(), kfSec.getIntValue(), kfMs.getIntValue())));
|
||||
|
||||
super.onValueChange(value);
|
||||
}
|
||||
};
|
||||
|
||||
kfMin.addValueChangeListener(listener);
|
||||
kfSec.addValueChangeListener(listener);
|
||||
kfMs.addValueChangeListener(listener);
|
||||
}
|
||||
|
||||
kfMin.xPosition = min.xPosition;
|
||||
kfSec.xPosition = sec.xPosition;
|
||||
kfMs.xPosition = ms.xPosition;
|
||||
|
||||
kfMin.yPosition = kfSec.yPosition = kfMs.yPosition = min.yPosition - 10 - 20;
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawScreen0() {
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.timestamp")+":", (width-w3)/2, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.minutes"), kfMin.xPosition + kfMin.width + 5, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.seconds"), kfSec.xPosition + kfSec.width + 5, kfSec.yPosition + 7, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.milliseconds"), kfMs.xPosition + kfMs.width + 5, kfMs.yPosition + 7, Color.WHITE.getRGB());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class GuiEditKeyframePosition extends GuiEditKeyframe<AdvancedPosition> {
|
||||
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
||||
private ComposedElement posInputs;
|
||||
|
||||
public GuiEditKeyframePosition(Keyframe<AdvancedPosition> keyframe) {
|
||||
super(keyframe, ReplayHandler.getPositionKeyframes());
|
||||
screenTitle = I18n.format("replaymod.gui.editkeyframe.title.pos");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
if (!initialized) {
|
||||
AdvancedPosition pos = keyframe.getValue();
|
||||
xCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getX()), true);
|
||||
yCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getY()), true);
|
||||
zCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getZ()), true);
|
||||
yaw = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getYaw()), true);
|
||||
pitch = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, -90d, 90d, RoundUtils.round2Decimals(pos.getPitch()), true);
|
||||
roll = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getRoll()), true);
|
||||
|
||||
posInputs = new ComposedElement(xCoord, yCoord, zCoord, yaw, pitch, roll);
|
||||
inputs.addPart(posInputs);
|
||||
|
||||
KeyframeValueChangeListener listener = new KeyframeValueChangeListener(this) {
|
||||
@Override
|
||||
public void onValueChange(double value) {
|
||||
keyframe.setValue(new AdvancedPosition(xCoord.getPreciseValue(), yCoord.getPreciseValue(),
|
||||
zCoord.getPreciseValue(), new Float(pitch.getPreciseValue()), (float) yaw.getPreciseValue(),
|
||||
(float) roll.getPreciseValue()));
|
||||
|
||||
super.onValueChange(value);
|
||||
}
|
||||
};
|
||||
|
||||
xCoord.addValueChangeListener(listener);
|
||||
yCoord.addValueChangeListener(listener);
|
||||
zCoord.addValueChangeListener(listener);
|
||||
pitch.addValueChangeListener(listener);
|
||||
yaw.addValueChangeListener(listener);
|
||||
roll.addValueChangeListener(listener);
|
||||
}
|
||||
|
||||
int w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
||||
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.ypos")),
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.zpos"))));
|
||||
w2 = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camyaw")),
|
||||
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")),
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camroll"))));
|
||||
|
||||
totalWidth = w +100+w2+100+5+5+10;
|
||||
left = (this.width - totalWidth)/2;
|
||||
|
||||
int x = w + left + 5;
|
||||
int i = 0;
|
||||
for(GuiElement input : posInputs.getParts()) {
|
||||
if(input instanceof GuiTextField) {
|
||||
GuiTextField textField = (GuiTextField)input;
|
||||
textField.xPosition = i < 3 ? x : left+totalWidth-100;
|
||||
textField.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawScreen0() {
|
||||
if (keyframe.getValue() instanceof SpectatorData) return;
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.xpos"), left, virtualY + 27, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.ypos"), left, virtualY + 57, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.zpos"), left, virtualY + 87, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camyaw"), left + totalWidth - 100 - 5 - w2, virtualY + 27, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.campitch"), left + totalWidth - 100 - 5 - w2, virtualY + 57, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camroll"), left + totalWidth - 100 - 5 - w2, virtualY + 87, Color.WHITE.getRGB());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class GuiEditKeyframeSpectator extends GuiEditKeyframe<AdvancedPosition> {
|
||||
private GuiToggleButton perspectiveButton;
|
||||
|
||||
private GuiString shoulderDistanceString, shoulderPitchString, shoulderYawString, shoulderSmoothnessString;
|
||||
private GuiDraggingNumberInput shoulderDistanceInput, shoulderPitchOffsetInput,
|
||||
shoulderYawOffsetInput, shoulderSmoothnessInput;
|
||||
|
||||
private ComposedElement spectatorCamSettings;
|
||||
private ComposedElement shoulderCamSettings;
|
||||
|
||||
private DelegatingElement perspectiveSettings = new DelegatingElement() {
|
||||
@Override
|
||||
public GuiElement delegate() {
|
||||
switch(perspectiveButton.getValue()) {
|
||||
case 0:
|
||||
return spectatorCamSettings;
|
||||
case 1:
|
||||
return shoulderCamSettings;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public GuiEditKeyframeSpectator(Keyframe<AdvancedPosition> keyframe) {
|
||||
super(keyframe, ReplayHandler.getPositionKeyframes());
|
||||
screenTitle = I18n.format("replaymod.gui.editkeyframe.title.spec");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
if (!initialized) {
|
||||
SpectatorData data = (SpectatorData)keyframe.getValue();
|
||||
|
||||
perspectiveButton = new GuiToggleButton(0, 0, 0, 200, 20, I18n.format("replaymod.gui.editkeyframe.spec.method")+": ", new String[]{
|
||||
I18n.format("replaymod.gui.editkeyframe.spec.method.firstperson"),
|
||||
I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder")});
|
||||
|
||||
perspectiveButton.setValue(Arrays.asList(SpectatorData.SpectatingMethod.values()).indexOf(data.getSpectatingMethod()));
|
||||
|
||||
spectatorCamSettings = new ComposedElement();
|
||||
|
||||
//create elements in shoulderCamSettings
|
||||
shoulderDistanceString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.distance"));
|
||||
shoulderPitchString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.pitch"));
|
||||
shoulderYawString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.yaw"));
|
||||
shoulderSmoothnessString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.smoothness"));
|
||||
|
||||
shoulderDistanceInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, 0d, 30d, data.getThirdPersonInfo().shoulderCamDistance, true, "", 0.1);
|
||||
shoulderPitchOffsetInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, -90d, 90d, data.getThirdPersonInfo().shoulderCamPitchOffset, false, "°", 1);
|
||||
shoulderYawOffsetInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, null, null, data.getThirdPersonInfo().shoulderCamYawOffset, false, "°", 1);
|
||||
shoulderSmoothnessInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, 0.1d, 3d, data.getThirdPersonInfo().shoulderCamSmoothness, true, "", 0.1);
|
||||
|
||||
shoulderCamSettings = new ComposedElement(
|
||||
shoulderDistanceString, shoulderDistanceInput,
|
||||
shoulderPitchString, shoulderPitchOffsetInput,
|
||||
shoulderYawString, shoulderYawOffsetInput,
|
||||
shoulderSmoothnessString, shoulderSmoothnessInput);
|
||||
|
||||
inputs.addPart(new ComposedElement(perspectiveButton, perspectiveSettings));
|
||||
}
|
||||
|
||||
perspectiveButton.xPosition = (this.width-perspectiveButton.width())/2;
|
||||
perspectiveButton.yPosition = this.virtualY + 20;
|
||||
|
||||
int verticalSpacing = 20 + 5;
|
||||
int totalWidth = 300;
|
||||
int elementWidth = 145;
|
||||
int horizontalSpacing = 10;
|
||||
|
||||
int y = perspectiveButton.yPos() + verticalSpacing;
|
||||
|
||||
int i = 0;
|
||||
for(GuiElement el : shoulderCamSettings.getParts()) {
|
||||
el.xPos((width-totalWidth)/2 + (i%2)*(elementWidth + horizontalSpacing));
|
||||
el.width(elementWidth);
|
||||
|
||||
el.yPos(y + ((i+1)%2)*7);
|
||||
|
||||
if(i%2 == 1) {
|
||||
y += verticalSpacing;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
SpectatorData data = (SpectatorData)keyframe.getValue();
|
||||
data.setSpectatingMethod(SpectatorData.SpectatingMethod.values()[perspectiveButton.getValue()]);
|
||||
data.getThirdPersonInfo().shoulderCamDistance = shoulderDistanceInput.getPreciseValue();
|
||||
data.getThirdPersonInfo().shoulderCamPitchOffset = shoulderPitchOffsetInput.getIntValue();
|
||||
data.getThirdPersonInfo().shoulderCamYawOffset = shoulderYawOffsetInput.getIntValue();
|
||||
data.getThirdPersonInfo().shoulderCamSmoothness = shoulderSmoothnessInput.getPreciseValue();
|
||||
super.onGuiClosed();
|
||||
}
|
||||
}
|
||||
|
||||
private static class KeyframeValueChangeListener implements NumberValueChangeListener {
|
||||
|
||||
private GuiEditKeyframe parent;
|
||||
|
||||
public KeyframeValueChangeListener(GuiEditKeyframe parent) {
|
||||
this.parent = parent;
|
||||
|
||||
parent.min.addValueChangeListener(this);
|
||||
parent.sec.addValueChangeListener(this);
|
||||
parent.ms.addValueChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChange(double value) {
|
||||
int realTimestamp = TimestampUtils.calculateTimestamp(parent.min.getIntValue(), parent.sec.getIntValue(), parent.ms.getIntValue());
|
||||
parent.keyframe.setRealTimestamp(realTimestamp);
|
||||
|
||||
ReplayHandler.fireKeyframesModifyEvent();
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
// private static class GuiEditKeyframeMarker extends GuiEditKeyframe<Marker> {
|
||||
// private GuiAdvancedTextField markerNameInput;
|
||||
//
|
||||
// public GuiEditKeyframeMarker(Keyframe<Marker> keyframe) {
|
||||
// super(keyframe, ReplayHandler.getMarkerKeyframes());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui() {
|
||||
// super.initGui();
|
||||
//
|
||||
// if (!initialized) {
|
||||
// String name = keyframe.getValue().getName();
|
||||
// if (name == null) name = "";
|
||||
// markerNameInput = new GuiAdvancedTextField(fontRendererObj, 0, 0, 200, 20);
|
||||
// markerNameInput.hint = I18n.format("replaymod.gui.editkeyframe.markername");
|
||||
// markerNameInput.setText(name);
|
||||
//
|
||||
// inputs.addPart(markerNameInput);
|
||||
//
|
||||
// new KeyframeValueChangeListener(this);
|
||||
// }
|
||||
//
|
||||
// markerNameInput.xPosition = width/2 - 100;
|
||||
// markerNameInput.yPosition = height/2-10;
|
||||
//
|
||||
// initialized = true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onGuiClosed() {
|
||||
// keyframe.getValue().setName(markerNameInput.getText().trim());
|
||||
// super.onGuiClosed();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class GuiEditKeyframeTime extends GuiEditKeyframe<TimestampValue> {
|
||||
// private GuiNumberInput kfMin, kfSec, kfMs;
|
||||
//
|
||||
// public GuiEditKeyframeTime(Keyframe<TimestampValue> keyframe) {
|
||||
// super(keyframe, ReplayHandler.getTimeKeyframes());
|
||||
// screenTitle = I18n.format("replaymod.gui.editkeyframe.title.time");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui() {
|
||||
// super.initGui();
|
||||
//
|
||||
// if (!initialized) {
|
||||
// int time = keyframe.getValue().asInt();
|
||||
//
|
||||
// kfMin = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 30, 0d, null, (double)TimestampUtils.timestampToWholeMinutes(time), false, "", 1);
|
||||
// kfSec = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 25, 0d, 59d, (double)TimestampUtils.getSecondsFromTimestamp(time), false, "", 1);
|
||||
// kfMs = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 35, 0d, 999d, (double)TimestampUtils.getMillisecondsFromTimestamp(time), false, "", 1);
|
||||
//
|
||||
// inputs.addPart(kfMin);
|
||||
// inputs.addPart(kfSec);
|
||||
// inputs.addPart(kfMs);
|
||||
//
|
||||
// KeyframeValueChangeListener listener = new KeyframeValueChangeListener(this) {
|
||||
// @Override
|
||||
// public void onValueChange(double value) {
|
||||
// keyframe.setValue(new TimestampValue(TimestampUtils.calculateTimestamp(
|
||||
// kfMin.getIntValue(), kfSec.getIntValue(), kfMs.getIntValue())));
|
||||
//
|
||||
// super.onValueChange(value);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// kfMin.addValueChangeListener(listener);
|
||||
// kfSec.addValueChangeListener(listener);
|
||||
// kfMs.addValueChangeListener(listener);
|
||||
// }
|
||||
//
|
||||
// kfMin.xPosition = min.xPosition;
|
||||
// kfSec.xPosition = sec.xPosition;
|
||||
// kfMs.xPosition = ms.xPosition;
|
||||
//
|
||||
// kfMin.yPosition = kfSec.yPosition = kfMs.yPosition = min.yPosition - 10 - 20;
|
||||
//
|
||||
// initialized = true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void drawScreen0() {
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.timestamp")+":", (width-w3)/2, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.minutes"), kfMin.xPosition + kfMin.width + 5, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.seconds"), kfSec.xPosition + kfSec.width + 5, kfSec.yPosition + 7, Color.WHITE.getRGB());
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.milliseconds"), kfMs.xPosition + kfMs.width + 5, kfMs.yPosition + 7, Color.WHITE.getRGB());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private static class GuiEditKeyframePosition extends GuiEditKeyframe<AdvancedPosition> {
|
||||
// private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
||||
// private ComposedElement posInputs;
|
||||
//
|
||||
// public GuiEditKeyframePosition(Keyframe<AdvancedPosition> keyframe) {
|
||||
// super(keyframe, ReplayHandler.getPositionKeyframes());
|
||||
// screenTitle = I18n.format("replaymod.gui.editkeyframe.title.pos");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui() {
|
||||
// super.initGui();
|
||||
//
|
||||
// if (!initialized) {
|
||||
// AdvancedPosition pos = keyframe.getValue();
|
||||
// xCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getX()), true);
|
||||
// yCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getY()), true);
|
||||
// zCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getZ()), true);
|
||||
// yaw = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getYaw()), true);
|
||||
// pitch = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, -90d, 90d, RoundUtils.round2Decimals(pos.getPitch()), true);
|
||||
// roll = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getRoll()), true);
|
||||
//
|
||||
// posInputs = new ComposedElement(xCoord, yCoord, zCoord, yaw, pitch, roll);
|
||||
// inputs.addPart(posInputs);
|
||||
//
|
||||
// KeyframeValueChangeListener listener = new KeyframeValueChangeListener(this) {
|
||||
// @Override
|
||||
// public void onValueChange(double value) {
|
||||
// keyframe.setValue(new AdvancedPosition(xCoord.getPreciseValue(), yCoord.getPreciseValue(),
|
||||
// zCoord.getPreciseValue(), new Float(pitch.getPreciseValue()), (float) yaw.getPreciseValue(),
|
||||
// (float) roll.getPreciseValue()));
|
||||
//
|
||||
// super.onValueChange(value);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// xCoord.addValueChangeListener(listener);
|
||||
// yCoord.addValueChangeListener(listener);
|
||||
// zCoord.addValueChangeListener(listener);
|
||||
// pitch.addValueChangeListener(listener);
|
||||
// yaw.addValueChangeListener(listener);
|
||||
// roll.addValueChangeListener(listener);
|
||||
// }
|
||||
//
|
||||
// int w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
||||
// Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.ypos")),
|
||||
// fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.zpos"))));
|
||||
// w2 = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camyaw")),
|
||||
// Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")),
|
||||
// fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camroll"))));
|
||||
//
|
||||
// totalWidth = w +100+w2+100+5+5+10;
|
||||
// left = (this.width - totalWidth)/2;
|
||||
//
|
||||
// int x = w + left + 5;
|
||||
// int i = 0;
|
||||
// for(GuiElement input : posInputs.getParts()) {
|
||||
// if(input instanceof GuiTextField) {
|
||||
// GuiTextField textField = (GuiTextField)input;
|
||||
// textField.xPosition = i < 3 ? x : left+totalWidth-100;
|
||||
// textField.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
|
||||
// i++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// initialized = true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void drawScreen0() {
|
||||
// if (keyframe.getValue() instanceof SpectatorData) return;
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.xpos"), left, virtualY + 27, Color.WHITE.getRGB());
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.ypos"), left, virtualY + 57, Color.WHITE.getRGB());
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.zpos"), left, virtualY + 87, Color.WHITE.getRGB());
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camyaw"), left + totalWidth - 100 - 5 - w2, virtualY + 27, Color.WHITE.getRGB());
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.campitch"), left + totalWidth - 100 - 5 - w2, virtualY + 57, Color.WHITE.getRGB());
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camroll"), left + totalWidth - 100 - 5 - w2, virtualY + 87, Color.WHITE.getRGB());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private static class GuiEditKeyframeSpectator extends GuiEditKeyframe<AdvancedPosition> {
|
||||
// private GuiToggleButton perspectiveButton;
|
||||
//
|
||||
// private GuiString shoulderDistanceString, shoulderPitchString, shoulderYawString, shoulderSmoothnessString;
|
||||
// private GuiDraggingNumberInput shoulderDistanceInput, shoulderPitchOffsetInput,
|
||||
// shoulderYawOffsetInput, shoulderSmoothnessInput;
|
||||
//
|
||||
// private ComposedElement spectatorCamSettings;
|
||||
// private ComposedElement shoulderCamSettings;
|
||||
//
|
||||
// private DelegatingElement perspectiveSettings = new DelegatingElement() {
|
||||
// @Override
|
||||
// public GuiElement delegate() {
|
||||
// switch(perspectiveButton.getValue()) {
|
||||
// case 0:
|
||||
// return spectatorCamSettings;
|
||||
// case 1:
|
||||
// return shoulderCamSettings;
|
||||
// default:
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// public GuiEditKeyframeSpectator(Keyframe<AdvancedPosition> keyframe) {
|
||||
// super(keyframe, ReplayHandler.getPositionKeyframes());
|
||||
// screenTitle = I18n.format("replaymod.gui.editkeyframe.title.spec");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui() {
|
||||
// super.initGui();
|
||||
//
|
||||
// if (!initialized) {
|
||||
// SpectatorData data = (SpectatorData)keyframe.getValue();
|
||||
//
|
||||
// perspectiveButton = new GuiToggleButton(0, 0, 0, 200, 20, I18n.format("replaymod.gui.editkeyframe.spec.method")+": ", new String[]{
|
||||
// I18n.format("replaymod.gui.editkeyframe.spec.method.firstperson"),
|
||||
// I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder")});
|
||||
//
|
||||
// perspectiveButton.setValue(Arrays.asList(SpectatorData.SpectatingMethod.values()).indexOf(data.getSpectatingMethod()));
|
||||
//
|
||||
// spectatorCamSettings = new ComposedElement();
|
||||
//
|
||||
// //create elements in shoulderCamSettings
|
||||
// shoulderDistanceString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.distance"));
|
||||
// shoulderPitchString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.pitch"));
|
||||
// shoulderYawString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.yaw"));
|
||||
// shoulderSmoothnessString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.smoothness"));
|
||||
//
|
||||
// shoulderDistanceInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, 0d, 30d, data.getThirdPersonInfo().shoulderCamDistance, true, "", 0.1);
|
||||
// shoulderPitchOffsetInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, -90d, 90d, data.getThirdPersonInfo().shoulderCamPitchOffset, false, "°", 1);
|
||||
// shoulderYawOffsetInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, null, null, data.getThirdPersonInfo().shoulderCamYawOffset, false, "°", 1);
|
||||
// shoulderSmoothnessInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, 0.1d, 3d, data.getThirdPersonInfo().shoulderCamSmoothness, true, "", 0.1);
|
||||
//
|
||||
// shoulderCamSettings = new ComposedElement(
|
||||
// shoulderDistanceString, shoulderDistanceInput,
|
||||
// shoulderPitchString, shoulderPitchOffsetInput,
|
||||
// shoulderYawString, shoulderYawOffsetInput,
|
||||
// shoulderSmoothnessString, shoulderSmoothnessInput);
|
||||
//
|
||||
// inputs.addPart(new ComposedElement(perspectiveButton, perspectiveSettings));
|
||||
// }
|
||||
//
|
||||
// perspectiveButton.xPosition = (this.width-perspectiveButton.width())/2;
|
||||
// perspectiveButton.yPosition = this.virtualY + 20;
|
||||
//
|
||||
// int verticalSpacing = 20 + 5;
|
||||
// int totalWidth = 300;
|
||||
// int elementWidth = 145;
|
||||
// int horizontalSpacing = 10;
|
||||
//
|
||||
// int y = perspectiveButton.yPos() + verticalSpacing;
|
||||
//
|
||||
// int i = 0;
|
||||
// for(GuiElement el : shoulderCamSettings.getParts()) {
|
||||
// el.xPos((width-totalWidth)/2 + (i%2)*(elementWidth + horizontalSpacing));
|
||||
// el.width(elementWidth);
|
||||
//
|
||||
// el.yPos(y + ((i+1)%2)*7);
|
||||
//
|
||||
// if(i%2 == 1) {
|
||||
// y += verticalSpacing;
|
||||
// }
|
||||
// i++;
|
||||
// }
|
||||
//
|
||||
// initialized = true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onGuiClosed() {
|
||||
// SpectatorData data = (SpectatorData)keyframe.getValue();
|
||||
// data.setSpectatingMethod(SpectatorData.SpectatingMethod.values()[perspectiveButton.getValue()]);
|
||||
// data.getThirdPersonInfo().shoulderCamDistance = shoulderDistanceInput.getPreciseValue();
|
||||
// data.getThirdPersonInfo().shoulderCamPitchOffset = shoulderPitchOffsetInput.getIntValue();
|
||||
// data.getThirdPersonInfo().shoulderCamYawOffset = shoulderYawOffsetInput.getIntValue();
|
||||
// data.getThirdPersonInfo().shoulderCamSmoothness = shoulderSmoothnessInput.getPreciseValue();
|
||||
// super.onGuiClosed();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class KeyframeValueChangeListener implements NumberValueChangeListener {
|
||||
//
|
||||
// private GuiEditKeyframe parent;
|
||||
//
|
||||
// public KeyframeValueChangeListener(GuiEditKeyframe parent) {
|
||||
// this.parent = parent;
|
||||
//
|
||||
// parent.min.addValueChangeListener(this);
|
||||
// parent.sec.addValueChangeListener(this);
|
||||
// parent.ms.addValueChangeListener(this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onValueChange(double value) {
|
||||
// int realTimestamp = TimestampUtils.calculateTimestamp(parent.min.getIntValue(), parent.sec.getIntValue(), parent.ms.getIntValue());
|
||||
// parent.keyframe.setRealTimestamp(realTimestamp);
|
||||
//
|
||||
// ReplayHandler.fireKeyframesModifyEvent();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiEntryList;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
||||
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
import eu.crushedpixel.replaymod.holders.KeyframeSet;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.CameraPathValidator;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -22,7 +18,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiKeyframeRepository extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
||||
public class GuiKeyframeRepository extends GuiScreen {
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
@@ -133,39 +129,40 @@ public class GuiKeyframeRepository extends GuiScreen implements GuiReplayOverlay
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button) {
|
||||
if(!button.enabled) return;
|
||||
switch(button.id) {
|
||||
case GuiConstants.KEYFRAME_REPOSITORY_ADD_BUTTON:
|
||||
List<Keyframe> kfs = new ArrayList<Keyframe>(ReplayHandler.getAllKeyframes());
|
||||
|
||||
Keyframe[] keyframes = kfs.toArray(new Keyframe[ReplayHandler.getAllKeyframes().size()]);
|
||||
KeyframeSet newSet = new KeyframeSet(I18n.format("replaymod.gui.keyframerepository.preset.defaultname"), keyframes, ReplayHandler.getCustomImageObjects());
|
||||
|
||||
try {
|
||||
CameraPathValidator.validateCameraPath(ReplayHandler.getPositionKeyframes(), ReplayHandler.getTimeKeyframes());
|
||||
} catch(CameraPathValidator.InvalidCameraPathException e) {
|
||||
message = e.getLocalizedMessage();
|
||||
break;
|
||||
}
|
||||
|
||||
if(keyframeSetList.getCopyOfElements().contains(newSet)) {
|
||||
message = I18n.format("replaymod.gui.keyframerepository.duplicate");
|
||||
break;
|
||||
}
|
||||
message = null;
|
||||
|
||||
keyframeSetList.addElement(newSet);
|
||||
keyframeSetList.setSelectionIndex(keyframeSetList.getEntryCount()-1);
|
||||
break;
|
||||
case GuiConstants.KEYFRAME_REPOSITORY_REMOVE_BUTTON:
|
||||
keyframeSetList.removeElement(keyframeSetList.getSelectionIndex());
|
||||
break;
|
||||
case GuiConstants.KEYFRAME_REPOSITORY_LOAD_BUTTON:
|
||||
ReplayHandler.useKeyframePreset(keyframeSetList.getElement(keyframeSetList.getSelectionIndex()));
|
||||
saveOnQuit();
|
||||
mc.displayGuiScreen(null);
|
||||
break;
|
||||
}
|
||||
// TODO
|
||||
// if(!button.enabled) return;
|
||||
// switch(button.id) {
|
||||
// case GuiConstants.KEYFRAME_REPOSITORY_ADD_BUTTON:
|
||||
// List<Keyframe> kfs = new ArrayList<Keyframe>(ReplayHandler.getAllKeyframes());
|
||||
//
|
||||
// Keyframe[] keyframes = kfs.toArray(new Keyframe[ReplayHandler.getAllKeyframes().size()]);
|
||||
// KeyframeSet newSet = new KeyframeSet(I18n.format("replaymod.gui.keyframerepository.preset.defaultname"), keyframes, ReplayHandler.getCustomImageObjects());
|
||||
//
|
||||
// try {
|
||||
// CameraPathValidator.validateCameraPath(ReplayHandler.getPositionKeyframes(), ReplayHandler.getTimeKeyframes());
|
||||
// } catch(CameraPathValidator.InvalidCameraPathException e) {
|
||||
// message = e.getLocalizedMessage();
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// if(keyframeSetList.getCopyOfElements().contains(newSet)) {
|
||||
// message = I18n.format("replaymod.gui.keyframerepository.duplicate");
|
||||
// break;
|
||||
// }
|
||||
// message = null;
|
||||
//
|
||||
// keyframeSetList.addElement(newSet);
|
||||
// keyframeSetList.setSelectionIndex(keyframeSetList.getEntryCount()-1);
|
||||
// break;
|
||||
// case GuiConstants.KEYFRAME_REPOSITORY_REMOVE_BUTTON:
|
||||
// keyframeSetList.removeElement(keyframeSetList.getSelectionIndex());
|
||||
// break;
|
||||
// case GuiConstants.KEYFRAME_REPOSITORY_LOAD_BUTTON:
|
||||
// ReplayHandler.useKeyframePreset(keyframeSetList.getElement(keyframeSetList.getSelectionIndex()));
|
||||
// saveOnQuit();
|
||||
// mc.displayGuiScreen(null);
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,7 +238,8 @@ public class GuiKeyframeRepository extends GuiScreen implements GuiReplayOverlay
|
||||
if(initialKeyframeSets.equals(copy)) return;
|
||||
|
||||
this.keyframeRepository = copy.toArray(new KeyframeSet[copy.size()]);
|
||||
ReplayHandler.setKeyframeRepository(keyframeRepository, true);
|
||||
// TODO
|
||||
// ReplayHandler.setKeyframeRepository(keyframeRepository, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiMouseInput extends GuiScreen {
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private final GuiReplayOverlay overlay;
|
||||
|
||||
private boolean shouldClose = false;
|
||||
|
||||
public GuiMouseInput(GuiReplayOverlay overlay) {
|
||||
this.overlay = overlay;
|
||||
Mouse.setGrabbed(false);
|
||||
Mouse.setCursorPosition(mc.displayWidth/2, mc.displayHeight/2);
|
||||
|
||||
if(mc.currentScreen instanceof GuiMouseInput) {
|
||||
shouldClose = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
if(shouldClose) mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
overlay.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
overlay.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
overlay.mouseDrag(mouseX, mouseY, clickedMouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
ReplayMod.overlay.closeToolbar();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,347 +1,314 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import com.mojang.realmsclient.util.Pair;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||
import eu.crushedpixel.replaymod.holders.PlayerVisibility;
|
||||
import eu.crushedpixel.replaymod.registry.PlayerHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.utils.SkinProvider;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
||||
public class GuiPlayerOverview extends GuiScreen {
|
||||
|
||||
public static boolean defaultSave = false;
|
||||
|
||||
private List<Pair<EntityPlayer, ResourceLocation>> players;
|
||||
private List<GuiCheckBox> checkBoxes;
|
||||
|
||||
private GuiCheckBox hideAllBox, showAllBox;
|
||||
private GuiCheckBox rememberHidden;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
private int playerCount;
|
||||
private int upperPlayer = 0;
|
||||
|
||||
private int lowerBound;
|
||||
|
||||
private boolean drag = false;
|
||||
private int lastY = 0;
|
||||
private int fitting = 0;
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private final String screenTitle = I18n.format("replaymod.input.playeroverview");
|
||||
|
||||
private final Set<UUID> initialHiddenPlayers;
|
||||
|
||||
public GuiPlayerOverview(List<EntityPlayer> players) {
|
||||
initialHiddenPlayers = new HashSet<UUID>(PlayerHandler.getHiddenPlayers());
|
||||
|
||||
Collections.sort(players, new PlayerComparator());
|
||||
|
||||
this.players = new ArrayList<Pair<EntityPlayer, ResourceLocation>>();
|
||||
this.checkBoxes = new ArrayList<GuiCheckBox>();
|
||||
|
||||
for(final EntityPlayer p : players) {
|
||||
final ResourceLocation loc = SkinProvider.getResourceLocationForPlayerUUID(p.getUniqueID());
|
||||
this.players.add(Pair.of(p, loc));
|
||||
}
|
||||
|
||||
playerCount = players.size();
|
||||
|
||||
ReplayMod.replaySender.setReplaySpeed(0);
|
||||
}
|
||||
|
||||
private boolean isSpectator(EntityPlayer e) {
|
||||
return e.isInvisible() && e.getActivePotionEffect(Potion.invisibility) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
throws IOException {
|
||||
|
||||
if(fitting < playerCount) {
|
||||
float visiblePerc = (float) fitting / (float) playerCount;
|
||||
|
||||
int h = this.height - 32 - 32;
|
||||
int offset = Math.round((upperPlayer / (fitting)) * visiblePerc * h);
|
||||
|
||||
int lower = Math.round(32 + offset + (h * visiblePerc)) - 2;
|
||||
|
||||
int k2 = (int) (this.width * 0.3);
|
||||
|
||||
if(mouseX >= k2 - 16 && mouseX <= k2 - 12 && mouseY >= 32 - 2 + offset && mouseY <= lower) {
|
||||
lastY = mouseY;
|
||||
drag = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
int k2 = (int) (this.width * 0.3);
|
||||
|
||||
if(mouseX >= k2 && mouseX <= (this.width * 0.6) && mouseY >= upperBound && mouseY <= lowerBound) {
|
||||
int off = mouseY - upperBound;
|
||||
int p = (off / 21) + upperPlayer;
|
||||
ReplayHandler.spectateEntity(players.get(p).first());
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY,
|
||||
int clickedMouseButton, long timeSinceLastClick) {
|
||||
|
||||
if(drag) {
|
||||
float step = 1f / (float) playerCount;
|
||||
|
||||
int diff = mouseY - lastY;
|
||||
int h = this.height - 32 - 32;
|
||||
|
||||
float percDiff = (float) diff / (float) h;
|
||||
if(Math.abs(percDiff) > Math.abs(step)) {
|
||||
int s = (int) (percDiff / step);
|
||||
lastY = mouseY;
|
||||
upperPlayer += s;
|
||||
if(upperPlayer > playerCount - fitting) {
|
||||
upperPlayer = playerCount - fitting;
|
||||
} else if(upperPlayer < 0) {
|
||||
upperPlayer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
drag = false;
|
||||
|
||||
for(GuiCheckBox checkBox : checkBoxes) {
|
||||
checkBox.mouseReleased(mouseX, mouseY);
|
||||
}
|
||||
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
upperPlayer = 0;
|
||||
lowerBound = this.height - 10;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
|
||||
int i = 0;
|
||||
for(GuiCheckBox checkBox : checkBoxes) {
|
||||
checkBox.xPosition = (int)(this.width*0.7)-5;
|
||||
buttonList.add(checkBox);
|
||||
i++;
|
||||
if(i >= fitting) break;
|
||||
}
|
||||
|
||||
if(!initialized) {
|
||||
hideAllBox = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_HIDE_ALL, 0, 0, "", false);
|
||||
showAllBox = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_SHOW_ALL, 0, 0, "", true);
|
||||
rememberHidden = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_REMEMBER, 0, 0, I18n.format("replaymod.gui.playeroverview.remembersettings"), defaultSave);
|
||||
}
|
||||
|
||||
hideAllBox.xPosition = (int)(this.width*0.7)-5;
|
||||
showAllBox.xPosition = (int)(this.width*0.7)-20;
|
||||
hideAllBox.yPosition = showAllBox.yPosition = 45;
|
||||
|
||||
rememberHidden.xPosition = (int)(this.width*0.3);
|
||||
rememberHidden.yPosition = 45;
|
||||
|
||||
buttonList.add(hideAllBox);
|
||||
buttonList.add(showAllBox);
|
||||
buttonList.add(rememberHidden);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
if(button == showAllBox) {
|
||||
showAllBox.setIsChecked(true);
|
||||
for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
||||
PlayerHandler.showPlayer(p.first());
|
||||
}
|
||||
} else if(button == hideAllBox) {
|
||||
hideAllBox.setIsChecked(false);
|
||||
for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
||||
PlayerHandler.hidePlayer(p.first());
|
||||
}
|
||||
}
|
||||
|
||||
if(!(button instanceof GuiCheckBox)) return;
|
||||
if(button.id >= fitting) return;
|
||||
if(!checkBoxes.contains(button)) return;
|
||||
PlayerHandler.setIsVisible(players.get(upperPlayer + button.id).first(), ((GuiCheckBox)button).isChecked());
|
||||
}
|
||||
|
||||
private static final int upperBound = 65;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawCenteredString(fontRendererObj, screenTitle, this.width / 2, 5, Color.WHITE.getRGB());
|
||||
int k2 = (int)(this.width * 0.3);
|
||||
int l2 = upperBound;
|
||||
|
||||
drawGradientRect(k2 - 20, 20, (int) (this.width * 0.7) + 20, this.height - 30 - 2 + 10, -1072689136, -804253680);
|
||||
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.playeroverview.spectate"), k2 - 10, 30, Color.WHITE.getRGB());
|
||||
|
||||
String visibleString = I18n.format("replaymod.gui.playeroverview.visible");
|
||||
drawString(fontRendererObj, visibleString, (int) (this.width * 0.7) + 10 - fontRendererObj.getStringWidth(visibleString), 30, Color.WHITE.getRGB());
|
||||
|
||||
fitting = 0;
|
||||
|
||||
int sk = 0;
|
||||
for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
||||
if(sk < upperPlayer) {
|
||||
sk++;
|
||||
continue;
|
||||
}
|
||||
boolean spec = isSpectator(p.first());
|
||||
|
||||
this.drawString(fontRendererObj, p.first().getName(), k2 + 16 + 5, l2 + 8 - (fontRendererObj.FONT_HEIGHT / 2),
|
||||
spec ? Color.DARK_GRAY.getRGB() : Color.WHITE.getRGB());
|
||||
|
||||
mc.getTextureManager().bindTexture(p.second());
|
||||
|
||||
drawScaledCustomSizeModalRect(k2, l2, 8.0F, 8.0F, 8, 8, 16, 16, 64.0F, 64.0F);
|
||||
if(p.first().func_175148_a(EnumPlayerModelParts.HAT))
|
||||
Gui.drawScaledCustomSizeModalRect(k2, l2, 40.0F, 8.0F, 8, 8, 16, 16, 64.0F, 64.0F);
|
||||
|
||||
GlStateManager.resetColor();
|
||||
if(fitting >= checkBoxes.size()) {
|
||||
checkBoxes.add(new GuiCheckBox(checkBoxes.size(), (int)(this.width*0.7)-5, l2+3, "", true));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
buttonList.add(checkBoxes.get(checkBoxes.size() - 1));
|
||||
}
|
||||
checkBoxes.get(fitting).setIsChecked(!PlayerHandler.isHidden(p.first().getUniqueID()));
|
||||
|
||||
l2 += 16 + 5;
|
||||
fitting++;
|
||||
if(l2 + 32 > lowerBound) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int dw = Mouse.getDWheel();
|
||||
if(dw > 0) {
|
||||
dw = -1;
|
||||
} else if(dw < 0) {
|
||||
dw = 1;
|
||||
}
|
||||
|
||||
upperPlayer = Math.max(Math.min(upperPlayer + dw, playerCount - fitting), 0);
|
||||
|
||||
if(fitting < playerCount) {
|
||||
float visiblePerc = ((float) fitting) / playerCount;
|
||||
int barHeight = (int) (visiblePerc * (height - 32 - 32));
|
||||
|
||||
float posPerc = ((float) upperPlayer) / playerCount;
|
||||
int barY = (int) (posPerc * (height - 32 - 32));
|
||||
|
||||
drawRect(k2 - 18, upperBound - 2, k2 - 10, this.height - 30 - 2, Color.BLACK.getRGB());
|
||||
drawRect(k2 - 16, upperBound+2 - 2 + barY, k2 - 12, 30+2 - 1 + barY + barHeight, Color.LIGHT_GRAY.getRGB());
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for(GuiCheckBox checkBox : checkBoxes) {
|
||||
checkBox.drawButton(mc, mouseX, mouseY);
|
||||
i++;
|
||||
if(i >= fitting) break;
|
||||
}
|
||||
|
||||
hideAllBox.drawButton(mc, mouseX, mouseY);
|
||||
showAllBox.drawButton(mc, mouseX, mouseY);
|
||||
rememberHidden.drawButton(mc, mouseX, mouseY);
|
||||
|
||||
if(hideAllBox.isMouseOver()) {
|
||||
ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.hideall"), this, Color.WHITE);
|
||||
}
|
||||
|
||||
if(showAllBox.isMouseOver()) {
|
||||
ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.showall"), this, Color.WHITE);
|
||||
}
|
||||
|
||||
if(rememberHidden.isMouseOver()) {
|
||||
ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.remembersettings.description"), this, Color.WHITE);
|
||||
}
|
||||
|
||||
//this is necessary to reset the GL parameters for further GUI rendering
|
||||
GlStateManager.enableBlend();
|
||||
}
|
||||
|
||||
private PlayerVisibility getVisibilityInstance() {
|
||||
Set<UUID> hidden = PlayerHandler.getHiddenPlayers();
|
||||
return new PlayerVisibility(hidden.toArray(new UUID[hidden.size()]));
|
||||
}
|
||||
|
||||
|
||||
private void saveOnQuit() {
|
||||
if(rememberHidden.isChecked()) {
|
||||
if(initialHiddenPlayers.equals(PlayerHandler.getHiddenPlayers())) return;
|
||||
try {
|
||||
File f = File.createTempFile(ReplayFile.ENTRY_VISIBILITY, "json");
|
||||
ReplayFileIO.write(getVisibilityInstance(), f);
|
||||
ReplayMod.replayFileAppender.registerModifiedFile(f, ReplayFile.ENTRY_VISIBILITY, ReplayHandler.getReplayFile());
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if(initialHiddenPlayers.isEmpty()) return;
|
||||
ReplayMod.replayFileAppender.registerModifiedFile(null, ReplayFile.ENTRY_VISIBILITY, ReplayHandler.getReplayFile());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if(keyCode == Keyboard.KEY_ESCAPE) {
|
||||
saveOnQuit();
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
private class PlayerComparator implements Comparator<EntityPlayer> {
|
||||
|
||||
@Override
|
||||
public int compare(EntityPlayer o1, EntityPlayer o2) {
|
||||
if(isSpectator(o1) && !isSpectator(o2)) {
|
||||
return 1;
|
||||
} else if(isSpectator(o2) && !isSpectator(o1)) {
|
||||
return -1;
|
||||
} else {
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// private List<Pair<EntityPlayer, ResourceLocation>> players;
|
||||
// private List<GuiCheckBox> checkBoxes;
|
||||
//
|
||||
// private GuiCheckBox hideAllBox, showAllBox;
|
||||
// private GuiCheckBox rememberHidden;
|
||||
//
|
||||
// private boolean initialized = false;
|
||||
//
|
||||
// private int playerCount;
|
||||
// private int upperPlayer = 0;
|
||||
//
|
||||
// private int lowerBound;
|
||||
//
|
||||
// private boolean drag = false;
|
||||
// private int lastY = 0;
|
||||
// private int fitting = 0;
|
||||
//
|
||||
// private final Minecraft mc = Minecraft.getMinecraft();
|
||||
//
|
||||
// private final String screenTitle = I18n.format("replaymod.input.playeroverview");
|
||||
//
|
||||
// private final Set<UUID> initialHiddenPlayers;
|
||||
//
|
||||
// public GuiPlayerOverview(List<EntityPlayer> players) {
|
||||
// initialHiddenPlayers = new HashSet<UUID>(PlayerHandler.getHiddenPlayers());
|
||||
//
|
||||
// Collections.sort(players, new PlayerComparator());
|
||||
//
|
||||
// this.players = new ArrayList<Pair<EntityPlayer, ResourceLocation>>();
|
||||
// this.checkBoxes = new ArrayList<GuiCheckBox>();
|
||||
//
|
||||
// for(final EntityPlayer p : players) {
|
||||
// final ResourceLocation loc = SkinProvider.getResourceLocationForPlayerUUID(p.getUniqueID());
|
||||
// this.players.add(Pair.of(p, loc));
|
||||
// }
|
||||
//
|
||||
// playerCount = players.size();
|
||||
//
|
||||
// ReplayMod.replaySender.setReplaySpeed(0);
|
||||
// }
|
||||
//
|
||||
// private boolean isSpectator(EntityPlayer e) {
|
||||
// return e.isInvisible() && e.getActivePotionEffect(Potion.invisibility) == null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
||||
// throws IOException {
|
||||
//
|
||||
// if(fitting < playerCount) {
|
||||
// float visiblePerc = (float) fitting / (float) playerCount;
|
||||
//
|
||||
// int h = this.height - 32 - 32;
|
||||
// int offset = Math.round((upperPlayer / (fitting)) * visiblePerc * h);
|
||||
//
|
||||
// int lower = Math.round(32 + offset + (h * visiblePerc)) - 2;
|
||||
//
|
||||
// int k2 = (int) (this.width * 0.3);
|
||||
//
|
||||
// if(mouseX >= k2 - 16 && mouseX <= k2 - 12 && mouseY >= 32 - 2 + offset && mouseY <= lower) {
|
||||
// lastY = mouseY;
|
||||
// drag = true;
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// int k2 = (int) (this.width * 0.3);
|
||||
//
|
||||
// if(mouseX >= k2 && mouseX <= (this.width * 0.6) && mouseY >= upperBound && mouseY <= lowerBound) {
|
||||
// int off = mouseY - upperBound;
|
||||
// int p = (off / 21) + upperPlayer;
|
||||
// // TODO
|
||||
//// ReplayHandler.spectateEntity(players.get(p).first());
|
||||
// mc.displayGuiScreen(null);
|
||||
// }
|
||||
//
|
||||
// super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void mouseClickMove(int mouseX, int mouseY,
|
||||
// int clickedMouseButton, long timeSinceLastClick) {
|
||||
//
|
||||
// if(drag) {
|
||||
// float step = 1f / (float) playerCount;
|
||||
//
|
||||
// int diff = mouseY - lastY;
|
||||
// int h = this.height - 32 - 32;
|
||||
//
|
||||
// float percDiff = (float) diff / (float) h;
|
||||
// if(Math.abs(percDiff) > Math.abs(step)) {
|
||||
// int s = (int) (percDiff / step);
|
||||
// lastY = mouseY;
|
||||
// upperPlayer += s;
|
||||
// if(upperPlayer > playerCount - fitting) {
|
||||
// upperPlayer = playerCount - fitting;
|
||||
// } else if(upperPlayer < 0) {
|
||||
// upperPlayer = 0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
// drag = false;
|
||||
//
|
||||
// for(GuiCheckBox checkBox : checkBoxes) {
|
||||
// checkBox.mouseReleased(mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
// super.mouseReleased(mouseX, mouseY, state);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void initGui() {
|
||||
// upperPlayer = 0;
|
||||
// lowerBound = this.height - 10;
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// List<GuiButton> buttonList = this.buttonList;
|
||||
//
|
||||
// int i = 0;
|
||||
// for(GuiCheckBox checkBox : checkBoxes) {
|
||||
// checkBox.xPosition = (int)(this.width*0.7)-5;
|
||||
// buttonList.add(checkBox);
|
||||
// i++;
|
||||
// if(i >= fitting) break;
|
||||
// }
|
||||
//
|
||||
// if(!initialized) {
|
||||
// hideAllBox = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_HIDE_ALL, 0, 0, "", false);
|
||||
// showAllBox = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_SHOW_ALL, 0, 0, "", true);
|
||||
// rememberHidden = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_REMEMBER, 0, 0, I18n.format("replaymod.gui.playeroverview.remembersettings"), defaultSave);
|
||||
// }
|
||||
//
|
||||
// hideAllBox.xPosition = (int)(this.width*0.7)-5;
|
||||
// showAllBox.xPosition = (int)(this.width*0.7)-20;
|
||||
// hideAllBox.yPosition = showAllBox.yPosition = 45;
|
||||
//
|
||||
// rememberHidden.xPosition = (int)(this.width*0.3);
|
||||
// rememberHidden.yPosition = 45;
|
||||
//
|
||||
// buttonList.add(hideAllBox);
|
||||
// buttonList.add(showAllBox);
|
||||
// buttonList.add(rememberHidden);
|
||||
//
|
||||
// initialized = true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void actionPerformed(GuiButton button) throws IOException {
|
||||
// if(button == showAllBox) {
|
||||
// showAllBox.setIsChecked(true);
|
||||
// for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
||||
// PlayerHandler.showPlayer(p.first());
|
||||
// }
|
||||
// } else if(button == hideAllBox) {
|
||||
// hideAllBox.setIsChecked(false);
|
||||
// for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
||||
// PlayerHandler.hidePlayer(p.first());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(!(button instanceof GuiCheckBox)) return;
|
||||
// if(button.id >= fitting) return;
|
||||
// if(!checkBoxes.contains(button)) return;
|
||||
// PlayerHandler.setIsVisible(players.get(upperPlayer + button.id).first(), ((GuiCheckBox)button).isChecked());
|
||||
// }
|
||||
//
|
||||
// private static final int upperBound = 65;
|
||||
//
|
||||
// @Override
|
||||
// public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
// this.drawCenteredString(fontRendererObj, screenTitle, this.width / 2, 5, Color.WHITE.getRGB());
|
||||
// int k2 = (int)(this.width * 0.3);
|
||||
// int l2 = upperBound;
|
||||
//
|
||||
// drawGradientRect(k2 - 20, 20, (int) (this.width * 0.7) + 20, this.height - 30 - 2 + 10, -1072689136, -804253680);
|
||||
//
|
||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.playeroverview.spectate"), k2 - 10, 30, Color.WHITE.getRGB());
|
||||
//
|
||||
// String visibleString = I18n.format("replaymod.gui.playeroverview.visible");
|
||||
// drawString(fontRendererObj, visibleString, (int) (this.width * 0.7) + 10 - fontRendererObj.getStringWidth(visibleString), 30, Color.WHITE.getRGB());
|
||||
//
|
||||
// fitting = 0;
|
||||
//
|
||||
// int sk = 0;
|
||||
// for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
||||
// if(sk < upperPlayer) {
|
||||
// sk++;
|
||||
// continue;
|
||||
// }
|
||||
// boolean spec = isSpectator(p.first());
|
||||
//
|
||||
// this.drawString(fontRendererObj, p.first().getName(), k2 + 16 + 5, l2 + 8 - (fontRendererObj.FONT_HEIGHT / 2),
|
||||
// spec ? Color.DARK_GRAY.getRGB() : Color.WHITE.getRGB());
|
||||
//
|
||||
// mc.getTextureManager().bindTexture(p.second());
|
||||
//
|
||||
// drawScaledCustomSizeModalRect(k2, l2, 8.0F, 8.0F, 8, 8, 16, 16, 64.0F, 64.0F);
|
||||
// if(p.first().func_175148_a(EnumPlayerModelParts.HAT))
|
||||
// Gui.drawScaledCustomSizeModalRect(k2, l2, 40.0F, 8.0F, 8, 8, 16, 16, 64.0F, 64.0F);
|
||||
//
|
||||
// GlStateManager.resetColor();
|
||||
// if(fitting >= checkBoxes.size()) {
|
||||
// checkBoxes.add(new GuiCheckBox(checkBoxes.size(), (int)(this.width*0.7)-5, l2+3, "", true));
|
||||
// @SuppressWarnings("unchecked")
|
||||
// List<GuiButton> buttonList = this.buttonList;
|
||||
// buttonList.add(checkBoxes.get(checkBoxes.size() - 1));
|
||||
// }
|
||||
// checkBoxes.get(fitting).setIsChecked(!PlayerHandler.isHidden(p.first().getUniqueID()));
|
||||
//
|
||||
// l2 += 16 + 5;
|
||||
// fitting++;
|
||||
// if(l2 + 32 > lowerBound) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int dw = Mouse.getDWheel();
|
||||
// if(dw > 0) {
|
||||
// dw = -1;
|
||||
// } else if(dw < 0) {
|
||||
// dw = 1;
|
||||
// }
|
||||
//
|
||||
// upperPlayer = Math.max(Math.min(upperPlayer + dw, playerCount - fitting), 0);
|
||||
//
|
||||
// if(fitting < playerCount) {
|
||||
// float visiblePerc = ((float) fitting) / playerCount;
|
||||
// int barHeight = (int) (visiblePerc * (height - 32 - 32));
|
||||
//
|
||||
// float posPerc = ((float) upperPlayer) / playerCount;
|
||||
// int barY = (int) (posPerc * (height - 32 - 32));
|
||||
//
|
||||
// drawRect(k2 - 18, upperBound - 2, k2 - 10, this.height - 30 - 2, Color.BLACK.getRGB());
|
||||
// drawRect(k2 - 16, upperBound+2 - 2 + barY, k2 - 12, 30+2 - 1 + barY + barHeight, Color.LIGHT_GRAY.getRGB());
|
||||
// }
|
||||
//
|
||||
// int i = 0;
|
||||
// for(GuiCheckBox checkBox : checkBoxes) {
|
||||
// checkBox.drawButton(mc, mouseX, mouseY);
|
||||
// i++;
|
||||
// if(i >= fitting) break;
|
||||
// }
|
||||
//
|
||||
// hideAllBox.drawButton(mc, mouseX, mouseY);
|
||||
// showAllBox.drawButton(mc, mouseX, mouseY);
|
||||
// rememberHidden.drawButton(mc, mouseX, mouseY);
|
||||
//
|
||||
// if(hideAllBox.isMouseOver()) {
|
||||
// ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.hideall"), this, Color.WHITE);
|
||||
// }
|
||||
//
|
||||
// if(showAllBox.isMouseOver()) {
|
||||
// ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.showall"), this, Color.WHITE);
|
||||
// }
|
||||
//
|
||||
// if(rememberHidden.isMouseOver()) {
|
||||
// ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.remembersettings.description"), this, Color.WHITE);
|
||||
// }
|
||||
//
|
||||
// //this is necessary to reset the GL parameters for further GUI rendering
|
||||
// GlStateManager.enableBlend();
|
||||
// }
|
||||
//
|
||||
// private void saveOnQuit() {
|
||||
// try {
|
||||
// // TODO
|
||||
//// if(rememberHidden.isChecked()) {
|
||||
//// if(initialHiddenPlayers.equals(PlayerHandler.getHiddenPlayers())) return;
|
||||
//// ReplayHandler.getReplayFile().writeInvisiblePlayers(PlayerHandler.getHiddenPlayers());
|
||||
//// } else {
|
||||
//// if(initialHiddenPlayers.isEmpty()) return;
|
||||
//// ReplayHandler.getReplayFile().writeInvisiblePlayers(Collections.<UUID>emptySet());
|
||||
//// }
|
||||
// } catch(Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
// if(keyCode == Keyboard.KEY_ESCAPE) {
|
||||
// saveOnQuit();
|
||||
// super.keyTyped(typedChar, keyCode);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private class PlayerComparator implements Comparator<EntityPlayer> {
|
||||
//
|
||||
// @Override
|
||||
// public int compare(EntityPlayer o1, EntityPlayer o2) {
|
||||
// if(isSpectator(o1) && !isSpectator(o2)) {
|
||||
// return 1;
|
||||
// } else if(isSpectator(o2) && !isSpectator(o1)) {
|
||||
// return -1;
|
||||
// } else {
|
||||
// return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.CheckBoxListener;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
||||
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.settings.EncodingPreset;
|
||||
import eu.crushedpixel.replaymod.settings.RenderOptions;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
@@ -29,7 +27,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
||||
public class GuiRenderSettings extends GuiScreen {
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@@ -542,7 +540,8 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
if(FMLClientHandler.instance().hasOptifine()) {
|
||||
mc.displayGuiScreen(new GuiErrorScreen(I18n.format("replaymod.gui.rendering.error.title"), I18n.format("replaymod.gui.rendering.error.optifine")));
|
||||
} else {
|
||||
ReplayHandler.startPath(options, true);
|
||||
// TODO
|
||||
// ReplayHandler.startPath(options, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiSettingsOnOffButton;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiToggleButton;
|
||||
import eu.crushedpixel.replaymod.settings.ReplaySettings.RecordingOptions;
|
||||
import eu.crushedpixel.replaymod.settings.ReplaySettings.ReplayOptions;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -12,8 +10,6 @@ import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import static eu.crushedpixel.replaymod.gui.GuiConstants.*;
|
||||
|
||||
public class GuiReplaySettings extends GuiScreen {
|
||||
protected String screenTitle = I18n.format("replaymod.gui.settings.title");
|
||||
private GuiScreen parentGuiScreen;
|
||||
@@ -38,23 +34,23 @@ public class GuiReplaySettings extends GuiScreen {
|
||||
|
||||
int xPos = this.width / 2 - 155 + i % 2 * 160;
|
||||
int yPos = this.height / 6 + 24 * (i >> 1);
|
||||
|
||||
if(o == RecordingOptions.notifications) {
|
||||
GuiToggleButton sendChatButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_SEND_CHAT, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(sendChatButton);
|
||||
|
||||
} else if(o == RecordingOptions.recordServer) {
|
||||
GuiToggleButton recordServerButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSERVER_ID, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(recordServerButton);
|
||||
|
||||
} else if(o == RecordingOptions.recordSingleplayer) {
|
||||
GuiToggleButton recordSPButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSP_ID, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(recordSPButton);
|
||||
|
||||
} else if(o == RecordingOptions.indicator) {
|
||||
GuiToggleButton showIndicatorButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_INDICATOR_ID, xPos, yPos, 150, 20, o);
|
||||
buttonList.add(showIndicatorButton);
|
||||
}
|
||||
// TODO
|
||||
// if(o == RecordingOptions.notifications) {
|
||||
// GuiToggleButton sendChatButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_SEND_CHAT, xPos, yPos, 150, 20, o);
|
||||
// buttonList.add(sendChatButton);
|
||||
//
|
||||
// } else if(o == RecordingOptions.recordServer) {
|
||||
// GuiToggleButton recordServerButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSERVER_ID, xPos, yPos, 150, 20, o);
|
||||
// buttonList.add(recordServerButton);
|
||||
//
|
||||
// } else if(o == RecordingOptions.recordSingleplayer) {
|
||||
// GuiToggleButton recordSPButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSP_ID, xPos, yPos, 150, 20, o);
|
||||
// buttonList.add(recordSPButton);
|
||||
//
|
||||
// } else if(o == RecordingOptions.indicator) {
|
||||
// GuiToggleButton showIndicatorButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_INDICATOR_ID, xPos, yPos, 150, 20, o);
|
||||
// buttonList.add(showIndicatorButton);
|
||||
// }
|
||||
|
||||
++i;
|
||||
}
|
||||
@@ -69,14 +65,15 @@ public class GuiReplaySettings extends GuiScreen {
|
||||
int xPos = this.width / 2 - 155 + i % 2 * 160;
|
||||
int yPos = this.height / 6 + 24 * (i >> 1);
|
||||
|
||||
if(o == ReplayOptions.linear) {
|
||||
GuiToggleButton linearButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_FORCE_LINEAR, xPos, yPos, 150, 20, o,
|
||||
I18n.format("replaymod.gui.settings.interpolation.linear"), I18n.format("replaymod.gui.settings.interpolation.cubic"));
|
||||
buttonList.add(linearButton);
|
||||
|
||||
} else {
|
||||
buttonList.add(new GuiSettingsOnOffButton(0, xPos, yPos, 150, 20, o));
|
||||
}
|
||||
// TODO
|
||||
// if(o == ReplayOptions.linear) {
|
||||
// GuiToggleButton linearButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_FORCE_LINEAR, xPos, yPos, 150, 20, o,
|
||||
// I18n.format("replaymod.gui.settings.interpolation.linear"), I18n.format("replaymod.gui.settings.interpolation.cubic"));
|
||||
// buttonList.add(linearButton);
|
||||
//
|
||||
// } else {
|
||||
// buttonList.add(new GuiSettingsOnOffButton(0, xPos, yPos, 150, 20, o));
|
||||
// }
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiAdvancedButton;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
|
||||
public class GuiReplaySpeedSlider extends GuiAdvancedButton {
|
||||
|
||||
@@ -74,7 +73,7 @@ public class GuiReplaySpeedSlider extends GuiAdvancedButton {
|
||||
l = packedFGColour;
|
||||
} else if(!this.enabled) {
|
||||
l = 10526880;
|
||||
} else if(this.hovered && FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class)) {
|
||||
} else if(this.hovered) {
|
||||
l = 16777120;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.CheckBoxListener;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements;
|
||||
|
||||
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||
import eu.crushedpixel.replaymod.utils.OpenGLUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import static com.replaymod.core.ReplayMod.TEXTURE;
|
||||
|
||||
public class GuiArrowButton extends GuiAdvancedButton {
|
||||
|
||||
private static final int TEXTURE_X = 40;
|
||||
@@ -42,7 +43,7 @@ public class GuiArrowButton extends GuiAdvancedButton {
|
||||
try {
|
||||
super.draw(mc, mouseX, mouseY, hovering);
|
||||
|
||||
mc.getTextureManager().bindTexture(GuiReplayOverlay.replay_gui);
|
||||
mc.getTextureManager().bindTexture(TEXTURE);
|
||||
|
||||
OpenGLUtils.drawRotatedRectWithCustomSizedTexture(xPosition+4, yPosition+4, dir.getRotation(),
|
||||
TEXTURE_X, TEXTURE_Y, TEXTURE_WIDTH, TEXTURE_HEIGHT, 128, 128);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
|
||||
@@ -6,8 +6,8 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import static eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay.TEXTURE_SIZE;
|
||||
import static eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay.replay_gui;
|
||||
import static com.replaymod.core.ReplayMod.TEXTURE;
|
||||
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class GuiScrollbar extends Gui implements GuiElement {
|
||||
@Override
|
||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
||||
GlStateManager.resetColor();
|
||||
mc.renderEngine.bindTexture(replay_gui);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
// Background
|
||||
@@ -157,7 +157,7 @@ public class GuiScrollbar extends Gui implements GuiElement {
|
||||
if(!enabled) {
|
||||
GlStateManager.color(Color.GRAY.getRed()/255f, Color.GRAY.getGreen()/255f, Color.GRAY.getBlue()/255f, 1f);
|
||||
}
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(replay_gui);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
drawModalRectWithCustomSizedTexture(x, y, u, v, width, height, TEXTURE_SIZE, TEXTURE_SIZE);
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.settings.ReplaySettings;
|
||||
import com.replaymod.core.SettingsRegistry;
|
||||
|
||||
public class GuiSettingsOnOffButton extends GuiOnOffButton {
|
||||
|
||||
private ReplaySettings.ValueEnum toChange;
|
||||
private SettingsRegistry settingsRegistry;
|
||||
private SettingsRegistry.SettingKey<Boolean> toChange;
|
||||
|
||||
public GuiSettingsOnOffButton(int buttonId, int x, int y, int width, int height, ReplaySettings.ValueEnum toChange) {
|
||||
super(buttonId, x, y, width, height, toChange.getName()+": ");
|
||||
public GuiSettingsOnOffButton(int buttonId, int x, int y, int width, int height, SettingsRegistry settingsRegistry,
|
||||
SettingsRegistry.SettingKey<Boolean> toChange) {
|
||||
super(buttonId, x, y, width, height, toChange.getDisplayString()+": ");
|
||||
this.settingsRegistry = settingsRegistry;
|
||||
this.toChange = toChange;
|
||||
if(toChange.getValue() instanceof Boolean) {
|
||||
this.setValue((Boolean) toChange.getValue() ? 0 : 1);
|
||||
}
|
||||
this.setValue(settingsRegistry.get(toChange) ? 0 : 1);
|
||||
}
|
||||
|
||||
public GuiSettingsOnOffButton(int buttonId, int x, int y, int width, int height, ReplaySettings.ValueEnum toChange, String onValue, String offValue) {
|
||||
super(buttonId, x, y, width, height, toChange.getName()+": ", onValue, offValue);
|
||||
public GuiSettingsOnOffButton(int buttonId, int x, int y, int width, int height, SettingsRegistry settingsRegistry,
|
||||
SettingsRegistry.SettingKey<Boolean> toChange, String onValue, String offValue) {
|
||||
super(buttonId, x, y, width, height, toChange.getDisplayString()+": ", onValue, offValue);
|
||||
this.settingsRegistry = settingsRegistry;
|
||||
this.toChange = toChange;
|
||||
if(toChange.getValue() instanceof Boolean) {
|
||||
this.setValue((Boolean) toChange.getValue() ? 0 : 1);
|
||||
}
|
||||
this.setValue(settingsRegistry.get(toChange) ? 0 : 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggle() {
|
||||
super.toggle();
|
||||
toChange.setValue(isOn());
|
||||
ReplayMod.replaySettings.rewriteSettings();
|
||||
settingsRegistry.set(toChange, isOn());
|
||||
settingsRegistry.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
super.setValue(value);
|
||||
toChange.setValue(isOn());
|
||||
ReplayMod.replaySettings.rewriteSettings();
|
||||
settingsRegistry.set(toChange, isOn());
|
||||
settingsRegistry.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements.timelines;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.GuiEditKeyframe;
|
||||
import eu.crushedpixel.replaymod.holders.*;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import java.util.ListIterator;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
|
||||
public class GuiKeyframeTimeline extends GuiTimeline {
|
||||
private static final int KEYFRAME_PLACE_X = 74;
|
||||
@@ -31,230 +24,231 @@ public class GuiKeyframeTimeline extends GuiTimeline {
|
||||
this.placeKeyframes = showPlaceKeyframes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
if(!enabled) return false;
|
||||
|
||||
long time = getTimeAt(mouseX, mouseY);
|
||||
if(time == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
||||
|
||||
Keyframe closest;
|
||||
if(mouseY >= positionY + BORDER_TOP + 5 && timeKeyframes) {
|
||||
closest = ReplayHandler.getTimeKeyframes().getClosestKeyframeForTimestamp((int) time, tolerance);
|
||||
} else if(mouseY >= positionY + BORDER_TOP && placeKeyframes) {
|
||||
closest = ReplayHandler.getPositionKeyframes().getClosestKeyframeForTimestamp((int) time, tolerance);
|
||||
} else {
|
||||
closest = null;
|
||||
}
|
||||
|
||||
//left mouse button
|
||||
if(button == 0) {
|
||||
ReplayHandler.selectKeyframe(closest); //can be null, deselects keyframe
|
||||
|
||||
// If we clicked on a key frame, then continue monitoring the mouse for movements
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if(closest != null) {
|
||||
if(currentTime - clickTime < 500) { // if double clicked then open GUI instead
|
||||
mc.displayGuiScreen(GuiEditKeyframe.create(closest));
|
||||
this.clickedKeyFrame = null;
|
||||
} else {
|
||||
this.clickedKeyFrame = closest;
|
||||
this.dragging = false;
|
||||
}
|
||||
} else { // If we didn't then just update the cursor
|
||||
ReplayHandler.setRealTimelineCursor((int) time);
|
||||
this.dragging = true;
|
||||
}
|
||||
this.clickTime = currentTime;
|
||||
|
||||
} else if(button == 1) {
|
||||
if(closest != null) {
|
||||
if(closest.getValue() instanceof AdvancedPosition) {
|
||||
AdvancedPosition pos = (AdvancedPosition)closest.getValue();
|
||||
ReplayHandler.getCameraEntity().movePath(pos);
|
||||
} else if(closest.getValue() instanceof TimestampValue) {
|
||||
ReplayMod.overlay.performJump(((TimestampValue)closest.getValue()).asInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isHovering(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
if(!enabled) return;
|
||||
long time = getTimeAt(mouseX, mouseY);
|
||||
if (time != -1) {
|
||||
if (clickedKeyFrame != null) {
|
||||
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
||||
|
||||
if (dragging || Math.abs(clickedKeyFrame.getRealTimestamp() - time) > tolerance) {
|
||||
clickedKeyFrame.setRealTimestamp((int) time);
|
||||
ReplayHandler.getPositionKeyframes().sort();
|
||||
ReplayHandler.getTimeKeyframes().sort();
|
||||
dragging = true;
|
||||
}
|
||||
} else if (dragging) {
|
||||
ReplayHandler.setRealTimelineCursor((int) time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
mouseDrag(mc, mouseX, mouseY, button);
|
||||
clickedKeyFrame = null;
|
||||
dragging = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
||||
super.draw(mc, mouseX, mouseY);
|
||||
|
||||
int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
||||
|
||||
long leftTime = Math.round(timeStart * timelineLength);
|
||||
long rightTime = Math.round((timeStart + zoom) * timelineLength);
|
||||
|
||||
double segmentLength = timelineLength * zoom;
|
||||
|
||||
//iterate over keyframes to find spectator segments
|
||||
if(placeKeyframes) {
|
||||
ListIterator<Keyframe<AdvancedPosition>> iterator = ReplayHandler.getPositionKeyframes().listIterator();
|
||||
while(iterator.hasNext()) {
|
||||
Keyframe<AdvancedPosition> kf = iterator.next();
|
||||
|
||||
if(!(kf.getValue() instanceof SpectatorData))
|
||||
continue;
|
||||
|
||||
int i = iterator.nextIndex();
|
||||
int nextSpectatorKeyframeRealTime = -1;
|
||||
|
||||
if (iterator.hasNext()) {
|
||||
Keyframe<AdvancedPosition> kf2 = iterator.next();
|
||||
|
||||
if(kf2.getValue() instanceof SpectatorData) {
|
||||
SpectatorData spectatorData1 = (SpectatorData)kf.getValue();
|
||||
SpectatorData spectatorData2 = (SpectatorData)kf2.getValue();
|
||||
|
||||
if(spectatorData1.getSpectatedEntityID() == spectatorData2.getSpectatedEntityID()) {
|
||||
nextSpectatorKeyframeRealTime = kf2.getRealTimestamp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int i2 = iterator.previousIndex();
|
||||
|
||||
while(i2 >= i) {
|
||||
iterator.previous();
|
||||
i2--;
|
||||
}
|
||||
|
||||
if(nextSpectatorKeyframeRealTime != -1) {
|
||||
int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||
int nextX = getKeyframeX(nextSpectatorKeyframeRealTime, leftTime, bodyWidth, segmentLength);
|
||||
|
||||
int color = ((SpectatorData)kf.getValue()).getSpectatingMethod().getColor();
|
||||
|
||||
drawRect(Math.max(keyframeX + 2, positionX+BORDER_LEFT), positionY + BORDER_TOP + 1, Math.min(nextX - 2, positionX+width-BORDER_RIGHT+1),
|
||||
positionY + BORDER_TOP + 4, color);
|
||||
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//iterate over time keyframes to find negative replay speeds
|
||||
if(timeKeyframes) {
|
||||
ListIterator<Keyframe<TimestampValue>> iterator = ReplayHandler.getTimeKeyframes().listIterator();
|
||||
while(iterator.hasNext()) {
|
||||
Keyframe<TimestampValue> kf = iterator.next();
|
||||
|
||||
int i = iterator.nextIndex();
|
||||
int nextTimeKeyframeRealTime = -1;
|
||||
|
||||
if (iterator.hasNext()) {
|
||||
Keyframe<TimestampValue> kf2 = iterator.next();
|
||||
if(kf.getValue().asInt() > kf2.getValue().asInt()) {
|
||||
nextTimeKeyframeRealTime = kf2.getRealTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
int i2 = iterator.previousIndex();
|
||||
|
||||
while(i2 >= i) {
|
||||
iterator.previous();
|
||||
i2--;
|
||||
}
|
||||
|
||||
if(nextTimeKeyframeRealTime != -1) {
|
||||
int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||
int nextX = getKeyframeX(nextTimeKeyframeRealTime, leftTime, bodyWidth, segmentLength);
|
||||
|
||||
drawGradientRect(Math.max(keyframeX + 2, positionX+BORDER_LEFT), positionY + BORDER_TOP + 6, Math.min(nextX - 2, positionX+width-BORDER_RIGHT+1),
|
||||
positionY + BORDER_TOP + 9, 0xFFFF0000, 0xFFFF0000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawTimelineCursor(leftTime, rightTime, bodyWidth);
|
||||
|
||||
|
||||
//Draw Keyframe logos
|
||||
for (Keyframe kf : ReplayHandler.getAllKeyframes()) {
|
||||
if (kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
|
||||
drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
||||
}
|
||||
|
||||
if(ReplayHandler.getSelectedKeyframe() != null && !(ReplayHandler.getSelectedKeyframe().getValue() instanceof Marker)) {
|
||||
drawKeyframe(ReplayHandler.getSelectedKeyframe(), bodyWidth, leftTime, rightTime, segmentLength);
|
||||
}
|
||||
}
|
||||
|
||||
private int getKeyframeX(int timestamp, long leftTime, int bodyWidth, double segmentLength) {
|
||||
long positionInSegment = timestamp - leftTime;
|
||||
double fractionOfSegment = positionInSegment / segmentLength;
|
||||
return (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
||||
}
|
||||
|
||||
private void drawKeyframe(Keyframe kf, int bodyWidth, long leftTime, long rightTime, double segmentLength) {
|
||||
if (kf.getRealTimestamp() <= rightTime && kf.getRealTimestamp() >= leftTime) {
|
||||
int textureX;
|
||||
int textureY;
|
||||
int y = positionY;
|
||||
|
||||
int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||
|
||||
if(kf.getValue() instanceof AdvancedPosition) {
|
||||
if(!placeKeyframes) return;
|
||||
textureX = KEYFRAME_PLACE_X;
|
||||
textureY = KEYFRAME_PLACE_Y;
|
||||
y += 0;
|
||||
|
||||
//If Spectator Keyframe, use different texture
|
||||
if(kf.getValue() instanceof SpectatorData) {
|
||||
textureX = KEYFRAME_SPEC_X;
|
||||
textureY = KEYFRAME_SPEC_Y;
|
||||
}
|
||||
} else if(kf.getValue() instanceof TimestampValue) {
|
||||
if(!timeKeyframes) return;
|
||||
textureX = KEYFRAME_TIME_X;
|
||||
textureY = KEYFRAME_TIME_Y;
|
||||
y += 5;
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unknown keyframe type: " + kf.getClass());
|
||||
}
|
||||
|
||||
if (ReplayHandler.isSelected(kf)) {
|
||||
textureX += 5;
|
||||
}
|
||||
|
||||
rect(keyframeX - 2, y + BORDER_TOP, textureX, textureY, 5, 5);
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
// @Override
|
||||
// public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
// if(!enabled) return false;
|
||||
//
|
||||
// long time = getTimeAt(mouseX, mouseY);
|
||||
// if(time == -1) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
||||
//
|
||||
// Keyframe closest;
|
||||
// if(mouseY >= positionY + BORDER_TOP + 5 && timeKeyframes) {
|
||||
// closest = ReplayHandler.getTimeKeyframes().getClosestKeyframeForTimestamp((int) time, tolerance);
|
||||
// } else if(mouseY >= positionY + BORDER_TOP && placeKeyframes) {
|
||||
// closest = ReplayHandler.getPositionKeyframes().getClosestKeyframeForTimestamp((int) time, tolerance);
|
||||
// } else {
|
||||
// closest = null;
|
||||
// }
|
||||
//
|
||||
// //left mouse button
|
||||
// if(button == 0) {
|
||||
// ReplayHandler.selectKeyframe(closest); //can be null, deselects keyframe
|
||||
//
|
||||
// // If we clicked on a key frame, then continue monitoring the mouse for movements
|
||||
// long currentTime = System.currentTimeMillis();
|
||||
// if(closest != null) {
|
||||
// if(currentTime - clickTime < 500) { // if double clicked then open GUI instead
|
||||
// mc.displayGuiScreen(GuiEditKeyframe.create(closest));
|
||||
// this.clickedKeyFrame = null;
|
||||
// } else {
|
||||
// this.clickedKeyFrame = closest;
|
||||
// this.dragging = false;
|
||||
// }
|
||||
// } else { // If we didn't then just update the cursor
|
||||
// ReplayHandler.setRealTimelineCursor((int) time);
|
||||
// this.dragging = true;
|
||||
// }
|
||||
// this.clickTime = currentTime;
|
||||
//
|
||||
// } else if(button == 1) {
|
||||
// if(closest != null) {
|
||||
// if(closest.getValue() instanceof AdvancedPosition) {
|
||||
// AdvancedPosition pos = (AdvancedPosition)closest.getValue();
|
||||
// ReplayHandler.getCameraEntity().movePath(pos);
|
||||
// } else if(closest.getValue() instanceof TimestampValue) {
|
||||
// ReplayMod.overlay.performJump(((TimestampValue)closest.getValue()).asInt());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return isHovering(mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
// if(!enabled) return;
|
||||
// long time = getTimeAt(mouseX, mouseY);
|
||||
// if (time != -1) {
|
||||
// if (clickedKeyFrame != null) {
|
||||
// int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
||||
//
|
||||
// if (dragging || Math.abs(clickedKeyFrame.getRealTimestamp() - time) > tolerance) {
|
||||
// clickedKeyFrame.setRealTimestamp((int) time);
|
||||
// ReplayHandler.getPositionKeyframes().sort();
|
||||
// ReplayHandler.getTimeKeyframes().sort();
|
||||
// dragging = true;
|
||||
// }
|
||||
// } else if (dragging) {
|
||||
// ReplayHandler.setRealTimelineCursor((int) time);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
// mouseDrag(mc, mouseX, mouseY, button);
|
||||
// clickedKeyFrame = null;
|
||||
// dragging = false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void draw(Minecraft mc, int mouseX, int mouseY) {
|
||||
// super.draw(mc, mouseX, mouseY);
|
||||
//
|
||||
// int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
||||
//
|
||||
// long leftTime = Math.round(timeStart * timelineLength);
|
||||
// long rightTime = Math.round((timeStart + zoom) * timelineLength);
|
||||
//
|
||||
// double segmentLength = timelineLength * zoom;
|
||||
//
|
||||
// //iterate over keyframes to find spectator segments
|
||||
// if(placeKeyframes) {
|
||||
// ListIterator<Keyframe<AdvancedPosition>> iterator = ReplayHandler.getPositionKeyframes().listIterator();
|
||||
// while(iterator.hasNext()) {
|
||||
// Keyframe<AdvancedPosition> kf = iterator.next();
|
||||
//
|
||||
// if(!(kf.getValue() instanceof SpectatorData))
|
||||
// continue;
|
||||
//
|
||||
// int i = iterator.nextIndex();
|
||||
// int nextSpectatorKeyframeRealTime = -1;
|
||||
//
|
||||
// if (iterator.hasNext()) {
|
||||
// Keyframe<AdvancedPosition> kf2 = iterator.next();
|
||||
//
|
||||
// if(kf2.getValue() instanceof SpectatorData) {
|
||||
// SpectatorData spectatorData1 = (SpectatorData)kf.getValue();
|
||||
// SpectatorData spectatorData2 = (SpectatorData)kf2.getValue();
|
||||
//
|
||||
// if(spectatorData1.getSpectatedEntityID() == spectatorData2.getSpectatedEntityID()) {
|
||||
// nextSpectatorKeyframeRealTime = kf2.getRealTimestamp();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int i2 = iterator.previousIndex();
|
||||
//
|
||||
// while(i2 >= i) {
|
||||
// iterator.previous();
|
||||
// i2--;
|
||||
// }
|
||||
//
|
||||
// if(nextSpectatorKeyframeRealTime != -1) {
|
||||
// int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||
// int nextX = getKeyframeX(nextSpectatorKeyframeRealTime, leftTime, bodyWidth, segmentLength);
|
||||
//
|
||||
// int color = ((SpectatorData)kf.getValue()).getSpectatingMethod().getColor();
|
||||
//
|
||||
// drawRect(Math.max(keyframeX + 2, positionX+BORDER_LEFT), positionY + BORDER_TOP + 1, Math.min(nextX - 2, positionX+width-BORDER_RIGHT+1),
|
||||
// positionY + BORDER_TOP + 4, color);
|
||||
//
|
||||
// GlStateManager.color(1, 1, 1, 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //iterate over time keyframes to find negative replay speeds
|
||||
// if(timeKeyframes) {
|
||||
// ListIterator<Keyframe<TimestampValue>> iterator = ReplayHandler.getTimeKeyframes().listIterator();
|
||||
// while(iterator.hasNext()) {
|
||||
// Keyframe<TimestampValue> kf = iterator.next();
|
||||
//
|
||||
// int i = iterator.nextIndex();
|
||||
// int nextTimeKeyframeRealTime = -1;
|
||||
//
|
||||
// if (iterator.hasNext()) {
|
||||
// Keyframe<TimestampValue> kf2 = iterator.next();
|
||||
// if(kf.getValue().asInt() > kf2.getValue().asInt()) {
|
||||
// nextTimeKeyframeRealTime = kf2.getRealTimestamp();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int i2 = iterator.previousIndex();
|
||||
//
|
||||
// while(i2 >= i) {
|
||||
// iterator.previous();
|
||||
// i2--;
|
||||
// }
|
||||
//
|
||||
// if(nextTimeKeyframeRealTime != -1) {
|
||||
// int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||
// int nextX = getKeyframeX(nextTimeKeyframeRealTime, leftTime, bodyWidth, segmentLength);
|
||||
//
|
||||
// drawGradientRect(Math.max(keyframeX + 2, positionX+BORDER_LEFT), positionY + BORDER_TOP + 6, Math.min(nextX - 2, positionX+width-BORDER_RIGHT+1),
|
||||
// positionY + BORDER_TOP + 9, 0xFFFF0000, 0xFFFF0000);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// drawTimelineCursor(leftTime, rightTime, bodyWidth);
|
||||
//
|
||||
//
|
||||
// //Draw Keyframe logos
|
||||
// for (Keyframe kf : ReplayHandler.getAllKeyframes()) {
|
||||
// if (kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
|
||||
// drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
||||
// }
|
||||
//
|
||||
// if(ReplayHandler.getSelectedKeyframe() != null) {
|
||||
// drawKeyframe(ReplayHandler.getSelectedKeyframe(), bodyWidth, leftTime, rightTime, segmentLength);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private int getKeyframeX(int timestamp, long leftTime, int bodyWidth, double segmentLength) {
|
||||
// long positionInSegment = timestamp - leftTime;
|
||||
// double fractionOfSegment = positionInSegment / segmentLength;
|
||||
// return (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
||||
// }
|
||||
//
|
||||
// private void drawKeyframe(Keyframe kf, int bodyWidth, long leftTime, long rightTime, double segmentLength) {
|
||||
// if (kf.getRealTimestamp() <= rightTime && kf.getRealTimestamp() >= leftTime) {
|
||||
// int textureX;
|
||||
// int textureY;
|
||||
// int y = positionY;
|
||||
//
|
||||
// int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||
//
|
||||
// if(kf.getValue() instanceof AdvancedPosition) {
|
||||
// if(!placeKeyframes) return;
|
||||
// textureX = KEYFRAME_PLACE_X;
|
||||
// textureY = KEYFRAME_PLACE_Y;
|
||||
// y += 0;
|
||||
//
|
||||
// //If Spectator Keyframe, use different texture
|
||||
// if(kf.getValue() instanceof SpectatorData) {
|
||||
// textureX = KEYFRAME_SPEC_X;
|
||||
// textureY = KEYFRAME_SPEC_Y;
|
||||
// }
|
||||
// } else if(kf.getValue() instanceof TimestampValue) {
|
||||
// if(!timeKeyframes) return;
|
||||
// textureX = KEYFRAME_TIME_X;
|
||||
// textureY = KEYFRAME_TIME_Y;
|
||||
// y += 5;
|
||||
// } else {
|
||||
// throw new UnsupportedOperationException("Unknown keyframe type: " + kf.getClass());
|
||||
// }
|
||||
//
|
||||
// if (ReplayHandler.isSelected(kf)) {
|
||||
// textureX += 5;
|
||||
// }
|
||||
//
|
||||
// rect(keyframeX - 2, y + BORDER_TOP, textureX, textureY, 5, 5);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements.timelines;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.GuiEditKeyframe;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
import eu.crushedpixel.replaymod.holders.Marker;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class GuiMarkerTimeline extends GuiTimeline {
|
||||
private static final int KEYFRAME_MARKER_X = 109;
|
||||
private static final int KEYFRAME_MARKER_Y = 20;
|
||||
|
||||
private Keyframe<Marker> clickedKeyFrame;
|
||||
private long clickTime;
|
||||
private boolean dragging;
|
||||
|
||||
public GuiMarkerTimeline(int positionX, int positionY, int width, int height, boolean showMarkers) {
|
||||
super(positionX, positionY, width, height);
|
||||
this.showMarkers = showMarkers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
if(!enabled) return false;
|
||||
|
||||
long time = getTimeAt(mouseX, mouseY);
|
||||
if(time == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
||||
|
||||
Keyframe<Marker> closest = null;
|
||||
if(mouseY >= positionY + BORDER_TOP + 10) {
|
||||
closest = ReplayHandler.getMarkerKeyframes().getClosestKeyframeForTimestamp((int) time, tolerance);
|
||||
}
|
||||
|
||||
//left mouse button
|
||||
if(button == 0) {
|
||||
ReplayHandler.selectKeyframe(closest);
|
||||
|
||||
if(closest == null) { //if no keyframe clicked, jump in time
|
||||
ReplayMod.overlay.performJump(getTimeAt(mouseX, mouseY));
|
||||
} else {
|
||||
// If we clicked on a key frame, then continue monitoring the mouse for movements
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if(closest != null) {
|
||||
if(currentTime - clickTime < 500) { // if double clicked then open GUI instead
|
||||
mc.displayGuiScreen(GuiEditKeyframe.create(closest));
|
||||
this.clickedKeyFrame = null;
|
||||
} else {
|
||||
this.clickedKeyFrame = closest;
|
||||
this.dragging = false;
|
||||
}
|
||||
} else { // If we didn't then just update the cursor
|
||||
this.dragging = true;
|
||||
}
|
||||
this.clickTime = currentTime;
|
||||
}
|
||||
|
||||
} else if(button == 1) {
|
||||
if(closest != null) {
|
||||
//Jump to clicked Marker Keyframe (explicitly force to jump to this position)
|
||||
ReplayHandler.setLastPosition(closest.getValue().getPosition(), true);
|
||||
|
||||
//perform the jump, telling the Overlay not to override the last position value
|
||||
ReplayMod.overlay.performJump(closest.getRealTimestamp(), false);
|
||||
}
|
||||
}
|
||||
|
||||
return isHovering(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
if(!enabled) return;
|
||||
long time = getTimeAt(mouseX, mouseY);
|
||||
if (time != -1) {
|
||||
if (clickedKeyFrame != null) {
|
||||
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
||||
|
||||
if (dragging || Math.abs(clickedKeyFrame.getRealTimestamp() - time) > tolerance) {
|
||||
clickedKeyFrame.setRealTimestamp((int) time);
|
||||
dragging = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
|
||||
mouseDrag(mc, mouseX, mouseY, button);
|
||||
clickedKeyFrame = null;
|
||||
dragging = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
||||
super.draw(mc, mouseX, mouseY);
|
||||
|
||||
int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
||||
|
||||
long leftTime = Math.round(timeStart * timelineLength);
|
||||
long rightTime = Math.round((timeStart + zoom) * timelineLength);
|
||||
|
||||
double segmentLength = timelineLength * zoom;
|
||||
|
||||
drawTimelineCursor(leftTime, rightTime, bodyWidth);
|
||||
|
||||
//Draw Keyframe logos
|
||||
for(Keyframe<Marker> kf : ReplayHandler.getMarkerKeyframes()) {
|
||||
if (kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
|
||||
drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
||||
}
|
||||
|
||||
if(ReplayHandler.getSelectedKeyframe() != null && ReplayHandler.getSelectedKeyframe().getValue() instanceof Marker) {
|
||||
drawKeyframe(ReplayHandler.getSelectedKeyframe(), bodyWidth, leftTime, rightTime, segmentLength);
|
||||
}
|
||||
}
|
||||
|
||||
private int getKeyframeX(int timestamp, long leftTime, int bodyWidth, double segmentLength) {
|
||||
long positionInSegment = timestamp - leftTime;
|
||||
double fractionOfSegment = positionInSegment / segmentLength;
|
||||
return (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOverlay(Minecraft mc, int mouseX, int mouseY) {
|
||||
boolean drawn = false;
|
||||
|
||||
int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
||||
|
||||
long leftTime = Math.round(timeStart * timelineLength);
|
||||
double segmentLength = timelineLength * zoom;
|
||||
|
||||
for(Keyframe<Marker> marker : ReplayHandler.getMarkerKeyframes()) {
|
||||
int keyframeX = getKeyframeX(marker.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||
|
||||
if(MouseUtils.isMouseWithinBounds(keyframeX - 2, this.positionY + BORDER_TOP + 10 + 1, 5, 5)) {
|
||||
Point mouse = MouseUtils.getMousePos();
|
||||
String markerName = marker.getValue().getName();
|
||||
if(markerName == null || markerName.isEmpty()) markerName = I18n.format("replaymod.gui.ingame.unnamedmarker");
|
||||
ReplayMod.tooltipRenderer.drawTooltip(mouse.getX(), mouse.getY(), markerName, null, Color.WHITE);
|
||||
|
||||
drawn = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!drawn) {
|
||||
super.drawOverlay(mc, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawKeyframe(Keyframe kf, int bodyWidth, long leftTime, long rightTime, double segmentLength) {
|
||||
if (kf.getRealTimestamp() <= rightTime && kf.getRealTimestamp() >= leftTime) {
|
||||
int textureX = KEYFRAME_MARKER_X;
|
||||
int textureY = KEYFRAME_MARKER_Y;
|
||||
int y = positionY+10;
|
||||
|
||||
int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||
|
||||
if (ReplayHandler.isSelected(kf)) {
|
||||
textureX += 5;
|
||||
}
|
||||
|
||||
rect(keyframeX - 2, y + BORDER_TOP, textureX, textureY, 5, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui.elements.timelines;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiElement;
|
||||
import eu.crushedpixel.replaymod.utils.RoundUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -11,8 +11,8 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import static eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay.TEXTURE_SIZE;
|
||||
import static eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay.replay_gui;
|
||||
import static com.replaymod.core.ReplayMod.TEXTURE;
|
||||
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class GuiTimeline extends Gui implements GuiElement {
|
||||
* This draws the time at big markers above the timeline. Therefore extra space in negative y direction
|
||||
* should be kept empty if markers are desired.
|
||||
*/
|
||||
public boolean showMarkers;
|
||||
public boolean showMarkers; // TODO: Rename to not be confused with Marker
|
||||
|
||||
protected final int positionX;
|
||||
protected final int positionY;
|
||||
@@ -280,7 +280,7 @@ public class GuiTimeline extends Gui implements GuiElement {
|
||||
if(!enabled) {
|
||||
GlStateManager.color(Color.GRAY.getRed() / 255f, Color.GRAY.getGreen() / 255f, Color.GRAY.getBlue() / 255f, 1f);
|
||||
}
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(replay_gui);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
drawModalRectWithCustomSizedTexture(x, y, u, v, width, height, TEXTURE_SIZE, TEXTURE_SIZE);
|
||||
|
||||
@@ -6,7 +6,7 @@ import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||
import de.johni0702.minecraft.gui.element.GuiPasswordField;
|
||||
import de.johni0702.minecraft.gui.element.GuiTextField;
|
||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
|
||||
public class GuiLoginPrompt extends AbstractGuiScreen<GuiLoginPrompt> {
|
||||
|
||||
@@ -7,7 +7,7 @@ import de.johni0702.minecraft.gui.element.*;
|
||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.api.ApiException;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.utils.EmailAddressUtils;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui.online;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.api.replay.SearchQuery;
|
||||
import eu.crushedpixel.replaymod.api.replay.holders.Category;
|
||||
import eu.crushedpixel.replaymod.api.replay.holders.FileInfo;
|
||||
@@ -12,7 +12,6 @@ import eu.crushedpixel.replaymod.api.replay.pagination.Pagination;
|
||||
import eu.crushedpixel.replaymod.api.replay.pagination.SearchPagination;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||
import eu.crushedpixel.replaymod.holders.GuiEntryListStringEntry;
|
||||
import net.minecraft.client.gui.*;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -265,7 +264,8 @@ 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 GuiReplayViewer());
|
||||
// TODO
|
||||
// mc.displayGuiScreen(new GuiReplayViewer(mod));
|
||||
} else if(button.id == GuiConstants.CENTER_RECENT_BUTTON) {
|
||||
disableTopBarButton(button.id);
|
||||
showOnlineRecent();
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package eu.crushedpixel.replaymod.gui.online;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
||||
import de.johni0702.minecraft.gui.element.GuiButton;
|
||||
import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||
import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.api.replay.holders.FileInfo;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -49,7 +48,8 @@ public class GuiReplayDownloading extends AbstractGuiScreen<GuiReplayDownloading
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ReplayHandler.startReplay(replayFile);
|
||||
// TODO
|
||||
// ReplayHandler.startReplay(replayFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import eu.crushedpixel.replaymod.gui.elements.GuiAdvancedButton;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiDropdown;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiString;
|
||||
import eu.crushedpixel.replaymod.holders.GuiEntryListValueEntry;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -55,7 +53,7 @@ public class GuiReplayInstanceChooser extends GuiScreen {
|
||||
for(File file : files) {
|
||||
try {
|
||||
String extension = FilenameUtils.getExtension(file.getAbsolutePath());
|
||||
if(!("." + extension).equals(ReplayFile.ZIP_FILE_EXTENSION)) continue;
|
||||
if(!"zip".equals(extension)) continue;
|
||||
|
||||
String filename = FilenameUtils.getBaseName(file.getAbsolutePath());
|
||||
String[] split = filename.split("_");
|
||||
@@ -72,7 +70,8 @@ public class GuiReplayInstanceChooser extends GuiScreen {
|
||||
|
||||
//if no modified versions of the replay were found, start the downloaded one
|
||||
if(chooseableFiles.isEmpty()) {
|
||||
ReplayHandler.startReplay(downloadedFile);
|
||||
// TODO
|
||||
// ReplayHandler.startReplay(downloadedFile);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +102,8 @@ public class GuiReplayInstanceChooser extends GuiScreen {
|
||||
public void run() {
|
||||
try {
|
||||
File file = fileDropdown.getElement(fileDropdown.getSelectionIndex()).getValue();
|
||||
ReplayHandler.startReplay(file);
|
||||
//TODO
|
||||
// ReplayHandler.startReplay(file);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
package eu.crushedpixel.replaymod.gui.online;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.google.common.base.Optional;
|
||||
import de.johni0702.replaystudio.replay.ReplayFile;
|
||||
import de.johni0702.replaystudio.replay.ReplayMetaData;
|
||||
import de.johni0702.replaystudio.replay.ZipReplayFile;
|
||||
import de.johni0702.replaystudio.studio.ReplayStudio;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.api.replay.FileUploader;
|
||||
import eu.crushedpixel.replaymod.api.replay.holders.Category;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||
import com.replaymod.replay.gui.screen.GuiReplayViewer;
|
||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.utils.*;
|
||||
import eu.crushedpixel.replaymod.utils.ImageUtils;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import eu.crushedpixel.replaymod.utils.RegexUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -35,7 +41,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -84,15 +89,15 @@ public class GuiUploadFile extends GuiScreen implements ProgressUpdateListener {
|
||||
boolean correctFile = false;
|
||||
this.replayFile = file;
|
||||
|
||||
if(("." + FilenameUtils.getExtension(file.getAbsolutePath())).equals(ReplayFile.ZIP_FILE_EXTENSION)) {
|
||||
if(("." + FilenameUtils.getExtension(file.getAbsolutePath())).equals(".zip")) {
|
||||
ReplayFile archive = null;
|
||||
try {
|
||||
archive = new ReplayFile(file);
|
||||
archive = new ZipReplayFile(new ReplayStudio(), file);
|
||||
|
||||
metaData = archive.metadata().get();
|
||||
BufferedImage img = archive.thumb().get();
|
||||
if(img != null) {
|
||||
thumb = ImageUtils.scaleImage(img, new Dimension(1280, 720));
|
||||
metaData = archive.getMetaData();
|
||||
Optional<BufferedImage> img = archive.getThumb();
|
||||
if(img.isPresent()) {
|
||||
thumb = ImageUtils.scaleImage(img.get(), new Dimension(1280, 720));
|
||||
hasThumbnail = true;
|
||||
}
|
||||
|
||||
@@ -307,21 +312,15 @@ public class GuiUploadFile extends GuiScreen implements ProgressUpdateListener {
|
||||
|
||||
if(hideServerIP.isChecked()) {
|
||||
File tmp = File.createTempFile("replay_hidden_ip", "mcpr");
|
||||
File tmpMeta = File.createTempFile("metadata", "json");
|
||||
|
||||
ReplayMetaData newMetaData = metaData.copy();
|
||||
newMetaData.removeServer();
|
||||
ReplayFileIO.write(newMetaData, tmpMeta);
|
||||
|
||||
HashMap<String, File> toAdd = new HashMap<String, File>();
|
||||
toAdd.put(ReplayFile.ENTRY_METADATA, tmpMeta);
|
||||
|
||||
FileUtils.copyFile(replayFile, tmp);
|
||||
ReplayFileIO.addFilesToZip(tmp, toAdd);
|
||||
ReplayMetaData newMetaData = new ReplayMetaData(metaData);
|
||||
newMetaData.setServerName(null);
|
||||
ReplayFile replay = new ZipReplayFile(new ReplayStudio(), replayFile);
|
||||
replay.writeMetaData(newMetaData);
|
||||
replay.saveTo(tmp);
|
||||
|
||||
uploader.uploadFile(GuiUploadFile.this, name, tags, tmp, category, desc);
|
||||
|
||||
FileUtils.deleteQuietly(tmpMeta);
|
||||
FileUtils.deleteQuietly(tmp);
|
||||
} else {
|
||||
uploader.uploadFile(GuiUploadFile.this, name, tags, replayFile, category, desc);
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.gui.overlay;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import static eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay.TEXTURE_SIZE;
|
||||
import static eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay.replay_gui;
|
||||
|
||||
/**
|
||||
* Renders overlay during recording.
|
||||
*/
|
||||
public class GuiRecordingOverlay {
|
||||
private final Minecraft mc;
|
||||
|
||||
public GuiRecordingOverlay(Minecraft mc) {
|
||||
this.mc = mc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the recording icon and text in the top left corner of the screen.
|
||||
* @param event Rendered post game overlay
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public void renderRecordingIndicator(RenderGameOverlayEvent.Post event) {
|
||||
if (event.type != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
if(ReplayMod.replaySettings.showRecordingIndicator()) {
|
||||
FontRenderer fontRenderer = mc.fontRendererObj;
|
||||
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
|
||||
mc.renderEngine.bindTexture(replay_gui);
|
||||
GlStateManager.resetColor();
|
||||
GlStateManager.enableAlpha();
|
||||
Gui.drawModalRectWithCustomSizedTexture(10, 10, 58, 20, 16, 16, TEXTURE_SIZE, TEXTURE_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,657 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.gui.overlay;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.entities.CameraEntity;
|
||||
import eu.crushedpixel.replaymod.gui.GuiMouseInput;
|
||||
import eu.crushedpixel.replaymod.gui.GuiRenderSettings;
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplaySpeedSlider;
|
||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||
import eu.crushedpixel.replaymod.gui.elements.timelines.GuiKeyframeTimeline;
|
||||
import eu.crushedpixel.replaymod.gui.elements.timelines.GuiMarkerTimeline;
|
||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
import eu.crushedpixel.replaymod.holders.SpectatorData;
|
||||
import eu.crushedpixel.replaymod.holders.TimestampValue;
|
||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
||||
import eu.crushedpixel.replaymod.registry.ReplayGuiRegistry;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.CameraPathValidator;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityOtherPlayerMP;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiChat;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||
|
||||
public class GuiReplayOverlay extends Gui {
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
public static final ResourceLocation replay_gui = new ResourceLocation("replaymod", "replay_gui.png");
|
||||
public static final int TEXTURE_SIZE = 128;
|
||||
|
||||
public static final int KEYFRAME_TIMELINE_LENGTH = 30 * 60 * 1000;
|
||||
|
||||
public static GuiTexturedButton texturedButton(int x, int y, int u, int v, int size, Runnable action, String hoverText) {
|
||||
return new GuiTexturedButton(0, x, y, size, size, replay_gui, u, v, TEXTURE_SIZE, TEXTURE_SIZE, action, I18n.format(hoverText));
|
||||
}
|
||||
|
||||
private final Point screenDimensions = MouseUtils.getScaledDimensions();
|
||||
private final int WIDTH = screenDimensions.getX();
|
||||
private final int HEIGHT = screenDimensions.getY();
|
||||
|
||||
// Top row
|
||||
private final int TOP_ROW = 10;
|
||||
private final int BUTTON_PLAY_PAUSE_X = 10;
|
||||
private final int SPEED_X = 35;
|
||||
private final int SPEED_WIDTH = 100;
|
||||
private final int TIMELINE_X = SPEED_X + SPEED_WIDTH + 5;
|
||||
|
||||
// Bottom row
|
||||
private final int BOTTOM_ROW = TOP_ROW + 33;
|
||||
private final int BUTTON_PLAY_PATH_X = 10;
|
||||
private final int BUTTON_EXPORT_X = BUTTON_PLAY_PATH_X + 25;
|
||||
private final int BUTTON_PLACE_X = BUTTON_EXPORT_X + 25;
|
||||
private final int BUTTON_TIME_X = BUTTON_PLACE_X + 25;
|
||||
private final int TIMELINE_REAL_X = BUTTON_TIME_X + 25;
|
||||
private final int TIMELINE_REAL_WIDTH = WIDTH - 14 - 11 - TIMELINE_REAL_X;
|
||||
|
||||
private final GuiElement buttonPlayPause = new DelegatingElement() {
|
||||
|
||||
private final GuiElement buttonPlay = texturedButton(BUTTON_PLAY_PAUSE_X, TOP_ROW, 0, 0, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayMod.replaySender.setReplaySpeed(speedSlider.getSliderValue());
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.unpause");
|
||||
|
||||
private final GuiElement buttonPause = texturedButton(BUTTON_PLAY_PAUSE_X, TOP_ROW, 0, 20, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayMod.replaySender.setReplaySpeed(0);
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.pause");
|
||||
|
||||
@Override
|
||||
public GuiElement delegate() {
|
||||
return ReplayMod.replaySender.paused() ? buttonPlay : buttonPause;
|
||||
}
|
||||
};
|
||||
|
||||
private final GuiElement buttonExport = texturedButton(BUTTON_EXPORT_X, BOTTOM_ROW, 40, 0, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
CameraPathValidator.validateCameraPath(ReplayHandler.getPositionKeyframes(), ReplayHandler.getTimeKeyframes());
|
||||
} catch(CameraPathValidator.InvalidCameraPathException e) {
|
||||
e.printToChat();
|
||||
return;
|
||||
}
|
||||
mc.displayGuiScreen(new GuiRenderSettings());
|
||||
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.renderpath");
|
||||
|
||||
private final GuiElement buttonPlayPausePath = new DelegatingElement() {
|
||||
|
||||
private final GuiElement buttonPlay = texturedButton(BUTTON_PLAY_PATH_X, BOTTOM_ROW, 0, 0, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayHandler.startPath(null, GuiScreen.isCtrlKeyDown());
|
||||
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.playpath");
|
||||
|
||||
private final GuiElement buttonPlayFromStart = texturedButton(BUTTON_PLAY_PATH_X, BOTTOM_ROW, 0, 0, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayHandler.startPath(null, GuiScreen.isCtrlKeyDown());
|
||||
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.playpathfromstart");
|
||||
|
||||
private final GuiElement buttonPause = texturedButton(BUTTON_PLAY_PATH_X, BOTTOM_ROW, 0, 20, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayHandler.interruptReplay();
|
||||
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.pausepath");
|
||||
|
||||
@Override
|
||||
public GuiElement delegate() {
|
||||
return ReplayHandler.isInPath() ? buttonPause : GuiScreen.isCtrlKeyDown() ? buttonPlayFromStart : buttonPlay;
|
||||
}
|
||||
};
|
||||
|
||||
private final GuiElement buttonPlace = new DelegatingElement() {
|
||||
private final GuiElement buttonNotSelected = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 0, 40, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Entity cam = mc.getRenderViewEntity();
|
||||
if (cam != null) {
|
||||
AdvancedPosition position = new AdvancedPosition(cam.posX, cam.posY, cam.posZ, cam.rotationPitch,
|
||||
cam.rotationYaw % 360, ReplayHandler.getCameraTilt());
|
||||
|
||||
if (ReplayHandler.isCamera())
|
||||
ReplayHandler.addKeyframe(new Keyframe<AdvancedPosition>(ReplayHandler.getRealTimelineCursor(), position));
|
||||
else
|
||||
ReplayHandler.addKeyframe(new Keyframe<AdvancedPosition>(ReplayHandler.getRealTimelineCursor(), new SpectatorData(cam)));
|
||||
}
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.addposkeyframe");
|
||||
|
||||
private final GuiElement buttonSelected = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 0, 60, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayHandler.removeKeyframe(ReplayHandler.getSelectedKeyframe());
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.removeposkeyframe");
|
||||
|
||||
private final GuiElement buttonSpectatorNotSelected = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 40, 40, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Entity cam = mc.getRenderViewEntity();
|
||||
if (cam != null) {
|
||||
AdvancedPosition position = new AdvancedPosition(cam.posX, cam.posY, cam.posZ, cam.rotationPitch,
|
||||
cam.rotationYaw % 360, ReplayHandler.getCameraTilt());
|
||||
|
||||
if (ReplayHandler.isCamera())
|
||||
ReplayHandler.addKeyframe(new Keyframe<AdvancedPosition>(ReplayHandler.getRealTimelineCursor(), position));
|
||||
else
|
||||
ReplayHandler.addKeyframe(new Keyframe<AdvancedPosition>(ReplayHandler.getRealTimelineCursor(), new SpectatorData(cam)));
|
||||
}
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.addspeckeyframe");
|
||||
|
||||
private final GuiElement buttonSpectatorSelected = texturedButton(BUTTON_PLACE_X, BOTTOM_ROW, 40, 60, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayHandler.removeKeyframe(ReplayHandler.getSelectedKeyframe());
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.removespeckeyframe");
|
||||
|
||||
@Override
|
||||
public GuiElement delegate() {
|
||||
boolean selected = ReplayHandler.getSelectedKeyframe() != null && ReplayHandler.getSelectedKeyframe().getValue() instanceof AdvancedPosition;
|
||||
boolean camera;
|
||||
if(selected) {
|
||||
camera = !(ReplayHandler.getSelectedKeyframe().getValue() instanceof SpectatorData);
|
||||
} else {
|
||||
camera = ReplayHandler.isCamera();
|
||||
}
|
||||
|
||||
if(camera) {
|
||||
return selected ? buttonSelected : buttonNotSelected;
|
||||
} else {
|
||||
return selected ? buttonSpectatorSelected : buttonSpectatorNotSelected;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final GuiElement buttonTime = new DelegatingElement() {
|
||||
|
||||
private final GuiElement buttonNotSelected = texturedButton(BUTTON_TIME_X, BOTTOM_ROW, 0, 80, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayHandler.addKeyframe(new Keyframe<TimestampValue>(ReplayHandler.getRealTimelineCursor(), new TimestampValue(ReplayMod.replaySender.currentTimeStamp())));
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.addtimekeyframe");
|
||||
|
||||
private final GuiElement buttonSelected = texturedButton(BUTTON_TIME_X, BOTTOM_ROW, 0, 100, 20, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayHandler.removeKeyframe(ReplayHandler.getSelectedKeyframe());
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.removetimekeyframe");
|
||||
|
||||
@Override
|
||||
public GuiElement delegate() {
|
||||
return ReplayHandler.getSelectedKeyframe() != null && ReplayHandler.getSelectedKeyframe().getValue() instanceof TimestampValue ? buttonSelected : buttonNotSelected;
|
||||
}
|
||||
};
|
||||
private final GuiElement buttonZoomIn = texturedButton(WIDTH - 14 - 9, BOTTOM_ROW, 40, 20, 9, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
timelineReal.zoomIn();
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.zoomin");
|
||||
|
||||
private final GuiElement buttonZoomOut = texturedButton(WIDTH - 14 - 9, BOTTOM_ROW + 11, 40, 30, 9, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
timelineReal.zoomOut();
|
||||
}
|
||||
}, "replaymod.gui.ingame.menu.zoomout");
|
||||
|
||||
|
||||
private final GuiMarkerTimeline timeline = new GuiMarkerTimeline(TIMELINE_X, TOP_ROW - 1, WIDTH - 14 - TIMELINE_X, 22, false);
|
||||
|
||||
private final GuiKeyframeTimeline timelineReal = new GuiKeyframeTimeline(TIMELINE_REAL_X, BOTTOM_ROW - 1, TIMELINE_REAL_WIDTH, 22, true, true, true);
|
||||
{
|
||||
timelineReal.timelineLength = KEYFRAME_TIMELINE_LENGTH;
|
||||
}
|
||||
|
||||
private final GuiScrollbar scrollbar = new GuiScrollbar(TIMELINE_REAL_X, BOTTOM_ROW + 22, TIMELINE_REAL_WIDTH) {
|
||||
@Override
|
||||
public void dragged() {
|
||||
timelineReal.timeStart = scrollbar.sliderPosition;
|
||||
}
|
||||
};
|
||||
|
||||
private final GuiReplaySpeedSlider speedSlider = new GuiReplaySpeedSlider(SPEED_X, TOP_ROW, I18n.format("replaymod.gui.speed"));
|
||||
|
||||
public double getSpeedSliderValue() {
|
||||
return speedSlider.getSliderValue();
|
||||
}
|
||||
|
||||
private boolean toolbarOpen = false;
|
||||
|
||||
private final DelegatingElement toolbar = new DelegatingElement() {
|
||||
|
||||
private void toggleOpen() {
|
||||
toolbarOpen = !toolbarOpen;
|
||||
}
|
||||
|
||||
private GuiElement buttonOpenToolbar = new GuiArrowButton(-1, 10, HEIGHT-10-20, "", GuiArrowButton.Direction.UP) {
|
||||
@Override
|
||||
public void performAction() {
|
||||
toggleOpen();
|
||||
}
|
||||
};
|
||||
|
||||
private GuiElement buttonCloseToolbar = new GuiArrowButton(-1, 10, HEIGHT-10-20, "", GuiArrowButton.Direction.DOWN) {
|
||||
@Override
|
||||
public void performAction() {
|
||||
toggleOpen();
|
||||
}
|
||||
};
|
||||
|
||||
private ComposedElement openElements = new ComposedElement(buttonCloseToolbar);
|
||||
|
||||
private int maxButtonY = -1;
|
||||
|
||||
{
|
||||
int buttonX = 10;
|
||||
int maxWidth = 0;
|
||||
int i = 0;
|
||||
|
||||
for(final KeyBinding kb : KeybindRegistry.getReplayModKeyBindings()) {
|
||||
int buttonY = HEIGHT-55-(i*25);
|
||||
|
||||
if(buttonY < 80) {
|
||||
buttonX += 25 + maxWidth + 5;
|
||||
maxWidth = 0;
|
||||
|
||||
i = 0;
|
||||
buttonY = HEIGHT-55-(i*25);
|
||||
}
|
||||
|
||||
if(buttonY < maxButtonY || maxButtonY == -1) maxButtonY = buttonY;
|
||||
|
||||
String keyName = "???";
|
||||
try {
|
||||
keyName = Keyboard.getKeyName(kb.getKeyCode());
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// Apparently windows likes to press strange keys, see https://www.replaymod.com/forum/thread/55
|
||||
}
|
||||
GuiElement button = new GuiAdvancedButton(buttonX, buttonY, 20, 20, keyName, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayMod.keyInputHandler.handleCustomKeybindings(kb, false, kb.getKeyCode());
|
||||
}
|
||||
}, null);
|
||||
|
||||
String stringText = I18n.format(kb.getKeyDescription());
|
||||
int stringWidth = mc.fontRendererObj.getStringWidth(stringText);
|
||||
|
||||
if(stringWidth > maxWidth) {
|
||||
maxWidth = stringWidth;
|
||||
}
|
||||
|
||||
GuiString string = new GuiString(buttonX+25, buttonY+6, Color.WHITE, stringText);
|
||||
|
||||
openElements.addPart(button);
|
||||
openElements.addPart(string);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiElement delegate() {
|
||||
if(toolbarOpen) {
|
||||
return openElements;
|
||||
} else {
|
||||
return buttonOpenToolbar;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
||||
if(toolbarOpen) {
|
||||
drawGradientRect(0, maxButtonY - 10, WIDTH, HEIGHT, -1072689136, -804253680);
|
||||
}
|
||||
super.draw(mc, mouseX, mouseY);
|
||||
}
|
||||
};
|
||||
|
||||
public void closeToolbar() {
|
||||
toolbarOpen = false;
|
||||
}
|
||||
|
||||
private final GuiElement content = new ComposedElement(buttonPlayPause, buttonExport, buttonPlace, buttonTime,
|
||||
buttonPlayPausePath, buttonZoomIn, buttonZoomOut, timeline, timelineReal, scrollbar, speedSlider, toolbar);
|
||||
|
||||
public boolean isVisible() {
|
||||
return ReplayHandler.isInReplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the UI.
|
||||
* @param resetElements Whether the timeline and Speed Slider should be reset as well
|
||||
*/
|
||||
public void resetUI(boolean resetElements) {
|
||||
if(FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class)) {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
if (resetElements) {
|
||||
timelineReal.zoom = 0.033f;
|
||||
timelineReal.timeStart = 0;
|
||||
|
||||
ReplayHandler.setRealTimelineCursor(0);
|
||||
speedSlider.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void register() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
}
|
||||
|
||||
private void checkResize() {
|
||||
if (!screenDimensions.equals(MouseUtils.getScaledDimensions())) {
|
||||
GuiReplayOverlay other = new GuiReplayOverlay();
|
||||
other.timelineReal.zoom = this.timelineReal.zoom;
|
||||
other.timelineReal.timeStart = this.timelineReal.timeStart;
|
||||
other.speedSlider.copyValueFrom(this.speedSlider);
|
||||
|
||||
this.unregister();
|
||||
other.register();
|
||||
ReplayMod.overlay = other;
|
||||
|
||||
if (mc.currentScreen instanceof GuiMouseInput) {
|
||||
mc.displayGuiScreen(new GuiMouseInput(other));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderTabList(RenderGameOverlayEvent.Pre event) { //cancelling tab list rendering and rendering help instead
|
||||
if (!isVisible()) return;
|
||||
if (event.type == RenderGameOverlayEvent.ElementType.PLAYER_LIST) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void tick() {
|
||||
if (FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class)) {
|
||||
Entity player = ReplayHandler.getCameraEntity();
|
||||
if(player != null) {
|
||||
player.setVelocity(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
checkResize();
|
||||
}
|
||||
|
||||
public void mouseDrag(int mouseX, int mouseY, int button) {
|
||||
content.mouseDrag(mc, mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
public void mouseReleased(int mouseX, int mouseY, int button) {
|
||||
content.mouseRelease(mc, mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
if (ReplayHandler.isInPath()) { // Only allow clicking of cancel button during path replay
|
||||
buttonPlayPausePath.mouseClick(mc, mouseX, mouseY, button);
|
||||
} else {
|
||||
content.mouseClick(mc, mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
||||
public void performJump(long timelineTime) {
|
||||
performJump(timelineTime, true);
|
||||
}
|
||||
|
||||
public void performJump(long timelineTime, boolean setLastPosition) {
|
||||
if (timelineTime != -1) { // Click on timeline
|
||||
//When hurrying, no Timeline jumping etc. is possible
|
||||
if(!ReplayMod.replaySender.isHurrying()) {
|
||||
if(timelineTime < ReplayMod.replaySender.currentTimeStamp()) {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
if(setLastPosition) {
|
||||
CameraEntity cam = ReplayHandler.getCameraEntity();
|
||||
if(cam != null) {
|
||||
ReplayHandler.setLastPosition(new AdvancedPosition(cam.posX, cam.posY, cam.posZ, cam.rotationPitch, cam.rotationYaw), false);
|
||||
} else {
|
||||
ReplayHandler.setLastPosition(null, false);
|
||||
}
|
||||
}
|
||||
|
||||
long diff = timelineTime - ReplayMod.replaySender.getDesiredTimestamp();
|
||||
if(diff != 0) {
|
||||
if (diff > 0 && diff < 5000) { // Small difference and no time travel
|
||||
ReplayMod.replaySender.jumpToTime((int) timelineTime);
|
||||
} else { // We either have to restart the replay or send a significant amount of packets
|
||||
// Render our please-wait-screen
|
||||
GuiScreen guiScreen = new GuiScreen() {
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawBackground(0);
|
||||
drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.pleasewait"),
|
||||
width / 2, height / 2, 0xffffffff);
|
||||
}
|
||||
};
|
||||
|
||||
// Make sure that the replaysender changes into sync mode
|
||||
ReplayMod.replaySender.setSyncModeAndWait();
|
||||
|
||||
// Perform the rendering using OpenGL
|
||||
pushMatrix();
|
||||
clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
enableTexture2D();
|
||||
mc.getFramebuffer().bindFramebuffer(true);
|
||||
mc.entityRenderer.setupOverlayRendering();
|
||||
|
||||
guiScreen.setWorldAndResolution(mc, WIDTH, HEIGHT);
|
||||
guiScreen.drawScreen(0, 0, 0);
|
||||
|
||||
mc.getFramebuffer().unbindFramebuffer();
|
||||
popMatrix();
|
||||
pushMatrix();
|
||||
mc.getFramebuffer().framebufferRender(mc.displayWidth, mc.displayHeight);
|
||||
popMatrix();
|
||||
|
||||
Display.update();
|
||||
|
||||
// Send the packets
|
||||
ReplayMod.replaySender.sendPacketsTill((int) timelineTime);
|
||||
ReplayMod.replaySender.setAsyncMode(true);
|
||||
ReplayMod.replaySender.setReplaySpeed(0);
|
||||
|
||||
mc.getNetHandler().getNetworkManager().processReceivedPackets();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Entity> entities = (List<Entity>) mc.theWorld.loadedEntityList;
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof EntityOtherPlayerMP) {
|
||||
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
||||
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
||||
e.rotationYaw = (float) e.otherPlayerMPYaw;
|
||||
e.rotationPitch = (float) e.otherPlayerMPPitch;
|
||||
}
|
||||
entity.lastTickPosX = entity.prevPosX = entity.posX;
|
||||
entity.lastTickPosY = entity.prevPosY = entity.posY;
|
||||
entity.lastTickPosZ = entity.prevPosZ = entity.posZ;
|
||||
entity.prevRotationYaw = entity.rotationYaw;
|
||||
entity.prevRotationPitch = entity.rotationPitch;
|
||||
}
|
||||
try {
|
||||
mc.runTick();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(); // This should never be thrown but whatever
|
||||
}
|
||||
|
||||
//finally, updating the camera's position (which is not done by the sync jumping)
|
||||
ReplayHandler.moveCameraToLastPosition();
|
||||
|
||||
// No need to remove our please-wait-screen. It'll vanish with the next
|
||||
// render pass as it's never been a real GuiScreen in the first place.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderGui(RenderGameOverlayEvent.Post event) throws IllegalArgumentException, IllegalAccessException {
|
||||
if (event.type != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
if (!isVisible()) return;
|
||||
|
||||
FMLClientHandler fml = FMLClientHandler.instance();
|
||||
|
||||
tick();
|
||||
|
||||
// Do not draw if GUI doesn't want us to
|
||||
if(mc.currentScreen instanceof NoOverlay) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are not currently spectating someone
|
||||
if (ReplayHandler.isCamera()) {
|
||||
ReplayGuiRegistry.hide(); // hide all normal UI
|
||||
} else {
|
||||
ReplayGuiRegistry.show(); // otherwise show them
|
||||
}
|
||||
|
||||
// Replace chat and inventory GUI (opened by pressing the respective hotkey) with a dummy input GUI
|
||||
if(fml.isGUIOpen(GuiChat.class) || fml.isGUIOpen(GuiInventory.class)) {
|
||||
mc.displayGuiScreen(new GuiMouseInput(this));
|
||||
}
|
||||
|
||||
GlStateManager.resetColor();
|
||||
|
||||
Point mousePoint = MouseUtils.getMousePos();
|
||||
int mouseX = mousePoint.getX();
|
||||
int mouseY = mousePoint.getY();
|
||||
|
||||
if (!(mc.currentScreen instanceof GuiMouseInput)) {
|
||||
// We only react to the mouse if our gui screen is opened.
|
||||
// Otherwise we just move the mouse away so it doesn't activate any buttons
|
||||
mouseX = mouseY = -1000;
|
||||
}
|
||||
|
||||
// Setup scrollbar and timelines
|
||||
if (timelineReal.timeStart + timelineReal.zoom > 1) {
|
||||
timelineReal.timeStart = 1 - timelineReal.zoom;
|
||||
}
|
||||
scrollbar.size = timelineReal.zoom;
|
||||
scrollbar.sliderPosition = timelineReal.timeStart;
|
||||
|
||||
timeline.cursorPosition = ReplayMod.replaySender.currentTimeStamp();
|
||||
timeline.timelineLength = ReplayMod.replaySender.replayLength();
|
||||
|
||||
timelineReal.cursorPosition = ReplayHandler.getRealTimelineCursor();
|
||||
|
||||
// Draw all elements
|
||||
content.draw(mc, mouseX, mouseY);
|
||||
content.drawOverlay(mc, mouseX, mouseY);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
}
|
||||
|
||||
public void togglePlayPause() {
|
||||
if (ReplayMod.replaySender.paused()) {
|
||||
ReplayMod.replaySender.setReplaySpeed(speedSlider.getSliderValue());
|
||||
} else {
|
||||
ReplayMod.replaySender.setReplaySpeed(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the Ambient Lighting and Path Preview indicators in the lower right corner.
|
||||
* @param event Rendered post game overlay
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public void renderIndicators(RenderGameOverlayEvent.Post event) {
|
||||
if (event.type != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
if(!ReplayHandler.isInReplay() || mc.currentScreen instanceof NoOverlay) return;
|
||||
|
||||
int xPos = WIDTH-10;
|
||||
|
||||
if(ReplayMod.replaySettings.isLightingEnabled()) {
|
||||
int width = 19;
|
||||
|
||||
mc.renderEngine.bindTexture(replay_gui);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.disableLighting();
|
||||
Gui.drawModalRectWithCustomSizedTexture(xPos-width, HEIGHT - 10 - 13,
|
||||
90, 20, 19, 13, TEXTURE_SIZE, TEXTURE_SIZE);
|
||||
|
||||
xPos -= width + 5;
|
||||
}
|
||||
|
||||
if(ReplayMod.replaySettings.showPathPreview()) {
|
||||
int width = 20;
|
||||
|
||||
mc.renderEngine.bindTexture(replay_gui);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.disableLighting();
|
||||
Gui.drawModalRectWithCustomSizedTexture(xPos - width, HEIGHT - 10 - 13,
|
||||
100, 0, 20, 13, TEXTURE_SIZE, TEXTURE_SIZE);
|
||||
|
||||
//noinspection UnusedAssignment
|
||||
xPos -= width + 5;
|
||||
}
|
||||
|
||||
//can be continued
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy interface for GUI on which this replay overlay shall not be rendered.
|
||||
*/
|
||||
public interface NoOverlay {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui.replayeditor;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiProgressBar;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui.replayeditor;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiDropdown;
|
||||
import eu.crushedpixel.replaymod.holders.GuiEntryListStringEntry;
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.gui.replayviewer;
|
||||
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiRenameReplay extends GuiScreen {
|
||||
private GuiScreen parent;
|
||||
private GuiTextField replayNameInput;
|
||||
private File file;
|
||||
|
||||
public GuiRenameReplay(GuiScreen parent, File file) {
|
||||
this.parent = parent;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
this.replayNameInput.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
buttonList.clear();
|
||||
buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("replaymod.gui.rename")));
|
||||
buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("replaymod.gui.cancel")));
|
||||
String s = FilenameUtils.getBaseName(file.getAbsolutePath());
|
||||
this.replayNameInput = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20);
|
||||
this.replayNameInput.setFocused(true);
|
||||
this.replayNameInput.setText(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
if(button.enabled) {
|
||||
if(button.id == 1) {
|
||||
this.mc.displayGuiScreen(this.parent);
|
||||
} else if(button.id == 0) {
|
||||
File folder = ReplayFileIO.getReplayFolder();
|
||||
|
||||
File initRenamed = new File(folder, (this.replayNameInput.getText().trim() + ReplayFile.ZIP_FILE_EXTENSION).replaceAll("[^a-zA-Z0-9\\.\\- ]", "_"));
|
||||
File renamed = ReplayFileIO.getNextFreeFile(initRenamed);
|
||||
try {
|
||||
FileUtils.moveFile(file, renamed);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
mc.displayGuiScreen(new GuiErrorScreen(
|
||||
I18n.format("replaymod.gui.viewer.delete.failed1"),
|
||||
I18n.format("replaymod.gui.viewer.delete.failed2")
|
||||
));
|
||||
return;
|
||||
}
|
||||
this.mc.displayGuiScreen(this.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
this.replayNameInput.textboxKeyTyped(typedChar, keyCode);
|
||||
((GuiButton) this.buttonList.get(0)).enabled = this.replayNameInput.getText().trim().length() > 0;
|
||||
|
||||
if(keyCode == 28 || keyCode == 156) {
|
||||
this.actionPerformed((GuiButton) this.buttonList.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.replayNameInput.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("replaymod.gui.viewer.rename.title"), this.width / 2, 20, 16777215);
|
||||
this.drawString(this.fontRendererObj, I18n.format("replaymod.gui.viewer.rename.name"), this.width / 2 - 100, 47, 10526880);
|
||||
this.replayNameInput.drawTextBox();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
@@ -1,351 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.gui.replayviewer;
|
||||
|
||||
import com.mojang.realmsclient.util.Pair;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.api.replay.holders.FileInfo;
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplaySettings;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiLoadingListEntry;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiReplayListEntry;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiReplayListExtended;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
|
||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ImageUtils;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
||||
|
||||
private static final int LOAD_BUTTON_ID = 9001;
|
||||
private static final int UPLOAD_BUTTON_ID = 9002;
|
||||
private static final int FOLDER_BUTTON_ID = 9003;
|
||||
private static final int RENAME_BUTTON_ID = 9004;
|
||||
private static final int DELETE_BUTTON_ID = 9005;
|
||||
private static final int SETTINGS_BUTTON_ID = 9006;
|
||||
private static final int CANCEL_BUTTON_ID = 9007;
|
||||
private boolean initialized;
|
||||
private GuiReplayListExtended replayGuiList;
|
||||
private List<Pair<Pair<File, ReplayMetaData>, File>> replayFileList = new ArrayList<Pair<Pair<File, ReplayMetaData>, File>>();
|
||||
private GuiButton loadButton;
|
||||
private GuiButton uploadButton;
|
||||
private GuiButton renameButton;
|
||||
private GuiButton deleteButton;
|
||||
private boolean delete_file = false;
|
||||
|
||||
private Queue<Runnable> loadedReplaysQueue = new ConcurrentLinkedQueue<Runnable>();
|
||||
|
||||
private Thread fileReloader;
|
||||
|
||||
private class FileReloaderThread extends Thread {
|
||||
private final GuiLoadingListEntry loadingListEntry = new GuiLoadingListEntry();
|
||||
|
||||
@Override
|
||||
public synchronized void start() {
|
||||
replayFileList = new ArrayList<Pair<Pair<File, ReplayMetaData>, File>>();
|
||||
replayGuiList.clearEntries();
|
||||
replayGuiList.addEntry(loadingListEntry);
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(final File file : ReplayFileIO.getAllReplayFiles()) {
|
||||
if(interrupted()) break;
|
||||
try {
|
||||
ReplayFile replayFile = new ReplayFile(file);
|
||||
final ReplayMetaData metaData = replayFile.metadata().get();
|
||||
BufferedImage img = replayFile.thumb().get();
|
||||
|
||||
replayFile.close();
|
||||
|
||||
File tmp = null;
|
||||
if(img != null) {
|
||||
img = ImageUtils.scaleImage(img, new Dimension(1280, 720));
|
||||
tmp = File.createTempFile(FilenameUtils.getBaseName(file.getAbsolutePath())+"_THUMBNAIL", "jpg");
|
||||
tmp.deleteOnExit();
|
||||
|
||||
ImageIO.write(img, "jpg", tmp);
|
||||
}
|
||||
|
||||
final File thumb = tmp;
|
||||
loadedReplaysQueue.offer(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addEntry(file, metaData, thumb);
|
||||
}
|
||||
});
|
||||
} catch(Exception e) {
|
||||
FMLLog.getLogger().error("Could not load Replay File "+file.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
loadedReplaysQueue.offer(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
replayGuiList.removeEntry(loadingListEntry);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, String file, int p_152129_2_) {
|
||||
String s1 = I18n.format("replaymod.gui.viewer.delete.linea");
|
||||
String s2 = "\'" + file + "\' " + I18n.format("replaymod.gui.viewer.delete.lineb");
|
||||
String s3 = I18n.format("replaymod.gui.delete");
|
||||
String s4 = I18n.format("replaymod.gui.cancel");
|
||||
return new GuiYesNo(p_152129_0_, s1, s2, s3, s4, p_152129_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
ResourceHelper.freeAllResources();
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void initGui() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
if(!this.initialized) {
|
||||
replayGuiList = new ReplayList(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
|
||||
this.initialized = true;
|
||||
} else {
|
||||
this.replayGuiList.setDimensions(this.width, this.height, 32, this.height - 64);
|
||||
}
|
||||
|
||||
try {
|
||||
if(fileReloader != null) {
|
||||
fileReloader.interrupt();
|
||||
fileReloader.join();
|
||||
}
|
||||
|
||||
fileReloader = new FileReloaderThread();
|
||||
fileReloader.start();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.createButtons();
|
||||
}
|
||||
|
||||
private void createButtons() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = this.buttonList;
|
||||
buttonList.add(loadButton = new GuiButton(LOAD_BUTTON_ID, this.width / 2 - 154, this.height - 52, 73, 20, I18n.format("replaymod.gui.load")));
|
||||
buttonList.add(uploadButton = new GuiButton(UPLOAD_BUTTON_ID, this.width / 2 - 154 + 78, this.height - 52, 73, 20, I18n.format("replaymod.gui.upload")));
|
||||
buttonList.add(new GuiButton(FOLDER_BUTTON_ID, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("replaymod.gui.viewer.replayfolder")));
|
||||
buttonList.add(renameButton = new GuiButton(RENAME_BUTTON_ID, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("replaymod.gui.rename")));
|
||||
buttonList.add(deleteButton = new GuiButton(DELETE_BUTTON_ID, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("replaymod.gui.delete")));
|
||||
buttonList.add(new GuiButton(SETTINGS_BUTTON_ID, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("replaymod.gui.settings")));
|
||||
buttonList.add(new GuiButton(CANCEL_BUTTON_ID, this.width / 2 + 4 + 78, this.height - 28, 72, 20, I18n.format("replaymod.gui.cancel")));
|
||||
setButtonsEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException {
|
||||
super.handleMouseInput();
|
||||
this.replayGuiList.handleMouseInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.replayGuiList.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
this.replayGuiList.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
this.replayGuiList.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.drawCenteredString(this.fontRendererObj, I18n.format("replaymod.gui.replayviewer"), this.width / 2, 20, 16777215);
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
if(uploadButton.isMouseOver() && !uploadButton.enabled && loadButton.enabled) {
|
||||
if(currentFileUploaded) {
|
||||
ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.viewer.alreadyuploaded"), this, Color.RED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
if(button.enabled) {
|
||||
if(button.id == LOAD_BUTTON_ID) {
|
||||
loadReplay(replayGuiList.selected);
|
||||
} else if(button.id == CANCEL_BUTTON_ID) {
|
||||
mc.displayGuiScreen(null);
|
||||
} else if(button.id == DELETE_BUTTON_ID) {
|
||||
String s = ((GuiReplayListEntry)replayGuiList.getListEntry(replayGuiList.selected)).getFileInfo().getName();
|
||||
|
||||
if(s != null) {
|
||||
delete_file = true;
|
||||
GuiYesNo guiyesno = getYesNoGui(this, s, 1);
|
||||
this.mc.displayGuiScreen(guiyesno);
|
||||
}
|
||||
} else if(button.id == SETTINGS_BUTTON_ID) {
|
||||
this.mc.displayGuiScreen(new GuiReplaySettings(this));
|
||||
} else if(button.id == RENAME_BUTTON_ID) {
|
||||
File file = replayFileList.get(replayGuiList.selected).first().first();
|
||||
this.mc.displayGuiScreen(new GuiRenameReplay(this, file));
|
||||
} else if(button.id == UPLOAD_BUTTON_ID) {
|
||||
File file = replayFileList.get(replayGuiList.selected).first().first();
|
||||
this.mc.displayGuiScreen(new GuiUploadFile(file, this));
|
||||
} else if(button.id == FOLDER_BUTTON_ID) {
|
||||
File file1 = ReplayFileIO.getReplayFolder();
|
||||
|
||||
String s = file1.getAbsolutePath();
|
||||
|
||||
if(Util.getOSType() == Util.EnumOS.OSX) {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[]{"/usr/bin/open", s});
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
LogManager.getLogger().error("Cannot open file", e);
|
||||
}
|
||||
} else if(Util.getOSType() == Util.EnumOS.WINDOWS) {
|
||||
String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", s);
|
||||
|
||||
try {
|
||||
Runtime.getRuntime().exec(s1);
|
||||
return;
|
||||
} catch(IOException e) {
|
||||
LogManager.getLogger().error("Cannot open file", e);
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = false;
|
||||
|
||||
try {
|
||||
Desktop.getDesktop().browse(file1.toURI());
|
||||
} catch(Throwable throwable) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if(flag) {
|
||||
Sys.openURL("file://" + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmClicked(boolean result, int id) {
|
||||
if(this.delete_file) {
|
||||
this.delete_file = false;
|
||||
|
||||
if(result) {
|
||||
try {
|
||||
FileUtils.forceDelete(replayFileList.get(replayGuiList.selected).first().first());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
replayFileList.remove(replayGuiList.selected);
|
||||
replayGuiList.selected = -1;
|
||||
}
|
||||
|
||||
this.mc.displayGuiScreen(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
while (!loadedReplaysQueue.isEmpty()) {
|
||||
loadedReplaysQueue.poll().run();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean currentFileUploaded = false;
|
||||
|
||||
public void setButtonsEnabled(boolean b) {
|
||||
loadButton.enabled = b;
|
||||
|
||||
if(b) {
|
||||
currentFileUploaded = ReplayMod.uploadedFileHandler.isUploaded(replayFileList.get(replayGuiList.selected).first().first());
|
||||
uploadButton.enabled = !currentFileUploaded;
|
||||
} else {
|
||||
uploadButton.enabled = false;
|
||||
}
|
||||
|
||||
|
||||
renameButton.enabled = b;
|
||||
deleteButton.enabled = b;
|
||||
}
|
||||
|
||||
public void loadReplay(int id) {
|
||||
mc.displayGuiScreen(null);
|
||||
|
||||
try {
|
||||
ReplayHandler.startReplay(replayFileList.get(id).first().first());
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addEntry(File file, ReplayMetaData metaData, File thumb) {
|
||||
final Pair<Pair<File, ReplayMetaData>, File> p = Pair.of(Pair.of(file, metaData), thumb);
|
||||
final int index = getInsertionIndex(p, replayFileList);
|
||||
|
||||
replayFileList.add(index, p);
|
||||
|
||||
final FileInfo fileInfo = new FileInfo(-1, p.first().second(), null, null,
|
||||
-1, -1, -1, FilenameUtils.getBaseName(p.first().first().getName()), true, -1);
|
||||
|
||||
replayGuiList.addEntry(index, new GuiReplayListEntry(replayGuiList, fileInfo, p.second()));
|
||||
}
|
||||
|
||||
private static FileAgeComparator fileAgeComparator = new FileAgeComparator();
|
||||
|
||||
public static class FileAgeComparator implements Comparator<Pair<Pair<File, ReplayMetaData>, File>> {
|
||||
|
||||
@Override
|
||||
public int compare(Pair<Pair<File, ReplayMetaData>, File> o1, Pair<Pair<File, ReplayMetaData>, File> o2) {
|
||||
try {
|
||||
return new Date(o2.first().second().getDate()).compareTo(new Date(o1.first().second().getDate()));
|
||||
} catch(Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getInsertionIndex(Pair<Pair<File, ReplayMetaData>, File> p, List<Pair<Pair<File, ReplayMetaData>, File>> list) {
|
||||
List<Pair<Pair<File, ReplayMetaData>, File>> nl = new ArrayList<Pair<Pair<File, ReplayMetaData>, File>>(list);
|
||||
|
||||
nl.add(p);
|
||||
Collections.sort(nl, fileAgeComparator);
|
||||
|
||||
return nl.indexOf(p);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.gui.replayviewer;
|
||||
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiReplayListExtended;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class ReplayList extends GuiReplayListExtended {
|
||||
|
||||
private GuiReplayViewer parent;
|
||||
|
||||
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_,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user