Add in ability to manually redefine colorData via user interface.

secondmonitor
sigonasr2 4 years ago
parent 5178517b74
commit 7b69c3f7f1
  1. BIN
      DivaBot/DivaBot.jar
  2. BIN
      DivaBot/button.xcf
  3. BIN
      DivaBot/capture.png
  4. BIN
      DivaBot/capture_2.png
  5. BIN
      DivaBot/capture_3.png
  6. BIN
      DivaBot/capture_4.png
  7. BIN
      DivaBot/capture_5.png
  8. 4
      DivaBot/colorData
  9. BIN
      DivaBot/reloadSong.png
  10. 40
      DivaBot/src/sig/AdditionalOptions.java
  11. 2
      DivaBot/src/sig/Display.java
  12. 22
      DivaBot/src/sig/DrawCanvas.java
  13. 25
      DivaBot/src/sig/MyRobot.java
  14. 196
      DivaBot/src/sig/ReloadSong.java
  15. 40
      DivaBot/src/sig/SongData.java
  16. BIN
      DivaBot/test.png

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 KiB

After

Width:  |  Height:  |  Size: 677 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 KiB

After

Width:  |  Height:  |  Size: 677 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 KiB

After

Width:  |  Height:  |  Size: 677 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 KiB

After

Width:  |  Height:  |  Size: 675 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 KiB

After

Width:  |  Height:  |  Size: 675 KiB

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@ -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;
}
}

@ -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);

@ -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<displays.size();i++) {
displays.get(i).draw(g);
@ -451,12 +453,22 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
applyConfig();
}
return;
} else
if (cursor.x>=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;
}

@ -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")));

@ -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<String,JSONObject> SONGARRAY = new HashMap<>();
public static JComboBox<JSONObject> 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
}
}

@ -42,32 +42,39 @@ public class SongData {
closestSong.distance=distance;
closestDistance=distance;
}
/*if (distance>=MAXTHRESHOLD && distance<closestMaxThresholdDistance) {
System.out.println(distance+" pixels diff: "+s.title);
closestMaxThresholdDistance=distance;
}*/
}
}
return closestSong;
}
public static void saveSongToFile(String title, long r, long g, long b) {
public static void saveSongToFile(String title, long r, long g, long b) throws IOException {
boolean found=false;
StringBuilder sb = new StringBuilder(title);
sb.append(":");
boolean first = true;
/*for (Color pixel : data) {
if (first) {
first=false;
} else {
sb.append(",");
}
sb.append(pixel.getRGB());
//Color c = new Color(9,true);
}*/
sb.append(r).append(",")
.append(g).append(",")
.append(b);
FileUtils.logToFile(sb.toString(),"colorData");
String[] fileData = FileUtils.readFromFile("colorData");
for (int i=0;i<fileData.length;i++) {
String[] split = fileData[i].split(":");
if (split.length>0) {
//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) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 KiB

After

Width:  |  Height:  |  Size: 506 KiB

Loading…
Cancel
Save