Modified fly cam to be a little more resilient
in the face of being called before it sees an input manager. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9162 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
fef809b3f0
commit
0c835eae80
@ -124,7 +124,7 @@ public class FlyByCamera implements AnalogListener, ActionListener {
|
|||||||
*/
|
*/
|
||||||
public void setEnabled(boolean enable){
|
public void setEnabled(boolean enable){
|
||||||
if (enabled && !enable){
|
if (enabled && !enable){
|
||||||
if (!dragToRotate || (dragToRotate && canRotate)){
|
if (inputManager!= null && (!dragToRotate || (dragToRotate && canRotate))){
|
||||||
inputManager.setCursorVisible(true);
|
inputManager.setCursorVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +161,9 @@ public class FlyByCamera implements AnalogListener, ActionListener {
|
|||||||
*/
|
*/
|
||||||
public void setDragToRotate(boolean dragToRotate) {
|
public void setDragToRotate(boolean dragToRotate) {
|
||||||
this.dragToRotate = dragToRotate;
|
this.dragToRotate = dragToRotate;
|
||||||
inputManager.setCursorVisible(dragToRotate);
|
if (inputManager != null) {
|
||||||
|
inputManager.setCursorVisible(dragToRotate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,7 +201,7 @@ public class FlyByCamera implements AnalogListener, ActionListener {
|
|||||||
inputManager.addMapping("FLYCAM_Lower", new KeyTrigger(KeyInput.KEY_Z));
|
inputManager.addMapping("FLYCAM_Lower", new KeyTrigger(KeyInput.KEY_Z));
|
||||||
|
|
||||||
inputManager.addListener(this, mappings);
|
inputManager.addListener(this, mappings);
|
||||||
inputManager.setCursorVisible(dragToRotate);
|
inputManager.setCursorVisible(dragToRotate || !isEnabled());
|
||||||
|
|
||||||
Joystick[] joysticks = inputManager.getJoysticks();
|
Joystick[] joysticks = inputManager.getJoysticks();
|
||||||
if (joysticks != null && joysticks.length > 0){
|
if (joysticks != null && joysticks.length > 0){
|
||||||
@ -218,6 +220,10 @@ public class FlyByCamera implements AnalogListener, ActionListener {
|
|||||||
*/
|
*/
|
||||||
public void unregisterInput(){
|
public void unregisterInput(){
|
||||||
|
|
||||||
|
if (inputManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (String s : mappings) {
|
for (String s : mappings) {
|
||||||
inputManager.deleteMapping( s );
|
inputManager.deleteMapping( s );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user