Finish up overlay bar. Fix all bugs.

secondmonitor
sigonasr2 4 years ago
parent 57f8f3b5d5
commit 07e207ebed
  1. 2
      DivaBot/.settings/org.eclipse.core.resources.prefs
  2. 38
      DivaBot/src/sig/DrawPanel.java
  3. 7
      DivaBot/src/sig/MyRobot.java
  4. 1
      DivaBot/src/sig/Result.java
  5. 1
      DivaBot/src/sig/SongData.java
  6. 1
      DivaBot/src/sig/TypeFace.java
  7. 5
      DivaBot/src/sig/utils/TextUtils.java

@ -1,3 +1,3 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/MyRobot.java=UTF-8 encoding//src/sig/MyRobot.java=UTF-8
encoding/colorData=UTF-8 encoding/colorData=UTF-8

@ -1,15 +1,19 @@
package sig;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.font.TextAttribute; import java.awt.font.TextAttribute;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.AttributedString; import java.text.AttributedString;
import java.util.Timer;
import java.util.TimerTask;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -20,6 +24,7 @@ import org.json.JSONObject;
import sig.utils.DrawUtils; import sig.utils.DrawUtils;
import sig.utils.FileUtils; import sig.utils.FileUtils;
import sig.utils.TextUtils;
public class DrawPanel extends JPanel{ public class DrawPanel extends JPanel{
String difficulty; String difficulty;
@ -42,6 +47,10 @@ public class DrawPanel extends JPanel{
long ratingTime = System.currentTimeMillis()-10000; long ratingTime = System.currentTimeMillis()-10000;
int lastRating = -1; int lastRating = -1;
Thread t = null; Thread t = null;
boolean scrolling = false;
int scrollX = 0;
int scrollSpd = 2;
Timer scrollTimer = new Timer();
DrawPanel() { DrawPanel() {
try { try {
@ -50,6 +59,18 @@ public class DrawPanel extends JPanel{
exextreme = ImageIO.read(new File("exex.png")); exextreme = ImageIO.read(new File("exex.png"));
extreme = ImageIO.read(new File("ex.png")); extreme = ImageIO.read(new File("ex.png"));
hard = ImageIO.read(new File("hd.png")); hard = ImageIO.read(new File("hd.png"));
Timer t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (MyRobot.p.scrolling) {
MyRobot.p.scrollX-=MyRobot.p.scrollSpd;
MyRobot.p.repaint();
}
}
},0,20);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -92,6 +113,14 @@ public class DrawPanel extends JPanel{
lastRating = overallrating; lastRating = overallrating;
overallrating = (int)obj.getDouble("rating"); overallrating = (int)obj.getDouble("rating");
if (lastRating<overallrating) {ratingTime=System.currentTimeMillis();}*/ if (lastRating<overallrating) {ratingTime=System.currentTimeMillis();}*/
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)":"No plays")+" "+((bestPlay!=null)?"Best Play - "+bestPlay.display():""+" Overall Rating: "+overallrating);
Rectangle2D bounds = TextUtils.calculateStringBoundsFont(text, programFont);
if (bounds.getWidth()>1345) {
scrolling=true;
} else {
scrolling=false;
}
scrollX = 0;
MyRobot.p.repaint(); MyRobot.p.repaint();
} catch (JSONException | IOException e) { } catch (JSONException | IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -109,12 +138,18 @@ public class DrawPanel extends JPanel{
RenderingHints.VALUE_FRACTIONALMETRICS_ON); RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g.setColor(new Color(0,255,0)); g.setColor(new Color(0,255,0));
g.fillRect(0, 0, 1400, 100); g.fillRect(0, 0, 1400, 100);
if (!MyRobot.isOnSongSelect()) {
g.setFont(programFont); g.setFont(programFont);
g.drawImage(bar, 0, 0, this); g.drawImage(bar, 0, 0, this);
if (ratingTime>System.currentTimeMillis()-10000) { if (ratingTime>System.currentTimeMillis()-10000) {
DrawUtils.drawOutlineText(g, programFont, 32, 36, 3, new Color(220,220,255,(int)Math.min(((System.currentTimeMillis()-ratingTime))/5,255)), new Color(0,0,0,64), "Rating up! "+lastRating+" -> "+overallrating); DrawUtils.drawOutlineText(g, programFont, 32, 36, 3, new Color(220,220,255,(int)Math.min(((System.currentTimeMillis()-ratingTime))/5,255)), new Color(0,0,0,64), "Rating up! "+lastRating+" -> "+overallrating);
} else { } else {
DrawUtils.drawOutlineText(g, programFont, 32, 36, 3, Color.WHITE, new Color(0,0,0,64), 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)":"No plays")+" "+((bestPlay!=null)?"Best Play - "+bestPlay.display():" Overall Rating: "+overallrating)); 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)":"No plays")+" "+((bestPlay!=null)?"Best Play - "+bestPlay.display():""+" Overall Rating: "+overallrating);
Rectangle2D bounds = TextUtils.calculateStringBoundsFont(text, programFont);
if (scrollX<-bounds.getWidth()-100) {
scrollX=(int)bounds.getWidth()+100;
}
DrawUtils.drawOutlineText(g, programFont, 32+scrollX, 36, 3, Color.WHITE, new Color(0,0,0,64) , text);
} }
switch (difficulty) { switch (difficulty) {
case "H":{ case "H":{
@ -127,6 +162,7 @@ public class DrawPanel extends JPanel{
g.drawImage(exextreme,0,0,20,51,this); g.drawImage(exextreme,0,0,20,51,this);
}break; }break;
} }
}
//as.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); //as.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
//g.drawString(songname, 24, 32); //g.drawString(songname, 24, 32);
g.drawImage(overallbar, 1349, 0, this); g.drawImage(overallbar, 1349, 0, this);

@ -1,3 +1,4 @@
package sig;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.GraphicsDevice; import java.awt.GraphicsDevice;
@ -65,7 +66,7 @@ import sig.utils.ImageUtils;
import sig.utils.SoundUtils; import sig.utils.SoundUtils;
public class MyRobot{ public class MyRobot{
Robot MYROBOT; static Robot MYROBOT;
Color SCREEN[][]; Color SCREEN[][];
static SongData SONGS[]; static SongData SONGS[];
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","みくみくにしてあげる♪","メルト","モノクロ∞ブルースカイ","ゆめゆめ","1/6 -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","砂の惑星","テオ","初音ミクの消失","秘密警察","妄想スケッチ","リンちゃんなう!","ローリンガール","ロキ","ロミオとシンデレラ","エンヴィキャットウォーク","骸骨楽団とリリア","サイハテ","ジグソーパズル","千本桜","ピアノ×フォルテ×スキャンダル","Blackjack","ぽっぴっぽー","裏表ラバーズ","Sadistic.Music∞Factory","デンパラダイム","二次元ドリームフィーバー","ネガポジ*コンティニューズ","初音ミクの激唱","ワールズエンド・ダンスホール","ココロ","システマティック・ラヴ","Knife","二息歩行","PIANOGIRL","夢喰い白黒バク"}; 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","みくみくにしてあげる♪","メルト","モノクロ∞ブルースカイ","ゆめゆめ","1/6 -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","砂の惑星","テオ","初音ミクの消失","秘密警察","妄想スケッチ","リンちゃんなう!","ローリンガール","ロキ","ロミオとシンデレラ","エンヴィキャットウォーク","骸骨楽団とリリア","サイハテ","ジグソーパズル","千本桜","ピアノ×フォルテ×スキャンダル","Blackjack","ぽっぴっぽー","裏表ラバーズ","Sadistic.Music∞Factory","デンパラダイム","二次元ドリームフィーバー","ネガポジ*コンティニューズ","初音ミクの激唱","ワールズエンド・ダンスホール","ココロ","システマティック・ラヴ","Knife","二息歩行","PIANOGIRL","夢喰い白黒バク"};
@ -93,7 +94,7 @@ public class MyRobot{
static JTextField title; static JTextField title;
final int WIDTH = 200; final int WIDTH = 200;
final int HEIGHT = 5; final int HEIGHT = 5;
static DrawPanel p; public static DrawPanel p;
static int currentSong = 0; static int currentSong = 0;
static SongData selectedSong = null; static SongData selectedSong = null;
static String difficulty = "H"; //H=Hard EX=Extreme EXEX=Extra Extreme static String difficulty = "H"; //H=Hard EX=Extreme EXEX=Extra Extreme
@ -606,7 +607,7 @@ public class MyRobot{
System.out.println(" Passed ("+(System.currentTimeMillis()-startTime)+"ms)!"); System.out.println(" Passed ("+(System.currentTimeMillis()-startTime)+"ms)!");
} }
boolean isOnSongSelect() { public static boolean isOnSongSelect() {
Color c = new Color(MYROBOT.createScreenCapture(new Rectangle(1255,824,20,20)).getRGB(10, 10)); Color c = new Color(MYROBOT.createScreenCapture(new Rectangle(1255,824,20,20)).getRGB(10, 10));
return c.getRed()==43 && c.getGreen()==88 && c.getBlue()==213; return c.getRed()==43 && c.getGreen()==88 && c.getBlue()==213;
} }

@ -1,3 +1,4 @@
package sig;
public class Result { public class Result {
String songName; String songName;

@ -1,3 +1,4 @@
package sig;
import java.awt.Color; import java.awt.Color;
import sig.utils.FileUtils; import sig.utils.FileUtils;

@ -1,3 +1,4 @@
package sig;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;

@ -6,13 +6,12 @@ import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import sig.MyRobot;
import sig.sigIRC;
public class TextUtils { public class TextUtils {
public static Rectangle2D calculateStringBoundsFont(String msg, Font font) { public static Rectangle2D calculateStringBoundsFont(String msg, Font font) {
FontRenderContext frc = sigIRC.panel.getFontMetrics(font).getFontRenderContext(); FontRenderContext frc = MyRobot.p.getFontMetrics(font).getFontRenderContext();
return font.getStringBounds(msg, frc); return font.getStringBounds(msg, frc);
} }

Loading…
Cancel
Save