diff --git a/sigIRCv2.jar b/sigIRCv2.jar index 929e0f3..a38cba0 100644 Binary files a/sigIRCv2.jar and b/sigIRCv2.jar differ diff --git a/src/sig/BackgroundColorButton.java b/src/sig/BackgroundColorButton.java index 48dd8ed..86cace3 100644 --- a/src/sig/BackgroundColorButton.java +++ b/src/sig/BackgroundColorButton.java @@ -44,9 +44,11 @@ public class BackgroundColorButton { 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); + if (sigIRC.backgroundcol!=null) { + 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 index b221627..6ad8eca 100644 --- a/src/sig/ColorPanel.java +++ b/src/sig/ColorPanel.java @@ -12,7 +12,7 @@ public class ColorPanel extends JPanel{ } public Color getBackgroundColor() { - return JColorChooser.showDialog(this, "Background Color Picker", Color.CYAN); + return JColorChooser.showDialog(this, "Background Color Picker", sigIRC.backgroundcol); } public Dimension getPreferredSize() { diff --git a/src/sig/MyPanel.java b/src/sig/MyPanel.java index fc65cd9..e907573 100644 --- a/src/sig/MyPanel.java +++ b/src/sig/MyPanel.java @@ -39,8 +39,8 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo final public static Font programFont = new Font(sigIRC.messageFont,0,24); final public static Font userFont = new Font(sigIRC.usernameFont,0,16); final public static Font smallFont = new Font(sigIRC.touhoumotherConsoleFont,0,12); - int lastMouseX = 0; - int lastMouseY = 0; + public int lastMouseX = 0; + public int lastMouseY = 0; public MyPanel() { //setBorder(BorderFactory.createLineBorder(Color.black)); diff --git a/src/sig/modules/Controller/Button.java b/src/sig/modules/Controller/Button.java index d7de4f4..357bf8c 100644 --- a/src/sig/modules/Controller/Button.java +++ b/src/sig/modules/Controller/Button.java @@ -2,9 +2,12 @@ package sig.modules.Controller; import java.awt.Color; import java.awt.Graphics; +import java.awt.geom.Rectangle2D; import net.java.games.input.Component.Identifier; +import net.java.games.input.Component; import net.java.games.input.Controller; +import sig.sigIRC; import sig.modules.ControllerModule; public class Button { @@ -18,11 +21,19 @@ public class Button { ControllerModule parent; boolean square; - public Button(double pct_x, double pct_width, double pct_y, double pct_height, Controller parent_controller, Identifier button_identifier, Color col, ControllerModule module) { - this(pct_x,pct_width,pct_y,pct_height,parent_controller,button_identifier,col,module,false); + public Button(Rectangle2D.Double rect, Controller parent_controller, Identifier button_identifier, Color col, ControllerModule module) { + this(rect.getX(),rect.getY(),rect.getWidth(),rect.getHeight(),parent_controller,button_identifier,col,module,false); } - public Button(double pct_x, double pct_width, double pct_y, double pct_height, Controller parent_controller, Identifier button_identifier, Color col, ControllerModule module, boolean square) { + public Button(Rectangle2D.Double rect, Controller parent_controller, Identifier button_identifier, Color col, ControllerModule module, boolean square) { + this(rect.getX(),rect.getY(),rect.getWidth(),rect.getHeight(),parent_controller,button_identifier,col,module,square); + } + + public Button(double pct_x, double pct_y, double pct_width, double pct_height, Controller parent_controller, Identifier button_identifier, Color col, ControllerModule module) { + this(pct_x,pct_y,pct_width,pct_height,parent_controller,button_identifier,col,module,false); + } + + public Button(double pct_x, double pct_y, double pct_width, double pct_height, Controller parent_controller, Identifier button_identifier, Color col, ControllerModule module, boolean square) { this.pct_x = pct_x; this.pct_y = pct_y; this.pct_width=pct_width; @@ -39,12 +50,56 @@ public class Button { Color col_identity = g.getColor(); g.setColor(pressed_col); g.fillOval((int)(parent.getPosition().getX() - +parent.getPosition().getWidth()*pct_x) + +parent.getControllerImage().getWidth(sigIRC.panel)*pct_x) ,(int)(parent.getPosition().getY() - +parent.getPosition().getWidth()*pct_y) - ,(int)(parent.getPosition().getWidth()*pct_width), - (int)(parent.getPosition().getWidth()*pct_height)); + +parent.getControllerImage().getHeight(sigIRC.panel)*pct_y) + ,(int)(parent.getControllerImage().getWidth(sigIRC.panel)*pct_width), + (int)(parent.getControllerImage().getHeight(sigIRC.panel)*pct_height)); g.setColor(col_identity); } } + + public String getSaveString() { + StringBuilder sb = new StringBuilder(); + sb.append(pct_x);sb.append(","); + sb.append(pct_y);sb.append(","); + sb.append(pct_width);sb.append(","); + sb.append(pct_height);sb.append(","); + sb.append(ident.getName());sb.append(","); + sb.append(pressed_col.getRed());sb.append(","); + sb.append(pressed_col.getGreen());sb.append(","); + sb.append(pressed_col.getBlue());sb.append(","); + sb.append(pressed_col.getAlpha());sb.append(","); + sb.append(square); + return sb.toString(); + } + + public static Button loadFromString(String s, Controller controller, ControllerModule module) { + String[] split = s.split(","); + return new Button( + Double.parseDouble(split[0]), + Double.parseDouble(split[1]), + Double.parseDouble(split[2]), + Double.parseDouble(split[3]), + controller, + GrabIdentifierFromString(split[4],controller), + new Color( + Integer.parseInt(split[5]), + Integer.parseInt(split[6]), + Integer.parseInt(split[7]), + Integer.parseInt(split[8]) + ), + module, + Boolean.parseBoolean(split[9])); + } + + private static Identifier GrabIdentifierFromString(String string, Controller controller) { + for (Component cp : controller.getComponents()) { + Identifier id = cp.getIdentifier(); + if (id.getName().equals(string)) { + return id; + } + } + return null; + } } diff --git a/src/sig/modules/Controller/ClickableButton.java b/src/sig/modules/Controller/ClickableButton.java index d39087f..0fad1b7 100644 --- a/src/sig/modules/Controller/ClickableButton.java +++ b/src/sig/modules/Controller/ClickableButton.java @@ -11,9 +11,9 @@ import sig.utils.DrawUtils; import sig.utils.TextUtils; public class ClickableButton { - int x,y,width,height; - String label; - ControllerModule module; + protected int x,y,width,height; + protected String label; + protected ControllerModule module; public ClickableButton(Rectangle position, String button_label, ControllerModule parent_module) { this.x = (int)position.getX(); @@ -25,14 +25,14 @@ public class ClickableButton { } public void onClickEvent(MouseEvent ev) { - if (mouseInsideBounds(ev)) { - System.out.println("Click performed!"); - } + /*if (mouseInsideBounds(ev)) { + //System.out.println("Click performed!"); + }*/ } - private boolean mouseInsideBounds(MouseEvent ev) { - return ev.getX()>=x && ev.getX()<=x+width && - ev.getY()>=y && ev.getY()<=y+height; + protected boolean mouseInsideBounds(MouseEvent ev) { + return ev.getX()>=module.getPosition().getX()+x && ev.getX()<=module.getPosition().getX()+x+width && + ev.getY()>=module.getPosition().getY()+y && ev.getY()<=module.getPosition().getY()+y+height; } public void draw(Graphics g) { diff --git a/src/sig/modules/Controller/ControlConfigurationWindow.java b/src/sig/modules/Controller/ControlConfigurationWindow.java new file mode 100644 index 0000000..9e7d63f --- /dev/null +++ b/src/sig/modules/Controller/ControlConfigurationWindow.java @@ -0,0 +1,10 @@ +package sig.modules.Controller; + +import javax.swing.JFrame; + +public class ControlConfigurationWindow extends JFrame{ + + public ControlConfigurationWindow() { + this.setVisible(true); + } +} diff --git a/src/sig/modules/Controller/EditMode.java b/src/sig/modules/Controller/EditMode.java new file mode 100644 index 0000000..e0c49c0 --- /dev/null +++ b/src/sig/modules/Controller/EditMode.java @@ -0,0 +1,10 @@ +package sig.modules.Controller; + +public enum EditMode { + DRAGSELECTION, //Drag to set size of button. + SELECTION, //Selects a button for editing + DELETESELECTION, //Delete a button. + BUTTONSET, //Asks for a controller button to set this button to. + COLORSET, + DEFAULT; +} diff --git a/src/sig/modules/Controller/clickablebutton/AddClickableButton.java b/src/sig/modules/Controller/clickablebutton/AddClickableButton.java new file mode 100644 index 0000000..34bdcd9 --- /dev/null +++ b/src/sig/modules/Controller/clickablebutton/AddClickableButton.java @@ -0,0 +1,23 @@ +package sig.modules.Controller.clickablebutton; + +import java.awt.Rectangle; +import java.awt.event.MouseEvent; + +import sig.modules.ControllerModule; +import sig.modules.Controller.ClickableButton; +import sig.modules.Controller.EditMode; + +public class AddClickableButton extends ClickableButton{ + + public AddClickableButton(Rectangle position, String button_label, ControllerModule parent_module) { + super(position, button_label, parent_module); + } + + public void onClickEvent(MouseEvent ev) { + super.onClickEvent(ev); + if (mouseInsideBounds(ev)) { + module.setMode(EditMode.DRAGSELECTION); + module.resetDragPoints(); + } + } +} diff --git a/src/sig/modules/Controller/clickablebutton/CopyClickableButton.java b/src/sig/modules/Controller/clickablebutton/CopyClickableButton.java new file mode 100644 index 0000000..ba5c989 --- /dev/null +++ b/src/sig/modules/Controller/clickablebutton/CopyClickableButton.java @@ -0,0 +1,24 @@ +package sig.modules.Controller.clickablebutton; + +import java.awt.Rectangle; +import java.awt.event.MouseEvent; + +import sig.modules.ControllerModule; +import sig.modules.Controller.ClickableButton; +import sig.modules.Controller.ControlConfigurationWindow; +import sig.modules.Controller.EditMode; + +public class CopyClickableButton extends ClickableButton{ + ControlConfigurationWindow window; + + public CopyClickableButton(Rectangle position, String button_label, ControllerModule parent_module) { + super(position, button_label, parent_module); + } + + public void onClickEvent(MouseEvent ev) { + super.onClickEvent(ev); + if (mouseInsideBounds(ev)) { + window = new ControlConfigurationWindow(); + } + } +} diff --git a/src/sig/modules/ControllerModule.java b/src/sig/modules/ControllerModule.java index 60b437a..9c9e521 100644 --- a/src/sig/modules/ControllerModule.java +++ b/src/sig/modules/ControllerModule.java @@ -1,8 +1,10 @@ package sig.modules; import java.awt.Color; +import java.awt.Cursor; import java.awt.Graphics; import java.awt.Image; +import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.geom.Rectangle2D; @@ -22,6 +24,9 @@ import sig.Module; import sig.sigIRC; import sig.modules.Controller.Button; import sig.modules.Controller.ClickableButton; +import sig.modules.Controller.EditMode; +import sig.modules.Controller.clickablebutton.AddClickableButton; +import sig.modules.Controller.clickablebutton.CopyClickableButton; import sig.utils.DrawUtils; import sig.utils.FileUtils; @@ -32,6 +37,13 @@ public class ControllerModule extends Module{ double imgratio = 1; List