Configuration controls! Added an overlay mode, so you can see the

overlay on your own screen. Config file has a lot more customizability
now and provides more control over the program.
dev
sigonasr2 8 years ago
parent 674f7979c6
commit b236798544
  1. 9
      .gitignore
  2. 21
      projectBuilder.xml
  3. BIN
      sigIRCv2.jar
  4. 2
      src/sig/BackgroundColorButton.java
  5. 27
      src/sig/ConfigFile.java
  6. 6
      src/sig/Module.java
  7. 51
      src/sig/MyPanel.java
  8. 5
      src/sig/ScrollingText.java
  9. 2
      src/sig/TextRow.java
  10. 6
      src/sig/TwitchEmote.java
  11. 46
      src/sig/UpdateEvent.java
  12. 59
      src/sig/sigIRC.java

9
.gitignore vendored

@ -1 +1,10 @@
/bin/ /bin/
/sigIRC/
/sigIRC/Emotes/
/backcolor.png
/kill.png
/memory
/sigIRCv2.conf
/swap.png
/update.png
/WSplits

@ -1,6 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="sigIRCv2.makejar" default="makejar" basedir="."> <project default="create_run_jar" name="Create Runnable Jar for Project sigIRCv2">
<target name ="makejar" description="Create a jar for the sigIRCv2 project"> <!--this file was created by Eclipse Runnable JAR Export Wizard-->
<jar jarfile="sigIRCv2.jar" includes="*.class" basedir="bin"/> <!--ANT 1.7 is required -->
<!--define folder properties-->
<property name="dir.buildfile" value="."/>
<property name="dir.workspace" value="${dir.buildfile}/.."/>
<property name="dir.jarfile" value="${dir.buildfile}"/>
<target name="create_run_jar">
<jar destfile="${dir.jarfile}/sigIRCv2.jar" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="sig.sigIRC"/>
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="${dir.jarfile}/bin"/>
<zipfileset excludes="META-INF/*.SF" src="D:/Data/commons-io-2.5.jar"/>
</jar>
</target> </target>
</project> </project>

Binary file not shown.

