Updated Overlay interface to make it user friendly!
This commit is contained in:
parent
f04b0e925f
commit
356c01c0d5
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
|||||||
438
|
544
|
||||||
290
|
253
|
||||||
1329
|
1456
|
||||||
787
|
763
|
||||||
|
40
DivaBot/src/sig/AdditionalOptions.java
Normal file
40
DivaBot/src/sig/AdditionalOptions.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package sig;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
public class AdditionalOptions extends JPanel{
|
||||||
|
public static JFrame f = new JFrame();
|
||||||
|
static GridBagConstraints g = new GridBagConstraints();
|
||||||
|
AdditionalOptions() throws IOException{
|
||||||
|
f = new JFrame();
|
||||||
|
f.setIconImage(ImageIO.read(new File("cross.png")));
|
||||||
|
f.setTitle("DivaBot - Additional Options");
|
||||||
|
this.setLayout(new GridBagLayout());
|
||||||
|
g.anchor=GridBagConstraints.EAST;
|
||||||
|
addComponent(1,1,5,1,new JLabel("Show Twitch Overlay Auto-Hotkey"));
|
||||||
|
addComponent(1,3,5,1,new JLabel("Hide Twitch Overlay Auto-Hotkey"));
|
||||||
|
|
||||||
|
addComponent(1,2,12,1,new JLabel(" "));
|
||||||
|
f.add(this);
|
||||||
|
f.pack();
|
||||||
|
f.setResizable(false);
|
||||||
|
f.setVisible(true);
|
||||||
|
}
|
||||||
|
private Component addComponent(int x, int y, int w, int h,Component component) {
|
||||||
|
g.gridx=x;
|
||||||
|
g.gridy=y;
|
||||||
|
g.gridwidth=w;
|
||||||
|
g.gridheight=h;
|
||||||
|
this.add(component,g);
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,14 @@
|
|||||||
package sig;
|
package sig;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Cursor;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import sig.utils.FileUtils;
|
import sig.utils.FileUtils;
|
||||||
@ -56,7 +58,24 @@ public class Calibrator{
|
|||||||
if (failed) {return;}
|
if (failed) {return;}
|
||||||
failed=CalibrationStage8();
|
failed=CalibrationStage8();
|
||||||
if (failed) {return;}
|
if (failed) {return;}
|
||||||
MyRobot.CALIBRATIONSTATUS="First calibration set done: X"+(x-MyRobot.STARTDRAG.x)+" Y"+(y-MyRobot.STARTDRAG.y);
|
MyRobot.CALIBRATIONSTATUS="Calibration is complete! - X"+(MyRobot.STARTDRAG.x)+" Y"+(MyRobot.STARTDRAG.y)+" W"+(MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x)+" H"+(MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y)+" R"+((float)(MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x)/(MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y));
|
||||||
|
|
||||||
|
MyRobot.FRAME.setCursor(Cursor.getDefaultCursor());
|
||||||
|
|
||||||
|
Overlay.started=false;
|
||||||
|
if (((float)(MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x)/(MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y))<=16/9f-0.04||
|
||||||
|
((float)(MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x)/(MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y))>=16/9f+0.04) {
|
||||||
|
int dialogResult = JOptionPane.showConfirmDialog (null, "Could not detect Megamix properly!\n\nYour calibration cut a bit "+((((float)(MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x)/(MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y))<=16/9f-0.04)?"more":"less")+" than expected. Do you want to try selecting a more accurate region?","Warning",JOptionPane.YES_NO_OPTION);
|
||||||
|
if(dialogResult == JOptionPane.YES_OPTION){
|
||||||
|
MyRobot.STARTDRAG=null;
|
||||||
|
MyRobot.ENDDRAG=null;
|
||||||
|
Overlay.OVERLAY.setVisible(true);
|
||||||
|
MyRobot.CALIBRATIONSTATUS="";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Overlay.OVERLAY.setVisible(true);
|
||||||
|
|
||||||
// failed=CalibrationStage3(p);
|
// failed=CalibrationStage3(p);
|
||||||
// if (failed) {return;}
|
// if (failed) {return;}
|
||||||
// failed=CalibrationStage4(p);
|
// failed=CalibrationStage4(p);
|
||||||
|
@ -20,7 +20,7 @@ public class ColorPanel extends JPanel{
|
|||||||
return JColorChooser.showDialog(this, "Color Picker", Color.MAGENTA);
|
return JColorChooser.showDialog(this, "Color Picker", Color.MAGENTA);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Running");
|
//System.out.println("Running");
|
||||||
return JColorChooser.showDialog(this, "Color Picker", Color.MAGENTA);
|
return JColorChooser.showDialog(this, "Color Picker", Color.MAGENTA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
|
|||||||
DisplayManager() throws IOException {
|
DisplayManager() throws IOException {
|
||||||
|
|
||||||
f.setIconImage(ImageIO.read(new File("cross.png")));
|
f.setIconImage(ImageIO.read(new File("cross.png")));
|
||||||
f.setTitle("Create Display");
|
f.setTitle("DivaBot - Create Display");
|
||||||
|
|
||||||
List<Font> tempFontList = new ArrayList(Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()));
|
List<Font> tempFontList = new ArrayList(Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()));
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ public class MyRobot{
|
|||||||
public static boolean DEBUG_MODE=false;
|
public static boolean DEBUG_MODE=false;
|
||||||
public static ColorPanel CP;
|
public static ColorPanel CP;
|
||||||
public static DisplayManager DM;
|
public static DisplayManager DM;
|
||||||
|
public static AdditionalOptions AO;
|
||||||
public static boolean FUTURETONE = false;
|
public static boolean FUTURETONE = false;
|
||||||
|
|
||||||
public static ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
public static ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
||||||
@ -579,10 +580,11 @@ public class MyRobot{
|
|||||||
OVERLAY = new Overlay();
|
OVERLAY = new Overlay();
|
||||||
OVERLAY.setBounds(FRAME.getGraphicsConfiguration().getBounds());
|
OVERLAY.setBounds(FRAME.getGraphicsConfiguration().getBounds());
|
||||||
OVERLAY.setOpaque(false);
|
OVERLAY.setOpaque(false);
|
||||||
|
FRAME.setAlwaysOnTop(true);
|
||||||
FRAME.addMouseListener(OVERLAY);
|
FRAME.addMouseListener(OVERLAY);
|
||||||
FRAME.addMouseMotionListener(OVERLAY);
|
FRAME.addMouseMotionListener(OVERLAY);
|
||||||
screenSize=new Dimension(FRAME.getGraphicsConfiguration().getBounds().width,FRAME.getGraphicsConfiguration().getBounds().height);
|
screenSize=new Dimension(FRAME.getGraphicsConfiguration().getBounds().width,FRAME.getGraphicsConfiguration().getBounds().height);
|
||||||
FRAME.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
//FRAME.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
||||||
//f.add(p);
|
//f.add(p);
|
||||||
//System.out.println(f.getGraphicsConfiguration().getBounds().width+"/"+f.getGraphicsConfiguration().getBounds().height);
|
//System.out.println(f.getGraphicsConfiguration().getBounds().width+"/"+f.getGraphicsConfiguration().getBounds().height);
|
||||||
FRAME.setSize(FRAME.getGraphicsConfiguration().getBounds().width,FRAME.getGraphicsConfiguration().getBounds().height);
|
FRAME.setSize(FRAME.getGraphicsConfiguration().getBounds().width,FRAME.getGraphicsConfiguration().getBounds().height);
|
||||||
@ -610,6 +612,7 @@ public class MyRobot{
|
|||||||
}
|
}
|
||||||
CP = new ColorPanel();
|
CP = new ColorPanel();
|
||||||
DM = new DisplayManager();
|
DM = new DisplayManager();
|
||||||
|
//AO = new AdditionalOptions();
|
||||||
FRAME.add(p);
|
FRAME.add(p);
|
||||||
}
|
}
|
||||||
FRAME.setIconImage(ImageIO.read(new File("cross.png")));
|
FRAME.setIconImage(ImageIO.read(new File("cross.png")));
|
||||||
@ -770,7 +773,7 @@ public class MyRobot{
|
|||||||
FUTURETONE=true;
|
FUTURETONE=true;
|
||||||
onSongSelect=true;
|
onSongSelect=true;
|
||||||
}
|
}
|
||||||
System.out.println(c);
|
//System.out.println(c);
|
||||||
}
|
}
|
||||||
//System.out.println(onSongSelect+"/"+c);
|
//System.out.println(onSongSelect+"/"+c);
|
||||||
|
|
||||||
|
@ -1,23 +1,43 @@
|
|||||||
package sig;
|
package sig;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Point;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import sig.utils.MouseUtils;
|
||||||
|
|
||||||
public class Overlay extends JPanel implements MouseMotionListener,MouseListener{
|
public class Overlay extends JPanel implements MouseMotionListener,MouseListener{
|
||||||
|
|
||||||
public static Overlay OVERLAY;
|
public static Overlay OVERLAY;
|
||||||
|
public static boolean started=false;
|
||||||
|
BufferedImage setupWindowButton;
|
||||||
|
BufferedImage finishButton;
|
||||||
|
Font drawFont = new Font("Verdana",Font.PLAIN,32);
|
||||||
|
|
||||||
Overlay() {
|
Overlay() throws IOException {
|
||||||
|
setupWindowButton = ImageIO.read(new File("setupwindow.png"));
|
||||||
|
finishButton = ImageIO.read(new File("finish.png"));
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
while (true) {
|
while (true) {
|
||||||
repaint();
|
repaint();
|
||||||
try {
|
try {
|
||||||
|
if (started) {
|
||||||
|
MyRobot.FRAME.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
||||||
|
} else {
|
||||||
|
MyRobot.FRAME.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
|
}
|
||||||
Thread.sleep(1000/60);
|
Thread.sleep(1000/60);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -32,14 +52,49 @@ public class Overlay extends JPanel implements MouseMotionListener,MouseListener
|
|||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
g.setColor(new Color(0,0,0,1));
|
if (started) {
|
||||||
g.fillRect(0, 0, MyRobot.screenSize.width, MyRobot.screenSize.height);
|
g.setColor(new Color(0,0,0,1));
|
||||||
g.setColor(new Color(0,255,255,96));
|
g.fillRect(0, 0, MyRobot.screenSize.width, MyRobot.screenSize.height);
|
||||||
if (MyRobot.STARTDRAG!=null&&MyRobot.ENDDRAG!=null) {
|
g.setFont(drawFont);
|
||||||
g.fillRect(0,0,Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x),MyRobot.screenSize.height);
|
g.setColor(Color.WHITE);
|
||||||
g.fillRect(Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x),0,MyRobot.screenSize.width,Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
g.drawString("Make sure you are on the main menu screen with 'Rhythm Game' selected",4,26);
|
||||||
g.fillRect(Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), Math.max(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y), Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x)-Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), MyRobot.screenSize.height-Math.max(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
g.setColor(Color.BLACK);
|
||||||
g.fillRect(Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y), MyRobot.screenSize.width-Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), MyRobot.screenSize.height-Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
g.drawString("Make sure you are on the main menu screen with 'Rhythm Game' selected.",5,28);
|
||||||
|
g.setColor(Color.WHITE);
|
||||||
|
g.drawString("Drag your cursor over the region your game will be displayed on your monitor.",4,58);
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawString("Drag your cursor over the region your game will be displayed on your monitor.",5,60);
|
||||||
|
g.setColor(new Color(0,255,255,96));
|
||||||
|
if (MyRobot.STARTDRAG!=null&&MyRobot.ENDDRAG!=null) {
|
||||||
|
g.fillRect(0,0,Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x),MyRobot.screenSize.height);
|
||||||
|
g.fillRect(Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x),0,MyRobot.screenSize.width,Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
||||||
|
g.fillRect(Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), Math.max(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y), Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x)-Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), MyRobot.screenSize.height-Math.max(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
||||||
|
g.fillRect(Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y), MyRobot.screenSize.width-Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), MyRobot.screenSize.height-Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (MyRobot.CALIBRATIONSTATUS.length()>0) {
|
||||||
|
g.setColor(new Color(0,0,0,1));
|
||||||
|
g.fillRect(0, 0, MyRobot.screenSize.width, MyRobot.screenSize.height);
|
||||||
|
g.setFont(drawFont);
|
||||||
|
g.setColor(new Color(0,140,170,255));
|
||||||
|
if (MyRobot.STARTDRAG!=null&&MyRobot.ENDDRAG!=null) {
|
||||||
|
g.fillRect(0,0,Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x),MyRobot.screenSize.height);
|
||||||
|
g.fillRect(Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x),0,MyRobot.screenSize.width,Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
||||||
|
g.fillRect(Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), Math.max(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y), Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x)-Math.min(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), MyRobot.screenSize.height-Math.max(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
||||||
|
g.fillRect(Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y), MyRobot.screenSize.width-Math.max(MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.x), MyRobot.screenSize.height-Math.min(MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.y));
|
||||||
|
}
|
||||||
|
g.setColor(Color.WHITE);
|
||||||
|
g.drawString(MyRobot.CALIBRATIONSTATUS,4,26);
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawString(MyRobot.CALIBRATIONSTATUS,5,28);
|
||||||
|
g.setColor(Color.WHITE);
|
||||||
|
g.drawString("If the game changes location later on, you will have to redo this. Hit the 'Finish' button to exit!",4,58);
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawString("If the game changes location later on, you will have to redo this. Hit the 'Finish' button to exit!",5,60);
|
||||||
|
g.drawImage(finishButton,MyRobot.screenSize.width-finishButton.getWidth()+1,0,this);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
g.drawImage(setupWindowButton,MyRobot.screenSize.width-setupWindowButton.getWidth()+1,0,this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,23 +104,46 @@ public class Overlay extends JPanel implements MouseMotionListener,MouseListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
MyRobot.STARTDRAG=e.getLocationOnScreen();
|
Point cursor = MouseUtils.GetCursorPosition(MyRobot.FRAME, e);
|
||||||
|
if (started) {
|
||||||
|
MyRobot.STARTDRAG=e.getLocationOnScreen();
|
||||||
|
} else
|
||||||
|
if (MyRobot.CALIBRATIONSTATUS.length()>0) {
|
||||||
|
if (cursor.x>=MyRobot.screenSize.width-finishButton.getWidth()+1&&
|
||||||
|
cursor.x<=MyRobot.screenSize.width&&
|
||||||
|
cursor.y>=0&&
|
||||||
|
cursor.y<=finishButton.getHeight()) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (cursor.x>=MyRobot.screenSize.width-setupWindowButton.getWidth()+1&&
|
||||||
|
cursor.x<=MyRobot.screenSize.width&&
|
||||||
|
cursor.y>=0&&
|
||||||
|
cursor.y<=setupWindowButton.getHeight()) {
|
||||||
|
started=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
MyRobot.ENDDRAG=e.getLocationOnScreen();
|
if (started) {
|
||||||
if (MyRobot.STARTDRAG.x>MyRobot.ENDDRAG.x) {
|
if (MyRobot.STARTDRAG!=null) {
|
||||||
int xTemp = MyRobot.STARTDRAG.x;
|
MyRobot.ENDDRAG=e.getLocationOnScreen();
|
||||||
MyRobot.STARTDRAG.x=MyRobot.ENDDRAG.x;
|
if (MyRobot.STARTDRAG.x>MyRobot.ENDDRAG.x) {
|
||||||
MyRobot.ENDDRAG.x=xTemp;
|
int xTemp = MyRobot.STARTDRAG.x;
|
||||||
|
MyRobot.STARTDRAG.x=MyRobot.ENDDRAG.x;
|
||||||
|
MyRobot.ENDDRAG.x=xTemp;
|
||||||
|
}
|
||||||
|
if (MyRobot.STARTDRAG.y>MyRobot.ENDDRAG.y) {
|
||||||
|
int xTemp = MyRobot.STARTDRAG.y;
|
||||||
|
MyRobot.STARTDRAG.y=MyRobot.ENDDRAG.y;
|
||||||
|
MyRobot.ENDDRAG.y=xTemp;
|
||||||
|
}
|
||||||
|
MyRobot.calibrating=true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (MyRobot.STARTDRAG.y>MyRobot.ENDDRAG.y) {
|
|
||||||
int xTemp = MyRobot.STARTDRAG.y;
|
|
||||||
MyRobot.STARTDRAG.y=MyRobot.ENDDRAG.y;
|
|
||||||
MyRobot.ENDDRAG.y=xTemp;
|
|
||||||
}
|
|
||||||
MyRobot.calibrating=true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -78,7 +156,9 @@ public class Overlay extends JPanel implements MouseMotionListener,MouseListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseDragged(MouseEvent e) {
|
public void mouseDragged(MouseEvent e) {
|
||||||
MyRobot.ENDDRAG=e.getLocationOnScreen();
|
if (started) {
|
||||||
|
MyRobot.ENDDRAG=e.getLocationOnScreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
16
DivaBot/src/sig/utils/MouseUtils.java
Normal file
16
DivaBot/src/sig/utils/MouseUtils.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package sig.utils;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import sig.MyRobot;
|
||||||
|
|
||||||
|
public class MouseUtils {
|
||||||
|
public static Point GetCursorPosition(JFrame f, MouseEvent e) {
|
||||||
|
Point cursor = e.getPoint();
|
||||||
|
cursor.translate(-f.getInsets().left,-f.getInsets().top);
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user