diff --git a/.classpath b/.classpath
index 91ee9a5..fd654da 100644
--- a/.classpath
+++ b/.classpath
@@ -2,5 +2,10 @@
+
+
+
+
+
diff --git a/src/sig/BackgroundColorButton.java b/src/sig/BackgroundColorButton.java
new file mode 100644
index 0000000..7f7b9a6
--- /dev/null
+++ b/src/sig/BackgroundColorButton.java
@@ -0,0 +1,53 @@
+package sig;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+import javax.imageio.ImageIO;
+
+import sig.DrawUtils;
+import sig.FileUtils;
+import sig.TextUtils;
+import sig.sigIRC;
+import sig.modules.TouhouMotherModule;
+
+public class BackgroundColorButton {
+ BufferedImage buttonimg;
+ int x=0;
+ int y=0;
+ boolean buttonEnabled = true;
+
+ public BackgroundColorButton(File filename, int x, int y) {
+ this.x=x;
+ this.y=y;
+ try {
+ buttonimg = ImageIO.read(filename);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void draw(Graphics g) {
+ if (buttonEnabled) {
+ g.drawImage(buttonimg, x, y, sigIRC.panel);
+ }
+ }
+
+ public void onClickEvent(MouseEvent ev) {
+ if (buttonEnabled) {
+ if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() &&
+ ev.getY()>=y && ev.getY()<=y+buttonimg.getHeight()) {
+ sigIRC.backgroundcol=sigIRC.colorpanel.getBackgroundColor();
+ sigIRC.config.setProperty("backgroundColor", Integer.toString(sigIRC.backgroundcol.getRGB()));
+ sigIRC.config.saveProperties();
+ sigIRC.panel.setBackground(sigIRC.backgroundcol);
+ }
+ }
+ }
+}
diff --git a/src/sig/ColorPanel.java b/src/sig/ColorPanel.java
new file mode 100644
index 0000000..b221627
--- /dev/null
+++ b/src/sig/ColorPanel.java
@@ -0,0 +1,21 @@
+package sig;
+
+import java.awt.Color;
+import java.awt.Dimension;
+
+import javax.swing.JColorChooser;
+import javax.swing.JPanel;
+
+public class ColorPanel extends JPanel{
+ public ColorPanel() {
+
+ }
+
+ public Color getBackgroundColor() {
+ return JColorChooser.showDialog(this, "Background Color Picker", Color.CYAN);
+ }
+
+ public Dimension getPreferredSize() {
+ return new Dimension(640,480);
+ }
+}
diff --git a/src/sig/ConfigFile.java b/src/sig/ConfigFile.java
new file mode 100644
index 0000000..4ee16e7
--- /dev/null
+++ b/src/sig/ConfigFile.java
@@ -0,0 +1,93 @@
+package sig;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Properties;
+
+public class ConfigFile {
+ String basepath;
+ Properties properties;
+ public static HashMap configDefaults = new HashMap();
+
+ public static void configureDefaultConfiguration() {
+ configDefaults.put("server", "irc.chat.twitch.tv");
+ configDefaults.put("nickname", "SigoNitori");
+ configDefaults.put("channel", "#sigonitori");
+ configDefaults.put("dingThreshold", "6");
+ configDefaults.put("backgroundColor", Integer.toString(Color.CYAN.getRGB()));
+ }
+
+ public static void setAllDefaultProperties(ConfigFile conf) {
+ for (String key : configDefaults.keySet()) {
+ conf.setProperty(key, configDefaults.get(key));
+ }
+ }
+
+ public ConfigFile(String basepath) {
+ this.basepath=basepath;
+ properties = new Properties();
+ try {
+ FileReader reader = GetFileReader(this.basepath);
+ if (reader!=null) {
+ properties.load(reader);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getProperty(String key) {
+ String val = properties.getProperty(key);
+ if (val==null) {
+ if (configDefaults.containsKey(key)) {
+ this.setProperty(key, configDefaults.get(key));
+ this.saveProperties();
+ return properties.getProperty(key);
+ } else {
+ return null;
+ }
+ } else {
+ return val;
+ }
+ }
+
+ public void setProperty(String key, String value) {
+ properties.setProperty(key, value);
+ }
+
+ public void saveProperties() {
+ try {
+ properties.store(GetFileWriter(basepath), "Properties file for sigIRCv2\n");
+ System.out.println("Properties successfully saved.");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private FileReader GetFileReader(String basepath) {
+ File file = new File(sigIRC.BASEDIR+basepath);
+ if (file.exists()) {
+ try {
+ return new FileReader(file);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ private FileWriter GetFileWriter(String basepath) {
+ File file = new File(sigIRC.BASEDIR+basepath);
+ try {
+ return new FileWriter(file,false);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/src/sig/CustomSound.java b/src/sig/CustomSound.java
index 94bcadf..888c6c7 100644
--- a/src/sig/CustomSound.java
+++ b/src/sig/CustomSound.java
@@ -6,6 +6,7 @@ public class CustomSound {
private int cooldown = 0;
private String customsound;
private String username;
+ private FileManager manager;
public String getUsername() {
return username;
@@ -19,6 +20,7 @@ public class CustomSound {
public CustomSound(String username, String customsound) {
this.username=username;
this.customsound=customsound;
+ this.manager = new FileManager("sigIRC/sounds/"+customsound);
}
public boolean isSoundAvailable() {
@@ -30,7 +32,8 @@ public class CustomSound {
}
public void playCustomSound() {
- SoundUtils.playSound(sigIRC.BASEDIR+"sounds\\"+customsound);
+ manager.verifyAndFetchFileFromServer();
+ SoundUtils.playSound(sigIRC.BASEDIR+"sounds/"+customsound);
cooldown = SOUNDCOOLDOWN;
}
diff --git a/src/sig/Emoticon.java b/src/sig/Emoticon.java
index e973cf7..72fae90 100644
--- a/src/sig/Emoticon.java
+++ b/src/sig/Emoticon.java
@@ -13,7 +13,7 @@ public class Emoticon {
public Emoticon(String emoteName, URL onlinePath) {
try {
- String imagePath = sigIRC.BASEDIR+"Emotes\\"+emoteName+".png";
+ String imagePath = sigIRC.BASEDIR+"sigIRC/Emotes/"+emoteName+".png";
File file = new File(imagePath);
if (file.exists()) {
image = ImageIO.read(file);
@@ -36,7 +36,9 @@ public class Emoticon {
public Emoticon(String emoteName, String fileName) {
try {
- String imagePath = sigIRC.BASEDIR+"Emotes\\"+fileName+".png";
+ FileManager manager = new FileManager("sigIRC/Emotes/"+fileName+".png");
+ manager.verifyAndFetchFileFromServer();
+ String imagePath = sigIRC.BASEDIR+"sigIRC/Emotes/"+fileName+".png";
File file = new File(imagePath);
if (file.exists()) {
image = ImageIO.read(file);
diff --git a/src/sig/FileManager.java b/src/sig/FileManager.java
new file mode 100644
index 0000000..462d848
--- /dev/null
+++ b/src/sig/FileManager.java
@@ -0,0 +1,52 @@
+package sig;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class FileManager {
+ String fileloc;
+ final String serverURL = "http://45.33.13.215/sigIRCv2/";
+ boolean folder=false;
+
+ public FileManager(String location) {
+ this.fileloc=location;
+ this.folder=false;
+ }
+
+ public FileManager(String location, boolean folder) {
+ this.fileloc=location;
+ this.folder=folder;
+ }
+
+ public String getRelativeFileLocation() {
+ return fileloc;
+ }
+
+ public void verifyAndFetchFileFromServer() {
+ File file = new File(sigIRC.BASEDIR+fileloc);
+ if (folder) {
+ if (!file.exists()) {
+ System.out.println("Could not find "+file.getAbsolutePath()+", creating Folder "+file.getName()+".");
+ if (file.mkdirs()) {
+ System.out.println(" >> Successfully created "+file.getAbsolutePath()+".");
+ }
+ }
+ } else {
+ if (!file.exists()) {
+ System.out.println("Could not find "+file.getAbsolutePath()+", retrieving file online from "+serverURL+file.getName()+".");
+ try {
+ org.apache.commons.io.FileUtils.copyURLToFile(new URL(serverURL+fileloc),file);
+ if (file.exists()) {
+ System.out.println(" >> Successfully downloaded "+file.getAbsolutePath()+".");
+ }
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
diff --git a/src/sig/MyPanel.java b/src/sig/MyPanel.java
index 1c7a68c..86afae9 100644
--- a/src/sig/MyPanel.java
+++ b/src/sig/MyPanel.java
@@ -1,5 +1,6 @@
package sig;
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
@@ -12,6 +13,7 @@ import java.awt.event.MouseListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
+import javax.swing.JColorChooser;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
@@ -47,10 +49,11 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
for (Module m : sigIRC.modules) {
m.draw(g);
}
+ sigIRC.button.draw(g);
}
public void addMessage(String message) {
- ScrollingText text = new ScrollingText(message,this.getWidth(),(int)(Math.random()*128),sigIRC.TEXTSCROLLSPD);
+ ScrollingText text = new ScrollingText(message,this.getWidth(),(int)(Math.random()*128));
TextRow row = TextRow.PickRandomTextRow(text.getUsername());
sigIRC.textobj.add(text);
row.updateRow(text);
@@ -65,6 +68,7 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
for (Module m : sigIRC.modules) {
m.mousePressed(ev);
}
+ sigIRC.button.onClickEvent(ev);
}
@Override
diff --git a/src/sig/ScrollingText.java b/src/sig/ScrollingText.java
index 4880a26..1b11f15 100644
--- a/src/sig/ScrollingText.java
+++ b/src/sig/ScrollingText.java
@@ -24,11 +24,11 @@ public class ScrollingText {
private String message;
private double x;
private double y;
- private double scrollspd;
private int stringWidth;
private int stringHeight;
private boolean isAlive=true;
private Color userColor;
+ private TextRow myRow;
public void setX(double x) {
this.x = x;
@@ -65,14 +65,13 @@ public class ScrollingText {
private int userstringWidth;
private int shadowSize;
- public ScrollingText(String msg, double x, double y, double scrollspd) {
+ public ScrollingText(String msg, double x, double y) {
LogMessageToFile(msg);
this.username = GetUsername(msg);
this.userColor = GetUserNameColor(this.username);
this.message = GetMessage(msg);
this.x=x;
this.y=y;
- this.scrollspd=scrollspd;
this.shadowSize=2;
@@ -88,14 +87,19 @@ public class ScrollingText {
if (cs!=null && cs.isSoundAvailable()) {
cs.playCustomSound();
} else {
- String soundName = sigIRC.BASEDIR+"sounds\\ping.wav";
- SoundUtils.playSound(soundName);
+ if (sigIRC.lastPlayedDing==0 && sigIRC.dingEnabled) {
+ String soundName = sigIRC.BASEDIR+"sigIRC/sounds/ping.wav";
+ FileManager manager = new FileManager("sigIRC/sounds/ping.wav");
+ manager.verifyAndFetchFileFromServer();
+ SoundUtils.playSound(soundName);
+ sigIRC.lastPlayedDing=sigIRC.DINGTIMER;
+ }
}
}
private void LogMessageToFile(String message) {
Calendar cal = Calendar.getInstance();
- FileUtils.logToFile(message, sigIRC.BASEDIR+"logs\\log_"+(cal.get(Calendar.MONTH)+1)+"_"+cal.get(Calendar.DAY_OF_MONTH)+"_"+cal.get(Calendar.YEAR)+".txt");
+ FileUtils.logToFile(message, sigIRC.BASEDIR+"sigIRC/logs/log_"+(cal.get(Calendar.MONTH)+1)+"_"+cal.get(Calendar.DAY_OF_MONTH)+"_"+cal.get(Calendar.YEAR)+".txt");
}
private Color GetUserNameColor(String username) {
@@ -121,7 +125,7 @@ public class ScrollingText {
}
public boolean run() {
- x-=scrollspd;
+ x-=myRow.getScrollSpd();
//System.out.println("X: "+x);
sigIRC.panel.repaint(
FindLeftMostCornerInDisplay(),
@@ -159,8 +163,8 @@ public class ScrollingText {
}
}
public int FindRightMostCornerInDisplay() {
- if (x+stringWidth+(int)scrollspd+1+shadowSize+1>0) {
- return Math.min(Math.max(stringWidth,userstringWidth+8)+(int)scrollspd+1+shadowSize+1, sigIRC.panel.getWidth()-(int)x);
+ 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);
} else {
return 0;
}
@@ -172,6 +176,10 @@ public class ScrollingText {
return 0;
}
}
+
+ public void setTextRow(TextRow row) {
+ this.myRow=row;
+ }
private String GetMessage(String msg) {
String basemsg = " "+msg.substring(msg.indexOf(":")+2, msg.length())+" ";
@@ -181,7 +189,7 @@ public class ScrollingText {
}
private String ConvertMessageSymbols(String basemsg) {
- basemsg = basemsg.replace("/", "SLASH").replace(":", "COLON").replace("\\", "BACKSLASH").replace("|", "BAR").replace(">", "GREATERTHAN").replace("<", "LESSTHAN");
+ basemsg = basemsg.replace("/", "SLASH").replace(":", "COLON").replace("/", "BACKSLASH").replace("|", "BAR").replace(">", "GREATERTHAN").replace("<", "LESSTHAN");
return basemsg;
}
diff --git a/src/sig/TextRow.java b/src/sig/TextRow.java
index 6234207..a24b429 100644
--- a/src/sig/TextRow.java
+++ b/src/sig/TextRow.java
@@ -5,6 +5,7 @@ public class TextRow {
private int maxX = 0; //Defines the greatest X position of all the messages in this row.
private int ypos = 0;
final int MESSAGE_SEPARATION=200;
+ private int scrollSpd = sigIRC.BASESCROLLSPD;
public TextRow(int ypos) {
this.ypos=ypos;
@@ -22,18 +23,28 @@ public class TextRow {
return maxX;
}
+ public int getScrollSpd() {
+ return scrollSpd;
+ }
+
public void updateRow(ScrollingText text) {
text.setX(maxX+sigIRC.panel.getWidth()+MESSAGE_SEPARATION);
text.setY(ypos);
+ text.setTextRow(this);
maxX+=text.getStringWidth()+MESSAGE_SEPARATION;
}
public void update() {
+ scrollSpd = DetermineScrollSpd();
if (maxX>0) {
- maxX-=sigIRC.TEXTSCROLLSPD;
+ maxX-=scrollSpd;
}
}
+ private int DetermineScrollSpd() {
+ return maxX/1000+sigIRC.BASESCROLLSPD;
+ }
+
public static TextRow PickRandomTextRow(String username) {
Random r = new Random();
r.setSeed(username.hashCode());
diff --git a/src/sig/UpdateEvent.java b/src/sig/UpdateEvent.java
index df4a8d6..eb23ad0 100644
--- a/src/sig/UpdateEvent.java
+++ b/src/sig/UpdateEvent.java
@@ -3,9 +3,26 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class UpdateEvent implements ActionListener{
+ final static int MSGTIMER = 300;
+ int last_authentication_msg = MSGTIMER;
+
@Override
public void actionPerformed(ActionEvent ev) {
UpdateScrollingText();
+ UpdateAuthenticationCountdownMessage();
+ }
+
+ private void UpdateAuthenticationCountdownMessage() {
+ if (!sigIRC.authenticated && last_authentication_msg0) {
+ sigIRC.lastPlayedDing--;
+ }
}
public void UpdateScrollingText() {
@@ -21,9 +38,7 @@ public class UpdateEvent implements ActionListener{
sigIRC.textobj.remove(i--);
}
}
- for (TextRow tr : sigIRC.rowobj) {
- tr.update();
- }
+ ProcessTextRows();
for (CustomSound cs : sigIRC.customsounds) {
if (!cs.isSoundAvailable()) {
cs.decreaseCooldown(1);
@@ -33,4 +48,12 @@ public class UpdateEvent implements ActionListener{
m.run();
}
}
+
+ 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);
+ }
}
diff --git a/src/sig/modules/TouhouMother/Button.java b/src/sig/modules/TouhouMother/Button.java
index f4f4d6a..160ef69 100644
--- a/src/sig/modules/TouhouMother/Button.java
+++ b/src/sig/modules/TouhouMother/Button.java
@@ -24,11 +24,15 @@ public class Button {
String[] data;
int currentselection=4;
TouhouMotherModule module;
+ boolean buttonEnabled = false;
public Button(TouhouMotherModule parentmodule, File filename, int x, int y) {
this.x=x;
this.y=y;
- data = FileUtils.readFromFile(sigIRC.BASEDIR+"..\\WSplits");
+ data = FileUtils.readFromFile(sigIRC.BASEDIR+"WSplits");
+ if (data.length>4) {
+ buttonEnabled=true;
+ }
this.module=parentmodule;
try {
buttonimg = ImageIO.read(filename);
@@ -38,31 +42,47 @@ public class Button {
}
public void draw(Graphics g) {
- DrawUtils.drawOutlineText(g, sigIRC.panel.smallFont, x-TextUtils.calculateStringBoundsFont(data[currentselection].split(",")[0], sigIRC.panel.smallFont).getWidth(), (int)module.getBounds().getY()+(int)module.getBounds().getHeight()-8, 1, Color.WHITE, new Color(30,0,86,255),
- data[currentselection].split(",")[0]);
- g.drawImage(buttonimg, x, y, sigIRC.panel);
+ if (buttonEnabled) {
+ DrawUtils.drawOutlineText(g, sigIRC.panel.smallFont, x-TextUtils.calculateStringBoundsFont(data[currentselection].split(",")[0], sigIRC.panel.smallFont).getWidth(), (int)module.getBounds().getY()+(int)module.getBounds().getHeight()-8, 1, Color.WHITE, new Color(30,0,86,255),
+ data[currentselection].split(",")[0]);
+ g.drawImage(buttonimg, x, y, sigIRC.panel);
+ }
}
public void onClickEvent(MouseEvent ev) {
- if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() &&
- ev.getY()>=y && ev.getY()<=y+buttonimg.getHeight()) {
- data = FileUtils.readFromFile(sigIRC.BASEDIR+"..\\WSplits");
-
- int val = Integer.parseInt(data[1].replace("Attempts=", ""));
- data[1]=data[1].replace(Integer.toString(val), Integer.toString(++val));
-
- for (int i=4;i<=currentselection;i++) {
- int runCount = Integer.parseInt(data[i].substring(data[i].indexOf("(")+1, data[i].indexOf(")")));
- data[i]=data[i].replace("("+Integer.toString(runCount)+")", "("+Integer.toString(++runCount)+")");
+ if (buttonEnabled) {
+ if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() &&
+ ev.getY()>=y && ev.getY()<=y+buttonimg.getHeight()) {
+ data = FileUtils.readFromFile(sigIRC.BASEDIR+"WSplits");
+
+ int val = Integer.parseInt(data[1].replace("Attempts=", ""));
+ data[1]=data[1].replace(Integer.toString(val), Integer.toString(++val));
+
+ for (int i=4;i<=currentselection;i++) {
+ int runCount = Integer.parseInt(data[i].substring(data[i].indexOf("(")+1, data[i].indexOf(")")));
+ data[i]=data[i].replace("("+Integer.toString(runCount)+")", "("+Integer.toString(++runCount)+")");
+ }
+ for (int i=4;i=14) {
ProcessMemoryData();
ValidateAndControlMonsterData();
@@ -214,7 +215,7 @@ public class TouhouMotherModule extends Module implements ActionListener{
private int calculateDataPropertyTotalValue(DataProperty property) {
int total = 0;
for (TouhouMotherCharacterData tmcd : characterDatabase) {
- total = tmcd.getDataProperty(property);
+ total += tmcd.getDataProperty(property);
}
return total;
}
@@ -347,7 +348,8 @@ public class TouhouMotherModule extends Module implements ActionListener{
tmcd.setCurrentDamage(0);
}
try {
- bossImage = ImageIO.read(new File(sigIRC.BASEDIR+"..\\Boss Sprites\\"+currentBoss.getImage()));
+ currentBoss.getFileManager().verifyAndFetchFileFromServer();
+ bossImage = ImageIO.read(new File(sigIRC.BASEDIR+"Boss Sprites/"+currentBoss.getImage()));
} catch (IOException e) {
e.printStackTrace();
}
@@ -443,6 +445,7 @@ public class TouhouMotherModule extends Module implements ActionListener{
monsterdata.add(new TouhouMotherBossData("KA-75", 203, 999999, "TME_203.png"));
monsterdata.add(new TouhouMotherBossData("Gensokyo", 999999, 900000, "TME_999999.png"));
monsterdata.add(new TouhouMotherBossData("Miss Satori", 108, 900000, "TME_108.png"));
+ monsterdata.add(new TouhouMotherBossData("Only God", 48, 4010, "TME_48.png"));
monsterDatabase = monsterdata.toArray(new TouhouMotherBossData[monsterdata.size()]);
}
@@ -485,13 +488,13 @@ public class TouhouMotherModule extends Module implements ActionListener{
private void DefineButton() {
updateButton = new Button(this, //56x20 pixels
- new File(sigIRC.BASEDIR+"..\\update.png"),
+ new File(sigIRC.BASEDIR+"update.png"),
(int)bounds.getX()+320-56,(int)bounds.getY()+sigIRC.panel.getHeight()/2-20);
killButton = new Button2(this,
- new File(sigIRC.BASEDIR+"..\\kill.png"),
+ new File(sigIRC.BASEDIR+"kill.png"),
(int)bounds.getX(),(int)bounds.getY()+sigIRC.panel.getHeight()/2-20);
swapButton = new Button3(this,
- new File(sigIRC.BASEDIR+"..\\swap.png"),
+ new File(sigIRC.BASEDIR+"swap.png"),
(int)bounds.getX(),(int)bounds.getY()+sigIRC.panel.getHeight()/2-40);
}
diff --git a/src/sig/sigIRC.java b/src/sig/sigIRC.java
index 07c91e8..aec1359 100644
--- a/src/sig/sigIRC.java
+++ b/src/sig/sigIRC.java
@@ -26,11 +26,13 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
+import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class sigIRC{
public static MyPanel panel = null;
+ public static ColorPanel colorpanel = null;
public static List textobj = new ArrayList();
public static List rowobj = new ArrayList();
public static List emoticons = new ArrayList();
@@ -39,22 +41,39 @@ public class sigIRC{
public static List modules = new ArrayList();
static UpdateEvent updater = new UpdateEvent();
static Timer programClock = new Timer(32,updater);
- final public static int TEXTSCROLLSPD = 4;
+ final public static int BASESCROLLSPD = 4;
final public static int ROWSEPARATION = 64;
- final public static String BASEDIR = ".\\";
+ final public static String BASEDIR = "./";
final public static String WINDOWTITLE = "sigIRCv2";
+ static ConfigFile config;
+ static String server;
+ static String nickname;
+ static String channel;
+ public static boolean authenticated=false;
+ public static int lastPlayedDing=0;
+ final public static int DINGTIMER=150;
+ static boolean dingEnabled=true;
+ static int dingThreshold;
+ static Color backgroundcol;
+ public static BackgroundColorButton button;
public static void main(String[] args) {
- String server = "irc.chat.twitch.tv";
- String nickname = "SigoNitori";
- String channel = "#sigonitori";
- String[] filedata = FileUtils.readFromFile(BASEDIR+"oauthToken.txt");
+ config = InitializeConfigurationFile();
+
+ server = config.getProperty("server");
+ nickname = config.getProperty("nickname");
+ channel = config.getProperty("channel");
+ dingThreshold = Integer.parseInt(config.getProperty("dingThreshold"));
+ backgroundcol = new Color(Integer.parseInt(config.getProperty("backgroundColor")));
+
+ DownloadAllRequiredDependencies();
+
+ String[] filedata = FileUtils.readFromFile(BASEDIR+"sigIRC/oauthToken.txt");
String oauth = filedata[0];
WriteBreakToLogFile();
-
programClock.start();
InitializeRows(3);
@@ -71,6 +90,31 @@ public class sigIRC{
InitializeIRCConnection(server, nickname, channel, oauth);
}
+ private static ConfigFile InitializeConfigurationFile() {
+ ConfigFile.configureDefaultConfiguration();
+ final String configname = "sigIRCv2.conf";
+ File config = new File(BASEDIR+configname);
+ ConfigFile conf = new ConfigFile(configname);
+ if (!config.exists()) {
+ ConfigFile.setAllDefaultProperties(conf);
+ conf.saveProperties();
+ }
+ return conf;
+ }
+
+ public static void DownloadAllRequiredDependencies() {
+ FileManager manager = new FileManager("sigIRC/oauthToken.txt"); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("sigIRC/Emotes/",true); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("sigIRC/logs/",true); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("sigIRC/sounds/",true); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("sigIRC/record"); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("kill.png"); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("memory"); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("swap.png"); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("update.png"); manager.verifyAndFetchFileFromServer();
+ manager = new FileManager("WSplits"); manager.verifyAndFetchFileFromServer();
+ }
+
private static void InitializeModules() {
modules.add(new TouhouMotherModule(
new Rectangle(0,panel.getHeight()/2,320,panel.getHeight()/2),
@@ -113,9 +157,9 @@ public class sigIRC{
public static void WriteBreakToLogFile() {
Calendar cal = Calendar.getInstance();
- File file = new File(BASEDIR+"logs\\log_"+(cal.get(Calendar.MONTH)+1)+"_"+cal.get(Calendar.DAY_OF_MONTH)+"_"+cal.get(Calendar.YEAR)+".txt");
+ File file = new File(BASEDIR+"logs/log_"+(cal.get(Calendar.MONTH)+1)+"_"+cal.get(Calendar.DAY_OF_MONTH)+"_"+cal.get(Calendar.YEAR)+".txt");
if (file.exists()) {
- FileUtils.logToFile("\n---------------------------\n", BASEDIR+"logs\\log_"+(cal.get(Calendar.MONTH)+1)+"_"+cal.get(Calendar.DAY_OF_MONTH)+"_"+cal.get(Calendar.YEAR)+".txt");
+ FileUtils.logToFile("\n---------------------------\n", BASEDIR+"logs/log_"+(cal.get(Calendar.MONTH)+1)+"_"+cal.get(Calendar.DAY_OF_MONTH)+"_"+cal.get(Calendar.YEAR)+".txt");
}
}
@@ -160,8 +204,8 @@ public class sigIRC{
}
/*private static void DefineEmoticons() {
- //emoticons.add(new Emoticon(sigIRC.BASEDIR+"Emotes\\;).png"));
- File folder = new File(sigIRC.BASEDIR+"Emotes\\");
+ //emoticons.add(new Emoticon(sigIRC.BASEDIR+"Emotes/;).png"));
+ File folder = new File(sigIRC.BASEDIR+"Emotes/");
for (File f : folder.listFiles()) {
emoticons.add(new Emoticon(f.getAbsolutePath()));
}
@@ -184,6 +228,9 @@ public class sigIRC{
}
else {
// Print the raw line received by the bot.
+ if (!authenticated && line.contains("372 "+nickname.toLowerCase())) {
+ authenticated=true;
+ } else
if (MessageIsAllowed(line)) {
String filteredMessage = FilterMessage(line);
panel.addMessage(filteredMessage);
@@ -195,7 +242,7 @@ public class sigIRC{
private static String FilterMessage(String line) {
System.out.println("Original Message: "+line);
String username = line.substring(1, line.indexOf("!"));
- String cutstring = "#sigonitori :";
+ String cutstring = channel+" :";
String message = line.substring(line.indexOf(cutstring)+cutstring.length(), line.length());
return username+": "+ message;
}
@@ -212,10 +259,14 @@ public class sigIRC{
JFrame f = new JFrame("sigIRCv2");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sigIRC.panel = new MyPanel();
- sigIRC.panel.setBackground(Color.CYAN);
+ 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);
}
public static boolean VerifyLogin(BufferedReader reader) throws IOException {