mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-17 06:11:36 +00:00
added javadoc to settings classes
This commit is contained in:
@@ -4,10 +4,17 @@ import java.io.File;
|
|||||||
|
|
||||||
import com.limelight.input.gamepad.GamepadMapping;
|
import com.limelight.input.gamepad.GamepadMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages the gamepad settings
|
||||||
|
* @author Diego Waxemberg
|
||||||
|
*/
|
||||||
public abstract class GamepadSettingsManager {
|
public abstract class GamepadSettingsManager {
|
||||||
private static GamepadMapping cachedSettings;
|
private static GamepadMapping cachedSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the gamepad settings from the gamepad file and caches the configuration
|
||||||
|
* @return the gamepad settings
|
||||||
|
*/
|
||||||
public static GamepadMapping getSettings() {
|
public static GamepadMapping getSettings() {
|
||||||
if (cachedSettings == null) {
|
if (cachedSettings == null) {
|
||||||
System.out.println("Reading Gamepad Settings");
|
System.out.println("Reading Gamepad Settings");
|
||||||
@@ -23,6 +30,10 @@ public abstract class GamepadSettingsManager {
|
|||||||
return cachedSettings;
|
return cachedSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the specified mapping to the gamepad file and updates the cached settings
|
||||||
|
* @param settings the new gamepad mapping to be written out
|
||||||
|
*/
|
||||||
public static void writeSettings(GamepadMapping settings) {
|
public static void writeSettings(GamepadMapping settings) {
|
||||||
cachedSettings = settings;
|
cachedSettings = settings;
|
||||||
System.out.println("Writing Gamepad Settings");
|
System.out.println("Writing Gamepad Settings");
|
||||||
|
|||||||
@@ -3,9 +3,17 @@ package com.limelight.settings;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages user preferences
|
||||||
|
* @author Diego Waxemberg
|
||||||
|
*/
|
||||||
public abstract class PreferencesManager {
|
public abstract class PreferencesManager {
|
||||||
private static Preferences cachedPreferences = null;
|
private static Preferences cachedPreferences = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the specified preferences to the preferences file and updates the cached preferences.
|
||||||
|
* @param prefs the preferences to be written out
|
||||||
|
*/
|
||||||
public static void writePreferences(Preferences prefs) {
|
public static void writePreferences(Preferences prefs) {
|
||||||
System.out.println("Writing Preferences");
|
System.out.println("Writing Preferences");
|
||||||
File prefFile = SettingsManager.getInstance().getSettingsFile();
|
File prefFile = SettingsManager.getInstance().getSettingsFile();
|
||||||
@@ -14,6 +22,10 @@ public abstract class PreferencesManager {
|
|||||||
cachedPreferences = prefs;
|
cachedPreferences = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the user preferences from the preferences file and caches them
|
||||||
|
* @return the user preferences
|
||||||
|
*/
|
||||||
public static Preferences getPreferences() {
|
public static Preferences getPreferences() {
|
||||||
if (cachedPreferences == null) {
|
if (cachedPreferences == null) {
|
||||||
System.out.println("Reading Preferences");
|
System.out.println("Reading Preferences");
|
||||||
@@ -29,17 +41,31 @@ public abstract class PreferencesManager {
|
|||||||
return cachedPreferences;
|
return cachedPreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a user's preferences
|
||||||
|
* @author Diego Waxemberg
|
||||||
|
*/
|
||||||
public static class Preferences implements Serializable {
|
public static class Preferences implements Serializable {
|
||||||
private static final long serialVersionUID = -5575445156215348048L;
|
private static final long serialVersionUID = -5575445156215348048L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The possible resolutions for the stream
|
||||||
|
*/
|
||||||
public enum Resolution { RES_720_30("1280x720 (30Hz)"), RES_720_60("1280x720 (60Hz)"),
|
public enum Resolution { RES_720_30("1280x720 (30Hz)"), RES_720_60("1280x720 (60Hz)"),
|
||||||
RES_1080_30("1920x1080 (30Hz)"), RES_1080_60("1920x1080 (60Hz)");
|
RES_1080_30("1920x1080 (30Hz)"), RES_1080_60("1920x1080 (60Hz)");
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a new resolution with the specified name
|
||||||
|
*/
|
||||||
private Resolution(String name) {
|
private Resolution(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the specified name for this resolution
|
||||||
|
* @return the specified name of this resolution
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
@@ -51,38 +77,67 @@ public abstract class PreferencesManager {
|
|||||||
private String host;
|
private String host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* construcs default preferences: 720p 30Hz fullscreen
|
* constructs default preferences: 720p 30Hz fullscreen
|
||||||
*/
|
*/
|
||||||
public Preferences() {
|
public Preferences() {
|
||||||
this(Resolution.RES_720_30, true);
|
this(Resolution.RES_720_30, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a preference with the specified values
|
||||||
|
* @param res the <code>Resolution</code> to use
|
||||||
|
* @param fullscreen whether to start the stream in fullscreen
|
||||||
|
*/
|
||||||
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";
|
this.host = "GeForce PC host";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The saved host in this preference
|
||||||
|
* @return the last used host
|
||||||
|
*/
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the host for this preference
|
||||||
|
* @param host the host to save
|
||||||
|
*/
|
||||||
public void setHost(String host) {
|
public void setHost(String host) {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the resolution in this preference
|
||||||
|
* @return the stored resolution
|
||||||
|
*/
|
||||||
public Resolution getResolution() {
|
public Resolution getResolution() {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether to use fullscreen
|
||||||
|
* @return the stored fullscreen mode
|
||||||
|
*/
|
||||||
public boolean getFullscreen() {
|
public boolean getFullscreen() {
|
||||||
return fullscreen;
|
return fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the resolution in this preference
|
||||||
|
* @param res the resolution to save
|
||||||
|
*/
|
||||||
public void setResolution(Resolution res) {
|
public void setResolution(Resolution res) {
|
||||||
this.res = res;
|
this.res = res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the fullscreen mode of this preference
|
||||||
|
* @param fullscreen whether to use fullscreen
|
||||||
|
*/
|
||||||
public void setFullscreen(boolean fullscreen) {
|
public void setFullscreen(boolean fullscreen) {
|
||||||
this.fullscreen = fullscreen;
|
this.fullscreen = fullscreen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,14 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages the settings files
|
||||||
|
* @author Diego Waxemberg
|
||||||
|
*/
|
||||||
public class SettingsManager {
|
public class SettingsManager {
|
||||||
|
/**
|
||||||
|
* Directory to which settings will be saved
|
||||||
|
*/
|
||||||
public static String SETTINGS_DIR = System.getProperty("user.home") + File.separator + "Limelight";
|
public static String SETTINGS_DIR = System.getProperty("user.home") + File.separator + "Limelight";
|
||||||
|
|
||||||
//directory to hold limelight settings
|
//directory to hold limelight settings
|
||||||
@@ -21,12 +27,19 @@ public class SettingsManager {
|
|||||||
|
|
||||||
private static SettingsManager manager;
|
private static SettingsManager manager;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructs a manager that initializes the settings files
|
||||||
|
*/
|
||||||
private SettingsManager() {
|
private SettingsManager() {
|
||||||
settingsFile = new File(SETTINGS_DIR + File.separator + "settings.lime");
|
settingsFile = new File(SETTINGS_DIR + File.separator + "settings.lime");
|
||||||
gamepadFile = new File(SETTINGS_DIR + File.separator + "gamepad.lime");
|
gamepadFile = new File(SETTINGS_DIR + File.separator + "gamepad.lime");
|
||||||
settingsDir = new File(SETTINGS_DIR);
|
settingsDir = new File(SETTINGS_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an instance of the manager, this is a singleton
|
||||||
|
* @return the instance of the manager
|
||||||
|
*/
|
||||||
public static SettingsManager getInstance() {
|
public static SettingsManager getInstance() {
|
||||||
if (manager == null) {
|
if (manager == null) {
|
||||||
manager = new SettingsManager();
|
manager = new SettingsManager();
|
||||||
@@ -34,6 +47,10 @@ public class SettingsManager {
|
|||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the gamepad preference file, if the file does not exist, it is created first
|
||||||
|
* @return the gamepad preference file
|
||||||
|
*/
|
||||||
public File getGamepadFile() {
|
public File getGamepadFile() {
|
||||||
if (!settingsDir.exists()) {
|
if (!settingsDir.exists()) {
|
||||||
settingsFile.mkdirs();
|
settingsFile.mkdirs();
|
||||||
@@ -51,6 +68,10 @@ public class SettingsManager {
|
|||||||
return gamepadFile;
|
return gamepadFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the settings file (user preferences), if the file does not exist, it is created first
|
||||||
|
* @return the settings file
|
||||||
|
*/
|
||||||
public File getSettingsFile() {
|
public File getSettingsFile() {
|
||||||
if (!settingsDir.exists()) {
|
if (!settingsDir.exists()) {
|
||||||
settingsFile.mkdirs();
|
settingsFile.mkdirs();
|
||||||
@@ -68,6 +89,12 @@ public class SettingsManager {
|
|||||||
return settingsFile;
|
return settingsFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the specified file as a settings file and returns the result.
|
||||||
|
* <br>A settings file must be a java serialized object
|
||||||
|
* @param file the file to read in
|
||||||
|
* @return the settings represented in this file
|
||||||
|
*/
|
||||||
public static Object readSettings(File file) {
|
public static Object readSettings(File file) {
|
||||||
ObjectInputStream ois = null;
|
ObjectInputStream ois = null;
|
||||||
Object settings = null;
|
Object settings = null;
|
||||||
@@ -100,6 +127,11 @@ public class SettingsManager {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the specified settings to the desired file
|
||||||
|
* @param file the file to write the settings to
|
||||||
|
* @param settings the settings to be written out
|
||||||
|
*/
|
||||||
public static void writeSettings(File file, Serializable settings) {
|
public static void writeSettings(File file, Serializable settings) {
|
||||||
ObjectOutputStream ous = null;
|
ObjectOutputStream ous = null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user