diff --git a/src/yugecin/opsudance/core/Demux.java b/src/yugecin/opsudance/core/Demux.java index a4361ca2..4d3d5c52 100644 --- a/src/yugecin/opsudance/core/Demux.java +++ b/src/yugecin/opsudance/core/Demux.java @@ -120,7 +120,7 @@ public class Demux implements KeyListener, MouseListener { } public boolean onCloseRequest() { - return !isTransitioning(); + return state.onCloseRequest(); } /* diff --git a/src/yugecin/opsudance/core/state/BaseOpsuState.java b/src/yugecin/opsudance/core/state/BaseOpsuState.java index 512387e1..faeef07b 100644 --- a/src/yugecin/opsudance/core/state/BaseOpsuState.java +++ b/src/yugecin/opsudance/core/state/BaseOpsuState.java @@ -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; diff --git a/src/yugecin/opsudance/core/state/OpsuState.java b/src/yugecin/opsudance/core/state/OpsuState.java index b2e070fb..22611efa 100644 --- a/src/yugecin/opsudance/core/state/OpsuState.java +++ b/src/yugecin/opsudance/core/state/OpsuState.java @@ -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 */ diff --git a/src/yugecin/opsudance/core/state/transitions/TransitionState.java b/src/yugecin/opsudance/core/state/transitions/TransitionState.java index 8b839b0d..3af5a749 100644 --- a/src/yugecin/opsudance/core/state/transitions/TransitionState.java +++ b/src/yugecin/opsudance/core/state/transitions/TransitionState.java @@ -71,4 +71,9 @@ public abstract class TransitionState extends BaseOpsuState { listener.onFinish(); } + @Override + public boolean onCloseRequest() { + return false; + } + } diff --git a/src/yugecin/opsudance/states/EmptyRedState.java b/src/yugecin/opsudance/states/EmptyRedState.java index e00eeaaf..eb40cdc9 100644 --- a/src/yugecin/opsudance/states/EmptyRedState.java +++ b/src/yugecin/opsudance/states/EmptyRedState.java @@ -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"); diff --git a/src/yugecin/opsudance/states/EmptyState.java b/src/yugecin/opsudance/states/EmptyState.java index 8e189941..d161f1cb 100644 --- a/src/yugecin/opsudance/states/EmptyState.java +++ b/src/yugecin/opsudance/states/EmptyState.java @@ -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;