From a309cbd62977ad4521ef1c0b2887ee7d8fdec6ab Mon Sep 17 00:00:00 2001 From: iobyte Date: Mon, 19 Feb 2024 20:37:37 +0000 Subject: [PATCH] trackeditor: remember surface, object, camera and light properties tabs git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9329 30fe4595-0a0c-4342-8851-515496e4dcbd --- src/tools/trackeditor/gui/EditorFrame.java | 8 ++++ .../gui/properties/CameraProperties.java | 13 ++++++ .../gui/properties/ObjectProperties.java | 13 ++++++ .../gui/properties/SurfaceProperties.java | 13 ++++++ .../gui/properties/TrackLightProperties.java | 13 ++++++ src/tools/trackeditor/utils/Project.java | 44 +++++++++++++++++++ src/tools/trackeditor/utils/Properties.java | 2 +- 7 files changed, 105 insertions(+), 1 deletion(-) diff --git a/src/tools/trackeditor/gui/EditorFrame.java b/src/tools/trackeditor/gui/EditorFrame.java index 23e5cfda3..71db3d521 100644 --- a/src/tools/trackeditor/gui/EditorFrame.java +++ b/src/tools/trackeditor/gui/EditorFrame.java @@ -917,6 +917,10 @@ public class EditorFrame extends JFrame getProject().setPropertiesEditorX(preferences.getInt("PropertiesEditorX", 0)); getProject().setPropertiesEditorY(preferences.getInt("PropertiesEditorY", 0)); getProject().setPropertiesEditorTab(preferences.getInt("PropertiesEditorTab", 0)); + getProject().setPropertiesEditorSurfaceTab(preferences.getInt("PropertiesEditorSurfaceTab", 0)); + getProject().setPropertiesEditorObjectTab(preferences.getInt("PropertiesEditorObjectTab", 0)); + getProject().setPropertiesEditorCameraTab(preferences.getInt("PropertiesEditorCameraTab", 0)); + getProject().setPropertiesEditorLightTab(preferences.getInt("PropertiesEditorLightTab", 0)); getProject().setDefaultSurfacesDialogX(preferences.getInt("DefaultSurfacesDialogX", 0)); getProject().setDefaultSurfacesDialogY(preferences.getInt("DefaultSurfacesDialogY", 0)); getProject().setDefaultObjectsDialogX(preferences.getInt("DefaultObjectsDialogX", 0)); @@ -3289,6 +3293,10 @@ public class EditorFrame extends JFrame preferences.putInt("PropertiesEditorX", getProject().getPropertiesEditorX()); preferences.putInt("PropertiesEditorY", getProject().getPropertiesEditorY()); preferences.putInt("PropertiesEditorTab", getProject().getPropertiesEditorTab()); + preferences.putInt("PropertiesEditorSurfaceTab", getProject().getPropertiesEditorSurfaceTab()); + preferences.putInt("PropertiesEditorObjectTab", getProject().getPropertiesEditorObjectTab()); + preferences.putInt("PropertiesEditorCameraTab", getProject().getPropertiesEditorCameraTab()); + preferences.putInt("PropertiesEditorLightTab", getProject().getPropertiesEditorLightTab()); preferences.putInt("DefaultSurfacesDialogX", getProject().getDefaultSurfacesDialogX()); preferences.putInt("DefaultSurfacesDialogY", getProject().getDefaultSurfacesDialogY()); preferences.putInt("DefaultObjectsDialogX", getProject().getDefaultObjectsDialogX()); diff --git a/src/tools/trackeditor/gui/properties/CameraProperties.java b/src/tools/trackeditor/gui/properties/CameraProperties.java index 6ccd1de6f..b51dee8f2 100644 --- a/src/tools/trackeditor/gui/properties/CameraProperties.java +++ b/src/tools/trackeditor/gui/properties/CameraProperties.java @@ -27,6 +27,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; +import javax.swing.SwingUtilities; import gui.EditorFrame; import utils.MutableDouble; @@ -144,6 +145,16 @@ public class CameraProperties extends PropertyPanel Camera camera = cameras.elementAt(i); tabbedPane.addTab(camera.getName(), null, new CameraPanel(camera), null); } + SwingUtilities.invokeLater( new Runnable() + { + public void run() + { + int lastTab = getEditorFrame().getProject().getPropertiesEditorCameraTab(); + + if (lastTab < tabbedPane.getTabCount()) + tabbedPane.setSelectedIndex(lastTab); + } + }); } return tabbedPane; } @@ -298,5 +309,7 @@ public class CameraProperties extends PropertyPanel cameras.add(camera); } } + + getEditorFrame().getProject().setPropertiesEditorCameraTab(this.tabbedPane.getSelectedIndex()); } } // @jve:decl-index=0:visual-constraint="10,10" diff --git a/src/tools/trackeditor/gui/properties/ObjectProperties.java b/src/tools/trackeditor/gui/properties/ObjectProperties.java index 196cfe7ea..c719fca91 100644 --- a/src/tools/trackeditor/gui/properties/ObjectProperties.java +++ b/src/tools/trackeditor/gui/properties/ObjectProperties.java @@ -37,6 +37,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; +import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.event.DocumentEvent; @@ -241,6 +242,16 @@ public class ObjectProperties extends PropertyPanel TrackObject object = objects.elementAt(i); tabbedPane.addTab(object.getName(), null, new ObjectPanel(object), null); } + SwingUtilities.invokeLater( new Runnable() + { + public void run() + { + int lastTab = getEditorFrame().getProject().getPropertiesEditorObjectTab(); + + if (lastTab < tabbedPane.getTabCount()) + tabbedPane.setSelectedIndex(lastTab); + } + }); } return tabbedPane; } @@ -798,6 +809,8 @@ public class ObjectProperties extends PropertyPanel objects.add(object); } } + + getEditorFrame().getProject().setPropertiesEditorObjectTab(this.tabbedPane.getSelectedIndex()); } private void setObjectFromPanel(TrackObject object, ObjectPanel panel) diff --git a/src/tools/trackeditor/gui/properties/SurfaceProperties.java b/src/tools/trackeditor/gui/properties/SurfaceProperties.java index 4ae70fa40..95a76e51b 100644 --- a/src/tools/trackeditor/gui/properties/SurfaceProperties.java +++ b/src/tools/trackeditor/gui/properties/SurfaceProperties.java @@ -30,6 +30,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; +import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.filechooser.FileNameExtensionFilter; @@ -229,6 +230,16 @@ public class SurfaceProperties extends PropertyPanel Surface surface = surfaces.elementAt(i); tabbedPane.addTab(surface.getName(), null, new SurfacePanel(surface), null); } + SwingUtilities.invokeLater( new Runnable() + { + public void run() + { + int lastTab = getEditorFrame().getProject().getPropertiesEditorSurfaceTab(); + + if (lastTab < tabbedPane.getTabCount()) + tabbedPane.setSelectedIndex(lastTab); + } + }); } return tabbedPane; } @@ -788,6 +799,8 @@ public class SurfaceProperties extends PropertyPanel surfaces.add(surface); } } + + getEditorFrame().getProject().setPropertiesEditorSurfaceTab(this.tabbedPane.getSelectedIndex()); } private void setSurfaceFromPanel(Surface surface, SurfacePanel panel) diff --git a/src/tools/trackeditor/gui/properties/TrackLightProperties.java b/src/tools/trackeditor/gui/properties/TrackLightProperties.java index 2206ede78..53bae6064 100644 --- a/src/tools/trackeditor/gui/properties/TrackLightProperties.java +++ b/src/tools/trackeditor/gui/properties/TrackLightProperties.java @@ -29,6 +29,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; +import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.filechooser.FileNameExtensionFilter; @@ -149,6 +150,16 @@ public class TrackLightProperties extends PropertyPanel TrackLight light = lights.elementAt(i); tabbedPane.addTab(light.getName(), null, new TrackLightPanel(light), null); } + SwingUtilities.invokeLater( new Runnable() + { + public void run() + { + int lastTab = getEditorFrame().getProject().getPropertiesEditorLightTab(); + + if (lastTab < tabbedPane.getTabCount()) + tabbedPane.setSelectedIndex(lastTab); + } + }); } return tabbedPane; } @@ -469,5 +480,7 @@ public class TrackLightProperties extends PropertyPanel lights.add(light); } } + + getEditorFrame().getProject().setPropertiesEditorLightTab(this.tabbedPane.getSelectedIndex()); } } // @jve:decl-index=0:visual-constraint="10,10" diff --git a/src/tools/trackeditor/utils/Project.java b/src/tools/trackeditor/utils/Project.java index 858ea2d7c..ef9e89066 100644 --- a/src/tools/trackeditor/utils/Project.java +++ b/src/tools/trackeditor/utils/Project.java @@ -49,6 +49,10 @@ public class Project private int checkDialogY = 0; private int checkDialogWidth = 0; private int checkDialogHeight = 0; + private int propertiesEditorSurfaceTab = 0; + private int propertiesEditorObjectTab = 0; + private int propertiesEditorCameraTab = 0; + private int propertiesEditorLightTab = 0; public Project() { @@ -281,4 +285,44 @@ public class Project { this.checkDialogHeight = checkDialogHeight; } + + public int getPropertiesEditorSurfaceTab() + { + return propertiesEditorSurfaceTab; + } + + public void setPropertiesEditorSurfaceTab(int propertiesEditorSurfaceTab) + { + this.propertiesEditorSurfaceTab = propertiesEditorSurfaceTab; + } + + public int getPropertiesEditorObjectTab() + { + return propertiesEditorObjectTab; + } + + public void setPropertiesEditorObjectTab(int propertiesEditorObjectTab) + { + this.propertiesEditorObjectTab = propertiesEditorObjectTab; + } + + public int getPropertiesEditorCameraTab() + { + return propertiesEditorCameraTab; + } + + public void setPropertiesEditorCameraTab(int propertiesEditorCameraTab) + { + this.propertiesEditorCameraTab = propertiesEditorCameraTab; + } + + public int getPropertiesEditorLightTab() + { + return propertiesEditorLightTab; + } + + public void setPropertiesEditorLightTab(int propertiesEditorLightTab) + { + this.propertiesEditorLightTab = propertiesEditorLightTab; + } } diff --git a/src/tools/trackeditor/utils/Properties.java b/src/tools/trackeditor/utils/Properties.java index d4b40cc7c..4110ae284 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.48"; + public final String version = "1.4.49"; private String path; private double imageScale = 1;