Added Overlay
This commit is contained in:
parent
2ba3e835ca
commit
ae521ece46
|
@ -37,6 +37,7 @@ public class Clicker implements Runnable{
|
||||||
private final int waittime = 50;//time between mouse teleports and clicks
|
private final int waittime = 50;//time between mouse teleports and clicks
|
||||||
|
|
||||||
private int mincolordistance = 35;
|
private int mincolordistance = 35;
|
||||||
|
private Overlay ov = null;
|
||||||
|
|
||||||
OSType os;
|
OSType os;
|
||||||
|
|
||||||
|
@ -394,4 +395,16 @@ public class Clicker implements Runnable{
|
||||||
OSX,
|
OSX,
|
||||||
unsupported
|
unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void toggleOverlay() {
|
||||||
|
if(ov == null) {
|
||||||
|
ov = new Overlay();
|
||||||
|
ov.set(playout, cardslots, end, battle, arena_switch);
|
||||||
|
ov.init();
|
||||||
|
} else {
|
||||||
|
ov.close();
|
||||||
|
ov = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package mrbesen.cr.auto.clicker;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
public class Overlay {
|
||||||
|
|
||||||
|
JFrame frame;
|
||||||
|
Point spawn;
|
||||||
|
Point cards[];
|
||||||
|
Point ok;
|
||||||
|
Point battle;
|
||||||
|
Point arenaview;
|
||||||
|
|
||||||
|
public Overlay() {
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(frame != null) {
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "Shutdownhook-Overlaycloser"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(Point spawn, Point[] cards, Point ok, Point battle, Point arenaview) {
|
||||||
|
this.spawn = spawn;
|
||||||
|
this.cards = cards;
|
||||||
|
this.ok = ok;
|
||||||
|
this.battle = battle;
|
||||||
|
this.arenaview = arenaview;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
frame = new JFrame("Bot Overlay");
|
||||||
|
frame.setUndecorated(true);
|
||||||
|
frame.setOpacity(0.5f);
|
||||||
|
|
||||||
|
int width=0, height=0;
|
||||||
|
int x=spawn.x,y=spawn.y;
|
||||||
|
for(Point p : getlist()) {
|
||||||
|
if(p != null) {
|
||||||
|
if(p.x < x) {
|
||||||
|
width += (x-p.x);//umsoviel weiter machen, wie nach links verschoben wird
|
||||||
|
x = p.x;
|
||||||
|
}
|
||||||
|
if(x+width < p.x) {
|
||||||
|
width += x+width-p.x;
|
||||||
|
}
|
||||||
|
if(p.y < y) {
|
||||||
|
height += (y-p.y);
|
||||||
|
y = p.y;
|
||||||
|
}
|
||||||
|
if(y+height < p.y) {
|
||||||
|
height += y+height-p.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.setSize(width, height);
|
||||||
|
frame.setLocation(x, y);
|
||||||
|
|
||||||
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
Graphics gra = frame.getGraphics();
|
||||||
|
gra.setColor(new Color(255, 0, 0));//red
|
||||||
|
for(Point p : cards) {
|
||||||
|
if(p != null) {
|
||||||
|
gra.drawRect(p.x-1, p.y-1, 300, 300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Overlay is da!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Point[] getlist() {
|
||||||
|
return new Point[] {spawn,ok,battle,arenaview, cards[0],cards[1],cards[2],cards[3]};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -62,6 +62,7 @@ public class UI implements ActionListener {
|
||||||
private JButton skip = new JButton("SKIP"); // the button, to skip waiting
|
private JButton skip = new JButton("SKIP"); // the button, to skip waiting
|
||||||
private JButton pause = new JButton("Pause");
|
private JButton pause = new JButton("Pause");
|
||||||
private JButton exit = new JButton("EXIT");
|
private JButton exit = new JButton("EXIT");
|
||||||
|
private JButton overlay = new JButton("Overlay");
|
||||||
|
|
||||||
private JLabel info = new JLabel("Define positions, to start.");
|
private JLabel info = new JLabel("Define positions, to start.");
|
||||||
private JLabel time = new JLabel("0 s");
|
private JLabel time = new JLabel("0 s");
|
||||||
|
@ -113,6 +114,7 @@ public class UI implements ActionListener {
|
||||||
start.addActionListener(this);
|
start.addActionListener(this);
|
||||||
pause.addActionListener(this);
|
pause.addActionListener(this);
|
||||||
exit.addActionListener(this);
|
exit.addActionListener(this);
|
||||||
|
overlay.addActionListener(this);
|
||||||
doubleplace.addActionListener(this);
|
doubleplace.addActionListener(this);
|
||||||
backfocus.addActionListener(this);
|
backfocus.addActionListener(this);
|
||||||
|
|
||||||
|
@ -124,6 +126,7 @@ public class UI implements ActionListener {
|
||||||
middle.add(skip);
|
middle.add(skip);
|
||||||
middle.add(pause);
|
middle.add(pause);
|
||||||
middle.add(exit);
|
middle.add(exit);
|
||||||
|
middle.add(overlay);
|
||||||
middle.add(autoplay);
|
middle.add(autoplay);
|
||||||
middle.add(doubleplace);
|
middle.add(doubleplace);
|
||||||
middle.add(backfocus);
|
middle.add(backfocus);
|
||||||
|
@ -187,6 +190,8 @@ public class UI implements ActionListener {
|
||||||
info("Paused.");
|
info("Paused.");
|
||||||
}
|
}
|
||||||
bot.setPause(!bot.isPaused());
|
bot.setPause(!bot.isPaused());
|
||||||
|
} else if(srcb.equals(overlay)) {
|
||||||
|
bot.toggleOverlay();
|
||||||
}
|
}
|
||||||
} else if(src instanceof JMenuItem) {
|
} else if(src instanceof JMenuItem) {
|
||||||
JMenuItem srcI = (JMenuItem) src;
|
JMenuItem srcI = (JMenuItem) src;
|
||||||
|
|
Loading…
Reference in New Issue