From 7b86e9c202ad563409056123d08c4f7f611723cc Mon Sep 17 00:00:00 2001 From: iobyte Date: Sat, 17 Feb 2024 17:18:23 +0000 Subject: [PATCH] trackeditor: add comment field to objects git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9322 30fe4595-0a0c-4342-8851-515496e4dcbd --- .../trackeditor/gui/DefaultObjectsDialog.java | 2 +- .../gui/properties/ObjectProperties.java | 65 +++++++++++-------- .../trackeditor/plugin/torcs/XmlReader.java | 1 + .../trackeditor/plugin/torcs/XmlWriter.java | 1 + src/tools/trackeditor/utils/Properties.java | 2 +- .../utils/circuit/TrackObject.java | 9 +++ 6 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/tools/trackeditor/gui/DefaultObjectsDialog.java b/src/tools/trackeditor/gui/DefaultObjectsDialog.java index 336c2d28a..035b6c594 100644 --- a/src/tools/trackeditor/gui/DefaultObjectsDialog.java +++ b/src/tools/trackeditor/gui/DefaultObjectsDialog.java @@ -22,7 +22,7 @@ public class DefaultObjectsDialog extends JDialog private void initialize() { this.setContentPane(getObjectProperties()); - this.setSize(550, 462); + this.setSize(550, 489); Point p = new Point(); p.x = editorFrame.getProject().getDefaultObjectsDialogX(); p.y = editorFrame.getProject().getDefaultObjectsDialogY(); diff --git a/src/tools/trackeditor/gui/properties/ObjectProperties.java b/src/tools/trackeditor/gui/properties/ObjectProperties.java index a094b3a93..196cfe7ea 100644 --- a/src/tools/trackeditor/gui/properties/ObjectProperties.java +++ b/src/tools/trackeditor/gui/properties/ObjectProperties.java @@ -107,7 +107,7 @@ public class ObjectProperties extends PropertyPanel if (addObjectButton == null) { addObjectButton = new JButton(); - addObjectButton.setBounds(10, 387, 120, 25); + addObjectButton.setBounds(10, 414, 120, 25); addObjectButton.setText("Add Object"); addObjectButton.addActionListener(new java.awt.event.ActionListener() { @@ -136,7 +136,7 @@ public class ObjectProperties extends PropertyPanel if (deleteObjectButton == null) { deleteObjectButton = new JButton(); - deleteObjectButton.setBounds(140, 387, 120, 25); + deleteObjectButton.setBounds(140, 414, 120, 25); deleteObjectButton.setText("Delete Object"); deleteObjectButton.addActionListener(new java.awt.event.ActionListener() { @@ -162,7 +162,7 @@ public class ObjectProperties extends PropertyPanel if (copyObjectButton == null) { copyObjectButton = new JButton(); - copyObjectButton.setBounds(270, 387, 120, 25); + copyObjectButton.setBounds(270, 414, 120, 25); copyObjectButton.setText("Copy Object"); copyObjectButton.addActionListener(new java.awt.event.ActionListener() { @@ -186,7 +186,7 @@ public class ObjectProperties extends PropertyPanel if (pasteObjectButton == null) { pasteObjectButton = new JButton(); - pasteObjectButton.setBounds(400, 387, 120, 25); + pasteObjectButton.setBounds(400, 414, 120, 25); pasteObjectButton.setText("Paste Object"); pasteObjectButton.addActionListener(new java.awt.event.ActionListener() { @@ -224,7 +224,7 @@ public class ObjectProperties extends PropertyPanel { tabbedPane = new JTabbedPane(); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); - tabbedPane.setBounds(10, 10, 510, 367); + tabbedPane.setBounds(10, 10, 510, 394); Vector objects = null; if (defaultObjects) @@ -251,6 +251,8 @@ public class ObjectProperties extends PropertyPanel private JTextField nameTextField = new JTextField(); private JLabel objectLabel = new JLabel(); private JTextField objectTextField = new JTextField(); + private JLabel commentLabel = new JLabel(); + private JTextField commentTextField = new JTextField(); private JLabel colorLabel = new JLabel(); private JTextField colorTextField = new JTextField(); private JLabel orientationTypeLabel = new JLabel(); @@ -307,41 +309,44 @@ public class ObjectProperties extends PropertyPanel setLayout(null); addLabel(this, 0, nameLabel, "Name", 160); - addLabel(this, 1, objectLabel, "Object", 160); - addLabel(this, 2, colorLabel, "Color", 160); - addLabel(this, 3, orientationTypeLabel, "Orientation Type", 160); - addLabel(this, 4, borderDistanceLabel, "Border Distance", 160); - addLabel(this, 5, orientationLabel, "Orientation", 160); - addLabel(this, 6, deltaHeightLabel, "Delta Height", 160); - addLabel(this, 7, deltaVertLabel, "Delta Vert", 160); - addLabel(this, 8, scaleTypeLabel, "Scale Type", 160); - addLabel(this, 9, scaleLabel, "Scale", 160); - addLabel(this, 10, scaleMinLabel, "Scale Min", 160); - addLabel(this, 11, scaleMaxLabel, "Scale Max", 160); + addLabel(this, 1, objectLabel, "Object", 160); + addLabel(this, 2, commentLabel, "Comment", 160); + addLabel(this, 3, colorLabel, "Color", 160); + addLabel(this, 4, orientationTypeLabel, "Orientation Type", 160); + addLabel(this, 5, borderDistanceLabel, "Border Distance", 160); + addLabel(this, 6, orientationLabel, "Orientation", 160); + addLabel(this, 7, deltaHeightLabel, "Delta Height", 160); + addLabel(this, 8, deltaVertLabel, "Delta Vert", 160); + addLabel(this, 9, scaleTypeLabel, "Scale Type", 160); + addLabel(this, 10, scaleLabel, "Scale", 160); + addLabel(this, 11, scaleMinLabel, "Scale Min", 160); + addLabel(this, 12, scaleMaxLabel, "Scale Max", 160); addTextField(this, 0, nameTextField, object.getName(), 120, 125); addTextField(this, 1, objectTextField, object.getObject(), 120, 290); - addTextField(this, 2, colorTextField, toHexString(object.getColor()), 120, 125); + addTextField(this, 2, commentTextField, object.getComment(), 120, 380); + addTextField(this, 3, colorTextField, toHexString(object.getColor()), 120, 125); add(getOrientationTypeComboBox(), null); getOrientationTypeComboBox().setSelectedItem(toNoneString(object.getOrientationType())); - addTextField(this, 4, borderDistanceTextField, object.getBorderDistance(), 120, 125); - addTextField(this, 5, orientationTextField, object.getOrientation(), 120, 125); - addTextField(this, 6, deltaHeightTextField, object.getDeltaHeight(), 120, 125); - addTextField(this, 7, deltaVertTextField, object.getDeltaVert(), 120, 125); + addTextField(this, 5, borderDistanceTextField, object.getBorderDistance(), 120, 125); + addTextField(this, 6, orientationTextField, object.getOrientation(), 120, 125); + addTextField(this, 7, deltaHeightTextField, object.getDeltaHeight(), 120, 125); + addTextField(this, 8, deltaVertTextField, object.getDeltaVert(), 120, 125); add(getScaleTypeComboBox(), null); getScaleTypeComboBox().setSelectedItem(toNoneString(object.getScaleType())); - addTextField(this, 9, scaleTextField, object.getScale(), 120, 125); - addTextField(this, 10, scaleMinTextField, object.getScaleMin(), 120, 125); - addTextField(this, 11, scaleMaxTextField, object.getScaleMax(), 120, 125); + addTextField(this, 10, scaleTextField, object.getScale(), 120, 125); + addTextField(this, 11, scaleMinTextField, object.getScaleMin(), 120, 125); + addTextField(this, 12, scaleMaxTextField, object.getScaleMax(), 120, 125); if (defaultObjects) { nameTextField.setEnabled(false); objectTextField.setEnabled(false); + commentTextField.setEnabled(false); colorTextField.setEnabled(false); orientationTypeComboBox.setEnabled(false); orientationTextField.setEnabled(false); @@ -441,7 +446,7 @@ public class ObjectProperties extends PropertyPanel { String[] items = {"none", "random", "standard", "track", "terrain", "border"}; orientationTypeComboBox = new JComboBox(items); - orientationTypeComboBox.setBounds(120, 91, 125, 23); + orientationTypeComboBox.setBounds(120, 118, 125, 23); } return orientationTypeComboBox; } @@ -452,7 +457,7 @@ public class ObjectProperties extends PropertyPanel { String[] items = {"none", "random", "fixed"}; scaleTypeComboBox = new JComboBox(items); - scaleTypeComboBox.setBounds(120, 228, 125, 23); + scaleTypeComboBox.setBounds(120, 255, 125, 23); scaleTypeComboBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) @@ -603,7 +608,7 @@ public class ObjectProperties extends PropertyPanel if (colorButton == null) { colorButton = new JButton(); - colorButton.setBounds(420, 63, 80, 25); + colorButton.setBounds(420, 90, 80, 25); colorButton.setText("Browse"); colorButton.addActionListener(new java.awt.event.ActionListener() { @@ -708,6 +713,12 @@ public class ObjectProperties extends PropertyPanel getEditorFrame().documentIsModified = true; } + if (isDifferent(panel.commentTextField.getText(), object.getComment(), stringResult)) + { + object.setComment(stringResult.getValue()); + getEditorFrame().documentIsModified = true; + } + if (isDifferent(panel.colorTextField.getText(), object.getColor(), integerResult)) { object.setColor(integerResult.getValue()); diff --git a/src/tools/trackeditor/plugin/torcs/XmlReader.java b/src/tools/trackeditor/plugin/torcs/XmlReader.java index f591f0880..aa4ee905e 100644 --- a/src/tools/trackeditor/plugin/torcs/XmlReader.java +++ b/src/tools/trackeditor/plugin/torcs/XmlReader.java @@ -523,6 +523,7 @@ public class XmlReader Element object = (Element) it.next(); obj.setName(object.getAttribute("name").getValue()); obj.setObject(getAttrStrValue(object, "object")); + obj.setComment(getAttrStrValue(object, "comment")); obj.setColor(getAttrIntValue(object, "color")); obj.setOrientationType(getAttrStrValue(object, "orientation type")); obj.setBorderDistance(getAttrNumValue(object, "border distance", "m")); diff --git a/src/tools/trackeditor/plugin/torcs/XmlWriter.java b/src/tools/trackeditor/plugin/torcs/XmlWriter.java index 2c653fc72..bc8fd5360 100644 --- a/src/tools/trackeditor/plugin/torcs/XmlWriter.java +++ b/src/tools/trackeditor/plugin/torcs/XmlWriter.java @@ -656,6 +656,7 @@ public class XmlWriter el.setAttribute(new Attribute("name", object.getName())); addContent(el, "object", object.getObject()); + addContent(el, "comment", object.getComment()); addHexContent(el, "color", null, object.getColor()); addContent(el, "orientation type", object.getOrientationType()); addContent(el, "border distance", "m", object.getBorderDistance()); diff --git a/src/tools/trackeditor/utils/Properties.java b/src/tools/trackeditor/utils/Properties.java index cfe591b09..47a2971f5 100644 --- a/src/tools/trackeditor/utils/Properties.java +++ b/src/tools/trackeditor/utils/Properties.java @@ -34,7 +34,7 @@ public class Properties private static Properties instance = new Properties(); private Vector propertiesListeners = new Vector(); public final String title = "sd2-trackeditor"; - public final String version = "1.4.43"; + public final String version = "1.4.44"; private String path; private double imageScale = 1; diff --git a/src/tools/trackeditor/utils/circuit/TrackObject.java b/src/tools/trackeditor/utils/circuit/TrackObject.java index b716a1ba6..64b3872b7 100644 --- a/src/tools/trackeditor/utils/circuit/TrackObject.java +++ b/src/tools/trackeditor/utils/circuit/TrackObject.java @@ -3,6 +3,7 @@ package utils.circuit; public final class TrackObject { private String name = null; private String object = null; + private String comment = null; private int color = Integer.MAX_VALUE; private String orientationType = null; private double borderDistance = Double.NaN; @@ -26,6 +27,14 @@ public final class TrackObject { return object; } + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + public void setObject(String object) { this.object = object; }