Continued work on fixing Scrolling Chat module. No luck yet.

dev
sigonasr2 7 years ago
parent e210299f7f
commit 824b8249d9
  1. 1
      .classpath
  2. BIN
      sigIRCv2.jar
  3. 53
      src/sig/ListenerPanel.java
  4. 53
      src/sig/Module.java
  5. 7
      src/sig/MyPanel.java
  6. 11
      src/sig/ScrollingText.java
  7. 6
      src/sig/TwitchEmote.java
  8. 21
      src/sig/modules/ChatLog/ChatLogMessage.java
  9. 9
      src/sig/modules/ChatLog/ChatLogTwitchEmote.java
  10. 55
      src/sig/modules/ChatLogModule.java
  11. 191
      src/sig/modules/ScrollingChatModule.java
  12. 18
      src/sig/sigIRC.java
  13. 1
      src/sig/windows/LoadingDialog.java
  14. 4
      src/sig/windows/ProgramWindow.java

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="lib"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/commons-io-2.5.jar"/> <classpathentry kind="lib" path="lib/commons-io-2.5.jar"/>
<classpathentry kind="lib" path="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/> <classpathentry kind="lib" path="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>

Binary file not shown.

@ -0,0 +1,53 @@
package sig;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import javax.swing.JPanel;
public class ListenerPanel extends JPanel implements MouseListener, MouseWheelListener{
Module mod;
public ListenerPanel(Module mod) {
this.addMouseListener(this);
this.addMouseWheelListener(this);
this.mod=mod;
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
this.mod.mouseWheelMoved(e);
}
@Override
public void mouseClicked(MouseEvent e) {
this.mod.mouseClicked(e);
}
@Override
public void mouseEntered(MouseEvent e) {
this.mod.mouseEntered(e);
}
@Override
public void mouseExited(MouseEvent e) {
this.mod.mouseExited(e);
}
@Override
public void mousePressed(MouseEvent e) {
this.mod.mousePressed(e);
}
@Override
public void mouseReleased(MouseEvent e) {
this.mod.mouseReleased(e);
}
}

