diff --git a/DivaBot/rectangle0.png b/DivaBot/rectangle0.png index b848020..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 40a55ff..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 612ad49..a3d64f1 100644 Binary files a/DivaBot/rectangle2.png and b/DivaBot/rectangle2.png differ diff --git a/DivaBot/src/sig/MyRobot.java b/DivaBot/src/sig/MyRobot.java index ca18191..536563c 100644 --- a/DivaBot/src/sig/MyRobot.java +++ b/DivaBot/src/sig/MyRobot.java @@ -942,6 +942,7 @@ public class MyRobot{ } System.exit(1); } + TypeFace2.deepCopyDefaultYPointers(); System.out.println("\tPassed ("+(System.currentTimeMillis()-startTime)+"ms)!"); } @@ -956,6 +957,7 @@ public class MyRobot{ System.out.println("Switching to Megamix"); SongData.loadSongsFromFile(); LASTMODE_FUTURETONE=false; + TypeFace2.deepCopyDefaultYPointers(); } } else { @@ -968,6 +970,7 @@ public class MyRobot{ System.out.println("Switching to Future Tone"); SongData.loadSongsFromFile(); LASTMODE_FUTURETONE=true; + TypeFace2.deepCopyDefaultYPointers(); } } else { stillOnSongSelect=0; diff --git a/DivaBot/src/sig/TypeFace2.java b/DivaBot/src/sig/TypeFace2.java index 9df91d5..0861767 100644 --- a/DivaBot/src/sig/TypeFace2.java +++ b/DivaBot/src/sig/TypeFace2.java @@ -65,14 +65,24 @@ public class TypeFace2 { final static Rectangle FUTURETONE_RECT_SEARCH_SCORE=new Rectangle(866+XOFFSET,543-4,250+XOFFSET+1,32+24); final static Rectangle FUTURETONE_RECT_SEARCH_COMBO=new Rectangle(1023+XOFFSET,402,100+XOFFSET+1,22+8); + public final static int[] DEFAULT_YPOINTERS = new int[] {-1,-1,-1,-1,-1,-1,-1,-1}; + public static int[] ypointers = new int[] {-1,-1,-1,-1,-1,-1,-1,-1}; + + public static void deepCopyDefaultYPointers() { + ypointers = new int[DEFAULT_YPOINTERS.length]; + for (int i=0;i150) { - //Breaks a rule. - ruleBreak=true; - if (!debug) { - break colorloop; - } else { - test.setRGB(x, y, Color.RED.getRGB()); - } - } else - if (fontCol.equals(Color.GREEN) && (pixelCol.getRed()>50 - || pixelCol.getGreen()>170 || pixelCol.getBlue()<150)) { - //Breaks a rule. - ruleBreak=true; - if (!debug) { - break colorloop; - } else { - test.setRGB(x, y, Color.GREEN.getRGB()); - } - } else - if (debug) { - test.setRGB(x, y, pixelCol.getRGB()); - }*/ if (fontCol.equals(Color.RED)) { if (lightColorCheck(pixelCol)) { @@ -425,29 +418,6 @@ public class TypeFace2 { for (int y=0;y<18;y++) { Color fontCol = new Color(futuretone_percentfont.getRGB(x+i*18,y)); Color pixelCol = new Color(img.getRGB(xpointer-18+x+1, y+ypointer)); - /*if (fontCol.equals(Color.RED) && pixelCol.getRed()<50 - && pixelCol.getGreen()<150 && pixelCol.getBlue()>150) { - //Breaks a rule. - ruleBreak=true; - if (!debug) { - break colorloop; - } else { - test.setRGB(x, y, Color.RED.getRGB()); - } - } else - if (fontCol.equals(Color.GREEN) && (pixelCol.getRed()>50 - || pixelCol.getGreen()>170 || pixelCol.getBlue()<150)) { - //Breaks a rule. - ruleBreak=true; - if (!debug) { - break colorloop; - } else { - test.setRGB(x, y, Color.GREEN.getRGB()); - } - } else - if (debug) { - test.setRGB(x, y, pixelCol.getRGB()); - }*/ if (fontCol.equals(Color.RED)) { if (lightColorCheck(pixelCol)) { @@ -548,29 +518,6 @@ public class TypeFace2 { for (int y=0;y<29;y++) { Color fontCol = new Color(percentfont.getRGB(x+i*24,y)); Color pixelCol = new Color(img.getRGB(xpointer-24+x+1, y+ypointer)); - /*if (fontCol.equals(Color.RED) && pixelCol.getRed()<50 - && pixelCol.getGreen()<150 && pixelCol.getBlue()>150) { - //Breaks a rule. - ruleBreak=true; - if (!debug) { - break colorloop; - } else { - test.setRGB(x, y, Color.RED.getRGB()); - } - } else - if (fontCol.equals(Color.GREEN) && (pixelCol.getRed()>50 - || pixelCol.getGreen()>170 || pixelCol.getBlue()<150)) { - //Breaks a rule. - ruleBreak=true; - if (!debug) { - break colorloop; - } else { - test.setRGB(x, y, Color.GREEN.getRGB()); - } - } else - if (debug) { - test.setRGB(x, y, pixelCol.getRGB()); - }*/ if (fontCol.equals(Color.RED)) { if (lightColorCheck(pixelCol)) { @@ -770,23 +717,26 @@ public class TypeFace2 { return pixel.getRed()<176 && pixel.getGreen()<178 && pixel.getBlue()>100; } - - public int extractNumbersFromImage(BufferedImage img) throws IOException { - return extractNumbersFromImage(img,false); - } - public int extractNumbersFromImage(BufferedImage img,boolean debug) throws IOException { + public int extractNumbersFromImage(BufferedImage img,boolean debug,int iteration) throws IOException { this.img=img; File f = null; BufferedImage test = null; xpointer=MEGAMIX_RECT_SEARCH_COOL.width-1; ypointer=0; String total = ""; + + boolean startPointer=ypointers[iteration]>=0; + + if (startPointer) { + ypointer=ypointers[iteration]; + System.out.println("Found a saved ypointer of "+ypointer); + } + trialloop: while (ypointer<8) { xpointer=MEGAMIX_RECT_SEARCH_COOL.width-1; while (xpointer>22) { - int distance = 0; int foundIndex = -1; //Compare the 22x21 range. for (int i=0;i<10;i++) { @@ -855,9 +805,14 @@ public class TypeFace2 { if (total.length()>0) { break trialloop; } - ypointer++; + if (startPointer) { + startPointer=false; + ypointer=0; + System.out.println("Could not find with saved ypointer. Switching back to old ypointer."); + } else { + ypointer++; + } } - if (total.equals("")) { return -1; } else { @@ -865,13 +820,20 @@ public class TypeFace2 { } } - public int extractFutureToneScoreNumbersFromImage(BufferedImage img,boolean debug) throws IOException { + public int extractFutureToneScoreNumbersFromImage(BufferedImage img,boolean debug,int iteration) throws IOException { this.img=img; File f = null; BufferedImage test = null; xpointer=FUTURETONE_RECT_SEARCH_SCORE.width-1; ypointer=0; String total = ""; + + boolean startPointer=ypointers[iteration]>=0; + + if (startPointer) { + ypointer=ypointers[iteration]; + } + trialloop: while (ypointer<20) { xpointer=FUTURETONE_RECT_SEARCH_SCORE.width-1; @@ -945,7 +907,12 @@ public class TypeFace2 { if (total.length()>0) { break trialloop; } - ypointer++; + if (startPointer) { + startPointer=false; + ypointer=0; + } else { + ypointer++; + } } if (total.equals("")) { @@ -955,13 +922,20 @@ public class TypeFace2 { } } - public int extractScoreNumbersFromImage(BufferedImage img,boolean debug) throws IOException { + public int extractScoreNumbersFromImage(BufferedImage img,boolean debug,int iteration) throws IOException { this.img=img; File f = null; BufferedImage test = null; xpointer=MEGAMIX_RECT_SEARCH_SCORE.width-1; ypointer=0; String total = ""; + + boolean startPointer=ypointers[iteration]>=0; + + if (startPointer) { + ypointer=ypointers[iteration]; + } + trialloop: while (ypointer<12) { xpointer=MEGAMIX_RECT_SEARCH_SCORE.width-1; @@ -1035,7 +1009,12 @@ public class TypeFace2 { if (total.length()>0) { break trialloop; } - ypointer++; + if (startPointer) { + startPointer=false; + ypointer=0; + } else { + ypointer++; + } } if (total.equals("")) {