From ae521ece466d20df2282936b29c2daf397091c11 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 12:59:11 +0200 Subject: [PATCH 01/15] Added Overlay --- src/mrbesen/cr/auto/clicker/Clicker.java | 13 ++++ src/mrbesen/cr/auto/clicker/Overlay.java | 86 ++++++++++++++++++++++++ src/mrbesen/cr/auto/clicker/UI.java | 5 ++ 3 files changed, 104 insertions(+) create mode 100644 src/mrbesen/cr/auto/clicker/Overlay.java diff --git a/src/mrbesen/cr/auto/clicker/Clicker.java b/src/mrbesen/cr/auto/clicker/Clicker.java index e549927..eeff945 100644 --- a/src/mrbesen/cr/auto/clicker/Clicker.java +++ b/src/mrbesen/cr/auto/clicker/Clicker.java @@ -37,6 +37,7 @@ public class Clicker implements Runnable{ private final int waittime = 50;//time between mouse teleports and clicks private int mincolordistance = 35; + private Overlay ov = null; OSType os; @@ -394,4 +395,16 @@ public class Clicker implements Runnable{ OSX, 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; + } + } } \ No newline at end of file diff --git a/src/mrbesen/cr/auto/clicker/Overlay.java b/src/mrbesen/cr/auto/clicker/Overlay.java new file mode 100644 index 0000000..cedf19f --- /dev/null +++ b/src/mrbesen/cr/auto/clicker/Overlay.java @@ -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]}; + } + +} \ No newline at end of file diff --git a/src/mrbesen/cr/auto/clicker/UI.java b/src/mrbesen/cr/auto/clicker/UI.java index 1733d71..eadd12f 100644 --- a/src/mrbesen/cr/auto/clicker/UI.java +++ b/src/mrbesen/cr/auto/clicker/UI.java @@ -62,6 +62,7 @@ public class UI implements ActionListener { private JButton skip = new JButton("SKIP"); // the button, to skip waiting private JButton pause = new JButton("Pause"); private JButton exit = new JButton("EXIT"); + private JButton overlay = new JButton("Overlay"); private JLabel info = new JLabel("Define positions, to start."); private JLabel time = new JLabel("0 s"); @@ -113,6 +114,7 @@ public class UI implements ActionListener { start.addActionListener(this); pause.addActionListener(this); exit.addActionListener(this); + overlay.addActionListener(this); doubleplace.addActionListener(this); backfocus.addActionListener(this); @@ -124,6 +126,7 @@ public class UI implements ActionListener { middle.add(skip); middle.add(pause); middle.add(exit); + middle.add(overlay); middle.add(autoplay); middle.add(doubleplace); middle.add(backfocus); @@ -187,6 +190,8 @@ public class UI implements ActionListener { info("Paused."); } bot.setPause(!bot.isPaused()); + } else if(srcb.equals(overlay)) { + bot.toggleOverlay(); } } else if(src instanceof JMenuItem) { JMenuItem srcI = (JMenuItem) src; From 724d5c51ea25502d1592a9561a3061d1ccf4d144 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 13:09:37 +0200 Subject: [PATCH 02/15] Added getRect() --- src/mrbesen/cr/auto/clicker/Clicker.java | 24 +++++++++++-------- .../cr/auto/clicker/PosColSelector.java | 7 +++--- src/mrbesen/cr/auto/clicker/UI.java | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/mrbesen/cr/auto/clicker/Clicker.java b/src/mrbesen/cr/auto/clicker/Clicker.java index eeff945..463ad61 100644 --- a/src/mrbesen/cr/auto/clicker/Clicker.java +++ b/src/mrbesen/cr/auto/clicker/Clicker.java @@ -46,7 +46,7 @@ public class Clicker implements Runnable{ private void sleep( int ms) { //update ui Main.get().ui.printTime((int) ( (System.currentTimeMillis()-started) / 1000 )); - + if(skipbattle) return; try { @@ -324,22 +324,22 @@ public class Clicker implements Runnable{ return false; //long start = System.currentTimeMillis(); int count = 0; - BufferedImage img = bot.createScreenCapture(new Rectangle(p.x-10, p.y-10, 20, 20));//smile - for (int x = 0; x < 20; x++) { - for (int y = 0; y < 20; y++) { + BufferedImage img = bot.createScreenCapture(getRect(p.x, p.y));//smile + for (int x = 0; x < img.getWidth(); x++) { + for (int y = 0; y < img.getHeight(); y++) { int color = img.getRGB(x, y); int red = (color & 0x00ff0000) >> 16; - int green = (color & 0x0000ff00) >> 8; - int blue = color & 0x000000ff; - double distance = Math.sqrt(Math.pow((blue - goalcolor.getBlue()), 2) + int green = (color & 0x0000ff00) >> 8; + int blue = color & 0x000000ff; + double distance = Math.sqrt(Math.pow((blue - goalcolor.getBlue()), 2) + Math.pow((red - goalcolor.getRed()), 2) + Math.pow((green - goalcolor.getGreen()), 2));//calculate the distance between the goalcolor and the test color - if (distance < mincolordistance) - count++; + if (distance < mincolordistance) + count++; } } // System.out.println("counts: " + count);//some performance checking - return count > 70; + return count > 4;//engough pixel have the right color } public Point getMouse() { @@ -396,6 +396,10 @@ public class Clicker implements Runnable{ unsupported } + + public static Rectangle getRect(int x, int y) { + return new Rectangle(x-2, y-2, 5, 5); + } public void toggleOverlay() { if(ov == null) { diff --git a/src/mrbesen/cr/auto/clicker/PosColSelector.java b/src/mrbesen/cr/auto/clicker/PosColSelector.java index 6d1204e..9f31d32 100644 --- a/src/mrbesen/cr/auto/clicker/PosColSelector.java +++ b/src/mrbesen/cr/auto/clicker/PosColSelector.java @@ -2,7 +2,6 @@ package mrbesen.cr.auto.clicker; import java.awt.AWTException; import java.awt.Color; -import java.awt.Rectangle; import java.awt.Robot; import java.awt.image.BufferedImage; import java.util.Comparator; @@ -24,7 +23,7 @@ public class PosColSelector extends PosSelector { try { Robot rob = new Robot(); Point p = ui.bot.getMouse(); - BufferedImage img = rob.createScreenCapture(new Rectangle(p.x-10, p.y-10, 20, 20)); + BufferedImage img = rob.createScreenCapture(Clicker.getRect(p.x, p.y)); //calculate avg color; int red = 0; int green = 0; @@ -46,8 +45,8 @@ public class PosColSelector extends PosSelector { //calculate distances: List dist = new LinkedList(); - for (int x = 0; x < 20; x++) { - for (int y = 0; y < 20; y++) { + for (int x = 0; x < img.getWidth(); x++) { + for (int y = 0; y < img.getHeight(); y++) { int color = img.getRGB(x, y); int redf = (color & 0x00ff0000) >> 16; int greenf = (color & 0x0000ff00) >> 8; diff --git a/src/mrbesen/cr/auto/clicker/UI.java b/src/mrbesen/cr/auto/clicker/UI.java index eadd12f..fd64694 100644 --- a/src/mrbesen/cr/auto/clicker/UI.java +++ b/src/mrbesen/cr/auto/clicker/UI.java @@ -62,7 +62,7 @@ public class UI implements ActionListener { private JButton skip = new JButton("SKIP"); // the button, to skip waiting private JButton pause = new JButton("Pause"); private JButton exit = new JButton("EXIT"); - private JButton overlay = new JButton("Overlay"); + private JButton overlay = new JButton("Overlay[Experimental]"); private JLabel info = new JLabel("Define positions, to start."); private JLabel time = new JLabel("0 s"); From 756924f1b7ff6aabcb1dcba9a0927f6be505a1f1 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 13:10:46 +0200 Subject: [PATCH 03/15] Changed Window size --- src/mrbesen/cr/auto/clicker/UI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mrbesen/cr/auto/clicker/UI.java b/src/mrbesen/cr/auto/clicker/UI.java index fd64694..120e698 100644 --- a/src/mrbesen/cr/auto/clicker/UI.java +++ b/src/mrbesen/cr/auto/clicker/UI.java @@ -92,7 +92,7 @@ public class UI implements ActionListener { Main.get().ui = this; //init screen frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - frame.setSize(730, 180); + frame.setSize(830, 180); save.setText("Save"); save.addActionListener(this); From 515301deda6c852d25f0e7a7e003bdbc6c2511dc Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 13:15:08 +0200 Subject: [PATCH 04/15] Added Overlay try-catch --- src/mrbesen/cr/auto/clicker/Clicker.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mrbesen/cr/auto/clicker/Clicker.java b/src/mrbesen/cr/auto/clicker/Clicker.java index 463ad61..fb88073 100644 --- a/src/mrbesen/cr/auto/clicker/Clicker.java +++ b/src/mrbesen/cr/auto/clicker/Clicker.java @@ -403,9 +403,14 @@ public class Clicker implements Runnable{ public void toggleOverlay() { if(ov == null) { - ov = new Overlay(); - ov.set(playout, cardslots, end, battle, arena_switch); - ov.init(); + try { + ov = new Overlay(); + ov.set(playout, cardslots, end, battle, arena_switch); + ov.init(); + } catch(Exception e) { + System.out.println("Catched Exception, while inflateing Overlay: "); + e.printStackTrace(); + } } else { ov.close(); ov = null; From 9fae8551fe56fc06712179c14caf286fc5103708 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 13:23:35 +0200 Subject: [PATCH 05/15] little bug fix --- src/mrbesen/cr/auto/clicker/PosColSelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mrbesen/cr/auto/clicker/PosColSelector.java b/src/mrbesen/cr/auto/clicker/PosColSelector.java index 9f31d32..e6a7cd0 100644 --- a/src/mrbesen/cr/auto/clicker/PosColSelector.java +++ b/src/mrbesen/cr/auto/clicker/PosColSelector.java @@ -71,7 +71,7 @@ public class PosColSelector extends PosSelector { } }); - int miniumdistance = dist.get(150);//at least the first 100 tests should fit + int miniumdistance = dist.get((int) (dist.size()*0.3f));//at least the first third tests should fit // int maximumdistance = dist.get(dist.size()-1); System.out.println("minimum distance: " + miniumdistance ); ui.bot.setColor(c,colornum, miniumdistance); From 72654bafffd3c333a79a38e88080e13d7bc58ef6 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 13:24:12 +0200 Subject: [PATCH 06/15] improved readability in backfocus() --- src/mrbesen/cr/auto/clicker/Clicker.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/mrbesen/cr/auto/clicker/Clicker.java b/src/mrbesen/cr/auto/clicker/Clicker.java index fb88073..ee29495 100644 --- a/src/mrbesen/cr/auto/clicker/Clicker.java +++ b/src/mrbesen/cr/auto/clicker/Clicker.java @@ -208,18 +208,16 @@ public class Clicker implements Runnable{ private void backfocus(Robot bot) { if(backfocus) { - if(os == OSType.Windows | os == OSType.Linux) - bot.keyPress(KeyEvent.VK_ALT); - else//osx / unsupported - bot.keyPress(KeyEvent.VK_META); - + + int alt_key = ( os == OSType.Windows | os == OSType.Linux ? KeyEvent.VK_ALT : KeyEvent.VK_META); + + bot.keyPress(alt_key); + bot.keyPress(KeyEvent.VK_TAB); sleep(waittime); bot.keyRelease(KeyEvent.VK_TAB); - if(os == OSType.Windows | os == OSType.Linux) - bot.keyRelease(KeyEvent.VK_ALT); - else//osx / unsupported - bot.keyRelease(KeyEvent.VK_META); + + bot.keyRelease(alt_key); } } @@ -375,7 +373,7 @@ public class Clicker implements Runnable{ arena_view = c; break; } - if(mincolordistance < minimumdistance) + if(mincolordistance < minimumdistance)//enlarging min distance required mincolordistance = minimumdistance; System.out.println(colornum + ": "+c.getRed() + " " + c.getGreen() + " " + c.getBlue()); } @@ -396,7 +394,6 @@ public class Clicker implements Runnable{ unsupported } - public static Rectangle getRect(int x, int y) { return new Rectangle(x-2, y-2, 5, 5); } From 963af8b78eebe4eeff9e180e6bb1204bc5a6cea7 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 13:47:55 +0200 Subject: [PATCH 07/15] Removed OSType --- src/mrbesen/cr/auto/clicker/Clicker.java | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/mrbesen/cr/auto/clicker/Clicker.java b/src/mrbesen/cr/auto/clicker/Clicker.java index ee29495..a33fe6f 100644 --- a/src/mrbesen/cr/auto/clicker/Clicker.java +++ b/src/mrbesen/cr/auto/clicker/Clicker.java @@ -39,7 +39,7 @@ public class Clicker implements Runnable{ private int mincolordistance = 35; private Overlay ov = null; - OSType os; + private int alt_key; long started = -1; @@ -94,17 +94,10 @@ public class Clicker implements Runnable{ public void run() { sleep(1000);//chill ma - //determine os String oss = System.getProperty("os.name").toLowerCase(); - if(oss.contains("nix") | oss.contains("nux") | oss.contains("aix")) - os = OSType.Linux; - else if(oss.contains("win")) - os = OSType.Windows; - else if(oss.contains("mac")) - os = OSType.OSX; - else - Main.get().ui.info("OS not supported for backfocus: " + oss); - + alt_key = ( oss.contains("nix") | oss.contains("nux") | oss.contains("aix") | oss.contains("win") ? KeyEvent.VK_ALT : KeyEvent.VK_META); + //windows and linux have another alt key than mac, so lets determine the OS type, to determine the key code. + int card = 0; try { Robot rob = new Robot(); @@ -209,8 +202,6 @@ public class Clicker implements Runnable{ private void backfocus(Robot bot) { if(backfocus) { - int alt_key = ( os == OSType.Windows | os == OSType.Linux ? KeyEvent.VK_ALT : KeyEvent.VK_META); - bot.keyPress(alt_key); bot.keyPress(KeyEvent.VK_TAB); @@ -387,13 +378,6 @@ public class Clicker implements Runnable{ paused = b; } - private enum OSType { - Linux, - Windows, - OSX, - unsupported - } - public static Rectangle getRect(int x, int y) { return new Rectangle(x-2, y-2, 5, 5); } From da8216d521b8f836f38a9007004f963586ffe3be Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 14:07:45 +0200 Subject: [PATCH 08/15] Code readability improved --- src/mrbesen/cr/auto/clicker/Clicker.java | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/mrbesen/cr/auto/clicker/Clicker.java b/src/mrbesen/cr/auto/clicker/Clicker.java index a33fe6f..d11713f 100644 --- a/src/mrbesen/cr/auto/clicker/Clicker.java +++ b/src/mrbesen/cr/auto/clicker/Clicker.java @@ -51,7 +51,7 @@ public class Clicker implements Runnable{ return; try { if(ms > 1000) { - Thread.sleep(1000); + Thread.sleep(1000);//split the sleep time. sleep(ms-1000); } else Thread.sleep(ms); @@ -163,13 +163,13 @@ public class Clicker implements Runnable{ clickL(rob, end);//ok button backfocus(rob); Main.get().ui.info("Battle ended."); - sleep(9000);//9 sec-loading screen + sleep(7000);//7 sec-loading screen //checken, ob Arena wechsel pop-up while(checkOK(arena_switch, rob,arena_view) & should_run) { System.out.println("Arena found, clicking"); clickL(rob, arena_switch); backfocus(rob); - sleep(2000); + sleep(2000);//wait 2 seconds } } } catch (AWTException e) { @@ -276,18 +276,26 @@ public class Clicker implements Runnable{ return (end != null & battle != null); } + /** + * Perform a Leftclick. + * @param b the Robot to use + * @param a the Position to click + */ private void clickL(Robot b, Point a) { if(!should_run) return; Point old = getMouse(); b.mouseMove(a.x, a.y); - sleep(50); + sleep(waittime); clickL(b); - sleep(50); b.mouseMove(old.x, old.y); - sleep(50); + sleep(waittime); } + /** + * Perform a Leftclick + * @param b + */ private void clickL(Robot b) {//40 ms delay b.mousePress(InputEvent.BUTTON1_MASK); sleep(waittime); @@ -327,7 +335,7 @@ public class Clicker implements Runnable{ } } - // System.out.println("counts: " + count);//some performance checking + System.out.println("counts: " + count);//some performance checking return count > 4;//engough pixel have the right color } @@ -364,7 +372,7 @@ public class Clicker implements Runnable{ arena_view = c; break; } - if(mincolordistance < minimumdistance)//enlarging min distance required + if(mincolordistance < minimumdistance)//enlarging mindistance mincolordistance = minimumdistance; System.out.println(colornum + ": "+c.getRed() + " " + c.getGreen() + " " + c.getBlue()); } From c276e463a2520a4914cbf55aed8b7a9556098775 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 14:08:30 +0200 Subject: [PATCH 09/15] make button Magenta, when they record a position --- src/mrbesen/cr/auto/clicker/PosSelector.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mrbesen/cr/auto/clicker/PosSelector.java b/src/mrbesen/cr/auto/clicker/PosSelector.java index 70f8f39..dae29a8 100644 --- a/src/mrbesen/cr/auto/clicker/PosSelector.java +++ b/src/mrbesen/cr/auto/clicker/PosSelector.java @@ -24,6 +24,7 @@ public class PosSelector implements Runnable { @Override public void run() { + button.setBackground(Color.MAGENTA); try { for(int i = 5; i > 0; i--) {//countdown ui.info(i + ""); From cf742dd451e2aab9cd11665387ca85b3f26a4ffa Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 14:18:59 +0200 Subject: [PATCH 10/15] Changed Messages --- src/mrbesen/cr/auto/clicker/Clicker.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mrbesen/cr/auto/clicker/Clicker.java b/src/mrbesen/cr/auto/clicker/Clicker.java index d11713f..3d7b132 100644 --- a/src/mrbesen/cr/auto/clicker/Clicker.java +++ b/src/mrbesen/cr/auto/clicker/Clicker.java @@ -102,6 +102,7 @@ public class Clicker implements Runnable{ try { Robot rob = new Robot(); while(should_run) { + Main.get().ui.info("Starting Battle."); sleep(500); clickL(rob, battle);//smash the start button sleep(1000); @@ -109,11 +110,11 @@ public class Clicker implements Runnable{ backfocus(rob); //battle is starting up sleep(9000);//wait for the battle to start (loading screen) - Main.get().ui.info("Battle started."); inbattle = true; float modifier = 1; long start = System.currentTimeMillis(); long lastwait = start;//actions like moving mouse and do stuff gets messured and subtracted of the wait's + Main.get().ui.info("Battle begins."); while( ((System.currentTimeMillis() - start) / 6000) < 41 & should_run & !skipbattle) { //check für ok-button @@ -166,7 +167,7 @@ public class Clicker implements Runnable{ sleep(7000);//7 sec-loading screen //checken, ob Arena wechsel pop-up while(checkOK(arena_switch, rob,arena_view) & should_run) { - System.out.println("Arena found, clicking"); + Main.get().ui.info("Arena found, clicking"); clickL(rob, arena_switch); backfocus(rob); sleep(2000);//wait 2 seconds From d2ce629dbb9bb5561777ceeb066e63caa82e7523 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 14:35:36 +0200 Subject: [PATCH 11/15] Added ToolTips --- src/mrbesen/cr/auto/clicker/UI.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/mrbesen/cr/auto/clicker/UI.java b/src/mrbesen/cr/auto/clicker/UI.java index 120e698..220dfa5 100644 --- a/src/mrbesen/cr/auto/clicker/UI.java +++ b/src/mrbesen/cr/auto/clicker/UI.java @@ -90,6 +90,7 @@ public class UI implements ActionListener { public UI() { Main.get().ui = this; + //init screen frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setSize(830, 180); @@ -146,6 +147,28 @@ public class UI implements ActionListener { frame.add(root);//create frame frame.setVisible(true); + + //set tooltips + start.setToolTipText("Starts the Bot."); + skip.setToolTipText("Skips the current Action.(Waiting or beeing in a match, only usefull, when the bot miss clicked somewhere)"); + pause.setToolTipText("Pauses the \"output\" of the Bot, but the internal states are still updated."); + exit.setToolTipText("Stops the Bot and closes the Window."); + overlay.setToolTipText("Enables a Overlay to visualize where the Bot trys to click."); + autoplay.setToolTipText("Enable or disable auto placement of cards."); + doubleplace.setToolTipText("Everytime the bot wants to play a card, he trys to play two cards at once."); + backfocus.setToolTipText("After each mouseclickaction the bot tryes to give the old window the focus back."); + slider[0].setToolTipText("the time the Bot waits between two crads."); + slider[1].setToolTipText("Give a value, how offset the playout place should be, to look more like a human player to the opponent and the game itself."); + + posselctors[0].button.setToolTipText("Set the position for the \"Battle\"-Button."); + posselctors[1].button.setToolTipText("Set the position for the \"ok\"-Button at the end of a match. Be carefull, this also saves the color of the button to auto-detect it."); + posselctors[2].button.setToolTipText("Set the Position of Card 1"); + posselctors[3].button.setToolTipText("Set the Position of Card 2"); + posselctors[4].button.setToolTipText("Set the Position of Card 3"); + posselctors[5].button.setToolTipText("Set the Position of Card 4"); + posselctors[6].button.setToolTipText("Set the Position, where a Card should be placed. Leave it empty to use the same position as the \"Battle\" position."); + posselctors[7].button.setToolTipText("Set the position of the Close button, of the menue that po up, when you tap the arena. This one also saves the color of the position to auto detect it."); + } @Override From 2c3ec47e3fed6fe765dd896ae7cfa60f54b20154 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 15:02:47 +0200 Subject: [PATCH 12/15] Added "new" option in Files Menu --- src/mrbesen/cr/auto/clicker/UI.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mrbesen/cr/auto/clicker/UI.java b/src/mrbesen/cr/auto/clicker/UI.java index 220dfa5..353c253 100644 --- a/src/mrbesen/cr/auto/clicker/UI.java +++ b/src/mrbesen/cr/auto/clicker/UI.java @@ -42,6 +42,7 @@ public class UI implements ActionListener { private JMenu file_ = new JMenu("File"); private JMenuItem load = new JMenuItem(); private JMenuItem save = new JMenuItem(); + private JMenuItem new_ = new JMenuItem(); private AutoPlayBox autoplay = new AutoPlayBox(); private JCheckBox doubleplace = new JCheckBox("DoublePlace"); @@ -99,9 +100,12 @@ public class UI implements ActionListener { save.addActionListener(this); load.setText("Load"); load.addActionListener(this); + new_.setText("New"); + new_.addActionListener(this); file_.add(save); file_.add(load); + file_.add(new_); menubar.add(file_); frame.setJMenuBar(menubar); @@ -222,6 +226,8 @@ public class UI implements ActionListener { load(true); } else if(srcI.equals(save)) { save(); + } else if(srcI.equals(new_)) { + new_(); } } else if(src instanceof JCheckBox) { JCheckBox srcb = (JCheckBox) src; @@ -310,6 +316,17 @@ public class UI implements ActionListener { } } + private void new_() { + int choose = JOptionPane.showConfirmDialog(null, "All of your setting are going to be lost, if you dont save it.", "Settings lost", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); + if(choose == 2) { + info("canceled."); + return; + } + bot.stop(); + bot = null; + bot = new Clicker(); + } + public void refresh() { //check if all required positions are set // & set the colors From dc208dbca5d0f20485776e70b18fd6b2aa8bfcc7 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 26 Oct 2017 17:23:00 +0200 Subject: [PATCH 13/15] little bug fix --- src/mrbesen/cr/auto/clicker/PosColSelector.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mrbesen/cr/auto/clicker/PosColSelector.java b/src/mrbesen/cr/auto/clicker/PosColSelector.java index e6a7cd0..3ea6fdd 100644 --- a/src/mrbesen/cr/auto/clicker/PosColSelector.java +++ b/src/mrbesen/cr/auto/clicker/PosColSelector.java @@ -29,8 +29,8 @@ public class PosColSelector extends PosSelector { int green = 0; int blue = 0; int count = 0; - for (int x = 0; x < 20; x++) { - for (int y = 0; y < 20; y++) { + for (int x = 0; x < img.getWidth(); x++) { + for (int y = 0; y < img.getHeight(); y++) { int color = img.getRGB(x, y); red += (color & 0x00ff0000) >> 16; green += (color & 0x0000ff00) >> 8; From 07c134f7c62d2e5267339271e94739641c61b638 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Sun, 26 Nov 2017 19:52:53 +0100 Subject: [PATCH 14/15] Size Ajustment for windows, removed Overlay button for next release --- src/mrbesen/cr/auto/clicker/UI.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mrbesen/cr/auto/clicker/UI.java b/src/mrbesen/cr/auto/clicker/UI.java index 353c253..e8678b5 100644 --- a/src/mrbesen/cr/auto/clicker/UI.java +++ b/src/mrbesen/cr/auto/clicker/UI.java @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -94,7 +95,7 @@ public class UI implements ActionListener { //init screen frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - frame.setSize(830, 180); + frame.setSize(830,( System.getProperty("os.name").toLowerCase().contains("win") ? 220 : 180));//extra large for windows save.setText("Save"); save.addActionListener(this); @@ -131,7 +132,7 @@ public class UI implements ActionListener { middle.add(skip); middle.add(pause); middle.add(exit); - middle.add(overlay); + //middle.add(overlay);//added later middle.add(autoplay); middle.add(doubleplace); middle.add(backfocus); From 487a263fc036354693b7224a95f2be24332bcc01 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Sun, 26 Nov 2017 20:03:06 +0100 Subject: [PATCH 15/15] warning removed --- src/mrbesen/cr/auto/clicker/UI.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mrbesen/cr/auto/clicker/UI.java b/src/mrbesen/cr/auto/clicker/UI.java index e8678b5..cc31607 100644 --- a/src/mrbesen/cr/auto/clicker/UI.java +++ b/src/mrbesen/cr/auto/clicker/UI.java @@ -4,7 +4,6 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; import java.io.File; import java.io.FileWriter; import java.io.IOException;