|
|
|
@ -100,57 +100,61 @@ public class sigPlace { |
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
final Color SDVX_UI_COL = new Color(48,48,48); |
|
|
|
|
if (args.length>0&&args[0].equals("arcade")) { |
|
|
|
|
try { |
|
|
|
|
Robot r = new Robot(); |
|
|
|
|
Reader lastReader = null; |
|
|
|
|
int matches=0; |
|
|
|
|
final int EXPECTED_MATCHES=20; |
|
|
|
|
boolean submitted=false; |
|
|
|
|
while (true) { |
|
|
|
|
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()); |
|
|
|
|
if (new Color(screenshot.getRGB(1550,604)).equals(SDVX_UI_COL)) { |
|
|
|
|
//This is a SDVX image, so we will flip it.
|
|
|
|
|
BufferedImage newCanvas = new BufferedImage(screenshot.getHeight(),screenshot.getWidth(),BufferedImage.TYPE_INT_ARGB); |
|
|
|
|
for (int x=0;x<screenshot.getWidth();x++) { |
|
|
|
|
for (int y=0;y<screenshot.getHeight();y++) { |
|
|
|
|
newCanvas.setRGB(screenshot.getHeight()-y-1, x, screenshot.getRGB(x,y)); |
|
|
|
|
if (args.length>1) { |
|
|
|
|
try { |
|
|
|
|
Robot r = new Robot(); |
|
|
|
|
Reader lastReader = null; |
|
|
|
|
int matches=0; |
|
|
|
|
final int EXPECTED_MATCHES=20; |
|
|
|
|
boolean submitted=false; |
|
|
|
|
while (true) { |
|
|
|
|
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()); |
|
|
|
|
if (new Color(screenshot.getRGB(1550,604)).equals(SDVX_UI_COL)) { |
|
|
|
|
//This is a SDVX image, so we will flip it.
|
|
|
|
|
BufferedImage newCanvas = new BufferedImage(screenshot.getHeight(),screenshot.getWidth(),BufferedImage.TYPE_INT_ARGB); |
|
|
|
|
for (int x=0;x<screenshot.getWidth();x++) { |
|
|
|
|
for (int y=0;y<screenshot.getHeight();y++) { |
|
|
|
|
newCanvas.setRGB(screenshot.getHeight()-y-1, x, screenshot.getRGB(x,y)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
screenshot.flush(); |
|
|
|
|
screenshot=newCanvas; |
|
|
|
|
} |
|
|
|
|
screenshot.flush(); |
|
|
|
|
screenshot=newCanvas; |
|
|
|
|
} |
|
|
|
|
final Path temp = Paths.get("temp.png"); |
|
|
|
|
Reader result = ArcadeReader.interpret(screenshot); |
|
|
|
|
if (result!=null) { |
|
|
|
|
System.out.println("Detected as "+result.getClass().getSimpleName()); |
|
|
|
|
ImageIO.write(screenshot,"png",temp.toFile()); |
|
|
|
|
result.interpretBoxes(temp, true); |
|
|
|
|
if (result.isReasonableData()) { |
|
|
|
|
if (lastReader!=null&&lastReader.equals(result)) { |
|
|
|
|
matches++; |
|
|
|
|
} else { |
|
|
|
|
lastReader=result; |
|
|
|
|
matches=0; |
|
|
|
|
submitted=false; |
|
|
|
|
} |
|
|
|
|
if (matches>=EXPECTED_MATCHES&&!submitted) { |
|
|
|
|
System.out.println("Data is reasonable, prepare for submitting..."); |
|
|
|
|
POSTRequest postRes = new POSTRequest("http://"+args[0]+"/uploadform.html",temp); |
|
|
|
|
if (((HttpResponse<String>)postRes.run()).statusCode()==200) { |
|
|
|
|
playSound(Paths.get("ding.wav")); |
|
|
|
|
System.out.println("Successful!"); |
|
|
|
|
submitted=true; |
|
|
|
|
final Path temp = Paths.get("temp.png"); |
|
|
|
|
Reader result = ArcadeReader.interpret(screenshot); |
|
|
|
|
if (result!=null) { |
|
|
|
|
System.out.println("Detected as "+result.getClass().getSimpleName()); |
|
|
|
|
ImageIO.write(screenshot,"png",temp.toFile()); |
|
|
|
|
result.interpretBoxes(temp, true); |
|
|
|
|
if (result.isReasonableData()) { |
|
|
|
|
if (lastReader!=null&&lastReader.equals(result)) { |
|
|
|
|
matches++; |
|
|
|
|
} else { |
|
|
|
|
lastReader=result; |
|
|
|
|
matches=0; |
|
|
|
|
submitted=false; |
|
|
|
|
} |
|
|
|
|
if (matches>=EXPECTED_MATCHES&&!submitted) { |
|
|
|
|
System.out.println("Data is reasonable, prepare for submitting..."); |
|
|
|
|
POSTRequest postRes = new POSTRequest("http://"+args[1]+"/uploadform.html",temp); |
|
|
|
|
if (((HttpResponse<String>)postRes.run()).statusCode()==200) { |
|
|
|
|
playSound(Paths.get("ding.wav")); |
|
|
|
|
System.out.println("Successful!"); |
|
|
|
|
submitted=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/*if (result.isReasonableData()) { |
|
|
|
|
POSTRequest postRes = new POSTRequest("http://"+args[0]+"/uploadform.html",Path.of("..",filename)); |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
/*if (result.isReasonableData()) { |
|
|
|
|
POSTRequest postRes = new POSTRequest("http://"+args[0]+"/uploadform.html",Path.of("..",filename)); |
|
|
|
|
}*/ |
|
|
|
|
Thread.sleep(50); |
|
|
|
|
} |
|
|
|
|
Thread.sleep(50); |
|
|
|
|
} catch (AWTException | InterruptedException | IOException | FailedResponseException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} catch (AWTException | InterruptedException | IOException | FailedResponseException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} else { |
|
|
|
|
System.out.println("You must include a host in the arguments!"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
populateDatabase(); |
|
|
|
|