Implement screenshot uploading to attach to completed plays.

secondmonitor 02
sigonasr2 4 years ago
parent f6be822371
commit 5178517b74
  1. BIN
      DivaBot/DivaBot.jar
  2. 34
      DivaBot/src/sig/MyRobot.java
  3. 5
      DivaBot/src/sig/Result.java
  4. 4
      DivaBot/src/sig/TypeFace2.java

Binary file not shown.

@ -245,7 +245,7 @@ public class MyRobot{
Scanner s = new Scanner(instream).useDelimiter("\\A");
String result = s.hasNext() ? s.next() : "";
System.out.println(result);
if (result.equalsIgnoreCase("\"authentication success!\"")) {
if (result.equalsIgnoreCase("authentication success!")) {
FileUtils.writetoFile(new String[] {username,authenticationToken,"The App Authentication token is used to record your scores and verify who you are! Do not share it with others!!!"}, "authToken.txt", false);
USERNAME=username;
AUTHTOKEN=authenticationToken;
@ -355,7 +355,7 @@ public class MyRobot{
tmp.mkdir();
}
try {
Result data = typeface1.getAllData(MYROBOT.createScoreScreenCapture());
final Result data = typeface1.getAllData(MYROBOT.createScoreScreenCapture());
System.out.println(data);
//ImageIO.write(MYROBOT.,"png",new File("test.png"));
if (data.cool==-1 || data.fine==-1 || data.safe==-1 || data.sad==-1 || data.worst==-1 || data.percent<0f || data.percent>110f || data.combo==-1 || data.score==-1) {
@ -372,7 +372,7 @@ public class MyRobot{
}
File[] songFolderFiles = songFolder.listFiles();
int playId = songFolderFiles.length;
File playFolder = new File(selectedSong.title+"/"+difficulty+"/"+playId);
final File playFolder = new File(selectedSong.title+"/"+difficulty+"/"+playId);
playFolder.mkdir();
recordedResults=true;
lastcool=data.cool;
@ -384,10 +384,12 @@ public class MyRobot{
lastcombo=data.combo;
lastscore=data.score;
lastfail=data.fail;
new File("scoreimage.png").renameTo(new File(playFolder,selectedSong.title+"_"+difficulty+"play_"+data.cool+"_"+data.fine+"_"+data.safe+"_"+data.sad+"_"+data.worst+"_"+data.percent+""
+ "_"+data.combo+"_"+data.score+".png"));
results.add(new Result(selectedSong.title,difficulty,data.cool,data.fine,data.safe,data.sad,data.worst,data.percent,data.mod,data.combo,data.score,data.fail));
File resultImage=new File(playFolder,selectedSong.title+"_"+difficulty+"play_"+data.cool+"_"+data.fine+"_"+data.safe+"_"+data.sad+"_"+data.worst+"_"+data.percent+""
+ "_"+data.combo+"_"+data.score+".png");
new File("scoreimage.png").renameTo(resultImage);
results.add(new Result(selectedSong.title,difficulty,data.cool,data.fine,data.safe,data.sad,data.worst,data.percent,data.mod,data.combo,data.score,data.fail,resultImage));
SoundUtils.playSound("collect_item.wav");
//gotoxy(800,64);
//click();
MYROBOT.setAutoDelay(0);
@ -405,7 +407,7 @@ public class MyRobot{
} else {
if (results.size()>0) {
recordingResults=true;
for (Result r : results) {
for (final Result r : results) {
r.songName=r.songName.equalsIgnoreCase("PIANOGIRL")?"PIANO*GIRL":(r.songName.equalsIgnoreCase("16 -out of the gravity-"))?"1/6 -out of the gravity-":r.songName;
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("http://45.33.13.215:4501/submit");
@ -440,17 +442,33 @@ public class MyRobot{
e.printStackTrace();
}
HttpEntity entity = response.getEntity();
JSONObject report = null;
if (entity != null) {
try (InputStream instream = entity.getContent()) {
Scanner s = new Scanner(instream).useDelimiter("\\A");
String result = s.hasNext() ? s.next() : "";
System.out.println(result);
report=new JSONObject(result);
instream.close();
} catch (UnsupportedOperationException | IOException e) {
e.printStackTrace();
}
}
final JSONObject finalReport=report;
System.out.println("Submitting screenshot for "+r.f);
Thread t = new Thread() {
public void run() {
HashMap<String,String> s = new HashMap<>();
s.put("username",USERNAME);
s.put("authentication_token",AUTHTOKEN);
s.put("playid",Integer.toString(finalReport.getInt("id")));
WebUtils.POSTimage("http://projectdivar.com/upload", r.f, s);
}
};
t.start();
}
results.clear();

@ -12,6 +12,7 @@ public class Result {
public String mod;
public int combo,score;
public boolean isResult;
public File f;
public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent) {
this.songName=song;
this.difficulty=diff;
@ -40,6 +41,10 @@ public class Result {
this.score=score;
this.mod=mod;
}
public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent,String mod,int combo, int score,boolean fail,File f) {
this(song,diff,cool,fine,safe,sad,worst,percent,mod,combo,score,fail);
this.f=f;
}
public String display() {
return new StringBuilder(Integer.toString(cool)).append("/").append(fine)
.append("/").append(safe).append("/").append(sad).append("/").append(worst).append(" ").append(percent).append("%")

@ -47,7 +47,7 @@ public class TypeFace2 {
final static Rectangle RECT_SEARCH_WORST=new Rectangle(866+XOFFSET,400,100+XOFFSET+1,22+8);
final static Rectangle RECT_SEARCH_PCT=new Rectangle(1182+XOFFSET,163,1132,8);
final static Rectangle RECT_SEARCH_PCT2=new Rectangle(1123+XOFFSET,163,1051,8);
final static Rectangle RECT_SEARCH_SCORE=new Rectangle(859+XOFFSET,578-2,250+XOFFSET+1,32+10);
final static Rectangle RECT_SEARCH_SCORE=new Rectangle(859+XOFFSET,578-4,250+XOFFSET+1,32+14);
final static Rectangle RECT_SEARCH_COMBO=new Rectangle(1010+XOFFSET,435-2,100+XOFFSET+1,22+8);
public Result getAllData(BufferedImage img, boolean debug) throws IOException,NumberFormatException,IndexOutOfBoundsException {
@ -506,7 +506,7 @@ public class TypeFace2 {
ypointer=0;
String total = "";
trialloop:
while (ypointer<8) {
while (ypointer<12) {
xpointer=RECT_SEARCH_SCORE.width-1;
while (xpointer>31) {
int distance = 0;

Loading…
Cancel
Save