Improve algorithms and speed. Reduce glitchy text and redundant calls.
@ -1,4 +1,4 @@
|
|||||||
746
|
536
|
||||||
577
|
520
|
||||||
1527
|
1307
|
||||||
1014
|
949
|
||||||
|
Before Width: | Height: | Size: 536 KiB After Width: | Height: | Size: 522 KiB |
Before Width: | Height: | Size: 535 KiB After Width: | Height: | Size: 522 KiB |
Before Width: | Height: | Size: 534 KiB After Width: | Height: | Size: 522 KiB |
Before Width: | Height: | Size: 534 KiB After Width: | Height: | Size: 519 KiB |
Before Width: | Height: | Size: 529 KiB After Width: | Height: | Size: 519 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.8 KiB |
@ -107,8 +107,14 @@ public class Display {
|
|||||||
if (!forceUpdate) {
|
if (!forceUpdate) {
|
||||||
AdvanceCycle();
|
AdvanceCycle();
|
||||||
}
|
}
|
||||||
updateFont();
|
if (labels.length>0) {
|
||||||
|
if (labels.length>cycle) {
|
||||||
currentText=interpretLabel(labels[cycle]);
|
currentText=interpretLabel(labels[cycle]);
|
||||||
|
} else {
|
||||||
|
currentText=interpretLabel(labels[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateFont();
|
||||||
MyRobot.p.repaint();
|
MyRobot.p.repaint();
|
||||||
nextUpdateTime=System.currentTimeMillis()+delay;
|
nextUpdateTime=System.currentTimeMillis()+delay;
|
||||||
forceUpdate=false;
|
forceUpdate=false;
|
||||||
|
@ -141,6 +141,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
|
|||||||
romanizedname = currentSong.romanized_name;
|
romanizedname = currentSong.romanized_name;
|
||||||
englishname = currentSong.english_name;
|
englishname = currentSong.english_name;
|
||||||
artist = currentSong.artist;
|
artist = currentSong.artist;
|
||||||
|
MyRobot.p.refreshAllLabels();
|
||||||
MyRobot.p.repaint();
|
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);
|
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")) {
|
if (obj.has("cool")) {
|
||||||
@ -160,7 +161,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
|
|||||||
overallrating = (int)obj.getDouble("rating");
|
overallrating = (int)obj.getDouble("rating");
|
||||||
if (lastRating<overallrating) {ratingTime=System.currentTimeMillis();}
|
if (lastRating<overallrating) {ratingTime=System.currentTimeMillis();}
|
||||||
*/
|
*/
|
||||||
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;
|
//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);
|
/*Rectangle2D bounds = TextUtils.calculateStringBoundsFont(text, programFont);
|
||||||
if (bounds.getWidth()>1345) {
|
if (bounds.getWidth()>1345) {
|
||||||
scrolling=true;
|
scrolling=true;
|
||||||
@ -337,8 +338,10 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
|
|||||||
}
|
}
|
||||||
sb.append(displays.get(i).getSaveString());
|
sb.append(displays.get(i).getSaveString());
|
||||||
}
|
}
|
||||||
|
if (displays.size()>0) {
|
||||||
configData.put("DISPLAYDATA",sb.toString());
|
configData.put("DISPLAYDATA",sb.toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
|
@ -313,8 +313,8 @@ public class MyRobot{
|
|||||||
if (selectedSong!=null && difficulty!=null) {
|
if (selectedSong!=null && difficulty!=null) {
|
||||||
if (!prevSongTitle.equalsIgnoreCase(selectedSong.title) || !prevDifficulty.equalsIgnoreCase(difficulty)) {
|
if (!prevSongTitle.equalsIgnoreCase(selectedSong.title) || !prevDifficulty.equalsIgnoreCase(difficulty)) {
|
||||||
System.out.println("On Song Select Screen: Current Song-"+selectedSong.title+" Diff:"+difficulty);
|
System.out.println("On Song Select Screen: Current Song-"+selectedSong.title+" Diff:"+difficulty);
|
||||||
MyRobot.p.refreshAllLabels();
|
|
||||||
p.pullData(selectedSong.title,difficulty);
|
p.pullData(selectedSong.title,difficulty);
|
||||||
|
MyRobot.p.refreshAllLabels();
|
||||||
prevSongTitle=selectedSong.title;
|
prevSongTitle=selectedSong.title;
|
||||||
prevDifficulty=difficulty;
|
prevDifficulty=difficulty;
|
||||||
MyRobot.p.repaint();
|
MyRobot.p.repaint();
|
||||||
@ -496,6 +496,19 @@ public class MyRobot{
|
|||||||
c3.getRed()>=200 && c3.getRed()<=255 && c3.getGreen()>=200 && c3.getGreen()<=255 && c3.getBlue()>=140 && c3.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() {
|
private void GetCurrentDifficulty() {
|
||||||
Color c = new Color(MYROBOT.createScreenCapture(new Rectangle(320,274,10,10)).getRGB(0, 0));
|
Color c = new Color(MYROBOT.createScreenCapture(new Rectangle(320,274,10,10)).getRGB(0, 0));
|
||||||
//return c.getRed()==43 && c.getGreen()==88 && c.getBlue()==213;
|
//return c.getRed()==43 && c.getGreen()==88 && c.getBlue()==213;
|
||||||
@ -518,6 +531,7 @@ public class MyRobot{
|
|||||||
private void GetCurrentSong() throws IOException {
|
private void GetCurrentSong() throws IOException {
|
||||||
BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(812-10,380-10,WIDTH+20,HEIGHT+20)));
|
BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(812-10,380-10,WIDTH+20,HEIGHT+20)));
|
||||||
boolean found=false;
|
boolean found=false;
|
||||||
|
SongData newPick = null;
|
||||||
LOOP1:
|
LOOP1:
|
||||||
for (int x=0;x<10;x++) {
|
for (int x=0;x<10;x++) {
|
||||||
for (int y=0;y<10;y++) {
|
for (int y=0;y<10;y++) {
|
||||||
@ -529,7 +543,7 @@ public class MyRobot{
|
|||||||
}
|
}
|
||||||
SongData ss = SongData.compareData(col);
|
SongData ss = SongData.compareData(col);
|
||||||
if (ss!=null) {
|
if (ss!=null) {
|
||||||
selectedSong = ss;
|
newPick = ss;
|
||||||
found=true;
|
found=true;
|
||||||
break LOOP1;
|
break LOOP1;
|
||||||
}
|
}
|
||||||
@ -543,7 +557,7 @@ public class MyRobot{
|
|||||||
}
|
}
|
||||||
SongData ss = SongData.compareData(col);
|
SongData ss = SongData.compareData(col);
|
||||||
if (ss!=null) {
|
if (ss!=null) {
|
||||||
selectedSong = ss;
|
newPick = ss;
|
||||||
found=true;
|
found=true;
|
||||||
break LOOP1;
|
break LOOP1;
|
||||||
}
|
}
|
||||||
@ -561,7 +575,7 @@ public class MyRobot{
|
|||||||
}
|
}
|
||||||
SongData ss = SongData.compareData(col);
|
SongData ss = SongData.compareData(col);
|
||||||
if (ss!=null) {
|
if (ss!=null) {
|
||||||
selectedSong = ss;
|
newPick = ss;
|
||||||
found=true;
|
found=true;
|
||||||
break LOOP2;
|
break LOOP2;
|
||||||
}
|
}
|
||||||
@ -575,13 +589,16 @@ public class MyRobot{
|
|||||||
}
|
}
|
||||||
SongData ss = SongData.compareData(col);
|
SongData ss = SongData.compareData(col);
|
||||||
if (ss!=null) {
|
if (ss!=null) {
|
||||||
selectedSong = ss;
|
newPick = ss;
|
||||||
found=true;
|
found=true;
|
||||||
break LOOP2;
|
break LOOP2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (found) {
|
||||||
|
selectedSong = newPick;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void go() throws FontFormatException, IOException {
|
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("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("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("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("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("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);
|
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);
|
Result data = typeface1.getAllData(img,debug);
|
||||||
try {
|
try {
|
||||||
|
//assert data.isResult == true : "Expected a result screenshot.";
|
||||||
assert data.cool == _cool : "Expected cool count to be "+_cool+", got "+data.cool;
|
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.fine == _fine : "Expected fine count to be "+_fine+", got "+data.fine;
|
||||||
assert data.safe == _safe : "Expected safe count to be "+_safe+", got "+data.safe;
|
assert data.safe == _safe : "Expected safe count to be "+_safe+", got "+data.safe;
|
||||||
|
@ -11,6 +11,7 @@ public class Result {
|
|||||||
public boolean fail;
|
public boolean fail;
|
||||||
public String mod;
|
public String mod;
|
||||||
public int combo,score;
|
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) {
|
public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent) {
|
||||||
this.songName=song;
|
this.songName=song;
|
||||||
this.difficulty=diff;
|
this.difficulty=diff;
|
||||||
|
@ -64,6 +64,8 @@ public class TypeFace2 {
|
|||||||
RECT_SEARCH_WORST,
|
RECT_SEARCH_WORST,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//result.isResult=MyRobot.IsResultsScreenshot(ImageUtils.toBufferedImage(img2.getScaledInstance(1227, 690, Image.SCALE_SMOOTH)));
|
||||||
|
|
||||||
for (int i=0;i<ranges.length;i++) {
|
for (int i=0;i<ranges.length;i++) {
|
||||||
Rectangle r = ranges[i];
|
Rectangle r = ranges[i];
|
||||||
|
|
||||||
@ -75,7 +77,9 @@ public class TypeFace2 {
|
|||||||
|
|
||||||
finalNumbers[i]=extractNumbersFromImage(img2.getSubimage(
|
finalNumbers[i]=extractNumbersFromImage(img2.getSubimage(
|
||||||
r.x,r.y,r.width,r.height),debug);
|
r.x,r.y,r.width,r.height),debug);
|
||||||
|
if (finalNumbers[i]==-1) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result.cool = finalNumbers[0];
|
result.cool = finalNumbers[0];
|
||||||
result.fine = finalNumbers[1];
|
result.fine = finalNumbers[1];
|
||||||
@ -84,7 +88,9 @@ public class TypeFace2 {
|
|||||||
result.worst = finalNumbers[4];
|
result.worst = finalNumbers[4];
|
||||||
|
|
||||||
float percent = extractPercentFromImage(img2,debug);
|
float percent = extractPercentFromImage(img2,debug);
|
||||||
|
if (percent<0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
result.percent=percent;
|
result.percent=percent;
|
||||||
// result.percent = ??
|
// result.percent = ??
|
||||||
|
|
||||||
@ -109,9 +115,15 @@ public class TypeFace2 {
|
|||||||
//1109,435
|
//1109,435
|
||||||
result.combo = extractNumbersFromImage(img2.getSubimage(
|
result.combo = extractNumbersFromImage(img2.getSubimage(
|
||||||
RECT_SEARCH_COMBO.x,RECT_SEARCH_COMBO.y,RECT_SEARCH_COMBO.width,RECT_SEARCH_COMBO.height),debug);
|
RECT_SEARCH_COMBO.x,RECT_SEARCH_COMBO.y,RECT_SEARCH_COMBO.width,RECT_SEARCH_COMBO.height),debug);
|
||||||
|
if (result.combo<0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
result.score = extractScoreNumbersFromImage(img2.getSubimage(
|
result.score = extractScoreNumbersFromImage(img2.getSubimage(
|
||||||
RECT_SEARCH_SCORE.x,RECT_SEARCH_SCORE.y,RECT_SEARCH_SCORE.width,RECT_SEARCH_SCORE.height),debug);
|
RECT_SEARCH_SCORE.x,RECT_SEARCH_SCORE.y,RECT_SEARCH_SCORE.width,RECT_SEARCH_SCORE.height),debug);
|
||||||
|
if (result.score<0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -374,8 +386,11 @@ public class TypeFace2 {
|
|||||||
}
|
}
|
||||||
ypointer++;
|
ypointer++;
|
||||||
}
|
}
|
||||||
|
if (integer.length()>0&&decimal.length()>0) {
|
||||||
return Float.parseFloat(integer+"."+decimal);
|
return Float.parseFloat(integer+"."+decimal);
|
||||||
|
} else {
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean lightColorCheck(Color pixel) {
|
private boolean lightColorCheck(Color pixel) {
|
||||||
|