Chat Log Module implemented. Scrolling w/ Mouse Wheel + Keys. Updated

config file with new keys.
dev
sigonasr2 7 years ago
parent 2b69dcda03
commit e4d37ab272
  1. BIN
      sigIRCv2.jar
  2. 20
      src/sig/Emoticon.java
  3. 33
      src/sig/Module.java
  4. 9
      src/sig/MyPanel.java
  5. 6
      src/sig/UpdateEvent.java
  6. 290
      src/sig/modules/ChatLog/ChatLogMessage.java
  7. 60
      src/sig/modules/ChatLog/ChatLogTwitchEmote.java
  8. 182
      src/sig/modules/ChatLogModule.java
  9. 38
      src/sig/modules/TouhouMotherModule.java
  10. 26
      src/sig/modules/TwitchModule.java
  11. 31
      src/sig/sigIRC.java
  12. 3
      src/sig/utils/FileUtils.java

Binary file not shown.

@ -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()<image.getWidth();
public boolean SpaceFilledIsSmallerThanImageWidth(StringBuilder spaces, Font font) {
return TextUtils.calculateStringBoundsFont(spaces.toString(), font).getWidth()<image.getWidth();
}
public String getEmoteName() {
@ -76,4 +80,8 @@ public class Emoticon {
public String getSpaceFiller() {
return spacefiller;
}
public String getSmallSpaceFiller() {
return spacefillersmall;
}
}

@ -18,10 +18,11 @@ import sig.utils.DrawUtils;
import sig.utils.TextUtils;
public class Module {
protected Rectangle2D bounds;
protected Rectangle2D position;
protected boolean enabled;
protected String name;
public static BufferedImage IMG_DRAGBAR;
public static BufferedImage MSG_SEPARATOR;
public static boolean inDragZone=false;
final protected int titleHeight;
@ -31,7 +32,7 @@ public class Module {
public static boolean DRAGGING=false;
public Module(Rectangle2D bounds, String moduleName) {
this.bounds = bounds;
this.position = bounds;
this.name = moduleName;
this.enabled=true;
@ -54,15 +55,15 @@ public class Module {
private void enableWindowDrag(int mouseX, int mouseY) {
if (!dragging && inDragBounds(mouseX,mouseY) && !DRAGGING) {
//Enable dragging.
dragOffset = new Point((int)bounds.getX() - mouseX,(int)bounds.getY()-mouseY);
dragOffset = new Point((int)position.getX() - mouseX,(int)position.getY()-mouseY);
dragging=DRAGGING=true;
}
}
public boolean inDragBounds(int x, int y) {
return x>=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;
}

@ -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<String> messages = new ArrayList<String>();
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<sigIRC.chatlogtwitchemoticons.size();i++) {
if (sigIRC.chatlogtwitchemoticons.get(i).textRefIsVisible()) {
sigIRC.chatlogtwitchemoticons.get(i).draw(g);
}
}
if (!sigIRC.overlayMode) {
sigIRC.button.draw(g);
}
@ -107,6 +115,7 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
TextRow row = TextRow.PickRandomTextRow(text.getUsername());
sigIRC.textobj.add(text);
row.updateRow(text);
//ChatLogMessage.importMessages(message);
}
@Override

@ -119,6 +119,12 @@ public class UpdateEvent implements ActionListener{
for (Module m : sigIRC.modules) {
m.moduleRun();
}
for (int i=0;i<sigIRC.chatlogtwitchemoticons.size();i++) {
boolean keep = sigIRC.chatlogtwitchemoticons.get(i).run();
if (!keep) {
sigIRC.chatlogtwitchemoticons.remove(i--);
}
}
}
private void ProcessTextRows() {

@ -0,0 +1,290 @@
package sig.modules.ChatLog;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.swing.SwingUtilities;
import sig.Emoticon;
import sig.Module;
import sig.SubEmoticon;
import sig.sigIRC;
import sig.modules.ChatLogModule;
import sig.utils.DrawUtils;
import sig.utils.TextUtils;
public class ChatLogMessage {
String rawMessage;
Point messageDisplaySize; //The amount of screen space (w,h) this message takes up.
public Point position;
ChatLogModule refModule;
String username;
List<String> displayMessage = new ArrayList<String>();
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;i<displayMessage.size();i++) {
displayMessage.set(i, ReplaceMessageWithEmoticons(displayMessage.get(i)+" ",i*MESSAGE_SPACING));
}
}
private String ReplaceMessageWithEmoticons(String basemsg, int ypos) {
int marker = basemsg.indexOf(" ");
while (marker<basemsg.length()) {
//Find a space.
int space = basemsg.indexOf(" ", marker+1);
if (space>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.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<String> 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<maxWidth) {
if (marker<msg.length()) {
int tempmarker = msg.indexOf(' ', marker);
if (tempmarker!=-1) {
textWidth = (int)TextUtils.calculateStringBoundsFont(msg.substring(0, tempmarker), sigIRC.panel.userFont).getWidth();
if (textWidth<maxWidth) {
marker = tempmarker+1;
}
//System.out.println(msg.substring(0, marker)+" | "+textWidth);
} else {
marker=msg.length();
break;
}
} else {
break;
}
}
String currentText = msg.substring(0, marker);
displayMessage.add(currentText);
return msg.substring(marker, msg.length());
}
public boolean run() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
sigIRC.panel.repaint(
(int)Math.max(refModule.getPosition().getX()+position.getX(),0),
(int)Math.max(refModule.getPosition().getY()+position.getY(),0),
(int)Math.min(sigIRC.panel.getWidth()-(refModule.getPosition().getX()+position.getX()+messageDisplaySize.getX()),messageDisplaySize.getX()),
(int)Math.min(sigIRC.panel.getHeight()-(refModule.getPosition().getY()+position.getY()+messageDisplaySize.getY()),messageDisplaySize.getY()));
}
});
//System.out.println(refModule.getPosition()+","+position);
return true;
}
public void draw(Graphics g) {
if (isVisible()) {
for (int i=0;i<displayMessage.size();i++) {
//System.out.println(displayMessage.get(i));
if (username!=null && i==0) {
DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, refModule.getPosition().getX()+position.getX(), refModule.getPosition().getY()+position.getY()+(i*MESSAGE_SPACING)+32, 2, GetUserNameColor(this.username), SHADOW_COL, this.username);
DrawUtils.drawTextFont(g, sigIRC.panel.userFont, refModule.getPosition().getX()+position.getX()+usernameWidth+2, refModule.getPosition().getY()+position.getY()+(i*MESSAGE_SPACING)+32, Color.BLACK, displayMessage.get(i));
} else {
DrawUtils.drawTextFont(g, sigIRC.panel.userFont, refModule.getPosition().getX()+position.getX(), refModule.getPosition().getY()+position.getY()+(i*MESSAGE_SPACING)+32, Color.BLACK, displayMessage.get(i));
}
}
g.drawImage(Module.MSG_SEPARATOR, (int)(refModule.getPosition().getX()+position.getX()+8), (int)(refModule.getPosition().getY()+position.getY()+messageDisplaySize.getY()+12), (int)(messageDisplaySize.getX()-8), 1, sigIRC.panel);
//g.drawLine((int)(refModule.getPosition().getX()+position.getX()+8), (int)(refModule.getPosition().getY()+position.getY()+messageDisplaySize.getY()+32), (int)(refModule.getPosition().getX()+position.getX()+messageDisplaySize.getX()-8), (int)(refModule.getPosition().getY()+position.getY()+messageDisplaySize.getY()+32));
}
}
public static void importMessages(String...logContents) {
for (String s : logContents) {
if (ChatLogModule.chatlogmodule.messageHistory.size()>=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())<refModule.getPosition().getY()+refModule.getPosition().getHeight()-16;
}
/*
private String ReplaceMessageWithEmoticons(String basemsg) {
int marker = basemsg.indexOf(" ");
while (marker<basemsg.length()) {
//Find a space.
int space = basemsg.indexOf(" ", marker+1);
if (space>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);
}*/
}

