SDK:
- fix Vehicle Creator scene opening git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8624 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
122d438e9d
commit
5cf69aa5fd
@ -37,6 +37,7 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
|
||||
/** path to the icon used by the component and its open action */
|
||||
static final String ICON_PATH = "com/jme3/gde/vehiclecreator/objects_039.gif";
|
||||
private static final String PREFERRED_ID = "VehicleCreatorTopComponent";
|
||||
private VehicleEditorController newEditorController;
|
||||
private VehicleEditorController editorController;
|
||||
private SceneRequest currentRequest;
|
||||
private SceneRequest sentRequest;
|
||||
@ -806,7 +807,7 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
|
||||
protected void componentActivated() {
|
||||
SceneViewerTopComponent.findInstance().requestVisible();
|
||||
}
|
||||
|
||||
|
||||
void writeProperties(java.util.Properties p) {
|
||||
// better to version settings since initial version as advocated at
|
||||
// http://wiki.apidesign.org/wiki/PropertyFiles
|
||||
@ -837,7 +838,6 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
private SuspensionSettings getSuspensionSettings() {
|
||||
SuspensionSettings settings = new SuspensionSettings();
|
||||
settings.setFriction((Float) frictionSpinner.getValue());
|
||||
@ -869,12 +869,12 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
|
||||
|
||||
public void openFile(BinaryModelDataObject file, Node spatial) {
|
||||
JmeNode node = NodeUtility.createNode(spatial, false);
|
||||
editorController = new VehicleEditorController(node, file);
|
||||
newEditorController = new VehicleEditorController(node, file);
|
||||
SceneApplication.getApplication().addSceneListener(this);
|
||||
sentRequest = new SceneRequest(this, node, file.getLookup().lookup(ProjectAssetManager.class));
|
||||
sentRequest.setWindowTitle("Vehicle Creator");
|
||||
sentRequest.setDataObject(file);
|
||||
sentRequest.setToolNode(editorController.getToolsNode());
|
||||
sentRequest.setToolNode(newEditorController.getToolsNode());
|
||||
sentRequest.setHelpCtx(ctx);
|
||||
SceneApplication.getApplication().openScene(sentRequest);
|
||||
}
|
||||
@ -883,53 +883,55 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
|
||||
}
|
||||
|
||||
public void sceneClosed(SceneRequest request) {
|
||||
if (request == sentRequest) {
|
||||
currentRequest = request;
|
||||
if (request == currentRequest) {
|
||||
SceneApplication.getApplication().removeSceneListener(this);
|
||||
editorController.cleanupApplication();
|
||||
setLoadedScene(null, false);
|
||||
final SceneRequest current= currentRequest;
|
||||
final SceneRequest current = currentRequest;
|
||||
currentRequest = null;
|
||||
final VehicleEditorController controller = editorController;
|
||||
setLoadedScene(null, false);
|
||||
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
||||
|
||||
public Void call() throws Exception {
|
||||
current.getRootNode().getParent().removeLight(dirLight);
|
||||
SceneApplication.getApplication().getStateManager().detach(editorController.getBulletState());
|
||||
controller.cleanupApplication();
|
||||
// current.getRootNode().removeLight(dirLight);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void sceneOpened(SceneRequest request) {
|
||||
if (request == currentRequest) {
|
||||
editorController.prepareApplication();
|
||||
SceneApplication.getApplication().getStateManager().attach(editorController.getBulletState());
|
||||
setLoadedScene(currentRequest.getJmeNode(), true);
|
||||
currentRequest.getRootNode().getParent().addLight(dirLight);
|
||||
public void sceneOpened(final SceneRequest request) {
|
||||
if (request == sentRequest) {
|
||||
currentRequest = request;
|
||||
editorController = newEditorController;
|
||||
setLoadedScene(currentRequest.getDataObject().getNodeDelegate(), true);
|
||||
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) {
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
if (!active) {
|
||||
close();
|
||||
setActivatedNodes(new org.openide.nodes.Node[]{});
|
||||
if (editorController != null) {
|
||||
editorController.cleanup();
|
||||
editorController = null;
|
||||
}
|
||||
} else {
|
||||
if (!isOpened()) {
|
||||
open();
|
||||
}
|
||||
requestActive();
|
||||
// setActivatedNodes(new org.openide.nodes.Node[]{jmeNode});
|
||||
editorController.checkVehicle();
|
||||
}
|
||||
if (!active) {
|
||||
close();
|
||||
setActivatedNodes(new org.openide.nodes.Node[]{});
|
||||
if (editorController != null) {
|
||||
editorController.cleanup();
|
||||
editorController = null;
|
||||
}
|
||||
});
|
||||
} 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() {
|
||||
SceneApplication.getApplication().getStateManager().attach(getBulletState());
|
||||
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_Up", new KeyTrigger(KeyInput.KEY_W));
|
||||
@ -116,6 +117,7 @@ public class VehicleEditorController implements LookupListener, ActionListener {
|
||||
SceneApplication.getApplication().getInputManager().removeListener(this);
|
||||
cameraController.disable();
|
||||
cameraController = null;
|
||||
SceneApplication.getApplication().getStateManager().detach(getBulletState());
|
||||
}
|
||||
|
||||
public JmeSpatial getJmeRootNode() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user