Continued work on fixing Scrolling Chat module. No luck yet.
This commit is contained in:
parent
e210299f7f
commit
824b8249d9
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<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="lib" path="lib/commons-io-2.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/twitch-api-wrapper-0.3-jar-with-dependencies.jar"/>
|
||||
|
BIN
sigIRCv2.jar
BIN
sigIRCv2.jar
Binary file not shown.
53
src/sig/ListenerPanel.java
Normal file
53
src/sig/ListenerPanel.java
Normal file
@ -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.KeyListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
@ -27,21 +25,21 @@ import java.util.concurrent.TimeUnit;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import sig.utils.DrawUtils;
|
||||
import sig.utils.TextUtils;
|
||||
import sig.windows.ProgramWindow;
|
||||
|
||||
public class Module extends JFrame implements MouseListener, MouseWheelListener, KeyListener, ComponentListener, WindowListener{
|
||||
public JPanel panel;
|
||||
public class Module extends JFrame implements ComponentListener, WindowListener, KeyListener{
|
||||
public ListenerPanel panel;
|
||||
public Rectangle position;
|
||||
protected boolean enabled;
|
||||
protected String name;
|
||||
public static BufferedImage IMG_DRAGBAR;
|
||||
public static BufferedImage MSG_SEPARATOR;
|
||||
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;
|
||||
|
||||
@ -58,18 +56,16 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
|
||||
|
||||
public Module(Rectangle bounds, String moduleName) {
|
||||
|
||||
this.addMouseListener(this);
|
||||
this.addMouseWheelListener(this);
|
||||
this.addKeyListener(this);
|
||||
this.addComponentListener(this);
|
||||
this.addWindowListener(this);
|
||||
this.addKeyListener(this);
|
||||
|
||||
this.position = bounds;
|
||||
this.name = moduleName;
|
||||
this.enabled=true;
|
||||
this.setVisible(true);
|
||||
this.setTitle(moduleName);
|
||||
panel = new JPanel(){
|
||||
panel = new ListenerPanel(this){
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(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.setSize((int)position.getWidth(), (int)position.getHeight());
|
||||
panel.setSize(this.getSize());
|
||||
|
||||
this.add(panel);
|
||||
//this.pack();
|
||||
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.scheduleWithFixedDelay(()->{
|
||||
@ -114,9 +112,6 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent ev) {
|
||||
}
|
||||
|
||||
public void ApplyConfigWindowProperties() {
|
||||
}
|
||||
@ -124,9 +119,6 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
|
||||
public void SaveConfig() {
|
||||
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent ev) {
|
||||
}
|
||||
|
||||
protected void moduleRun() {
|
||||
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 mouseWheel(MouseWheelEvent ev) {
|
||||
}
|
||||
|
||||
public void keypressed(KeyEvent ev) {
|
||||
|
||||
}
|
||||
|
||||
public void keyreleased(KeyEvent ev) {
|
||||
}
|
||||
|
||||
public void windowClosed(WindowEvent ev) {
|
||||
|
||||
@ -210,7 +192,7 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
|
||||
}
|
||||
|
||||
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);
|
||||
ApplyConfigWindowProperties();
|
||||
sigIRC.configNeedsUpdating = System.currentTimeMillis();
|
||||
@ -226,46 +208,47 @@ public class Module extends JFrame implements MouseListener, MouseWheelListener,
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void keyPressed(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
public void mouseWheelMoved(MouseWheelEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
// 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 sig.modules.ChatLogModule;
|
||||
import sig.modules.ScrollingChatModule;
|
||||
import sig.modules.ChatLog.ChatLogMessage;
|
||||
import sig.utils.FileUtils;
|
||||
|
||||
@ -51,8 +52,8 @@ public class MyPanel extends JPanel{
|
||||
// Draw Text
|
||||
//int counter=18;
|
||||
if (sigIRC.panel!=null) {
|
||||
lastMouseX = (int)(MouseInfo.getPointerInfo().getLocation().getX()-sigIRC.panel.getLocationOnScreen().getX());
|
||||
lastMouseY = (int)(MouseInfo.getPointerInfo().getLocation().getY()-sigIRC.panel.getLocationOnScreen().getY());
|
||||
lastMouseX = (int)(MouseInfo.getPointerInfo().getLocation().getX());
|
||||
lastMouseY = (int)(MouseInfo.getPointerInfo().getLocation().getY());
|
||||
//System.out.println("("+lastMouseX+","+lastMouseY+")");
|
||||
}
|
||||
/*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) {
|
||||
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());
|
||||
sigIRC.textobj.add(text);
|
||||
row.updateRow(text);
|
||||
|
@ -20,6 +20,7 @@ import javax.sound.sampled.LineUnavailableException;
|
||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import sig.modules.ScrollingChatModule;
|
||||
import sig.utils.DrawUtils;
|
||||
import sig.utils.FileUtils;
|
||||
import sig.utils.SoundUtils;
|
||||
@ -180,7 +181,7 @@ public class ScrollingText {
|
||||
}
|
||||
|
||||
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 false;
|
||||
@ -188,28 +189,28 @@ public class ScrollingText {
|
||||
|
||||
public int FindLeftMostCornerInDisplay() {
|
||||
if (x-shadowSize>0) {
|
||||
return Math.min((int)x-shadowSize, sigIRC.panel.getWidth());
|
||||
return Math.min((int)x-shadowSize, ScrollingChatModule.module.getWidth());
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int FindTopMostCornerInDisplay() {
|
||||
if (y-shadowSize>0) {
|
||||
return Math.min((int)y-shadowSize, sigIRC.panel.getHeight());
|
||||
return Math.min((int)y-shadowSize, ScrollingChatModule.module.getHeight());
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int FindRightMostCornerInDisplay() {
|
||||
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 {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int FindBottomMostCornerInDisplay() {
|
||||
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 {
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ import java.awt.Graphics;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import sig.modules.ScrollingChatModule;
|
||||
|
||||
public class TwitchEmote {
|
||||
Emoticon emote;
|
||||
int x=0; //X Offset
|
||||
@ -38,7 +40,7 @@ public class TwitchEmote {
|
||||
|
||||
public void draw(Graphics g) {
|
||||
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) {
|
||||
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 false;
|
||||
|
@ -25,7 +25,7 @@ public class ChatLogMessage {
|
||||
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 int BORDER_SPACING = 16;
|
||||
final static public Color SHADOW_COL = new Color(35,35,35,255);
|
||||
int usernameWidth = 0;
|
||||
boolean active=true;
|
||||
@ -170,7 +170,7 @@ public class ChatLogMessage {
|
||||
}
|
||||
|
||||
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();
|
||||
while (textWidth<maxWidth) {
|
||||
if (marker<msg.length()) {
|
||||
@ -213,15 +213,22 @@ public class ChatLogMessage {
|
||||
for (int i=0;i<displayMessage.size();i++) {
|
||||
//System.out.println(displayMessage.get(i));
|
||||
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.drawTextFont(g, sigIRC.userFont, position.getX()+usernameWidth+2, position.getY()+(i*MESSAGE_SPACING)+32, Color.BLACK, displayMessage.get(i));
|
||||
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-Module.WINDOW_EXTRA_BORDER, Color.BLACK, displayMessage.get(i));
|
||||
} 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));
|
||||
}
|
||||
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) {
|
||||
@ -242,7 +249,7 @@ public class ChatLogMessage {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.awt.Graphics;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import sig.Emoticon;
|
||||
import sig.Module;
|
||||
import sig.ScrollingText;
|
||||
import sig.sigIRC;
|
||||
|
||||
@ -42,13 +43,15 @@ public class ChatLogTwitchEmote {
|
||||
}
|
||||
|
||||
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);
|
||||
if (WithinBounds((int)(text.position.getX()+x), (int)(text.position.getY()+y-Module.WINDOW_EXTRA_BORDER), emote.getImage().getWidth(), emote.getImage().getHeight())) {
|
||||
//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) {
|
||||
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 false;
|
||||
|
@ -32,7 +32,8 @@ public class ChatLogModule extends Module{
|
||||
public int scrolllog_yoffset = 0;
|
||||
public Color backgroundColor;
|
||||
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) {
|
||||
@ -40,7 +41,6 @@ public class ChatLogModule extends Module{
|
||||
//Initialize();
|
||||
chatlogmodule = this;
|
||||
backgroundColor = DrawUtils.convertStringToColor(sigIRC.chatlogmodule_backgroundColor);
|
||||
prevpos = (Rectangle)position.clone();
|
||||
}
|
||||
|
||||
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) {
|
||||
positionsNeedUpdating=0;
|
||||
int diff = (int)(position.getHeight()-prevpos.getHeight());
|
||||
prevpos = (Rectangle)position.clone();
|
||||
for (ChatLogMessage clm : messageHistory) {
|
||||
/*for (ChatLogMessage clm : messageHistory) {
|
||||
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.fill3DRect(0, 0, (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();
|
||||
if (messageHistory!=null) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,11 +124,12 @@ public class ChatLogModule extends Module{
|
||||
sigIRC.config.setInteger("CHATLOG_module_Y", sigIRC.chatlogmodule_Y);
|
||||
sigIRC.config.setInteger("CHATLOG_module_width", sigIRC.chatlogmodule_width);
|
||||
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())) {
|
||||
int scrollMult = 8;
|
||||
int scrollMult = 12;
|
||||
int scrollAmt = -ev.getWheelRotation()*scrollMult;
|
||||
if (scrollAmt>0) {
|
||||
if (HighestMessageIsVisible()) {
|
||||
@ -145,11 +157,6 @@ public class ChatLogModule extends Module{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
this.positionsNeedUpdating=System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void moveAllMessages(int yAmt) {
|
||||
for (int i=0;i<messageHistory.size();i++) {
|
||||
ChatLogMessage clm = messageHistory.get(i);
|
||||
@ -164,14 +171,14 @@ public class ChatLogModule extends Module{
|
||||
}
|
||||
|
||||
private boolean mouseInBounds(int mouseX, int mouseY) {
|
||||
return mouseX>=position.getX() &&
|
||||
mouseX<=position.getX()+position.getWidth() &&
|
||||
mouseY>=position.getX() &&
|
||||
mouseY<=position.getX()+position.getHeight();
|
||||
return mouseX>=0 &&
|
||||
mouseX<=0+position.getWidth() &&
|
||||
mouseY>=0 &&
|
||||
mouseY<=0+position.getHeight();
|
||||
}
|
||||
|
||||
|
||||
public void keypressed(KeyEvent ev) {
|
||||
public void keyPressed(KeyEvent ev) {
|
||||
int key = ev.getKeyCode();
|
||||
int scroll = 0;
|
||||
if (key==KeyEvent.VK_PAGE_UP) {
|
||||
@ -181,7 +188,7 @@ public class ChatLogModule extends Module{
|
||||
scroll=-8;
|
||||
}
|
||||
if (key==KeyEvent.VK_HOME) {
|
||||
scroll=Math.abs(GetHighestMessagePosition());
|
||||
scroll=Math.abs(GetHighestMessagePosition()-Module.WINDOW_EXTRA_BORDER);
|
||||
}
|
||||
if (key==KeyEvent.VK_END) {
|
||||
moveAllMessages(-scrolllog_yoffset);
|
||||
|
191
src/sig/modules/ScrollingChatModule.java
Normal file
191
src/sig/modules/ScrollingChatModule.java
Normal file
@ -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 int lastPlayedDing=0;
|
||||
final public static int DINGTIMER=150;
|
||||
static boolean dingEnabled=true;
|
||||
static int dingThreshold;
|
||||
public static boolean dingEnabled=true;
|
||||
public static int dingThreshold;
|
||||
public static Color backgroundcol;
|
||||
//public static BackgroundColorButton button;
|
||||
public static ProgramWindow window;
|
||||
@ -120,9 +120,9 @@ public class sigIRC{
|
||||
public static boolean touhoumothermodule_enabled=false;
|
||||
public static boolean twitchmodule_enabled=true;
|
||||
public static boolean chatlogmodule_enabled=true;
|
||||
static boolean downloadsComplete=false;
|
||||
public static boolean downloadsComplete=false;
|
||||
public static boolean hardwareAcceleration=true;
|
||||
static boolean playedoAuthSoundOnce=false;
|
||||
public static boolean playedoAuthSoundOnce=false;
|
||||
public static int twitchmodule_width=500;
|
||||
public static int twitchmodule_height=200;
|
||||
public static int twitchmodule_X=320;
|
||||
@ -183,6 +183,11 @@ public class sigIRC{
|
||||
|
||||
static int lastWindowX = 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);
|
||||
|
||||
@ -238,6 +243,10 @@ 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);
|
||||
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_Y = config.getInteger("RABIRIBI_module_Y",312);
|
||||
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 {
|
||||
String line;
|
||||
while ((line = reader.readLine( )) != null) {
|
||||
System.out.println("Waiting for data..."+line);
|
||||
if (line.toLowerCase( ).startsWith("PING ")) {
|
||||
// We must respond to PINGs to avoid being disconnected.
|
||||
writer.write("PONG " + line.substring(5) + "\r\n");
|
||||
|
@ -201,6 +201,7 @@ public class LoadingDialog extends JFrame{
|
||||
//Load is done. Start up the panel.
|
||||
sigIRC.window = new ProgramWindow();
|
||||
this.setVisible(false);
|
||||
sigIRC.downloadsComplete=true;
|
||||
}
|
||||
|
||||
private void UpdateBar() {
|
||||
|
@ -31,6 +31,7 @@ import sig.Module;
|
||||
import sig.MyPanel;
|
||||
import sig.sigIRC;
|
||||
import sig.modules.ChatLogModule;
|
||||
import sig.modules.ScrollingChatModule;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ProgramWindow extends JFrame{
|
||||
@ -89,7 +90,8 @@ public class ProgramWindow extends JFrame{
|
||||
sigIRC.panel.add(myLabel);
|
||||
|
||||
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);
|
||||
}
|
||||
if (sigIRC.chatlogmodule_enabled) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user