diff --git a/src/com/thistestuser/cursormacro/player/DefaultPlayer.java b/src/com/thistestuser/cursormacro/player/DefaultPlayer.java index c681090..f0e7aea 100644 --- a/src/com/thistestuser/cursormacro/player/DefaultPlayer.java +++ b/src/com/thistestuser/cursormacro/player/DefaultPlayer.java @@ -80,6 +80,12 @@ public boolean isRunning() return execution != null && execution.isAlive(); } + @Override + public boolean shouldStop() + { + return !playing; + } + @Override public boolean hasInstructions() { diff --git a/src/com/thistestuser/cursormacro/player/Player.java b/src/com/thistestuser/cursormacro/player/Player.java index f1381d0..9c94ec2 100644 --- a/src/com/thistestuser/cursormacro/player/Player.java +++ b/src/com/thistestuser/cursormacro/player/Player.java @@ -30,6 +30,11 @@ public abstract class Player * Check if the thread has terminated yet. If this is true, nothing is allowed to be run. */ public abstract boolean isRunning(); + + /** + * Returns if the execution should stop. This is used to exit from instructions that may run forever. + */ + public abstract boolean shouldStop(); public void registerMouse(boolean press, int button) { diff --git a/src/com/thistestuser/cursormacro/player/custom/HotkeyPlayer.java b/src/com/thistestuser/cursormacro/player/custom/HotkeyPlayer.java index e9fc012..2ba7a94 100644 --- a/src/com/thistestuser/cursormacro/player/custom/HotkeyPlayer.java +++ b/src/com/thistestuser/cursormacro/player/custom/HotkeyPlayer.java @@ -61,6 +61,12 @@ public boolean isRunning() return execution != null && execution.isAlive(); } + @Override + public boolean shouldStop() + { + return !listening; + } + public void activateKeyMacro(int keyCode) { if(!listening || isRunning())