Compare commits

...

7 Commits
master ... dev

Author SHA1 Message Date
yannis aed0f2be96 oups 2018-02-14 17:41:00 +01:00
yannis ee755219d4 Merge branch 'dev' into feature/macosx 2018-02-14 17:40:28 +01:00
yannis 3d5e3eaa25 fixed typo 2018-02-14 17:32:30 +01:00
yannis 9f8f8d1f75 Some Overlay tests 2018-02-14 16:58:27 +01:00
MrBesen b88f8d0a12
Update UI.java
The Window is to large, on linux without this line
2018-02-11 23:12:36 +01:00
Daniel Ceballos 3d24e8e0f3 fixed colorizing for mac osx buttons 2018-02-04 16:10:08 +01:00
Daniel Ceballos 020f260129 on osx the button timer to set is not visible 2018-02-04 16:08:26 +01:00
5 changed files with 109 additions and 50 deletions

View File

@ -72,11 +72,16 @@ public class Clicker implements Runnable{
}
public void stop() {
if(ov != null)
ov.close();
should_run = false;
skipbattle = true;
System.out.println("interupting!");
while(running) {
thread.interrupt();//stop that shit (its maybe sleeping)
}
System.out.println("Bot stopped!");
}
public void skip() {
@ -396,7 +401,7 @@ public class Clicker implements Runnable{
try {
ov = new Overlay();
ov.set(playout, cardslots, end, battle, arena_switch);
ov.init();
//ov.init();
} catch(Exception e) {
System.out.println("Catched Exception, while inflateing Overlay: ");
e.printStackTrace();

View File

@ -1,5 +1,10 @@
package mrbesen.cr.auto.clicker;
import javax.swing.*;
import java.awt.GraphicsDevice;
import java.awt.GraphicsDevice.WindowTranslucency;
import java.awt.GraphicsEnvironment;
public class Main {
private static Main main;
@ -10,8 +15,25 @@ public class Main {
}
public Main() {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
//If translucent windows aren't supported, exit.
if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
System.err.println(
"Translucency is not supported");
System.exit(0);
}
main = this;
new UI();
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
new UI();
}
public static Main get() {

View File

@ -1,13 +1,20 @@
package mrbesen.cr.auto.clicker;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import javax.swing.JFrame;
public class Overlay {
public class Overlay extends JFrame {
JFrame frame;
/**
*
*/
private static final long serialVersionUID = 4305002876609279070L;
// JFrame frame;
Point spawn;
Point cards[];
Point ok;
@ -15,14 +22,15 @@ public class Overlay {
Point arenaview;
public Overlay() {
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
/*Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
if(frame != null) {
frame.dispose();
}
// if(frame != null) {
dispose();
// }
}
}, "Shutdownhook-Overlaycloser"));
}, "Shutdownhook-Overlaycloser"));*/
init();
}
void set(Point spawn, Point[] cards, Point ok, Point battle, Point arenaview) {
@ -34,48 +42,69 @@ public class Overlay {
}
public void init() {
frame = new JFrame("Bot Overlay");
frame.setUndecorated(true);
frame.setOpacity(0.5f);
setTitle("Bot Overlay");
setUndecorated(true);
setBackground(new Color(0, 0, 0, 0));
setOpacity(.5f);
setAlwaysOnTop(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);
}
}
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width=screenSize.width, height=screenSize.height;
int x=0, y=0;
System.out.println("x: " + x + " y: " + y + " size: " + width + ", " + height);
//
// 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;
// }
// }
// }
setSize(width, height);
setLocation(x, y);
setVisible(true);
// frame.invalidate();
System.out.println("Overlay is da!");
}
/* @Override
public void paint(Graphics gra) {
// gra.setPaintMode();
gra.setColor(new Color(255, 255, 255, 0));
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// gra.fillRect(0, 0, screenSize.width, screenSize.height);
gra.setColor(new Color(255, 0, 0, 255));//red
// gra.setColor(new Color(1, 0, 0,0.5f));
for(Point p : getlist()) {
if(p != null) {
gra.fillRect(p.x-2, p.y-2, 25, 25);
System.out.println("draw: " + p.x +", " + p.y);
}
}
System.out.println("paint!");
}*/
public void close() {
frame.dispose();
/*if (frame != null) {
frame.dispose();
System.out.println("Closed Overlay");
}*/
dispose();
}

View File

@ -16,10 +16,13 @@ public class PosSelector implements Runnable {
return required;
}
public PosSelector(UI ui, String text, boolean required, int num) {
this.ui = ui; this.required = required;this.num = num;
PosSelector(UI ui, String text, boolean required, int num) {
this.ui = ui;
this.required = required;
this.num = num;
button = new JButton(text);
button.addActionListener(ui);
button.setOpaque(true);
red();
}

View File

@ -94,7 +94,7 @@ public class UI implements ActionListener {
//init screen
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.setSize(830,( System.getProperty("os.name").toLowerCase().contains("win") ? 220 : 180));//extra large for windows
frame.setSize(830, ( System.getProperty("os.name").toLowerCase().contains("nux") ? 180 : 220));
save.setText("Save");
save.addActionListener(this);
@ -131,7 +131,7 @@ public class UI implements ActionListener {
middle.add(skip);
middle.add(pause);
middle.add(exit);
//middle.add(overlay);//added later
middle.add(overlay);//added later
middle.add(autoplay);
middle.add(doubleplace);
middle.add(backfocus);
@ -537,4 +537,4 @@ public class UI implements ActionListener {
setValue(defaultvalue);
}
}
}
}