Include host argument
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
71c522b26b
commit
c854a43f7a
@ -100,57 +100,61 @@ public class sigPlace {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final Color SDVX_UI_COL = new Color(48,48,48);
|
final Color SDVX_UI_COL = new Color(48,48,48);
|
||||||
if (args.length>0&&args[0].equals("arcade")) {
|
if (args.length>0&&args[0].equals("arcade")) {
|
||||||
try {
|
if (args.length>1) {
|
||||||
Robot r = new Robot();
|
try {
|
||||||
Reader lastReader = null;
|
Robot r = new Robot();
|
||||||
int matches=0;
|
Reader lastReader = null;
|
||||||
final int EXPECTED_MATCHES=20;
|
int matches=0;
|
||||||
boolean submitted=false;
|
final int EXPECTED_MATCHES=20;
|
||||||
while (true) {
|
boolean submitted=false;
|
||||||
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
|
while (true) {
|
||||||
if (new Color(screenshot.getRGB(1550,604)).equals(SDVX_UI_COL)) {
|
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
|
||||||
//This is a SDVX image, so we will flip it.
|
if (new Color(screenshot.getRGB(1550,604)).equals(SDVX_UI_COL)) {
|
||||||
BufferedImage newCanvas = new BufferedImage(screenshot.getHeight(),screenshot.getWidth(),BufferedImage.TYPE_INT_ARGB);
|
//This is a SDVX image, so we will flip it.
|
||||||
for (int x=0;x<screenshot.getWidth();x++) {
|
BufferedImage newCanvas = new BufferedImage(screenshot.getHeight(),screenshot.getWidth(),BufferedImage.TYPE_INT_ARGB);
|
||||||
for (int y=0;y<screenshot.getHeight();y++) {
|
for (int x=0;x<screenshot.getWidth();x++) {
|
||||||
newCanvas.setRGB(screenshot.getHeight()-y-1, x, screenshot.getRGB(x,y));
|
for (int y=0;y<screenshot.getHeight();y++) {
|
||||||
}
|
newCanvas.setRGB(screenshot.getHeight()-y-1, x, screenshot.getRGB(x,y));
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
screenshot.flush();
|
||||||
|
screenshot=newCanvas;
|
||||||
}
|
}
|
||||||
/*if (result.isReasonableData()) {
|
final Path temp = Paths.get("temp.png");
|
||||||
POSTRequest postRes = new POSTRequest("http://"+args[0]+"/uploadform.html",Path.of("..",filename));
|
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));
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
Thread.sleep(50);
|
||||||
}
|
}
|
||||||
Thread.sleep(50);
|
} catch (AWTException | InterruptedException | IOException | FailedResponseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (AWTException | InterruptedException | IOException | FailedResponseException e) {
|
} else {
|
||||||
e.printStackTrace();
|
System.out.println("You must include a host in the arguments!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
populateDatabase();
|
populateDatabase();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user