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.
This commit is contained in:
parent
b62b02b41b
commit
109b608eeb
@ -2,5 +2,10 @@
|
||||
<classpath>
|
||||
<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="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"/>
|
||||
</classpath>
|
||||
|
53
src/sig/BackgroundColorButton.java
Normal file
53
src/sig/BackgroundColorButton.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
src/sig/ColorPanel.java
Normal file
21
src/sig/ColorPanel.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
93
src/sig/ConfigFile.java
Normal file
93
src/sig/ConfigFile.java
Normal file
@ -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 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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
52
src/sig/FileManager.java
Normal file
52
src/sig/FileManager.java
Normal 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;
|
||||
|
||||
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
|
||||
|
@ -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";
|
||||
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;
|
||||
}
|
||||
@ -173,6 +177,10 @@ public class ScrollingText {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextRow(TextRow row) {
|
||||
this.myRow=row;
|
||||
}
|
||||
|
||||
private String GetMessage(String msg) {
|
||||
String basemsg = " "+msg.substring(msg.indexOf(":")+2, msg.length())+" ";
|
||||
//basemsg = ConvertMessageSymbols(basemsg);
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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_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() {
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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,15 +42,18 @@ public class Button {
|
||||
}
|
||||
|
||||
public void draw(Graphics g) {
|
||||
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 (buttonEnabled) {
|
||||
if (ev.getX()>=x && ev.getX()<=x+buttonimg.getWidth() &&
|
||||
ev.getY()>=y && ev.getY()<=y+buttonimg.getHeight()) {
|
||||
data = FileUtils.readFromFile(sigIRC.BASEDIR+"..\\WSplits");
|
||||
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));
|
||||
@ -55,15 +62,28 @@ public class Button {
|
||||
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)+")");
|
||||
}
|
||||
FileUtils.writetoFile(data, sigIRC.BASEDIR+"..\\WSplits");
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onMouseWheelEvent(MouseWheelEvent ev) {
|
||||
if (buttonEnabled) {
|
||||
int nextselection = currentselection+(int)Math.signum(ev.getWheelRotation());
|
||||
nextselection = LoopSelectionAround(nextselection);
|
||||
currentselection=nextselection;
|
||||
}
|
||||
}
|
||||
|
||||
public int LoopSelectionAround(int nextselection) {
|
||||
if (nextselection<4) {
|
||||
|
@ -29,7 +29,7 @@ public class Button3 {
|
||||
int x=0;
|
||||
int y=0;
|
||||
TouhouMotherModule module;
|
||||
final static String GAMEDIR = "D:\\Documents\\Games\\Touhou Mother\\Data\\";
|
||||
final static String GAMEDIR = "D:/Documents/Games/Touhou Mother/Data/";
|
||||
|
||||
boolean controlKeyPressed;
|
||||
|
||||
@ -125,8 +125,8 @@ public class Button3 {
|
||||
String[] contents = dir.list();
|
||||
for (String s : contents) {
|
||||
if (IsValidTouhouMotherSaveFile(s)) {
|
||||
File existingfile = new File(GAMEDIR+"SAVES"+foldernumb+"\\"+s);
|
||||
File newfile = new File(GAMEDIR+"\\"+s);
|
||||
File existingfile = new File(GAMEDIR+"SAVES"+foldernumb+"/"+s);
|
||||
File newfile = new File(GAMEDIR+"/"+s);
|
||||
try {
|
||||
System.out.println("Copying file "+existingfile.getAbsolutePath()+" to "+newfile.getAbsolutePath());
|
||||
FileUtils.copyFile(existingfile, newfile);
|
||||
@ -151,8 +151,8 @@ public class Button3 {
|
||||
String[] contents = dir.list();
|
||||
for (String s : contents) {
|
||||
if (IsValidTouhouMotherSaveFile(s)) {
|
||||
File newfile = new File(GAMEDIR+"SAVES"+foldernumb+"\\"+s);
|
||||
File existingfile = new File(GAMEDIR+"\\"+s);
|
||||
File newfile = new File(GAMEDIR+"SAVES"+foldernumb+"/"+s);
|
||||
File existingfile = new File(GAMEDIR+"/"+s);
|
||||
try {
|
||||
System.out.println("Copying file "+existingfile.getAbsolutePath()+" to "+newfile.getAbsolutePath());
|
||||
FileUtils.copyFile(existingfile, newfile);
|
||||
|
@ -16,7 +16,7 @@ public class TimeRecord {
|
||||
}
|
||||
|
||||
public static void LoadRecordDatabase() {
|
||||
String[] records = FileUtils.readFromFile(sigIRC.BASEDIR+"records");
|
||||
String[] records = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/records");
|
||||
for (String s : records) {
|
||||
if (s.contains(":")) {
|
||||
String[] pieces = s.split(":");
|
||||
@ -33,7 +33,7 @@ public class TimeRecord {
|
||||
for (TimeRecord tr : tmm.recordDatabase) {
|
||||
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) {
|
||||
|
@ -1,16 +1,20 @@
|
||||
package sig.modules.TouhouMother;
|
||||
|
||||
import sig.FileManager;
|
||||
|
||||
public class TouhouMotherBossData {
|
||||
private String img;
|
||||
private String name;
|
||||
private int hp;
|
||||
private int id;
|
||||
private FileManager manager;
|
||||
|
||||
public TouhouMotherBossData(String name, int id, int hp, String img) {
|
||||
this.name=name;
|
||||
this.id=id;
|
||||
this.hp=hp;
|
||||
this.img=img;
|
||||
this.manager = new FileManager("Boss Sprites/"+img);
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
@ -28,4 +32,8 @@ public class TouhouMotherBossData {
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public FileManager getFileManager() {
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,8 @@ public class TouhouMotherModule extends Module implements ActionListener{
|
||||
|
||||
@Override
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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<ScrollingText> textobj = new ArrayList<ScrollingText>();
|
||||
public static List<TextRow> rowobj = new ArrayList<TextRow>();
|
||||
public static List<Emoticon> emoticons = new ArrayList<Emoticon>();
|
||||
@ -39,22 +41,39 @@ public class sigIRC{
|
||||
public static List<Module> modules = new ArrayList<Module>();
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user