@ -40,7 +40,7 @@ public class BackgroundColorButton {
} }
public void onClickEvent(MouseEvent ev) { public void onClickEvent(MouseEvent ev) {
if (buttonEnabled) { if (buttonEnabled && !sigIRC.overlayMode) {
if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() && if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() &&
ev.getY()>=y && ev.getY()<=y+buttonimg.getHeight()) { ev.getY()>=y && ev.getY()<=y+buttonimg.getHeight()) {
sigIRC.backgroundcol=sigIRC.colorpanel.getBackgroundColor(); sigIRC.backgroundcol=sigIRC.colorpanel.getBackgroundColor();

@ -56,10 +56,37 @@ public class ConfigFile {
} }
} }
public String getProperty(String key, String def) {
String val = properties.getProperty(key);
if (val==null) {
this.setProperty(key, def);
this.saveProperties();
return properties.getProperty(key);
} else {
return val;
}
}
public boolean getBoolean(String key, boolean def) {
return Boolean.parseBoolean(getProperty(key,Boolean.toString(def)));
}
public int getInteger(String key, int def) {
return Integer.parseInt(getProperty(key,Integer.toString(def)));
}
public void setProperty(String key, String value) { public void setProperty(String key, String value) {
properties.setProperty(key, value); properties.setProperty(key, value);
} }
public void setBoolean(String key, boolean value) {
properties.setProperty(key, Boolean.toString(value));
}
public void setInteger(String key, int value) {
properties.setProperty(key, Integer.toString(value));
}
public void saveProperties() { public void saveProperties() {
try { try {
properties.store(GetFileWriter(basepath), "Properties file for sigIRCv2\n"); properties.store(GetFileWriter(basepath), "Properties file for sigIRCv2\n");

@ -5,6 +5,8 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import javax.swing.SwingUtilities;
public class Module { public class Module {
protected Rectangle2D bounds; protected Rectangle2D bounds;
protected boolean enabled; protected boolean enabled;
@ -29,8 +31,12 @@ public class Module {
} }
public void draw(Graphics g) { public void draw(Graphics g) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
sigIRC.panel.repaint(bounds.getBounds()); sigIRC.panel.repaint(bounds.getBounds());
} }
});
}
public void mouseWheel(MouseWheelEvent ev) { public void mouseWheel(MouseWheelEvent ev) {
} }

@ -7,6 +7,8 @@ import java.awt.Graphics;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
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;
@ -19,16 +21,17 @@ import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
public class MyPanel extends JPanel implements MouseListener, ActionListener, MouseWheelListener, KeyListener{ public class MyPanel extends JPanel implements MouseListener, ActionListener, MouseWheelListener, KeyListener, ComponentListener{
//List<String> messages = new ArrayList<String>(); //List<String> messages = new ArrayList<String>();
final public static Font programFont = new Font("Gill Sans Ultra Bold Condensed",0,24); final public static Font programFont = new Font(sigIRC.messageFont,0,24);
final public static Font userFont = new Font("Gill Sans",0,16); final public static Font userFont = new Font(sigIRC.usernameFont,0,16);
final public static Font smallFont = new Font("Agency FB Bold",0,12); final public static Font smallFont = new Font(sigIRC.touhoumotherConsoleFont,0,12);
public MyPanel() { public MyPanel() {
//setBorder(BorderFactory.createLineBorder(Color.black)); //setBorder(BorderFactory.createLineBorder(Color.black));
addMouseListener(this); addMouseListener(this);
addMouseWheelListener(this); addMouseWheelListener(this);
addComponentListener(this);
addKeyListener(this); addKeyListener(this);
setFocusable(true); setFocusable(true);
} }
@ -58,8 +61,10 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
for (Module m : sigIRC.modules) { for (Module m : sigIRC.modules) {
m.draw(g); m.draw(g);
} }
if (!sigIRC.overlayMode) {
sigIRC.button.draw(g); sigIRC.button.draw(g);
} }
}
public void addMessage(String message) { public void addMessage(String message) {
ScrollingText text = new ScrollingText(message,this.getWidth(),(int)(Math.random()*128)); ScrollingText text = new ScrollingText(message,this.getWidth(),(int)(Math.random()*128));
@ -121,4 +126,42 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
m.keyreleased(ev); m.keyreleased(ev);
} }
} }
@Override
public void componentResized(ComponentEvent ev) {
sigIRC.windowX = sigIRC.window.getX();
sigIRC.windowY = sigIRC.window.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.button.x = sigIRC.panel.getX()+sigIRC.panel.getWidth()-96;
sigIRC.button.y = 64+sigIRC.rowobj.size()*sigIRC.rowSpacing;
sigIRC.config.saveProperties();
}
@Override
public void componentMoved(ComponentEvent ev) {
sigIRC.windowX = sigIRC.window.getX();
sigIRC.windowY = sigIRC.window.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.button.x = sigIRC.panel.getX()+sigIRC.panel.getWidth()-96;
sigIRC.button.y = 64+sigIRC.rowobj.size()*sigIRC.rowSpacing;
sigIRC.config.saveProperties();
}
@Override
public void componentShown(ComponentEvent ev) {
}
@Override
public void componentHidden(ComponentEvent ev) {
}
} }

