mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-16 13:51:15 +00:00
now remembers last used host
This commit is contained in:
@@ -31,6 +31,8 @@ import com.limelight.binding.PlatformBinding;
|
|||||||
import com.limelight.input.ControllerListener;
|
import com.limelight.input.ControllerListener;
|
||||||
import com.limelight.nvstream.NvConnection;
|
import com.limelight.nvstream.NvConnection;
|
||||||
import com.limelight.nvstream.http.NvHTTP;
|
import com.limelight.nvstream.http.NvHTTP;
|
||||||
|
import com.limelight.settings.PreferencesManager;
|
||||||
|
import com.limelight.settings.PreferencesManager.Preferences;
|
||||||
|
|
||||||
public class MainFrame {
|
public class MainFrame {
|
||||||
private JTextField hostField;
|
private JTextField hostField;
|
||||||
@@ -59,10 +61,12 @@ public class MainFrame {
|
|||||||
JPanel centerPane = new JPanel();
|
JPanel centerPane = new JPanel();
|
||||||
centerPane.setLayout(new BoxLayout(centerPane, BoxLayout.Y_AXIS));
|
centerPane.setLayout(new BoxLayout(centerPane, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
Preferences prefs = PreferencesManager.getPreferences();
|
||||||
|
|
||||||
hostField = new JTextField();
|
hostField = new JTextField();
|
||||||
hostField.setMaximumSize(new Dimension(Integer.MAX_VALUE, 24));
|
hostField.setMaximumSize(new Dimension(Integer.MAX_VALUE, 24));
|
||||||
hostField.setToolTipText("Enter host name or IP address");
|
hostField.setToolTipText("Enter host name or IP address");
|
||||||
hostField.setText("GeForce PC host");
|
hostField.setText(prefs.getHost());
|
||||||
hostField.setSelectionStart(0);
|
hostField.setSelectionStart(0);
|
||||||
hostField.setSelectionEnd(hostField.getText().length());
|
hostField.setSelectionEnd(hostField.getText().length());
|
||||||
|
|
||||||
@@ -144,7 +148,13 @@ public class MainFrame {
|
|||||||
return new ActionListener() {
|
return new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Limelight.createInstance(hostField.getText());
|
String host = hostField.getText();
|
||||||
|
Preferences prefs = PreferencesManager.getPreferences();
|
||||||
|
if (!host.equals(prefs.getHost())) {
|
||||||
|
prefs.setHost(host);
|
||||||
|
PreferencesManager.writePreferences(prefs);
|
||||||
|
}
|
||||||
|
Limelight.createInstance(host);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,18 +48,27 @@ public abstract class PreferencesManager {
|
|||||||
|
|
||||||
private Resolution res;
|
private Resolution res;
|
||||||
private boolean fullscreen;
|
private boolean fullscreen;
|
||||||
|
private String host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* construcs default preferences: 720p 30Hz fullscreen
|
* construcs default preferences: 720p 30Hz fullscreen
|
||||||
*/
|
*/
|
||||||
public Preferences() {
|
public Preferences() {
|
||||||
this.res = Resolution.RES_720_30;
|
this(Resolution.RES_720_30, true);
|
||||||
this.fullscreen = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Preferences(Resolution res, boolean fullscreen) {
|
public Preferences(Resolution res, boolean fullscreen) {
|
||||||
this.res = res;
|
this.res = res;
|
||||||
this.fullscreen = fullscreen;
|
this.fullscreen = fullscreen;
|
||||||
|
this.host = "GeForce PC host";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resolution getResolution() {
|
public Resolution getResolution() {
|
||||||
|
|||||||
Reference in New Issue
Block a user