Skip to content

Commit 7ff77ba

Browse files
committed
Update and refactor code to work with testmenu
1 parent e1422d6 commit 7ff77ba

21 files changed

+182
-183
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ merge them together. NTR and ninjahax images can exist in the same folder and wi
4444
independently!
4545

4646
###Examples output with template
47-
![An example screenshot exported with a template.](./output/scr_68_MERGED.png "Screenshot")
48-
![An example screenshot exported with a template.](./output/scr_85_MERGED.png "Screenshot")
47+
![An example screenshot exported with a template.](./output/ninjahax_68.png "Screenshot")
48+
![An example screenshot exported with a template.](./output/ninjahax_119.png "Screenshot")
49+
![Using the NTR file name format.](./output/ntr_0001.png "Screenshot")
4950

5051
###Examples output without template
51-
![An example screenshot exported with this tool alone.](./output/scr_28_MERGED.png "Screenshot")
52-
![An example screenshot exported with this tool alone.](./output/scr_30_MERGED.png "Screenshot")
52+
![An example screenshot exported with this tool alone using the testmenu filename format.](./output/testmenu_20161206_0800_00000.png "Screenshot")

input/20161206_0800_LO_00000.png

14.2 KB
Loading

input/20161206_0800_UL_00000.png

12.9 KB
Loading

input/bot_0001.png

86.1 KB
Loading

input/top_0001.png

73.3 KB
Loading

output/ninjahax_119.png

355 KB
Loading

output/ninjahax_28.png

568 KB
Loading

output/ninjahax_30.png

452 KB
Loading
File renamed without changes.

output/ninjahax_85.png

13.1 KB
Loading

output/ninjahax_88.png

194 KB
Loading

output/ntr_0001.png

493 KB
Loading

output/scr_119_MERGED.png

-253 KB
Binary file not shown.

output/scr_28_MERGED.png

-40.9 KB
Binary file not shown.

output/scr_30_MERGED.png

-101 KB
Binary file not shown.

output/scr_85_MERGED.png

-288 KB
Binary file not shown.

output/scr_88_MERGED.png

-477 KB
Binary file not shown.
19.2 KB
Loading

src/red/ImagePair.java

