mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-16 05:40:56 +00:00
now use preferences to select resolution and fullscreen option
This commit is contained in:
@@ -16,7 +16,6 @@ import java.net.UnknownHostException;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
@@ -37,7 +36,6 @@ public class MainFrame {
|
||||
private JTextField hostField;
|
||||
private JButton pair;
|
||||
private JButton stream;
|
||||
private JCheckBox fullscreen;
|
||||
private JFrame limeFrame;
|
||||
|
||||
public JFrame getLimeFrame() {
|
||||
@@ -76,8 +74,6 @@ public class MainFrame {
|
||||
pair.addActionListener(createPairButtonListener());
|
||||
pair.setToolTipText("Send pair request to GeForce PC");
|
||||
|
||||
fullscreen = new JCheckBox("Fullscreen", true);
|
||||
|
||||
Box streamBox = Box.createHorizontalBox();
|
||||
streamBox.add(Box.createHorizontalGlue());
|
||||
streamBox.add(stream);
|
||||
@@ -98,8 +94,6 @@ public class MainFrame {
|
||||
contentBox.add(Box.createVerticalStrut(20));
|
||||
contentBox.add(hostBox);
|
||||
contentBox.add(Box.createVerticalStrut(5));
|
||||
contentBox.add(fullscreen);
|
||||
contentBox.add(Box.createVerticalStrut(5));
|
||||
contentBox.add(streamBox);
|
||||
contentBox.add(Box.createVerticalStrut(10));
|
||||
contentBox.add(pairBox);
|
||||
@@ -150,7 +144,7 @@ public class MainFrame {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Limelight.createInstance(hostField.getText(), fullscreen.isSelected());
|
||||
Limelight.createInstance(hostField.getText());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,19 +14,20 @@ import javax.swing.JPanel;
|
||||
|
||||
import com.limelight.settings.PreferencesManager;
|
||||
import com.limelight.settings.PreferencesManager.Preferences;
|
||||
import com.limelight.settings.PreferencesManager.Preferences.Resolution;
|
||||
|
||||
public class PreferencesFrame extends JFrame {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JComboBox resolution;
|
||||
private JCheckBox fullscreen;
|
||||
private Preferences prefs;
|
||||
private boolean prefsChanged = false;
|
||||
|
||||
public PreferencesFrame() {
|
||||
super("Preferences");
|
||||
this.setSize(200, 100);
|
||||
this.setResizable(false);
|
||||
this.setAlwaysOnTop(true);
|
||||
prefs = PreferencesManager.getPreferences();
|
||||
}
|
||||
|
||||
public void build() {
|
||||
@@ -35,12 +36,15 @@ public class PreferencesFrame extends JFrame {
|
||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
||||
|
||||
resolution = new JComboBox();
|
||||
resolution.addItem("1080p");
|
||||
resolution.addItem("720p");
|
||||
for (Resolution res : Resolution.values()) {
|
||||
resolution.addItem(res);
|
||||
}
|
||||
|
||||
resolution.setSelectedItem(prefs.getResolution());
|
||||
|
||||
fullscreen = new JCheckBox("Fullscreen");
|
||||
|
||||
|
||||
fullscreen.setSelected(prefs.getFullscreen());
|
||||
|
||||
Box resolutionBox = Box.createHorizontalBox();
|
||||
resolutionBox.add(Box.createHorizontalGlue());
|
||||
resolutionBox.add(resolution);
|
||||
@@ -61,7 +65,7 @@ public class PreferencesFrame extends JFrame {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
super.windowClosing(e);
|
||||
if (prefsChanged) {
|
||||
if (prefsChanged()) {
|
||||
writePreferences();
|
||||
}
|
||||
}
|
||||
@@ -76,7 +80,14 @@ public class PreferencesFrame extends JFrame {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private boolean prefsChanged() {
|
||||
return (prefs.getResolution() != resolution.getSelectedItem()) ||
|
||||
(prefs.getFullscreen() != fullscreen.isSelected());
|
||||
}
|
||||
|
||||
private void writePreferences() {
|
||||
prefs.setFullscreen(fullscreen.isSelected());
|
||||
prefs.setResolution((Resolution)resolution.getSelectedItem());
|
||||
PreferencesManager.writePreferences(prefs);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user