Include initial Display Manager form to handle creating Displays.

secondmonitor
sigonasr2 5 years ago
parent cf9a4b6112
commit a41ff099fc
  1. 2
      Calibrate DivaBot.bat
  2. BIN
      DivaBot/addDisplay.png
  3. BIN
      DivaBot/backgroundCol.png
  4. BIN
      DivaBot/button.xcf
  5. 3
      DivaBot/config.txt
  6. BIN
      DivaBot/cross.png
  7. 35
      DivaBot/src/sig/ColorPanel.java
  8. 187
      DivaBot/src/sig/DisplayManager.java
  9. 311
      DivaBot/src/sig/DrawCanvas.java
  10. 56
      DivaBot/src/sig/MyRobot.java
  11. 8
      DivaBot/src/sig/utils/FileUtils.java
  12. 2
      Run DivaBot.bat

@ -0,0 +1,2 @@
cd DivaBot
java -jar "DivaBot.jar" calibrate

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

@ -0,0 +1,3 @@
WIDTH 546
HEIGHT 384
BACKGROUND -10092442

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

@ -0,0 +1,35 @@
package sig;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
public class ColorPanel extends JPanel{
public ColorPanel() {
}
public Color getBackgroundColor() {
if (DrawCanvas.configData.containsKey("BACKGROUND")) {
try {
return JColorChooser.showDialog(this, "Color Picker",
new Color(
Integer.parseInt(DrawCanvas.configData.get("BACKGROUND"))));
} catch (NumberFormatException e) {
return JColorChooser.showDialog(this, "Color Picker", Color.MAGENTA);
}
} else {
System.out.println("Running");
return JColorChooser.showDialog(this, "Color Picker", Color.MAGENTA);
}
}
public Color getColor(Color color) {
return JColorChooser.showDialog(this, "Color Picker", color);
}
public Dimension getPreferredSize() {
return new Dimension(640,480);
}
}

@ -0,0 +1,187 @@
package sig;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
public class DisplayManager extends JPanel implements MouseListener{
JFrame f = new JFrame();
GridBagConstraints g = new GridBagConstraints();
Font[] fontList = null;
ColorButton colorButton;
ColorButton colorButton2;
JTextField fontSizeInput;
DisplayManager() {
List<Font> tempFontList = new ArrayList(Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()));
for (int i=0;i<tempFontList.size();i++) {
if (!tempFontList.get(i).canDisplay(12479) || tempFontList.get(i).getFontName().equals("Dialog.plain")) {
tempFontList.remove(i);
}
}
fontList = tempFontList.toArray(new Font[tempFontList.size()]);
this.setLayout(new GridBagLayout());
g.anchor=GridBagConstraints.EAST;
addComponent(1,1,3,1,new JLabel("Background Color"));
g.anchor=GridBagConstraints.WEST;
colorButton = (ColorButton)addComponent(4,1,4,1,new ColorButton("Color"));
JComboBox fonts = new JComboBox(fontList) {
@Override
public Dimension getPreferredSize() {
return new Dimension(300,40);
}
};
addComponent(9,1,2,1,new JLabel(" "));
fonts.setRenderer(new FontRenderer());
fonts.setMaximumRowCount(5);
g.anchor=GridBagConstraints.EAST;
addComponent(1,3,3,1,new JLabel("Font"));
g.anchor=GridBagConstraints.WEST;
addComponent(4,3,4,1,fonts);
g.anchor=GridBagConstraints.EAST;
addComponent(1,5,3,1,new JLabel("Font Color"));
g.anchor=GridBagConstraints.WEST;
colorButton = (ColorButton)addComponent(4,5,4,1,new ColorButton("Color"));
g.anchor=GridBagConstraints.EAST;
addComponent(1,7,3,1,new JLabel("Width"));
g.anchor=GridBagConstraints.WEST;
fontSizeInput = (JTextField)addComponent(4,7,1,1,new JTextField() {
@Override
public Dimension getPreferredSize() {
return new Dimension(50,20);
}
});
g.anchor=GridBagConstraints.EAST;
addComponent(5,7,2,1,new JLabel("Height"));
g.anchor=GridBagConstraints.WEST;
fontSizeInput = (JTextField)addComponent(7,7,1,1,new JTextField() {
@Override
public Dimension getPreferredSize() {
return new Dimension(50,20);
}
});
addComponent(1,2,3,1,new JLabel(" "));
addComponent(1,4,3,1,new JLabel(" "));
addComponent(1,6,3,1,new JLabel(" "));
f.add(this);
f.pack();
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;
}
class FontRenderer extends JLabel
implements ListCellRenderer {
@Override
public Dimension getPreferredSize() {
return new Dimension(300,40);
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
Font selectedFont = ((Font)value);
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setText(selectedFont.getFontName());
setFont(selectedFont.deriveFont(32f));
return this;
}
}
class ColorButton extends JButton{
protected Color col = Color.BLUE;
public ColorButton(String string) {
super(string);
this.setColor(col);
this.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
Color c = MyRobot.CP.getColor(col);
if (c!=null) {
((ColorButton)(e.getSource())).setColor(c);
}
}
});
}
@Override
public Dimension getPreferredSize() {
return new Dimension(120,24);
}
public void setColor(Color col) {
this.setBackground(col);
if (col.getRed()+col.getGreen()+col.getBlue()<=255) {
this.setForeground(Color.WHITE);
} else {
this.setForeground(Color.BLACK);
}
}
public Color getColor() {
return col;
}
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}

