Include screenshot info in finalized arcade data (#8)

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 835d7ef442
commit 3a8a8d9458
  1. 12
      ArcadeReader.java
  2. 6
      readers/Reader.java
  3. 1
      sigPlace.java
  4. 11
      sigServer.java

@ -713,20 +713,20 @@ public class ArcadeReader {
//Insert here.
found=true;
if (i==0) {
RECENT_RECORDS.add(0,newImg.toString());
RECENT_RECORDS.add(0,newImg.toStringWithScreenshot());
}
RECENT_PLAYS.add(0,newImg.toString());
RECENT_PLAYS.add(0,newImg.toStringWithScreenshot());
if (RECENT_PLAYS.size()>20) {
RECENT_PLAYS.remove(RECENT_PLAYS.size()-1);
}
RECORDS.add(i, newImg.toString());
RECORDS.add(i, newImg.toStringWithScreenshot());
break;
}
}
if (!found) {
RECORDS.add(newImg.toString());
RECENT_RECORDS.add(0,newImg.toString());
RECENT_PLAYS.add(0,newImg.toString());
RECORDS.add(newImg.toStringWithScreenshot());
RECENT_RECORDS.add(0,newImg.toStringWithScreenshot());
RECENT_PLAYS.add(0,newImg.toStringWithScreenshot());
if (RECENT_PLAYS.size()>20) {
RECENT_PLAYS.remove(RECENT_PLAYS.size()-1);
}

@ -20,6 +20,7 @@ public abstract class Reader{
int maxcombo;
String other="";
String[] sig_data;
public Path result_screenshot;
List<Box> readRegions = new ArrayList<>();
int sig_data_size = 0;
final int TRANSPARENT = new Color(0,0,0,0).getRGB();
@ -340,6 +341,11 @@ public abstract class Reader{
+ ", \"other\":" + other + ", \"pct\":" + pct + ", \"rank\":" + rank + ", \"score\":" + score + ", \"title\":\"" + title.replaceAll(Pattern.quote("\n"),"\\\\n")
+ "\"}";
}
public String toStringWithScreenshot() {
return "{\"game\":\""+getClass().getSimpleName()+"\",\"difficulty\":" + difficulty + ", \"maxcombo\":" + maxcombo + ", \"notes\":" + Arrays.toString(notes)
+ ", \"other\":" + other + ", \"pct\":" + pct + ", \"rank\":" + rank + ", \"score\":" + score + ", \"title\":\"" + title.replaceAll(Pattern.quote("\n"),"\\\\n")
+ "\", \"screenshot\":\""+result_screenshot+"\"}";
}
public int getScore() {
return score;
}

@ -44,6 +44,7 @@ public class sigPlace {
final static String ARTICLESDIR = "articles";
final static String UPLOADSDIR = "uploads";
final static String COMMENTSDIR = "comments";
final static String ARCADEDIR = "arcade";
final static String DIRECTORYLISTING_FILENAME = "DIRECTORY_LISTING";
static int PORT = 8080;
static String SECRET = "";

@ -108,7 +108,12 @@ public class sigServer {
}
} else {
System.out.println(line);
File myFile = new File(new File(sigPlace.OUTDIR,sigPlace.UPLOADSDIR),filename);
File myFile = null;
if (filename.contains(".png")) {
myFile = new File(sigPlace.ARCADEDIR,filename);
} else {
myFile = new File(new File(sigPlace.OUTDIR,sigPlace.UPLOADSDIR),filename);
}
// check if file exist, otherwise create the file before writing
myFile.mkdirs();
System.out.println("Dirs added.");
@ -145,9 +150,9 @@ public class sigServer {
CreateRequest(client,"400","Bad Request",Paths.get(sigPlace.OUTDIR,"testfile.html"));
return;
} else {
System.out.println("Saving upload to "+sigPlace.UPLOADSDIR+" directory.");
System.out.println("Saving upload to "+myFile);
if (filename.contains(".png")) {
ArcadeReader.submitToDatabase(Paths.get(sigPlace.OUTDIR,sigPlace.UPLOADSDIR,filename));
ArcadeReader.submitToDatabase(Paths.get(sigPlace.ARCADEDIR,filename));
System.out.println("Submitted to the database!");
}
}

Loading…
Cancel
Save