parent
f8f6cabf06
commit
4d76f9db12
@ -1,3 +1,10 @@ |
|||||||
WIDTH 546 |
LAST_HEIGHT 48 |
||||||
HEIGHT 384 |
WIDTH 1071 |
||||||
BACKGROUND -10092442 |
HEIGHT 765 |
||||||
|
BACKGROUND -6697729 |
||||||
|
LAST_TEXT -6723841 |
||||||
|
LAST_FONT Serif.italic |
||||||
|
LAST_FONTSIZE 32 |
||||||
|
LAST_BACKGROUND -16776961 |
||||||
|
LAST_WIDTH 200 |
||||||
|
LAST_DELAY 10000 |
||||||
|
@ -0,0 +1,186 @@ |
|||||||
|
package sig; |
||||||
|
|
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Font; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.util.HashMap; |
||||||
|
|
||||||
|
public class Display { |
||||||
|
Color backgroundCol=Color.BLUE; |
||||||
|
Color textCol=Color.WHITE; |
||||||
|
Font font=new Font("Batang",Font.PLAIN,32); |
||||||
|
int fontSize=32; |
||||||
|
int x; |
||||||
|
int y; |
||||||
|
int width=200; |
||||||
|
int height=48; |
||||||
|
int delay=10000; |
||||||
|
String[] labels; |
||||||
|
String currentText; |
||||||
|
int cycle=0; |
||||||
|
boolean deleted=false; |
||||||
|
Display() { |
||||||
|
HashMap<String,String> config = MyRobot.p.configData; |
||||||
|
if (config.containsKey("LAST_BACKGROUND")) { |
||||||
|
try { |
||||||
|
backgroundCol=new Color(Integer.parseInt(config.get("LAST_BACKGROUND"))); |
||||||
|
} catch (NumberFormatException e) { |
||||||
|
backgroundCol=Color.BLUE; |
||||||
|
} |
||||||
|
} |
||||||
|
if (config.containsKey("LAST_TEXT")) { |
||||||
|
try { |
||||||
|
textCol=new Color(Integer.parseInt(config.get("LAST_TEXT"))); |
||||||
|
} catch (NumberFormatException e) { |
||||||
|
textCol=Color.WHITE; |
||||||
|
} |
||||||
|
} |
||||||
|
if (config.containsKey("LAST_WIDTH")) { |
||||||
|
try { |
||||||
|
width=Integer.parseInt(config.get("LAST_WIDTH")); |
||||||
|
} catch (NumberFormatException e) { |
||||||
|
width=200; |
||||||
|
} |
||||||
|
} |
||||||
|
if (config.containsKey("LAST_HEIGHT")) { |
||||||
|
try { |
||||||
|
height=Integer.parseInt(config.get("LAST_HEIGHT")); |
||||||
|
} catch (NumberFormatException e) { |
||||||
|
height=48; |
||||||
|
} |
||||||
|
} |
||||||
|
x=0; |
||||||
|
y=0; |
||||||
|
if (config.containsKey("LAST_DELAY")) { |
||||||
|
try { |
||||||
|
delay=Integer.parseInt(config.get("LAST_DELAY")); |
||||||
|
} catch (NumberFormatException e) { |
||||||
|
delay=10000; |
||||||
|
} |
||||||
|
} |
||||||
|
cycle=0; |
||||||
|
if (config.containsKey("LAST_FONTSIZE")) { |
||||||
|
try { |
||||||
|
fontSize=Integer.parseInt(config.get("LAST_FONTSIZE")); |
||||||
|
} catch (NumberFormatException e) { |
||||||
|
fontSize=32; |
||||||
|
} |
||||||
|
} |
||||||
|
if (config.containsKey("LAST_FONT")) { |
||||||
|
try { |
||||||
|
font = new Font(config.get("LAST_FONT"),Font.PLAIN,fontSize); |
||||||
|
} catch (NumberFormatException e) { |
||||||
|
font = new Font("Batang",Font.PLAIN,fontSize); |
||||||
|
} |
||||||
|
} |
||||||
|
labels = new String[]{"Add a label!"}; |
||||||
|
currentText=interpretLabel(labels[cycle]); |
||||||
|
Thread t = new Thread() { |
||||||
|
public void run() { |
||||||
|
try { |
||||||
|
while (!deleted) { |
||||||
|
AdvanceCycle(); |
||||||
|
MyRobot.p.repaint(); |
||||||
|
Thread.sleep(delay); |
||||||
|
} |
||||||
|
} catch (InterruptedException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void AdvanceCycle() { |
||||||
|
cycle=(cycle+1)%labels.length; |
||||||
|
currentText=interpretLabel(labels[cycle]); |
||||||
|
} |
||||||
|
}; |
||||||
|
t.start(); |
||||||
|
} |
||||||
|
|
||||||
|
public void draw(Graphics g) { |
||||||
|
g.setColor(backgroundCol); |
||||||
|
g.fill3DRect(x, y, width, height, true); |
||||||
|
g.setColor(textCol); |
||||||
|
g.setFont(font); |
||||||
|
g.drawString(currentText,x,y+fontSize); |
||||||
|
} |
||||||
|
|
||||||
|
private String interpretLabel(String string){ |
||||||
|
DrawCanvas data = MyRobot.p; |
||||||
|
try { |
||||||
|
switch (string) { |
||||||
|
case "Best Play":{ |
||||||
|
if (data.bestPlayTime>System.currentTimeMillis()-10000) { |
||||||
|
return "New Record!"; |
||||||
|
} else { |
||||||
|
return ((data.bestPlay!=null)?data.bestPlay.display():""); |
||||||
|
} |
||||||
|
} |
||||||
|
case "Overall Rating":{ |
||||||
|
if (data.ratingTime>System.currentTimeMillis()-10000) { |
||||||
|
return "Rating up! "+data.lastRating+" -> "+data.overallrating; |
||||||
|
} else { |
||||||
|
return Integer.toString(data.overallrating); |
||||||
|
} |
||||||
|
} |
||||||
|
case "Song Difficulty":{ |
||||||
|
return data.difficultyRating + " - " + fullNameDifficulty(data.difficulty); |
||||||
|
} |
||||||
|
case "Song Title (Japanese)":{ |
||||||
|
return data.songname + " by "+data.artist; |
||||||
|
} |
||||||
|
case "Song Title (Romanized)":{ |
||||||
|
return ((data.romanizedname.length()>0)?data.romanizedname:data.englishname) + " by "+data.artist; |
||||||
|
} |
||||||
|
case "Song Title (Japanese+Romanized)":{ |
||||||
|
return (data.songname + " - " + ((data.romanizedname.length()>0)?data.romanizedname:data.englishname)) + " by "+data.artist; |
||||||
|
} |
||||||
|
case "Song Title (English)":{ |
||||||
|
return data.englishname + " by "+data.artist; |
||||||
|
} |
||||||
|
case "Song Title (Japanese+Romanized+ENG)":{ |
||||||
|
return (data.songname + " - " + ((data.romanizedname.length()>0)?(data.romanizedname.equalsIgnoreCase(data.englishname))?data.romanizedname:data.romanizedname+" ("+data.englishname+")":data.englishname)) + " by "+data.artist; |
||||||
|
} |
||||||
|
case "Play Count":{ |
||||||
|
return Integer.toString(data.plays)+" play"+((data.plays!=1)?"s":""); |
||||||
|
} |
||||||
|
case "Pass/Play Count":{ |
||||||
|
return Integer.toString(data.passes) + "/" + Integer.toString(data.plays)+" play"+((data.plays!=1)?"s":""); |
||||||
|
} |
||||||
|
case "Pass/Play Count (+%)":{ |
||||||
|
return (data.passes)+"/"+(data.plays)+" play"+((data.plays!=1)?"s":"")+" "+"("+((int)(Math.floor(((float)data.passes)/data.plays*100)))+"% pass rate)"; |
||||||
|
} |
||||||
|
case "FC Count":{ |
||||||
|
return data.fcCount +" FC"+(data.fcCount==1?"":"s"); |
||||||
|
} |
||||||
|
case "FC Count (+%)":{ |
||||||
|
return data.fcCount +" FC"+(data.fcCount==1?"":"s")+" "+((int)(Math.floor(((float)data.fcCount)/data.plays*100)))+"% FC rate"; |
||||||
|
} |
||||||
|
default:{ |
||||||
|
return string; |
||||||
|
} |
||||||
|
} |
||||||
|
} catch(NullPointerException e) { |
||||||
|
return string; |
||||||
|
} |
||||||
|
} |
||||||
|
private String fullNameDifficulty(String difficulty) { |
||||||
|
switch (difficulty) { |
||||||
|
case "E":{ |
||||||
|
return "Easy"; |
||||||
|
} |
||||||
|
case "N":{ |
||||||
|
return "Normal"; |
||||||
|
} |
||||||
|
case "H":{ |
||||||
|
return "Hard"; |
||||||
|
} |
||||||
|
case "EX":{ |
||||||
|
return "Extreme"; |
||||||
|
} |
||||||
|
case "EXEX":{ |
||||||
|
return "Extra Extreme"; |
||||||
|
} |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue