Skip to content

Commit

Permalink
Merge pull request #240 from stayintarkov/hide-start-server-button
Browse files Browse the repository at this point in the history
Hide start server button
  • Loading branch information
Plootie committed May 5, 2024
2 parents 3cffbe8 + 9b52f9b commit 851a066
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 9 additions & 4 deletions SIT.Manager/ViewModels/Play/DirectConnectViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public partial class DirectConnectViewModel : ObservableRecipient
[ObservableProperty]
private string _quickPlayText = string.Empty;

[ObservableProperty]
private bool _isLocalServerRunning = false;

public IAsyncRelayCommand ConnectToServerCommand { get; }
public IAsyncRelayCommand QuickPlayCommand { get; }

Expand Down Expand Up @@ -76,9 +79,9 @@ public partial class DirectConnectViewModel : ObservableRecipient
QuickPlayCommand = new AsyncRelayCommand(async () => await ConnectToServer(true));
}

public Task ConnectToServer(string address, string username, string password)
public Task ConnectToServer(string address, string username, string password)
{
if(!string.IsNullOrEmpty(address))
if (!string.IsNullOrEmpty(address))
{
LastServer = address;
}
Expand All @@ -87,12 +90,12 @@ public Task ConnectToServer(string address, string username, string password)
LastServer = "127.0.0.1";
}

if(!string.IsNullOrEmpty(username))
if (!string.IsNullOrEmpty(username))
{
Username = username;
}

if(!string.IsNullOrEmpty(password))
if (!string.IsNullOrEmpty(password))
{
Password = password;
}
Expand Down Expand Up @@ -308,6 +311,7 @@ private async Task<bool> LaunchServer()
}

QuickPlayText = _localizationService.TranslateSource("DirectConnectViewModelQuickPlayText");
IsLocalServerRunning = _akiServerService.State == RunningState.Running || _akiServerService.State == RunningState.Starting;
return aborted;
}

Expand All @@ -316,5 +320,6 @@ protected override void OnActivated()
base.OnActivated();

QuickPlayText = _localizationService.TranslateSource("DirectConnectViewModelQuickPlayText");
IsLocalServerRunning = _akiServerService.State == RunningState.Running || _akiServerService.State == RunningState.Starting;
}
}
9 changes: 8 additions & 1 deletion SIT.Manager/Views/Play/DirectConnectView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<Label Content="{DynamicResource DirectConnectViewPasswordBoxTitle}" Margin="10 10 10 0" FontWeight="Bold" FontSize="14"/>
<TextBox Name="PasswordBox" Text="{Binding Password, Mode=TwoWay}" MinWidth="300" Margin="8 4 8 8" HorizontalAlignment="Left" PasswordChar="" Watermark="{DynamicResource DirectConnectViewEnterPasswordPlaceholder}"/>
<CheckBox Name="RememberMeCheck" Content="{DynamicResource DirectConnectViewRememberMeCheckBoxTitle}" Margin="8" IsChecked="{Binding RememberMe}"/>
<Grid ColumnDefinitions="*, *" Margin="8">
<Grid ColumnDefinitions="*, auto" Margin="8">
<Button Name="ConnectButton"
Grid.Column="0"
HorizontalAlignment="Stretch"
Expand All @@ -42,6 +42,13 @@
Command="{Binding QuickPlayCommand}"
ToolTip.Tip="{DynamicResource DirectConnectViewStartServerAndConnectButtonTitleToolTip}"
Margin="4,0,0,0">
<Button.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="ManagerConfig.AkiServerPath" Converter="{x:Static StringConverters.IsNotNullOrEmpty}"/>
<Binding Path="!IsLocalServerRunning"/>
</MultiBinding>
</Button.IsVisible>

<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding QuickPlayText}"/>
<controls:LoadingSpinner Width="12"
Expand Down

0 comments on commit 851a066

Please sign in to comment.