@ -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 (x<sigIRC.panel.getWidth() && x+w>0 && y<sigIRC.panel.getHeight() && y+h>0) {
return true;
}
return false;
}
public boolean textRefIsVisible() {
return text.isVisible();
}
}

@ -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<ChatLogMessage> messageHistory = new ArrayList<ChatLogMessage>();
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; i<messageHistory.size();i++) {
ChatLogMessage clm = messageHistory.get(i);
if (clm!=null) {
try {
clm.run();
} catch (ConcurrentModificationException e) {
e.printStackTrace();
}
}
}
}
public void draw(Graphics g) {
super.draw(g);
g.setColor(new Color(195,195,195,255));
g.fill3DRect((int)position.getX(), (int)position.getY(), (int)position.getWidth(), (int)position.getHeight(), true);
g.setColor(Color.BLACK);
for (int i=0; i<messageHistory.size();i++) {
ChatLogMessage clm = messageHistory.get(i);
if (clm!=null) {
try {
clm.draw(g);
} catch (ConcurrentModificationException e) {
e.printStackTrace();
}
}
}
}
public void mouseWheel(MouseWheelEvent ev) {
if (mouseInBounds(ev.getX(),ev.getY())) {
int scrollMult = 8;
int scrollAmt = -ev.getWheelRotation()*scrollMult;
if (scrollAmt>0) {
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<messageHistory.size();i++) {
ChatLogMessage clm = messageHistory.get(i);
if (clm!=null) {
try {
clm.position.setLocation(clm.position.getX(), clm.position.getY()+yAmt);
} catch (ConcurrentModificationException e) {
e.printStackTrace();
}
}
}
}
private boolean mouseInBounds(int mouseX, int mouseY) {
return mouseX>=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;
}
}

@ -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;i<sorteddmg.length;i++) {
if (sorteddmg[i]!=-1 && characterDatabase[sorteddmg[i]].getDataProperty(property)>0) {
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;
}
}

@ -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 (textY<bounds.getY()+bounds.getHeight() && textX+usernameTextsize.getWidth()>bounds.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 (textY<position.getY()+position.getHeight() && textX+usernameTextsize.getWidth()>position.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());
}
}
}

@ -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<Emoticon> emoticons = new ArrayList<Emoticon>();
public static List<Emoticon> emoticon_queue = new ArrayList<Emoticon>();
public static List<TwitchEmote> twitchemoticons = new ArrayList<TwitchEmote>();
public static List<ChatLogTwitchEmote> chatlogtwitchemoticons = new ArrayList<ChatLogTwitchEmote>();
public static List<CustomSound> customsounds = new ArrayList<CustomSound>();
public static List<Module> modules = new ArrayList<Module>();
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));
}
}

@ -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) {

Loading…
Cancel
Save