Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/assets/screenshots/example_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ HardCoded
Sekwah41
* Generation

# Can I get banned?
We have reached out to the Rust team and they told us that our application is ok.
We are still waiting for a response from the EAC team.
If you have any problem with the program please create a new issue and tell us what went wrong.

# Usage
Work in progress...
Check out our wiki for more information
[Wiki](https://github.com/Bob-Rust/Bob-Rust-Java/wiki)

# Preview
![Example](.github/assets/screenshots/example_1.jpg)
# FAQ

# Issue
If you have any problem with the program please create a new issue and tell us what went wrong.
## How many colors?
This tool can approximate most colors from the color spectrum.
![Example](.github/assets/screenshots/example_2.jpg)

## Can I get banned?
We have reached out to the Rust team and they told us that our application is ok.
We are still waiting for a response from the EAC team.
8 changes: 4 additions & 4 deletions src/main/java/com/bobrust/gui/BobRustDrawDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,18 @@ private void showPaletteWarning() {

private boolean findColorPalette() {
// The bounds of the screen.
Rectangle screen = overlay.dialog.getBounds();
Rectangle screenBounds = overlay.dialog.getBounds();

// Check for bright red on the edge of the screen.
try {
BufferedImage screenshot = new Robot().createScreenCapture(screen);
BufferedImage screenshot = new Robot().createScreenCapture(screenBounds);
Point paletteLocation = rustPalette.findPalette(screenshot);

if(paletteLocation != null) {
overlay.colorRegion.setLocation(paletteLocation.x, paletteLocation.y + 132 + 100);
Point paletteScreenLocation = new Point(screen.x + paletteLocation.x, screen.y + paletteLocation.y);
Point paletteScreenLocation = new Point(screenBounds.x + paletteLocation.x, screenBounds.y + paletteLocation.y);

if(rustPalette.analyse(dialog, screenshot, screen.getLocation(), paletteScreenLocation)) {
if(rustPalette.analyse(dialog, screenshot, screenBounds, paletteScreenLocation)) {
// Found the palette.
LogUtils.info("Found the color palette (%d, %d)", paletteScreenLocation.x, paletteScreenLocation.y);
overlay.repaint();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/bobrust/gui/BobRustOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ private void startGeneration() {
signType.width,
signType.height,
bgColor,
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
gui.getSettingsScaling()
);

// Apply the ICC cmyk lut filter.
Expand Down
162 changes: 98 additions & 64 deletions src/main/java/com/bobrust/gui/BobRustSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class BobRustSettingsDialog {
private final JDialog dialog;

private final JComboBox<Integer> alphaCombobox;
private final JComboBox<String> scalingCombobox;
private final JIntegerField maxShapesField;
private final JIntegerField callbackIntervalField;
private final JIntegerField clickIntervalField;
Expand Down Expand Up @@ -95,73 +96,105 @@ public BobRustSettingsDialog(BobRustEditor gui, JDialog parent) {
});
signPanel.add(btnSign);

JPanel alphaPanel = new JPanel();
alphaPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
alphaPanel.setBorder(new EmptyBorder(5, 5, 0, 5));
alphaPanel.setPreferredSize(optionSize);
alphaPanel.setMinimumSize(optionSize);
alphaPanel.setMaximumSize(optionSize);
panel.add(alphaPanel);
alphaPanel.setLayout(new BoxLayout(alphaPanel, BoxLayout.Y_AXIS));

JLabel alphaLabel = new JLabel(RustUI.getString(Type.SETTINGS_ALPHAINDEX_LABEL));
alphaLabel.setToolTipText(RustUI.getString(Type.SETTINGS_ALPHAINDEX_TOOLTIP));
alphaLabel.setHorizontalTextPosition(SwingConstants.CENTER);
alphaLabel.setHorizontalAlignment(SwingConstants.CENTER);
alphaPanel.add(alphaLabel);

alphaCombobox = new JComboBox<Integer>();
alphaCombobox.setAlignmentX(Component.LEFT_ALIGNMENT);
alphaCombobox.setFocusable(false);
alphaLabel.setLabelFor(alphaCombobox);
alphaCombobox.setMaximumSize(new Dimension(116, 20));
alphaCombobox.setModel(new DefaultComboBoxModel<Integer>(new Integer[] { 0, 1, 2, 3, 4, 5 }));
alphaCombobox.setSelectedIndex(gui.getSettingsAlpha());
alphaPanel.add(alphaCombobox);

JPanel shapesPanel = new JPanel();
shapesPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
shapesPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
shapesPanel.setPreferredSize(optionSize);
shapesPanel.setMinimumSize(optionSize);
shapesPanel.setMaximumSize(optionSize);
panel.add(shapesPanel);
shapesPanel.setLayout(new BoxLayout(shapesPanel, BoxLayout.Y_AXIS));

JLabel shapesLabel = new JLabel(RustUI.getString(Type.SETTINGS_MAXSHAPES_LABEL));
shapesLabel.setToolTipText(RustUI.getString(Type.SETTINGS_MAXSHAPES_TOOLTIP));
shapesLabel.setHorizontalTextPosition(SwingConstants.CENTER);
shapesLabel.setHorizontalAlignment(SwingConstants.CENTER);
shapesPanel.add(shapesLabel);

maxShapesField = new JIntegerField(gui.getSettingsMaxShapes());
maxShapesField.setAlignmentX(Component.LEFT_ALIGNMENT);
maxShapesField.setFocusable(true);
maxShapesField.setMaximumSize(new Dimension(116, 20));
shapesLabel.setLabelFor(maxShapesField);
shapesPanel.add(maxShapesField);
{
JPanel alphaPanel = new JPanel();
alphaPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
alphaPanel.setBorder(new EmptyBorder(5, 5, 0, 5));
alphaPanel.setPreferredSize(optionSize);
alphaPanel.setMinimumSize(optionSize);
alphaPanel.setMaximumSize(optionSize);
panel.add(alphaPanel);
alphaPanel.setLayout(new BoxLayout(alphaPanel, BoxLayout.Y_AXIS));

JLabel alphaLabel = new JLabel(RustUI.getString(Type.SETTINGS_ALPHAINDEX_LABEL));
alphaLabel.setToolTipText(RustUI.getString(Type.SETTINGS_ALPHAINDEX_TOOLTIP));
alphaLabel.setHorizontalTextPosition(SwingConstants.CENTER);
alphaLabel.setHorizontalAlignment(SwingConstants.CENTER);
alphaPanel.add(alphaLabel);

alphaCombobox = new JComboBox<Integer>();
alphaCombobox.setAlignmentX(Component.LEFT_ALIGNMENT);
alphaCombobox.setFocusable(false);
alphaLabel.setLabelFor(alphaCombobox);
alphaCombobox.setMaximumSize(new Dimension(116, 20));
alphaCombobox.setModel(new DefaultComboBoxModel<Integer>(new Integer[] { 0, 1, 2, 3, 4, 5 }));
alphaCombobox.setSelectedIndex(gui.getSettingsAlpha());
alphaPanel.add(alphaCombobox);
}

JPanel callbackPanel = new JPanel();
callbackPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
callbackPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
callbackPanel.setPreferredSize(optionSize);
callbackPanel.setMinimumSize(optionSize);
callbackPanel.setMaximumSize(optionSize);
panel.add(callbackPanel);
callbackPanel.setLayout(new BoxLayout(callbackPanel, BoxLayout.Y_AXIS));
{
JPanel scalingPanel = new JPanel();
scalingPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
scalingPanel.setBorder(new EmptyBorder(5, 5, 0, 5));
scalingPanel.setPreferredSize(optionSize);
scalingPanel.setMinimumSize(optionSize);
scalingPanel.setMaximumSize(optionSize);
panel.add(scalingPanel);
scalingPanel.setLayout(new BoxLayout(scalingPanel, BoxLayout.Y_AXIS));

JLabel scalingLabel = new JLabel(RustUI.getString(Type.SETTINGS_SCALINGTYPE_LABEL));
scalingLabel.setToolTipText(RustUI.getString(Type.SETTINGS_SCALINGTYPE_TOOLTIP));
scalingLabel.setHorizontalTextPosition(SwingConstants.CENTER);
scalingLabel.setHorizontalAlignment(SwingConstants.CENTER);
scalingPanel.add(scalingLabel);

scalingCombobox = new JComboBox<String>();
scalingCombobox.setAlignmentX(Component.LEFT_ALIGNMENT);
scalingCombobox.setFocusable(false);
scalingLabel.setLabelFor(scalingCombobox);
scalingCombobox.setMaximumSize(new Dimension(116, 20));
scalingCombobox.setModel(new DefaultComboBoxModel<String>(new String[] { "NEAREST", "BILINEAR", "BICUBIC" }));
scalingCombobox.setSelectedIndex(gui.getSettingsScaling());
scalingPanel.add(scalingCombobox);
}

JLabel callbackLabel = new JLabel(RustUI.getString(Type.SETTINGS_CALLBACKINTERVAL_LABEL));
callbackLabel.setToolTipText(RustUI.getString(Type.SETTINGS_CALLBACKINTERVAL_TOOLTIP));
callbackLabel.setHorizontalTextPosition(SwingConstants.CENTER);
callbackLabel.setHorizontalAlignment(SwingConstants.CENTER);
callbackPanel.add(callbackLabel);
{
JPanel shapesPanel = new JPanel();
shapesPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
shapesPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
shapesPanel.setPreferredSize(optionSize);
shapesPanel.setMinimumSize(optionSize);
shapesPanel.setMaximumSize(optionSize);
panel.add(shapesPanel);
shapesPanel.setLayout(new BoxLayout(shapesPanel, BoxLayout.Y_AXIS));

JLabel shapesLabel = new JLabel(RustUI.getString(Type.SETTINGS_MAXSHAPES_LABEL));
shapesLabel.setToolTipText(RustUI.getString(Type.SETTINGS_MAXSHAPES_TOOLTIP));
shapesLabel.setHorizontalTextPosition(SwingConstants.CENTER);
shapesLabel.setHorizontalAlignment(SwingConstants.CENTER);
shapesPanel.add(shapesLabel);

maxShapesField = new JIntegerField(gui.getSettingsMaxShapes());
maxShapesField.setAlignmentX(Component.LEFT_ALIGNMENT);
maxShapesField.setFocusable(true);
maxShapesField.setMaximumSize(new Dimension(116, 20));
shapesLabel.setLabelFor(maxShapesField);
shapesPanel.add(maxShapesField);
}

callbackIntervalField = new JIntegerField(gui.getSettingsCallbackInterval());
callbackIntervalField.setAlignmentX(Component.LEFT_ALIGNMENT);
callbackIntervalField.setFocusable(true);
callbackIntervalField.setMaximumSize(new Dimension(116, 20));
callbackLabel.setLabelFor(callbackIntervalField);
callbackPanel.add(callbackIntervalField);
{
JPanel callbackPanel = new JPanel();
callbackPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
callbackPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
callbackPanel.setPreferredSize(optionSize);
callbackPanel.setMinimumSize(optionSize);
callbackPanel.setMaximumSize(optionSize);
panel.add(callbackPanel);
callbackPanel.setLayout(new BoxLayout(callbackPanel, BoxLayout.Y_AXIS));

JLabel callbackLabel = new JLabel(RustUI.getString(Type.SETTINGS_CALLBACKINTERVAL_LABEL));
callbackLabel.setToolTipText(RustUI.getString(Type.SETTINGS_CALLBACKINTERVAL_TOOLTIP));
callbackLabel.setHorizontalTextPosition(SwingConstants.CENTER);
callbackLabel.setHorizontalAlignment(SwingConstants.CENTER);
callbackPanel.add(callbackLabel);

callbackIntervalField = new JIntegerField(gui.getSettingsCallbackInterval());
callbackIntervalField.setAlignmentX(Component.LEFT_ALIGNMENT);
callbackIntervalField.setFocusable(true);
callbackIntervalField.setMaximumSize(new Dimension(116, 20));
callbackLabel.setLabelFor(callbackIntervalField);
callbackPanel.add(callbackIntervalField);
}

{
JPanel clickIntervalPanel = new JPanel();
Expand Down Expand Up @@ -351,6 +384,7 @@ public void openDialog(Point point) {
dialog.setVisible(true);

gui.setSettingsAlpha(alphaCombobox.getSelectedIndex());
gui.setSettingsScaling(scalingCombobox.getSelectedIndex());

try {
gui.setSettingsMaxShapes(maxShapesField.getNumberValue());
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/bobrust/lang/RustUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public enum Type {
SETTINGS_AUTOSAVEINTERVAL_TOOLTIP("How many presses done between saves"),
SETTINGS_ALPHAINDEX_LABEL("Alpha Index"),
SETTINGS_ALPHAINDEX_TOOLTIP("The alpha value used when drawing the image"),
SETTINGS_SCALINGTYPE_LABEL("Scaling Type"),
SETTINGS_SCALINGTYPE_TOOLTIP("The type of scaling performed when resizing the image"),
SETTINGS_MAXSHAPES_LABEL("Max Shapes"),
SETTINGS_MAXSHAPES_TOOLTIP("The max amount of shapes used when drawing the image"),
SETTINGS_SIGNTYPE_LABEL("Sign Type"),
Expand Down
57 changes: 52 additions & 5 deletions src/main/java/com/bobrust/robot/BobRustPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.bobrust.generator.sorter.BlobList;
import com.bobrust.gui.BobRustEditor;
import com.bobrust.gui.BobRustOverlay;
import com.bobrust.logging.LogUtils;
import com.bobrust.util.RustUtil;
import com.bobrust.util.Sign;

Expand All @@ -30,6 +31,8 @@ public BobRustPainter(BobRustEditor gui, BobRustOverlay overlay, BobRustPalette
}

public boolean startDrawing(BlobList list) throws Exception {
if(list.size() < 1) return true;

Robot robot = new Robot();

Rectangle canvas = overlay.getCanvasArea();
Expand All @@ -56,13 +59,13 @@ public boolean startDrawing(BlobList list) throws Exception {

{
// Make sure that we have selected the game.
clickPoint(robot, palette.getFocusPoint(), 4, autoDelay);
clickPoint(robot, palette.getFocusPoint(), 4, 50);

// Make sure that we have selected the correct alpha.
clickPoint(robot, palette.getAlphaButton(alphaSetting), 4, autoDelay);
clickPoint(robot, palette.getAlphaButton(alphaSetting), 4, 50);

// Make sure that we have selected the correct shape.
clickPoint(robot, palette.getShapeButton(shapeSetting), 4, autoDelay);
clickPoint(robot, palette.getShapeButton(shapeSetting), 4, 50);
}

// We create an update thread because repainting graphics
Expand Down Expand Up @@ -98,19 +101,31 @@ public boolean startDrawing(BlobList list) throws Exception {
Point lastPoint = new Point(0, 0);
int lastColor = -1;
int lastSize = -1;

{
Blob first = blobList.get(0);

// Select first color to prevent exception.
clickPoint(robot, palette.getColorButton(BorstUtils.getClosestColor(first.color)), 4, 50);
lastColor = first.colorIndex;
}

for(int i = 0, l = 1; i < count; i++, l++) {
Blob blob = blobList.get(i);

// Change the size.
if(lastSize != blob.sizeIndex) {
clickPoint(robot, palette.getSizeButton(blob.sizeIndex), autoDelay);
clickSize(robot, palette.getSizeButton(blob.sizeIndex), 20, autoDelay);
lastSize = blob.sizeIndex;
l++;
}

// Change the color.
if(lastColor != blob.colorIndex) {
clickPoint(robot, palette.getColorButton(BorstUtils.getClosestColor(blob.color)), autoDelay);
if(!clickColor(robot, palette.getColorButton(BorstUtils.getClosestColor(blob.color)), 20, autoDelay)) {
LogUtils.warn("Potentially failed to change color! Will still keep try drawing");
}

lastColor = blob.colorIndex;
l++;
}
Expand Down Expand Up @@ -179,6 +194,38 @@ private void clickPoint(Robot robot, Point point, double delay) {
//System.out.printf("Time: took %.4f, wanted: %.4f\n", time, delay * 3.0);
}

private void clickSize(Robot robot, Point point, int maxAttempts, double delay) {
// Make sure that we press the size
while(maxAttempts-- > 0) {
clickPoint(robot, point, delay);

Color after = robot.getPixelColor(point.x, point.y + 8);
if(after.getGreen() > 120) {
return;
}
}

throw new IllegalStateException("Failed to select size");
}

private boolean clickColor(Robot robot, Point point, int maxAttempts, double delay) {
Point colorPreview = palette.getColorPreview();
Color before = robot.getPixelColor(colorPreview.x, colorPreview.y);

// Make sure that we press the size
while(maxAttempts-- > 0) {
clickPoint(robot, point, delay);

Color after = robot.getPixelColor(colorPreview.x, colorPreview.y);
if(!before.equals(after)) {
return true;
}
}

// throw new IllegalStateException("Failed to select color");
return false;
}

/**
* This method is used to provide a more accurate timing than {@code Robot.setAutoDelay}.
*/
Expand Down
Loading