Added Dragging Capabilities for Modules. Cleaned up Button class for

Touhou Mother Module. Removed constant dinging sound when oAuth token
does not authenticate properly.
dev
sigonasr2 7 years ago
parent d91c705403
commit 9251d09aa7
  1. 2
      .classpath
  2. 3
      .gitignore
  3. 2
      projectBuilder.xml
  4. BIN
      sigIRCv2.jar
  5. 6
      src/sig/BackgroundColorButton.java
  6. 1
      src/sig/CustomSound.java
  7. 2
      src/sig/Emoticon.java
  8. 94
      src/sig/Module.java
  9. 11
      src/sig/MyPanel.java
  10. 13
      src/sig/ScrollingText.java
  11. 7
      src/sig/UpdateEvent.java
  12. 27
      src/sig/modules/TouhouMother/KillButton.java
  13. 25
      src/sig/modules/TouhouMother/SwapButton.java
  14. 2
      src/sig/modules/TouhouMother/TimeRecord.java
  15. 66
      src/sig/modules/TouhouMother/TouhouMotherButton.java
  16. 25
      src/sig/modules/TouhouMother/UpdateButton.java
  17. 36
      src/sig/modules/TouhouMotherModule.java
  18. 2
      src/sig/modules/utils/SemiValidInteger.java
  19. 2
      src/sig/modules/utils/SemiValidString.java
  20. 10
      src/sig/sigIRC.java
  21. 4
      src/sig/utils/DrawUtils.java
  22. 2
      src/sig/utils/FileUtils.java
  23. 2
      src/sig/utils/SoundUtils.java
  24. 4
      src/sig/utils/TextUtils.java

@ -2,7 +2,7 @@
<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">
<classpathentry kind="lib" path="D:/Downloads/commons-io-2.5.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/D:/Data/commons-io-2.5-javadoc.jar!/"/>
</attributes>

3
.gitignore vendored

@ -7,4 +7,5 @@
/sigIRCv2.conf
/swap.png
/update.png
/WSplits
/WSplits
/drag_bar.png

@ -13,7 +13,7 @@
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="${dir.jarfile}/bin"/>
<zipfileset excludes="META-INF/*.SF" src="D:/Data/commons-io-2.5.jar"/>
<zipfileset excludes="META-INF/*.SF" src="D:/Downloads/commons-io-2.5.jar"/>
</jar>
</target>
</project>

Binary file not shown.

