From 917c6efb69196a425ea976b1ab8ae71a45672d38 Mon Sep 17 00:00:00 2001 From: SaltyCuban <137945152+SaltyCuban@users.noreply.github.com> Date: Mon, 28 Oct 2024 07:01:28 -0400 Subject: [PATCH] Crossplay check box (#62) * added variables to hold and check teh check box status as well as added the check box * adjusted variable to a string and added it to the argument that gets passed to steam cmd --- ValheimServer/ValheimServer/MainWindow.xaml | 2 ++ .../Properties/Resources.Designer.cs | 9 +++++ .../ValheimServer/Properties/Resources.resx | 3 ++ .../ViewModels/MainWindowViewModel.cs | 34 ++++++++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/ValheimServer/ValheimServer/MainWindow.xaml b/ValheimServer/ValheimServer/MainWindow.xaml index 8c38d0b..16cf4f7 100644 --- a/ValheimServer/ValheimServer/MainWindow.xaml +++ b/ValheimServer/ValheimServer/MainWindow.xaml @@ -75,5 +75,7 @@ + + diff --git a/ValheimServer/ValheimServer/Properties/Resources.Designer.cs b/ValheimServer/ValheimServer/Properties/Resources.Designer.cs index 3ac284a..d8bce35 100644 --- a/ValheimServer/ValheimServer/Properties/Resources.Designer.cs +++ b/ValheimServer/ValheimServer/Properties/Resources.Designer.cs @@ -78,6 +78,15 @@ public static string Port_Name { } } + /// + /// Looks up a localized string similar to Crossplay. + /// + public static string Server_Crossplay { + get { + return ResourceManager.GetString("Server_Crossplay", resourceCulture); + } + } + /// /// Looks up a localized string similar to Server Name:. /// diff --git a/ValheimServer/ValheimServer/Properties/Resources.resx b/ValheimServer/ValheimServer/Properties/Resources.resx index 7f8ff6f..4416d51 100644 --- a/ValheimServer/ValheimServer/Properties/Resources.resx +++ b/ValheimServer/ValheimServer/Properties/Resources.resx @@ -123,6 +123,9 @@ Port Number: + + Crossplay + Server Name: diff --git a/ValheimServer/ValheimServer/ViewModels/MainWindowViewModel.cs b/ValheimServer/ValheimServer/ViewModels/MainWindowViewModel.cs index 4efd7b8..b93bfe7 100644 --- a/ValheimServer/ValheimServer/ViewModels/MainWindowViewModel.cs +++ b/ValheimServer/ValheimServer/ViewModels/MainWindowViewModel.cs @@ -27,6 +27,7 @@ public partial class MainWindowViewModel : ObservableObject private string _passwordTextBox; private string _hiddenTextBox; private bool _serverVisibilityCheckBox = true; + private bool _serverCrossPlayCheckBox = false; /// /// Initializes a new instance of the class. @@ -186,6 +187,22 @@ public bool ServerVisibilityCheckBox } } + /// + /// Gets or Sets a value indicating whether the checkbox is visible. + /// + public bool ServerCrossPlayCheckBox + { + get + { + return _serverCrossPlayCheckBox; + } + + set + { + SetProperty(ref _serverCrossPlayCheckBox, value); + } + } + private int ServerVisibiltyCheck { get @@ -201,6 +218,21 @@ private int ServerVisibiltyCheck } } + private string ServerCrossPlayCheck + { + get + { + if (_serverCrossPlayCheckBox == true) + { + return "-crossplay"; + } + else + { + return " "; + } + } + } + [RelayCommand] private void SteamButtonClick() { @@ -250,7 +282,7 @@ private void ServerStartButtonClick() ProcessStartInfo startInfo = new ProcessStartInfo { FileName = "cmd.exe", - Arguments = $@"/K set SteamAppId=892970 && {_installFolder}\\valheim_server.exe -nographics -batchmode -name ""{_serverTextBox}"" -port {_portTextBox} -world ""{_worldTextBox}"" -password ""{_passwordTextBox}"" -public {ServerVisibiltyCheck}", + Arguments = $@"/K set SteamAppId=892970 && {_installFolder}\\valheim_server.exe -nographics -batchmode -name ""{_serverTextBox}"" -port {_portTextBox} -world ""{_worldTextBox}"" -password ""{_passwordTextBox}"" -public {ServerVisibiltyCheck} {ServerCrossPlayCheck}", UseShellExecute = false, };