Skip to content

Commit

Permalink
Add map description to game detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Axle1975 committed Nov 13, 2021
1 parent 0a37a9d commit 6ec1680
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.faforever.client.fx.Controller;
import com.faforever.client.fx.JavaFxUtil;
import com.faforever.client.i18n.I18n;
import com.faforever.client.map.MapBean;
import com.faforever.client.map.MapService;
import com.faforever.client.map.MapService.PreviewType;
import com.faforever.client.mod.ModService;
Expand All @@ -22,6 +23,7 @@
import javafx.beans.WeakInvalidationListener;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.WeakChangeListener;
import javafx.collections.ObservableMap;
Expand Down Expand Up @@ -67,6 +69,7 @@ public class GameDetailController implements Controller<Pane> {
public Pane gameDetailRoot;
public Label gameTypeLabel;
public Label mapLabel;
public Label mapDescription;
public Label numberOfPlayersLabel;
public Label gameStatusLabel;
public Label hostLabel;
Expand Down Expand Up @@ -145,7 +148,7 @@ public void initialize() {

mapContextMenuController = uiService.loadFxml("theme/play/game_detail_map_context_menu.fxml");

JavaFxUtil.addLabelContextMenus(uiService, gameTitleLabel, mapLabel, gameTypeLabel);
JavaFxUtil.addLabelContextMenus(uiService, gameTitleLabel, hostLabel);
gameDetailRoot.parentProperty().addListener(observable -> {
if (!(gameDetailRoot.getParent() instanceof Pane)) {
return;
Expand All @@ -157,6 +160,7 @@ public void initialize() {
gameTitleLabel.managedProperty().bind(gameTitleLabel.visibleProperty());
hostLabel.managedProperty().bind(hostLabel.visibleProperty());
mapLabel.managedProperty().bind(mapLabel.visibleProperty());
mapDescription.managedProperty().bind(mapDescription.visibleProperty());
numberOfPlayersLabel.managedProperty().bind(numberOfPlayersLabel.visibleProperty());
mapImageView.managedProperty().bind(mapImageView.visibleProperty());
gameTypeLabel.managedProperty().bind(gameTypeLabel.visibleProperty());
Expand Down Expand Up @@ -266,6 +270,16 @@ public void setGame(Game game) {
this.watchButtonController.setGame(game);
}

Optional<MapBean> knownMap = mapService.getMapLocallyFromName(game.getFeaturedMod(), game.getMapName());
if (knownMap.isPresent()) {
mapDescription.setVisible(true);
mapDescription.textProperty().setValue(knownMap.get().getDescription());
}
else {
mapDescription.textProperty().setValue(null);
mapDescription.setVisible(false);
}

gameTitleLabel.textProperty().bind(game.titleProperty());
hostLabel.textProperty().bind(game.hostProperty());
mapLabel.textProperty().bind(game.mapNameProperty());
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ game.create.install=Set Game Location
settings.fa.enableAutoJoin=Auto-Join Rehosted Games
settings.fa.enableAutoJoin.description=Enable to automatically activate the Auto-Join feature for any games that you play. This will ensure that when/if the host rehosts another game, you'll automatically join them for a rematch
game.create.update=Update
game.detail.map.createNew=Create new game on this map
game.detail.map.createNew=Inspect map / Create new game
game.detail.map.changeMap=Change map
game.detail.map.browseMap=Inspect map
teammatchmaking.queue.ladder1v1_tacc=Core Cont. 1v1
Expand Down
25 changes: 13 additions & 12 deletions src/main/resources/theme/play/game_detail.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.HBox?>

<?import javafx.scene.layout.AnchorPane?>
<GridPane fx:id="gameDetailRoot" maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minWidth="50.0" styleClass="game-detail" vgap="10.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.faforever.client.game.GameDetailController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
Expand All @@ -27,10 +28,15 @@
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ImageView fx:id="mapImageView" onMouseClicked="#onClickedMap" fitWidth="230.0" fitHeight="320.0" pickOnBounds="true" preserveRatio="true" styleClass="map-preview" GridPane.columnSpan="2147483647" GridPane.halignment="CENTER" />
<AnchorPane GridPane.columnSpan="2147483647" GridPane.halignment="CENTER">
<ImageView fx:id="mapImageView" onMouseClicked="#onClickedMap" fitWidth="230.0" fitHeight="320.0" pickOnBounds="true" preserveRatio="true" styleClass="map-preview"/>
<VBox alignment="BOTTOM_LEFT" styleClass="image-dimmer" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<Label fx:id="mapLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Map&gt;" wrapText="true"/>
<Label fx:id="mapDescription" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Map Description&gt;" wrapText="true"/>
</VBox>
</AnchorPane>
<Label fx:id="gameTitleLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" styleClass="game-title" text="&lt;A pretty long game title&gt;" wrapText="true" GridPane.columnSpan="2147483647" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" />
<Label fx:id="gameTypeLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Game type&gt;" wrapText="true" GridPane.rowIndex="2" />
<Label fx:id="gameStatusLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Map&gt;" wrapText="true" GridPane.rowIndex="3">
Expand All @@ -39,34 +45,29 @@
</graphic>
</Label>
<Label fx:id="gameTimeSinceStartLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Map&gt;" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Label fx:id="mapLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Map&gt;" wrapText="true" GridPane.rowIndex="4">
<graphic>
<Region styleClass="icon,map-icon" />
</graphic>
</Label>
<Label fx:id="hostLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Host&gt;" wrapText="true" GridPane.rowIndex="5">
<Label fx:id="hostLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Host&gt;" wrapText="true" GridPane.rowIndex="4">
<graphic>
<Region styleClass="icon,host-icon" />
</graphic>
</Label>
<Label fx:id="numberOfPlayersLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Number of players&gt;" wrapText="true" GridPane.rowIndex="6">
<Label fx:id="numberOfPlayersLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Number of players&gt;" wrapText="true" GridPane.rowIndex="5">
<graphic>
<Region styleClass="icon,players-icon" />
</graphic>
</Label>
<Label fx:id="liveReplayDelayLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Number of players&gt;" wrapText="true" GridPane.rowIndex="7">
<Label fx:id="liveReplayDelayLabel" maxWidth="1.7976931348623157E308" minWidth="0.0" text="&lt;Number of players&gt;" wrapText="true" GridPane.rowIndex="6">
<graphic>
<Region styleClass="icon,live-tv-icon" />
</graphic>
</Label>
<HBox alignment="CENTER" GridPane.columnSpan="2147483647" GridPane.rowIndex="8">
<HBox alignment="CENTER" GridPane.columnSpan="2147483647" GridPane.rowIndex="7">
<fx:include fx:id="watchButton" source="../vault/replay/watch_button.fxml"/>
<Button fx:id="leaveButton" mnemonicParsing="false" onAction="#onLeaveButtonClicked" text="%game.leave" styleClass="leave-game-button"><tooltip><Tooltip text="%game.leave.tooltip"/></tooltip></Button>
<Button fx:id="startButton" mnemonicParsing="false" onAction="#onStartButtonClicked" text="%game.start" styleClass="start-game-button"><tooltip><Tooltip text="%game.start.tooltip"/></tooltip></Button>
<Button fx:id="joinButton" mnemonicParsing="false" onAction="#onJoinButtonClicked" text="%game.join" styleClass="join-game-button"><tooltip><Tooltip text="%game.join.tooltip"/></tooltip></Button>
<Button fx:id="autoJoinButton" mnemonicParsing="false" onAction="#onAutoJoinButtonClicked" text="%game.autojoin" styleClass="autojoin-game-button-not-active"><tooltip><Tooltip text="%game.autojoin.tooltip"/></tooltip></Button>
</HBox>
<VBox alignment="BOTTOM_CENTER" fx:id="teamListPane" maxWidth="1.7976931348623157E308" spacing="10.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="9" />
<VBox alignment="BOTTOM_CENTER" fx:id="teamListPane" maxWidth="1.7976931348623157E308" spacing="10.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="8" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
Expand Down

0 comments on commit 6ec1680

Please sign in to comment.