Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep map selection when searching #3132

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/main/java/com/faforever/client/game/CreateGameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@

private final SimpleInvalidationListener createButtonStateListener = this::setCreateGameButtonState;

private MapVersionBean lastMapChosen = null;

public Label mapSizeLabel;
public Label mapPlayersLabel;
public Label mapDescriptionLabel;
Expand Down Expand Up @@ -158,7 +160,7 @@
mapListView.scrollTo(newMapIndex);
event.consume();
});

Function<FeaturedModBean, String> isDefaultModString = mod -> Objects.equals(mod.getTechnicalName(), KnownFeaturedMod.DEFAULT.getTechnicalName()) ? " " + i18n.get("game.create.defaultGameTypeMarker") : null;

featuredModListView.setCellFactory(param -> new DualStringListCell<>(FeaturedModBean::getDisplayName, isDefaultModString, FeaturedModBean::getDescription, STYLE_CLASS_DUAL_LIST_CELL, uiService, fxApplicationThreadExecutor));
Expand Down Expand Up @@ -299,10 +301,17 @@

private void setSelectedMap(MapVersionBean mapVersion) {
if (mapVersion == null) {
fxApplicationThreadExecutor.execute(() -> mapNameLabel.setText(""));
if (lastMapChosen != null && filteredMaps.contains(lastMapChosen)) {
mapListView.getSelectionModel().select(lastMapChosen);

Check warning on line 305 in src/main/java/com/faforever/client/game/CreateGameController.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/faforever/client/game/CreateGameController.java#L305

Added line #L305 was not covered by tests
} else {
lastMapChosen = null;
fxApplicationThreadExecutor.execute(() -> mapNameLabel.setText(""));
}
return;
}

lastMapChosen = mapVersion;

ComparableVersion version = mapVersion.getVersion();
MapSize mapSize = mapVersion.getSize();
Image largePreview = mapService.loadPreview(mapVersion.getFolderName(), PreviewSize.LARGE);
Expand Down Expand Up @@ -501,7 +510,7 @@
}

/**
* @return returns true of the map was found and false if not
* @return returns true if the map was found and false if not
*/
boolean selectMap(String mapFolderName) {
Optional<MapVersionBean> mapBeanOptional = mapListView.getItems()
Expand Down
Loading