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. 11
      .gitignore
  2. 25
      projectBuilder.xml
  3. BIN
      sigIRCv2.jar
  4. 2
      src/sig/BackgroundColorButton.java
  5. 27
      src/sig/ConfigFile.java
  6. 8
      src/sig/Module.java
  7. 53
      src/sig/MyPanel.java
  8. 15
      src/sig/ScrollingText.java
  9. 2
      src/sig/TextRow.java
  10. 16
      src/sig/TwitchEmote.java
  11. 46
      src/sig/UpdateEvent.java
  12. 67
      src/sig/sigIRC.java

11
.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"?>
<project name="sigIRCv2.makejar" default="makejar" basedir=".">
<target name ="makejar" description="Create a jar for the sigIRCv2 project">
<jar jarfile="sigIRCv2.jar" includes="*.class" basedir="bin"/>
</target>
</project>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project sigIRCv2">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--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>
</project>

Binary file not shown.

@ -40,7 +40,7 @@ public class BackgroundColorButton {
}
public void onClickEvent(MouseEvent ev) {
if (buttonEnabled) {
if (buttonEnabled && !sigIRC.overlayMode) {
if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() &&
ev.getY()>=y && ev.getY()<=y+buttonimg.getHeight()) {
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) {
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() {
try {
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.geom.Rectangle2D;
import javax.swing.SwingUtilities;
public class Module {
protected Rectangle2D bounds;
protected boolean enabled;
@ -29,7 +31,11 @@ public class Module {
}
public void draw(Graphics g) {
sigIRC.panel.repaint(bounds.getBounds());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
sigIRC.panel.repaint(bounds.getBounds());
}
});
}
public void mouseWheel(MouseWheelEvent ev) {

@ -7,6 +7,8 @@ import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
@ -19,16 +21,17 @@ import javax.swing.JMenuItem;
import javax.swing.JPanel;
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>();
final public static Font programFont = new Font("Gill Sans Ultra Bold Condensed",0,24);
final public static Font userFont = new Font("Gill Sans",0,16);
final public static Font smallFont = new Font("Agency FB Bold",0,12);
final public static Font programFont = new Font(sigIRC.messageFont,0,24);
final public static Font userFont = new Font(sigIRC.usernameFont,0,16);
final public static Font smallFont = new Font(sigIRC.touhoumotherConsoleFont,0,12);
public MyPanel() {
//setBorder(BorderFactory.createLineBorder(Color.black));
addMouseListener(this);
addMouseWheelListener(this);
addComponentListener(this);
addKeyListener(this);
setFocusable(true);
}
@ -58,7 +61,9 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
for (Module m : sigIRC.modules) {
m.draw(g);
}
sigIRC.button.draw(g);
if (!sigIRC.overlayMode) {
sigIRC.button.draw(g);
}
}
public void addMessage(String message) {
@ -121,4 +126,42 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
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.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.SwingUtilities;
public class ScrollingText {
private String username;
@ -127,11 +128,15 @@ public class ScrollingText {
public boolean run() {
x-=myRow.getScrollSpd();
//System.out.println("X: "+x);
sigIRC.panel.repaint(
FindLeftMostCornerInDisplay(),
FindTopMostCornerInDisplay()-32,
(int)Math.max(FindRightMostCornerInDisplay(),(int)TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getWidth())+4,
FindBottomMostCornerInDisplay()+(stringHeight*2)+4);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
sigIRC.panel.repaint(
FindLeftMostCornerInDisplay(),
FindTopMostCornerInDisplay()-32,
(int)Math.max(FindRightMostCornerInDisplay(),(int)TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getWidth())+4,
FindBottomMostCornerInDisplay()+(stringHeight*2)+4);
}
});
//sigIRC.panel.repaint();
if (x+stringWidth<0) {
isAlive=false;

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

@ -1,6 +1,8 @@
package sig;
import java.awt.Graphics;
import javax.swing.SwingUtilities;
public class TwitchEmote {
Emoticon emote;
int x=0; //X Offset
@ -17,11 +19,15 @@ public class TwitchEmote {
public boolean run() {
//this.x-=paint.TEXTSCROLLSPD;
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()));
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 (x+emote.getImage().getWidth()<0 || text==null || !text.isActive()) {
active=false;
return false;

@ -4,7 +4,12 @@ import java.awt.event.ActionListener;
public class UpdateEvent implements ActionListener{
final static int MSGTIMER = 300;
final static int AUTOSAVETIMER = 600;
int last_authentication_msg = MSGTIMER;
int last_autosave = AUTOSAVETIMER;
long lasttime = System.currentTimeMillis();
int avgfps = 30;
int counter = 0;
@Override
public void actionPerformed(ActionEvent ev) {
@ -15,14 +20,51 @@ public class UpdateEvent implements ActionListener{
private void UpdateAuthenticationCountdownMessage() {
if (!sigIRC.authenticated && last_authentication_msg<MSGTIMER) {
last_authentication_msg++;
}
if (!sigIRC.authenticated && last_authentication_msg==MSGTIMER) {
} else
if (!sigIRC.authenticated && last_authentication_msg>=MSGTIMER) {
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");
}
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) {
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() {

@ -12,6 +12,8 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@ -56,6 +58,20 @@ public class sigIRC{
static int dingThreshold;
static Color backgroundcol;
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) {
@ -64,8 +80,21 @@ public class sigIRC{
server = config.getProperty("server");
nickname = config.getProperty("nickname");
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"));
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();
@ -76,12 +105,12 @@ public class sigIRC{
WriteBreakToLogFile();
programClock.start();
InitializeRows(3);
InitializeRows(chatRows);
InitializeCustomSounds();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
window = createAndShowGUI();
InitializeModules();
performTwitchEmoteUpdate();
@ -117,10 +146,12 @@ public class sigIRC{
}
private static void InitializeModules() {
modules.add(new TouhouMotherModule(
new Rectangle(0,panel.getHeight()/2,320,panel.getHeight()/2),
"Touhou Mother"
));
if (touhoumothermodule_enabled) {
modules.add(new TouhouMotherModule(
new Rectangle(0,panel.getHeight()/2,320,panel.getHeight()/2),
"Touhou Mother"
));
}
}
private static void InitializeCustomSounds() {
@ -214,7 +245,7 @@ public class sigIRC{
private static void InitializeRows(int rowcount) {
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");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
if (sigIRC.overlayMode && !sigIRC.showWindowControls) {
f.setUndecorated(true);
}
sigIRC.panel = new MyPanel();
if (sigIRC.overlayMode) {
sigIRC.panel.setOpaque(false);
}
sigIRC.panel.setBackground(sigIRC.backgroundcol);
colorpanel = new ColorPanel();
f.add(colorpanel);
f.add(sigIRC.panel);
f.pack();
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 {

Loading…
Cancel
Save