Fully self-dependent program. Downloads and creates all dependencies.

Smarter text/chat management. Configuration file created for easy
modification of channel to view. Added ability to change background
color.
dev
sigonasr2 8 years ago
parent b62b02b41b
commit 109b608eeb
  1. 5
      .classpath
  2. 53
      src/sig/BackgroundColorButton.java
  3. 21
      src/sig/ColorPanel.java
  4. 93
      src/sig/ConfigFile.java
  5. 5
      src/sig/CustomSound.java
  6. 6
      src/sig/Emoticon.java
  7. 52
      src/sig/FileManager.java
  8. 6
      src/sig/MyPanel.java
  9. 28
      src/sig/ScrollingText.java
  10. 13
      src/sig/TextRow.java
  11. 29
      src/sig/UpdateEvent.java
  12. 56
      src/sig/modules/TouhouMother/Button.java
  13. 10
      src/sig/modules/TouhouMother/Button3.java
  14. 4
      src/sig/modules/TouhouMother/TimeRecord.java
  15. 8
      src/sig/modules/TouhouMother/TouhouMotherBossData.java
  16. 15
      src/sig/modules/TouhouMotherModule.java
  17. 77
      src/sig/sigIRC.java

@ -2,5 +2,10 @@
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="D:/Data/commons-io-2.5.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/D:/Data/commons-io-2.5-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

@ -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);
}
}
}
}

@ -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);
}
}

@ -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<String,String> configDefaults = new HashMap<String,String>();
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;
}
}

