- fix Vehicle Creator scene opening

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8624 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent 122d438e9d
commit 5cf69aa5fd
  1. 74
      sdk/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java
  2. 2
      sdk/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java

@ -37,6 +37,7 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
/** path to the icon used by the component and its open action */ /** path to the icon used by the component and its open action */
static final String ICON_PATH = "com/jme3/gde/vehiclecreator/objects_039.gif"; static final String ICON_PATH = "com/jme3/gde/vehiclecreator/objects_039.gif";
private static final String PREFERRED_ID = "VehicleCreatorTopComponent"; private static final String PREFERRED_ID = "VehicleCreatorTopComponent";
private VehicleEditorController newEditorController;
private VehicleEditorController editorController; private VehicleEditorController editorController;
private SceneRequest currentRequest; private SceneRequest currentRequest;
private SceneRequest sentRequest; private SceneRequest sentRequest;
@ -806,7 +807,7 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
protected void componentActivated() { protected void componentActivated() {
SceneViewerTopComponent.findInstance().requestVisible(); SceneViewerTopComponent.findInstance().requestVisible();
} }
void writeProperties(java.util.Properties p) { void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at // better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles // http://wiki.apidesign.org/wiki/PropertyFiles
@ -837,7 +838,6 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
return ctx; return ctx;
} }
private SuspensionSettings getSuspensionSettings() { private SuspensionSettings getSuspensionSettings() {
SuspensionSettings settings = new SuspensionSettings(); SuspensionSettings settings = new SuspensionSettings();
settings.setFriction((Float) frictionSpinner.getValue()); settings.setFriction((Float) frictionSpinner.getValue());
@ -869,12 +869,12 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
public void openFile(BinaryModelDataObject file, Node spatial) { public void openFile(BinaryModelDataObject file, Node spatial) {
JmeNode node = NodeUtility.createNode(spatial, false); JmeNode node = NodeUtility.createNode(spatial, false);
editorController = new VehicleEditorController(node, file); newEditorController = new VehicleEditorController(node, file);
SceneApplication.getApplication().addSceneListener(this); SceneApplication.getApplication().addSceneListener(this);
sentRequest = new SceneRequest(this, node, file.getLookup().lookup(ProjectAssetManager.class)); sentRequest = new SceneRequest(this, node, file.getLookup().lookup(ProjectAssetManager.class));
sentRequest.setWindowTitle("Vehicle Creator"); sentRequest.setWindowTitle("Vehicle Creator");
sentRequest.setDataObject(file); sentRequest.setDataObject(file);
sentRequest.setToolNode(editorController.getToolsNode()); sentRequest.setToolNode(newEditorController.getToolsNode());
sentRequest.setHelpCtx(ctx); sentRequest.setHelpCtx(ctx);
SceneApplication.getApplication().openScene(sentRequest); SceneApplication.getApplication().openScene(sentRequest);
} }
@ -883,53 +883,55 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
} }
public void sceneClosed(SceneRequest request) { public void sceneClosed(SceneRequest request) {
if (request == sentRequest) { if (request == currentRequest) {
currentRequest = request;
SceneApplication.getApplication().removeSceneListener(this); SceneApplication.getApplication().removeSceneListener(this);
editorController.cleanupApplication(); final SceneRequest current = currentRequest;
setLoadedScene(null, false);
final SceneRequest current= currentRequest;
currentRequest = null; currentRequest = null;
final VehicleEditorController controller = editorController;
setLoadedScene(null, false);
SceneApplication.getApplication().enqueue(new Callable<Void>() { SceneApplication.getApplication().enqueue(new Callable<Void>() {
public Void call() throws Exception { public Void call() throws Exception {
current.getRootNode().getParent().removeLight(dirLight); controller.cleanupApplication();
SceneApplication.getApplication().getStateManager().detach(editorController.getBulletState()); // current.getRootNode().removeLight(dirLight);
return null; return null;
} }
}); });
} }
} }
public void sceneOpened(SceneRequest request) { public void sceneOpened(final SceneRequest request) {
if (request == currentRequest) { if (request == sentRequest) {
editorController.prepareApplication(); currentRequest = request;
SceneApplication.getApplication().getStateManager().attach(editorController.getBulletState()); editorController = newEditorController;
setLoadedScene(currentRequest.getJmeNode(), true); setLoadedScene(currentRequest.getDataObject().getNodeDelegate(), true);
currentRequest.getRootNode().getParent().addLight(dirLight); final VehicleEditorController controller = editorController;
SceneApplication.getApplication().enqueue(new Callable<Void>() {
public Void call() throws Exception {
controller.prepareApplication();
// request.getRootNode().addLight(dirLight);
return null;
}
});
} }
} }
private void setLoadedScene(final org.openide.nodes.Node jmeNode, final boolean active) { private void setLoadedScene(final org.openide.nodes.Node jmeNode, final boolean active) {
java.awt.EventQueue.invokeLater(new Runnable() { if (!active) {
close();
public void run() { setActivatedNodes(new org.openide.nodes.Node[]{});
if (!active) { if (editorController != null) {
close(); editorController.cleanup();
setActivatedNodes(new org.openide.nodes.Node[]{}); editorController = null;
if (editorController != null) {
editorController.cleanup();
editorController = null;
}
} else {
if (!isOpened()) {
open();
}
requestActive();
// setActivatedNodes(new org.openide.nodes.Node[]{jmeNode});
editorController.checkVehicle();
}
} }
}); } else {
if (!isOpened()) {
open();
}
requestActive();
setActivatedNodes(new org.openide.nodes.Node[]{jmeNode});
editorController.checkVehicle();
}
} }
} }

@ -99,6 +99,7 @@ public class VehicleEditorController implements LookupListener, ActionListener {
} }
public void prepareApplication() { public void prepareApplication() {
SceneApplication.getApplication().getStateManager().attach(getBulletState());
SceneApplication.getApplication().getInputManager().addMapping("VehicleEditor_Left", new KeyTrigger(KeyInput.KEY_A)); SceneApplication.getApplication().getInputManager().addMapping("VehicleEditor_Left", new KeyTrigger(KeyInput.KEY_A));
SceneApplication.getApplication().getInputManager().addMapping("VehicleEditor_Right", new KeyTrigger(KeyInput.KEY_D)); SceneApplication.getApplication().getInputManager().addMapping("VehicleEditor_Right", new KeyTrigger(KeyInput.KEY_D));
SceneApplication.getApplication().getInputManager().addMapping("VehicleEditor_Up", new KeyTrigger(KeyInput.KEY_W)); SceneApplication.getApplication().getInputManager().addMapping("VehicleEditor_Up", new KeyTrigger(KeyInput.KEY_W));
@ -116,6 +117,7 @@ public class VehicleEditorController implements LookupListener, ActionListener {
SceneApplication.getApplication().getInputManager().removeListener(this); SceneApplication.getApplication().getInputManager().removeListener(this);
cameraController.disable(); cameraController.disable();
cameraController = null; cameraController = null;
SceneApplication.getApplication().getStateManager().detach(getBulletState());
} }
public JmeSpatial getJmeRootNode() { public JmeSpatial getJmeRootNode() {

Loading…
Cancel
Save