diff --git a/DivaBot/DivaBot.jar b/DivaBot/DivaBot.jar index 7105a82..d18c35e 100644 Binary files a/DivaBot/DivaBot.jar and b/DivaBot/DivaBot.jar differ diff --git a/DivaBot/button.xcf b/DivaBot/button.xcf index a25a0db..bb9af1d 100644 Binary files a/DivaBot/button.xcf and b/DivaBot/button.xcf differ diff --git a/DivaBot/capture.png b/DivaBot/capture.png index 2a89f6d..88d9987 100644 Binary files a/DivaBot/capture.png and b/DivaBot/capture.png differ diff --git a/DivaBot/capture_2.png b/DivaBot/capture_2.png index 056498b..617c8df 100644 Binary files a/DivaBot/capture_2.png and b/DivaBot/capture_2.png differ diff --git a/DivaBot/capture_3.png b/DivaBot/capture_3.png index a68d840..06ab385 100644 Binary files a/DivaBot/capture_3.png and b/DivaBot/capture_3.png differ diff --git a/DivaBot/capture_4.png b/DivaBot/capture_4.png index 86f281e..0f5d177 100644 Binary files a/DivaBot/capture_4.png and b/DivaBot/capture_4.png differ diff --git a/DivaBot/capture_5.png b/DivaBot/capture_5.png index 2937a33..86f91b9 100644 Binary files a/DivaBot/capture_5.png and b/DivaBot/capture_5.png differ diff --git a/DivaBot/colorData b/DivaBot/colorData index 19acfc4..1341dfe 100644 --- a/DivaBot/colorData +++ b/DivaBot/colorData @@ -8,7 +8,7 @@ Weekender Girl:9603623129,8143536192,7023009997 神曲:4946258494,4475941595,3340301379 カンタレラ:4503782143,3790000754,2513049117 巨大少女:3731017798,4370780514,7413760542 -クローバー♣クラブ:4365468840,5530233610,4779101844 +クローバー♣クラブ:5260193720,6627800391,5551285857 恋スルVOC@LOID:11460873603,10480525867,9425227787 桜ノ雨:8300126301,6096391834,6982464695 39:8911910637,8910841892,7738153876 @@ -113,7 +113,7 @@ Sweet Devil:6634620218,3136086595,6192411098 テオ:1670938584,1119524410,5147341281 初音ミクの消失 -DEAD END-:6701961288,6767316619,6746417217 秘密警察:3262137487,4000164607,3989724890 -妄想スケッチ:5664849812,5303351516,6760495429 +妄想スケッチ:6382410753,5949239568,7533122178 リンちゃんなう!:7136782033,6228041551,4262735136 ローリンガール:6764558530,6758136800,6759135862 ロキ:2406990430,945189166,3873292660 diff --git a/DivaBot/reloadSong.png b/DivaBot/reloadSong.png new file mode 100644 index 0000000..6800026 Binary files /dev/null and b/DivaBot/reloadSong.png differ diff --git a/DivaBot/src/sig/AdditionalOptions.java b/DivaBot/src/sig/AdditionalOptions.java deleted file mode 100644 index ae27389..0000000 --- a/DivaBot/src/sig/AdditionalOptions.java +++ /dev/null @@ -1,40 +0,0 @@ -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; - } -} diff --git a/DivaBot/src/sig/Display.java b/DivaBot/src/sig/Display.java index 55c1da2..2e5d31d 100644 --- a/DivaBot/src/sig/Display.java +++ b/DivaBot/src/sig/Display.java @@ -154,7 +154,7 @@ public class Display { public void draw(Graphics g) { g.setColor(backgroundCol); - g.fill3DRect(x, y, width, height, true); + g.fillRect(x, y, width, height); g.setColor(textCol); g.setFont(modifiedfont); g.drawString(currentText,x,y+height/2+fontHeight/4); diff --git a/DivaBot/src/sig/DrawCanvas.java b/DivaBot/src/sig/DrawCanvas.java index 3375435..0f9d33e 100644 --- a/DivaBot/src/sig/DrawCanvas.java +++ b/DivaBot/src/sig/DrawCanvas.java @@ -65,7 +65,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener, double difficultyRating = 0; Result bestPlay=null; int overallrating = 0; - BufferedImage addConfigButton,backgroundColorButton; + BufferedImage addConfigButton,backgroundColorButton,reloadSongButton; long ratingTime = System.currentTimeMillis()-10000; long bestPlayTime = System.currentTimeMillis()-10000; int lastRating = -1; @@ -88,6 +88,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener, //loadConfig(); addConfigButton = ImageIO.read(new File("addDisplay.png")); backgroundColorButton = ImageIO.read(new File("backgroundCol.png")); + reloadSongButton = ImageIO.read(new File("reloadSong.png")); Thread t = new Thread() { public void run() { while (true) { @@ -238,6 +239,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener, g2.drawImage(addConfigButton,getWidth()-addConfigButton.getWidth()+1,0,this); g2.drawImage(backgroundColorButton,getWidth()-backgroundColorButton.getWidth()+1,backgroundColorButton.getHeight()+1,this); + g2.drawImage(reloadSongButton,getWidth()-reloadSongButton.getWidth()+1,reloadSongButton.getHeight()*2+1,this); for (int i=0;i=getWidth()-addConfigButton.getWidth()&& + cursor.x<=getWidth()&& + cursor.y>=addConfigButton.getHeight()*2+1&& + cursor.y<=addConfigButton.getHeight()*2+1+addConfigButton.getHeight()) { + //System.out.println("Click"); + MyRobot.AO.f.setVisible(true); + return; } - Display previousDisplay = selectedDisplay; - if (selectedDisplay.equals(previousDisplay)) { - //System.out.println("Double click"); - DisplayManager.setupSettings(selectedDisplay); + if (selectedDisplay!=null) { + Display previousDisplay = selectedDisplay; + if (selectedDisplay.equals(previousDisplay)) { + //System.out.println("Double click"); + DisplayManager.setupSettings(selectedDisplay); + } } }break; } diff --git a/DivaBot/src/sig/MyRobot.java b/DivaBot/src/sig/MyRobot.java index a9fa6ac..ec82ebd 100644 --- a/DivaBot/src/sig/MyRobot.java +++ b/DivaBot/src/sig/MyRobot.java @@ -95,8 +95,7 @@ public class MyRobot{ /*static String FUTURETONESONGNAMES[] = 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[] {}; - static String NEWSONGS[] = 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 String NEWSONGS[] = new String[] {}; int SCREEN_X; int SCREEN_Y; int WINDOW_X; @@ -160,7 +159,7 @@ public class MyRobot{ public static boolean DEBUG_MODE=false; public static ColorPanel CP; public static DisplayManager DM; - public static AdditionalOptions AO; + public static ReloadSong AO; public static boolean FUTURETONE = false; public static String USERNAME = ""; public static String AUTHTOKEN = ""; @@ -553,14 +552,6 @@ public class MyRobot{ BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(630,80,580,380))); long r=0,g=0,b=0; int count=0; - for (int i=0;i<20;i++) { - if (img.getRGB(i, i)!=firstTwentyPixels[i]) { - firstTwentyPixels[i]=img.getRGB(i,i); - } else { - //System.out.println("Same image as last frame. Ignoring."); - return; - } - } for (int i=0;i<580;i++) { for (int j=0;j<380;j++) { r+=Math.pow(new Color(img.getRGB(i,j),true).getRed(),2); @@ -568,9 +559,7 @@ public class MyRobot{ b+=Math.pow(new Color(img.getRGB(i,j),true).getBlue(),2); } } - if (r+g+b>=MyRobot.smallestSongColor) { - selectedSong = SongData.compareData(r,g,b); - } + selectedSong = SongData.compareData(r,g,b); } void go() throws FontFormatException, IOException { @@ -634,7 +623,11 @@ public class MyRobot{ totalb+=Math.pow(new Color(img.getRGB(i,j),true).getBlue(),2); } } - SongData.saveSongToFile(NEWSONGS[currentSong],totalr,totalg,totalb); + try { + SongData.saveSongToFile(NEWSONGS[currentSong],totalr,totalg,totalb); + } catch (IOException e2) { + e2.printStackTrace(); + } try { SongData.loadSongsFromFile(); } catch (IOException e1) { @@ -692,7 +685,7 @@ public class MyRobot{ } CP = new ColorPanel(); DM = new DisplayManager(); - //AO = new AdditionalOptions(); + AO = new ReloadSong(); FRAME.add(p); } FRAME.setIconImage(ImageIO.read(new File("cross.png"))); diff --git a/DivaBot/src/sig/ReloadSong.java b/DivaBot/src/sig/ReloadSong.java new file mode 100644 index 0000000..584a94a --- /dev/null +++ b/DivaBot/src/sig/ReloadSong.java @@ -0,0 +1,196 @@ +package sig; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Rectangle; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; + +import javax.imageio.ImageIO; +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.ListCellRenderer; + +import org.json.JSONException; +import org.json.JSONObject; + +import sig.DisplayManager.FontRenderer; +import sig.utils.FileUtils; + +public class ReloadSong extends JPanel implements ItemListener,MouseListener{ + public static JFrame f = new JFrame(); + public static HashMap SONGARRAY = new HashMap<>(); + public static JComboBox songs; + static GridBagConstraints g = new GridBagConstraints(); + ReloadSong() throws IOException{ + JSONObject obj = FileUtils.readJsonFromUrl("http://projectdivar.com/songs"); + + for (String s : JSONObject.getNames(obj)) { + JSONObject songdata = obj.getJSONObject(s); + SONGARRAY.put(songdata.getString("name"),songdata); + } + + f = new JFrame(); + f.setIconImage(ImageIO.read(new File("cross.png"))); + f.setTitle("DivaBot - Reload Song"); + this.setLayout(new GridBagLayout()); + g.anchor=GridBagConstraints.EAST; + addComponent(1,1,2,1,new JLabel("Select correct song:")); + + JSONObject[] songList = new JSONObject[SONGARRAY.size()]; + int count = 0; + for (String s : SONGARRAY.keySet()) { + songList[count++]=SONGARRAY.get(s); + } + + for (int i = 0; i < count; i++) + { + for (int j = i + 1; j < count; j++) { + if (songList[i].getString("english_name").toLowerCase().compareTo(songList[j].getString("english_name").toLowerCase())>0) + { + JSONObject temp = songList[i]; + songList[i] = songList[j]; + songList[j] = temp; + } + } + } + + songs = new JComboBox(songList) { + @Override + public Dimension getPreferredSize() { + return new Dimension(600,40); + } + }; + songs.setRenderer(new SongRenderer()); + songs.setMaximumRowCount(12); + songs.addItemListener(this); + + JButton submit = new JButton("Recalibrate Song") { + @Override + public Dimension getPreferredSize() { + return new Dimension(600,40); + } + }; + + addComponent(3,1,10,1,songs); + addComponent(1,4,12,1,submit); + + submit.addMouseListener(this); + + addComponent(1,2,12,1,new JLabel(" ")); + addComponent(1,3,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; + } + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + + } + class SongRenderer 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) { + JSONObject selectedSong = ((JSONObject)value); + + if (isSelected) { + setBackground(list.getSelectionBackground()); + setForeground(list.getSelectionForeground()); + } else { + setBackground(list.getBackground()); + setForeground(list.getForeground()); + } + setText(selectedSong.getString("english_name") + +" - " + +((selectedSong.getString("romanized_name").length()>0)? + (!selectedSong.getString("romanized_name").equalsIgnoreCase(selectedSong.getString("name")))? + selectedSong.getString("romanized_name")+"("+selectedSong.getString("name")+")":"":selectedSong.getString("name"))); + return this; + } + + } + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + + } + @Override + public void mousePressed(MouseEvent e) { + BufferedImage img = null; + try { + ImageIO.write(img=MyRobot.MYROBOT.createScreenCapture(new Rectangle(630,80,580,380)),"png",new File("test.png")); + } catch (IOException e1) { + e1.printStackTrace(); + } + long totalr=0; + long totalg=0; + long totalb=0; + for (int i=0;i<580;i++) { + for (int j=0;j<380;j++) { + totalr+=Math.pow(new Color(img.getRGB(i,j),true).getRed(),2); + totalg+=Math.pow(new Color(img.getRGB(i,j),true).getGreen(),2); + totalb+=Math.pow(new Color(img.getRGB(i,j),true).getBlue(),2); + } + } + try { + SongData.saveSongToFile(((JSONObject)songs.getSelectedItem()).getString("name"),totalr,totalg,totalb); + } catch (JSONException | IOException e2) { + e2.printStackTrace(); + } + try { + SongData.loadSongsFromFile(); + } catch (IOException e1) { + e1.printStackTrace(); + } + f.setVisible(false); + } + @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/SongData.java b/DivaBot/src/sig/SongData.java index 37d1685..7a49bb3 100644 --- a/DivaBot/src/sig/SongData.java +++ b/DivaBot/src/sig/SongData.java @@ -42,32 +42,39 @@ public class SongData { closestSong.distance=distance; closestDistance=distance; } - /*if (distance>=MAXTHRESHOLD && distance0) { + //System.out.println(split[0]+"/"+title); + if (split[0].equalsIgnoreCase(title)) { + //System.out.println("Updated color data with new data for "+title+"!"); + fileData[i]=sb.toString(); + found=true; + break; + } + } + } + if (!found) { + FileUtils.logToFile(sb.toString(),"colorData"); + System.out.println("Appended color data with new data for "+title+"!"); + } else { + FileUtils.writetoFile(fileData, "colorData",false); + System.out.println("Updated color data with new data for "+title+"!"); + } } public static void loadSongsFromFile() throws IOException { String[] data = FileUtils.readFromFile("colorData"); @@ -76,6 +83,7 @@ public class SongData { SongData sd = ParseSong(data[i]); MyRobot.SONGS[i]=sd; } + MyRobot.firstTwentyPixels= new int[20]; } public static SongData ParseSong(String s) { diff --git a/DivaBot/test.png b/DivaBot/test.png index b274d8e..177bdd1 100644 Binary files a/DivaBot/test.png and b/DivaBot/test.png differ