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 3 commits
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
12 changes: 10 additions & 2 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 @@ -270,7 +272,13 @@
mapListView.getSelectionModel()
.selectedItemProperty()
.when(showing)
.subscribe(this::setSelectedMap);
.subscribe((oldItem, newItem) -> {
if (newItem == null && oldItem != null && filteredMaps.contains(oldItem)) {
mapListView.getSelectionModel().select(oldItem);

Check warning on line 277 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#L277

Added line #L277 was not covered by tests
} else {
setSelectedMap(newItem);
}
});

FilteredList<MapVersionBean> skirmishMaps = mapService.getInstalledMaps()
.filtered(mapVersion -> mapVersion.getMap().getMapType() == MapType.SKIRMISH);
Expand Down Expand Up @@ -501,7 +509,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