diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/CliProperties.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/CliProperties.java index 40ce83caf80..d9ffc8e5740 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/CliProperties.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/CliProperties.java @@ -5,16 +5,22 @@ /** A collection of all CLI related constants. */ public class CliProperties { @NonNls public static final String TRIPLEA_GAME = "triplea.game"; - @NonNls public static final String TRIPLEA_SERVER = "triplea.server"; - @NonNls public static final String TRIPLEA_CLIENT = "triplea.client"; + @NonNls public static final String TRIPLEA_SERVER = "triplea.server"; // true/false + @NonNls public static final String TRIPLEA_CLIENT = "triplea.client"; // true/false @NonNls public static final String TRIPLEA_HOST = "triplea.host"; @NonNls public static final String TRIPLEA_PORT = "triplea.port"; @NonNls public static final String TRIPLEA_NAME = "triplea.name"; + @NonNls public static final String TRIPLEA_START = "triplea.start"; @NonNls public static final String SERVER_PASSWORD = "triplea.server.password"; @NonNls public static final String LOBBY_URI = "triplea.lobby.uri"; @NonNls public static final String LOBBY_GAME_COMMENTS = "triplea.lobby.game.comments"; - @NonNls public static final String MAP_FOLDER = "triplea.map.folder"; @NonNls public static final String TRIPLEA_MAP_DOWNLOAD = "triplea.map.download"; + @NonNls public static final String TRIPLEA_MAP_DOWNLOAD_PREFIX = "triplea:"; + + @NonNls public static final String TRIPLEA_START_LOCAL = "local"; + @NonNls public static final String TRIPLEA_START_PBF = "pbf"; + @NonNls public static final String TRIPLEA_START_PBEM = "pbem"; + @NonNls public static final String TRIPLEA_START_LOBBY = "lobby"; private CliProperties() {} } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/mc/ServerModel.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/mc/ServerModel.java index 99f6d0b0176..4943355be6c 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/mc/ServerModel.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/mc/ServerModel.java @@ -350,7 +350,7 @@ private void setPlayerEnabled(final String playerName, final boolean enabled) { playersEnabledListing.put(playerName, enabled); if (launchAction.shouldMinimizeExpensiveAiUse()) { // we do not want the host bot to actually play, so set to null if enabled, - // and set to weak ai if disabled + // and set to weak AI if disabled if (enabled) { playersToNodeListing.put(playerName, null); } else { @@ -484,7 +484,7 @@ private Map getLocalPlayerTypes() { } final Map localPlayerMappings = new HashMap<>(); - // local player default = humans (for bots = weak ai) + // local player default = humans (for bots = weak AI) final PlayerTypes.Type defaultLocalType = launchAction.getDefaultLocalPlayerType(); for (final Map.Entry entry : playersToNodeListing.entrySet()) { final String player = entry.getKey(); diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorPanel.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorPanel.java index 3cba7ce55c1..ae077cddf60 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/game/selector/GameSelectorPanel.java @@ -359,7 +359,7 @@ private void selectGameFile() { } } - private void gameSelected(final Path gameFile) { + public void gameSelected(final Path gameFile) { BackgroundTaskRunner.runInBackground( "Loading map...", () -> { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/Constants.java b/game-app/game-core/src/main/java/games/strategy/triplea/Constants.java index 4e41be732dc..7039640cdf8 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/Constants.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/Constants.java @@ -210,49 +210,49 @@ public interface Constants { String SUPPORT_RULE_NAME_OLD = SUPPORT_ATTACHMENT_PREFIX + OLD_ART_RULE_NAME; String SUPPORT_RULE_NAME_OLD_TEMP_FIRST = SUPPORT_ATTACHMENT_PREFIX + OLD_ART_RULE_NAME + "TempFirst"; - String EDIT_MODE = "EditMode"; + @NonNls String EDIT_MODE = "EditMode"; // by default this is 0, but for lhtr, it is 1 - String ORIGINAL_OWNER = "originalOwner"; + @NonNls String ORIGINAL_OWNER = "originalOwner"; // unit types - String UNIT_TYPE_INFANTRY = "infantry"; - String UNIT_TYPE_INF = "inf"; - String UNIT_TYPE_MOTORIZED = "motorized"; - String UNIT_TYPE_ARMOUR = "armour"; - String UNIT_TYPE_TRANSPORT = "transport"; - String UNIT_TYPE_SUBMARINE = "submarine"; - String UNIT_TYPE_BATTLESHIP = "battleship"; - String UNIT_TYPE_MARINE = "marine"; - String UNIT_TYPE_CARRIER = "carrier"; - String UNIT_TYPE_FIGHTER = "fighter"; - String UNIT_TYPE_BOMBER = "bomber"; - String UNIT_TYPE_FACTORY = "factory"; - String UNIT_TYPE_AAGUN = "aaGun"; - String UNIT_TYPE_ARTILLERY = "artillery"; - String UNIT_TYPE_DESTROYER = "destroyer"; - String SMALL_MAP_FILENAME = "smallMap"; - String[] SMALL_MAP_EXTENSIONS = {"jpeg", "jpg", "png"}; - String MAP_NAME = "mapName"; + @NonNls String UNIT_TYPE_INFANTRY = "infantry"; + @NonNls String UNIT_TYPE_INF = "inf"; + @NonNls String UNIT_TYPE_MOTORIZED = "motorized"; + @NonNls String UNIT_TYPE_ARMOUR = "armour"; + @NonNls String UNIT_TYPE_TRANSPORT = "transport"; + @NonNls String UNIT_TYPE_SUBMARINE = "submarine"; + @NonNls String UNIT_TYPE_BATTLESHIP = "battleship"; + @NonNls String UNIT_TYPE_MARINE = "marine"; + @NonNls String UNIT_TYPE_CARRIER = "carrier"; + @NonNls String UNIT_TYPE_FIGHTER = "fighter"; + @NonNls String UNIT_TYPE_BOMBER = "bomber"; + @NonNls String UNIT_TYPE_FACTORY = "factory"; + @NonNls String UNIT_TYPE_AAGUN = "aaGun"; + @NonNls String UNIT_TYPE_ARTILLERY = "artillery"; + @NonNls String UNIT_TYPE_DESTROYER = "destroyer"; + @NonNls String SMALL_MAP_FILENAME = "smallMap"; + @NonNls String[] SMALL_MAP_EXTENSIONS = {"jpeg", "jpg", "png"}; + @NonNls String MAP_NAME = "mapName"; // relationships stuff - String RELATIONSHIP_TYPE_SELF = "self_relation"; - String RELATIONSHIP_TYPE_NULL = "null_relation"; - String RELATIONSHIP_TYPE_DEFAULT_ALLIED = "default_allied_relation"; - String RELATIONSHIP_TYPE_DEFAULT_WAR = "default_war_relation"; - String RELATIONSHIP_CONDITION_ANY_NEUTRAL = "anyNeutral"; - String RELATIONSHIP_CONDITION_ANY = "any"; - String RELATIONSHIP_CONDITION_ANY_ALLIED = "anyAllied"; - String RELATIONSHIP_CONDITION_ANY_WAR = "anyWar"; - String RELATIONSHIP_ARCHETYPE_NEUTRAL = "neutral"; - String RELATIONSHIP_ARCHETYPE_WAR = "war"; - String RELATIONSHIP_ARCHETYPE_ALLIED = "allied"; - String RELATIONSHIP_PROPERTY_DEFAULT = "default"; - String RELATIONSHIP_PROPERTY_TRUE = "true"; - String RELATIONSHIP_PROPERTY_FALSE = "false"; - String PROPERTY_TRUE = "true"; - String PROPERTY_FALSE = "false"; + @NonNls String RELATIONSHIP_TYPE_SELF = "self_relation"; + @NonNls String RELATIONSHIP_TYPE_NULL = "null_relation"; + @NonNls String RELATIONSHIP_TYPE_DEFAULT_ALLIED = "default_allied_relation"; + @NonNls String RELATIONSHIP_TYPE_DEFAULT_WAR = "default_war_relation"; + @NonNls String RELATIONSHIP_CONDITION_ANY_NEUTRAL = "anyNeutral"; + @NonNls String RELATIONSHIP_CONDITION_ANY = "any"; + @NonNls String RELATIONSHIP_CONDITION_ANY_ALLIED = "anyAllied"; + @NonNls String RELATIONSHIP_CONDITION_ANY_WAR = "anyWar"; + @NonNls String RELATIONSHIP_ARCHETYPE_NEUTRAL = "neutral"; + @NonNls String RELATIONSHIP_ARCHETYPE_WAR = "war"; + @NonNls String RELATIONSHIP_ARCHETYPE_ALLIED = "allied"; + @NonNls String RELATIONSHIP_PROPERTY_DEFAULT = "default"; + @NonNls String RELATIONSHIP_PROPERTY_TRUE = "true"; + @NonNls String RELATIONSHIP_PROPERTY_FALSE = "false"; + @NonNls String PROPERTY_TRUE = "true"; + @NonNls String PROPERTY_FALSE = "false"; - String CONSTRUCTION_TYPE_FACTORY = "factory"; - String CONSTRUCTION_TYPE_STRUCTURE = "structure"; + @NonNls String CONSTRUCTION_TYPE_FACTORY = "factory"; + @NonNls String CONSTRUCTION_TYPE_STRUCTURE = "structure"; static String getIncomePercentageFor(final GamePlayer gamePlayer) { return gamePlayer.getName() + " Income Percentage"; diff --git a/game-app/game-headed/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/HeadedServerSetupModel.java b/game-app/game-headed/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/HeadedServerSetupModel.java index 20518945363..6971099ba4e 100644 --- a/game-app/game-headed/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/HeadedServerSetupModel.java +++ b/game-app/game-headed/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/HeadedServerSetupModel.java @@ -57,8 +57,7 @@ public void showPbem() { } /** - * Starts the game server and displays the game start screen afterwards, awaiting remote game - * clients. + * Starts the game server and then displays the game start screen, awaiting remote game clients. */ public ServerModel showServer() { final ServerModel serverModel = new ServerModel(gameSelectorModel, new HeadedLaunchAction(ui)); @@ -81,7 +80,7 @@ private void onServerMessengerCreated(final ServerModel serverModel) { () -> { setGameTypePanel(new ServerSetupPanel(serverModel, gameSelectorModel)); - // for whatever reason, the server window is showing very very small, causing the nation + // for whatever reason, the server window is showing very, very small, causing the nation // info to be cut and requiring scroll bars final int x = Math.max(ui.getPreferredSize().width, 800); final int y = Math.max(ui.getPreferredSize().height, 660); @@ -92,7 +91,7 @@ private void onServerMessengerCreated(final ServerModel serverModel) { /** * A method that establishes a connection to a remote game and displays the game start screen - * afterwards if the connection was successfully established. + * after the connection was successfully established. */ public void showClient() { Preconditions.checkState(!SwingUtilities.isEventDispatchThread()); @@ -123,7 +122,8 @@ private void setGameTypePanel(final SetupPanel panel) { /** * Executes a login sequence prompting the user for their lobby username+password and sends it to * server. If successful the user is presented with the lobby frame. Failure cases are handled and - * user is presented with another try or they can abort. In the abort case this method is a no-op. + * user is presented with another try, or they can abort. In the abort case this method is a + * no-op. */ public void login() { new LobbyLogin(ui) diff --git a/game-app/game-headed/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/MainPanelBuilder.java b/game-app/game-headed/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/MainPanelBuilder.java index a95f011b146..204b08127f6 100644 --- a/game-app/game-headed/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/MainPanelBuilder.java +++ b/game-app/game-headed/src/main/java/games/strategy/engine/framework/startup/ui/panels/main/MainPanelBuilder.java @@ -5,8 +5,10 @@ import games.strategy.engine.framework.startup.ui.panels.main.game.selector.GameSelectorPanel; import games.strategy.engine.framework.ui.background.WaitWindow; import java.util.Optional; +import java.util.function.Consumer; import javax.swing.JOptionPane; import lombok.AllArgsConstructor; +import org.jetbrains.annotations.NotNull; import org.triplea.game.startup.SetupModel; import org.triplea.java.ThreadRunner; @@ -31,11 +33,7 @@ public MainPanel buildMainPanel( new MainPanel( quitAction, gameSelectorPanel, - uiPanel -> { - final var setupPanel = headedServerSetupModel.getPanel(); - setupPanel.getLauncher().ifPresent(launcher -> launch(uiPanel, launcher)); - setupPanel.postStartGame(); - }, + getMainPanelLaunchAction(headedServerSetupModel), Optional.ofNullable(headedServerSetupModel.getPanel()) .map(SetupModel::getChatModel) .orElse(null), @@ -45,7 +43,16 @@ public MainPanel buildMainPanel( return mainPanel; } - private void launch(MainPanel uiPanel, ILauncher launcher) { + public static @NotNull Consumer getMainPanelLaunchAction( + HeadedServerSetupModel headedServerSetupModel) { + return uiPanel -> { + final var setupPanel = headedServerSetupModel.getPanel(); + setupPanel.getLauncher().ifPresent(launcher -> launch(uiPanel, launcher)); + setupPanel.postStartGame(); + }; + } + + private static void launch(MainPanel uiPanel, ILauncher launcher) { final WaitWindow gameLoadingWindow = new WaitWindow(); final var frame = JOptionPane.getFrameForComponent(uiPanel); gameLoadingWindow.setLocationRelativeTo(frame); diff --git a/game-app/game-headed/src/main/java/games/strategy/engine/framework/ui/MainFrame.java b/game-app/game-headed/src/main/java/games/strategy/engine/framework/ui/MainFrame.java index 02717deb334..0a6af20042d 100644 --- a/game-app/game-headed/src/main/java/games/strategy/engine/framework/ui/MainFrame.java +++ b/game-app/game-headed/src/main/java/games/strategy/engine/framework/ui/MainFrame.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; import javax.swing.JFrame; import javax.swing.SwingUtilities; import org.triplea.game.client.HeadedGameRunner; @@ -26,35 +27,35 @@ public class MainFrame { private static MainFrame instance; - private final JFrame mainFrame; + private final JFrame mainJFrame; private final MainPanel mainPanel; private final List quitActions = new ArrayList<>(); private MainFrame( final HeadedServerSetupModel headedServerSetupModel, final GameSelectorModel gameSelectorModel) { - mainFrame = + mainJFrame = JFrameBuilder.builder() .title("TripleA") .iconImage(EngineImageLoader.loadFrameIcon()) .windowClosedAction(HeadedGameRunner::exitGameIfNoWindowsVisible) .build(); - BackgroundTaskRunner.setMainFrame(mainFrame); + BackgroundTaskRunner.setMainFrame(mainJFrame); - LookAndFeelSwingFrameListener.register(mainFrame); + LookAndFeelSwingFrameListener.register(mainJFrame); final Runnable quitAction = () -> { quitActions.forEach(Runnable::run); - mainFrame.dispatchEvent(new WindowEvent(mainFrame, WindowEvent.WINDOW_CLOSING)); + mainJFrame.dispatchEvent(new WindowEvent(mainJFrame, WindowEvent.WINDOW_CLOSING)); }; mainPanel = new MainPanelBuilder(quitAction).buildMainPanel(headedServerSetupModel, gameSelectorModel); - mainFrame.add(mainPanel); - mainFrame.pack(); + mainJFrame.add(mainPanel); + mainJFrame.pack(); - headedServerSetupModel.setUi(mainFrame); + headedServerSetupModel.setUi(mainJFrame); } public static void buildMainFrame( @@ -67,14 +68,20 @@ public static void buildMainFrame( public static void show() { SwingUtilities.invokeLater( () -> { - instance.mainFrame.requestFocus(); - instance.mainFrame.toFront(); - instance.mainFrame.setVisible(true); + instance.mainJFrame.requestFocus(); + instance.mainJFrame.toFront(); + instance.mainJFrame.setVisible(true); }); } + public static void startGameDirectly(final HeadedServerSetupModel headedServerSetupModel) { + Consumer mainPanelLaunchAction = + MainPanelBuilder.getMainPanelLaunchAction(headedServerSetupModel); + SwingUtilities.invokeLater(() -> mainPanelLaunchAction.accept(instance.mainPanel)); + } + public static void hide() { - SwingUtilities.invokeLater(() -> instance.mainFrame.setVisible(false)); + SwingUtilities.invokeLater(() -> instance.mainJFrame.setVisible(false)); } public static void addQuitAction(final Runnable onQuitAction) { diff --git a/game-app/game-headed/src/main/java/org/triplea/game/client/HeadedGameRunner.java b/game-app/game-headed/src/main/java/org/triplea/game/client/HeadedGameRunner.java index 8161f011f13..838fb4208f4 100644 --- a/game-app/game-headed/src/main/java/org/triplea/game/client/HeadedGameRunner.java +++ b/game-app/game-headed/src/main/java/org/triplea/game/client/HeadedGameRunner.java @@ -5,10 +5,19 @@ import static games.strategy.engine.framework.CliProperties.TRIPLEA_CLIENT; import static games.strategy.engine.framework.CliProperties.TRIPLEA_GAME; import static games.strategy.engine.framework.CliProperties.TRIPLEA_MAP_DOWNLOAD; +import static games.strategy.engine.framework.CliProperties.TRIPLEA_MAP_DOWNLOAD_PREFIX; import static games.strategy.engine.framework.CliProperties.TRIPLEA_SERVER; +import static games.strategy.engine.framework.CliProperties.TRIPLEA_START; +import static games.strategy.engine.framework.CliProperties.TRIPLEA_START_LOBBY; +import static games.strategy.engine.framework.CliProperties.TRIPLEA_START_LOCAL; +import static games.strategy.engine.framework.CliProperties.TRIPLEA_START_PBEM; +import static games.strategy.engine.framework.CliProperties.TRIPLEA_START_PBF; +import static games.strategy.triplea.Constants.PROPERTY_FALSE; +import static games.strategy.triplea.Constants.PROPERTY_TRUE; import games.strategy.engine.ClientFileSystemHelper; import games.strategy.engine.auto.update.UpdateChecks; +import games.strategy.engine.framework.GameDataFileUtils; import games.strategy.engine.framework.GameShutdownRegistry; import games.strategy.engine.framework.I18nResourceBundle; import games.strategy.engine.framework.lookandfeel.LookAndFeel; @@ -67,12 +76,19 @@ public static void initializeLookAndFeel() { } public static void initializeDesktopIntegrations(final String[] args) { - if ((args.length == 1) && args[0].startsWith("triplea:")) { - final String value = - URLDecoder.decode(args[0].substring("triplea:".length()), StandardCharsets.UTF_8); - System.setProperty(TRIPLEA_MAP_DOWNLOAD, value); - } else if ((args.length == 1) && !args[0].contains("=")) { - System.setProperty(TRIPLEA_GAME, args[0]); + if (args.length == 1) { // simple case with one argument only + if (args[0].startsWith(TRIPLEA_MAP_DOWNLOAD_PREFIX)) { + final String value = + URLDecoder.decode( + args[0].substring(TRIPLEA_MAP_DOWNLOAD_PREFIX.length()), StandardCharsets.UTF_8); + System.setProperty(TRIPLEA_MAP_DOWNLOAD, value); + } else if (!args[0].contains("=")) { + System.setProperty(TRIPLEA_GAME, args[0]); + } else { + setPropertiesFromArgs(args); + } + } else { + setPropertiesFromArgs(args); } if (SystemProperties.isMac()) { @@ -80,7 +96,8 @@ public static void initializeDesktopIntegrations(final String[] args) { uri -> { final String mapName = URLDecoder.decode( - uri.toString().substring("triplea:".length()), StandardCharsets.UTF_8); + uri.toString().substring(TRIPLEA_MAP_DOWNLOAD_PREFIX.length()), + StandardCharsets.UTF_8); SwingUtilities.invokeLater( () -> DownloadMapsWindow.showDownloadMapsWindowAndDownload(mapName)); }); @@ -92,6 +109,26 @@ public static void initializeDesktopIntegrations(final String[] args) { } } + private static void setPropertiesFromArgs(String[] args) { + for (String arg : args) { + String[] nameValuePair = arg.split("="); + if (nameValuePair.length != 2) { + log.warn("Property '{}' not matching pattern '='.", arg); + continue; + } + switch (nameValuePair[0]) { + case TRIPLEA_GAME: + case TRIPLEA_SERVER: + case TRIPLEA_CLIENT: + case TRIPLEA_START: + System.setProperty(nameValuePair[0], nameValuePair[1]); + break; + default: + log.warn("Property '{}' not unknown.", nameValuePair[0]); + } + } + } + /** Entry point for running a new headed game client. */ public static void main(final String[] args) { checkNotNull(args); @@ -162,25 +199,23 @@ private static void start() { */ public static void showMainFrame() { GameShutdownRegistry.runShutdownActions(); - - if (System.getProperty(TRIPLEA_SERVER, "false").equals("true")) { + final String startProperty = System.getProperty(TRIPLEA_START, "").toLowerCase(Locale.ROOT); + if (startProperty.equals(TRIPLEA_START_LOBBY)) { + SwingUtilities.invokeLater(() -> headedServerSetupModel.login()); + } else if (System.getProperty(TRIPLEA_SERVER, PROPERTY_FALSE).equals(PROPERTY_TRUE)) { MainFrame.show(); gameSelectorModel.loadDefaultGameSameThread(); final ServerModel serverModel = headedServerSetupModel.showServer(); MainFrame.addQuitAction(serverModel::cancel); System.clearProperty(TRIPLEA_SERVER); - } else if (System.getProperty(TRIPLEA_CLIENT, "false").equals("true")) { + } else if (System.getProperty(TRIPLEA_CLIENT, PROPERTY_FALSE).equals(PROPERTY_TRUE)) { MainFrame.show(); headedServerSetupModel.showClient(); System.clearProperty(TRIPLEA_CLIENT); } else { final String saveGameFileName = System.getProperty(TRIPLEA_GAME, ""); if (!saveGameFileName.isEmpty()) { - final Path saveGameFile = Path.of(saveGameFileName); - if (Files.exists(saveGameFile) && !gameSelectorModel.loadSave(saveGameFile)) { - // abort launch if we failed to load the specified game - return; - } + startGameDirectly(saveGameFileName, startProperty); } MainFrame.show(); gameSelectorModel.loadDefaultGameSameThread(); @@ -188,6 +223,44 @@ public static void showMainFrame() { } } + private static void startGameDirectly(String saveGameFileName, String startProperty) { + final boolean isSaveFile = saveGameFileName.endsWith(GameDataFileUtils.getExtension()); + if (!isSaveFile && !saveGameFileName.endsWith(".xml")) { + log.warn("File '{}' neither save nor game map file", saveGameFileName); + return; + } + Path gameFilePath = Path.of(saveGameFileName); + if (!Files.exists(gameFilePath)) { + gameFilePath = + Path.of(ClientSetting.saveGamesFolderPath.getValueOrThrow().toString(), saveGameFileName); + if (!Files.exists(gameFilePath)) { + log.warn("Save game file '{}' not found", saveGameFileName); + return; + } + } + final Path fileToLoadPath = gameFilePath; + SwingUtilities.invokeLater( + () -> { + final boolean isFileLoaded; + if (isSaveFile) isFileLoaded = gameSelectorModel.loadSave(fileToLoadPath); + else isFileLoaded = gameSelectorModel.loadMap(fileToLoadPath); + if (isFileLoaded) { + switch (startProperty) { + case TRIPLEA_START_PBF: + headedServerSetupModel.showPbf(); + break; + case TRIPLEA_START_PBEM: + headedServerSetupModel.showPbem(); + break; + case TRIPLEA_START_LOCAL: + default: + headedServerSetupModel.showLocal(); + MainFrame.startGameDirectly(headedServerSetupModel); + } + } + }); + } + private static void openMapDownloadWindowIfDownloadScheduled() { final String downloadableMap = System.getProperty(TRIPLEA_MAP_DOWNLOAD, ""); if (!downloadableMap.isEmpty()) {