@ -18,6 +18,7 @@ import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip; import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.SwingUtilities;
public class ScrollingText { public class ScrollingText {
private String username; private String username;
@ -127,11 +128,15 @@ public class ScrollingText {
public boolean run() { public boolean run() {
x-=myRow.getScrollSpd(); x-=myRow.getScrollSpd();
//System.out.println("X: "+x); //System.out.println("X: "+x);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
sigIRC.panel.repaint( sigIRC.panel.repaint(
FindLeftMostCornerInDisplay(), FindLeftMostCornerInDisplay(),
FindTopMostCornerInDisplay()-32, FindTopMostCornerInDisplay()-32,
(int)Math.max(FindRightMostCornerInDisplay(),(int)TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getWidth())+4, (int)Math.max(FindRightMostCornerInDisplay(),(int)TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getWidth())+4,
FindBottomMostCornerInDisplay()+(stringHeight*2)+4); FindBottomMostCornerInDisplay()+(stringHeight*2)+4);
}
});
//sigIRC.panel.repaint(); //sigIRC.panel.repaint();
if (x+stringWidth<0) { if (x+stringWidth<0) {
isAlive=false; isAlive=false;

@ -42,7 +42,7 @@ public class TextRow {
} }
private int DetermineScrollSpd() { private int DetermineScrollSpd() {
return maxX/1000+sigIRC.BASESCROLLSPD; return maxX/Math.max(1000,sigIRC.windowWidth)+sigIRC.chatScrollSpd;
} }
public static TextRow PickRandomTextRow(String username) { public static TextRow PickRandomTextRow(String username) {

@ -1,6 +1,8 @@
package sig; package sig;
import java.awt.Graphics; import java.awt.Graphics;
import javax.swing.SwingUtilities;
public class TwitchEmote { public class TwitchEmote {
Emoticon emote; Emoticon emote;
int x=0; //X Offset int x=0; //X Offset
@ -17,11 +19,15 @@ public class TwitchEmote {
public boolean run() { public boolean run() {
//this.x-=paint.TEXTSCROLLSPD; //this.x-=paint.TEXTSCROLLSPD;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
sigIRC.panel.repaint( sigIRC.panel.repaint(
Math.max(x,0), Math.max(x,0),
Math.max(y, 0), Math.max(y, 0),
Math.min(sigIRC.panel.getWidth()-x,emote.getImage().getWidth()), Math.min(sigIRC.panel.getWidth()-x,emote.getImage().getWidth()),
Math.min(sigIRC.panel.getHeight()-y,emote.getImage().getHeight())); Math.min(sigIRC.panel.getHeight()-y,emote.getImage().getHeight()));
}
});
if (x+emote.getImage().getWidth()<0 || text==null || !text.isActive()) { if (x+emote.getImage().getWidth()<0 || text==null || !text.isActive()) {
active=false; active=false;
return false; return false;

@ -4,7 +4,12 @@ import java.awt.event.ActionListener;
public class UpdateEvent implements ActionListener{ public class UpdateEvent implements ActionListener{
final static int MSGTIMER = 300; final static int MSGTIMER = 300;
final static int AUTOSAVETIMER = 600;
int last_authentication_msg = MSGTIMER; int last_authentication_msg = MSGTIMER;
int last_autosave = AUTOSAVETIMER;
long lasttime = System.currentTimeMillis();
int avgfps = 30;
int counter = 0;
@Override @Override
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
@ -15,14 +20,51 @@ public class UpdateEvent implements ActionListener{
private void UpdateAuthenticationCountdownMessage() { private void UpdateAuthenticationCountdownMessage() {
if (!sigIRC.authenticated && last_authentication_msg<MSGTIMER) { if (!sigIRC.authenticated && last_authentication_msg<MSGTIMER) {
last_authentication_msg++; last_authentication_msg++;
} } else
if (!sigIRC.authenticated && last_authentication_msg==MSGTIMER) { if (!sigIRC.authenticated && last_authentication_msg>=MSGTIMER) {
last_authentication_msg=0; last_authentication_msg=0;
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.panel.addMessage("SYSTEM: Your oauthToken was not successful. Please go to the sigIRC folder and make sure your oauthToken.txt file is correct!!! SwiftRage");
} }
if (last_autosave<AUTOSAVETIMER) {
last_authentication_msg++;
} else
if (last_autosave>=AUTOSAVETIMER) {
last_autosave=0;
sigIRC.windowX = sigIRC.window.getX();
sigIRC.windowY = sigIRC.window.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) { if (sigIRC.lastPlayedDing>0) {
sigIRC.lastPlayedDing--; sigIRC.lastPlayedDing--;
} }
updateFPSCounter();
sigIRC.window.setTitle("sigIRCv2 - "+(avgfps)+" FPS");
lasttime=System.currentTimeMillis();
}
public void updateFPSCounter() {
if (System.currentTimeMillis()-lasttime>1000/avgfps) {
//System.out.println("WARNING! Last update took "+(System.currentTimeMillis()-lasttime)+"ms! Lagging?");
if (counter<30) {
counter++;
} else {
counter=0;
avgfps--;
}
} else {
if (counter>-30) {
counter--;
} else {
counter=0;
avgfps++;
}
}
} }
public void UpdateScrollingText() { public void UpdateScrollingText() {

@ -12,6 +12,8 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -56,6 +58,20 @@ public class sigIRC{
static int dingThreshold; static int dingThreshold;
static Color backgroundcol; static Color backgroundcol;
public static BackgroundColorButton button; public static BackgroundColorButton button;
public static JFrame window;
static boolean overlayMode=false;
static boolean showWindowControls=false;
static int windowX=0;
static int windowY=0;
static int windowWidth=0;
static int windowHeight=0;
static int chatRows=3;
static int chatScrollSpd=4;
static int rowSpacing=64;
static String messageFont="Gill Sans Ultra Bold Condensed";
static String usernameFont="Gill Sans";
static String touhoumotherConsoleFont="Agency FB Bold";
static boolean touhoumothermodule_enabled=true;
public static void main(String[] args) { public static void main(String[] args) {
@ -64,8 +80,21 @@ public class sigIRC{
server = config.getProperty("server"); server = config.getProperty("server");
nickname = config.getProperty("nickname"); nickname = config.getProperty("nickname");
channel = config.getProperty("channel"); channel = config.getProperty("channel");
overlayMode = config.getBoolean("overlayMode", false);
showWindowControls = config.getBoolean("showWindowControls", true);
windowX = config.getInteger("windowX", 0);
windowY = config.getInteger("windowY", 0);
windowWidth = config.getInteger("windowWidth", (int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth());
windowHeight = config.getInteger("windowHeight", (int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight());
chatRows = config.getInteger("chatRows", 3);
chatScrollSpd = config.getInteger("chatScrollSpd", 4);
rowSpacing = config.getInteger("rowSpacing", 64);
dingThreshold = Integer.parseInt(config.getProperty("dingThreshold")); dingThreshold = Integer.parseInt(config.getProperty("dingThreshold"));
backgroundcol = new Color(Integer.parseInt(config.getProperty("backgroundColor"))); backgroundcol = new Color(Integer.parseInt(config.getProperty("backgroundColor")));
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);
DownloadAllRequiredDependencies(); DownloadAllRequiredDependencies();
@ -76,12 +105,12 @@ public class sigIRC{
WriteBreakToLogFile(); WriteBreakToLogFile();
programClock.start(); programClock.start();
InitializeRows(3); InitializeRows(chatRows);
InitializeCustomSounds(); InitializeCustomSounds();
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
createAndShowGUI(); window = createAndShowGUI();
InitializeModules(); InitializeModules();
performTwitchEmoteUpdate(); performTwitchEmoteUpdate();
@ -117,11 +146,13 @@ public class sigIRC{
} }
private static void InitializeModules() { private static void InitializeModules() {
if (touhoumothermodule_enabled) {
modules.add(new TouhouMotherModule( modules.add(new TouhouMotherModule(
new Rectangle(0,panel.getHeight()/2,320,panel.getHeight()/2), new Rectangle(0,panel.getHeight()/2,320,panel.getHeight()/2),
"Touhou Mother" "Touhou Mother"
)); ));
} }
}
private static void InitializeCustomSounds() { private static void InitializeCustomSounds() {
customsounds.add(new CustomSound("monkeyman5876", "Howler Monkeys Howling (Very Funny)-Pia8ku7jUNg.wav")); customsounds.add(new CustomSound("monkeyman5876", "Howler Monkeys Howling (Very Funny)-Pia8ku7jUNg.wav"));
@ -214,7 +245,7 @@ public class sigIRC{
private static void InitializeRows(int rowcount) { private static void InitializeRows(int rowcount) {
for (int i=0;i<rowcount;i++) { for (int i=0;i<rowcount;i++) {
rowobj.add(new TextRow(32+ROWSEPARATION*i)); rowobj.add(new TextRow(32+rowSpacing*i));
} }
} }
@ -256,17 +287,35 @@ public class sigIRC{
} }
} }
private static void createAndShowGUI() { private static JFrame createAndShowGUI() {
if (sigIRC.overlayMode && sigIRC.showWindowControls) {
JFrame.setDefaultLookAndFeelDecorated(true);
}
System.setProperty("sun.java2d.opengl", "true");
JFrame f = new JFrame("sigIRCv2"); JFrame f = new JFrame("sigIRCv2");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
if (sigIRC.overlayMode && !sigIRC.showWindowControls) {
f.setUndecorated(true);
}
sigIRC.panel = new MyPanel(); sigIRC.panel = new MyPanel();
if (sigIRC.overlayMode) {
sigIRC.panel.setOpaque(false);
}
sigIRC.panel.setBackground(sigIRC.backgroundcol); sigIRC.panel.setBackground(sigIRC.backgroundcol);
colorpanel = new ColorPanel(); colorpanel = new ColorPanel();
f.add(colorpanel); f.add(colorpanel);
f.add(sigIRC.panel); f.add(sigIRC.panel);
f.pack(); f.pack();
f.setVisible(true); f.setVisible(true);
button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,panel.getHeight()/2); f.setLocation(windowX, windowY);
f.setSize(windowWidth, windowHeight);
button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,64+rowobj.size()*rowSpacing);
if (sigIRC.overlayMode) {
f.setBackground(new Color(0,0,0,0));
f.setAlwaysOnTop(true);
}
//f.setOpacity(0.5f);
return f;
} }
public static boolean VerifyLogin(BufferedReader reader) throws IOException { public static boolean VerifyLogin(BufferedReader reader) throws IOException {

Loading…
Cancel
Save