Skip to content

Commit

Permalink
added play button disabling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Enn3Developer committed May 27, 2024
1 parent 09888b3 commit b970b40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class MainViewModel : ViewModelBase
private UpdateInfo? _updateInfo;
private string _serverInfo = "0/20";
private bool _needsJava;
private bool _isPlayEnabled;

public MainViewModel()
{
Expand Down Expand Up @@ -86,6 +87,12 @@ public string ServerInfo
private set => this.RaiseAndSetIfChanged(ref _serverInfo, value);
}

public bool IsPlayEnabled
{
get => _isPlayEnabled;
private set => this.RaiseAndSetIfChanged(ref _isPlayEnabled, value);
}

private async Task<string?> CheckJava()
{
UpdateProgress(0.0f, "Checking Java version", false);
Expand Down Expand Up @@ -404,7 +411,9 @@ await _updateManager.DownloadUpdatesAsync(_updateInfo,

private async Task OnPlayButton()
{
IsPlayEnabled = false;
await PlayButtonRun();
IsPlayEnabled = true;
}

private async Task DownloadUpdate()
Expand Down Expand Up @@ -468,6 +477,7 @@ public async Task AsyncOnLoaded()
{
UpdateProgress(1.0f, "Found launcher updates");
PlayText = "Update";
IsPlayEnabled = true;
return;
}
}
Expand All @@ -489,6 +499,8 @@ public async Task AsyncOnLoaded()
{
UpdateProgress(1.0f, "Ready");
}

IsPlayEnabled = true;
}

private void UpdateProgress(float value, string desc, bool determinateValue = true)
Expand Down
2 changes: 1 addition & 1 deletion Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<Label Content="{CompiledBinding ServerInfo}" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="20">
<Button Command="{CompiledBinding PlayBtn}">
<Button Command="{CompiledBinding PlayBtn}" IsEnabled="{CompiledBinding IsPlayEnabled}">
<Label Content="{CompiledBinding PlayText}" FontSize="20" />
</Button>
<Rectangle Fill="White" Width="2" />
Expand Down

0 comments on commit b970b40

Please sign in to comment.