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

Add versioning to maps in the installed maps dialog #3267

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public record MapVersion(
boolean ranked,
URL downloadUrl,
URL thumbnailUrlSmall,
URL thumbnailUrlLarge, Map map,
URL thumbnailUrlLarge,
Map map,
OffsetDateTime createTime
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.faforever.client.domain.api.Map;
import com.faforever.client.domain.api.MapVersion;
import com.faforever.client.fx.NodeController;
import com.faforever.client.i18n.I18n;
import com.faforever.client.map.MapService;
import com.faforever.client.map.MapService.PreviewSize;
import com.faforever.client.notification.NotificationService;
Expand All @@ -14,6 +15,8 @@
import javafx.scene.layout.HBox;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.apache.maven.artifact.versioning.ComparableVersion;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
Expand All @@ -28,7 +31,9 @@ public class RemovableMapCellController extends NodeController<HBox> {
public Button removeButton;
public ImageView previewMapView;
public Label mapNameLabel;
public Label mapVersionLabel;

private final I18n i18n;
private final MapService mapService;
private final NotificationService notificationService;

Expand All @@ -39,6 +44,10 @@ protected void onInitialize() {
previewMapView.imageProperty().bind(mapVersion.map(MapVersion::folderName)
.map(folderName -> mapService.loadPreview(folderName, PreviewSize.SMALL)));
mapNameLabel.textProperty().bind(mapVersion.map(MapVersion::map).map(Map::displayName));
mapVersionLabel.textProperty()
.bind(mapVersion.map(MapVersion::version)
.map(ComparableVersion::getCanonical)
.map(version -> i18n.get("versionFormat", version)));
removeButton.disableProperty().bind(mapVersion.map(mapService::isCustomMap).map(isCustom -> !isCustom));
removeButton.onMouseClickedProperty()
.bind(mapVersion.map(
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/theme/vault/map/removable_map_cell.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
fx:controller="com.faforever.client.map.management.RemovableMapCellController">
<children>
<ImageView fx:id="previewMapView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true"/>
<Label fx:id="mapNameLabel" prefWidth="280.0">
<Label fx:id="mapNameLabel">
<HBox.margin>
<Insets left="5.0" right="5.0"/>
</HBox.margin>
</Label>
<Label fx:id="mapVersionLabel" maxWidth="370.0" HBox.hgrow="ALWAYS"/>
<Button fx:id="removeButton" mnemonicParsing="false" prefHeight="24.0" prefWidth="24.0">
<graphic>
<Region>
Expand Down
Loading