Skip to content

Commit

Permalink
Add versioning to maps in the installed maps dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
obydog002 committed Oct 31, 2024
1 parent fe8b09f commit d464860
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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

0 comments on commit d464860

Please sign in to comment.