mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-04 15:06:03 +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.nvstream.NvConnection;
|
||||
import com.limelight.nvstream.http.NvHTTP;
|
||||
import com.limelight.settings.PreferencesManager;
|
||||
import com.limelight.settings.PreferencesManager.Preferences;
|
||||
|
||||
public class MainFrame {
|
||||
private JTextField hostField;
|
||||
@@ -59,10 +61,12 @@ public class MainFrame {
|
||||
JPanel centerPane = new JPanel();
|
||||
centerPane.setLayout(new BoxLayout(centerPane, BoxLayout.Y_AXIS));
|
||||
|
||||
Preferences prefs = PreferencesManager.getPreferences();
|
||||
|
||||
hostField = new JTextField();
|
||||
hostField.setMaximumSize(new Dimension(Integer.MAX_VALUE, 24));
|
||||
hostField.setToolTipText("Enter host name or IP address");
|
||||
hostField.setText("GeForce PC host");
|
||||
hostField.setText(prefs.getHost());
|
||||
hostField.setSelectionStart(0);
|
||||
hostField.setSelectionEnd(hostField.getText().length());
|
||||
|
||||
@@ -144,7 +148,13 @@ public class MainFrame {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
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 boolean fullscreen;
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* construcs default preferences: 720p 30Hz fullscreen
|
||||
*/
|
||||
public Preferences() {
|
||||
this.res = Resolution.RES_720_30;
|
||||
this.fullscreen = true;
|
||||
this(Resolution.RES_720_30, true);
|
||||
}
|
||||
|
||||
public Preferences(Resolution res, boolean fullscreen) {
|
||||
this.res = res;
|
||||
this.fullscreen = fullscreen;
|
||||
this.host = "GeForce PC host";
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public Resolution getResolution() {
|
||||
|
||||
Reference in New Issue
Block a user