From 7196bc03bddb54ec0449bf8c5bce9bbceecfb923 Mon Sep 17 00:00:00 2001 From: CrushedPixel Date: Wed, 9 Sep 2015 23:23:33 +0200 Subject: [PATCH] Rebalance the maximum and default SpectatorDataThirdPersonInfo#shoulderCamSmoothness values (+1 squashed commit) Squashed commits: [d1374a7] Information about the shoulder camera's position are now stored in a separate, interpolateable Object instead of directly in the SpectatorData Object --- .../replaymod/gui/GuiEditKeyframe.java | 16 +++--- .../replaymod/holders/SpectatorData.java | 22 +-------- .../holders/SpectatorDataThirdPersonInfo.java | 49 +++++++++++++++++++ 3 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 src/main/java/eu/crushedpixel/replaymod/holders/SpectatorDataThirdPersonInfo.java diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java index 5eed7972..39568ffb 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java @@ -442,10 +442,10 @@ public abstract class GuiEditKeyframe extends GuiScreen 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.getShoulderCamDistance(), true, "", 0.1); - shoulderPitchOffsetInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, -90d, 90d, (double)data.getShoulderCamPitchOffset(), false, "°", 1); - shoulderYawOffsetInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, null, null, (double)data.getShoulderCamYawOffset(), false, "°", 1); - shoulderSmoothnessInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, 0.1d, 1d, data.getShoulderCamSmoothness()/1000d, true, "", 0.1); + 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, @@ -486,10 +486,10 @@ public abstract class GuiEditKeyframe extends GuiScreen public void onGuiClosed() { SpectatorData data = (SpectatorData)keyframe.getValue(); data.setSpectatingMethod(SpectatorData.SpectatingMethod.values()[perspectiveButton.getValue()]); - data.setShoulderCamDistance(shoulderDistanceInput.getPreciseValue()); - data.setShoulderCamPitchOffset(shoulderPitchOffsetInput.getIntValue()); - data.setShoulderCamYawOffset(shoulderYawOffsetInput.getIntValue()); - data.setShoulderCamSmoothness((int)(shoulderSmoothnessInput.getPreciseValue()*1000)); + data.getThirdPersonInfo().shoulderCamDistance = shoulderDistanceInput.getPreciseValue(); + data.getThirdPersonInfo().shoulderCamPitchOffset = shoulderPitchOffsetInput.getIntValue(); + data.getThirdPersonInfo().shoulderCamYawOffset = shoulderYawOffsetInput.getIntValue(); + data.getThirdPersonInfo().shoulderCamSmoothness = shoulderSmoothnessInput.getPreciseValue(); super.onGuiClosed(); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/SpectatorData.java b/src/main/java/eu/crushedpixel/replaymod/holders/SpectatorData.java index 363dbb6e..7fffccf0 100755 --- a/src/main/java/eu/crushedpixel/replaymod/holders/SpectatorData.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/SpectatorData.java @@ -18,27 +18,7 @@ public class SpectatorData extends AdvancedPosition { private SpectatingMethod spectatingMethod = SpectatingMethod.FIRST_PERSON; - //these fields are only relevant for SpectatingMethod.SHOULDER_CAM - /** - * The shoulder camera's distance (in blocks) to the player - */ - private double shoulderCamDistance = 3; - - /** - * The shoulder camera's pitch offset in degrees, value between -90 and 90 - */ - private float shoulderCamPitchOffset = 0; - - /** - * The shoulder camera's rotation around the player in degrees - */ - private float shoulderCamYawOffset = 0; - - /** - * The distance between the automatically calculated position keyframes in milliseconds - */ - private int shoulderCamSmoothness = 500; - + private SpectatorDataThirdPersonInfo thirdPersonInfo = new SpectatorDataThirdPersonInfo(); public int getSpectatedEntityID() { if(spectatedEntityID == null) throw new IllegalStateException(); diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/SpectatorDataThirdPersonInfo.java b/src/main/java/eu/crushedpixel/replaymod/holders/SpectatorDataThirdPersonInfo.java new file mode 100644 index 00000000..ae910e5e --- /dev/null +++ b/src/main/java/eu/crushedpixel/replaymod/holders/SpectatorDataThirdPersonInfo.java @@ -0,0 +1,49 @@ +package eu.crushedpixel.replaymod.holders; + +import eu.crushedpixel.replaymod.interpolation.*; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +@NoArgsConstructor +public class SpectatorDataThirdPersonInfo implements KeyframeValue { + + /** + * The shoulder camera's distance (in blocks) to the player + */ + @Interpolate + public double shoulderCamDistance = 3; + + /** + * The shoulder camera's pitch offset in degrees, value between -90 and 90 + */ + @Interpolate + public double shoulderCamPitchOffset = 0; + + /** + * The shoulder camera's rotation around the player in degrees + */ + @Interpolate + public double shoulderCamYawOffset = 0; + + /** + * The distance between the automatically calculated position keyframes in seconds + */ + @Interpolate + public double shoulderCamSmoothness = 1; + + @Override + public KeyframeValue newInstance() { + return new SpectatorDataThirdPersonInfo(); + } + + @Override + public Interpolation getLinearInterpolator() { + return new GenericLinearInterpolation(); + } + + @Override + public Interpolation getCubicInterpolator() { + return new GenericSplineInterpolation(); + } +}