diff --git a/Install/news b/Install/news index ee250d6..c508b08 100644 --- a/Install/news +++ b/Install/news @@ -3,7 +3,7 @@ -

Update 1.6.24 is now released!

+

Update 1.7.25 is now released!

Update to the latest version by clicking the update button bottom-left corner.

diff --git a/Install/version b/Install/version index 4ad1e55..48b2a23 100644 --- a/Install/version +++ b/Install/version @@ -1 +1 @@ -1.6.24 +1.7.25 diff --git a/src/main/java/bot/penguee/ScreenGPU.java b/src/main/java/bot/penguee/ScreenGPU.java index b2a2361..2a7e99d 100644 --- a/src/main/java/bot/penguee/ScreenGPU.java +++ b/src/main/java/bot/penguee/ScreenGPU.java @@ -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(); diff --git a/src/main/java/bot/penguee/Update.java b/src/main/java/bot/penguee/Update.java index c46c21a..89e913b 100644 --- a/src/main/java/bot/penguee/Update.java +++ b/src/main/java/bot/penguee/Update.java @@ -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"; diff --git a/src/main/java/bot/penguee/gui/GrabPanel.java b/src/main/java/bot/penguee/gui/GrabPanel.java index 36d9a25..a89f33e 100644 --- a/src/main/java/bot/penguee/gui/GrabPanel.java +++ b/src/main/java/bot/penguee/gui/GrabPanel.java @@ -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; @@ -92,7 +93,7 @@ private void init() { grabCentral.setBounds(0, 55, 834, 530); grabCentral.setLayout(null); - final JPanel grabPanelScreenshot = new JPanel() { + grabPanelScreenshot = new JPanel() { /** * */ @@ -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 @@ -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(); } } @@ -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(); } } }); @@ -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; } @@ -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