Skip to content

Commit

Permalink
beauty code
Browse files Browse the repository at this point in the history
  • Loading branch information
9-9-9-9 committed Nov 16, 2022
1 parent ea54631 commit 9a6349b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 11 additions & 5 deletions src/main/java/bh/bot/app/AbstractApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,17 @@ protected Tuple2<Point[], Byte> detectRadioButtons(Rectangle scanRect) {
else {
if (selectedRadioButtonIndex != curRadioButtonIndex)
throw new InvalidDataException(
"Found more than one selected radio button which is absolutely wrong!");
"Found more than one selected radio button which is absolutely wrong!"
);
}
break;
}

optionalDebug(debug, "detectRadioButtons captured at %3d,%3d with size %3dx%3d, match at %3d,%3d",
screenCapturedResult.x, screenCapturedResult.y, screenCapturedResult.w,
screenCapturedResult.h, x, y);
screenCapturedResult.x, screenCapturedResult.y,
screenCapturedResult.w, screenCapturedResult.h,
x, y
);
startingCoords.add(new Point(x, y));
}
}
Expand All @@ -674,9 +677,12 @@ protected Tuple2<Point[], Byte> detectRadioButtons(Rectangle scanRect) {
throw new InvalidDataException("Unable to detect index of selected radio button among %d results",
startingCoords.size());

return new Tuple2<>(startingCoords.stream()
return new Tuple2<>(
startingCoords.stream()
.map(c -> new Point(screenCapturedResult.x + c.x, screenCapturedResult.y + c.y))
.toArray(Point[]::new), (byte) selectedRadioButtonIndex);
.toArray(Point[]::new),
(byte) selectedRadioButtonIndex
);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/bh/bot/app/dev/TestApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public static Rectangle getWindowLocationAndSize(final HWND hwnd) {
@SuppressWarnings("unused")
private void detectRaidRadioButtons() {
Tuple2<Point[], Byte> result = detectRadioButtons(
Configuration.screenResolutionProfile.getRectangleRadioButtonsOfRaid());
Configuration.screenResolutionProfile.getRectangleRadioButtonsOfRaid()
);
Point[] points = result._1;
byte selectedIndex = result._2;
info("Found %d, selected %d", points.length, selectedIndex + 1);
Expand All @@ -89,7 +90,8 @@ private void detectRaidRadioButtons() {
@SuppressWarnings("unused")
private void detectWorldBossRadioButtons() {
Tuple2<Point[], Byte> result = detectRadioButtons(
Configuration.screenResolutionProfile.getRectangleRadioButtonsOfWorldBoss());
Configuration.screenResolutionProfile.getRectangleRadioButtonsOfWorldBoss()
);
Point[] points = result._1;
byte selectedIndex = result._2;
info("Found %d, selected %d", points.length, selectedIndex + 1);
Expand Down

0 comments on commit 9a6349b

Please sign in to comment.