diff --git a/ArcadeReader.java b/ArcadeReader.java index 5a4da94..0309b53 100644 --- a/ArcadeReader.java +++ b/ArcadeReader.java @@ -1,5 +1,6 @@ import java.nio.file.Path; +import readers.DDRReader; import readers.PopnReader; public class ArcadeReader { @@ -55,6 +56,6 @@ public class ArcadeReader { * */ public static void retrieveData(Path img) { - new PopnReader().interpretBoxes(img); + new DDRReader().interpretBoxes(img); } } diff --git a/readers/DDRReader.java b/readers/DDRReader.java new file mode 100644 index 0000000..6296ac7 --- /dev/null +++ b/readers/DDRReader.java @@ -0,0 +1,125 @@ +package readers; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +import javax.imageio.ImageIO; + +public class DDRReader extends Reader{ + final static int REGION_PADDING = 32; + List extraRegions = new ArrayList<>(); + static int lastJump=0; + public DDRReader(){ + readRegions.add(new Box(132,184,181,32)); //score[0] + readRegions.add(new Box(270,246,58,17)); //max combo[1] + readRegions.add(new Box(269,268,58,17)); //marvelous[2] + readRegions.add(new Box(269,286,61,20)); //perfect[3] + readRegions.add(new Box(268,307,59,19)); //great[4] + readRegions.add(new Box(268,326,59,19)); //good[5] + readRegions.add(new Box(268,347,59,19)); //OK[6] + readRegions.add(new Box(268,367,59,19)); //miss[7] + readRegions.add(new Box(265,386,65,18)); //ex score[8] + readRegions.add(new Box(348,324,60,18)); //fast[9] + readRegions.add(new Box(348,363,60,18)); //slow[10] + readRegions.add(new Box(260,32,73,15)); //playstyle[11] + readRegions.add(new Box(257,47,81,18)); //difficulty[12] + readRegions.add(new Box(277,65,39,23)); //diffnumb[13] + readRegions.add(new Box(104,80,171,88)); //grade[14] + readRegions.add(new Box(335,185,185,18)); //songname[15] + + //extraRegions.add(new Box(699,616,179,44)); //score text[0] + } + + void ColorFilter(int[] arr,int region,int width) { + switch (region) { + case 999:{ + process(arr,width, + 240,255,100,130,0,10, + 240,255,100,255,0,100); + }break; + } + } + + public void interpretBoxes(Path img){ + /*String dataString = readAllBoxes(img); + String[] data = dataString.split(Pattern.quote("\n")); + String[] ja_data = data[0].split(Pattern.quote(")")); + String[] en_data = data[2].split(Pattern.quote(")")); + trimAllData(ja_data); + trimAllData(en_data); + System.out.println(Arrays.toString(ja_data)); + System.out.println(Arrays.toString(en_data));*/ + + int regionHeights = 0; + int maxWidth = 0; + for (int i=0;imaxWidth) { + maxWidth=readRegions.get(i).w; + } + } + try { + BufferedImage originalImg = ImageIO.read(img.toFile()); + BufferedImage cutImg = new BufferedImage(maxWidth,regionHeights,BufferedImage.TYPE_INT_ARGB); + Graphics2D g = cutImg.createGraphics(); + int currentHeight=0; + for (int i=0;irightMost) { + rightMost=j%extraRegions.get(i).w; + } + } + //cutImg.setRGB(rightMost-leftMost,currentHeight,readRegions.get(i).w,readRegions.get(i).h,arr,0,readRegions.get(i).w); + cutImg.setRGB(0,currentHeight,extraRegions.get(i).w,extraRegions.get(i).h,arr2,0,extraRegions.get(i).w); + final int PADDING = 4; + for (int x=leftMost;x data; try {