Search in sources :

Example 1 with GameChooserModel

use of games.strategy.engine.framework.ui.GameChooserModel in project triplea by triplea-game.

the class GameSelectorModel method selectByName.

private GameChooserEntry selectByName() {
    final String userPreferredDefaultGameName = ClientSetting.DEFAULT_GAME_NAME_PREF.value();
    final GameChooserModel model = new GameChooserModel();
    GameChooserEntry selectedGame = model.findByName(userPreferredDefaultGameName).orElse(null);
    if (selectedGame == null && model.size() > 0) {
        selectedGame = model.get(0);
    }
    if (selectedGame == null) {
        return null;
    }
    if (!selectedGame.isGameDataLoaded()) {
        try {
            selectedGame.fullyParseGameData();
        } catch (final GameParseException e) {
            model.removeEntry(selectedGame);
            resetToFactoryDefault();
            return null;
        }
    }
    return selectedGame;
}
Also used : GameChooserEntry(games.strategy.engine.framework.ui.GameChooserEntry) GameChooserModel(games.strategy.engine.framework.ui.GameChooserModel) GameParseException(games.strategy.engine.data.GameParseException)

Aggregations

GameParseException (games.strategy.engine.data.GameParseException)1 GameChooserEntry (games.strategy.engine.framework.ui.GameChooserEntry)1 GameChooserModel (games.strategy.engine.framework.ui.GameChooserModel)1