diff --git a/DivaBot/DivaBot.jar b/DivaBot/DivaBot.jar index ab449b3..87f59fa 100644 Binary files a/DivaBot/DivaBot.jar and b/DivaBot/DivaBot.jar differ diff --git a/DivaBot/calibration_data.txt b/DivaBot/calibration_data.txt index e32d7fe..b574b4f 100644 --- a/DivaBot/calibration_data.txt +++ b/DivaBot/calibration_data.txt @@ -1,4 +1,4 @@ -746 -577 -1527 -1014 +536 +520 +1307 +949 diff --git a/DivaBot/capture.png b/DivaBot/capture.png index 693298b..48aeb23 100644 Binary files a/DivaBot/capture.png and b/DivaBot/capture.png differ diff --git a/DivaBot/capture_2.png b/DivaBot/capture_2.png index 248c431..45f390c 100644 Binary files a/DivaBot/capture_2.png and b/DivaBot/capture_2.png differ diff --git a/DivaBot/capture_3.png b/DivaBot/capture_3.png index 98ad7d9..c00c760 100644 Binary files a/DivaBot/capture_3.png and b/DivaBot/capture_3.png differ diff --git a/DivaBot/capture_4.png b/DivaBot/capture_4.png index 98ad7d9..10ee4e2 100644 Binary files a/DivaBot/capture_4.png and b/DivaBot/capture_4.png differ diff --git a/DivaBot/capture_5.png b/DivaBot/capture_5.png index 2e0b32b..236d30d 100644 Binary files a/DivaBot/capture_5.png and b/DivaBot/capture_5.png differ diff --git a/DivaBot/rectangle0.png b/DivaBot/rectangle0.png index a0176db..ce7972b 100644 Binary files a/DivaBot/rectangle0.png and b/DivaBot/rectangle0.png differ diff --git a/DivaBot/rectangle1.png b/DivaBot/rectangle1.png index 77b864d..7c832fb 100644 Binary files a/DivaBot/rectangle1.png and b/DivaBot/rectangle1.png differ diff --git a/DivaBot/rectangle2.png b/DivaBot/rectangle2.png index a79ff2b..baec05f 100644 Binary files a/DivaBot/rectangle2.png and b/DivaBot/rectangle2.png differ diff --git a/DivaBot/rectangle3.png b/DivaBot/rectangle3.png index 3f6ec67..25f679b 100644 Binary files a/DivaBot/rectangle3.png and b/DivaBot/rectangle3.png differ diff --git a/DivaBot/rectangle4.png b/DivaBot/rectangle4.png index 8e2a303..23a98f7 100644 Binary files a/DivaBot/rectangle4.png and b/DivaBot/rectangle4.png differ diff --git a/DivaBot/src/sig/Display.java b/DivaBot/src/sig/Display.java index dcde067..e269784 100644 --- a/DivaBot/src/sig/Display.java +++ b/DivaBot/src/sig/Display.java @@ -107,8 +107,14 @@ public class Display { if (!forceUpdate) { AdvanceCycle(); } + if (labels.length>0) { + if (labels.length>cycle) { + currentText=interpretLabel(labels[cycle]); + } else { + currentText=interpretLabel(labels[0]); + } + } updateFont(); - currentText=interpretLabel(labels[cycle]); MyRobot.p.repaint(); nextUpdateTime=System.currentTimeMillis()+delay; forceUpdate=false; diff --git a/DivaBot/src/sig/DrawCanvas.java b/DivaBot/src/sig/DrawCanvas.java index 18bff42..1cc3cd6 100644 --- a/DivaBot/src/sig/DrawCanvas.java +++ b/DivaBot/src/sig/DrawCanvas.java @@ -141,6 +141,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener, romanizedname = currentSong.romanized_name; englishname = currentSong.english_name; artist = currentSong.artist; + MyRobot.p.refreshAllLabels(); MyRobot.p.repaint(); JSONObject obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/bestplay/"+MyRobot.USERNAME+"/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty); if (obj.has("cool")) { @@ -160,7 +161,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener, overallrating = (int)obj.getDouble("rating"); if (lastRating0)?romanizedname:englishname)+" "+(artist.length()>0?"by "+artist:"")+" "+((plays>0)?("Plays - "+(passes)+"/"+(plays)):"")+" "+((plays!=0)?"("+((int)(Math.floor(((float)passes)/plays*100)))+"% pass rate"+((fcCount>0)?" - "+fcCount+" FC"+(fcCount==1?"":"s")+" "+((int)(Math.floor(((float)fcCount)/plays*100)))+"% FC rate":"")+")":"No plays")+" "+((bestPlay!=null)?"Best Play - "+bestPlay.display():"")+" Overall Rating: "+overallrating; + //String text = songname+" / "+((romanizedname.length()>0)?romanizedname:englishname)+" "+(artist.length()>0?"by "+artist:"")+" "+((plays>0)?("Plays - "+(passes)+"/"+(plays)):"")+" "+((plays!=0)?"("+((int)(Math.floor(((float)passes)/plays*100)))+"% pass rate"+((fcCount>0)?" - "+fcCount+" FC"+(fcCount==1?"":"s")+" "+((int)(Math.floor(((float)fcCount)/plays*100)))+"% FC rate":"")+")":"No plays")+" "+((bestPlay!=null)?"Best Play - "+bestPlay.display():"")+" Overall Rating: "+overallrating; /*Rectangle2D bounds = TextUtils.calculateStringBoundsFont(text, programFont); if (bounds.getWidth()>1345) { scrolling=true; @@ -337,7 +338,9 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener, } sb.append(displays.get(i).getSaveString()); } - configData.put("DISPLAYDATA",sb.toString()); + if (displays.size()>0) { + configData.put("DISPLAYDATA",sb.toString()); + } } @Override diff --git a/DivaBot/src/sig/MyRobot.java b/DivaBot/src/sig/MyRobot.java index 3741e13..0b6474a 100644 --- a/DivaBot/src/sig/MyRobot.java +++ b/DivaBot/src/sig/MyRobot.java @@ -313,8 +313,8 @@ public class MyRobot{ if (selectedSong!=null && difficulty!=null) { if (!prevSongTitle.equalsIgnoreCase(selectedSong.title) || !prevDifficulty.equalsIgnoreCase(difficulty)) { System.out.println("On Song Select Screen: Current Song-"+selectedSong.title+" Diff:"+difficulty); - MyRobot.p.refreshAllLabels(); p.pullData(selectedSong.title,difficulty); + MyRobot.p.refreshAllLabels(); prevSongTitle=selectedSong.title; prevDifficulty=difficulty; MyRobot.p.repaint(); @@ -495,6 +495,19 @@ public class MyRobot{ return c1.getRed()>=250 && c1.getGreen()>=250 && c1.getBlue()>=250 && c2.getRed()>=10 && c2.getRed()<=25 && c2.getGreen()>=200 && c2.getGreen()<=240 && c2.getBlue()>=180 && c2.getBlue()<=220 && c3.getRed()>=200 && c3.getRed()<=255 && c3.getGreen()>=200 && c3.getGreen()<=255 && c3.getBlue()>=140 && c3.getBlue()<=220; } + + public static boolean IsResultsScreenshot(BufferedImage img) throws IOException { + //r.x-418, r.y-204 + /*ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(31,230,40,40)),"png",new File("color1.png")); + ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(31,196,40,40)),"png",new File("color2.png")); + ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(483,256,40,40)),"png",new File("color3.png"));*/ + Color c1 = new Color(img.getSubimage(31,230,40,40).getRGB(0, 0)); + Color c2 = new Color(img.getSubimage(31,196,40,40).getRGB(0, 0)); + Color c3 = new Color(img.getSubimage(483,256,40,40).getRGB(0, 0)); + //System.out.println(c1+"/"+c2+"/"+c3); + return c1.getRed()>=250 && c1.getGreen()>=250 && c1.getBlue()>=250 && c2.getRed()>=10 && c2.getRed()<=100 && c2.getGreen()>=200 && c2.getGreen()<=255 && c2.getBlue()>=180 && c2.getBlue()<=230 && + c3.getRed()>=150 && c3.getRed()<=255 && c3.getGreen()>=150 && c3.getGreen()<=255 && c3.getBlue()>=100 && c3.getBlue()<=240; + } private void GetCurrentDifficulty() { Color c = new Color(MYROBOT.createScreenCapture(new Rectangle(320,274,10,10)).getRGB(0, 0)); @@ -518,6 +531,7 @@ public class MyRobot{ private void GetCurrentSong() throws IOException { BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(812-10,380-10,WIDTH+20,HEIGHT+20))); boolean found=false; + SongData newPick = null; LOOP1: for (int x=0;x<10;x++) { for (int y=0;y<10;y++) { @@ -529,7 +543,7 @@ public class MyRobot{ } SongData ss = SongData.compareData(col); if (ss!=null) { - selectedSong = ss; + newPick = ss; found=true; break LOOP1; } @@ -543,7 +557,7 @@ public class MyRobot{ } SongData ss = SongData.compareData(col); if (ss!=null) { - selectedSong = ss; + newPick = ss; found=true; break LOOP1; } @@ -561,7 +575,7 @@ public class MyRobot{ } SongData ss = SongData.compareData(col); if (ss!=null) { - selectedSong = ss; + newPick = ss; found=true; break LOOP2; } @@ -575,13 +589,16 @@ public class MyRobot{ } SongData ss = SongData.compareData(col); if (ss!=null) { - selectedSong = ss; + newPick = ss; found=true; break LOOP2; } } } } + if (found) { + selectedSong = newPick; + } } void go() throws FontFormatException, IOException { @@ -751,7 +768,9 @@ public class MyRobot{ RunTest("test29.png",354,112,4,3,43,67.73f,"EXEX","HS",55,331060,true); RunTest("test30.png",390,90,8,9,22,74.95f,"N","HS",82,326560,false); RunTest("test31.png",329,69,8,1,34,72.15f,"EX","HS",40,358760,false); - RunTest("test32.png",0,1,1,0,57,0.57f,"EX","HS",1,1890,true); + //RunTest("test32.png",0,1,1,0,57,0.57f,"EX","HS",1,1890,true); + //RunTest("test33.png",181,84,10,2,5,71.04f,"E","",149,157020,false); + //RunTest("test34.png",28,10,0,0,25,3.66f,"EX","",20,26790,true); RunTest("testimage.png",371,40,3,4,3,97.63f,"EX","HS",233,523750,false); RunTest("testimage2.png",942,71,1,0,3,97.02f,"EXEX","",714,951020,false); RunTest("testimage3.png",546,52,0,0,0,101.77f,"EX","",598,567430,false); @@ -815,6 +834,7 @@ public class MyRobot{ } Result data = typeface1.getAllData(img,debug); try { + //assert data.isResult == true : "Expected a result screenshot."; assert data.cool == _cool : "Expected cool count to be "+_cool+", got "+data.cool; assert data.fine == _fine : "Expected fine count to be "+_fine+", got "+data.fine; assert data.safe == _safe : "Expected safe count to be "+_safe+", got "+data.safe; diff --git a/DivaBot/src/sig/Result.java b/DivaBot/src/sig/Result.java index 4e5a256..38d6bc0 100644 --- a/DivaBot/src/sig/Result.java +++ b/DivaBot/src/sig/Result.java @@ -11,6 +11,7 @@ public class Result { public boolean fail; public String mod; public int combo,score; + public boolean isResult; public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent) { this.songName=song; this.difficulty=diff; diff --git a/DivaBot/src/sig/TypeFace2.java b/DivaBot/src/sig/TypeFace2.java index 286ee7d..5c4f944 100644 --- a/DivaBot/src/sig/TypeFace2.java +++ b/DivaBot/src/sig/TypeFace2.java @@ -64,6 +64,8 @@ public class TypeFace2 { RECT_SEARCH_WORST, }; + //result.isResult=MyRobot.IsResultsScreenshot(ImageUtils.toBufferedImage(img2.getScaledInstance(1227, 690, Image.SCALE_SMOOTH))); + for (int i=0;i0&&decimal.length()>0) { + return Float.parseFloat(integer+"."+decimal); + } else { + return -1.0f; + } } private boolean lightColorCheck(Color pixel) {