@ -11,9 +11,7 @@ import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.event.WindowListener; import java.awt.event.WindowListener;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
@ -27,21 +25,21 @@ import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import sig.utils.DrawUtils; import sig.utils.DrawUtils;
import sig.utils.TextUtils; import sig.utils.TextUtils;
import sig.windows.ProgramWindow; import sig.windows.ProgramWindow;
public class Module extends JFrame implements MouseListener, MouseWheelListener, KeyListener, ComponentListener, WindowListener{ public class Module extends JFrame implements ComponentListener, WindowListener, KeyListener{
public JPanel panel; public ListenerPanel panel;
public Rectangle position; public Rectangle position;
protected boolean enabled; protected boolean enabled;
protected String name; protected String name;
public static BufferedImage IMG_DRAGBAR; public static BufferedImage IMG_DRAGBAR;
public static BufferedImage MSG_SEPARATOR; public static BufferedImage MSG_SEPARATOR;
public static boolean inDragZone=false; public static boolean inDragZone=false;
final public static int WINDOW_EXTRA_BORDER = 32; //Number of pixels that the border takes up (Reduces the size of the window)
final protected int titleHeight; final protected int titleHeight;
@ -58,18 +56,16 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
public Module(Rectangle bounds, String moduleName) { public Module(Rectangle bounds, String moduleName) {
this.addMouseListener(this);
this.addMouseWheelListener(this);
this.addKeyListener(this);
this.addComponentListener(this); this.addComponentListener(this);
this.addWindowListener(this); this.addWindowListener(this);
this.addKeyListener(this);
this.position = bounds; this.position = bounds;
this.name = moduleName; this.name = moduleName;
this.enabled=true; this.enabled=true;
this.setVisible(true); this.setVisible(true);
this.setTitle(moduleName); this.setTitle(moduleName);
panel = new JPanel(){ panel = new ListenerPanel(this){
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
draw(g); draw(g);
@ -79,10 +75,12 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
this.titleHeight = (int)TextUtils.calculateStringBoundsFont(this.name, sigIRC.userFont).getHeight(); this.titleHeight = (int)TextUtils.calculateStringBoundsFont(this.name, sigIRC.userFont).getHeight();
this.setSize((int)position.getWidth(), (int)position.getHeight()); this.setSize((int)position.getWidth(), (int)position.getHeight());
panel.setSize(this.getSize()); panel.setSize(this.getSize());
this.add(panel); this.add(panel);
//this.pack();
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleWithFixedDelay(()->{ scheduler.scheduleWithFixedDelay(()->{
@ -114,9 +112,6 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
} }
return val; return val;
} }
public void mousePressed(MouseEvent ev) {
}
public void ApplyConfigWindowProperties() { public void ApplyConfigWindowProperties() {
} }
@ -124,9 +119,6 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
public void SaveConfig() { public void SaveConfig() {
} }
public void mouseReleased(MouseEvent ev) {
}
protected void moduleRun() { protected void moduleRun() {
run(); run();
@ -147,16 +139,6 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
public void ModuleDragEvent(int oldX, int oldY, int newX, int newY) { public void ModuleDragEvent(int oldX, int oldY, int newX, int newY) {
} }
public void mouseWheel(MouseWheelEvent ev) {
}
public void keypressed(KeyEvent ev) {
}
public void keyreleased(KeyEvent ev) {
}
public void windowClosed(WindowEvent ev) { public void windowClosed(WindowEvent ev) {
@ -210,7 +192,7 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
} }
private void UpdatePosition(ComponentEvent e) { private void UpdatePosition(ComponentEvent e) {
position = new Rectangle((int)e.getComponent().getLocationOnScreen().getX(),(int)e.getComponent().getLocationOnScreen().getY(),e.getComponent().getWidth(),e.getComponent().getHeight()-16); position = new Rectangle((int)e.getComponent().getLocationOnScreen().getX(),(int)e.getComponent().getLocationOnScreen().getY(),e.getComponent().getWidth(),e.getComponent().getHeight());
//System.out.println(position); //System.out.println(position);
ApplyConfigWindowProperties(); ApplyConfigWindowProperties();
sigIRC.configNeedsUpdating = System.currentTimeMillis(); sigIRC.configNeedsUpdating = System.currentTimeMillis();
@ -226,46 +208,47 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override
public void keyTyped(KeyEvent e) { public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override public void mouseWheelMoved(MouseWheelEvent arg0) {
public void mouseWheelMoved(MouseWheelEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent e) {
}
} }

@ -30,6 +30,7 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import sig.modules.ChatLogModule; import sig.modules.ChatLogModule;
import sig.modules.ScrollingChatModule;
import sig.modules.ChatLog.ChatLogMessage; import sig.modules.ChatLog.ChatLogMessage;
import sig.utils.FileUtils; import sig.utils.FileUtils;
@ -51,8 +52,8 @@ public class MyPanel extends JPanel{
// Draw Text // Draw Text
//int counter=18; //int counter=18;
if (sigIRC.panel!=null) { if (sigIRC.panel!=null) {
lastMouseX = (int)(MouseInfo.getPointerInfo().getLocation().getX()-sigIRC.panel.getLocationOnScreen().getX()); lastMouseX = (int)(MouseInfo.getPointerInfo().getLocation().getX());
lastMouseY = (int)(MouseInfo.getPointerInfo().getLocation().getY()-sigIRC.panel.getLocationOnScreen().getY()); lastMouseY = (int)(MouseInfo.getPointerInfo().getLocation().getY());
//System.out.println("("+lastMouseX+","+lastMouseY+")"); //System.out.println("("+lastMouseX+","+lastMouseY+")");
} }
/*if (sigIRC.window!=null && sigIRC.window.getMousePosition(true)!=null && sigIRC.overlayMode) { /*if (sigIRC.window!=null && sigIRC.window.getMousePosition(true)!=null && sigIRC.overlayMode) {
@ -103,7 +104,7 @@ public class MyPanel extends JPanel{
} }
public void addMessage(String message, boolean playSound) { public void addMessage(String message, boolean playSound) {
ScrollingText text = new ScrollingText(message,this.getWidth(),(int)(Math.random()*128),playSound); ScrollingText text = new ScrollingText(message,ScrollingChatModule.module.getWidth(),(int)(Math.random()*128),playSound);
TextRow row = TextRow.PickRandomTextRow(text.getUsername()); TextRow row = TextRow.PickRandomTextRow(text.getUsername());
sigIRC.textobj.add(text); sigIRC.textobj.add(text);
row.updateRow(text); row.updateRow(text);

@ -20,6 +20,7 @@ import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import sig.modules.ScrollingChatModule;
import sig.utils.DrawUtils; import sig.utils.DrawUtils;
import sig.utils.FileUtils; import sig.utils.FileUtils;
import sig.utils.SoundUtils; import sig.utils.SoundUtils;
@ -180,7 +181,7 @@ public class ScrollingText {
} }
private boolean WithinBounds(double x, double y, double w, double h) { 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) { if (x<ScrollingChatModule.module.getWidth() && x+w>0 && y<ScrollingChatModule.module.getHeight() && y+h>0) {
return true; return true;
} }
return false; return false;
@ -188,28 +189,28 @@ public class ScrollingText {
public int FindLeftMostCornerInDisplay() { public int FindLeftMostCornerInDisplay() {
if (x-shadowSize>0) { if (x-shadowSize>0) {
return Math.min((int)x-shadowSize, sigIRC.panel.getWidth()); return Math.min((int)x-shadowSize, ScrollingChatModule.module.getWidth());
} else { } else {
return 0; return 0;
} }
} }
public int FindTopMostCornerInDisplay() { public int FindTopMostCornerInDisplay() {
if (y-shadowSize>0) { if (y-shadowSize>0) {
return Math.min((int)y-shadowSize, sigIRC.panel.getHeight()); return Math.min((int)y-shadowSize, ScrollingChatModule.module.getHeight());
} else { } else {
return 0; return 0;
} }
} }
public int FindRightMostCornerInDisplay() { public int FindRightMostCornerInDisplay() {
if (x+stringWidth+(int)sigIRC.BASESCROLLSPD+1+shadowSize+1>0) { if (x+stringWidth+(int)sigIRC.BASESCROLLSPD+1+shadowSize+1>0) {
return Math.min(Math.max(stringWidth,userstringWidth+8)+(int)sigIRC.BASESCROLLSPD+1+shadowSize+1, sigIRC.panel.getWidth()-(int)x); return Math.min(Math.max(stringWidth,userstringWidth+8)+(int)sigIRC.BASESCROLLSPD+1+shadowSize+1, ScrollingChatModule.module.getWidth()-(int)x);
} else { } else {
return 0; return 0;
} }
} }
public int FindBottomMostCornerInDisplay() { public int FindBottomMostCornerInDisplay() {
if (y+stringHeight+shadowSize>0) { if (y+stringHeight+shadowSize>0) {
return Math.min(stringHeight+shadowSize+4, sigIRC.panel.getHeight()-(int)y); return Math.min(stringHeight+shadowSize+4, ScrollingChatModule.module.getHeight()-(int)y);
} else { } else {
return 0; return 0;
} }

@ -3,6 +3,8 @@ import java.awt.Graphics;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import sig.modules.ScrollingChatModule;
public class TwitchEmote { public class TwitchEmote {
Emoticon emote; Emoticon emote;
int x=0; //X Offset int x=0; //X Offset
@ -38,7 +40,7 @@ public class TwitchEmote {
public void draw(Graphics g) { public void draw(Graphics g) {
if (WithinBounds((int)(text.getX()+x), (int)(text.getY()+y), emote.getImage().getWidth(), emote.getImage().getHeight())) { if (WithinBounds((int)(text.getX()+x), (int)(text.getY()+y), emote.getImage().getWidth(), emote.getImage().getHeight())) {
g.drawImage(emote.getImage(), (int)(text.getX()+x), (int)(text.getY()+y), sigIRC.panel); g.drawImage(emote.getImage(), (int)(text.getX()+x), (int)(text.getY()+y), ScrollingChatModule.module.panel);
} }
} }
@ -47,7 +49,7 @@ public class TwitchEmote {
} }
private boolean WithinBounds(double x, double y, double w, double h) { 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) { if (x<ScrollingChatModule.module.getWidth() && x+w>0 && y<ScrollingChatModule.module.getHeight() && y+h>0) {
return true; return true;
} }
return false; return false;

@ -25,7 +25,7 @@ public class ChatLogMessage {
String username; String username;
List<String> displayMessage = new ArrayList<String>(); List<String> displayMessage = new ArrayList<String>();
final static public int MESSAGE_SPACING = 24; final static public int MESSAGE_SPACING = 24;
final static public int BORDER_SPACING = 8; final static public int BORDER_SPACING = 16;
final static public Color SHADOW_COL = new Color(35,35,35,255); final static public Color SHADOW_COL = new Color(35,35,35,255);
int usernameWidth = 0; int usernameWidth = 0;
boolean active=true; boolean active=true;
@ -170,7 +170,7 @@ public class ChatLogMessage {
} }
private String BreakTextAtNextSection(String msg, int maxWidth) { private String BreakTextAtNextSection(String msg, int maxWidth) {
int marker = 1; int marker = msg.indexOf(' ');
int textWidth = (int)TextUtils.calculateStringBoundsFont(msg.substring(0, marker), sigIRC.userFont).getWidth(); int textWidth = (int)TextUtils.calculateStringBoundsFont(msg.substring(0, marker), sigIRC.userFont).getWidth();
while (textWidth<maxWidth) { while (textWidth<maxWidth) {
if (marker<msg.length()) { if (marker<msg.length()) {
@ -213,15 +213,22 @@ public class ChatLogMessage {
for (int i=0;i<displayMessage.size();i++) { for (int i=0;i<displayMessage.size();i++) {
//System.out.println(displayMessage.get(i)); //System.out.println(displayMessage.get(i));
if (username!=null && i==0) { if (username!=null && i==0) {
DrawUtils.drawOutlineText(g, sigIRC.userFont, position.getX(), position.getY()+(i*MESSAGE_SPACING)+32, 2, GetUserNameColor(this.username), SHADOW_COL, this.username); DrawUtils.drawOutlineText(g, sigIRC.userFont, position.getX(), position.getY()+(i*MESSAGE_SPACING)+32-Module.WINDOW_EXTRA_BORDER, 2, GetUserNameColor(this.username), SHADOW_COL, this.username);
DrawUtils.drawTextFont(g, sigIRC.userFont, position.getX()+usernameWidth+2, position.getY()+(i*MESSAGE_SPACING)+32, Color.BLACK, displayMessage.get(i)); DrawUtils.drawTextFont(g, sigIRC.userFont, position.getX()+usernameWidth+2, position.getY()+(i*MESSAGE_SPACING)+32-Module.WINDOW_EXTRA_BORDER, Color.BLACK, displayMessage.get(i));
} else { } else {
DrawUtils.drawTextFont(g, sigIRC.userFont, position.getX(), position.getY()+(i*MESSAGE_SPACING)+32, Color.BLACK, displayMessage.get(i)); DrawUtils.drawTextFont(g, sigIRC.userFont, position.getX(), position.getY()+(i*MESSAGE_SPACING)+32-Module.WINDOW_EXTRA_BORDER, Color.BLACK, displayMessage.get(i));
} }
} }
g.drawImage(Module.MSG_SEPARATOR, (int)(position.getX()+8), (int)(position.getY()+messageDisplaySize.getY()+12), (int)(messageDisplaySize.getX()-8), 1, sigIRC.panel); g.drawImage(Module.MSG_SEPARATOR, (int)(position.getX()+8), (int)(position.getY()+messageDisplaySize.getY()+8-Module.WINDOW_EXTRA_BORDER), (int)(messageDisplaySize.getX()-8), 1, sigIRC.panel);
//g.drawLine((int)(position.getX()+8), (int)(position.getY()+messageDisplaySize.getY()+32), (int)(position.getX()+messageDisplaySize.getX()-8), (int)(position.getY()+messageDisplaySize.getY()+32)); //g.drawLine((int)(position.getX()+8), (int)(position.getY()+messageDisplaySize.getY()+32), (int)(position.getX()+messageDisplaySize.getX()-8), (int)(position.getY()+messageDisplaySize.getY()+32));
} }
for (int i=0;i<sigIRC.chatlogtwitchemoticons.size();i++) {
if (sigIRC.chatlogtwitchemoticons.get(i).textRefIsVisible()) {
ChatLogTwitchEmote emote = sigIRC.chatlogtwitchemoticons.get(i);
//System.out.println("Twitch emote is "+emote.emote.getEmoteName()+" "+emote.x+","+emote.y);
sigIRC.chatlogtwitchemoticons.get(i).draw(g);
}
}
} }
public static void importMessages(String...logContents) { public static void importMessages(String...logContents) {
@ -242,7 +249,7 @@ public class ChatLogMessage {
} }
public boolean isVisible() { public boolean isVisible() {
return (position.getY()+MESSAGE_SPACING)>0 && return (position.getY()+MESSAGE_SPACING-Module.WINDOW_EXTRA_BORDER)>0 &&
(position.getY()+messageDisplaySize.getY())<refModule.getPosition().getHeight()-16; (position.getY()+messageDisplaySize.getY())<refModule.getPosition().getHeight()-16;
} }

@ -5,6 +5,7 @@ import java.awt.Graphics;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import sig.Emoticon; import sig.Emoticon;
import sig.Module;
import sig.ScrollingText; import sig.ScrollingText;
import sig.sigIRC; import sig.sigIRC;
@ -42,13 +43,15 @@ public class ChatLogTwitchEmote {
} }
public void draw(Graphics g) { public void draw(Graphics g) {
if (WithinBounds((int)(text.position.getX()+x), (int)(text.position.getY()+y), emote.getImage().getWidth(), emote.getImage().getHeight())) { if (WithinBounds((int)(text.position.getX()+x), (int)(text.position.getY()+y-Module.WINDOW_EXTRA_BORDER), 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); //g.drawString("Emote", (int)(text.position.getX()+x), (int)(text.position.getY()+y));
//System.out.println("Emote Pos: "+(int)(text.position.getX()+x)+","+(int)(text.position.getY()+y));
g.drawImage(emote.getImage(), (int)(text.position.getX()+x), (int)(text.position.getY()+y-Module.WINDOW_EXTRA_BORDER), text.refModule.panel);
} }
} }
private boolean WithinBounds(double x, double y, double w, double h) { 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) { if (x<text.refModule.panel.getWidth() && x+w>0 && y<text.refModule.panel.getHeight() && y+h>0) {
return true; return true;
} }
return false; return false;

@ -32,7 +32,8 @@ public class ChatLogModule extends Module{
public int scrolllog_yoffset = 0; public int scrolllog_yoffset = 0;
public Color backgroundColor; public Color backgroundColor;
long positionsNeedUpdating = 0; //Set it to System.currentTimeMillis() to request a configuration save. long positionsNeedUpdating = 0; //Set it to System.currentTimeMillis() to request a configuration save.
Rectangle prevpos; Rectangle prevpos = (Rectangle)position.clone();
int justOpened=2;
public ChatLogModule(Rectangle bounds, String moduleName) { public ChatLogModule(Rectangle bounds, String moduleName) {
@ -40,7 +41,6 @@ public class ChatLogModule extends Module{
//Initialize(); //Initialize();
chatlogmodule = this; chatlogmodule = this;
backgroundColor = DrawUtils.convertStringToColor(sigIRC.chatlogmodule_backgroundColor); backgroundColor = DrawUtils.convertStringToColor(sigIRC.chatlogmodule_backgroundColor);
prevpos = (Rectangle)position.clone();
} }
private void Initialize() { private void Initialize() {
@ -77,13 +77,22 @@ public class ChatLogModule extends Module{
} }
} }
} }
if (positionsNeedUpdating==0 && (prevpos.getWidth()!=position.getWidth() || prevpos.getHeight()!=position.getHeight())) {
positionsNeedUpdating=System.currentTimeMillis();
}
if (positionsNeedUpdating!=0 && System.currentTimeMillis()-positionsNeedUpdating>1000) { if (positionsNeedUpdating!=0 && System.currentTimeMillis()-positionsNeedUpdating>1000) {
positionsNeedUpdating=0; positionsNeedUpdating=0;
int diff = (int)(position.getHeight()-prevpos.getHeight()); int diff = (int)(position.getHeight()-prevpos.getHeight());
prevpos = (Rectangle)position.clone(); prevpos = (Rectangle)position.clone();
for (ChatLogMessage clm : messageHistory) { /*for (ChatLogMessage clm : messageHistory) {
clm.position.y+=diff; clm.position.y+=diff;
} }*/
messageHistory.clear();
sigIRC.chatlogtwitchemoticons.clear();
Initialize();
moveAllMessages(-scrolllog_yoffset);
scrolllog_yoffset=0;
repaint();
} }
} }
@ -92,13 +101,15 @@ public class ChatLogModule extends Module{
g.setColor(backgroundColor); g.setColor(backgroundColor);
g.fill3DRect(0, 0, (int)position.getWidth(), (int)position.getHeight(), true); g.fill3DRect(0, 0, (int)position.getWidth(), (int)position.getHeight(), true);
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
for (int i=0; i<messageHistory.size();i++) { if (messageHistory!=null) {
ChatLogMessage clm = messageHistory.get(i); for (int i=0; i<messageHistory.size();i++) {
if (clm!=null) { ChatLogMessage clm = messageHistory.get(i);
try { if (clm!=null) {
clm.draw(g); try {
} catch (ConcurrentModificationException e) { clm.draw(g);
e.printStackTrace(); } catch (ConcurrentModificationException e) {
e.printStackTrace();
}
} }
} }
} }
@ -113,11 +124,12 @@ public class ChatLogModule extends Module{
sigIRC.config.setInteger("CHATLOG_module_Y", sigIRC.chatlogmodule_Y); sigIRC.config.setInteger("CHATLOG_module_Y", sigIRC.chatlogmodule_Y);
sigIRC.config.setInteger("CHATLOG_module_width", sigIRC.chatlogmodule_width); sigIRC.config.setInteger("CHATLOG_module_width", sigIRC.chatlogmodule_width);
sigIRC.config.setInteger("CHATLOG_module_height", sigIRC.chatlogmodule_height); sigIRC.config.setInteger("CHATLOG_module_height", sigIRC.chatlogmodule_height);
sigIRC.config.saveProperties();
} }
public void mouseWheel(MouseWheelEvent ev) { public void mouseWheelMoved(MouseWheelEvent ev) {
if (mouseInBounds(ev.getX(),ev.getY())) { if (mouseInBounds(ev.getX(),ev.getY())) {
int scrollMult = 8; int scrollMult = 12;
int scrollAmt = -ev.getWheelRotation()*scrollMult; int scrollAmt = -ev.getWheelRotation()*scrollMult;
if (scrollAmt>0) { if (scrollAmt>0) {
if (HighestMessageIsVisible()) { if (HighestMessageIsVisible()) {
@ -145,11 +157,6 @@ public class ChatLogModule extends Module{
return true; return true;
} }
@Override
public void componentResized(ComponentEvent e) {
this.positionsNeedUpdating=System.currentTimeMillis();
}
public void moveAllMessages(int yAmt) { public void moveAllMessages(int yAmt) {
for (int i=0;i<messageHistory.size();i++) { for (int i=0;i<messageHistory.size();i++) {
ChatLogMessage clm = messageHistory.get(i); ChatLogMessage clm = messageHistory.get(i);
@ -164,14 +171,14 @@ public class ChatLogModule extends Module{
} }
private boolean mouseInBounds(int mouseX, int mouseY) { private boolean mouseInBounds(int mouseX, int mouseY) {
return mouseX>=position.getX() && return mouseX>=0 &&
mouseX<=position.getX()+position.getWidth() && mouseX<=0+position.getWidth() &&
mouseY>=position.getX() && mouseY>=0 &&
mouseY<=position.getX()+position.getHeight(); mouseY<=0+position.getHeight();
} }
public void keypressed(KeyEvent ev) { public void keyPressed(KeyEvent ev) {
int key = ev.getKeyCode(); int key = ev.getKeyCode();
int scroll = 0; int scroll = 0;
if (key==KeyEvent.VK_PAGE_UP) { if (key==KeyEvent.VK_PAGE_UP) {
@ -181,7 +188,7 @@ public class ChatLogModule extends Module{
scroll=-8; scroll=-8;
} }
if (key==KeyEvent.VK_HOME) { if (key==KeyEvent.VK_HOME) {
scroll=Math.abs(GetHighestMessagePosition()); scroll=Math.abs(GetHighestMessagePosition()-Module.WINDOW_EXTRA_BORDER);
} }
if (key==KeyEvent.VK_END) { if (key==KeyEvent.VK_END) {
moveAllMessages(-scrolllog_yoffset); moveAllMessages(-scrolllog_yoffset);

@ -0,0 +1,191 @@
package sig.modules;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import org.json.JSONException;
import org.json.JSONObject;
import sig.CustomSound;
import sig.Module;
import sig.TextRow;
import sig.sigIRC;
import sig.utils.FileUtils;
public class ScrollingChatModule extends Module{
final static int MSGTIMER = 300;
final static int AUTOSAVETIMER = 600;
int last_authentication_msg = MSGTIMER;
int last_autosave = AUTOSAVETIMER;
public static ScrollingChatModule module;
public ScrollingChatModule(Rectangle bounds, String moduleName) {
super(bounds, moduleName);
ScrollingChatModule.module = this;
String[] filedata = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/oauthToken.txt");
final String oauth = filedata[0].trim().substring(0, Math.min(36,filedata[0].trim().length()));
Thread t = new Thread(()->{
sigIRC.InitializeIRCConnection(sigIRC.server, sigIRC.nickname, sigIRC.channel, oauth);
});
t.start();
UpdateSubEmoticons();
}
public void run() {
UpdateScrollingText();
UpdateAuthenticationCountdownMessage();
}
private void UpdateSubEmoticons() {
if (!sigIRC.downloadedSubEmotes &&
sigIRC.disableChatMessages &&
sigIRC.subchannelCount==sigIRC.subchannelIds.size()) {
Thread downloadThread = new Thread(){
public void run() {
JSONObject data = GetSubEmoteJson();
sigIRC.downloadSubEmotes(data);
sigIRC.subEmotesCompleted=true;
}
};
downloadThread.start();
sigIRC.downloadedSubEmotes=true;
}
}
public void draw(Graphics g) {
for (int i=0;i<sigIRC.textobj.size();i++) {
if (sigIRC.textobj.get(i).isActive()) {
if (sigIRC.overlayMode) {
if (!sigIRC.textobj.get(i).intersects((int)(sigIRC.panel.lastMouseX-position.getX()),(int)(sigIRC.panel.lastMouseY-position.getY()))) {
sigIRC.textobj.get(i).setVisible(true);
sigIRC.textobj.get(i).draw(g);
} else {
//System.out.println("Setting to False.");
sigIRC.textobj.get(i).setVisible(false);
}
} else {
sigIRC.textobj.get(i).draw(g);
}
}
}
for (int i=0;i<sigIRC.twitchemoticons.size();i++) {
if (sigIRC.twitchemoticons.get(i).isActive() &&
sigIRC.twitchemoticons.get(i).textRefIsVisible()) {
sigIRC.twitchemoticons.get(i).draw(g);
} else {
break;
}
}
}
private JSONObject GetSubEmoteJson() {
JSONObject subemotes = null;
try {
File filer = new File(sigIRC.SUBEMOTELISTFILE);
if (!filer.exists()) {
System.out.println("Local copy of Sub emotes not found. Downloading in background...");
subemotes = FileUtils.readJsonFromUrlWithFilter("https://twitchemotes.com/api_cache/v3/subscriber.json",sigIRC.subchannelIds,sigIRC.SUBEMOTELISTFILE,true);
} else {
if (sigIRC.lastSubEmoteUpdate == Calendar.getInstance().get(Calendar.DAY_OF_YEAR)) {
System.out.println("Using local copy of Sub emote JSON.");
subemotes = FileUtils.readJsonFromFileWithFilter(sigIRC.SUBEMOTELISTFILE,sigIRC.subchannelIds);
} else {
System.out.println("Local copy of Sub emote JSON out-of-date! Re-downloading in background...");
subemotes = FileUtils.readJsonFromFileWithFilter(sigIRC.SUBEMOTELISTFILE,sigIRC.subchannelIds);
new Thread(){
public void run() {
try {
FileUtils.readJsonFromUrlWithFilter("https://twitchemotes.com/api_cache/v3/subscriber.json",sigIRC.subchannelIds,sigIRC.SUBEMOTELISTFILE,true);
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
}
} catch (JSONException | IOException e) {
e.printStackTrace();
}
sigIRC.lastSubEmoteUpdate = Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
sigIRC.config.setInteger("lastSubEmote_APIUpdate", sigIRC.lastSubEmoteUpdate);
return subemotes;
}
private void UpdateAuthenticationCountdownMessage() {
if (sigIRC.downloadsComplete) {
if ((!sigIRC.authenticated || sigIRC.testMode) && last_authentication_msg<MSGTIMER) {
last_authentication_msg++;
} else
if ((!sigIRC.authenticated || sigIRC.testMode) && last_authentication_msg>=MSGTIMER) {
last_authentication_msg=0;
if (!sigIRC.authenticated && !sigIRC.testMode) {
sigIRC.panel.addMessage("SYSTEM: Your oauthToken was not successful. Please go to the sigIRC folder and make sure your oauthToken.txt file is correct!!! SwiftRage",!sigIRC.playedoAuthSoundOnce);
if (!sigIRC.playedoAuthSoundOnce) {
sigIRC.playedoAuthSoundOnce=true;
}
} else {
sigIRC.panel.addMessage("SYSTEM: This is a test message for your testing convenience. mikansBox",!sigIRC.playedoAuthSoundOnce);
}
}
if (last_autosave<AUTOSAVETIMER) {
last_authentication_msg++;
} else
if (last_autosave>=AUTOSAVETIMER) {
last_autosave=0;
sigIRC.windowX = (int)sigIRC.window.getLocationOnScreen().getX();
sigIRC.windowY = (int)sigIRC.window.getLocationOnScreen().getY();
sigIRC.windowWidth = sigIRC.window.getWidth();
sigIRC.windowHeight = sigIRC.window.getHeight();
sigIRC.config.setInteger("windowX", sigIRC.windowX);
sigIRC.config.setInteger("windowY", sigIRC.windowY);
sigIRC.config.setInteger("windowWidth", sigIRC.windowWidth);
sigIRC.config.setInteger("windowHeight", sigIRC.windowHeight);
sigIRC.config.saveProperties();
}
if (sigIRC.lastPlayedDing>0) {
sigIRC.lastPlayedDing--;
}
}
}
public void UpdateScrollingText() {
for (int i=0;i<sigIRC.twitchemoticons.size();i++) {
boolean keep = sigIRC.twitchemoticons.get(i).run();
if (!keep) {
sigIRC.twitchemoticons.remove(i--);
}
}
for (int i=0;i<sigIRC.textobj.size();i++) {
System.out.println(sigIRC.textobj.get(i).getX()+","+sigIRC.textobj.get(i).getY());
boolean keep = sigIRC.textobj.get(i).run();
if (!keep) {
sigIRC.textobj.remove(i--);
}
}
ProcessTextRows();
for (CustomSound cs : sigIRC.customsounds) {
if (!cs.isSoundAvailable()) {
cs.decreaseCooldown(1);
}
}
}
private void ProcessTextRows() {
for (TextRow tr : sigIRC.rowobj) {
tr.update();
}
sigIRC.dingEnabled = (sigIRC.textobj.size()<=sigIRC.dingThreshold);
//System.out.println(sigIRC.textobj.size()+"/"+sigIRC.dingThreshold+sigIRC.dingEnabled);
}
}

@ -99,8 +99,8 @@ public class sigIRC{
public static boolean authenticated=false; public static boolean authenticated=false;
public static int lastPlayedDing=0; public static int lastPlayedDing=0;
final public static int DINGTIMER=150; final public static int DINGTIMER=150;
static boolean dingEnabled=true; public static boolean dingEnabled=true;
static int dingThreshold; public static int dingThreshold;
public static Color backgroundcol; public static Color backgroundcol;
//public static BackgroundColorButton button; //public static BackgroundColorButton button;
public static ProgramWindow window; public static ProgramWindow window;
@ -120,9 +120,9 @@ public class sigIRC{
public static boolean touhoumothermodule_enabled=false; public static boolean touhoumothermodule_enabled=false;
public static boolean twitchmodule_enabled=true; public static boolean twitchmodule_enabled=true;
public static boolean chatlogmodule_enabled=true; public static boolean chatlogmodule_enabled=true;
static boolean downloadsComplete=false; public static boolean downloadsComplete=false;
public static boolean hardwareAcceleration=true; public static boolean hardwareAcceleration=true;
static boolean playedoAuthSoundOnce=false; public static boolean playedoAuthSoundOnce=false;
public static int twitchmodule_width=500; public static int twitchmodule_width=500;
public static int twitchmodule_height=200; public static int twitchmodule_height=200;
public static int twitchmodule_X=320; public static int twitchmodule_X=320;
@ -183,6 +183,11 @@ public class sigIRC{
static int lastWindowX = 0; static int lastWindowX = 0;
static int lastWindowY = 0; static int lastWindowY = 0;
public static int scrollingchatmodule_X=0;
public static int scrollingchatmodule_Y=0;
public static int scrollingchatmodule_width=0;
public static int scrollingchatmodule_height=0;
final public static Font rabiRibiTinyDisplayFont = new Font("CP Font",0,12); final public static Font rabiRibiTinyDisplayFont = new Font("CP Font",0,12);
@ -238,6 +243,10 @@ public class sigIRC{
touhoumothermodule_Y = config.getInteger("TOUHOUMOTHER_module_Y",312); touhoumothermodule_Y = config.getInteger("TOUHOUMOTHER_module_Y",312);
touhoumothermodule_width = config.getInteger("TOUHOUMOTHER_module_width",320); touhoumothermodule_width = config.getInteger("TOUHOUMOTHER_module_width",320);
touhoumothermodule_height = config.getInteger("TOUHOUMOTHER_module_height",312); touhoumothermodule_height = config.getInteger("TOUHOUMOTHER_module_height",312);
scrollingchatmodule_X = config.getInteger("SCROLLINGCHAT_module_X",0);
scrollingchatmodule_Y = config.getInteger("SCROLLINGCHAT_module_Y",312);
scrollingchatmodule_width = config.getInteger("SCROLLINGCHAT_module_width",320);
scrollingchatmodule_height = config.getInteger("SCROLLINGCHAT_module_height",312);
/*rabiribimodule_X = config.getInteger("RABIRIBI_module_X",0); /*rabiribimodule_X = config.getInteger("RABIRIBI_module_X",0);
rabiribimodule_Y = config.getInteger("RABIRIBI_module_Y",312); rabiribimodule_Y = config.getInteger("RABIRIBI_module_Y",312);
rabiribimodule_width = config.getInteger("RABIRIBI_module_width",320); rabiribimodule_width = config.getInteger("RABIRIBI_module_width",320);
@ -570,6 +579,7 @@ public class sigIRC{
public static void runIRCLoop(String channel, BufferedWriter writer, BufferedReader reader) throws IOException { public static void runIRCLoop(String channel, BufferedWriter writer, BufferedReader reader) throws IOException {
String line; String line;
while ((line = reader.readLine( )) != null) { while ((line = reader.readLine( )) != null) {
System.out.println("Waiting for data..."+line);
if (line.toLowerCase( ).startsWith("PING ")) { if (line.toLowerCase( ).startsWith("PING ")) {
// We must respond to PINGs to avoid being disconnected. // We must respond to PINGs to avoid being disconnected.
writer.write("PONG " + line.substring(5) + "\r\n"); writer.write("PONG " + line.substring(5) + "\r\n");

@ -201,6 +201,7 @@ public class LoadingDialog extends JFrame{
//Load is done. Start up the panel. //Load is done. Start up the panel.
sigIRC.window = new ProgramWindow(); sigIRC.window = new ProgramWindow();
this.setVisible(false); this.setVisible(false);
sigIRC.downloadsComplete=true;
} }
private void UpdateBar() { private void UpdateBar() {

@ -31,6 +31,7 @@ import sig.Module;
import sig.MyPanel; import sig.MyPanel;
import sig.sigIRC; import sig.sigIRC;
import sig.modules.ChatLogModule; import sig.modules.ChatLogModule;
import sig.modules.ScrollingChatModule;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ProgramWindow extends JFrame{ public class ProgramWindow extends JFrame{
@ -89,7 +90,8 @@ public class ProgramWindow extends JFrame{
sigIRC.panel.add(myLabel); sigIRC.panel.add(myLabel);
if (!sigIRC.disableChatMessages) { if (!sigIRC.disableChatMessages) {
ModuleButton button = new ModuleButton("Scrolling Chat",new Module(new Rectangle(0,0,0,0),"Test")); ScrollingChatModule mod = new ScrollingChatModule(new Rectangle((int)sigIRC.scrollingchatmodule_X,(int)sigIRC.scrollingchatmodule_Y,(int)sigIRC.scrollingchatmodule_width,(int)sigIRC.scrollingchatmodule_height),"Scrolling Chat");
ModuleButton button = new ModuleButton("Scrolling Chat",mod);
sigIRC.panel.add(button); sigIRC.panel.add(button);
} }
if (sigIRC.chatlogmodule_enabled) { if (sigIRC.chatlogmodule_enabled) {

Loading…
Cancel
Save