Pause Function Added.

This commit is contained in:
mrbesen 2017-05-28 19:59:09 +02:00
parent ac05f9070e
commit 37d30d60b3
2 changed files with 24 additions and 1 deletions

View File

@ -31,6 +31,7 @@ public class Clicker implements Runnable{
private boolean doubleplayout = true;
private int truppenwait = 180;
private int randomness = 15;
private boolean paused = false;
private int mincolordistance = 35;
@ -39,6 +40,9 @@ public class Clicker implements Runnable{
return;
try {
Thread.sleep(ms);
while(paused) {
Thread.sleep(75);
}
} catch (InterruptedException e) {//when skip is applyed
;
}
@ -319,4 +323,13 @@ public class Clicker implements Runnable{
mincolordistance = minimumdistance;
System.out.println(colornum + ": "+c.getRed() + " " + c.getGreen() + " " + c.getBlue());
}
public boolean isPaused() {
return paused;
}
public void setPause(boolean b) {
paused = b;
}
}

View File

@ -53,8 +53,9 @@ public class UI implements ActionListener {
new PosColSelector(this, "Arena View", false, 7,1)
};
private JButton skip = new JButton("SKIP"); // the button, to skip waiting
private JButton start = new JButton("START");
private JButton skip = new JButton("SKIP"); // the button, to skip waiting
private JButton pause = new JButton("Pause");
private JButton exit = new JButton("EXIT");
private JLabel info = new JLabel("Define positions, to start.");
@ -161,6 +162,15 @@ public class UI implements ActionListener {
bot.stop();
frame.setVisible(false);
System.exit(0);
} else if(srcb.equals(pause)) {
if(bot.isPaused()) {//the bot is going to be unpaused
pause.setText("Pause");
info("Unpaused.");
} else {//the bot is going to be paused.
pause.setText("Unpause");
info("Paused.");
}
bot.setPause(!bot.isPaused());
}
} else if(src instanceof JMenuItem) {
JMenuItem srcI = (JMenuItem) src;