diff --git a/DivaBot/DivaBot.jar b/DivaBot/DivaBot.jar index 1212ee1..63bb319 100644 Binary files a/DivaBot/DivaBot.jar and b/DivaBot/DivaBot.jar differ diff --git a/DivaBot/config.txt b/DivaBot/config.txt index 9d836e7..8cb5640 100644 --- a/DivaBot/config.txt +++ b/DivaBot/config.txt @@ -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 diff --git a/DivaBot/src/sig/Display.java b/DivaBot/src/sig/Display.java index e269784..55c1da2 100644 --- a/DivaBot/src/sig/Display.java +++ b/DivaBot/src/sig/Display.java @@ -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) { diff --git a/DivaBot/src/sig/DisplayManager.java b/DivaBot/src/sig/DisplayManager.java index c191ad5..9559d83 100644 --- a/DivaBot/src/sig/DisplayManager.java +++ b/DivaBot/src/sig/DisplayManager.java @@ -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 displays = new ArrayList(); 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=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=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=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=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(); + } } }