handle close request per state
This commit is contained in:
parent
4ba32c44f2
commit
66ee2a0979
|
@ -120,7 +120,7 @@ public class Demux implements KeyListener, MouseListener {
|
|||
}
|
||||
|
||||
public boolean onCloseRequest() {
|
||||
return !isTransitioning();
|
||||
return state.onCloseRequest();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -19,6 +19,11 @@ package yugecin.opsudance.core.state;
|
|||
|
||||
public abstract class BaseOpsuState implements OpsuState {
|
||||
|
||||
@Override
|
||||
public boolean onCloseRequest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, char c) {
|
||||
return false;
|
||||
|
|
|
@ -27,6 +27,11 @@ public interface OpsuState {
|
|||
void enter();
|
||||
void leave();
|
||||
|
||||
/**
|
||||
* @return true if closing is allowed
|
||||
*/
|
||||
boolean onCloseRequest();
|
||||
|
||||
/**
|
||||
* @return false to stop event bubbling
|
||||
*/
|
||||
|
|
|
@ -71,4 +71,9 @@ public abstract class TransitionState extends BaseOpsuState {
|
|||
listener.onFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCloseRequest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,6 +65,11 @@ public class EmptyRedState implements OpsuState {
|
|||
public void leave() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCloseRequest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, char c) {
|
||||
System.out.println("pressed");
|
||||
|
|
|
@ -62,6 +62,11 @@ public class EmptyState implements OpsuState {
|
|||
public void leave() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCloseRequest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, char c) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user