trackeditor: linear profil can't have tangents

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9288 30fe4595-0a0c-4342-8851-515496e4dcbd
This commit is contained in:
iobyte 2024-01-27 20:39:50 +00:00
parent 036a27fc82
commit e07bafe83f
5 changed files with 63 additions and 13 deletions

View File

@ -108,7 +108,7 @@ IF(Java_Development_FOUND AND Java_FOUND)
utils/circuit/ObjectData.java
utils/circuit/ObjectMap.java
utils/circuit/Pits.java
utils/circuit/Point3D.java
utils/circuit/Point3D.java
utils/circuit/Reliefs.java
utils/circuit/Sector.java
utils/circuit/Segment.java

View File

@ -834,10 +834,20 @@ public class SegmentEditorDlg extends JDialog implements SliderListener
this.getProfileStepsSlider().setValue(shape.getProfilSteps());
this.getProfileStepsLengthSlider().setValue(shape.getProfilStepsLength());
if (shape.getProfil() == null || shape.getProfil().isEmpty())
{
getProfileButton().setSelected("none");
}
else
{
getProfileButton().setSelected(shape.getProfil());
}
if (shape.getValidProfil(editorFrame).equals("linear"))
{
this.getStartTangentSlider().setEnabled(false);
this.getEndTangentSlider().setEnabled(false);
this.getEndTangentLeftSlider().setEnabled(false);
this.getEndTangentRightSlider().setEnabled(false);
}
} catch (Exception e)
{
e.printStackTrace();
@ -939,9 +949,32 @@ public class SegmentEditorDlg extends JDialog implements SliderListener
public void profileChanged()
{
if (getProfileButton().getSelected().isEmpty() || getProfileButton().getSelected() == "none")
{
shape.setProfil("");
}
else
{
shape.setProfil(getProfileButton().getSelected());
}
if (shape.getValidProfil(editorFrame).equals("linear"))
{
shape.setProfilStartTangent(Double.NaN);
shape.setProfilEndTangent(Double.NaN);
shape.setProfilEndTangentLeft(Double.NaN);
shape.setProfilEndTangentRight(Double.NaN);
this.getStartTangentSlider().setEnabled(false);
this.getEndTangentSlider().setEnabled(false);
this.getEndTangentLeftSlider().setEnabled(false);
this.getEndTangentRightSlider().setEnabled(false);
}
else
{
this.getStartTangentSlider().setEnabled(true);
this.getEndTangentSlider().setEnabled(true);
this.getEndTangentLeftSlider().setEnabled(true);
this.getEndTangentRightSlider().setEnabled(true);
}
editorFrame.documentIsModified = true;
}

View File

@ -34,7 +34,7 @@ public class Properties
private static Properties instance = new Properties();
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
public final String title = "sd2-trackeditor";
public final String version = "1.4.19";
public final String version = "1.4.20";
private String path;
private double imageScale = 1;

View File

@ -5,6 +5,7 @@ public class MainTrack
public static final double DEFAULT_WIDTH = 10;
public static final String DEFAULT_SURFACE = "asphalt2-lines";
public static final double DEFAULT_PROFIL_STEPS_LENGTH = 4;
public static final String DEFAULT_PROFIL = "spline";
private double width = Double.NaN;
private String surface = null;

View File

@ -1063,21 +1063,37 @@ public class Segment implements Cloneable
}
// this is not inherited
public double getValidProfilStepsLength(EditorFrame editorFrame)
{
double length = profilStepsLength;
public String getValidProfil(EditorFrame editorFrame)
{
if (hasProfil())
{
return getProfil();
}
if (editorFrame.getTrackData().getMainTrack().getProfil() != null)
{
return editorFrame.getTrackData().getMainTrack().getProfil();
}
return MainTrack.DEFAULT_PROFIL;
}
// this is not inherited
public double getValidProfilStepsLength(EditorFrame editorFrame)
{
double length = profilStepsLength;
if (hasProfilStepsLength())
{
return length;
}
length = editorFrame.getTrackData().getMainTrack().getProfilStepsLength();
if (Double.isNaN(length))
{
length = MainTrack.DEFAULT_PROFIL_STEPS_LENGTH;
}
return length;
}
length = editorFrame.getTrackData().getMainTrack().getProfilStepsLength();
if (Double.isNaN(length))
{
length = MainTrack.DEFAULT_PROFIL_STEPS_LENGTH;
}
return length;
}
public double getValidLeftBarrierWidth(EditorFrame editorFrame)
{