Improved Display behaviors.
This commit is contained in:
parent
6e1572cdd9
commit
f6be822371
Binary file not shown.
@ -1,11 +1,11 @@
|
||||
DISPLAYDATA -16776961*-13369549*100*Gungsuh*600*90*5000*Song Title (Japanese+Romanized)*176*136*~-16776961*-13369549*24*Gulim*400*40*300*Overall Rating|Song Title (Romanized)|FC Count*176*240*~-16776961*-13369549*24*Gulim*400*40*300*Best Play*0*0*
|
||||
LAST_HEIGHT 40
|
||||
DISPLAYDATA -16776961*-13369549*94*Microsoft YaHei UI Bold*600*150*5000*Song Title (Japanese+Romanized)*176*80*~-16776961*-13369549*24*Gulim*400*40*300*Overall Rating|Song Title (Romanized)|FC Count*176*240*
|
||||
LAST_HEIGHT 150
|
||||
WIDTH 1127
|
||||
HEIGHT 765
|
||||
HEIGHT 732
|
||||
BACKGROUND -6697729
|
||||
LAST_TEXT -13369549
|
||||
LAST_FONT Gulim
|
||||
LAST_FONTSIZE 24
|
||||
LAST_FONT Microsoft YaHei UI Bold
|
||||
LAST_FONTSIZE 94
|
||||
LAST_BACKGROUND -16776961
|
||||
LAST_WIDTH 400
|
||||
LAST_DELAY 300
|
||||
LAST_WIDTH 600
|
||||
LAST_DELAY 5000
|
||||
|
@ -12,13 +12,14 @@ import sig.utils.TextUtils;
|
||||
public class Display {
|
||||
Color backgroundCol=Color.BLUE;
|
||||
Color textCol=Color.WHITE;
|
||||
Font font=new Font("Batang",Font.PLAIN,32);
|
||||
Font font=new Font("Dialog.bold",Font.PLAIN,32);
|
||||
int fontSize=32;
|
||||
Font modifiedfont=font;
|
||||
int x;
|
||||
int y;
|
||||
int width=200;
|
||||
int height=48;
|
||||
int fontHeight=0;
|
||||
int delay=10000;
|
||||
long nextUpdateTime = System.currentTimeMillis();
|
||||
boolean forceUpdate=false;
|
||||
@ -137,16 +138,18 @@ public class Display {
|
||||
}
|
||||
|
||||
public void updateFont() {
|
||||
//modifiedfont
|
||||
int currentSize=fontSize;
|
||||
modifiedfont = font;
|
||||
Rectangle2D bounds = TextUtils.calculateStringBoundsFont(currentText, font);
|
||||
fontHeight = (int)bounds.getHeight();
|
||||
while (currentSize>1&&bounds.getWidth()>width) {
|
||||
currentSize-=2;
|
||||
if (currentSize<=1) {break;}
|
||||
modifiedfont = new Font(font.getFontName(),Font.PLAIN,currentSize);
|
||||
bounds = TextUtils.calculateStringBoundsFont(currentText, modifiedfont);
|
||||
fontHeight = (int)bounds.getHeight();
|
||||
}
|
||||
forceUpdate=true;
|
||||
}
|
||||
|
||||
public void draw(Graphics g) {
|
||||
@ -154,7 +157,7 @@ public class Display {
|
||||
g.fill3DRect(x, y, width, height, true);
|
||||
g.setColor(textCol);
|
||||
g.setFont(modifiedfont);
|
||||
g.drawString(currentText,x,y+modifiedfont.getSize()+((height-modifiedfont.getSize())/2));
|
||||
g.drawString(currentText,x,y+height/2+fontHeight/4);
|
||||
}
|
||||
|
||||
public String getSaveString() {
|
||||
@ -205,19 +208,30 @@ public class Display {
|
||||
return data.difficultyRating + " - " + fullNameDifficulty(data.difficulty);
|
||||
}
|
||||
case "Song Title (Japanese)":{
|
||||
return data.songname + " by "+data.artist;
|
||||
return data.songname;
|
||||
}
|
||||
case "Song Title (Romanized)":{
|
||||
return ((data.romanizedname.length()>0)?data.romanizedname:data.englishname) + " by "+data.artist;
|
||||
return ((data.romanizedname.length()>0)?data.romanizedname:data.englishname);
|
||||
}
|
||||
case "Song Title (Japanese+Romanized)":{
|
||||
return (data.songname + " - " + ((data.romanizedname.length()>0)?data.romanizedname:data.englishname)) + " by "+data.artist;
|
||||
if (data.songname.equalsIgnoreCase(((data.romanizedname.length()>0)?data.romanizedname:data.englishname))) {
|
||||
return data.songname;
|
||||
} else {
|
||||
return (data.songname + " - " + ((data.romanizedname.length()>0)?data.romanizedname:data.englishname));
|
||||
}
|
||||
}
|
||||
case "Song Title (English)":{
|
||||
return data.englishname + " by "+data.artist;
|
||||
return data.englishname;
|
||||
}
|
||||
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;
|
||||
if (data.songname.equalsIgnoreCase(((data.romanizedname.length()>0)?data.romanizedname:data.englishname))) {
|
||||
return data.songname;
|
||||
} else {
|
||||
return (data.songname + " - " + ((data.romanizedname.length()>0)?(data.romanizedname.equalsIgnoreCase(data.englishname))?data.romanizedname:data.romanizedname+" ("+data.englishname+")":data.englishname));
|
||||
}
|
||||
}
|
||||
case "Song Artist":{
|
||||
return "Artist: "+data.artist;
|
||||
}
|
||||
case "Play Count":{
|
||||
if (data.plays>0) {
|
||||
|
@ -67,7 +67,8 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
|
||||
"Pass/Play Count",
|
||||
"Pass/Play Count (+%)",
|
||||
"FC Count",
|
||||
"FC Count (+%)"
|
||||
"FC Count (+%)",
|
||||
"Song Artist",
|
||||
};
|
||||
|
||||
DisplayManager() throws IOException {
|
||||
@ -79,7 +80,7 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
|
||||
|
||||
for (int i=0;i<tempFontList.size();i++) {
|
||||
//System.out.println(tempFontList.get(i));
|
||||
if (!tempFontList.get(i).canDisplay(12479) || tempFontList.get(i).getFontName().equals("Dialog.plain")) {
|
||||
if (!tempFontList.get(i).canDisplay(12479) || !tempFontList.get(i).canDisplay(12540) || tempFontList.get(i).getFontName().equals("Dialog.plain")) {
|
||||
tempFontList.remove(i--);
|
||||
}
|
||||
}
|
||||
@ -489,6 +490,7 @@ public class DisplayManager extends JPanel implements MouseListener,ListSelectio
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (selectedDisplay!=null) {
|
||||
selectedDisplay.font=new Font(((Font)fonts.getSelectedItem()).getFontName(),Font.PLAIN,selectedDisplay.fontSize);
|
||||
selectedDisplay.updateFont();
|
||||
MyRobot.p.repaint();
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
|
||||
static List<Display> displays = new ArrayList<Display>();
|
||||
public static Display selectedDisplay = null;
|
||||
public static Display draggedDisplay = null;
|
||||
public static Point initialDragPoint = null;
|
||||
DrawCanvas() throws FontFormatException, IOException {
|
||||
//loadConfig();
|
||||
addConfigButton = ImageIO.read(new File("addDisplay.png"));
|
||||
@ -380,70 +381,25 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
Point cursor = GetCursorPosition(e);
|
||||
switch (e.getButton()) {
|
||||
case MouseEvent.BUTTON3:{
|
||||
selectedDisplay=null;
|
||||
for (int i=0;i<displays.size();i++) {
|
||||
Display d = displays.get(i);
|
||||
if (cursor.x>=d.x&&
|
||||
cursor.x<=d.x+d.width&&
|
||||
cursor.y>=d.y&&
|
||||
cursor.y<=d.y+d.height) {
|
||||
selectedDisplay=d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DeleteDisplay();
|
||||
}break;
|
||||
case MouseEvent.BUTTON1:{
|
||||
//System.out.println(cursor+"/"+addConfigButton.getHeight());
|
||||
if (cursor.x>=getWidth()-addConfigButton.getWidth()&&
|
||||
cursor.x<=getWidth()&&
|
||||
cursor.y>=0&&
|
||||
cursor.y<=addConfigButton.getHeight()) {
|
||||
Display d = new Display();
|
||||
displays.add(d);
|
||||
selectedDisplay=d;
|
||||
DisplayManager.setupSettings(selectedDisplay);
|
||||
return;
|
||||
} else
|
||||
if (cursor.x>=getWidth()-addConfigButton.getWidth()&&
|
||||
cursor.x<=getWidth()&&
|
||||
cursor.y>=addConfigButton.getHeight()+1&&
|
||||
cursor.y<=addConfigButton.getHeight()+1+addConfigButton.getHeight()) {
|
||||
Color c = MyRobot.CP.getBackgroundColor();
|
||||
if (c!=null) {
|
||||
configData.put("BACKGROUND",Integer.toString(c.getRGB()));
|
||||
applyConfig();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Display previousDisplay = selectedDisplay;
|
||||
selectedDisplay=null;
|
||||
for (int i=0;i<displays.size();i++) {
|
||||
Display d = displays.get(i);
|
||||
if (cursor.x>=d.x&&
|
||||
cursor.x<=d.x+d.width&&
|
||||
cursor.y>=d.y&&
|
||||
cursor.y<=d.y+d.height) {
|
||||
selectedDisplay=d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedDisplay==null) {
|
||||
MyRobot.FRAME.setCursor(Cursor.getDefaultCursor());
|
||||
DisplayManager.f.setVisible(false);
|
||||
} else {
|
||||
MyRobot.FRAME.setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
||||
draggedDisplay=selectedDisplay;
|
||||
if (selectedDisplay.equals(previousDisplay)) {
|
||||
//System.out.println("Double click");
|
||||
DisplayManager.setupSettings(selectedDisplay);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
initialDragPoint=cursor;
|
||||
selectedDisplay=null;
|
||||
for (int i=0;i<displays.size();i++) {
|
||||
Display d = displays.get(i);
|
||||
if (cursor.x>=d.x&&
|
||||
cursor.x<=d.x+d.width&&
|
||||
cursor.y>=d.y&&
|
||||
cursor.y<=d.y+d.height) {
|
||||
selectedDisplay=d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedDisplay==null) {
|
||||
MyRobot.FRAME.setCursor(Cursor.getDefaultCursor());
|
||||
DisplayManager.f.setVisible(false);
|
||||
} else {
|
||||
MyRobot.FRAME.setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
||||
draggedDisplay=selectedDisplay;
|
||||
}
|
||||
}
|
||||
|
||||
@ -455,7 +411,55 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
Point cursor = GetCursorPosition(e);
|
||||
draggedDisplay=null;
|
||||
MyRobot.FRAME.setCursor(Cursor.getDefaultCursor());
|
||||
switch (e.getButton()) {
|
||||
case MouseEvent.BUTTON3:{
|
||||
selectedDisplay=null;
|
||||
for (int i=0;i<displays.size();i++) {
|
||||
Display d = displays.get(i);
|
||||
if (cursor.x>=d.x&&
|
||||
cursor.x<=d.x+d.width&&
|
||||
cursor.y>=d.y&&
|
||||
cursor.y<=d.y+d.height) {
|
||||
selectedDisplay=d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DeleteDisplay();
|
||||
}break;
|
||||
case MouseEvent.BUTTON1:{
|
||||
//System.out.println(cursor+"/"+addConfigButton.getHeight());
|
||||
if (cursor.x>=getWidth()-addConfigButton.getWidth()&&
|
||||
cursor.x<=getWidth()&&
|
||||
cursor.y>=0&&
|
||||
cursor.y<=addConfigButton.getHeight()) {
|
||||
Display d = new Display();
|
||||
displays.add(d);
|
||||
selectedDisplay=d;
|
||||
DisplayManager.setupSettings(selectedDisplay);
|
||||
return;
|
||||
} else
|
||||
if (cursor.x>=getWidth()-addConfigButton.getWidth()&&
|
||||
cursor.x<=getWidth()&&
|
||||
cursor.y>=addConfigButton.getHeight()+1&&
|
||||
cursor.y<=addConfigButton.getHeight()+1+addConfigButton.getHeight()) {
|
||||
Color c = MyRobot.CP.getBackgroundColor();
|
||||
if (c!=null) {
|
||||
configData.put("BACKGROUND",Integer.toString(c.getRGB()));
|
||||
applyConfig();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Display previousDisplay = selectedDisplay;
|
||||
if (selectedDisplay.equals(previousDisplay)) {
|
||||
//System.out.println("Double click");
|
||||
DisplayManager.setupSettings(selectedDisplay);
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -474,9 +478,19 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
if (draggedDisplay!=null) {
|
||||
Point cursor = GetCursorPosition(e);
|
||||
draggedDisplay.x=(int)(Math.floor((cursor.x-draggedDisplay.width/2)/8)*8);
|
||||
draggedDisplay.y=(int)(Math.floor((cursor.y-draggedDisplay.height/2)/8)*8);
|
||||
MyRobot.p.repaint();
|
||||
if (initialDragPoint!=null) {
|
||||
if ((Math.abs(cursor.x-initialDragPoint.x)>24||
|
||||
Math.abs(cursor.y-initialDragPoint.y)>24)) {
|
||||
draggedDisplay.x=(int)(Math.floor((cursor.x-draggedDisplay.width/2)/8)*8);
|
||||
draggedDisplay.y=(int)(Math.floor((cursor.y-draggedDisplay.height/2)/8)*8);
|
||||
MyRobot.p.repaint();
|
||||
initialDragPoint=null;
|
||||
}
|
||||
} else {
|
||||
draggedDisplay.x=(int)(Math.floor((cursor.x-draggedDisplay.width/2)/8)*8);
|
||||
draggedDisplay.y=(int)(Math.floor((cursor.y-draggedDisplay.height/2)/8)*8);
|
||||
MyRobot.p.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user