Skip to content

Commit

Permalink
FAForever#3092 keep map selection when searching if the string matches
Browse files Browse the repository at this point in the history
  • Loading branch information
obydog002 committed Feb 19, 2024
1 parent 37795c7 commit 9a7bb2e
Showing 1 changed file with 12 additions and 3 deletions.
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 @@ public class CreateGameController extends NodeController<Pane> {

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 @@ protected void onInitialize() {
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 @@ protected void initMapSelection() {

private void setSelectedMap(MapVersionBean mapVersion) {
if (mapVersion == null) {
fxApplicationThreadExecutor.execute(() -> mapNameLabel.setText(""));
if (lastMapChosen != null && filteredMaps.contains(lastMapChosen)) {
mapListView.getSelectionModel().select(lastMapChosen);
} 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 @@ public void setGamesRoot(StackPane root) {
}

/**
* @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

0 comments on commit 9a7bb2e

Please sign in to comment.