diff --git a/sigIRCv2.jar b/sigIRCv2.jar index a38cba0..ce95b53 100644 Binary files a/sigIRCv2.jar and b/sigIRCv2.jar differ diff --git a/src/sig/modules/Controller/Button.java b/src/sig/modules/Controller/Button.java index 357bf8c..32e344a 100644 --- a/src/sig/modules/Controller/Button.java +++ b/src/sig/modules/Controller/Button.java @@ -16,24 +16,25 @@ public class Button { double pct_width = 0; double pct_height = 0; Identifier ident; + float value; Controller parent_controller; Color pressed_col; ControllerModule parent; boolean square; - 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(Rectangle2D.Double rect, Controller parent_controller, Identifier button_identifier, float button_val, Color col, ControllerModule module) { + this(rect.getX(),rect.getY(),rect.getWidth(),rect.getHeight(),parent_controller,button_identifier,button_val,col,module,false); } - 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(Rectangle2D.Double rect, Controller parent_controller, Identifier button_identifier, float button_val, Color col, ControllerModule module, boolean square) { + this(rect.getX(),rect.getY(),rect.getWidth(),rect.getHeight(),parent_controller,button_identifier,button_val,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, float button_val, Color col, ControllerModule module) { + this(pct_x,pct_y,pct_width,pct_height,parent_controller,button_identifier,button_val,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) { + public Button(double pct_x, double pct_y, double pct_width, double pct_height, Controller parent_controller, Identifier button_identifier, float button_val, Color col, ControllerModule module, boolean square) { this.pct_x = pct_x; this.pct_y = pct_y; this.pct_width=pct_width; @@ -43,10 +44,11 @@ public class Button { this.pressed_col=col; this.parent = module; this.square = square; + this.value = button_val; } public void draw(Graphics g) { - if (parent_controller.getComponent(ident).getPollData()==1) { + if (parent_controller.getComponent(ident).getPollData()==value) { Color col_identity = g.getColor(); g.setColor(pressed_col); g.fillOval((int)(parent.getPosition().getX() @@ -66,6 +68,7 @@ public class Button { sb.append(pct_width);sb.append(","); sb.append(pct_height);sb.append(","); sb.append(ident.getName());sb.append(","); + sb.append(value);sb.append(","); sb.append(pressed_col.getRed());sb.append(","); sb.append(pressed_col.getGreen());sb.append(","); sb.append(pressed_col.getBlue());sb.append(","); @@ -76,21 +79,23 @@ public class Button { public static Button loadFromString(String s, Controller controller, ControllerModule module) { String[] split = s.split(","); + int i=0; return new Button( - Double.parseDouble(split[0]), - Double.parseDouble(split[1]), - Double.parseDouble(split[2]), - Double.parseDouble(split[3]), + Double.parseDouble(split[i++]), + Double.parseDouble(split[i++]), + Double.parseDouble(split[i++]), + Double.parseDouble(split[i++]), controller, - GrabIdentifierFromString(split[4],controller), + GrabIdentifierFromString(split[i++],controller), + Float.parseFloat(split[i++]), new Color( - Integer.parseInt(split[5]), - Integer.parseInt(split[6]), - Integer.parseInt(split[7]), - Integer.parseInt(split[8]) + Integer.parseInt(split[i++]), + Integer.parseInt(split[i++]), + Integer.parseInt(split[i++]), + Integer.parseInt(split[i++]) ), module, - Boolean.parseBoolean(split[9])); + Boolean.parseBoolean(split[i++])); } private static Identifier GrabIdentifierFromString(String string, Controller controller) { diff --git a/src/sig/modules/Controller/ControlConfigurationWindow.java b/src/sig/modules/Controller/ControlConfigurationWindow.java index 9e7d63f..7755ec9 100644 --- a/src/sig/modules/Controller/ControlConfigurationWindow.java +++ b/src/sig/modules/Controller/ControlConfigurationWindow.java @@ -1,10 +1,282 @@ package sig.modules.Controller; +import java.awt.BorderLayout; +import java.awt.Checkbox; +import java.awt.Color; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.JCheckBox; +import javax.swing.JComponent; import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JLayeredPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; + +import net.java.games.input.Component; +import net.java.games.input.Controller; +import sig.modules.ControllerModule; -public class ControlConfigurationWindow extends JFrame{ +public class ControlConfigurationWindow extends JFrame implements WindowListener{ + DialogType dialog; + List panels = new ArrayList(); + List analog_controller_components = new ArrayList(); + List analog_controller_component_labels = new ArrayList(); + ControllerModule module; + DecimalFormat df = new DecimalFormat("0.000"); + PreviewPanel previewpanel; + ActionListener checkboxListener = new ActionListener(){ + @Override + public void actionPerformed(ActionEvent ev) { + int checkedamt=0; + for (JCheckBox cb : analog_controller_component_labels) { + checkedamt+=(cb.isSelected())?1:0; + } + if (previewpanel.twoAxis && checkedamt>1) { + UncheckPreviouslyCheckedbox(ev); + } else + if (!previewpanel.twoAxis && checkedamt>2) { + UncheckPreviouslyCheckedbox(ev); + } + } + + private void UncheckPreviouslyCheckedbox(ActionEvent ev) { + for (int i=0;i getControllers() { + return controllers; + } public void resetDragPoints() { this.start_drag=null; @@ -151,6 +158,10 @@ public class ControllerModule extends Module{ public Rectangle2D getPosition() { return position; } + + public void setConfigureWindow(ControlConfigurationWindow window) { + this.configure_window=window; + } public void run() { for (Controller c : controllers) { @@ -193,8 +204,9 @@ public class ControllerModule extends Module{ stored_controller_button=null; for (Controller c : controllers) { for (Component cp : c.getComponents()) { - if (!cp.isAnalog() && cp.getPollData()==1.0f) { + if (!cp.isAnalog() && cp.getPollData()!=0.0f) { stored_controller_button = cp.getIdentifier(); + stored_controller_value = cp.getPollData(); controller=c; MODE=EditMode.COLORSET; buttoncol = PopupColorPanel(); @@ -208,6 +220,9 @@ public class ControllerModule extends Module{ } } } + if (configure_window!=null) { + configure_window.run(); + } } public Image getControllerImage() { @@ -218,12 +233,12 @@ public class ControllerModule extends Module{ super.draw(g); for (int i=0;i