@ -11,11 +11,11 @@ import java.util.Arrays;
import javax.imageio.ImageIO;
import sig.DrawUtils;
import sig.FileUtils;
import sig.TextUtils;
import sig.sigIRC;
import sig.modules.TouhouMotherModule;
import sig.utils.DrawUtils;
import sig.utils.FileUtils;
import sig.utils.TextUtils;
public class BackgroundColorButton {
BufferedImage buttonimg;

@ -1,5 +1,6 @@
package sig;
import sig.utils.SoundUtils;
public class CustomSound {
final static int SOUNDCOOLDOWN = 108000;

@ -6,6 +6,8 @@ import java.net.URL;
import javax.imageio.ImageIO;
import sig.utils.TextUtils;
public class Emoticon {
private BufferedImage image=null;
private String emotename=null;

@ -1,43 +1,131 @@
package sig;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.Vector;
import javax.swing.SwingUtilities;
import sig.utils.DrawUtils;
import sig.utils.TextUtils;
public class Module {
protected Rectangle2D bounds;
protected boolean enabled;
protected String name;
public static BufferedImage IMG_DRAGBAR;
final protected int titleHeight;
Point dragOffset;
boolean dragging=false;
public Module(Rectangle2D bounds, String moduleName) {
this.bounds = bounds;
this.name = moduleName;
this.enabled=true;
this.titleHeight = (int)TextUtils.calculateStringBoundsFont(this.name, sigIRC.panel.userFont).getHeight();
}
public Module(Rectangle2D bounds, String moduleName, boolean enabled) {
this.bounds = bounds;
this.name = moduleName;
this(bounds, moduleName);
this.enabled=enabled;
}
protected void mouseModuleMousePress(MouseEvent ev) {
int mouseX = ev.getX();
int mouseY = ev.getY();
//System.out.println(mouseX + "," + mouseY);
enableWindowDrag(mouseX,mouseY);
mousePressed(ev);
}
private void enableWindowDrag(int mouseX, int mouseY) {
if (!dragging && inDragBounds(mouseX,mouseY)) {
//Enable dragging.
dragOffset = new Point((int)bounds.getX() - mouseX,(int)bounds.getY()-mouseY);
dragging=true;
}
}
public boolean inDragBounds(int x, int y) {
return x>=bounds.getX() && x<=bounds.getX()+bounds.getWidth() &&
y>=(int)bounds.getY()-Module.IMG_DRAGBAR.getHeight() &&
y<=(int)bounds.getY();
}
public void mousePressed(MouseEvent ev) {
}
public void mouseReleased(MouseEvent ev) {
if (dragging) {
dragging=false;
}
}
protected void moduleRun() {
dragWindow();
run();
}
private void dragWindow() {
if (dragging) {
sigIRC.panel.repaint(getDrawBounds().getBounds());
int mouseX = sigIRC.panel.lastMouseX+(int)dragOffset.getX();
int mouseY = sigIRC.panel.lastMouseY+(int)dragOffset.getY();
int oldX = (int)bounds.getX();
int oldY = (int)bounds.getY();
bounds = new Rectangle(mouseX, mouseY,(int)bounds.getWidth(),(int)bounds.getHeight());
//System.out.println(sigIRC.panel.lastMouseX+","+sigIRC.panel.lastMouseY);
ModuleDragEvent(oldX,oldY,mouseX,mouseY);
}
if (inDragBounds(sigIRC.panel.lastMouseX,sigIRC.panel.lastMouseY)) {
sigIRC.panel.setCursor(new Cursor(Cursor.MOVE_CURSOR));
} else
if (sigIRC.panel.getCursor().getType()==Cursor.MOVE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
public void run() {
}
public void draw(Graphics g) {
drawModuleHeader(g);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
sigIRC.panel.repaint(bounds.getBounds());
sigIRC.panel.repaint(getDrawBounds().getBounds());
}
});
}
private void drawModuleHeader(Graphics g) {
g.drawImage(Module.IMG_DRAGBAR,
(int)bounds.getX()+2,
(int)bounds.getY()-Module.IMG_DRAGBAR.getHeight(),
(int)bounds.getWidth()-4,
Module.IMG_DRAGBAR.getHeight(),
sigIRC.panel);
DrawUtils.drawTextFont(g, sigIRC.panel.smallFont, (int)bounds.getX(), (int)bounds.getY()-titleHeight/2+4, Color.BLACK, this.name);
}
private Rectangle2D getDrawBounds() {
Rectangle2D drawBounds = new Rectangle((int)bounds.getX(),(int)bounds.getY()-titleHeight+3,(int)bounds.getWidth(),(int)bounds.getHeight()+titleHeight);
return drawBounds;
}
public void ModuleDragEvent(int oldX, int oldY, int newX, int newY) {
}
public void mouseWheel(MouseWheelEvent ev) {
}

@ -95,7 +95,11 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
}
public void addMessage(String message) {
ScrollingText text = new ScrollingText(message,this.getWidth(),(int)(Math.random()*128));
addMessage(message,true);
}
public void addMessage(String message, boolean playSound) {
ScrollingText text = new ScrollingText(message,this.getWidth(),(int)(Math.random()*128),playSound);
TextRow row = TextRow.PickRandomTextRow(text.getUsername());
sigIRC.textobj.add(text);
row.updateRow(text);
@ -108,13 +112,16 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
@Override
public void mousePressed(MouseEvent ev) {
for (Module m : sigIRC.modules) {
m.mousePressed(ev);
m.mouseModuleMousePress(ev);
}
sigIRC.button.onClickEvent(ev);
}
@Override
public void mouseReleased(MouseEvent ev) {
for (Module m : sigIRC.modules) {
m.mouseReleased(ev);
}
}
@Override

@ -20,6 +20,11 @@ import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.SwingUtilities;
import sig.utils.DrawUtils;
import sig.utils.FileUtils;
import sig.utils.SoundUtils;
import sig.utils.TextUtils;
public class ScrollingText {
private String username;
private String message;
@ -86,8 +91,14 @@ public class ScrollingText {
this.stringWidth = (int)TextUtils.calculateStringBoundsFont(this.message,MyPanel.programFont).getWidth();
this.stringHeight = (int)TextUtils.calculateStringBoundsFont(this.message,MyPanel.programFont).getHeight();
this.userstringWidth = (int)TextUtils.calculateStringBoundsFont(this.username,MyPanel.userFont).getWidth();
}
public ScrollingText(String msg, double x, double y, boolean playSound) {
this(msg,x,y);
playMessageSound(username);
if (playSound) {
playMessageSound(username);
}
}
private void playMessageSound(String user) {

@ -24,7 +24,10 @@ public class UpdateEvent implements ActionListener{
} else
if (!sigIRC.authenticated && last_authentication_msg>=MSGTIMER) {
last_authentication_msg=0;
sigIRC.panel.addMessage("SYSTEM: Your oauthToken was not successful. Please go to the sigIRC folder and make sure your oauthToken.txt file is correct!!! SwiftRage");
sigIRC.panel.addMessage("SYSTEM: Your oauthToken was not successful. Please go to the sigIRC folder and make sure your oauthToken.txt file is correct!!! SwiftRage",!sigIRC.playedoAuthSoundOnce);
if (!sigIRC.playedoAuthSoundOnce) {
sigIRC.playedoAuthSoundOnce=true;
}
}
if (last_autosave<AUTOSAVETIMER) {
last_authentication_msg++;
@ -89,7 +92,7 @@ public class UpdateEvent implements ActionListener{
}
}
for (Module m : sigIRC.modules) {
m.run();
m.moduleRun();
}
}

@ -11,31 +11,16 @@ import java.util.Arrays;
import javax.imageio.ImageIO;
import sig.DrawUtils;
import sig.FileUtils;
import sig.TextUtils;
import sig.sigIRC;
import sig.modules.TouhouMotherModule;
import sig.utils.DrawUtils;
import sig.utils.FileUtils;
import sig.utils.TextUtils;
public class Button2 {
BufferedImage buttonimg;
int x=0;
int y=0;
TouhouMotherModule module;
public class KillButton extends TouhouMotherButton{
public Button2(TouhouMotherModule parentmodule, File filename, int x, int y) {
this.x=x;
this.y=y;
this.module=parentmodule;
try {
buttonimg = ImageIO.read(filename);
} catch (IOException e) {
e.printStackTrace();
}
}
public void draw(Graphics g) {
g.drawImage(buttonimg, x, y, sigIRC.panel);
public KillButton(TouhouMotherModule parentmodule, File filename, int x, int y) {
super(parentmodule,filename,x,y);
}
public void onClickEvent(MouseEvent ev) {

@ -17,18 +17,14 @@ import java.util.Arrays;
import javax.imageio.ImageIO;
import sig.DrawUtils;
import sig.FileUtils;
import sig.MyPanel;
import sig.TextUtils;
import sig.sigIRC;
import sig.modules.TouhouMotherModule;
import sig.utils.DrawUtils;
import sig.utils.FileUtils;
import sig.utils.TextUtils;
public class Button3 {
BufferedImage buttonimg;
int x=0;
int y=0;
TouhouMotherModule module;
public class SwapButton extends TouhouMotherButton{
final static String GAMEDIR = "D:/Documents/Games/Touhou Mother/Data/";
boolean controlKeyPressed;
@ -39,15 +35,8 @@ public class Button3 {
int slotselected=0;
public Button3(TouhouMotherModule parentmodule, File filename, int x, int y) {
this.x=x;
this.y=y;
this.module=parentmodule;
try {
buttonimg = ImageIO.read(filename);
} catch (IOException e) {
e.printStackTrace();
}
public SwapButton(TouhouMotherModule parentmodule, File filename, int x, int y) {
super(parentmodule,filename,x,y);
}
public void run() {
@ -57,7 +46,7 @@ public class Button3 {
}
public void draw(Graphics g) {
g.drawImage(buttonimg, x, y, sigIRC.panel);
super.draw(g);
if (displaytime>0) {
DrawUtils.drawOutlineText(g, MyPanel.smallFont, x+buttonimg.getWidth()+4, y+buttonimg.getHeight(), 2, Color.WHITE, new Color(60,0,150), message);
}

@ -1,8 +1,8 @@
package sig.modules.TouhouMother;
import sig.FileUtils;
import sig.sigIRC;
import sig.modules.TouhouMotherModule;
import sig.utils.FileUtils;
public class TimeRecord {
final public static int ERROR_VALUE = Integer.MAX_VALUE;

@ -0,0 +1,66 @@
package sig.modules.TouhouMother;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import sig.sigIRC;
import sig.modules.TouhouMotherModule;
public class TouhouMotherButton {
protected BufferedImage buttonimg;
protected int x=0;
protected int y=0;
protected TouhouMotherModule module;
public TouhouMotherButton(TouhouMotherModule parentmodule, File filename, int x, int y) {
this.x=x;
this.y=y;
this.module=parentmodule;
try {
buttonimg = ImageIO.read(filename);
} catch (IOException e) {
e.printStackTrace();
}
}
public void run() {
}
public void draw(Graphics g) {
g.drawImage(buttonimg, x, y, sigIRC.panel);
}
public void onClickEvent(MouseEvent ev) {
}
public void keyPressEvent(KeyEvent ev) {
}
public void keyReleaseEvent(KeyEvent ev) {
}
public void onMouseWheelEvent(MouseWheelEvent ev) {
}
public void updatePosition(int oldX, int oldY, int newX, int newY) {
int diffx = x - oldX;
int diffy = y - oldY;
x = newX + diffx;
y = newY + diffy;
/*System.out.println("Old: "+oldX+","+oldY);
System.out.println("New: "+newX+","+newY);
System.out.println("Diffs: "+diffx+","+diffy);*/
}
}

@ -11,41 +11,30 @@ import java.util.Arrays;
import javax.imageio.ImageIO;
import sig.DrawUtils;
import sig.FileUtils;
import sig.TextUtils;
import sig.sigIRC;
import sig.modules.TouhouMotherModule;
import sig.utils.DrawUtils;
import sig.utils.FileUtils;
import sig.utils.TextUtils;
public class Button {
BufferedImage buttonimg;
int x=0;
int y=0;
public class UpdateButton extends TouhouMotherButton{
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;
public UpdateButton(TouhouMotherModule parentmodule, File filename, int x, int y) {
super(parentmodule,filename,x,y);
data = FileUtils.readFromFile(sigIRC.BASEDIR+"WSplits");
if (data.length>4) {
buttonEnabled=true;
}
this.module=parentmodule;
try {
buttonimg = ImageIO.read(filename);
} catch (IOException e) {
e.printStackTrace();
}
}
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);
super.draw(g);
}
}

@ -19,22 +19,23 @@ import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.Timer;
import sig.DrawUtils;
import sig.FileUtils;
import sig.Module;
import sig.TextUtils;
import sig.sigIRC;
import sig.modules.TouhouMother.Button;
import sig.modules.TouhouMother.Button2;
import sig.modules.TouhouMother.Button3;
import sig.modules.TouhouMother.DataProperty;
import sig.modules.TouhouMother.IncreaseTouhouMotherClockCount;
import sig.modules.TouhouMother.KillButton;
import sig.modules.TouhouMother.SwapButton;
import sig.modules.TouhouMother.TimeRecord;
import sig.modules.TouhouMother.TouhouMotherBossData;
import sig.modules.TouhouMother.TouhouMotherButton;
import sig.modules.TouhouMother.TouhouMotherCharacterData;
import sig.modules.TouhouMother.TouhouPlayerCharacter;
import sig.modules.TouhouMother.UpdateButton;
import sig.modules.utils.SemiValidInteger;
import sig.modules.utils.SemiValidString;
import sig.utils.DrawUtils;
import sig.utils.FileUtils;
import sig.utils.TextUtils;
public class TouhouMotherModule extends Module implements ActionListener{
Timer filereadClock = new Timer(200,this);
@ -66,9 +67,11 @@ public class TouhouMotherModule extends Module implements ActionListener{
boolean diamondSparkyMsg = false;
Button updateButton;
Button2 killButton;
Button3 swapButton;
List<TouhouMotherButton> moduleButtons = new ArrayList<TouhouMotherButton>();
UpdateButton updateButton;
KillButton killButton;
SwapButton swapButton;
public TouhouMotherModule(Rectangle2D bounds, String moduleName) {
super(bounds, moduleName);
@ -109,6 +112,12 @@ public class TouhouMotherModule extends Module implements ActionListener{
EnableAndDisableTimer();
}
public void ModuleDragEvent(int oldX, int oldY, int newX, int newY) {
for (TouhouMotherButton tmb : moduleButtons) {
tmb.updatePosition(oldX,oldY,newX,newY);
}
}
public void draw(Graphics g) {
if (enabled) {
super.draw(g);
@ -487,15 +496,18 @@ public class TouhouMotherModule extends Module implements ActionListener{
}
private void DefineButton() {
updateButton = new Button(this, //56x20 pixels
updateButton = new UpdateButton(this, //56x20 pixels
new File(sigIRC.BASEDIR+"update.png"),
(int)bounds.getX()+320-56,(int)bounds.getY()+sigIRC.panel.getHeight()/2-20);
killButton = new Button2(this,
killButton = new KillButton(this,
new File(sigIRC.BASEDIR+"kill.png"),
(int)bounds.getX(),(int)bounds.getY()+sigIRC.panel.getHeight()/2-20);
swapButton = new Button3(this,
swapButton = new SwapButton(this,
new File(sigIRC.BASEDIR+"swap.png"),
(int)bounds.getX(),(int)bounds.getY()+sigIRC.panel.getHeight()/2-40);
moduleButtons.add(updateButton);
moduleButtons.add(killButton);
moduleButtons.add(swapButton);
}
public Rectangle2D getBounds() {

@ -2,7 +2,7 @@ package sig.modules.utils;
import java.util.Arrays;
import sig.TextUtils;
import sig.utils.TextUtils;
public class SemiValidInteger {
final public static int ERROR_VALUE = Integer.MIN_VALUE;

@ -2,7 +2,7 @@ package sig.modules.utils;
import java.util.Arrays;
import sig.TextUtils;
import sig.utils.TextUtils;
public class SemiValidString {
final public static String ERROR_VALUE = "nil";

@ -7,6 +7,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import sig.modules.TouhouMotherModule;
import sig.utils.FileUtils;
import java.awt.Color;
import java.awt.Dimension;
@ -70,11 +71,12 @@ public class sigIRC{
static int chatScrollSpd=4;
static int rowSpacing=64;
static String messageFont="Gill Sans Ultra Bold Condensed";
static String usernameFont="Gill Sans";
static String usernameFont="GillSansMTStd-Book";
static String touhoumotherConsoleFont="Agency FB Bold";
static boolean touhoumothermodule_enabled=true;
static boolean downloadsComplete=false;
static boolean hardwareAcceleration=true;
static boolean playedoAuthSoundOnce=false;
public static void main(String[] args) {
@ -148,10 +150,16 @@ public class sigIRC{
manager = new FileManager("swap.png"); manager.verifyAndFetchFileFromServer();
manager = new FileManager("update.png"); manager.verifyAndFetchFileFromServer();
manager = new FileManager("backcolor.png"); manager.verifyAndFetchFileFromServer();
manager = new FileManager("drag_bar.png"); manager.verifyAndFetchFileFromServer();
manager = new FileManager("WSplits"); manager.verifyAndFetchFileFromServer();
}
private static void InitializeModules() {
try {
Module.IMG_DRAGBAR = ImageIO.read(new File(sigIRC.BASEDIR+"drag_bar.png"));
} catch (IOException e) {
e.printStackTrace();
}
if (touhoumothermodule_enabled) {
modules.add(new TouhouMotherModule(
new Rectangle(0,panel.getHeight()/2,320,panel.getHeight()/2),

@ -1,4 +1,4 @@
package sig;
package sig.utils;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
@ -13,6 +13,8 @@ import java.awt.font.TextAttribute;
import java.awt.geom.Rectangle2D;
import java.text.AttributedString;
import sig.MyPanel;
public class DrawUtils {
public static void drawOutlineText(Graphics g, Font font, double x, double y, int outline_size, Color text_color, Color shadow_color, String message) {
AttributedString as = new AttributedString(message);

@ -1,4 +1,4 @@
package sig;
package sig.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;

@ -1,4 +1,4 @@
package sig;
package sig.utils;
import java.io.File;
import java.io.IOException;

@ -1,8 +1,10 @@
package sig;
package sig.utils;
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
import sig.sigIRC;
public class TextUtils {
public static Rectangle2D calculateStringBoundsFont(String msg, Font font) {
Loading…
Cancel
Save