2015-11-06 18:15:26 +01:00
|
|
|
package com.ixab.GUI;
|
|
|
|
|
|
2015-11-06 21:42:03 +01:00
|
|
|
import com.ixab.ConfigHandling.ConfigFileIOHandler;
|
|
|
|
|
import com.ixab.ConfigHandling.ConfigFileInstanceHandler;
|
2015-11-07 00:19:11 +01:00
|
|
|
import com.ixab.StreamHandling.StreamInfo;
|
2015-11-06 21:42:03 +01:00
|
|
|
import com.ixab.StreamHandling.StreamOpener;
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
2015-11-07 00:56:35 +01:00
|
|
|
import java.awt.event.*;
|
2015-11-06 21:42:03 +01:00
|
|
|
|
2015-11-06 18:15:26 +01:00
|
|
|
public class StreamChooserMenu {
|
2015-11-06 21:42:03 +01:00
|
|
|
private JPanel panel;
|
2015-11-07 00:19:11 +01:00
|
|
|
private JComboBox comboBoxStreams;
|
2015-11-07 00:56:35 +01:00
|
|
|
private JComboBox comboBoxQuality;
|
2015-11-06 21:42:03 +01:00
|
|
|
private JTextField textField1;
|
|
|
|
|
private JButton hinzufügenButton;
|
|
|
|
|
private JButton streamAbspielenButton;
|
|
|
|
|
private JButton entfernenButton;
|
2015-11-07 00:19:11 +01:00
|
|
|
private JLabel labelStreamStatus;
|
|
|
|
|
private JLabel labelStreamViewers;
|
|
|
|
|
private JLabel labelStreamTitle;
|
|
|
|
|
private JLabel labelStreamGame;
|
2015-11-07 00:56:35 +01:00
|
|
|
private JButton neuLadenButton;
|
|
|
|
|
private boolean lockStreamInfoGetter = false;
|
2015-11-06 21:42:03 +01:00
|
|
|
|
|
|
|
|
public StreamChooserMenu() {
|
|
|
|
|
this.initComboBoxes();
|
|
|
|
|
streamAbspielenButton.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-07 00:56:35 +01:00
|
|
|
StreamOpener so = new StreamOpener(ConfigFileInstanceHandler.getConfig(), ConfigFileInstanceHandler.getConfig().getStreams().indexOf(comboBoxStreams.getSelectedItem()), comboBoxQuality.getSelectedItem().toString());
|
2015-11-06 21:42:03 +01:00
|
|
|
so.start();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
hinzufügenButton.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-06 22:16:23 +01:00
|
|
|
addNewStream();
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
entfernenButton.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-07 00:19:11 +01:00
|
|
|
ConfigFileInstanceHandler.getConfig().removeStream(comboBoxStreams.getSelectedItem());
|
2015-11-06 21:42:03 +01:00
|
|
|
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
|
2015-11-07 00:56:35 +01:00
|
|
|
lockStreamInfoGetter = true;
|
2015-11-06 22:16:23 +01:00
|
|
|
initStreamsComboBox();
|
2015-11-07 00:56:35 +01:00
|
|
|
lockStreamInfoGetter = false;
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
|
|
|
|
});
|
2015-11-07 00:19:11 +01:00
|
|
|
comboBoxStreams.addActionListener(new ActionListener() {
|
2015-11-06 22:16:23 +01:00
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2015-11-07 00:56:35 +01:00
|
|
|
if (!lockStreamInfoGetter) {
|
|
|
|
|
updateStreamDetails();
|
|
|
|
|
}
|
2015-11-06 22:16:23 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
textField1.addKeyListener(new KeyAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void keyPressed(KeyEvent e) {
|
|
|
|
|
super.keyPressed(e);
|
|
|
|
|
if (textField1.isFocusOwner() && e.getKeyCode() == 10) {
|
|
|
|
|
addNewStream();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-11-07 00:56:35 +01:00
|
|
|
neuLadenButton.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
updateStreamDetails();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
private void updateStreamDetails() {
|
|
|
|
|
StreamInfo.getStreamInfo(comboBoxStreams.getSelectedItem().toString());
|
|
|
|
|
labelStreamStatus.setText(StreamInfo.getStatus());
|
|
|
|
|
labelStreamGame.setText(StreamInfo.getGame());
|
|
|
|
|
labelStreamViewers.setText(StreamInfo.getViewers());
|
|
|
|
|
labelStreamTitle.setText(StreamInfo.getTitle());
|
2015-11-06 22:16:23 +01:00
|
|
|
}
|
|
|
|
|
private void addNewStream() {
|
|
|
|
|
ConfigFileInstanceHandler.getConfig().addStream(textField1.getText());
|
|
|
|
|
ConfigFileIOHandler.save(ConfigFileInstanceHandler.getConfig());
|
2015-11-07 00:56:35 +01:00
|
|
|
lockStreamInfoGetter = true;
|
2015-11-06 22:16:23 +01:00
|
|
|
initStreamsComboBox();
|
2015-11-07 00:56:35 +01:00
|
|
|
lockStreamInfoGetter = false;
|
2015-11-06 22:16:23 +01:00
|
|
|
textField1.setText("");
|
|
|
|
|
}
|
|
|
|
|
private void initComboBoxes() {
|
|
|
|
|
initQualityComboBox();
|
|
|
|
|
initStreamsComboBox();
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
2015-11-06 22:16:23 +01:00
|
|
|
private void initStreamsComboBox() {
|
2015-11-07 00:19:11 +01:00
|
|
|
comboBoxStreams.removeAllItems();
|
2015-11-06 21:42:03 +01:00
|
|
|
for (String streamName :
|
|
|
|
|
ConfigFileInstanceHandler.getConfig().getStreams()) {
|
2015-11-07 00:19:11 +01:00
|
|
|
comboBoxStreams.addItem(streamName);
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
2015-11-06 22:16:23 +01:00
|
|
|
}
|
|
|
|
|
private void initQualityComboBox() {
|
2015-11-07 00:56:35 +01:00
|
|
|
comboBoxQuality.removeAllItems();
|
|
|
|
|
comboBoxQuality.addItem("best"); comboBoxQuality.addItem("high"); comboBoxQuality.addItem("medium"); comboBoxQuality.addItem("low"); comboBoxQuality.addItem("mobile");
|
2015-11-06 21:42:03 +01:00
|
|
|
}
|
|
|
|
|
public static void main(String[] args) {
|
2015-11-06 22:16:23 +01:00
|
|
|
JFrame frame = new JFrame("jLSLauncher v"+ com.ixab.Main.getVersion());
|
2015-11-06 21:42:03 +01:00
|
|
|
frame.setContentPane(new StreamChooserMenu().panel);
|
|
|
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
|
frame.pack();
|
2015-11-06 22:16:23 +01:00
|
|
|
frame.setLocationByPlatform(true);
|
2015-11-06 21:42:03 +01:00
|
|
|
frame.setVisible(true);
|
|
|
|
|
}
|
2015-11-06 18:15:26 +01:00
|
|
|
}
|