Skip to content

Commit

Permalink
Attempt to fix initialization of the CustomGamesController
Browse files Browse the repository at this point in the history
  • Loading branch information
chrsin authored and Chris Haggan committed Apr 15, 2022
1 parent 50fbabe commit 3b04c18
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public TilesSortingOrder fromString(String string) {
}
});

ObservableList<Game> games = gameService.getGames();

filteredItems = new FilteredList<>(games);
JavaFxUtil.bindBidirectional(showModdedGamesCheckBox.selectedProperty(), preferencesService.getPreferences().showModdedGamesProperty());
JavaFxUtil.bindBidirectional(showPasswordProtectedGamesCheckBox.selectedProperty(), preferencesService.getPreferences().showPasswordProtectedGamesProperty());

ObservableList<Game> games = gameService.getGames();
filteredItems = new FilteredList<>(games, getGamePredicate());
updateFilteredItems();

JavaFxUtil.addListener(preferencesService.getPreferences().showModdedGamesProperty(), new WeakChangeListener<>(filterConditionsChangedListener));
JavaFxUtil.addListener(preferencesService.getPreferences().showPasswordProtectedGamesProperty(), new WeakChangeListener<>(filterConditionsChangedListener));

Expand Down Expand Up @@ -175,11 +175,14 @@ protected void onDisplay(NavigateEvent navigateEvent) {

private void updateFilteredItems() {
preferencesService.storeInBackground();
filteredItems.setPredicate(getGamePredicate());
}

private Predicate<Game> getGamePredicate() {
boolean showPasswordProtectedGames = showPasswordProtectedGamesCheckBox.isSelected();
boolean showModdedGames = showModdedGamesCheckBox.isSelected();

filteredItems.setPredicate(OPEN_CUSTOM_GAMES_PREDICATE.and(gameInfoBean ->
return (OPEN_CUSTOM_GAMES_PREDICATE.and(gameInfoBean ->
(showPasswordProtectedGames || !gameInfoBean.isPasswordProtected())
&& (showModdedGames || gameInfoBean.getSimMods().isEmpty())));
}
Expand Down

0 comments on commit 3b04c18

Please sign in to comment.