add option to allow multiple instances (closes #33)
This commit is contained in:
parent
86f6b168d8
commit
6b1b4e2339
|
@ -118,6 +118,7 @@ public class Opsu extends StateBasedGame {
|
||||||
Options.parseOptions();
|
Options.parseOptions();
|
||||||
|
|
||||||
// only allow a single instance
|
// only allow a single instance
|
||||||
|
if (!Options.noSingleInstance()) {
|
||||||
try {
|
try {
|
||||||
SERVER_SOCKET = new ServerSocket(Options.getPort(), 1, InetAddress.getLocalHost());
|
SERVER_SOCKET = new ServerSocket(Options.getPort(), 1, InetAddress.getLocalHost());
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
|
@ -131,6 +132,7 @@ public class Opsu extends StateBasedGame {
|
||||||
Options.getPort()), null, false);
|
Options.getPort()), null, false);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File nativeDir;
|
File nativeDir;
|
||||||
if (!Utils.isJarRunning() && (
|
if (!Utils.isJarRunning() && (
|
||||||
|
|
|
@ -134,6 +134,8 @@ public class Options {
|
||||||
/** Port binding. */
|
/** Port binding. */
|
||||||
private static int port = 49250;
|
private static int port = 49250;
|
||||||
|
|
||||||
|
private static boolean noSingleInstance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the XDG flag in the manifest (if any) is set to "true".
|
* Returns whether the XDG flag in the manifest (if any) is set to "true".
|
||||||
* @return true if XDG directories are enabled, false otherwise
|
* @return true if XDG directories are enabled, false otherwise
|
||||||
|
@ -279,6 +281,15 @@ public class Options {
|
||||||
port = i;
|
port = i;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
NOSINGLEINSTANCE ("NoSingleInstance") {
|
||||||
|
@Override
|
||||||
|
public String write() { return noSingleInstance + ""; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(String s) {
|
||||||
|
noSingleInstance = !"false".equals(s);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// in-game options
|
// in-game options
|
||||||
SCREEN_RESOLUTION ("Screen Resolution", "ScreenResolution", "Restart (Ctrl+Shift+F5) to apply resolution changes.") {
|
SCREEN_RESOLUTION ("Screen Resolution", "ScreenResolution", "Restart (Ctrl+Shift+F5) to apply resolution changes.") {
|
||||||
|
@ -1492,6 +1503,8 @@ public class Options {
|
||||||
*/
|
*/
|
||||||
public static int getPort() { return port; }
|
public static int getPort() { return port; }
|
||||||
|
|
||||||
|
public static boolean noSingleInstance() { return noSingleInstance; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the cursor scale.
|
* Returns the cursor scale.
|
||||||
* @return the scale [0.5, 2]
|
* @return the scale [0.5, 2]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user