Skip to content

Commit

Permalink
1.7.25
Browse files Browse the repository at this point in the history
Now java 1.7 compatible, can run on Windows XP.

Creating fragments now easier
  • Loading branch information
1Ridav committed Jul 12, 2018
1 parent e99f5d1 commit c510d11
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Install/news
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title></title>
</head>
<body>
<h2 style="text-align: center;"><span style="font-size:26px;"><span style="font-family: tahoma,geneva,sans-serif;">Update 1.6.24 is now released!</span></span></h2>
<h2 style="text-align: center;"><span style="font-size:26px;"><span style="font-family: tahoma,geneva,sans-serif;">Update 1.7.25 is now released!</span></span></h2>

<p><span style="font-size:16px;">Update to the latest version by clicking the update button bottom-left corner.</span></p>

Expand Down
2 changes: 1 addition & 1 deletion Install/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.24
1.7.25
18 changes: 17 additions & 1 deletion src/main/java/bot/penguee/ScreenGPU.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,24 @@ public class ScreenGPU extends Screen {
}

private int[] flat(int[][] array) {
return Stream.of(array).flatMapToInt(Arrays::stream).toArray();
//FOR JAVA 1.8
//return Stream.of(array).flatMapToInt(Arrays::stream).toArray();

//FOR JAVA 1.7 ALLOW TO RUN ON WINDOWS XP
int[] buff = new int[array.length * array[0].length];
int x_len = array[0].length;
int row_cache;
int[] row_cache2;
for(int y = 0; y < array.length; y++) {
row_cache = y * x_len;
row_cache2 = array[y];
for(int x = 0; x < x_len; x++) {
buff[row_cache + x] = row_cache2[x];
}
}
return buff;
}

@Override
public void grab() throws Exception {
super.grab();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bot/penguee/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.net.URL;

public class Update {
public final static String version = "1.6.24";
public final static String version = "1.7.25";
private static String versionURL = "https://github.com/raw/1Ridav/PengueeBot/master/Install/version";
private static String downloadURL = "https://github.com/1Ridav/PengueeBot/releases/download/v";
private static String newsURL = "https://github.com/raw/1Ridav/PengueeBot/master/Install/news";
Expand Down
94 changes: 74 additions & 20 deletions src/main/java/bot/penguee/gui/GrabPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class GrabPanel extends JPanel {
JLabel testDelayLabel;
private JLabel lblXAndY;
private JPanel panel_pixel_color;
private JPanel grabPanelScreenshot;

private boolean isCTRLdown;
private boolean isALTdown;
Expand Down Expand Up @@ -92,7 +93,7 @@ private void init() {
grabCentral.setBounds(0, 55, 834, 530);
grabCentral.setLayout(null);

final JPanel grabPanelScreenshot = new JPanel() {
grabPanelScreenshot = new JPanel() {
/**
*
*/
Expand Down Expand Up @@ -351,17 +352,7 @@ public void mouseReleased(java.awt.event.MouseEvent evt) {
p2 = evt.getPoint();

if (p2.getX() != p1.getX() || p2.getY() != p1.getY()) {
try {
imageFragment = getImage().getSubimage(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
panel_fragment_zoom.setPreferredSize(new Dimension(imageFragment.getWidth() * previewScaleRate,
imageFragment.getHeight() * previewScaleRate));
grabPanelScreenshot.repaint();
// SwingUtilities.updateComponentTreeUI(frame);
scrollPane.revalidate();
scrollPane.repaint();
} catch (Exception e) {
//e.printStackTrace();
}
repaintScreen();
}
// copy rectangle to clipboard in "x1, y1, x2, y2" format, works if CTRL is
// being pressed
Expand Down Expand Up @@ -417,7 +408,7 @@ public void mouseDragged(java.awt.event.MouseEvent evt) {
imageCursorZoomFragment = getImage().getSubimage(p2.x - 10, p2.y - 10, 20, 20);
panel_cursor_zoom.repaint();
} catch (Exception e) {
//e.printStackTrace();
// e.printStackTrace();
}
}

Expand All @@ -430,7 +421,7 @@ public void mouseMoved(java.awt.event.MouseEvent evt) {
imageCursorZoomFragment = getImage().getSubimage(x - 10, y - 10, 20, 20);
panel_cursor_zoom.repaint();
} catch (Exception e) {
//e.printStackTrace();
// e.printStackTrace();
}
}
});
Expand Down Expand Up @@ -537,20 +528,69 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
public boolean dispatchKeyEvent(KeyEvent e) {
switch (e.getID()) {
case KeyEvent.KEY_PRESSED:
if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
switch (e.getKeyCode()) {
case KeyEvent.VK_CONTROL:
isCTRLdown = true;
}
if (e.getKeyCode() == KeyEvent.VK_ALT) {
break;
case KeyEvent.VK_ALT:
isALTdown = true;
break;
case KeyEvent.VK_UP:
if (p1 != null && p2 != null) {
if (isCTRLdown) {
p2.setLocation(p2.x, p2.y - 1);
} else {
p1.setLocation(p1.x, p1.y - 1);
p2.setLocation(p2.x, p2.y - 1);
}
repaintScreen();
}
break;
case KeyEvent.VK_DOWN:
if (p1 != null && p2 != null) {
if (isCTRLdown) {
p2.setLocation(p2.x, p2.y + 1);
} else {
p1.setLocation(p1.x, p1.y + 1);
p2.setLocation(p2.x, p2.y + 1);
}
repaintScreen();
}
break;
case KeyEvent.VK_LEFT:
if (p1 != null && p2 != null) {
if (isCTRLdown) {
p2.setLocation(p2.x - 1, p2.y);
} else {
p1.setLocation(p1.x - 1, p1.y);
p2.setLocation(p2.x - 1, p2.y);
}
repaintScreen();
}
break;
case KeyEvent.VK_RIGHT:
if (p1 != null && p2 != null) {
if (isCTRLdown) {
p2.setLocation(p2.x + 1, p2.y);
} else {
p1.setLocation(p1.x + 1, p1.y);
p2.setLocation(p2.x + 1, p2.y);
}
repaintScreen();
}
break;
}
break;

case KeyEvent.KEY_RELEASED:
if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
switch (e.getKeyCode()) {
case KeyEvent.VK_CONTROL:
isCTRLdown = false;
}
if (e.getKeyCode() == KeyEvent.VK_ALT) {
break;
case KeyEvent.VK_ALT:
isALTdown = false;
break;

}
break;
}
Expand All @@ -564,6 +604,20 @@ private BufferedImage getImage() {
return image;
}

private void repaintScreen() {
try {
imageFragment = getImage().getSubimage(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
panel_fragment_zoom.setPreferredSize(new Dimension(imageFragment.getWidth() * previewScaleRate,
imageFragment.getHeight() * previewScaleRate));
grabPanelScreenshot.repaint();
// SwingUtilities.updateComponentTreeUI(frame);
scrollPane.revalidate();
scrollPane.repaint();
} catch (Exception e2) {
// e.printStackTrace();
}
}

private void updateImage(int delay) {
Timer timer = new Timer(delay, new ActionListener() {
@Override
Expand Down

0 comments on commit c510d11

Please sign in to comment.