Shortened display of "New Record!". Added miku fc icon.

secondmonitor
sigonasr2 4 years ago
parent ef0afa0292
commit da84bac38e
  1. 6
      DivaBot/config.txt
  2. 39
      DivaBot/src/sig/Display.java
  3. 19
      DivaBot/src/sig/DrawCanvas.java

@ -1,11 +1,11 @@
DISPLAYDATA -16765135*-10027060*48*Yu Gothic UI Bold*665*64*10000*Song Title (Japanese+Romanized)|Song Title (English)*80*16**~-16765135*-10027060*48*Yu Gothic UI Light*380*64*10000*Best Play*80*952**~-16765135*-10027060*48*Yu Gothic UI Light*380*64*10000*Overall Rating*560*952**~-16765135*-10027060*48*Yu Gothic UI Light*380*64*10000*Song Difficulty|Pass/Play Count (+%)|FC Count (+%)*1048*952**~-16765135*-10027060*16*Yu Gothic UI Semilight*245*14*10000*Song Artist*504*16*Artist: * DISPLAYDATA -16765135*-10027060*48*Yu Gothic UI Bold*665*64*10000*Song Title (Japanese+Romanized)|Song Title (English)*80*16**~-16765135*-10027060*48*Yu Gothic UI Light*380*64*10000*Best Play*80*952**~-16765135*-10027060*48*Yu Gothic UI Light*380*64*10000*Overall Rating*560*952**~-16765135*-10027060*48*Yu Gothic UI Light*380*64*10000*Song Difficulty|Pass/Play Count (+%)|FC Count (+%)*1048*952**~-16765135*-10027060*16*Yu Gothic UI Semilight*245*14*10000*Song Artist*504*16*Artist: *
LAST_HEIGHT 64 LAST_HEIGHT 128
WIDTH 1936 WIDTH 1936
HEIGHT 1096 HEIGHT 1096
BACKGROUND -16765135 BACKGROUND -16765135
LAST_TEXT -10027060 LAST_TEXT -10027060
LAST_FONT Yu Gothic UI Bold LAST_FONT Yu Gothic UI Light
LAST_FONTSIZE 48 LAST_FONTSIZE 48
LAST_BACKGROUND -16765135 LAST_BACKGROUND -16765135
LAST_WIDTH 665 LAST_WIDTH 380
LAST_DELAY 10000 LAST_DELAY 10000

