Skip to content

Commit 86df738

Browse files
committed
Bring back force relay option
1 parent 58fb8f7 commit 86df738

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

src/main/java/com/faforever/client/fa/relay/ice/IceAdapterImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ List<String> buildCommand(Path workDirectory, int adapterPort, int gpgPort, int
241241

242242
cmd.addAll(standardIceOptions);
243243

244+
if (forgedAlliancePrefs.isForceRelay()) {
245+
cmd.add("--force-relay");
246+
log.info("Forcing ice adapter relay connection");
247+
}
248+
244249
if (forgedAlliancePrefs.isShowIceAdapterDebugWindow()) {
245250
cmd.add("--debug-window");
246251
cmd.add("--info-window");

src/main/java/com/faforever/client/preferences/ForgedAlliancePrefs.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class ForgedAlliancePrefs {
2222
private final ObjectProperty<Path> preferencesFile = new SimpleObjectProperty<>();
2323
private final ObjectProperty<Path> vaultBaseDirectory = new SimpleObjectProperty<>();
2424
private final BooleanProperty warnNonAsciiVaultPath = new SimpleBooleanProperty(true);
25+
private final BooleanProperty forceRelay = new SimpleBooleanProperty(false);
2526
private final BooleanProperty autoDownloadMaps = new SimpleBooleanProperty(true);
2627
private final BooleanProperty allowIpv6 = new SimpleBooleanProperty(false);
2728

@@ -51,6 +52,18 @@ public ObjectProperty<Path> preferencesFileProperty() {
5152
return preferencesFile;
5253
}
5354

55+
public boolean isForceRelay() {
56+
return forceRelay.get();
57+
}
58+
59+
public void setForceRelay(boolean forceRelay) {
60+
this.forceRelay.set(forceRelay);
61+
}
62+
63+
public BooleanProperty forceRelayProperty() {
64+
return forceRelay;
65+
}
66+
5467
public boolean isAutoDownloadMaps() {
5568
return autoDownloadMaps.get();
5669
}

src/main/java/com/faforever/client/preferences/ui/SettingsController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public class SettingsController extends NodeController<Node> {
119119
public Toggle randomColorsToggle;
120120
public Toggle defaultColorsToggle;
121121
public CheckBox hideFoeToggle;
122+
public CheckBox forceRelayToggle;
122123
public TextField dataLocationTextField;
123124
public TextField gameLocationTextField;
124125
public TextField vaultLocationTextField;
@@ -308,6 +309,7 @@ private void bindGeneralPreferences() {
308309

309310
private void bindGamePreferences() {
310311
ForgedAlliancePrefs forgedAlliancePrefs = preferences.getForgedAlliance();
312+
forceRelayToggle.selectedProperty().bindBidirectional(forgedAlliancePrefs.forceRelayProperty());
311313
gameLocationTextField.textProperty()
312314
.bindBidirectional(forgedAlliancePrefs.installationPathProperty(), PATH_STRING_CONVERTER);
313315
autoDownloadMapsToggle.selectedProperty().bindBidirectional(forgedAlliancePrefs.autoDownloadMapsProperty());

src/main/resources/theme/settings/settings.fxml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,27 @@
854854
</ListView>
855855
</children>
856856
</GridPane>
857+
<GridPane styleClass="setting-container">
858+
<columnConstraints>
859+
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0"/>
860+
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES"
861+
minWidth="10.0"/>
862+
</columnConstraints>
863+
<rowConstraints>
864+
<RowConstraints minHeight="10.0" valignment="TOP" vgrow="SOMETIMES"/>
865+
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
866+
</rowConstraints>
867+
<children>
868+
<Label contentDisplay="RIGHT" maxWidth="1.7976931348623157E308"
869+
styleClass="setting-title" text="%settings.fa.forceRelay"/>
870+
<Label styleClass="setting-description"
871+
text="%settings.fa.forceRelay.description"
872+
GridPane.columnSpan="2147483647" GridPane.hgrow="ALWAYS"
873+
GridPane.rowIndex="1"/>
874+
<CheckBox fx:id="forceRelayToggle" contentDisplay="GRAPHIC_ONLY"
875+
mnemonicParsing="false" GridPane.columnIndex="1"/>
876+
</children>
877+
</GridPane>
857878
</children>
858879
</VBox>
859880
</content>

src/test/java/com/faforever/client/fa/relay/ice/IceAdapterImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public void testBuildCommand() throws Exception {
118118
PlayerInfo currentPlayer = PlayerInfoBuilder.create().defaultValues().get();
119119
when(playerService.getCurrentPlayer()).thenReturn(currentPlayer);
120120
when(tokenRetriever.getRefreshedTokenValue()).thenReturn(Mono.just("someToken"));
121+
forgedAlliancePrefs.setForceRelay(true);
121122
forgedAlliancePrefs.setShowIceAdapterDebugWindow(true);
122123

123124
List<String> command = instance.buildCommand(Path.of("."), 0, 0, 4711);

0 commit comments

Comments
 (0)