Skip to content

Commit

Permalink
Introduce shouldStop()
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisTestUser committed Jun 6, 2022
1 parent d365220 commit 2e30572
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/com/thistestuser/cursormacro/player/DefaultPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public boolean isRunning()
return execution != null && execution.isAlive();
}

@Override
public boolean shouldStop()
{
return !playing;
}

@Override
public boolean hasInstructions()
{
Expand Down
5 changes: 5 additions & 0 deletions src/com/thistestuser/cursormacro/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 2e30572

Please sign in to comment.