diff --git a/sigIRCv2.jar b/sigIRCv2.jar index e93d5e9..5e2200c 100644 Binary files a/sigIRCv2.jar and b/sigIRCv2.jar differ diff --git a/src/sig/Emoticon.java b/src/sig/Emoticon.java index 3cb0172..4f01edb 100644 --- a/src/sig/Emoticon.java +++ b/src/sig/Emoticon.java @@ -1,4 +1,5 @@ package sig; +import java.awt.Font; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -12,6 +13,7 @@ public class Emoticon { private BufferedImage image=null; private String emotename=null; private String spacefiller=""; + private String spacefillersmall=""; public Emoticon(String emoteName, URL onlinePath) { try { @@ -29,7 +31,8 @@ public class Emoticon { System.out.println("Saved to "+file.getName()+"."); emotename = emoteName; } - spacefiller = GetSpaceLength(); + spacefiller = GetSpaceLength(sigIRC.panel.programFont); + spacefillersmall = GetSpaceLength(sigIRC.panel.userFont); //System.out.println("Space size for "+emotename+" is "+spacefiller.length()); } catch (IOException e) { e.printStackTrace(); @@ -46,23 +49,24 @@ public class Emoticon { image = ImageIO.read(file); emotename = emoteName; } - spacefiller = GetSpaceLength(); + spacefiller = GetSpaceLength(sigIRC.panel.programFont); + spacefillersmall = GetSpaceLength(sigIRC.panel.userFont); //System.out.println("Space size for "+emotename+" is "+spacefiller.length()); } catch (IOException e) { e.printStackTrace(); } } - private String GetSpaceLength() { + private String GetSpaceLength(Font f) { StringBuilder spaces = new StringBuilder(); - while (SpaceFilledIsSmallerThanImageWidth(spaces)) { + while (SpaceFilledIsSmallerThanImageWidth(spaces,f)) { spaces.append(" "); } return spaces.toString(); } - public boolean SpaceFilledIsSmallerThanImageWidth(StringBuilder spaces) { - return TextUtils.calculateStringBoundsFont(spaces.toString(), sigIRC.panel.programFont).getWidth()=bounds.getX() && x<=bounds.getX()+bounds.getWidth() && - y>=(int)bounds.getY()-Module.IMG_DRAGBAR.getHeight() && - y<=(int)bounds.getY(); + return x>=position.getX() && x<=position.getX()+position.getWidth() && + y>=(int)position.getY()-Module.IMG_DRAGBAR.getHeight() && + y<=(int)position.getY(); } public void mousePressed(MouseEvent ev) { @@ -101,9 +102,9 @@ public class Module { sigIRC.panel.repaint(getDrawBounds().getBounds()); int mouseX = sigIRC.panel.lastMouseX+(int)dragOffset.getX(); int mouseY = sigIRC.panel.lastMouseY+(int)dragOffset.getY(); - int oldX = (int)bounds.getX(); - int oldY = (int)bounds.getY(); - bounds = new Rectangle(mouseX, mouseY,(int)bounds.getWidth(),(int)bounds.getHeight()); + int oldX = (int)position.getX(); + int oldY = (int)position.getY(); + position = new Rectangle(mouseX, mouseY,(int)position.getWidth(),(int)position.getHeight()); //System.out.println(sigIRC.panel.lastMouseX+","+sigIRC.panel.lastMouseY); ModuleDragEvent(oldX,oldY,mouseX,mouseY); } @@ -117,6 +118,10 @@ public class Module { }*/ } + public Rectangle2D getPosition() { + return position; + } + public void run() { } @@ -131,16 +136,16 @@ public class Module { private void drawModuleHeader(Graphics g) { g.drawImage(Module.IMG_DRAGBAR, - (int)bounds.getX()+2, - (int)bounds.getY()-Module.IMG_DRAGBAR.getHeight(), - (int)bounds.getWidth()-4, + (int)position.getX()+2, + (int)position.getY()-Module.IMG_DRAGBAR.getHeight(), + (int)position.getWidth()-4, Module.IMG_DRAGBAR.getHeight(), sigIRC.panel); - DrawUtils.drawTextFont(g, sigIRC.panel.smallFont, (int)bounds.getX(), (int)bounds.getY()-titleHeight/2+4, Color.BLACK, this.name); + DrawUtils.drawTextFont(g, sigIRC.panel.smallFont, (int)position.getX(), (int)position.getY()-titleHeight/2+4, Color.BLACK, this.name); } private Rectangle2D getDrawBounds() { - Rectangle2D drawBounds = new Rectangle((int)bounds.getX(),(int)bounds.getY()-titleHeight+3,(int)bounds.getWidth(),(int)bounds.getHeight()+titleHeight); + Rectangle2D drawBounds = new Rectangle((int)position.getX(),(int)position.getY()-titleHeight+3,(int)position.getWidth(),(int)position.getHeight()+titleHeight); return drawBounds; } diff --git a/src/sig/MyPanel.java b/src/sig/MyPanel.java index 077e54b..55998aa 100644 --- a/src/sig/MyPanel.java +++ b/src/sig/MyPanel.java @@ -28,6 +28,9 @@ import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; +import sig.modules.ChatLogModule; +import sig.modules.ChatLog.ChatLogMessage; + public class MyPanel extends JPanel implements MouseListener, ActionListener, MouseWheelListener, KeyListener, ComponentListener, WindowListener{ //List messages = new ArrayList(); final public static Font programFont = new Font(sigIRC.messageFont,0,24); @@ -93,6 +96,11 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo for (Module m : sigIRC.modules) { m.draw(g); } + for (int i=0;i displayMessage = new ArrayList(); + final static public int MESSAGE_SPACING = 24; + final static public int BORDER_SPACING = 8; + final static public Color SHADOW_COL = new Color(35,35,35,255); + int usernameWidth = 0; + boolean active=true; + + public ChatLogMessage(String rawMessage) { + this.refModule = ChatLogModule.chatlogmodule; + this.rawMessage = rawMessage; + this.position = new Point(0,(int)refModule.getPosition().getHeight()-MESSAGE_SPACING); + WrapText(); + for (ChatLogMessage clm : this.refModule.messageHistory) { + clm.position.setLocation( + clm.position.getX(), + clm.position.getY()-messageDisplaySize.getY()); + //System.out.println(clm.rawMessage+": "+clm.position); + } + this.position.setLocation(this.position.getX(), this.position.getY()-messageDisplaySize.getY()+ChatLogModule.chatlogmodule.scrolllog_yoffset); + //System.out.println(displayMessage); + DetectUsername(displayMessage); + if (this.username!=null) { + displayMessage.set(0,GetMessage(displayMessage.get(0))); + usernameWidth = (int)TextUtils.calculateStringBoundsFont(this.username, sigIRC.panel.userFont).getWidth(); + } + for (int i=0;i0) { + String word = basemsg.substring(marker+1, space); + //System.out.println("Word is '"+word+"'"); + sigIRC.emoticons.addAll(sigIRC.emoticon_queue); + sigIRC.emoticon_queue.clear(); + for (Emoticon e : sigIRC.emoticons) { + //System.out.println("Checking for emoticon "+e.getEmoteName()); + try { + if (e.getEmoteName().equals(word)) { + if (e instanceof SubEmoticon) { + SubEmoticon se = (SubEmoticon)e; + if (!se.canUserUseEmoticon(username)) { + //System.out.println("User "+username+" is not subscribed to "+se.channelName+"'s channel!"); + break; + } + } + //System.out.println(" Found one!"); + basemsg = TextUtils.replaceFirst(basemsg, e.getEmoteName(), e.getSmallSpaceFiller()); + GenerateEmoticon(marker+1, ypos, basemsg, e); + space = basemsg.indexOf(" ", marker+1); + break; + } + } catch (NullPointerException ex) { + ex.printStackTrace(); + } + } + marker=space; + } else { + break; + } + } + //textMaxWidth = (int)TextUtils.calculateStringBoundsFont(basemsg, sigIRC.panel.programFont).getWidth(); + //textMaxHeight = Math.max(textMaxHeight,(int)TextUtils.calculateStringBoundsFont(basemsg, sigIRC.panel.programFont).getHeight()); + return basemsg; + } + + private void GenerateEmoticon(int textpos, int ypos, String basemsg, Emoticon e) { + String cutstring = basemsg.substring(0, textpos); + double width = TextUtils.calculateStringBoundsFont(cutstring, sigIRC.panel.userFont).getWidth(); + //System.out.println("Width of '"+cutstring+"' is "+width); + sigIRC.createEmoticon(e, this, (int)(width), ypos+16); + //textMaxHeight = Math.max(textMaxHeight, e.getImage().getHeight()); + //textMaxWidth = (int)(width + e.getImage().getWidth()+1); + } + + private String GetMessage(String msg) { + String basemsg = " "+msg.substring(msg.indexOf(":")+2, msg.length())+" "; + //basemsg = ConvertMessageSymbols(basemsg); + //basemsg = ReplaceMessageWithEmoticons(basemsg); + return basemsg.replaceFirst(" ", "").substring(0,basemsg.length()-1); + } + + private void DetectUsername(List messages) { + if (messages.size()>0) { + String username = GetUsername(messages.get(0)); + if (username!=null) { + this.username = username; + } + } + } + + private Color GetUserNameColor(String username) { + Random r = new Random(); + r.setSeed(username.hashCode()); + int randomnumb = r.nextInt(3); + Color col; + switch (randomnumb) { + case 0:{ + col=new Color(255,r.nextInt(128)+64,r.nextInt(128)+64,255); + }break; + case 1:{ + col=new Color(r.nextInt(128)+64,255,r.nextInt(128)+64,255); + }break; + case 2:{ + col=new Color(r.nextInt(128)+64,r.nextInt(128)+64,255,255); + }break; + default:{ + col=Color.GREEN; + } + } + return col; + } + + private String GetUsername(String msg) { + if (msg.contains(":")) { + return msg.substring(0,msg.indexOf(":")); + } else { + return null; + } + } + + private void WrapText() { + String rawmessage = rawMessage; + int textWidth = (int)TextUtils.calculateStringBoundsFont(rawmessage, sigIRC.panel.userFont).getWidth(); + int maxWidth = (int)refModule.getPosition().getWidth()-BORDER_SPACING; + do { + rawmessage = BreakTextAtNextSection(rawmessage,maxWidth); + textWidth = (int)TextUtils.calculateStringBoundsFont(rawmessage, sigIRC.panel.userFont).getWidth(); + } while (textWidth>maxWidth); + if (rawmessage.length()>0) { + displayMessage.add(rawmessage); + } + messageDisplaySize = new Point((int)(refModule.getPosition().getWidth()-BORDER_SPACING),(int)(displayMessage.size()*MESSAGE_SPACING)); + //System.out.println(displayMessage+": "+messageDisplaySize); + } + + private String BreakTextAtNextSection(String msg, int maxWidth) { + int marker = 1; + int textWidth = (int)TextUtils.calculateStringBoundsFont(msg.substring(0, marker), sigIRC.panel.userFont).getWidth(); + while (textWidth=ChatLogModule.messageHistoryCount) { + ChatLogModule.chatlogmodule.messageHistory.remove(0).cleanup(); + } + ChatLogModule.chatlogmodule.messageHistory.add(new ChatLogMessage(s)); + } + } + + public void cleanup() { + active=false; + } + + public boolean isVisible() { + return (refModule.getPosition().getY()+position.getY()+MESSAGE_SPACING)>refModule.getPosition().getY() && + (refModule.getPosition().getY()+position.getY()+messageDisplaySize.getY())0) { + String word = basemsg.substring(marker+1, space); + //System.out.println("Word is '"+word+"'"); + sigIRC.emoticons.addAll(sigIRC.emoticon_queue); + sigIRC.emoticon_queue.clear(); + for (Emoticon e : sigIRC.emoticons) { + //System.out.println("Checking for emoticon "+e.getEmoteName()); + try { + if (e.getEmoteName().equals(word)) { + if (e instanceof SubEmoticon) { + SubEmoticon se = (SubEmoticon)e; + if (!se.canUserUseEmoticon(username)) { + //System.out.println("User "+username+" is not subscribed to "+se.channelName+"'s channel!"); + break; + } + } + //System.out.println(" Found one!"); + basemsg = TextUtils.replaceFirst(basemsg, e.getEmoteName(), e.getSpaceFiller()); + GenerateEmoticon(marker+1, basemsg, e); + space = basemsg.indexOf(" ", marker+1); + break; + } + } catch (NullPointerException ex) { + ex.printStackTrace(); + } + } + marker=space; + } else { + break; + } + } + textMaxWidth = (int)TextUtils.calculateStringBoundsFont(basemsg, sigIRC.panel.programFont).getWidth(); + textMaxHeight = Math.max(textMaxHeight,(int)TextUtils.calculateStringBoundsFont(basemsg, sigIRC.panel.programFont).getHeight()); + return basemsg; + } + + private void GenerateEmoticon(int pos, String basemsg, Emoticon e) { + String cutstring = basemsg.substring(0, pos); + double width = TextUtils.calculateStringBoundsFont(cutstring, sigIRC.panel.programFont).getWidth(); + //System.out.println("Width of '"+cutstring+"' is "+width); + sigIRC.createEmoticon(e, this, (int)(width), 0); + textMaxHeight = Math.max(textMaxHeight, e.getImage().getHeight()); + //textMaxWidth = (int)(width + e.getImage().getWidth()+1); + }*/ +} diff --git a/src/sig/modules/ChatLog/ChatLogTwitchEmote.java b/src/sig/modules/ChatLog/ChatLogTwitchEmote.java new file mode 100644 index 0000000..39af1eb --- /dev/null +++ b/src/sig/modules/ChatLog/ChatLogTwitchEmote.java @@ -0,0 +1,60 @@ +package sig.modules.ChatLog; + +import java.awt.Graphics; + +import javax.swing.SwingUtilities; + +import sig.Emoticon; +import sig.ScrollingText; +import sig.sigIRC; + +public class ChatLogTwitchEmote { + Emoticon emote; + int x=0; //X Offset + int y=0; //Y Offset + ChatLogMessage text; + + public ChatLogTwitchEmote(Emoticon emote, ChatLogMessage textref, int x, int y) { + this.emote=emote; + this.x=x; + this.y=y+24-emote.getImage().getHeight(); + this.text = textref; + } + + public boolean run() { + //this.x-=paint.TEXTSCROLLSPD; + /*if (textRefIsVisible()) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + sigIRC.panel.repaint( + Math.max(x,0), + Math.max(y, 0), + Math.min(sigIRC.panel.getWidth()-x,emote.getImage().getWidth()), + Math.min(sigIRC.panel.getHeight()-y,emote.getImage().getHeight())); + } + }); + }*/ + if (text==null || !text.active) { + return false; + } else { + return true; + } + } + + public void draw(Graphics g) { + if (WithinBounds((int)(text.position.getX()+x), (int)(text.position.getY()+y), emote.getImage().getWidth(), emote.getImage().getHeight())) { + g.drawImage(emote.getImage(), (int)(text.refModule.getPosition().getX()+text.position.getX()+x), (int)(text.refModule.getPosition().getY()+text.position.getY()+y), sigIRC.panel); + } + } + + private boolean WithinBounds(double x, double y, double w, double h) { + if (x0 && y0) { + return true; + } + return false; + } + + public boolean textRefIsVisible() { + return text.isVisible(); + } +} diff --git a/src/sig/modules/ChatLogModule.java b/src/sig/modules/ChatLogModule.java new file mode 100644 index 0000000..f09571e --- /dev/null +++ b/src/sig/modules/ChatLogModule.java @@ -0,0 +1,182 @@ +package sig.modules; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.KeyEvent; +import java.awt.event.MouseWheelEvent; +import java.awt.geom.Rectangle2D; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.ConcurrentModificationException; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.SwingUtilities; + +import sig.Module; +import sig.sigIRC; +import sig.modules.ChatLog.ChatLogMessage; +import sig.utils.FileUtils; + +public class ChatLogModule extends Module{ + public static int messageHistoryCount = 50; + public List messageHistory = new ArrayList(); + int delay = 150; + boolean initialized=false; + public static ChatLogModule chatlogmodule; + public int scrolllog_yoffset = 0; + + public ChatLogModule(Rectangle2D bounds, String moduleName) { + super(bounds, moduleName); + //Initialize(); + chatlogmodule = this; + } + + private void Initialize() { + messageHistoryCount = sigIRC.chatlogMessageHistory; + Calendar cal = Calendar.getInstance(); + String logFileLoc = sigIRC.BASEDIR+"sigIRC/logs/log_"+(cal.get(Calendar.MONTH)+1)+"_"+cal.get(Calendar.DAY_OF_MONTH)+"_"+cal.get(Calendar.YEAR)+".txt"; + File todaysLogFile = new File(logFileLoc); + if (todaysLogFile.exists()) { + String[] logContents = FileUtils.readFromFile(logFileLoc); + if (logContents.length>messageHistoryCount) { + logContents = Arrays.copyOfRange(logContents, logContents.length-messageHistoryCount-1, logContents.length); + } + ChatLogMessage.importMessages(logContents); + } + } + + public void run() { + super.run(); + if (delay>0) { + delay--; + } else + if (!initialized) + { + Initialize(); + initialized=true; + } + for (int i=0; i0) { + if (HighestMessageIsVisible()) { + return; + } + } + if (scrolllog_yoffset+scrollAmt>0) { + scrolllog_yoffset+=scrollAmt; + moveAllMessages(scrollAmt); + //System.out.println("Moving all messages by "+(-(ev.getWheelRotation()*scrollMult))); + } else + { + //System.out.println("Cannot move beyond lower bound. Moving all messages by -"+(scrolllog_yoffset)+"."); + moveAllMessages(-scrolllog_yoffset); + scrolllog_yoffset=0; + } + } + } + + private boolean HighestMessageIsVisible() { + if (messageHistory.size()>0) { + ChatLogMessage clm = messageHistory.get(0); + return clm.isVisible(); + } + return true; + } + + public void moveAllMessages(int yAmt) { + for (int i=0;i=position.getX() && + mouseX<=position.getX()+position.getWidth() && + mouseY>=position.getX() && + mouseY<=position.getX()+position.getHeight(); + } + + + public void keypressed(KeyEvent ev) { + int key = ev.getKeyCode(); + int scroll = 0; + if (key==KeyEvent.VK_PAGE_UP) { + scroll=8; + } else + if (key==KeyEvent.VK_PAGE_DOWN) { + scroll=-8; + } + if (key==KeyEvent.VK_HOME) { + scroll=Math.abs(GetHighestMessagePosition()); + } + if (key==KeyEvent.VK_END) { + moveAllMessages(-scrolllog_yoffset); + scrolllog_yoffset=0; + return; + } + if (scroll>0) { + if (HighestMessageIsVisible()) { + return; + } + } + if (scrolllog_yoffset+scroll>0) { + scrolllog_yoffset+=scroll; + moveAllMessages(scroll); + //System.out.println("Moving all messages by "+(-(ev.getWheelRotation()*scrollMult))); + } else + { + //System.out.println("Cannot move beyond lower bound. Moving all messages by -"+(scrolllog_yoffset)+"."); + moveAllMessages(-scrolllog_yoffset); + scrolllog_yoffset=0; + } + } + + private int GetHighestMessagePosition() { + if (messageHistory.size()>0) { + ChatLogMessage clm = messageHistory.get(0); + return (int)clm.position.getY(); + } + return 0; + } +} diff --git a/src/sig/modules/TouhouMotherModule.java b/src/sig/modules/TouhouMotherModule.java index 966425e..ec95074 100644 --- a/src/sig/modules/TouhouMotherModule.java +++ b/src/sig/modules/TouhouMotherModule.java @@ -121,8 +121,8 @@ public class TouhouMotherModule extends Module implements ActionListener{ } public void ApplyConfigWindowProperties() { - sigIRC.touhoumothermodule_X=(int)bounds.getX(); - sigIRC.touhoumothermodule_Y=(int)bounds.getY(); + sigIRC.touhoumothermodule_X=(int)position.getX(); + sigIRC.touhoumothermodule_Y=(int)position.getY(); sigIRC.config.setInteger("TOUHOUMOTHER_module_X", sigIRC.touhoumothermodule_X); sigIRC.config.setInteger("TOUHOUMOTHER_module_Y", sigIRC.touhoumothermodule_Y); } @@ -133,7 +133,7 @@ public class TouhouMotherModule extends Module implements ActionListener{ if (currentBoss!=null) { DrawBossAndPlayerInfo(g); } else { - DrawUtils.drawOutlineText(g, sigIRC.panel.programFont, (int)bounds.getX()+4, (int)bounds.getY()+4+16, 1, Color.WHITE, new Color(30,0,86,255), + DrawUtils.drawOutlineText(g, sigIRC.panel.programFont, (int)position.getX()+4, (int)position.getY()+4+16, 1, Color.WHITE, new Color(30,0,86,255), DataProperty.getDataPropertyBasedOnID(data_display_id).getDisplayName()); DrawSortedHealthbarsBasedOnDataProperty(g, DataProperty.getDataPropertyBasedOnID(data_display_id), 0, -64); } @@ -144,24 +144,24 @@ public class TouhouMotherModule extends Module implements ActionListener{ } public void DrawBossAndPlayerInfo(Graphics g) { - g.drawImage(bossImage, (int)bounds.getX()+4, (int)bounds.getY()+4, sigIRC.panel); - DrawUtils.drawOutlineText(g, sigIRC.panel.programFont, Math.min(bossImage.getWidth()+4,160)+(int)bounds.getX()+4, (int)bounds.getY()+4+16, 1, Color.WHITE, new Color(30,0,86,255), + g.drawImage(bossImage, (int)position.getX()+4, (int)position.getY()+4, sigIRC.panel); + DrawUtils.drawOutlineText(g, sigIRC.panel.programFont, Math.min(bossImage.getWidth()+4,160)+(int)position.getX()+4, (int)position.getY()+4+16, 1, Color.WHITE, new Color(30,0,86,255), currentBoss.getName()); - DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, Math.min(bossImage.getWidth()+4,160)+(int)bounds.getX()+4, (int)bounds.getY()+4+48, 1, Color.WHITE, new Color(30,0,86,255), + DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, Math.min(bossImage.getWidth()+4,160)+(int)position.getX()+4, (int)position.getY()+4+48, 1, Color.WHITE, new Color(30,0,86,255), real_bossHP+" / "+bossMaxHP +" ("+Math.round(((real_bossHP/(double)bossMaxHP)*100))+"%)"); DrawUtils.drawHealthbar(g, new Rectangle( - Math.min(bossImage.getWidth()+4,160)+(int)bounds.getX()+4, - (int)bounds.getY()+4+20, + Math.min(bossImage.getWidth()+4,160)+(int)position.getX()+4, + (int)position.getY()+4+20, (int)TextUtils.calculateStringBoundsFont(bossMaxHP+" / "+bossMaxHP +" ("+Math.round((1d*100))+"%", sigIRC.panel.userFont).getWidth(), 8 ), real_bossHP/(double)bossMaxHP, ChooseHealthbarColor(real_bossHP/(double)bossMaxHP)); - DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, Math.min(bossImage.getWidth()+4,160)+(int)bounds.getX()+16, (int)bounds.getY()+4+68, 1, Color.WHITE, new Color(30,0,86,255), + DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, Math.min(bossImage.getWidth()+4,160)+(int)position.getX()+16, (int)position.getY()+4+68, 1, Color.WHITE, new Color(30,0,86,255), TextUtils.convertSecondsToTimeFormat(secondsCount)); int record = TimeRecord.getRecord(currentBoss.getID()); if (record!=TimeRecord.ERROR_VALUE) { - DrawUtils.drawOutlineText(g, sigIRC.panel.smallFont, Math.min(bossImage.getWidth()+4,160)+(int)bounds.getX()+ + DrawUtils.drawOutlineText(g, sigIRC.panel.smallFont, Math.min(bossImage.getWidth()+4,160)+(int)position.getX()+ TextUtils.calculateStringBoundsFont(TextUtils.convertSecondsToTimeFormat(secondsCount), sigIRC.panel.userFont).getWidth()+20, - (int)bounds.getY()+4+72, 1, Color.WHITE, new Color(30,0,86,255), + (int)position.getY()+4+72, 1, Color.WHITE, new Color(30,0,86,255), "RECORD "+TextUtils.convertSecondsToTimeFormat(record)); } DrawSortedHealthbarsBasedOnDataProperty(g, DataProperty.CURRENTDAMAGE, 0, 0); @@ -175,18 +175,18 @@ public class TouhouMotherModule extends Module implements ActionListener{ int totaldmg = calculateDataPropertyTotalValue(property); for (int i=0;i0) { - DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, Math.min(((bossImage!=null)?bossImage.getWidth():0)+4,160)+(int)bounds.getX()+4-Math.min(50, (bossImage!=null)?bossImage.getWidth():0)+x, (int)bounds.getY()+4+96+pos+y, 1, Color.WHITE, new Color(30,0,86,255), + DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, Math.min(((bossImage!=null)?bossImage.getWidth():0)+4,160)+(int)position.getX()+4-Math.min(50, (bossImage!=null)?bossImage.getWidth():0)+x, (int)position.getY()+4+96+pos+y, 1, Color.WHITE, new Color(30,0,86,255), characterDatabase[sorteddmg[i]].getName()); DrawUtils.drawHealthbar(g, new Rectangle( - Math.min(((bossImage!=null)?bossImage.getWidth():0)+4,160)+(int)bounds.getX()+4+Math.max(0, 50-((bossImage!=null)?bossImage.getWidth():0))+x, - (int)bounds.getY()+4+86+pos+y, + Math.min(((bossImage!=null)?bossImage.getWidth():0)+4,160)+(int)position.getX()+4+Math.max(0, 50-((bossImage!=null)?bossImage.getWidth():0))+x, + (int)position.getY()+4+86+pos+y, 96, 10 ) , (double)characterDatabase[sorteddmg[i]].getDataProperty(property)/maxdmg, characterDatabase[sorteddmg[i]].getColor()); DecimalFormat df = new DecimalFormat("0.0"); - DrawUtils.drawOutlineText(g, sigIRC.panel.smallFont, Math.min((bossImage!=null)?bossImage.getWidth():0+4,160)+(int)bounds.getX()+4+Math.max(0, 50-((bossImage!=null)?bossImage.getWidth():0))+108+x, (int)bounds.getY()+4+96+pos+y, 1, Color.WHITE, new Color(30,0,86,255), + DrawUtils.drawOutlineText(g, sigIRC.panel.smallFont, Math.min((bossImage!=null)?bossImage.getWidth():0+4,160)+(int)position.getX()+4+Math.max(0, 50-((bossImage!=null)?bossImage.getWidth():0))+108+x, (int)position.getY()+4+96+pos+y, 1, Color.WHITE, new Color(30,0,86,255), characterDatabase[sorteddmg[i]].getDataProperty(property)+" "+"("+df.format(((((double)characterDatabase[sorteddmg[i]].getDataProperty(property)/totaldmg))*100))+"%)"); pos+=16; } @@ -507,19 +507,19 @@ public class TouhouMotherModule extends Module implements ActionListener{ private void DefineButton() { updateButton = new UpdateButton(this, //56x20 pixels new File(sigIRC.BASEDIR+"update.png"), - (int)bounds.getX()+320-56,(int)bounds.getY()+sigIRC.panel.getHeight()/2-20); + (int)position.getX()+320-56,(int)position.getY()+sigIRC.panel.getHeight()/2-20); killButton = new KillButton(this, new File(sigIRC.BASEDIR+"kill.png"), - (int)bounds.getX(),(int)bounds.getY()+sigIRC.panel.getHeight()/2-20); + (int)position.getX(),(int)position.getY()+sigIRC.panel.getHeight()/2-20); swapButton = new SwapButton(this, new File(sigIRC.BASEDIR+"swap.png"), - (int)bounds.getX(),(int)bounds.getY()+sigIRC.panel.getHeight()/2-40); + (int)position.getX(),(int)position.getY()+sigIRC.panel.getHeight()/2-40); moduleButtons.add(updateButton); moduleButtons.add(killButton); moduleButtons.add(swapButton); } public Rectangle2D getBounds() { - return bounds; + return position; } } diff --git a/src/sig/modules/TwitchModule.java b/src/sig/modules/TwitchModule.java index 75151a5..63d4573 100644 --- a/src/sig/modules/TwitchModule.java +++ b/src/sig/modules/TwitchModule.java @@ -168,8 +168,8 @@ public class TwitchModule extends Module{ } public void ApplyConfigWindowProperties() { - sigIRC.twitchmodule_X=(int)bounds.getX(); - sigIRC.twitchmodule_Y=(int)bounds.getY(); + sigIRC.twitchmodule_X=(int)position.getX(); + sigIRC.twitchmodule_Y=(int)position.getY(); sigIRC.config.setInteger("TWITCH_module_X", sigIRC.twitchmodule_X); sigIRC.config.setInteger("TWITCH_module_Y", sigIRC.twitchmodule_Y); } @@ -428,9 +428,9 @@ public class TwitchModule extends Module{ private void DrawStatisticsBar(Graphics g) { g.setColor(new Color(25,25,25)); - int xoffset = (int)bounds.getX()+4; - int yoffset = (int)(bounds.getY()+follower_img.getHeight()+sigIRC.twitchmodule_newfollowerImgLogoSize); - g.fillPolygon(new int[]{(int)bounds.getX(),(int)(bounds.getX()+bounds.getWidth()),(int)(bounds.getX()+bounds.getWidth()),(int)bounds.getX()}, + int xoffset = (int)position.getX()+4; + int yoffset = (int)(position.getY()+follower_img.getHeight()+sigIRC.twitchmodule_newfollowerImgLogoSize); + g.fillPolygon(new int[]{(int)position.getX(),(int)(position.getX()+position.getWidth()),(int)(position.getX()+position.getWidth()),(int)position.getX()}, new int[]{yoffset-4,yoffset-4,yoffset+16,yoffset+16}, 4); if (currentlyPlaying!=null && currentlyPlaying.length()>0) { @@ -476,25 +476,25 @@ public class TwitchModule extends Module{ //System.out.println(yAlteration); //g.drawImage(follower_img, (int)bounds.getX()+xAlteration, (int)bounds.getY()+yAlteration, sigIRC.panel); //g.drawImage(follower_img, (int)bounds.getX(), (int)bounds.getY(), , , sigIRC.panel) - g.drawImage(follower_img, (int)bounds.getX(), (int)bounds.getY()+canvasYOffset, (int)bounds.getX()+follower_img.getWidth()+canvasXOffset, (int)bounds.getY()+follower_img.getHeight(), + g.drawImage(follower_img, (int)position.getX(), (int)position.getY()+canvasYOffset, (int)position.getX()+follower_img.getWidth()+canvasXOffset, (int)position.getY()+follower_img.getHeight(), -xAlteration, 0, follower_img.getWidth(), follower_img.getHeight()-yAlteration, sigIRC.panel); Rectangle2D usernameTextsize = TextUtils.calculateStringBoundsFont(announcedFollowerUser.getDisplayName(), sigIRC.panel.programFont); - int textY = (int)bounds.getY()+sigIRC.twitchmodule_followerText_Y+yAlteration; - int textX = (int)bounds.getX()+sigIRC.twitchmodule_followerText_centerX+xAlteration; - if (textYbounds.getX()) { - DrawUtils.drawCenteredText(g, sigIRC.panel.programFont, (int)bounds.getX()+sigIRC.twitchmodule_followerText_centerX+xAlteration, (int)bounds.getY()+sigIRC.twitchmodule_followerText_Y+yAlteration, Color.BLACK, announcedFollowerUser.getDisplayName()); + int textY = (int)position.getY()+sigIRC.twitchmodule_followerText_Y+yAlteration; + int textX = (int)position.getX()+sigIRC.twitchmodule_followerText_centerX+xAlteration; + if (textYposition.getX()) { + DrawUtils.drawCenteredText(g, sigIRC.panel.programFont, (int)position.getX()+sigIRC.twitchmodule_followerText_centerX+xAlteration, (int)position.getY()+sigIRC.twitchmodule_followerText_Y+yAlteration, Color.BLACK, announcedFollowerUser.getDisplayName()); } if (announcedFollowerUser.getBio()!=null && !announcedFollowerUser.getBio().equalsIgnoreCase("null")) { if (followerUserLogo!=null) { final int image_size = sigIRC.twitchmodule_newfollowerImgLogoSize; - int img_startx = (int)(bounds.getX()+bounds.getWidth()-ticksPassed*3-(image_size+4)); - int img_starty = (int)(bounds.getY()+follower_img.getHeight()+2-image_size/2); + int img_startx = (int)(position.getX()+position.getWidth()-ticksPassed*3-(image_size+4)); + int img_starty = (int)(position.getY()+follower_img.getHeight()+2-image_size/2); //g.setColor(Color.BLACK); //g.drawRect(img_startx, img_starty, image_size, image_size); g.drawImage(followerUserLogo, img_startx, img_starty, img_startx+image_size, img_starty+image_size, 0, 0, followerUserLogo.getWidth(), followerUserLogo.getHeight(), TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerImgBackgroundColor), sigIRC.panel); } if (announcedFollowerUser.getBio()!=null && announcedFollowerUser.getBio().length()>0) { - DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, bounds.getX()+bounds.getWidth()-ticksPassed*3, bounds.getY()+follower_img.getHeight()+2+8, 2, TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerTextColor), TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerShadowTextColor), announcedFollowerUser.getBio()); + DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, position.getX()+position.getWidth()-ticksPassed*3, position.getY()+follower_img.getHeight()+2+8, 2, TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerTextColor), TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerShadowTextColor), announcedFollowerUser.getBio()); } } } diff --git a/src/sig/sigIRC.java b/src/sig/sigIRC.java index e46aecd..1b81f2a 100644 --- a/src/sig/sigIRC.java +++ b/src/sig/sigIRC.java @@ -13,8 +13,11 @@ import com.mb3364.twitch.api.handlers.StreamResponseHandler; import com.mb3364.twitch.api.models.Channel; import com.mb3364.twitch.api.models.Stream; +import sig.modules.ChatLogModule; import sig.modules.TouhouMotherModule; import sig.modules.TwitchModule; +import sig.modules.ChatLog.ChatLogMessage; +import sig.modules.ChatLog.ChatLogTwitchEmote; import sig.utils.FileUtils; import sig.utils.TextUtils; @@ -52,6 +55,7 @@ public class sigIRC{ public static List emoticons = new ArrayList(); public static List emoticon_queue = new ArrayList(); public static List twitchemoticons = new ArrayList(); + public static List chatlogtwitchemoticons = new ArrayList(); public static List customsounds = new ArrayList(); public static List modules = new ArrayList(); static UpdateEvent updater = new UpdateEvent(); @@ -84,8 +88,9 @@ public class sigIRC{ static String messageFont="Gill Sans Ultra Bold Condensed"; static String usernameFont="GillSansMTStd-Book"; static String touhoumotherConsoleFont="Agency FB Bold"; - static boolean touhoumothermodule_enabled=true; + static boolean touhoumothermodule_enabled=false; static boolean twitchmodule_enabled=true; + static boolean chatlogmodule_enabled=true; static boolean downloadsComplete=false; static boolean hardwareAcceleration=true; static boolean playedoAuthSoundOnce=false; @@ -101,6 +106,11 @@ public class sigIRC{ public static int touhoumothermodule_height=312; public static int touhoumothermodule_X=0; public static int touhoumothermodule_Y=312; + public static int chatlogmodule_width=320; + public static int chatlogmodule_height=312; + public static int chatlogmodule_X=0; + public static int chatlogmodule_Y=312; + public static int chatlogMessageHistory=50; public static String twitchmodule_newfollowerImgBackgroundColor="90,90,90"; public static String twitchmodule_newfollowerShadowTextColor="26,90,150"; public static String twitchmodule_newfollowerTextColor="255,255,255"; @@ -136,8 +146,9 @@ public class sigIRC{ messageFont = config.getProperty("messageFont","Gill Sans Ultra Bold Condensed"); usernameFont = config.getProperty("usernameFont","Gill Sans"); touhoumotherConsoleFont = config.getProperty("touhoumotherConsoleFont","Agency FB Bold"); - touhoumothermodule_enabled = config.getBoolean("Module_touhoumother_Enabled",true); + touhoumothermodule_enabled = config.getBoolean("Module_touhoumother_Enabled",false); twitchmodule_enabled = config.getBoolean("Module_twitch_Enabled",true); + chatlogmodule_enabled = config.getBoolean("Module_chatlog_Enabled",true); twitchmodule_width = config.getInteger("TWITCH_module_width",500); twitchmodule_height = config.getInteger("TWITCH_module_height",200); twitchmodule_follower_img = config.getProperty("TWITCH_module_follower_img","sigIRC/glaceon_follower.png"); @@ -155,6 +166,11 @@ public class sigIRC{ touhoumothermodule_Y = config.getInteger("TOUHOUMOTHER_module_Y",312); touhoumothermodule_width = config.getInteger("TOUHOUMOTHER_module_width",320); touhoumothermodule_height = config.getInteger("TOUHOUMOTHER_module_height",312); + chatlogmodule_X = config.getInteger("CHATLOG_module_X",0); + chatlogmodule_Y = config.getInteger("CHATLOG_module_Y",312); + chatlogmodule_width = config.getInteger("CHATLOG_module_width",320); + chatlogmodule_height = config.getInteger("CHATLOG_module_height",312); + chatlogMessageHistory = config.getInteger("CHATLOG_module_MessageHistory",50); hardwareAcceleration = config.getBoolean("hardware_acceleration",true); lastSubEmoteUpdate = config.getInteger("lastSubEmote_APIUpdate",Calendar.getInstance().get(Calendar.DAY_OF_YEAR)); manager.setClientId("o4c2x0l3e82scgar4hpxg6m5dfjbem"); @@ -228,6 +244,7 @@ public class sigIRC{ private static void InitializeModules() { try { Module.IMG_DRAGBAR = ImageIO.read(new File(sigIRC.BASEDIR+"drag_bar.png")); + Module.MSG_SEPARATOR = ImageIO.read(new File(sigIRC.BASEDIR+"sigIRC/message_separator.png")); } catch (IOException e) { e.printStackTrace(); } @@ -243,6 +260,12 @@ public class sigIRC{ "Twitch" )); } + if (chatlogmodule_enabled) { + modules.add(new ChatLogModule( + new Rectangle(chatlogmodule_X,chatlogmodule_Y,chatlogmodule_width,chatlogmodule_height), + "Chat Log" + )); + } } private static void InitializeCustomSounds() { @@ -529,4 +552,8 @@ public class sigIRC{ public static void createEmoticon(Emoticon emote, ScrollingText textref, int x, int y) { twitchemoticons.add(new TwitchEmote(emote,textref,x,y)); } + + public static void createEmoticon(Emoticon emote, ChatLogMessage textref, int x, int y) { + chatlogtwitchemoticons.add(new ChatLogTwitchEmote(emote,textref,x,y)); + } } diff --git a/src/sig/utils/FileUtils.java b/src/sig/utils/FileUtils.java index c7ff7f3..6e79c78 100644 --- a/src/sig/utils/FileUtils.java +++ b/src/sig/utils/FileUtils.java @@ -19,6 +19,8 @@ import java.util.List; import org.json.JSONException; import org.json.JSONObject; +import sig.modules.ChatLog.ChatLogMessage; + public class FileUtils { public static String[] readFromFile(String filename) { File file = new File(filename); @@ -112,6 +114,7 @@ public class FileUtils { } catch (IOException e) { e.printStackTrace(); } + ChatLogMessage.importMessages(message); } public static void writetoFile(String[] data, String filename) {