Updated Overlay interface to make it user friendly!

secondmonitor
sigonasr2 4 years ago
parent f04b0e925f
commit 356c01c0d5
  1. BIN
      DivaBot/DivaBot.jar
  2. BIN
      DivaBot/button.xcf
  3. 8
      DivaBot/calibration_data.txt
  4. 40
      DivaBot/src/sig/AdditionalOptions.java
  5. 21
      DivaBot/src/sig/Calibrator.java
  6. 2
      DivaBot/src/sig/ColorPanel.java
  7. 2
      DivaBot/src/sig/DisplayManager.java
  8. 7
      DivaBot/src/sig/MyRobot.java
  9. 124
      DivaBot/src/sig/Overlay.java
  10. 16
      DivaBot/src/sig/utils/MouseUtils.java

Binary file not shown.

Binary file not shown.

@ -1,4 +1,4 @@
438
290
1329
787
544
253
1456
763

@ -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;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import sig.utils.FileUtils;
@ -56,7 +58,24 @@ public class Calibrator{
if (failed) {return;}
failed=CalibrationStage8();
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);
// if (failed) {return;}
// failed=CalibrationStage4(p);

@ -20,7 +20,7 @@ public class ColorPanel extends JPanel{
return JColorChooser.showDialog(this, "Color Picker", Color.MAGENTA);
}
} else {
System.out.println("Running");
//System.out.println("Running");
return JColorChooser.showDialog(this, "Color Picker", Color.MAGENTA);
}
}

@ -73,7 +73,7 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
DisplayManager() throws IOException {
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()));

@ -157,6 +157,7 @@ public class MyRobot{
public static boolean DEBUG_MODE=false;
public static ColorPanel CP;
public static DisplayManager DM;
public static AdditionalOptions AO;
public static boolean FUTURETONE = false;
public static ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
@ -579,10 +580,11 @@ public class MyRobot{
OVERLAY = new Overlay();
OVERLAY.setBounds(FRAME.getGraphicsConfiguration().getBounds());
OVERLAY.setOpaque(false);
FRAME.setAlwaysOnTop(true);
FRAME.addMouseListener(OVERLAY);
FRAME.addMouseMotionListener(OVERLAY);
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);
//System.out.println(f.getGraphicsConfiguration().getBounds().width+"/"+f.getGraphicsConfiguration().getBounds().height);
FRAME.setSize(FRAME.getGraphicsConfiguration().getBounds().width,FRAME.getGraphicsConfiguration().getBounds().height);
@ -610,6 +612,7 @@ public class MyRobot{
}
CP = new ColorPanel();
DM = new DisplayManager();
//AO = new AdditionalOptions();
FRAME.add(p);
}
FRAME.setIconImage(ImageIO.read(new File("cross.png")));
@ -770,7 +773,7 @@ public class MyRobot{
FUTURETONE=true;
onSongSelect=true;
}
System.out.println(c);
//System.out.println(c);
}
//System.out.println(onSongSelect+"/"+c);

@ -1,23 +1,43 @@
package sig;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
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 sig.utils.MouseUtils;
public class Overlay extends JPanel implements MouseMotionListener,MouseListener{
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() {
public void run() {
while (true) {
repaint();
try {
if (started) {
MyRobot.FRAME.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
} else {
MyRobot.FRAME.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
Thread.sleep(1000/60);
} catch (InterruptedException e) {
e.printStackTrace();
@ -32,14 +52,49 @@ public class Overlay extends JPanel implements MouseMotionListener,MouseListener
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(new Color(0,0,0,1));
g.fillRect(0, 0, MyRobot.screenSize.width, MyRobot.screenSize.height);
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));
if (started) {
g.setColor(new Color(0,0,0,1));
g.fillRect(0, 0, MyRobot.screenSize.width, MyRobot.screenSize.height);
g.setFont(drawFont);
g.setColor(Color.WHITE);
g.drawString("Make sure you are on the main menu screen with 'Rhythm Game' selected",4,26);
g.setColor(Color.BLACK);
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
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
public void mouseReleased(MouseEvent e) {
MyRobot.ENDDRAG=e.getLocationOnScreen();
if (MyRobot.STARTDRAG.x>MyRobot.ENDDRAG.x) {
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;
if (started) {
if (MyRobot.STARTDRAG!=null) {
MyRobot.ENDDRAG=e.getLocationOnScreen();
if (MyRobot.STARTDRAG.x>MyRobot.ENDDRAG.x) {
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;
}
}
MyRobot.calibrating=true;
}
@Override
@ -78,7 +156,9 @@ public class Overlay extends JPanel implements MouseMotionListener,MouseListener
@Override
public void mouseDragged(MouseEvent e) {
MyRobot.ENDDRAG=e.getLocationOnScreen();
if (started) {
MyRobot.ENDDRAG=e.getLocationOnScreen();
}
}
@Override

@ -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…
Cancel
Save