diff --git a/Calibrate DivaBot.bat b/Calibrate DivaBot.bat new file mode 100644 index 0000000..5169359 --- /dev/null +++ b/Calibrate DivaBot.bat @@ -0,0 +1,2 @@ +cd DivaBot +java -jar "DivaBot.jar" calibrate \ No newline at end of file diff --git a/DivaBot/addDisplay.png b/DivaBot/addDisplay.png new file mode 100644 index 0000000..16e402f Binary files /dev/null and b/DivaBot/addDisplay.png differ diff --git a/DivaBot/backgroundCol.png b/DivaBot/backgroundCol.png new file mode 100644 index 0000000..c5cbe2a Binary files /dev/null and b/DivaBot/backgroundCol.png differ diff --git a/DivaBot/button.xcf b/DivaBot/button.xcf new file mode 100644 index 0000000..e4d6ba8 Binary files /dev/null and b/DivaBot/button.xcf differ diff --git a/DivaBot/config.txt b/DivaBot/config.txt new file mode 100644 index 0000000..c404a95 --- /dev/null +++ b/DivaBot/config.txt @@ -0,0 +1,3 @@ +WIDTH 546 +HEIGHT 384 +BACKGROUND -10092442 diff --git a/DivaBot/cross.png b/DivaBot/cross.png new file mode 100644 index 0000000..147f637 Binary files /dev/null and b/DivaBot/cross.png differ diff --git a/DivaBot/src/sig/ColorPanel.java b/DivaBot/src/sig/ColorPanel.java new file mode 100644 index 0000000..8258154 --- /dev/null +++ b/DivaBot/src/sig/ColorPanel.java @@ -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); + } +} diff --git a/DivaBot/src/sig/DisplayManager.java b/DivaBot/src/sig/DisplayManager.java new file mode 100644 index 0000000..dc9e7ec --- /dev/null +++ b/DivaBot/src/sig/DisplayManager.java @@ -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 tempFontList = new ArrayList(Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts())); + + for (int i=0;i configData = new HashMap(); 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"))); - - - Thread t = new Thread() { - public void run() { - while (true) { - displayTimer++; - MyRobot.p.repaint(0, 0, 1400, 1000); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + 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, MyRobot.p.getWidth(),MyRobot.p.getHeight()); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); } } - }; - t.start(); - } catch (IOException e) { - e.printStackTrace(); - } + } + }; + t.start(); } 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) { @@ -170,7 +163,38 @@ 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;i0)?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()); - } - } - - /* - 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); - } - }*/ - - - /*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 + + } } diff --git a/DivaBot/src/sig/MyRobot.java b/DivaBot/src/sig/MyRobot.java index 9fa5ac2..7936634 100644 --- a/DivaBot/src/sig/MyRobot.java +++ b/DivaBot/src/sig/MyRobot.java @@ -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 { - RunTests(); - f.setSize(1362, 1036); - f.add(p); + if (DEBUG_MODE) { + RunTests(); + } + 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); } - f.setVisible(true); - f.setTitle("DivaBot"); + 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); diff --git a/DivaBot/src/sig/utils/FileUtils.java b/DivaBot/src/sig/utils/FileUtils.java index 994329a..bce5562 100644 --- a/DivaBot/src/sig/utils/FileUtils.java +++ b/DivaBot/src/sig/utils/FileUtils.java @@ -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); } diff --git a/Run DivaBot.bat b/Run DivaBot.bat new file mode 100644 index 0000000..ea930df --- /dev/null +++ b/Run DivaBot.bat @@ -0,0 +1,2 @@ +cd DivaBot +java -jar "DivaBot.jar" \ No newline at end of file