mirror of
https://github.com/Maschell/StreamingPluginClient.git
synced 2025-02-21 15:07:13 +01:00
commit
6aba6610d9
@ -18,5 +18,5 @@ mvn package
|
|||||||
```
|
```
|
||||||
|
|
||||||
# Used libraries
|
# Used libraries
|
||||||
- [lombok](https://projectlombok.org/)
|
- [lombok](https://projectlombok.org/) ([Install to IDE](https://projectlombok.org/setup/overview) too!)
|
||||||
- [commons-cli](https://commons.apache.org/proper/commons-cli/)
|
- [commons-cli](https://commons.apache.org/proper/commons-cli/)
|
||||||
|
@ -22,9 +22,11 @@
|
|||||||
|
|
||||||
package de.mas.wiiu.streaming;
|
package de.mas.wiiu.streaming;
|
||||||
|
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.net.BindException;
|
import java.net.BindException;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
@ -39,29 +41,71 @@ import de.mas.wiiu.streaming.gui.StreamWindow;
|
|||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
if(GraphicsEnvironment.isHeadless()) {
|
||||||
|
System.out.println("This program does not support running in a headless environment!");
|
||||||
|
System.exit(2);
|
||||||
|
}else {
|
||||||
|
String ip = null;
|
||||||
|
if(args.length != 0) {
|
||||||
CommandLineParser parser = new DefaultParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
options.addOption("ip", "ip", true, "IP address of your Wii U Console.");
|
options.addOption("ip", "ip", true, "IP address of your Wii U Console.");
|
||||||
|
|
||||||
CommandLine line = parser.parse(options, args);
|
CommandLine line = parser.parse(options, args, true);
|
||||||
String ip = null;
|
|
||||||
|
|
||||||
if (line.hasOption("ip")) {
|
if (line.hasOption("ip")) {
|
||||||
ip = line.getOptionValue("ip");
|
ip = line.getOptionValue("ip");
|
||||||
}else {
|
}else {
|
||||||
HelpFormatter formatter = new HelpFormatter();
|
HelpFormatter formatter = new HelpFormatter();
|
||||||
formatter.printHelp("streamingTool", options);
|
formatter.printHelp("streamingTool", options);
|
||||||
ip = JOptionPane.showInputDialog(null, "Please enter the local IP address of your Wii U", "Wii U streaming client", JOptionPane.PLAIN_MESSAGE);
|
System.exit(2);
|
||||||
}
|
}
|
||||||
|
} else{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Create a JFrame to show the icon in the taskbar
|
||||||
|
final JFrame frame = new JFrame("Wii U Streaming Client - Enter IP...");
|
||||||
|
frame.setUndecorated( true );
|
||||||
|
frame.setVisible( true );
|
||||||
|
frame.setLocationRelativeTo( null );
|
||||||
|
|
||||||
|
//Display the IP Dialog
|
||||||
|
ip = JOptionPane.showInputDialog(frame, "Please enter the local IP address of your Wii U", "Wii U streaming client", JOptionPane.PLAIN_MESSAGE);
|
||||||
|
|
||||||
|
//Check if user clicked "Cancel"
|
||||||
|
if(ip == null) {
|
||||||
|
System.out.println("Cancelled. Exiting program");
|
||||||
|
frame.dispose();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
//Close the JFrame again
|
||||||
|
frame.dispose();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new Main(ip);
|
new Main(ip);
|
||||||
} catch (BindException e) {
|
} catch (BindException e) {
|
||||||
JOptionPane.showMessageDialog(null, "Can't bind socket. The client is probably already running.", e.getClass().getName(),
|
//Create a JFrame to show the icon in the taskbar
|
||||||
|
final JFrame frame = new JFrame("Wii U Streaming Client - "+e.getClass().getName());
|
||||||
|
frame.setUndecorated( true );
|
||||||
|
frame.setVisible( true );
|
||||||
|
frame.setLocationRelativeTo( null );
|
||||||
|
|
||||||
|
//Display the Message
|
||||||
|
JOptionPane.showMessageDialog(frame, "Can't bind socket. The client is probably already running.", e.getClass().getName(),
|
||||||
JOptionPane.WARNING_MESSAGE);
|
JOptionPane.WARNING_MESSAGE);
|
||||||
|
//Close the JFrame again
|
||||||
|
frame.dispose();
|
||||||
|
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Main(String ip) throws SocketException {
|
public Main(String ip) throws SocketException {
|
||||||
ImageStreamer imageStreamer = new ImageStreamer(ip);
|
ImageStreamer imageStreamer = new ImageStreamer(ip);
|
||||||
|
@ -21,18 +21,55 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package de.mas.wiiu.streaming.gui;
|
package de.mas.wiiu.streaming.gui;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.WindowConstants;
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
public class StreamWindow {
|
public class StreamWindow {
|
||||||
private final ImagePanel image = new ImagePanel(1280, 720);
|
private final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
private final ImagePanel image = new ImagePanel(screenSize.width-15, screenSize.height-100);
|
||||||
|
|
||||||
public StreamWindow(IImageProvider imageProvider) {
|
public StreamWindow(IImageProvider imageProvider) {
|
||||||
JFrame editorFrame = new JFrame("Stream");
|
|
||||||
|
JFrame editorFrame = new JFrame("Wii U Streaming Client");
|
||||||
|
|
||||||
|
editorFrame.setMaximumSize(screenSize);
|
||||||
editorFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
editorFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
imageProvider.setOnImageChange((bi) -> image.setImage(bi));
|
imageProvider.setOnImageChange((bi) -> image.setImage(bi));
|
||||||
editorFrame.add(image);
|
editorFrame.getContentPane().add(image);
|
||||||
|
|
||||||
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
editorFrame.getContentPane().add(menuBar, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
JMenu mnSettings = new JMenu("Settings");
|
||||||
|
menuBar.add(mnSettings);
|
||||||
|
|
||||||
|
|
||||||
|
JMenuItem mntmNewMenuItem = new JMenuItem("Config (Not implemented!)");
|
||||||
|
mntmNewMenuItem.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
//TODO Add program config
|
||||||
|
}
|
||||||
|
});
|
||||||
|
JMenuItem mntmExit = new JMenuItem("Exit");
|
||||||
|
mntmExit.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mntmNewMenuItem.setEnabled(false);
|
||||||
|
mnSettings.add(mntmNewMenuItem);
|
||||||
|
mnSettings.add(mntmExit);
|
||||||
|
|
||||||
editorFrame.pack();
|
editorFrame.pack();
|
||||||
editorFrame.setLocationRelativeTo(null);
|
editorFrame.setLocationRelativeTo(null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user