Lines changed: 73 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,98 @@
33
public class ImagePair {
44
String image1;
55
String image2;
6-
int number;
6+
String number;
7+
Type type = Type.UNKNOWN;
78
boolean left = true;
8-
boolean isNTR = false;
9-
boolean init = false;
10-
public ImagePair(String image1, String image2) throws UnmatchedException, NumberFormatException{
9+
10+
enum Type {
11+
UNKNOWN,
12+
NINJAHAX,
13+
NTR,
14+
TESTMENU
15+
}
16+
17+
public ImagePair(String image1, String image2) throws UnmatchedException, IndexOutOfBoundsException{
1118
if(image1 == null || image2 == null || image1.equals("null") || image2.equals("null")) {
1219
System.out.println("Trying to trick me with null images?!");
1320
throw new UnmatchedException();
1421
}
15-
if(image1.substring(0,4).equals("scr_") && image2.substring(0,4).equals("scr_")) {
16-
//We are now in Ninjahax Mode.
17-
if (image1.substring(0,image1.indexOf("_", 4)).equals(image2.substring(0,image2.indexOf("_", 4))) &&
18-
!image1.substring(image1.indexOf("_",4)).equals(image2.substring(image2.indexOf("_",4)))){
22+
23+
//Check if NINJAHAX
24+
String img1pre, img2pre;
25+
img1pre = image1.substring(0,4);
26+
img2pre = image2.substring(0,4);
27+
if(img1pre.equals("scr_") && img2pre.equals("scr_")) { //NINJAHAX universal prefix
28+
if (image1.substring(0,image1.indexOf("_", 4)).equals(image2.substring(0,image2.indexOf("_", 4))) && //Check if number matches
29+
!image1.substring(image1.indexOf("_",4)).equals(image2.substring(image2.indexOf("_",4)))){ //And that types are different
1930
this.image1 = image1;
2031
this.image2 = image2;
21-
try{
22-
number = Integer.parseInt(image1.substring(image1.indexOf("_") + 1,image1.indexOf("_", 4)));
23-
} catch (NumberFormatException e) {
24-
throw e;
25-
}
26-
if(image1.contains("RIGHT") || image2.contains("RIGHT")) {
27-
left = false;
28-
}
29-
init = true; //nice.
32+
this.number = image1.substring(image1.indexOf("_") + 1,image1.indexOf("_", 4));
33+
this.left = image1.contains("LEFT") || image2.contains("LEFT");
34+
if(this.left && image1.contains("RIGHT") || image2.contains("RIGHT")) throw new UnmatchedException(); //Other image cannot be right if one is left!
35+
this.type = Type.NINJAHAX;
36+
return;
3037
}
31-
} else if
38+
}
3239

33-
//Find NTR in English first
34-
(((image1.substring(0,3).equals("top") || image1.substring(0,3).equals("bot")) &&
35-
(image2.substring(0,3).equals("top") || image2.substring(0,3).equals("bot"))) ||
36-
37-
//Or spanish I guess?
38-
((image1.substring(0,3).equals("sup") || image1.substring(0,3).equals("inf")) &&
39-
(image2.substring(0,3).equals("sup") || image2.substring(0,3).equals("inf"))))
40-
41-
{ //extra check for ntr since I don't want it matching ninjahax ones.
42-
if (image1.substring(4,8)
43-
.equals(image2.substring(4,8)) &&
44-
!image1.substring(0,image1.indexOf("_"))
45-
.equals(image2.substring(0,image2.indexOf("_")))) {
46-
this.isNTR = true;
40+
//Check if NTR
41+
img1pre = image1.substring(0,3);
42+
img2pre = image2.substring(0,3);
43+
if (((img1pre.equals("top") || img1pre.equals("bot")) && (img2pre.equals("top") || img2pre.equals("bot"))) || //NTR English prefix
44+
((img1pre.equals("sup") || img1pre.equals("inf")) && (img2pre.equals("sup") || img2pre.equals("inf"))) ) { //NTR Spanish prefix
45+
if (image1.substring(4,8).equals(image2.substring(4,8)) && //Check if number matches
46+
!image1.substring(0,image1.indexOf("_")).equals(image2.substring(0,image2.indexOf("_")))) {
4747
this.image1 = image1;
4848
this.image2 = image2;
49-
try{
50-
number = Integer.parseInt(image1.substring(4,8));
51-
} catch (NumberFormatException e) {
52-
throw e;
53-
}
54-
init = true; //nice.
49+
this.number = image1.substring(4,8);
50+
this.type = Type.NTR;
51+
return;
5552
}
56-
} else {
57-
throw new UnmatchedException();
5853
}
54+
55+
//check if TESTMENU
56+
String date1 = image1.substring(0, 8); //The date part (first 8 letters)
57+
String date2 = image2.substring(0, 8);
58+
String time1 = image1.substring(9, 13); //The time part (After first _, 4 letters)
59+
String time2 = image2.substring(9, 13);
60+
String number1 = image1.substring(17, 22); //The number part (After _UL_, _UR_, or _LO_, 5 letters)
61+
String number2 = image2.substring(17, 22);
62+
63+
//If any of this fails, an exception will be thrown.
64+
Integer.parseInt(date1);
65+
Integer.parseInt(date2);
66+
Integer.parseInt(time1);
67+
Integer.parseInt(time2);
68+
Integer.parseInt(number1);
69+
Integer.parseInt(number2);
70+
if(date1.equals(date2) && time1.equals(time2) && number1.equals(number2)) {
71+
if(!image1.substring(13, 17).equals(image2.substring(13, 17))) {
72+
this.image1 = image1;
73+
this.image2 = image2;
74+
this.number = date1 + "_" + time1 + "_" + number1;
75+
this.left = image1.contains("UL") || image2.contains("UL");
76+
if(this.left && image1.contains("UR") || image2.contains("UR")) throw new UnmatchedException();
77+
this.type = Type.TESTMENU;
78+
return;
79+
}
80+
}
81+
82+
throw new UnmatchedException();
5983
}
6084

6185
public String toString() {
62-
return (isNTR ? "NTR image," : "Ninjahax image,") + " First: " + image1 + ", Second: " + image2 + ", Number: " + number;
86+
return type.toString() + " image, First: " + image1 + ", Second: " + image2 + ", Number: " + number;
87+
}
88+
89+
public String getName() {
90+
return type.toString().toLowerCase() + "_" + number + (left ? "" : "_RIGHT") + ".png";
6391
}
6492

6593
public boolean equals(ImagePair pair2) {
66-
return this.number == pair2.getNumber() && this.left == pair2.isLeft() && this.isNTR == pair2.isNTR();
94+
return this.number.equals(pair2.getNumber()) && this.left == pair2.isLeft() && this.type.equals(pair2.getType());
6795
}
6896

69-
public int getNumber() {
97+
public String getNumber() {
7098
return number;
7199
}
72100

@@ -82,11 +110,7 @@ public boolean isLeft() {
82110
return left;
83111
}
84112

85-
public boolean isNTR() {
86-
return isNTR;
87-
}
88-
89-
public boolean isReal() {
90-
return init; //not quite sure how one can get through without being real but...
113+
public Type getType() {
114+
return type;
91115
}
92116
}

0 commit comments

Comments
 (0)