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 */
|
/** 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;
|
||||||
@ -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,37 +883,41 @@ 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();
|
|
||||||
setLoadedScene(null, false);
|
|
||||||
final SceneRequest current = currentRequest;
|
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() {
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
if (!active) {
|
if (!active) {
|
||||||
close();
|
close();
|
||||||
setActivatedNodes(new org.openide.nodes.Node[]{});
|
setActivatedNodes(new org.openide.nodes.Node[]{});
|
||||||
@ -926,10 +930,8 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
|
|||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
requestActive();
|
requestActive();
|
||||||
// setActivatedNodes(new org.openide.nodes.Node[]{jmeNode});
|
setActivatedNodes(new org.openide.nodes.Node[]{jmeNode});
|
||||||
editorController.checkVehicle();
|
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…
x
Reference in New Issue
Block a user