2017-12-03 16:41:16 -06:00
|
|
|
package sig.windows;
|
|
|
|
|
|
|
|
import java.awt.Color;
|
2017-12-03 17:57:52 -06:00
|
|
|
import java.awt.Dimension;
|
|
|
|
import java.awt.GridLayout;
|
|
|
|
import java.awt.Image;
|
|
|
|
import java.awt.Rectangle;
|
|
|
|
import java.awt.geom.Rectangle2D;
|
2017-12-03 16:41:16 -06:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2017-12-03 19:50:34 -06:00
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
2017-12-03 16:41:16 -06:00
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
2017-12-03 17:57:52 -06:00
|
|
|
import javax.swing.BoxLayout;
|
2017-12-03 16:41:16 -06:00
|
|
|
import javax.swing.Icon;
|
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
import javax.swing.JButton;
|
|
|
|
import javax.swing.JFrame;
|
2017-12-03 17:57:52 -06:00
|
|
|
import javax.swing.JLabel;
|
2017-12-03 16:41:16 -06:00
|
|
|
import javax.swing.JToggleButton;
|
|
|
|
import javax.swing.event.ChangeEvent;
|
|
|
|
import javax.swing.event.ChangeListener;
|
|
|
|
|
|
|
|
import sig.BackgroundColorButton;
|
|
|
|
import sig.ColorPanel;
|
2017-12-03 17:57:52 -06:00
|
|
|
import sig.Module;
|
2017-12-03 16:41:16 -06:00
|
|
|
import sig.MyPanel;
|
|
|
|
import sig.sigIRC;
|
2017-12-03 19:50:34 -06:00
|
|
|
import sig.modules.ChatLogModule;
|
2017-12-03 16:41:16 -06:00
|
|
|
|
2017-12-03 19:50:34 -06:00
|
|
|
@SuppressWarnings("serial")
|
2017-12-03 16:41:16 -06:00
|
|
|
public class ProgramWindow extends JFrame{
|
2017-12-03 19:50:34 -06:00
|
|
|
|
|
|
|
public static Icon deselected_icon,selected_icon;
|
2017-12-03 16:41:16 -06:00
|
|
|
|
|
|
|
List<ModuleButton> buttons = new ArrayList<ModuleButton>();
|
|
|
|
|
|
|
|
public ProgramWindow() {
|
2017-12-03 19:50:34 -06:00
|
|
|
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
|
|
|
scheduler.scheduleWithFixedDelay(()->{
|
|
|
|
if (sigIRC.configNeedsUpdating>0 &&
|
|
|
|
System.currentTimeMillis()-sigIRC.configNeedsUpdating>1000) {
|
|
|
|
sigIRC.config.saveProperties();
|
|
|
|
sigIRC.configNeedsUpdating=0;
|
|
|
|
}
|
|
|
|
},1000,1000,TimeUnit.MILLISECONDS);
|
2017-12-03 17:57:52 -06:00
|
|
|
|
|
|
|
try {
|
2017-12-03 19:50:34 -06:00
|
|
|
sigIRC.programIcon = ImageIO.read(sigIRC.class.getResource("/resource/sigIRCicon.png"));
|
2017-12-03 17:57:52 -06:00
|
|
|
} catch (IOException e1) {
|
|
|
|
e1.printStackTrace();
|
|
|
|
}
|
|
|
|
|
2017-12-03 16:41:16 -06:00
|
|
|
try {
|
|
|
|
deselected_icon = new ImageIcon(ImageIO.read(sigIRC.class.getResource("/resource/deselected_button.png")));
|
|
|
|
selected_icon = new ImageIcon(ImageIO.read(sigIRC.class.getResource("/resource/selected_button.png")));
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sigIRC.overlayMode && sigIRC.showWindowControls) {
|
|
|
|
JFrame.setDefaultLookAndFeelDecorated(true);
|
|
|
|
}
|
|
|
|
System.setProperty("sun.java2d.opengl", Boolean.toString(sigIRC.hardwareAcceleration));
|
|
|
|
JFrame f = new JFrame("sigIRCv2");
|
|
|
|
this.setAutoRequestFocus(true);
|
|
|
|
this.toFront();
|
|
|
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
if (sigIRC.overlayMode && !sigIRC.showWindowControls) {
|
|
|
|
this.setUndecorated(true);
|
|
|
|
}
|
2017-12-03 17:57:52 -06:00
|
|
|
|
|
|
|
|
2017-12-03 16:41:16 -06:00
|
|
|
sigIRC.panel = new MyPanel();
|
2017-12-03 17:57:52 -06:00
|
|
|
|
|
|
|
JLabel myLabel = new JLabel("Module Control:");
|
2017-12-03 16:41:16 -06:00
|
|
|
if (sigIRC.overlayMode) {
|
|
|
|
sigIRC.panel.setOpaque(false);
|
|
|
|
}
|
2017-12-03 17:57:52 -06:00
|
|
|
sigIRC.panel.setBackground(Color.BLACK);
|
|
|
|
myLabel.setBackground(sigIRC.panel.getBackground());
|
|
|
|
myLabel.setForeground(Color.WHITE);
|
|
|
|
myLabel.setIcon(new ImageIcon(sigIRC.programIcon.getScaledInstance(48, 48, Image.SCALE_AREA_AVERAGING)));
|
|
|
|
|
|
|
|
sigIRC.panel.add(myLabel);
|
2017-12-03 16:41:16 -06:00
|
|
|
|
|
|
|
if (!sigIRC.disableChatMessages) {
|
2017-12-03 19:50:34 -06:00
|
|
|
ModuleButton button = new ModuleButton("Scrolling Chat",new Module(new Rectangle(0,0,0,0),"Test"));
|
2017-12-03 17:57:52 -06:00
|
|
|
sigIRC.panel.add(button);
|
|
|
|
}
|
|
|
|
if (sigIRC.chatlogmodule_enabled) {
|
2017-12-03 19:50:34 -06:00
|
|
|
ChatLogModule mod = new ChatLogModule(new Rectangle(sigIRC.chatlogmodule_X,sigIRC.chatlogmodule_Y,sigIRC.chatlogmodule_width,sigIRC.chatlogmodule_height),"Chat Log");
|
|
|
|
ModuleButton button = new ModuleButton("Chat Log",mod);
|
2017-12-03 17:57:52 -06:00
|
|
|
sigIRC.panel.add(button);
|
|
|
|
}
|
|
|
|
if (sigIRC.controllermodule_enabled) {
|
2017-12-03 19:50:34 -06:00
|
|
|
ModuleButton button = new ModuleButton("Controller",new Module(new Rectangle(0,0,0,0),"Test"));
|
2017-12-03 17:57:52 -06:00
|
|
|
sigIRC.panel.add(button);
|
|
|
|
}
|
|
|
|
if (sigIRC.twitchmodule_enabled) {
|
2017-12-03 19:50:34 -06:00
|
|
|
ModuleButton button = new ModuleButton("Twitch",new Module(new Rectangle(0,0,0,0),"Test"));
|
2017-12-03 17:57:52 -06:00
|
|
|
sigIRC.panel.add(button);
|
2017-12-03 16:41:16 -06:00
|
|
|
}
|
2017-12-03 17:57:52 -06:00
|
|
|
if (sigIRC.rabiracemodule_enabled) {
|
2017-12-03 19:50:34 -06:00
|
|
|
ModuleButton button = new ModuleButton("Rabi-Race",new Module(new Rectangle(0,0,0,0),"Test"));
|
2017-12-03 17:57:52 -06:00
|
|
|
sigIRC.panel.add(button);
|
|
|
|
}
|
|
|
|
if (sigIRC.touhoumothermodule_enabled) {
|
2017-12-03 19:50:34 -06:00
|
|
|
ModuleButton button = new ModuleButton("Touhou Mother",new Module(new Rectangle(0,0,0,0),"Test"));
|
2017-12-03 17:57:52 -06:00
|
|
|
sigIRC.panel.add(button);
|
|
|
|
}
|
|
|
|
GridLayout myLayout = new GridLayout(0,1);
|
|
|
|
sigIRC.panel.setLayout(myLayout);
|
2017-12-03 16:41:16 -06:00
|
|
|
|
|
|
|
//colorpanel = new ColorPanel();
|
|
|
|
//this.add(colorpanel);
|
2017-12-03 17:57:52 -06:00
|
|
|
this.setLocationByPlatform(true);
|
2017-12-03 16:41:16 -06:00
|
|
|
this.add(sigIRC.panel);
|
|
|
|
this.pack();
|
|
|
|
this.setVisible(true);
|
2017-12-03 17:57:52 -06:00
|
|
|
//this.setLocation(sigIRC.windowX, sigIRC.windowY);
|
|
|
|
//this.setSize(sigIRC.windowWidth, sigIRC.windowHeight);
|
2017-12-03 16:41:16 -06:00
|
|
|
|
|
|
|
this.setIconImage(sigIRC.programIcon);
|
|
|
|
|
|
|
|
// button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,64+rowobj.size()*rowSpacing);
|
|
|
|
if (sigIRC.overlayMode) {
|
|
|
|
this.setBackground(new Color(0,0,0,0));
|
|
|
|
this.setAlwaysOnTop(true);
|
|
|
|
}
|
|
|
|
//this.setOpacity(0.5f);
|
2017-12-03 19:50:34 -06:00
|
|
|
//this.addWindowListener(sigIRC.panel);
|
2017-12-03 17:57:52 -06:00
|
|
|
|
2017-12-03 19:50:34 -06:00
|
|
|
//Module testMod = new Module(new Rectangle(0,0,640,480),"Test");
|
2017-12-03 16:41:16 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-03 19:50:34 -06:00
|
|
|
@SuppressWarnings("serial")
|
|
|
|
class ModuleButton extends JToggleButton{
|
2017-12-03 16:41:16 -06:00
|
|
|
String label = "";
|
|
|
|
ModuleButton button;
|
2017-12-03 19:50:34 -06:00
|
|
|
Module myModule;
|
|
|
|
public ModuleButton(String label, Module module) {
|
2017-12-03 16:41:16 -06:00
|
|
|
this.label=label;
|
|
|
|
this.button=this;
|
2017-12-03 19:50:34 -06:00
|
|
|
this.myModule=module;
|
2017-12-03 16:41:16 -06:00
|
|
|
this.setBackground(Color.DARK_GRAY);
|
2017-12-03 17:57:52 -06:00
|
|
|
this.setText(label);
|
|
|
|
this.setToolTipText("Click to enable and disable the \n"+label+" module.");
|
|
|
|
this.setPreferredSize(new Dimension(160,56));
|
|
|
|
this.setForeground(Color.GRAY);
|
|
|
|
this.setIconTextGap(4);
|
|
|
|
this.setSelectedIcon(ProgramWindow.selected_icon);
|
2017-12-03 19:50:34 -06:00
|
|
|
this.setIcon(ProgramWindow.deselected_icon);
|
2017-12-03 17:57:52 -06:00
|
|
|
this.setSelected(true);
|
|
|
|
button.setForeground(Color.BLUE);
|
2017-12-03 16:41:16 -06:00
|
|
|
this.addChangeListener(new ChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void stateChanged(ChangeEvent e) {
|
|
|
|
if (button.isSelected()) {
|
|
|
|
button.setForeground(Color.BLUE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
button.setBackground(Color.DARK_GRAY);
|
|
|
|
button.setForeground(Color.GRAY);
|
|
|
|
}
|
2017-12-03 19:50:34 -06:00
|
|
|
myModule.setVisible(button.isSelected());
|
2017-12-03 16:41:16 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|