restoreButton.setVisible(false);
this.addChild(restoreButton);
menuShape.addGestureListener(DragProcessor.class, new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
DragEvent de = (DragEvent)ge;
switch (de.getId()) {
case MTGestureEvent.GESTURE_DETECTED:
restoreButton.setVisible(true);
closeButton.setVisible(true);
unhighlightButton(closeButton, buttonOpacity);
unhighlightButton(restoreButton, buttonOpacity);
break;
case MTGestureEvent.GESTURE_UPDATED:
//Mouse over effect
if (closeButton.containsPointGlobal(de.getTo())){
highlightButton(closeButton);
}else{
unhighlightButton(closeButton, buttonOpacity);
}
if (restoreButton.containsPointGlobal(de.getTo())){
highlightButton(restoreButton);
}else{
unhighlightButton(restoreButton, buttonOpacity);
}
break;
case MTGestureEvent.GESTURE_ENDED:
unhighlightButton(closeButton, buttonOpacity);
unhighlightButton(restoreButton, buttonOpacity);
InputCursor cursor = de.getDragCursor();
Vector3D restoreButtonIntersection = restoreButton.getIntersectionGlobal(Tools3D.getCameraPickRay(getRenderer(), restoreButton, cursor.getCurrentEvtPosX(), cursor.getCurrentEvtPosY()));
if (restoreButtonIntersection != null){
logger.debug("--> RESTORE!");
MTSceneMenu.this.sceneTexture.restore();
}
Vector3D closeButtonIntersection = closeButton.getIntersectionGlobal(Tools3D.getCameraPickRay(getRenderer(), closeButton, cursor.getCurrentEvtPosX(), cursor.getCurrentEvtPosY()));
if (closeButtonIntersection != null){
// if (app.popScene()){
// app.removeScene(scene); //FIXME wont work if the scene has a transition because we cant remove the still active scene
//// destroy(); //this will be destroyed with the scene
// sceneTexture.destroy(); //destroys also the MTSceneWindow and with it the scene
// logger.debug("--> CLOSE!");
// }
if (sceneTexture.restore()){
// app.removeScene(scene); //FIXME wont work if the scene has a transition because we cant remove the still active scene
// destroy(); //this will be destroyed with the scene
sceneTexture.destroy(); //destroys also the MTSceneWindow and with it the scene
logger.debug("--> CLOSE!");
}
}
restoreButton.setVisible(false);
closeButton.setVisible(false);
break;
default:
break;
}
return false;
}
});
}else{
if (scene != null){
menuShape.addGestureListener(DragProcessor.class, new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
DragEvent de = (DragEvent)ge;
switch (de.getId()) {
case MTGestureEvent.GESTURE_DETECTED:
closeButton.setVisible(true);
unhighlightButton(closeButton, buttonOpacity);
break;
case MTGestureEvent.GESTURE_UPDATED:
//Mouse over effect
if (closeButton.containsPointGlobal(de.getTo())){
highlightButton(closeButton);
}else{
unhighlightButton(closeButton, buttonOpacity);
}
break;
case MTGestureEvent.GESTURE_ENDED:
unhighlightButton(closeButton, buttonOpacity);
InputCursor cursor = de.getDragCursor();
Vector3D closeButtonIntersection = closeButton.getIntersectionGlobal(Tools3D.getCameraPickRay(getRenderer(), closeButton, cursor.getCurrentEvtPosX(), cursor.getCurrentEvtPosY()));
if (closeButtonIntersection != null){
if (app.popScene()){
destroy(); //Destroy this
scene.destroy(); //Destroy the scene