now remembers last used host

This commit is contained in:
Diego Waxemberg
2013-12-20 20:57:21 -05:00
parent 627efa15f8
commit 18c7d3c098
2 changed files with 23 additions and 4 deletions

View File

@@ -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);
}
};
}

View File

@@ -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() {