package com.replaymod.simplepathing.gui; import com.replaymod.pathing.properties.LensProperties; import com.replaymod.pathing.properties.FovProperty; import com.replaymod.replaystudio.pathing.path.Keyframe; import de.johni0702.minecraft.gui.container.AbstractGuiContainer; import de.johni0702.minecraft.gui.element.GuiLabel; import de.johni0702.minecraft.gui.element.GuiNumberField; import de.johni0702.minecraft.gui.layout.GridLayout; import org.apache.commons.lang3.tuple.Triple; public class GuiLensKeyframePanel extends AbstractGuiContainer { public final GuiNumberField focalDistanceField = new GuiNumberField().setValidateOnFocusChange(true).setSize(60, 20).setPrecision(3).setMinValue(0); public final GuiNumberField apertureRadiusField = new GuiNumberField().setValidateOnFocusChange(true).setSize(60, 20).setPrecision(4).setMinValue(0); public final GuiNumberField fovField = new GuiNumberField().setValidateOnFocusChange(true).setSize(60, 20).setPrecision(1).setMinValue(1).setMaxValue(179); public GuiLensKeyframePanel() { setLayout(new GridLayout().setCellsEqualSize(false).setColumns(2).setSpacingX(3).setSpacingY(5)); addElements(new GridLayout.Data(1, 0.5), new GuiLabel().setI18nText("replaymod.gui.editkeyframe.focalDistance"), focalDistanceField, new GuiLabel().setI18nText("replaymod.gui.editkeyframe.apertureRadius"), apertureRadiusField, new GuiLabel().setI18nText("replaymod.gui.editkeyframe.fov"), fovField); } public GuiLensKeyframePanel load(Keyframe keyframe) { focalDistanceField.setValue(keyframe.getValue(LensProperties.FOCAL_DISTANCE) .map(Triple::getLeft).orElse(LensProperties.DEFAULT_FOCAL_DISTANCE)); apertureRadiusField.setValue(keyframe.getValue(LensProperties.APERTURE_RADIUS) .map(Triple::getLeft).orElse(LensProperties.DEFAULT_APERTURE_RADIUS)); fovField.setValue(keyframe.getValue(FovProperty.FOV) .map(Triple::getLeft).orElse(FovProperty.DEFAULT_FOV)); return this; } public float getFocalDistance() { return focalDistanceField.getFloat(); } public float getApertureRadius() { return apertureRadiusField.getFloat(); } public float getFov() { return fovField.getFloat(); } @Override protected GuiLensKeyframePanel getThis() { return this; } }