@ -3,10 +3,13 @@ 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.Image;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.HashMap; import java.util.HashMap;
import sig.utils.ImageUtils;
import sig.utils.TextUtils; import sig.utils.TextUtils;
public class Display { public class Display {
@ -17,6 +20,7 @@ public class Display {
Font modifiedfont=font; Font modifiedfont=font;
int x; int x;
int y; int y;
int modDisplayX=0;
int width=200; int width=200;
int height=48; int height=48;
int fontHeight=0; int fontHeight=0;
@ -147,7 +151,13 @@ public class Display {
modifiedfont = font; modifiedfont = font;
Rectangle2D bounds = TextUtils.calculateStringBoundsFont(currentText, font); Rectangle2D bounds = TextUtils.calculateStringBoundsFont(currentText, font);
fontHeight = (int)bounds.getHeight(); fontHeight = (int)bounds.getHeight();
while (currentSize>1&&bounds.getWidth()>width) { if (labels[cycle].equalsIgnoreCase("Best Play")) {
BufferedImage scaledMiku=ImageUtils.toBufferedImage(DrawCanvas.mikuFC.getScaledInstance(-1, height, BufferedImage.SCALE_SMOOTH));
modDisplayX = width-scaledMiku.getWidth();
} else {
modDisplayX = width;
}
while (currentSize>1&&bounds.getWidth()>modDisplayX) {
currentSize-=2; currentSize-=2;
if (currentSize<=1) {break;} if (currentSize<=1) {break;}
modifiedfont = new Font(font.getFontName(),Font.PLAIN,currentSize); modifiedfont = new Font(font.getFontName(),Font.PLAIN,currentSize);
@ -162,8 +172,25 @@ public class Display {
g.fillRect(x, y, width, height); g.fillRect(x, y, width, height);
g.setColor(textCol); g.setColor(textCol);
g.setFont(modifiedfont); g.setFont(modifiedfont);
DrawCanvas data = MyRobot.p;
if (labels[cycle].equalsIgnoreCase("Best Play")) {
if (data.bestPlay!=null) {
if (data.bestPlay.safe+data.bestPlay.sad+data.bestPlay.worst==0) {
if (height>1) {
BufferedImage scaledMiku=ImageUtils.toBufferedImage(DrawCanvas.mikuFC.getScaledInstance(-1, height, BufferedImage.SCALE_SMOOTH));
g.drawImage(scaledMiku,x,y+height-scaledMiku.getHeight(),MyRobot.p);
}
g.drawString(currentText,x+width-modDisplayX,y+height/2+fontHeight/4);
} else {
g.drawString(currentText,x,y+height/2+fontHeight/4); g.drawString(currentText,x,y+height/2+fontHeight/4);
} }
} else {
g.drawString(currentText,x,y+height/2+fontHeight/4);
}
} else {
g.drawString(currentText,x,y+height/2+fontHeight/4);
}
}
public String getSaveString() { public String getSaveString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -197,11 +224,19 @@ public class Display {
try { try {
switch (string) { switch (string) {
case "Best Play":{ case "Best Play":{
if (data.bestPlayTime>System.currentTimeMillis()-10000) { if (data.bestPlayTime>System.currentTimeMillis()-5000) {
return "New Record!"; return "New Record!";
} else {
if (data.bestPlay!=null) {
if (data.bestPlay.safe+data.bestPlay.sad+data.bestPlay.worst==0) {
return header+data.bestPlay.display();
} else { } else {
return header+((data.bestPlay!=null)?data.bestPlay.display():"No plays"); return header+((data.bestPlay!=null)?data.bestPlay.display():"No plays");
} }
} else {
return header+"No plays";
}
}
} }
case "Overall Rating":{ case "Overall Rating":{
if (data.ratingTime>System.currentTimeMillis()-10000) { if (data.ratingTime>System.currentTimeMillis()-10000) {

@ -66,6 +66,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
Result bestPlay=null; Result bestPlay=null;
int overallrating = 0; int overallrating = 0;
BufferedImage addConfigButton,backgroundColorButton,reloadSongButton; BufferedImage addConfigButton,backgroundColorButton,reloadSongButton;
static BufferedImage mikuFC;
long ratingTime = System.currentTimeMillis()-10000; long ratingTime = System.currentTimeMillis()-10000;
long bestPlayTime = System.currentTimeMillis()-10000; long bestPlayTime = System.currentTimeMillis()-10000;
int lastRating = -1; int lastRating = -1;
@ -89,6 +90,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
addConfigButton = ImageIO.read(new File("addDisplay.png")); addConfigButton = ImageIO.read(new File("addDisplay.png"));
backgroundColorButton = ImageIO.read(new File("backgroundCol.png")); backgroundColorButton = ImageIO.read(new File("backgroundCol.png"));
reloadSongButton = ImageIO.read(new File("reloadSong.png")); reloadSongButton = ImageIO.read(new File("reloadSong.png"));
mikuFC = ImageIO.read(new File("mikufc.png"));
Thread t = new Thread() { Thread t = new Thread() {
public void run() { public void run() {
while (true) { while (true) {
@ -129,10 +131,6 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
t = new Thread() { t = new Thread() {
public void run() { public void run() {
try { try {
/*JSONObject obj = FileUtils.readJsonArrayFromUrl("http://45.33.13.215:4501/song/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")).getJSONObject(0);
romanizedname = obj.getString("romanized_name");
englishname = obj.getString("english_name");
artist = obj.getString("artist");*/
if (MyRobot.p.songname!=null) { if (MyRobot.p.songname!=null) {
SongInfo currentSong = SongInfo.getByTitle(MyRobot.p.songname); SongInfo currentSong = SongInfo.getByTitle(MyRobot.p.songname);
//FileUtils.writetoFile(new String[] {MyRobot.p.songname}, "testencode.txt"); //FileUtils.writetoFile(new String[] {MyRobot.p.songname}, "testencode.txt");
@ -164,19 +162,6 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
if (obj.has("fccount")) { if (obj.has("fccount")) {
fcCount = obj.getInt("fccount"); fcCount = obj.getInt("fccount");
} }
/*obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/rating/"+MyRobot.USERNAME);
lastRating = overallrating;
overallrating = (int)obj.getDouble("rating");
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"+((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 (bounds.getWidth()>1345) {
scrolling=true;
} else {
scrolling=false;
}
scrollX = 0;*/
MyRobot.p.repaint(); MyRobot.p.repaint();
MyRobot.p.refreshAllLabels(); MyRobot.p.refreshAllLabels();
} }

Loading…
Cancel
Save