@ -6,6 +6,7 @@ public class CustomSound {
private int cooldown = 0; private int cooldown = 0;
private String customsound; private String customsound;
private String username; private String username;
private FileManager manager;
public String getUsername() { public String getUsername() {
return username; return username;
@ -19,6 +20,7 @@ public class CustomSound {
public CustomSound(String username, String customsound) { public CustomSound(String username, String customsound) {
this.username=username; this.username=username;
this.customsound=customsound; this.customsound=customsound;
this.manager = new FileManager("sigIRC/sounds/"+customsound);
} }
public boolean isSoundAvailable() { public boolean isSoundAvailable() {
@ -30,7 +32,8 @@ public class CustomSound {
} }
public void playCustomSound() { public void playCustomSound() {
SoundUtils.playSound(sigIRC.BASEDIR+"sounds\\"+customsound); manager.verifyAndFetchFileFromServer();
SoundUtils.playSound(sigIRC.BASEDIR+"sounds/"+customsound);
cooldown = SOUNDCOOLDOWN; cooldown = SOUNDCOOLDOWN;
} }

@ -13,7 +13,7 @@ public class Emoticon {
public Emoticon(String emoteName, URL onlinePath) { public Emoticon(String emoteName, URL onlinePath) {
try { try {
String imagePath = sigIRC.BASEDIR+"Emotes\\"+emoteName+".png"; String imagePath = sigIRC.BASEDIR+"sigIRC/Emotes/"+emoteName+".png";
File file = new File(imagePath); File file = new File(imagePath);
if (file.exists()) { if (file.exists()) {
image = ImageIO.read(file); image = ImageIO.read(file);
@ -36,7 +36,9 @@ public class Emoticon {
public Emoticon(String emoteName, String fileName) { public Emoticon(String emoteName, String fileName) {
try { 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); File file = new File(imagePath);
if (file.exists()) { if (file.exists()) {
image = ImageIO.read(file); image = ImageIO.read(file);

@ -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();
}
}
}
}
}

@ -1,5 +1,6 @@
package sig; package sig;
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;
@ -12,6 +13,7 @@ import java.awt.event.MouseListener;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener; import java.awt.event.MouseWheelListener;
import javax.swing.JColorChooser;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
@ -47,10 +49,11 @@ 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);
} }
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),sigIRC.TEXTSCROLLSPD); ScrollingText text = new ScrollingText(message,this.getWidth(),(int)(Math.random()*128));
TextRow row = TextRow.PickRandomTextRow(text.getUsername()); TextRow row = TextRow.PickRandomTextRow(text.getUsername());
sigIRC.textobj.add(text); sigIRC.textobj.add(text);
row.updateRow(text); row.updateRow(text);
@ -65,6 +68,7 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
for (Module m : sigIRC.modules) { for (Module m : sigIRC.modules) {
m.mousePressed(ev); m.mousePressed(ev);
} }
sigIRC.button.onClickEvent(ev);
} }
@Override @Override

@ -24,11 +24,11 @@ public class ScrollingText {
private String message; private String message;
private double x; private double x;
private double y; private double y;
private double scrollspd;
private int stringWidth; private int stringWidth;
private int stringHeight; private int stringHeight;
private boolean isAlive=true; private boolean isAlive=true;
private Color userColor; private Color userColor;
private TextRow myRow;
public void setX(double x) { public void setX(double x) {
this.x = x; this.x = x;
@ -65,14 +65,13 @@ public class ScrollingText {
private int userstringWidth; private int userstringWidth;
private int shadowSize; private int shadowSize;
public ScrollingText(String msg, double x, double y, double scrollspd) { public ScrollingText(String msg, double x, double y) {
LogMessageToFile(msg); LogMessageToFile(msg);
this.username = GetUsername(msg); this.username = GetUsername(msg);
this.userColor = GetUserNameColor(this.username); this.userColor = GetUserNameColor(this.username);
this.message = GetMessage(msg); this.message = GetMessage(msg);
this.x=x; this.x=x;
this.y=y; this.y=y;
this.scrollspd=scrollspd;
this.shadowSize=2; this.shadowSize=2;
@ -88,14 +87,19 @@ public class ScrollingText {
if (cs!=null && cs.isSoundAvailable()) { if (cs!=null && cs.isSoundAvailable()) {
cs.playCustomSound(); cs.playCustomSound();
} else { } else {
String soundName = sigIRC.BASEDIR+"sounds\\ping.wav"; if (sigIRC.lastPlayedDing==0 && sigIRC.dingEnabled) {
SoundUtils.playSound(soundName); 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) { private void LogMessageToFile(String message) {
Calendar cal = Calendar.getInstance(); 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) { private Color GetUserNameColor(String username) {
@ -121,7 +125,7 @@ public class ScrollingText {
} }
public boolean run() { public boolean run() {
x-=scrollspd; x-=myRow.getScrollSpd();
//System.out.println("X: "+x); //System.out.println("X: "+x);
sigIRC.panel.repaint( sigIRC.panel.repaint(
FindLeftMostCornerInDisplay(), FindLeftMostCornerInDisplay(),
@ -159,8 +163,8 @@ public class ScrollingText {
} }
} }
public int FindRightMostCornerInDisplay() { public int FindRightMostCornerInDisplay() {
if (x+stringWidth+(int)scrollspd+1+shadowSize+1>0) { if (x+stringWidth+(int)sigIRC.BASESCROLLSPD+1+shadowSize+1>0) {
return Math.min(Math.max(stringWidth,userstringWidth+8)+(int)scrollspd+1+shadowSize+1, sigIRC.panel.getWidth()-(int)x); return Math.min(Math.max(stringWidth,userstringWidth+8)+(int)sigIRC.BASESCROLLSPD+1+shadowSize+1, sigIRC.panel.getWidth()-(int)x);
} else { } else {
return 0; return 0;
} }
@ -172,6 +176,10 @@ public class ScrollingText {
return 0; return 0;
} }
} }
public void setTextRow(TextRow row) {
this.myRow=row;
}
private String GetMessage(String msg) { private String GetMessage(String msg) {
String basemsg = " "+msg.substring(msg.indexOf(":")+2, msg.length())+" "; String basemsg = " "+msg.substring(msg.indexOf(":")+2, msg.length())+" ";
@ -181,7 +189,7 @@ public class ScrollingText {
} }
private String ConvertMessageSymbols(String basemsg) { 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; return basemsg;
} }

@ -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 maxX = 0; //Defines the greatest X position of all the messages in this row.
private int ypos = 0; private int ypos = 0;
final int MESSAGE_SEPARATION=200; final int MESSAGE_SEPARATION=200;
private int scrollSpd = sigIRC.BASESCROLLSPD;
public TextRow(int ypos) { public TextRow(int ypos) {
this.ypos=ypos; this.ypos=ypos;
@ -22,18 +23,28 @@ public class TextRow {
return maxX; return maxX;
} }
public int getScrollSpd() {
return scrollSpd;
}
public void updateRow(ScrollingText text) { public void updateRow(ScrollingText text) {
text.setX(maxX+sigIRC.panel.getWidth()+MESSAGE_SEPARATION); text.setX(maxX+sigIRC.panel.getWidth()+MESSAGE_SEPARATION);
text.setY(ypos); text.setY(ypos);
text.setTextRow(this);
maxX+=text.getStringWidth()+MESSAGE_SEPARATION; maxX+=text.getStringWidth()+MESSAGE_SEPARATION;
} }
public void update() { public void update() {
scrollSpd = DetermineScrollSpd();
if (maxX>0) { if (maxX>0) {
maxX-=sigIRC.TEXTSCROLLSPD; maxX-=scrollSpd;
} }
} }
private int DetermineScrollSpd() {
return maxX/1000+sigIRC.BASESCROLLSPD;
}
public static TextRow PickRandomTextRow(String username) { public static TextRow PickRandomTextRow(String username) {
Random r = new Random(); Random r = new Random();
r.setSeed(username.hashCode()); r.setSeed(username.hashCode());

@ -3,9 +3,26 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
public class UpdateEvent implements ActionListener{ public class UpdateEvent implements ActionListener{
final static int MSGTIMER = 300;
int last_authentication_msg = MSGTIMER;
@Override @Override
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
UpdateScrollingText(); UpdateScrollingText();
UpdateAuthenticationCountdownMessage();
}
private void UpdateAuthenticationCountdownMessage() {
if (!sigIRC.authenticated && last_authentication_msg<MSGTIMER) {
last_authentication_msg++;
}
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 (sigIRC.lastPlayedDing>0) {
sigIRC.lastPlayedDing--;
}
} }
public void UpdateScrollingText() { public void UpdateScrollingText() {
@ -21,9 +38,7 @@ public class UpdateEvent implements ActionListener{
sigIRC.textobj.remove(i--); sigIRC.textobj.remove(i--);
} }
} }
for (TextRow tr : sigIRC.rowobj) { ProcessTextRows();
tr.update();
}
for (CustomSound cs : sigIRC.customsounds) { for (CustomSound cs : sigIRC.customsounds) {
if (!cs.isSoundAvailable()) { if (!cs.isSoundAvailable()) {
cs.decreaseCooldown(1); cs.decreaseCooldown(1);
@ -33,4 +48,12 @@ public class UpdateEvent implements ActionListener{
m.run(); 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);
}
} }

@ -24,11 +24,15 @@ public class Button {
String[] data; String[] data;
int currentselection=4; int currentselection=4;
TouhouMotherModule module; TouhouMotherModule module;
boolean buttonEnabled = false;
public Button(TouhouMotherModule parentmodule, File filename, int x, int y) { public Button(TouhouMotherModule parentmodule, File filename, int x, int y) {
this.x=x; this.x=x;
this.y=y; this.y=y;
data = FileUtils.readFromFile(sigIRC.BASEDIR+"..\\WSplits"); data = FileUtils.readFromFile(sigIRC.BASEDIR+"WSplits");
if (data.length>4) {
buttonEnabled=true;
}
this.module=parentmodule; this.module=parentmodule;
try { try {
buttonimg = ImageIO.read(filename); buttonimg = ImageIO.read(filename);
@ -38,31 +42,47 @@ public class Button {
} }
public void draw(Graphics g) { 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), if (buttonEnabled) {
data[currentselection].split(",")[0]); 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),
g.drawImage(buttonimg, x, y, sigIRC.panel); data[currentselection].split(",")[0]);
g.drawImage(buttonimg, x, y, sigIRC.panel);
}
} }
public void onClickEvent(MouseEvent ev) { public void onClickEvent(MouseEvent ev) {
if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() && if (buttonEnabled) {
ev.getY()>=y && ev.getY()<=y+buttonimg.getHeight()) { if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() &&
data = FileUtils.readFromFile(sigIRC.BASEDIR+"..\\WSplits"); 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)); 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(")"))); for (int i=4;i<=currentselection;i++) {
data[i]=data[i].replace("("+Integer.toString(runCount)+")", "("+Integer.toString(++runCount)+")"); 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<data.length-1;i++) {
int runCount = Integer.parseInt(data[i].substring(data[i].indexOf("(")+1, data[i].indexOf(")")));
final String pctRunString = " - "+Integer.toString((int)(((double)runCount/val)*100))+"%";
if (data[i].contains("%")) {
String pctRuns = data[i].substring(data[i].indexOf(" - "), data[i].indexOf("%")+1);
data[i]=data[i].replace(pctRuns, pctRunString);
} else {
data[i]=data[i].substring(0, data[i].indexOf(")")+1)+pctRunString+data[i].substring(data[i].indexOf(","), data[i].length());
}
}
FileUtils.writetoFile(data, sigIRC.BASEDIR+"WSplits");
} }
FileUtils.writetoFile(data, sigIRC.BASEDIR+"..\\WSplits");
} }
} }
public void onMouseWheelEvent(MouseWheelEvent ev) { public void onMouseWheelEvent(MouseWheelEvent ev) {
int nextselection = currentselection+(int)Math.signum(ev.getWheelRotation()); if (buttonEnabled) {
nextselection = LoopSelectionAround(nextselection); int nextselection = currentselection+(int)Math.signum(ev.getWheelRotation());
currentselection=nextselection; nextselection = LoopSelectionAround(nextselection);
currentselection=nextselection;
}
} }
public int LoopSelectionAround(int nextselection) { public int LoopSelectionAround(int nextselection) {

@ -29,7 +29,7 @@ public class Button3 {
int x=0; int x=0;
int y=0; int y=0;
TouhouMotherModule module; TouhouMotherModule module;
final static String GAMEDIR = "D:\\Documents\\Games\\Touhou Mother\\Data\\"; final static String GAMEDIR = "D:/Documents/Games/Touhou Mother/Data/";
boolean controlKeyPressed; boolean controlKeyPressed;
@ -125,8 +125,8 @@ public class Button3 {
String[] contents = dir.list(); String[] contents = dir.list();
for (String s : contents) { for (String s : contents) {
if (IsValidTouhouMotherSaveFile(s)) { if (IsValidTouhouMotherSaveFile(s)) {
File existingfile = new File(GAMEDIR+"SAVES"+foldernumb+"\\"+s); File existingfile = new File(GAMEDIR+"SAVES"+foldernumb+"/"+s);
File newfile = new File(GAMEDIR+"\\"+s); File newfile = new File(GAMEDIR+"/"+s);
try { try {
System.out.println("Copying file "+existingfile.getAbsolutePath()+" to "+newfile.getAbsolutePath()); System.out.println("Copying file "+existingfile.getAbsolutePath()+" to "+newfile.getAbsolutePath());
FileUtils.copyFile(existingfile, newfile); FileUtils.copyFile(existingfile, newfile);
@ -151,8 +151,8 @@ public class Button3 {
String[] contents = dir.list(); String[] contents = dir.list();
for (String s : contents) { for (String s : contents) {
if (IsValidTouhouMotherSaveFile(s)) { if (IsValidTouhouMotherSaveFile(s)) {
File newfile = new File(GAMEDIR+"SAVES"+foldernumb+"\\"+s); File newfile = new File(GAMEDIR+"SAVES"+foldernumb+"/"+s);
File existingfile = new File(GAMEDIR+"\\"+s); File existingfile = new File(GAMEDIR+"/"+s);
try { try {
System.out.println("Copying file "+existingfile.getAbsolutePath()+" to "+newfile.getAbsolutePath()); System.out.println("Copying file "+existingfile.getAbsolutePath()+" to "+newfile.getAbsolutePath());
FileUtils.copyFile(existingfile, newfile); FileUtils.copyFile(existingfile, newfile);

@ -16,7 +16,7 @@ public class TimeRecord {
} }
public static void LoadRecordDatabase() { public static void LoadRecordDatabase() {
String[] records = FileUtils.readFromFile(sigIRC.BASEDIR+"records"); String[] records = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/records");
for (String s : records) { for (String s : records) {
if (s.contains(":")) { if (s.contains(":")) {
String[] pieces = s.split(":"); String[] pieces = s.split(":");
@ -33,7 +33,7 @@ public class TimeRecord {
for (TimeRecord tr : tmm.recordDatabase) { for (TimeRecord tr : tmm.recordDatabase) {
sb.append(tr.getID()+":"+tr.getTimeRecord()+"\n"); sb.append(tr.getID()+":"+tr.getTimeRecord()+"\n");
} }
FileUtils.writetoFile(new String[]{sb.toString()}, sigIRC.BASEDIR+"records"); FileUtils.writetoFile(new String[]{sb.toString()}, sigIRC.BASEDIR+"sigIRC/records");
} }
public static int getRecord(int id) { public static int getRecord(int id) {

@ -1,16 +1,20 @@
package sig.modules.TouhouMother; package sig.modules.TouhouMother;
import sig.FileManager;
public class TouhouMotherBossData { public class TouhouMotherBossData {
private String img; private String img;
private String name; private String name;
private int hp; private int hp;
private int id; private int id;
private FileManager manager;
public TouhouMotherBossData(String name, int id, int hp, String img) { public TouhouMotherBossData(String name, int id, int hp, String img) {
this.name=name; this.name=name;
this.id=id; this.id=id;
this.hp=hp; this.hp=hp;
this.img=img; this.img=img;
this.manager = new FileManager("Boss Sprites/"+img);
} }
public String getImage() { public String getImage() {
@ -28,4 +32,8 @@ public class TouhouMotherBossData {
public int getID() { public int getID() {
return id; return id;
} }
public FileManager getFileManager() {
return manager;
}
} }

@ -90,7 +90,8 @@ public class TouhouMotherModule extends Module implements ActionListener{
@Override @Override
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
memory = FileUtils.readFromFile(sigIRC.BASEDIR+"..\\memory"); memory = FileUtils.readFromFile(sigIRC.BASEDIR+"memory");
System.out.println(Arrays.toString(memory));
if (memory.length>=14) { if (memory.length>=14) {
ProcessMemoryData(); ProcessMemoryData();
ValidateAndControlMonsterData(); ValidateAndControlMonsterData();
@ -214,7 +215,7 @@ public class TouhouMotherModule extends Module implements ActionListener{
private int calculateDataPropertyTotalValue(DataProperty property) { private int calculateDataPropertyTotalValue(DataProperty property) {
int total = 0; int total = 0;
for (TouhouMotherCharacterData tmcd : characterDatabase) { for (TouhouMotherCharacterData tmcd : characterDatabase) {
total = tmcd.getDataProperty(property); total += tmcd.getDataProperty(property);
} }
return total; return total;
} }
@ -347,7 +348,8 @@ public class TouhouMotherModule extends Module implements ActionListener{
tmcd.setCurrentDamage(0); tmcd.setCurrentDamage(0);
} }
try { 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) { } catch (IOException e) {
e.printStackTrace(); 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("KA-75", 203, 999999, "TME_203.png"));
monsterdata.add(new TouhouMotherBossData("Gensokyo", 999999, 900000, "TME_999999.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("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()]); monsterDatabase = monsterdata.toArray(new TouhouMotherBossData[monsterdata.size()]);
} }
@ -485,13 +488,13 @@ public class TouhouMotherModule extends Module implements ActionListener{
private void DefineButton() { private void DefineButton() {
updateButton = new Button(this, //56x20 pixels 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); (int)bounds.getX()+320-56,(int)bounds.getY()+sigIRC.panel.getHeight()/2-20);
killButton = new Button2(this, 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); (int)bounds.getX(),(int)bounds.getY()+sigIRC.panel.getHeight()/2-20);
swapButton = new Button3(this, 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); (int)bounds.getX(),(int)bounds.getY()+sigIRC.panel.getHeight()/2-40);
} }

@ -26,11 +26,13 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.swing.JColorChooser;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
public class sigIRC{ public class sigIRC{
public static MyPanel panel = null; public static MyPanel panel = null;
public static ColorPanel colorpanel = null;
public static List<ScrollingText> textobj = new ArrayList<ScrollingText>(); public static List<ScrollingText> textobj = new ArrayList<ScrollingText>();
public static List<TextRow> rowobj = new ArrayList<TextRow>(); public static List<TextRow> rowobj = new ArrayList<TextRow>();
public static List<Emoticon> emoticons = new ArrayList<Emoticon>(); public static List<Emoticon> emoticons = new ArrayList<Emoticon>();
@ -39,22 +41,39 @@ public class sigIRC{
public static List<Module> modules = new ArrayList<Module>(); public static List<Module> modules = new ArrayList<Module>();
static UpdateEvent updater = new UpdateEvent(); static UpdateEvent updater = new UpdateEvent();
static Timer programClock = new Timer(32,updater); 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 int ROWSEPARATION = 64;
final public static String BASEDIR = ".\\"; final public static String BASEDIR = "./";
final public static String WINDOWTITLE = "sigIRCv2"; 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) { 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]; String oauth = filedata[0];
WriteBreakToLogFile(); WriteBreakToLogFile();
programClock.start(); programClock.start();
InitializeRows(3); InitializeRows(3);
@ -71,6 +90,31 @@ public class sigIRC{
InitializeIRCConnection(server, nickname, channel, oauth); 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() { private static void InitializeModules() {
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),
@ -113,9 +157,9 @@ public class sigIRC{
public static void WriteBreakToLogFile() { public static void WriteBreakToLogFile() {
Calendar cal = Calendar.getInstance(); 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()) { 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() { /*private static void DefineEmoticons() {
//emoticons.add(new Emoticon(sigIRC.BASEDIR+"Emotes\\;).png")); //emoticons.add(new Emoticon(sigIRC.BASEDIR+"Emotes/;).png"));
File folder = new File(sigIRC.BASEDIR+"Emotes\\"); File folder = new File(sigIRC.BASEDIR+"Emotes/");
for (File f : folder.listFiles()) { for (File f : folder.listFiles()) {
emoticons.add(new Emoticon(f.getAbsolutePath())); emoticons.add(new Emoticon(f.getAbsolutePath()));
} }
@ -184,6 +228,9 @@ public class sigIRC{
} }
else { else {
// Print the raw line received by the bot. // Print the raw line received by the bot.
if (!authenticated && line.contains("372 "+nickname.toLowerCase())) {
authenticated=true;
} else
if (MessageIsAllowed(line)) { if (MessageIsAllowed(line)) {
String filteredMessage = FilterMessage(line); String filteredMessage = FilterMessage(line);
panel.addMessage(filteredMessage); panel.addMessage(filteredMessage);
@ -195,7 +242,7 @@ public class sigIRC{
private static String FilterMessage(String line) { private static String FilterMessage(String line) {
System.out.println("Original Message: "+line); System.out.println("Original Message: "+line);
String username = line.substring(1, line.indexOf("!")); String username = line.substring(1, line.indexOf("!"));
String cutstring = "#sigonitori :"; String cutstring = channel+" :";
String message = line.substring(line.indexOf(cutstring)+cutstring.length(), line.length()); String message = line.substring(line.indexOf(cutstring)+cutstring.length(), line.length());
return username+": "+ message; return username+": "+ message;
} }
@ -212,10 +259,14 @@ public class sigIRC{
JFrame f = new JFrame("sigIRCv2"); JFrame f = new JFrame("sigIRCv2");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sigIRC.panel = new MyPanel(); 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.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);
} }
public static boolean VerifyLogin(BufferedReader reader) throws IOException { public static boolean VerifyLogin(BufferedReader reader) throws IOException {

Loading…
Cancel
Save