trackeditor: update reliefs tab when loading relief file
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9369 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: f869dba6426e4cc5aa57163c4cfd66b53acb4707 Former-commit-id: f4fc1ccc63c66a54258030e4b045c82d01850a63
This commit is contained in:
parent
a74cafdae1
commit
14d4d00c54
7 changed files with 214 additions and 175 deletions
|
@ -611,7 +611,7 @@ public class CheckDialog extends JDialog
|
|||
{
|
||||
Ac3dSurface surface = object.getSurfaces().get(j);
|
||||
|
||||
if (surface.isLine())
|
||||
if (surface.isOpenLine())
|
||||
{
|
||||
double[] firstVertex = object.getVertices().get(0);
|
||||
double[] lastVertex = object.getVertices().get(object.getVertices().size() - 1);
|
||||
|
|
|
@ -30,10 +30,19 @@ public class ReliefProperties extends PropertyPanel
|
|||
private JTabbedPane tabbedPane = null;
|
||||
private JButton addReliefButton = null;
|
||||
private JButton deleteReliefButton = null;
|
||||
private Reliefs reliefs = null;
|
||||
|
||||
ReliefProperties(EditorFrame editorFrame)
|
||||
{
|
||||
super(editorFrame);
|
||||
reliefs = getEditorFrame().getReliefs();
|
||||
initialize();
|
||||
}
|
||||
|
||||
ReliefProperties(EditorFrame editorFrame, Reliefs reliefs)
|
||||
{
|
||||
super(editorFrame);
|
||||
this.reliefs = reliefs;
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
@ -54,12 +63,10 @@ public class ReliefProperties extends PropertyPanel
|
|||
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
||||
tabbedPane.setBounds(10, 10, 487, 307);
|
||||
|
||||
Reliefs reliefs = getEditorFrame().getReliefs();
|
||||
|
||||
for (int i = 0; i < reliefs.getReliefs().size(); i++)
|
||||
{
|
||||
tabbedPane.addTab("relief " + String.valueOf(i + 1), null, new ReliefPanel(reliefs.getReliefs().get(i)), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tabbedPane;
|
||||
}
|
||||
|
@ -76,17 +83,16 @@ public class ReliefProperties extends PropertyPanel
|
|||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
ObjShapeRelief relief = new ObjShapeRelief();
|
||||
Reliefs reliefs = getEditorFrame().getReliefs();
|
||||
|
||||
// add points
|
||||
Rectangle2D.Double boundingRectangle = getEditorFrame().getBoundingRectangle();
|
||||
double center[] = { boundingRectangle.width / 2, boundingRectangle.height / 2 };
|
||||
double offset = tabbedPane.getTabCount() * 50;
|
||||
relief.setReliefType(ObjShapeRelief.ReliefType.Interior);
|
||||
relief.setLineType(ObjShapeRelief.LineType.Polyline);
|
||||
relief.setLineType(ObjShapeRelief.LineType.Open);
|
||||
relief.addVertex(new double[] { center[0] - 50, 0, -(center[1] + offset) });
|
||||
relief.addVertex(new double[] { center[0] + 50, 0, -(center[1] + offset) });
|
||||
|
||||
|
||||
tabbedPane.addTab("relief " + String.valueOf(reliefs.getReliefs().size() + 1), null, new ReliefPanel(relief), null);
|
||||
tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
|
||||
}
|
||||
|
@ -123,7 +129,7 @@ public class ReliefProperties extends PropertyPanel
|
|||
private JLabel lineTypeLabel = new JLabel();
|
||||
private JComboBox<String> lineTypeComboBox = null;
|
||||
private ReliefTablePanel reliefTablePanel = null;
|
||||
|
||||
|
||||
private final String[] reliefTypes = {"interior", "exterior"};
|
||||
private int reliefTypeIndex = 0;
|
||||
private final String[] lineTypes = {"closed", "open"};
|
||||
|
@ -134,7 +140,7 @@ public class ReliefProperties extends PropertyPanel
|
|||
{
|
||||
super();
|
||||
reliefTypeIndex = reliefShape.isInterior() ? 0 : 1;
|
||||
lineTypeIndex = reliefShape.isPolygon() ? 0 : 1;
|
||||
lineTypeIndex = reliefShape.isClosed() ? 0 : 1;
|
||||
for (int i = 0; i < reliefShape.getVertices().size(); i++)
|
||||
{
|
||||
vertices.add(new double[] { reliefShape.getVertices().get(i)[0], reliefShape.getVertices().get(i)[1], reliefShape.getVertices().get(i)[2]});
|
||||
|
@ -194,18 +200,18 @@ public class ReliefProperties extends PropertyPanel
|
|||
}
|
||||
|
||||
class ReliefTableModel extends AbstractTableModel
|
||||
{
|
||||
private final String[] columnNames = { null, "X", "Y", "Z" };
|
||||
private final Class<?>[] columnClass = new Class[]
|
||||
{
|
||||
Integer.class, Double.class, Double.class, Double.class
|
||||
};
|
||||
{
|
||||
private final String[] columnNames = { null, "X", "Y", "Z" };
|
||||
private final Class<?>[] columnClass = new Class[]
|
||||
{
|
||||
Integer.class, Double.class, Double.class, Double.class
|
||||
};
|
||||
private Vector<double[]> vertices = null;
|
||||
|
||||
ReliefTableModel(Vector<double[]> vertices)
|
||||
ReliefTableModel(Vector<double[]> vertices)
|
||||
{
|
||||
this.vertices = vertices;
|
||||
}
|
||||
this.vertices = vertices;
|
||||
}
|
||||
|
||||
public int getRowCount()
|
||||
{
|
||||
|
@ -217,24 +223,24 @@ public class ReliefProperties extends PropertyPanel
|
|||
return columnNames.length;
|
||||
}
|
||||
|
||||
public String getColumnName(int columnIndex)
|
||||
{
|
||||
return columnNames[columnIndex];
|
||||
}
|
||||
public String getColumnName(int columnIndex)
|
||||
{
|
||||
return columnNames[columnIndex];
|
||||
}
|
||||
|
||||
public Class<?> getColumnClass(int columnIndex)
|
||||
{
|
||||
return columnClass[columnIndex];
|
||||
}
|
||||
public Class<?> getColumnClass(int columnIndex)
|
||||
{
|
||||
return columnClass[columnIndex];
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int row, int columnIndex)
|
||||
{
|
||||
if (columnIndex == 1 || columnIndex == 2 || columnIndex == 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isCellEditable(int row, int columnIndex)
|
||||
{
|
||||
if (columnIndex == 1 || columnIndex == 2 || columnIndex == 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
|
@ -258,15 +264,15 @@ public class ReliefProperties extends PropertyPanel
|
|||
{
|
||||
case 1:
|
||||
vertices.get(rowIndex)[0] = (Double) value;
|
||||
fireTableCellUpdated(rowIndex, columnIndex);
|
||||
fireTableCellUpdated(rowIndex, columnIndex);
|
||||
break;
|
||||
case 2:
|
||||
vertices.get(rowIndex)[2] = -(Double) value;
|
||||
fireTableCellUpdated(rowIndex, columnIndex);
|
||||
fireTableCellUpdated(rowIndex, columnIndex);
|
||||
break;
|
||||
case 3:
|
||||
vertices.get(rowIndex)[1] = (Double) value;
|
||||
fireTableCellUpdated(rowIndex, columnIndex);
|
||||
fireTableCellUpdated(rowIndex, columnIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -276,67 +282,67 @@ public class ReliefProperties extends PropertyPanel
|
|||
vertices.removeElementAt(row);
|
||||
fireTableRowsDeleted(row - 1, vertices.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ReliefTablePanel extends JPanel
|
||||
{
|
||||
JTable table = null;
|
||||
JScrollPane scrollPane = null;
|
||||
ReliefTableModel model = null;
|
||||
JTable table = null;
|
||||
JScrollPane scrollPane = null;
|
||||
ReliefTableModel model = null;
|
||||
|
||||
public ReliefTablePanel(Vector<double[]> vertices)
|
||||
public ReliefTablePanel(Vector<double[]> vertices)
|
||||
{
|
||||
super(new GridLayout(1,0));
|
||||
super(new GridLayout(1,0));
|
||||
|
||||
model = new ReliefTableModel(vertices);
|
||||
table = new JTable(model);
|
||||
scrollPane = new JScrollPane(table);
|
||||
table.getColumnModel().getColumn(0).setPreferredWidth(25);
|
||||
table.setAutoCreateRowSorter(true);
|
||||
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
|
||||
|
||||
JPopupMenu popupMenu = new JPopupMenu();
|
||||
JMenuItem deleteItem = new JMenuItem("Delete Row");
|
||||
table.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
public void mouseClicked(MouseEvent me)
|
||||
{
|
||||
if (SwingUtilities.isRightMouseButton(me) == true)
|
||||
{
|
||||
int row = table.rowAtPoint(me.getPoint());
|
||||
if (table.getSelectedRow() != row)
|
||||
{
|
||||
table.setRowSelectionInterval(row, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
deleteItem.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1)
|
||||
{
|
||||
if (JOptionPane.showConfirmDialog(null, "Delete this row?", "Delete Row", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
{
|
||||
model.removeRowAt(table.convertRowIndexToModel(row));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
popupMenu.add(deleteItem);
|
||||
table.setComponentPopupMenu(popupMenu);
|
||||
|
||||
add(scrollPane);
|
||||
}
|
||||
model = new ReliefTableModel(vertices);
|
||||
table = new JTable(model);
|
||||
scrollPane = new JScrollPane(table);
|
||||
table.getColumnModel().getColumn(0).setPreferredWidth(25);
|
||||
table.setAutoCreateRowSorter(true);
|
||||
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
|
||||
|
||||
JPopupMenu popupMenu = new JPopupMenu();
|
||||
JMenuItem deleteItem = new JMenuItem("Delete Row");
|
||||
table.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
public void mouseClicked(MouseEvent me)
|
||||
{
|
||||
if (SwingUtilities.isRightMouseButton(me) == true)
|
||||
{
|
||||
int row = table.rowAtPoint(me.getPoint());
|
||||
if (table.getSelectedRow() != row)
|
||||
{
|
||||
table.setRowSelectionInterval(row, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
deleteItem.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1)
|
||||
{
|
||||
if (JOptionPane.showConfirmDialog(null, "Delete this row?", "Delete Row", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
{
|
||||
model.removeRowAt(table.convertRowIndexToModel(row));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
popupMenu.add(deleteItem);
|
||||
table.setComponentPopupMenu(popupMenu);
|
||||
|
||||
add(scrollPane);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void exit()
|
||||
{
|
||||
MutableString stringResult = new MutableString();
|
||||
Reliefs reliefs = getEditorFrame().getReliefs();
|
||||
Reliefs reliefs = getEditorFrame().getReliefs();
|
||||
int minReliefCount = Math.min(reliefs.getReliefs().size(), tabbedPane.getTabCount());
|
||||
if (reliefs.getReliefs().size() != tabbedPane.getTabCount())
|
||||
{
|
||||
|
@ -356,46 +362,46 @@ public class ReliefProperties extends PropertyPanel
|
|||
String lineType = panel.lineTypes[panel.lineTypeIndex];
|
||||
if (isDifferent(panel.lineTypeComboBox.getSelectedItem().toString(), lineType, stringResult))
|
||||
{
|
||||
relief.setLineType(stringResult.getValue().equals(panel.lineTypes[0]) ? ObjShapeRelief.LineType.Polygon : ObjShapeRelief.LineType.Polyline);
|
||||
relief.setLineType(stringResult.getValue().equals(panel.lineTypes[0]) ? ObjShapeRelief.LineType.Closed : ObjShapeRelief.LineType.Open);
|
||||
reliefs.setChanged(true);
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
int minVertexCount = Math.min(panel.vertices.size(), relief.getVertices().size());
|
||||
|
||||
if (panel.vertices.size() != relief.getVertices().size())
|
||||
{
|
||||
getEditorFrame().documentIsModified = true;
|
||||
reliefs.setChanged(true);
|
||||
}
|
||||
for (int j = 0; j < minVertexCount; j++)
|
||||
{
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
if (panel.vertices.get(j)[k] != relief.getVertices().get(j)[k])
|
||||
{
|
||||
relief.getVertices().get(j)[k] = panel.vertices.get(j)[k];
|
||||
getEditorFrame().documentIsModified = true;
|
||||
reliefs.setChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (panel.vertices.size() < relief.getVertices().size())
|
||||
{
|
||||
// need to trim vertices
|
||||
while (relief.getVertices().size() > panel.vertices.size())
|
||||
{
|
||||
relief.deleteVertexAt(relief.getVertices().size() - 1);
|
||||
}
|
||||
}
|
||||
else if (relief.getVertices().size() < panel.vertices.size())
|
||||
{
|
||||
// need to add to vertices
|
||||
while (relief.getVertices().size() < panel.vertices.size())
|
||||
{
|
||||
relief.addVertex(panel.vertices.get(relief.getVertices().size()));
|
||||
}
|
||||
}
|
||||
if (panel.vertices.size() != relief.getVertices().size())
|
||||
{
|
||||
getEditorFrame().documentIsModified = true;
|
||||
reliefs.setChanged(true);
|
||||
}
|
||||
for (int j = 0; j < minVertexCount; j++)
|
||||
{
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
if (panel.vertices.get(j)[k] != relief.getVertices().get(j)[k])
|
||||
{
|
||||
relief.getVertices().get(j)[k] = panel.vertices.get(j)[k];
|
||||
getEditorFrame().documentIsModified = true;
|
||||
reliefs.setChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (panel.vertices.size() < relief.getVertices().size())
|
||||
{
|
||||
// need to trim vertices
|
||||
while (relief.getVertices().size() > panel.vertices.size())
|
||||
{
|
||||
relief.deleteVertexAt(relief.getVertices().size() - 1);
|
||||
}
|
||||
}
|
||||
else if (relief.getVertices().size() < panel.vertices.size())
|
||||
{
|
||||
// need to add to vertices
|
||||
while (relief.getVertices().size() < panel.vertices.size())
|
||||
{
|
||||
relief.addVertex(panel.vertices.get(relief.getVertices().size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (reliefs.getReliefs().size() > tabbedPane.getTabCount())
|
||||
{
|
||||
|
@ -410,11 +416,11 @@ public class ReliefProperties extends PropertyPanel
|
|||
// need to add to reliefs
|
||||
while (reliefs.getReliefs().size() < tabbedPane.getTabCount())
|
||||
{
|
||||
ReliefPanel panel = (ReliefPanel) tabbedPane.getComponentAt(reliefs.getReliefs().size());
|
||||
ObjShapeRelief shape = new ObjShapeRelief();
|
||||
shape.setReliefType(panel.reliefTypeComboBox.getSelectedItem().toString().equals("interior") ? ObjShapeRelief.ReliefType.Interior : ObjShapeRelief.ReliefType.Exterior);
|
||||
shape.setLineType(panel.lineTypeComboBox.getSelectedItem().toString().equals("closed") ? ObjShapeRelief.LineType.Polygon : ObjShapeRelief.LineType.Polyline);
|
||||
shape.setVertices(panel.vertices);
|
||||
ReliefPanel panel = (ReliefPanel) tabbedPane.getComponentAt(reliefs.getReliefs().size());
|
||||
ObjShapeRelief shape = new ObjShapeRelief();
|
||||
shape.setReliefType(panel.reliefTypeComboBox.getSelectedItem().toString().equals("interior") ? ObjShapeRelief.ReliefType.Interior : ObjShapeRelief.ReliefType.Exterior);
|
||||
shape.setLineType(panel.lineTypeComboBox.getSelectedItem().toString().equals("closed") ? ObjShapeRelief.LineType.Closed : ObjShapeRelief.LineType.Open);
|
||||
shape.setVertices(panel.vertices);
|
||||
reliefs.getReliefs().add(shape);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.swing.JButton;
|
|||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
@ -43,6 +44,7 @@ import utils.MutableInteger;
|
|||
import utils.MutableString;
|
||||
import utils.SurfaceComboBox;
|
||||
import utils.ac3d.Ac3dException;
|
||||
import utils.circuit.Reliefs;
|
||||
import utils.circuit.Surface;
|
||||
import utils.circuit.TerrainGeneration;
|
||||
|
||||
|
@ -91,15 +93,15 @@ public class TerrainProperties extends PropertyPanel
|
|||
private final String sep = System.getProperty("file.separator");
|
||||
|
||||
private String[] roadSurfaceItems =
|
||||
{"asphalt-lines", "asphalt-l-left", "asphalt-l-right",
|
||||
"asphalt-l-both", "asphalt-pits", "asphalt", "dirt", "dirt-b", "asphalt2", "road1", "road1-pits",
|
||||
"road1-asphalt", "asphalt-road1", "b-road1", "b-road1-l2", "b-road1-l2p", "concrete", "concrete2",
|
||||
"concrete3", "b-asphalt", "b-asphalt-l1", "b-asphalt-l1p", "asphalt2-lines", "asphalt2-l-left",
|
||||
"asphalt2-l-right", "asphalt2-l-both", "grass", "grass3", "grass5", "grass6", "grass7", "gravel", "sand3",
|
||||
"sand", "curb-5cm-r", "curb-5cm-l", "curb-l", "tar-grass3-l", "tar-grass3-r", "tar-sand", "b-road1-grass6",
|
||||
"b-road1-grass6-l2", "b-road1-gravel-l2", "b-road1-sand3", "b-road1-sand3-l2", "b-asphalt-grass7",
|
||||
"b-asphalt-grass7-l1", "b-asphalt-grass6", "b-asphalt-grass6-l1", "b-asphalt-sand3", "b-asphalt-sand3-l1",
|
||||
"barrier", "barrier2", "barrier-turn", "barrier-grille", "wall", "wall2", "tire-wall"};
|
||||
{"asphalt-lines", "asphalt-l-left", "asphalt-l-right",
|
||||
"asphalt-l-both", "asphalt-pits", "asphalt", "dirt", "dirt-b", "asphalt2", "road1", "road1-pits",
|
||||
"road1-asphalt", "asphalt-road1", "b-road1", "b-road1-l2", "b-road1-l2p", "concrete", "concrete2",
|
||||
"concrete3", "b-asphalt", "b-asphalt-l1", "b-asphalt-l1p", "asphalt2-lines", "asphalt2-l-left",
|
||||
"asphalt2-l-right", "asphalt2-l-both", "grass", "grass3", "grass5", "grass6", "grass7", "gravel", "sand3",
|
||||
"sand", "curb-5cm-r", "curb-5cm-l", "curb-l", "tar-grass3-l", "tar-grass3-r", "tar-sand", "b-road1-grass6",
|
||||
"b-road1-grass6-l2", "b-road1-gravel-l2", "b-road1-sand3", "b-road1-sand3-l2", "b-asphalt-grass7",
|
||||
"b-asphalt-grass7-l1", "b-asphalt-grass6", "b-asphalt-grass6-l1", "b-asphalt-sand3", "b-asphalt-sand3-l1",
|
||||
"barrier", "barrier2", "barrier-turn", "barrier-grille", "wall", "wall2", "tire-wall"};
|
||||
private Vector<String> roadSurfaceVector = new Vector<String>(Arrays.asList(roadSurfaceItems));
|
||||
|
||||
/**
|
||||
|
@ -109,7 +111,7 @@ public class TerrainProperties extends PropertyPanel
|
|||
{
|
||||
super(editorFrame);
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes this
|
||||
|
@ -174,7 +176,7 @@ public class TerrainProperties extends PropertyPanel
|
|||
if (orientationComboBox == null)
|
||||
{
|
||||
String[] items =
|
||||
{"none", "clockwise", "counter-clockwise"};
|
||||
{"none", "clockwise", "counter-clockwise"};
|
||||
orientationComboBox = new JComboBox<String>(items);
|
||||
orientationComboBox.setBounds(140, 118, 125, 23);
|
||||
String orientation = getEditorFrame().getTerrainGeneration().getOrientation();
|
||||
|
@ -237,9 +239,9 @@ public class TerrainProperties extends PropertyPanel
|
|||
|
||||
private void addDefaultSurfaces(Vector<String> surfaceVector)
|
||||
{
|
||||
Vector<Surface> surfaces = getEditorFrame().getTrackData().getSurfaces();
|
||||
for (int i = 0; i < surfaces.size(); i++)
|
||||
{
|
||||
Vector<Surface> surfaces = getEditorFrame().getTrackData().getSurfaces();
|
||||
for (int i = 0; i < surfaces.size(); i++)
|
||||
{
|
||||
String surface = surfaces.elementAt(i).getName();
|
||||
if (surface != null)
|
||||
{
|
||||
|
@ -257,7 +259,7 @@ public class TerrainProperties extends PropertyPanel
|
|||
surfaceVector.add(surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(surfaceVector);
|
||||
}
|
||||
|
||||
|
@ -382,6 +384,31 @@ public class TerrainProperties extends PropertyPanel
|
|||
if (pathToFile.equals(Editor.getProperties().getPath()))
|
||||
fileName = fileName.substring(index + 1);
|
||||
reliefFileTextField.setText(fileName);
|
||||
|
||||
Reliefs reliefs = new Reliefs();
|
||||
|
||||
try
|
||||
{
|
||||
reliefs.setFileName(fileName);
|
||||
tabbedPane.remove(2);
|
||||
tabbedPane.addTab("Reliefs", null, new ReliefProperties(getEditorFrame(), reliefs));
|
||||
tabbedPane.setSelectedIndex(2);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
String msg = fileName + " : Can't read input file!";
|
||||
JOptionPane.showMessageDialog(getEditorFrame(), msg, "Relief File", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
catch (Ac3dException e)
|
||||
{
|
||||
String msg = fileName + " : " + e.getLocalizedMessage();
|
||||
JOptionPane.showMessageDialog(getEditorFrame(), msg, "Relief File", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
String msg = fileName + " : " + e.getLocalizedMessage();
|
||||
JOptionPane.showMessageDialog(getEditorFrame(), msg, "Relief File", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -572,23 +599,29 @@ public class TerrainProperties extends PropertyPanel
|
|||
getEditorFrame().getTerrainGeneration().setReliefFile(stringResult.getValue());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
{
|
||||
String msg = stringResult.getValue() + " : Can't read input file!";
|
||||
JOptionPane.showMessageDialog(getEditorFrame(), msg, "Relief File", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
catch (Ac3dException e)
|
||||
{
|
||||
{
|
||||
String msg = stringResult.getValue() + " : " + e.getLocalizedMessage();
|
||||
JOptionPane.showMessageDialog(getEditorFrame(), msg, "Relief File", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
{
|
||||
String msg = stringResult.getValue() + " : " + e.getLocalizedMessage();
|
||||
JOptionPane.showMessageDialog(getEditorFrame(), msg, "Relief File", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(reliefBorderComboBox.getSelectedItem().toString(),
|
||||
getEditorFrame().getTerrainGeneration().getReliefBorder(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTerrainGeneration().setReliefBorder(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
if (isDifferent(reliefBorderComboBox.getSelectedItem().toString(),
|
||||
getEditorFrame().getTerrainGeneration().getReliefBorder(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTerrainGeneration().setReliefBorder(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent((String) surfaceComboBox.getSelectedItem(),
|
||||
getEditorFrame().getTerrainGeneration().getSurface(), stringResult))
|
||||
|
@ -604,12 +637,12 @@ public class TerrainProperties extends PropertyPanel
|
|||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(useObjectMaterialsComboBox.getSelectedItem().toString(),
|
||||
getEditorFrame().getTerrainGeneration().getUseObjectMaterials(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTerrainGeneration().setUseObjectMaterials(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
if (isDifferent(useObjectMaterialsComboBox.getSelectedItem().toString(),
|
||||
getEditorFrame().getTerrainGeneration().getUseObjectMaterials(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTerrainGeneration().setUseObjectMaterials(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
Component component0 = tabbedPane.getComponentAt(0);
|
||||
GraphicObjectProperties properties0 = (GraphicObjectProperties)component0;
|
||||
|
@ -625,4 +658,4 @@ public class TerrainProperties extends PropertyPanel
|
|||
|
||||
getEditorFrame().getProject().setPropertiesEditorTerrainTab(this.tabbedPane.getSelectedIndex());
|
||||
}
|
||||
} // @jve:decl-index=0:visual-constraint="10,10"
|
||||
} // @jve:decl-index=0:visual-constraint="10,10"
|
||||
|
|
|
@ -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.61";
|
||||
public final String version = "1.4.62";
|
||||
private String path;
|
||||
|
||||
private double imageScale = 1;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Ac3dSurface
|
|||
public static final int SURFACE_TYPE_MASK = 0x0f;
|
||||
public static final int SURFACE_TYPE_POLYGON = 0x00;
|
||||
public static final int SURFACE_TYPE_CLOSED_LINE = 0x01;
|
||||
public static final int SURFACE_TYPE_LINE = 0x02;
|
||||
public static final int SURFACE_TYPE_OPEN_LINE = 0x02;
|
||||
|
||||
public static final int SHADED_MASK = 0x10;
|
||||
public static final int SHADED_FLAT = 0x00;
|
||||
|
@ -80,20 +80,20 @@ public class Ac3dSurface
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isLine()
|
||||
public boolean isOpenLine()
|
||||
{
|
||||
return (surf & SURFACE_TYPE_MASK) == SURFACE_TYPE_LINE;
|
||||
return (surf & SURFACE_TYPE_MASK) == SURFACE_TYPE_OPEN_LINE;
|
||||
}
|
||||
|
||||
public void setLine()
|
||||
public void setOpenLine()
|
||||
{
|
||||
if (surf == null)
|
||||
{
|
||||
surf = SURFACE_TYPE_LINE;
|
||||
surf = SURFACE_TYPE_OPEN_LINE;
|
||||
}
|
||||
else
|
||||
{
|
||||
surf = (surf & ~SURFACE_TYPE_MASK) | SURFACE_TYPE_LINE;
|
||||
surf = (surf & ~SURFACE_TYPE_MASK) | SURFACE_TYPE_OPEN_LINE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public class ObjShapeRelief extends Segment
|
|||
private static int POINT_DIAMETER = POINT_RADIUS * 2;
|
||||
|
||||
public enum ReliefType { Interior, Exterior };
|
||||
public enum LineType { Polygon, Polyline };
|
||||
public enum LineType { Closed, Open };
|
||||
|
||||
private ReliefType reliefType;
|
||||
private String reliefName = new String();
|
||||
|
@ -24,7 +24,7 @@ public class ObjShapeRelief extends Segment
|
|||
{
|
||||
super("relief");
|
||||
this.reliefType = ReliefType.Interior;
|
||||
this.lineType = LineType.Polyline;
|
||||
this.lineType = LineType.Open;
|
||||
}
|
||||
|
||||
public ObjShapeRelief(String name, ReliefType reliefType, LineType lineType, Vector<double[]> vertices)
|
||||
|
@ -87,13 +87,13 @@ public class ObjShapeRelief extends Segment
|
|||
{
|
||||
return reliefType == ReliefType.Exterior;
|
||||
}
|
||||
public boolean isPolygon()
|
||||
public boolean isClosed()
|
||||
{
|
||||
return lineType == LineType.Polygon;
|
||||
return lineType == LineType.Closed;
|
||||
}
|
||||
public boolean isPolyline()
|
||||
public boolean isOpen()
|
||||
{
|
||||
return lineType == LineType.Polyline;
|
||||
return lineType == LineType.Open;
|
||||
}
|
||||
public Vector<double[]> getVertices() {
|
||||
return vertices;
|
||||
|
@ -190,7 +190,7 @@ public class ObjShapeRelief extends Segment
|
|||
g.fillOval(xToDraw[i] - POINT_RADIUS, yToDraw[i] - POINT_RADIUS, POINT_DIAMETER, POINT_DIAMETER);
|
||||
}
|
||||
|
||||
if (lineType == LineType.Polygon)
|
||||
if (lineType == LineType.Closed)
|
||||
{
|
||||
g.drawPolygon(xToDraw, yToDraw, points.length);
|
||||
}
|
||||
|
@ -327,8 +327,8 @@ public class ObjShapeRelief extends Segment
|
|||
super.dump(indent);
|
||||
|
||||
System.out.println(indent + " ObjShapeRelief");
|
||||
System.out.println(indent + " reliefType : " + (isInterior() ? "Interior" : "Exterior"));
|
||||
System.out.println(indent + " lineType : " + (isPolyline() ? "Polyline" : "Polygon"));
|
||||
System.out.println(indent + " reliefType : " + reliefType.toString());
|
||||
System.out.println(indent + " lineType : " + lineType.toString());
|
||||
System.out.println(indent + " vertices : " + vertices.size());
|
||||
for (int i = 0; i < vertices.size(); i++)
|
||||
{
|
||||
|
|
|
@ -92,7 +92,7 @@ public class Reliefs
|
|||
for (int j = 0; j < object.getSurfaces().size(); j++)
|
||||
{
|
||||
Ac3dSurface surface = object.getSurfaces().get(j);
|
||||
ObjShapeRelief.LineType lineType = surface.isLine() ? ObjShapeRelief.LineType.Polyline : ObjShapeRelief.LineType.Polygon;
|
||||
ObjShapeRelief.LineType lineType = surface.isOpenLine() ? ObjShapeRelief.LineType.Open : ObjShapeRelief.LineType.Closed;
|
||||
Vector<double[]> vertices = new Vector<double[]>();
|
||||
|
||||
for (int k = 0; k < surface.getRefs().size(); k++)
|
||||
|
@ -158,13 +158,13 @@ public class Reliefs
|
|||
|
||||
Ac3dSurface surface = new Ac3dSurface();
|
||||
|
||||
if (relief.isPolygon())
|
||||
if (relief.isClosed())
|
||||
{
|
||||
surface.setClosedLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
surface.setLine();
|
||||
surface.setOpenLine();
|
||||
}
|
||||
|
||||
for (int j = 0; j < relief.getVertices().size(); j++)
|
||||
|
|
Loading…
Reference in a new issue