@ -1,15 +1,25 @@
package sig;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.font.TextAttribute;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
@ -18,6 +28,7 @@ import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.AttributedString;
import java.util.HashMap;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
@ -34,7 +45,7 @@ import sig.utils.FileUtils;
import sig.utils.ImageUtils;
import sig.utils.TextUtils;
public class DrawCanvas extends JPanel implements KeyListener{
public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,WindowListener,MouseListener{
String difficulty;
String panelText;
//Font programFont = new Font("Alata Regular", Font.PLAIN, 32);
@ -50,12 +61,7 @@ public class DrawCanvas extends JPanel implements KeyListener{
double difficultyRating = 0;
Result bestPlay=null;
int overallrating = 0;
BufferedImage bar;
BufferedImage hard;
BufferedImage extreme;
BufferedImage exextreme;
BufferedImage overallbar;
BufferedImage panel,paneloverlay,songpanel,songpaneloverlay;
BufferedImage addConfigButton,backgroundColorButton;
long ratingTime = System.currentTimeMillis()-10000;
long bestPlayTime = System.currentTimeMillis()-10000;
int lastRating = -1;
@ -68,27 +74,17 @@ public class DrawCanvas extends JPanel implements KeyListener{
int displayTimer = 0;
BufferedImage doubleBuffer=null,firstBuffer=null;
boolean targetBuffer=false;
static Color background = new Color(170,170,170);
public static HashMap<String,String> configData = new HashMap<String,String>();
DrawCanvas() throws FontFormatException, IOException {
Font originalProgramFont = Font.createFont(Font.TRUETYPE_FONT,new File("Alata-Regular.ttf"));
programFont = originalProgramFont.deriveFont(36f);
programFontSmall = originalProgramFont.deriveFont(24f);
try {
bar = ImageUtils.toCompatibleImage(ImageIO.read(new File("divabar.png")));
overallbar = ImageUtils.toCompatibleImage(ImageIO.read(new File("overlaybar.png")));
exextreme = ImageUtils.toCompatibleImage(ImageIO.read(new File("exex.png")));
extreme = ImageUtils.toCompatibleImage(ImageIO.read(new File("ex.png")));
hard = ImageUtils.toCompatibleImage(ImageIO.read(new File("hd.png")));
panel = ImageUtils.toCompatibleImage(ImageIO.read(new File("panel.png")));
songpanel = ImageUtils.toCompatibleImage(ImageIO.read(new File("songpanel.png")));
paneloverlay = ImageUtils.toCompatibleImage(ImageIO.read(new File("paneloverlay.png")));
songpaneloverlay = ImageUtils.toCompatibleImage(ImageIO.read(new File("songpanel_overlay.png")));
loadConfig();
addConfigButton = ImageIO.read(new File("addDisplay.png"));
backgroundColorButton = ImageIO.read(new File("backgroundCol.png"));
Thread t = new Thread() {
public void run() {
while (true) {
displayTimer++;
MyRobot.p.repaint(0, 0, 1400, 1000);
MyRobot.p.repaint(0, 0, MyRobot.p.getWidth(),MyRobot.p.getHeight());
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
@ -98,9 +94,6 @@ public class DrawCanvas extends JPanel implements KeyListener{
}
};
t.start();
} catch (IOException e) {
e.printStackTrace();
}
}
public void pullData(final String songname,final String difficulty) {
@ -113,7 +106,7 @@ public class DrawCanvas extends JPanel implements KeyListener{
passes=0;
fcCount=0;
artist="";
this.repaint(0,0,1400,1000);
this.repaint(0,0,this.getWidth(),this.getHeight());
if (t!=null && t.isAlive()) {
t.stop();
}
@ -160,7 +153,7 @@ public class DrawCanvas extends JPanel implements KeyListener{
scrolling=false;
}
scrollX = 0;
MyRobot.p.repaint(0,0,1400,1000);
MyRobot.p.repaint(0,0,MyRobot.p.getWidth(),MyRobot.p.getHeight());
}
}
} catch (JSONException | IOException e) {
@ -171,6 +164,37 @@ public class DrawCanvas extends JPanel implements KeyListener{
t.start();
}
public static void saveConfig() {
String[] data = new String[configData.size()];
int i = 0;
for (String s : configData.keySet()) {
data[i++]=s+"\t"+configData.get(s).replaceAll("\t", "");
}
FileUtils.writetoFile(data, "config.txt", false);
}
public static void loadConfig() throws IOException {
String[] data = FileUtils.readFromFile("config.txt");
for (int i=0;i<data.length;i++) {
String[] split = data[i].split("\t");
configData.put(split[0],split[1]);
}
applyConfig();
}
public static void applyConfig() {
if (configData.containsKey("BACKGROUND")) {
try {
background = new Color(Integer.parseInt(configData.get("BACKGROUND")));
} catch (NumberFormatException e) {
}
}
if (MyRobot.p!=null) {
MyRobot.p.repaint(0, 0, MyRobot.p.getWidth(),MyRobot.p.getHeight());
}
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
@ -179,88 +203,47 @@ public class DrawCanvas extends JPanel implements KeyListener{
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g2.setColor(new Color(0,255,0));
g2.fillRect(0, 0, 1362, 1000);
//if (!MyRobot.isOnSongSelect()) {
//g2.setFont(programFont);
//g2.drawImage(bar, 0, 0,null);
g2.drawImage(songpanel, 0,0,null);
g2.drawImage(panel, 0,935,null);
g2.drawImage(panel, 484,935,null);
g2.drawImage(panel, 968,935,null);
String songDisplay = ((romanizedname.length()>0)?romanizedname:englishname) + " - " + artist;
Rectangle2D bounds = TextUtils.calculateStringBoundsFont(songDisplay, programFont);
if (bounds.getWidth()>675) {
DrawUtils.drawOutlineText(g2, programFontSmall, 8, 42, 1, Color.WHITE, new Color(0,0,0,64), songDisplay);
} else {
DrawUtils.drawOutlineText(g2, programFont, 8, 42, 1, Color.WHITE, new Color(0,0,0,64), songDisplay);
}
if ((bestPlayTime>System.currentTimeMillis()-10000)) {
DrawUtils.drawOutlineText(g2, programFont, 8, 935+42, 1, new Color(220,220,255,(int)Math.min(((System.currentTimeMillis()-bestPlayTime))/5,255)), new Color(0,0,0,64),"New Record!");
} else {
DrawUtils.drawOutlineText(g2, programFontSmall, 8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),((bestPlay!=null)?bestPlay.display():""));
}
if ((ratingTime>System.currentTimeMillis()-10000)) {
DrawUtils.drawOutlineText(g2, programFontSmall, 484+8, 935+42, 1, new Color(220,220,255,(int)Math.min(((System.currentTimeMillis()-ratingTime))/5,255)), new Color(0,0,0,64),"Rating up! "+lastRating+" -> "+overallrating);
} else {
DrawUtils.drawOutlineText(g2, programFont, 484+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),Integer.toString(overallrating));
}
if (displayTimer%3==0) {
DrawUtils.drawOutlineText(g2, programFont, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),difficultyRating + " - " + fullNameDifficulty());
} else
if (displayTimer%3==1) {
if (plays>0) {
DrawUtils.drawOutlineText(g2, programFontSmall, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),""+(passes)+"/"+(plays)+" play"+((plays!=1)?"s":"")+" "+"("+((int)(Math.floor(((float)passes)/plays*100)))+"% pass rate)");
} else {
DrawUtils.drawOutlineText(g2, programFont, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),"No plays");
}
} else {
if (fcCount>0) {
DrawUtils.drawOutlineText(g2, programFont, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),fcCount +" FC"+(fcCount==1?"":"s")+" "+((int)(Math.floor(((float)fcCount)/plays*100)))+"% FC rate");
} else {
DrawUtils.drawOutlineText(g2, programFont, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),difficultyRating + " - " + fullNameDifficulty());
}
}
g2.setColor(background);
g2.fillRect(0, 0, this.getWidth(), this.getHeight());
/*
if (ratingTime>System.currentTimeMillis()-10000) {
DrawUtils.drawOutlineText(g, programFont, 32, 36, 1, new Color(220,220,255,(int)Math.min(((System.currentTimeMillis()-ratingTime))/5,255)), new Color(0,0,0,64), "Rating up! "+lastRating+" -> "+overallrating);
} else {
String text = songname+" / "+((romanizedname.length()>0)?romanizedname:englishname)+" "+(artist.length()>0?"by "+artist:"")+" "+((plays>0)?("Plays - "+(passes)+"/"+(plays)):"")+" "+((plays!=0)?"("+((int)(Math.floor(((float)passes)/plays*100)))+"% pass rate"+((fcCount>0)?" - "+fcCount+" FC"+(fcCount==1?"":"s")+" "+((int)(Math.floor(((float)fcCount)/plays*100)))+"% FC rate":"")+")":"No plays")+" "+((bestPlay!=null)?"Best Play - "+bestPlay.display():"")+" Overall Rating: "+overallrating;
Rectangle2D bounds = TextUtils.calculateStringBoundsFont(text, programFont);
if (scrollX<-bounds.getWidth()-100) {
scrollX=0;
}
DrawUtils.drawOutlineText(g2, programFont, 32+scrollX, 36, 1, Color.WHITE, new Color(0,0,0,64), text);
if (scrolling) {
DrawUtils.drawOutlineText(g2, programFont, 32+scrollX+(int)bounds.getWidth()+100, 36, 1, Color.WHITE, new Color(0,0,0,64), text);
}
}*/
g2.drawImage(addConfigButton,getWidth()-addConfigButton.getWidth()+1,0,this);
g2.drawImage(backgroundColorButton,getWidth()-backgroundColorButton.getWidth()+1,backgroundColorButton.getHeight()+1,this);
/*switch (difficulty) {
case "H":{
g2.drawImage(hard,0,0,20,51,null);
}break;
case "EX":{
g2.drawImage(extreme,0,0,20,51,null);
}break;
case "EXEX":{
g2.drawImage(exextreme,0,0,20,51,null);
}break;
}*/
//}
//as.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
//g2.drawString(songname, 24, 32);
//g2.drawImage(overallbar, 1349, 0,null);
g2.drawImage(songpaneloverlay, 0,0,null);
g2.drawImage(paneloverlay, 0,935,null);
g2.drawImage(paneloverlay, 484,935,null);
g2.drawImage(paneloverlay, 968,935,null);
//System.out.println(System.currentTimeMillis()-startTime+"ms");
// String songDisplay = ((romanizedname.length()>0)?romanizedname:englishname) + " - " + artist;
// Rectangle2D bounds = TextUtils.calculateStringBoundsFont(songDisplay, programFont);
// if (bounds.getWidth()>675) {
// DrawUtils.drawOutlineText(g2, programFontSmall, 8, 42, 1, Color.WHITE, new Color(0,0,0,64), songDisplay);
// } else {
// DrawUtils.drawOutlineText(g2, programFont, 8, 42, 1, Color.WHITE, new Color(0,0,0,64), songDisplay);
// }
//
// if ((bestPlayTime>System.currentTimeMillis()-10000)) {
// DrawUtils.drawOutlineText(g2, programFont, 8, 935+42, 1, new Color(220,220,255,(int)Math.min(((System.currentTimeMillis()-bestPlayTime))/5,255)), new Color(0,0,0,64),"New Record!");
// } else {
// DrawUtils.drawOutlineText(g2, programFontSmall, 8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),((bestPlay!=null)?bestPlay.display():""));
// }
// if ((ratingTime>System.currentTimeMillis()-10000)) {
// DrawUtils.drawOutlineText(g2, programFontSmall, 484+8, 935+42, 1, new Color(220,220,255,(int)Math.min(((System.currentTimeMillis()-ratingTime))/5,255)), new Color(0,0,0,64),"Rating up! "+lastRating+" -> "+overallrating);
// } else {
// DrawUtils.drawOutlineText(g2, programFont, 484+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),Integer.toString(overallrating));
// }
// if (displayTimer%3==0) {
// DrawUtils.drawOutlineText(g2, programFont, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),difficultyRating + " - " + fullNameDifficulty());
// } else
// if (displayTimer%3==1) {
// if (plays>0) {
// DrawUtils.drawOutlineText(g2, programFontSmall, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),""+(passes)+"/"+(plays)+" play"+((plays!=1)?"s":"")+" "+"("+((int)(Math.floor(((float)passes)/plays*100)))+"% pass rate)");
// } else {
// DrawUtils.drawOutlineText(g2, programFont, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),"No plays");
// }
// } else {
// if (fcCount>0) {
// DrawUtils.drawOutlineText(g2, programFont, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),fcCount +" FC"+(fcCount==1?"":"s")+" "+((int)(Math.floor(((float)fcCount)/plays*100)))+"% FC rate");
// } else {
// DrawUtils.drawOutlineText(g2, programFont, 968+8, 935+42, 1, Color.WHITE, new Color(0,0,0,64),difficultyRating + " - " + fullNameDifficulty());
// }
// }
}
private String fullNameDifficulty() {
@ -292,7 +275,6 @@ public class DrawCanvas extends JPanel implements KeyListener{
@Override
public void keyPressed(KeyEvent e) {
System.out.println(e.getKeyChar());
}
@Override
@ -300,4 +282,117 @@ public class DrawCanvas extends JPanel implements KeyListener{
// TODO Auto-generated method stub
}
@Override
public void componentResized(ComponentEvent e) {
configData.put("WIDTH",Integer.toString(this.getWidth()+MyRobot.FRAME.getInsets().left+MyRobot.FRAME.getInsets().right));
configData.put("HEIGHT",Integer.toString(this.getHeight()+MyRobot.FRAME.getInsets().top+MyRobot.FRAME.getInsets().bottom));
}
@Override
public void componentMoved(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentShown(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentHidden(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
saveConfig();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
Point cursor = e.getPoint();
cursor.translate(-MyRobot.FRAME.getInsets().left,-MyRobot.FRAME.getInsets().top);
System.out.println(cursor+"/"+addConfigButton.getHeight());
if (cursor.x>=getWidth()-addConfigButton.getWidth()&&
cursor.x<=getWidth()&&
cursor.y>=0&&
cursor.y<=addConfigButton.getHeight()) {
MyRobot.FRAME.setCursor(new Cursor(Cursor.HAND_CURSOR));
} else
if (cursor.x>=getWidth()-addConfigButton.getWidth()&&
cursor.x<=getWidth()&&
cursor.y>=addConfigButton.getHeight()+1&&
cursor.y<=addConfigButton.getHeight()+1+addConfigButton.getHeight()) {
Color c = MyRobot.CP.getBackgroundColor();
if (c!=null) {
configData.put("BACKGROUND",Integer.toString(c.getRGB()));
applyConfig();
}
} else
{
MyRobot.FRAME.setCursor(Cursor.getDefaultCursor());
}
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}

@ -89,6 +89,7 @@ public class MyRobot{
static CustomRobot MYROBOT;
Color SCREEN[][];
static SongData SONGS[];
public static JFrame FRAME;
/*static String SONGNAMES[] = new String[] {"Yellow","The secret garden","Tell Your World","愛言葉","Weekender Girl","歌に形はないけれど","えれくとりっく・えんじぇぅ","神曲","カンタレラ","巨大少女","クローバー♣クラブ","恋スルVOC@LOID","桜ノ雨","39","深海シティアンダーグラウンド","深海少女","積乱雲グラフィティ","千年の独奏歌","ダブルラリアット","ハジメテノオト","初めての恋が終わる時","packaged","Palette","FREELY TOMORROW","from Y to Y","みくみくにしてあげる♪","メルト","モノクロ∞ブルースカイ","ゆめゆめ","16 -out of the gravity-","ACUTE","インタビュア","LOL -lots of laugh-","Glory 3usi9","soundless voice","ジェミニ","白い雪のプリンセスは","スキキライ","タイムマシン","Dear","DECORATOR","トリコロール・エア・ライン","Nostalogic","Hand in Hand","Fire◎Flower","ブラック★ロックシューター","メテオ","ワールドイズマイン","アマツキツネ","erase or zero","エレクトロサチュレイタ","on the rocks","からくりピエロ","カラフル×メロディ","Catch the Wave","キャットフード","サマーアイドル","shake it!","Just Be Friends","スイートマジック","SPiCa -39's Giving Day Edition-","番凩","テレカクシ思春期","天樂","どういうことなの!?","東京テディベア","どりーみんチュチュ","トリノコシティ","ネトゲ廃人シュプレヒコール","No Logic","ハイハハイニ","はじめまして地球人さん","*ハロー、プラネット。 (I.M.PLSE-EDIT)","Hello, Worker","忘却心中","magnet","右肩の蝶","結ンデ開イテ羅刹ト骸","メランコリック","リモコン","ルカルカ★ナイトフィーバー","炉心融解","WORLD'S END UMBRELLA","アカツキアライヴァル","アゲアゲアゲイン","1925","え?あぁ、そう。","エイリアンエイリアン","ODDS&ENDS","君の体温","こっち向いて Baby","壊セ壊セ","39みゅーじっく!","サンドリヨン","SING&SMILE","スノーマン","DYE","なりすましゲンガー","ヒバナ","ヒビカセ","ブラックゴールド","ミラクルペイント","指切り","ありふれたせかいせいふく","アンハッピーリフレイン","大江戸ジュリアナイト","ゴーストルール","こちら、幸福安心委員会です。","孤独の果て -extend edition-","ジターバグ","Sweet Devil","砂の惑星","テオ","初音ミクの消失 -DEAD END-","秘密警察","妄想スケッチ","リンちゃんなう!","ローリンガール","ロキ","ロミオとシンデレラ","エンヴィキャットウォーク","骸骨楽団とリリア","サイハテ","ジグソーパズル","千本桜","ピアノ×フォルテ×スキャンダル","Blackjack","ぽっぴっぽー","裏表ラバーズ","Sadistic.Music∞Factory","デンパラダイム","二次元ドリームフィーバー","ネガポジ*コンティニューズ","初音ミクの激唱","ワールズエンド・ダンスホール","ココロ","システマティック・ラヴ","Knife","二息歩行","PIANOGIRL","夢喰い白黒バク","ブレス・ユア・ブレス","恋は戦争","あなたの歌姫","Starduster","StargazeR","リンリンシグナル","Rosary Pale","多重未来のカルテット~QUARTET THEME~","LIKE THE WIND","AFTER BURNER",
"ストロボナイツ","VOiCE","恋色病棟","ねこみみスイッチ","パラジクロロベンゼン","カラフル×セクシィ","劣等上等","Star Story","パズル","キップル・インダストリー","夢の続き","MEGANE","Change me"};*/
static SongInfo SONGNAMES[] = new SongInfo[] {};
@ -151,6 +152,9 @@ public class MyRobot{
static boolean repaintCalled = false;
public static Overlay OVERLAY;
public static boolean CALIBRATION_MODE=false;
public static boolean DEBUG_MODE=false;
public static ColorPanel CP;
public static DisplayManager DM;
public static ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
@ -160,6 +164,9 @@ public class MyRobot{
if (args[0].equalsIgnoreCase("calibrate")) {
CALIBRATION_MODE=true;
}
if (args[0].equalsIgnoreCase("debug")) {
DEBUG_MODE=true;
}
}
JSONObject obj = FileUtils.readJsonFromUrl("http://www.projectdivar.com/songs");
SONGNAMES = new SongInfo[JSONObject.getNames(obj).length];
@ -500,6 +507,7 @@ public class MyRobot{
void go() throws FontFormatException, IOException {
initialize();
DrawCanvas.loadConfig();
//gotoxy(100, 100);
SCREEN = new Color[SCREEN_X][SCREEN_Y];
long startTime = System.currentTimeMillis();
@ -507,8 +515,8 @@ public class MyRobot{
SongData.loadSongsFromFile();
System.setProperty("awt.useSystemAAFontSettings","on");
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FRAME = new JFrame();
FRAME.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p = new DrawCanvas();
p.difficulty="EXEX";
p.songname = "Dear";
@ -574,26 +582,44 @@ public class MyRobot{
});
if (CALIBRATION_MODE) {
JFrame.setDefaultLookAndFeelDecorated(true);
f.setUndecorated(true);
FRAME.setUndecorated(true);
OVERLAY = new Overlay();
OVERLAY.setBounds(f.getGraphicsConfiguration().getBounds());
OVERLAY.setBounds(FRAME.getGraphicsConfiguration().getBounds());
OVERLAY.setOpaque(false);
f.addMouseListener(OVERLAY);
f.addMouseMotionListener(OVERLAY);
screenSize=new Dimension(f.getGraphicsConfiguration().getBounds().width,f.getGraphicsConfiguration().getBounds().height);
f.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
FRAME.addMouseListener(OVERLAY);
FRAME.addMouseMotionListener(OVERLAY);
screenSize=new Dimension(FRAME.getGraphicsConfiguration().getBounds().width,FRAME.getGraphicsConfiguration().getBounds().height);
FRAME.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
//f.add(p);
//System.out.println(f.getGraphicsConfiguration().getBounds().width+"/"+f.getGraphicsConfiguration().getBounds().height);
f.setSize(f.getGraphicsConfiguration().getBounds().width,f.getGraphicsConfiguration().getBounds().height);
f.add(OVERLAY);
f.setBackground(new Color(0,0,0,0));
FRAME.setSize(FRAME.getGraphicsConfiguration().getBounds().width,FRAME.getGraphicsConfiguration().getBounds().height);
FRAME.add(OVERLAY);
FRAME.setBackground(new Color(0,0,0,0));
} else {
if (DEBUG_MODE) {
RunTests();
f.setSize(1362, 1036);
f.add(p);
}
f.setVisible(true);
f.setTitle("DivaBot");
FRAME.addComponentListener(p);
FRAME.addWindowListener(p);
FRAME.addMouseListener(p);
if (DrawCanvas.configData.containsKey("WIDTH")&&DrawCanvas.configData.containsKey("HEIGHT")) {
try {
FRAME.setSize(
Integer.parseInt(DrawCanvas.configData.get("WIDTH")),
Integer.parseInt(DrawCanvas.configData.get("HEIGHT")));
} catch (NumberFormatException e) {
FRAME.setSize(640, 480);
}
} else {
FRAME.setSize(640, 480);
}
CP = new ColorPanel();
DM = new DisplayManager();
FRAME.add(p);
}
FRAME.setIconImage(ImageIO.read(new File("cross.png")));
FRAME.setVisible(true);
FRAME.setTitle("DivaBot");
title = new JTextField();
title.setSize(200,100);
title.setText((currentSong>=SONGNAMES.length)?"DONE!":SONGNAMES[currentSong].name);

@ -282,6 +282,10 @@ public class FileUtils {
}
public static void writetoFile(String[] data, String filename) {
writetoFile(data,filename,true);
}
public static void writetoFile(String[] data, String filename, boolean append) {
File file = new File(filename);
try {
@ -289,10 +293,10 @@ public class FileUtils {
file.createNewFile();
}
OutputStream out = new FileOutputStream(file,true);
OutputStream out = new FileOutputStream(file,append);
Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
PrintWriter pw = new PrintWriter(writer);
pw.print('\uFEFF');
//pw.print('\uFEFF');
for (String s : data) {
pw.println(s);
}

@ -0,0 +1,2 @@
cd DivaBot
java -jar "DivaBot.jar"
Loading…
Cancel
Save