mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Merge pull request #4916 from Faxn/enhancement/startArgs
Enhancement/Autoconnect by Argument
This commit is contained in:
commit
edc7daf126
1 changed files with 41 additions and 2 deletions
|
@ -105,6 +105,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
private static final String GRAY_MODE_ARG = "-gray";
|
||||
private static final String FILL_SCREEN_ARG = "-fullscreen";
|
||||
private static final String SKIP_DONE_SYMBOLS = "-skipDoneSymbols";
|
||||
private static final String USER_ARG = "-user";
|
||||
private static final String PASSWORD_ARG = "-pw";
|
||||
private static final String SERVER_ARG = "-server";
|
||||
private static final String PORT_ARG = "-port";
|
||||
|
||||
private static final String NOT_CONNECTED_TEXT = "<not connected>";
|
||||
private static MageFrame instance;
|
||||
|
@ -123,6 +127,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
private static boolean grayMode = false;
|
||||
private static boolean fullscreenMode = false;
|
||||
private static boolean skipSmallSymbolGenerationForExisting = false;
|
||||
private static String startUser = null;
|
||||
private static String startPassword = "";
|
||||
private static String startServer = "localhost";
|
||||
private static int startPort = -1;
|
||||
|
||||
private static final Map<UUID, ChatPanelBasic> CHATS = new HashMap<>();
|
||||
private static final Map<UUID, GamePanel> GAMES = new HashMap<>();
|
||||
|
@ -732,7 +740,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}
|
||||
|
||||
public boolean autoConnect() {
|
||||
boolean autoConnectParamValue = Boolean.parseBoolean(PREFS.get("autoConnect", "false"));
|
||||
boolean autoConnectParamValue = startUser != null || Boolean.parseBoolean(PREFS.get("autoConnect", "false"));
|
||||
boolean status = false;
|
||||
if (autoConnectParamValue) {
|
||||
status = performConnect(false);
|
||||
|
@ -1186,8 +1194,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
startTime = System.currentTimeMillis();
|
||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> LOGGER.fatal(null, e));
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
for (String arg : args) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (arg.startsWith(LITE_MODE_ARG)) {
|
||||
liteMode = true;
|
||||
}
|
||||
|
@ -1200,6 +1210,22 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
if (arg.startsWith(SKIP_DONE_SYMBOLS)) {
|
||||
skipSmallSymbolGenerationForExisting = true;
|
||||
}
|
||||
if (arg.startsWith(USER_ARG)){
|
||||
startUser = args[i+1];
|
||||
i++;
|
||||
}
|
||||
if (arg.startsWith(PASSWORD_ARG)){
|
||||
startPassword = args[i+1];
|
||||
i++;
|
||||
}
|
||||
if (arg.startsWith(SERVER_ARG)){
|
||||
startServer = args[i+1];
|
||||
i++;
|
||||
}
|
||||
if (arg.startsWith(PORT_ARG)){
|
||||
startPort = Integer.valueOf(args[i+1]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!liteMode) {
|
||||
final SplashScreen splash = SplashScreen.getSplashScreen();
|
||||
|
@ -1212,6 +1238,19 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
}
|
||||
}
|
||||
instance = new MageFrame();
|
||||
|
||||
if( startUser != null){
|
||||
instance.currentConnection = new Connection();
|
||||
instance.currentConnection.setUsername(startUser);
|
||||
instance.currentConnection.setHost(startServer);
|
||||
if (startPort > 0){
|
||||
instance.currentConnection.setPort(startPort);
|
||||
}else {
|
||||
instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(Config.port));
|
||||
}
|
||||
PreferencesDialog.setProxyInformation(instance.currentConnection);
|
||||
instance.currentConnection.setPassword(startPassword);
|
||||
}
|
||||
instance.setVisible(true);
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue