Skip to content

Commit

Permalink
Merge pull request #557 from TheTrackerCouncil/sprite-download-updates
Browse files Browse the repository at this point in the history
Sprite download updates
  • Loading branch information
MattEqualsCoder authored Jul 24, 2024
2 parents 36e3406 + 167ebf1 commit fc539ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
9 changes: 9 additions & 0 deletions src/TrackerCouncil.Smz3.UI/Services/MainWindowService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
Expand Down Expand Up @@ -112,6 +113,14 @@ public async Task DownloadSpritesAsync()
return;
}

#if DEBUG
// Skip sprite download when debugging if the folder already exists
if (Directory.Exists(Sprite.SpritePath))
{
return;
}
#endif

var toDownload = await gitHubSpriteDownloaderService.GetSpritesToDownloadAsync("TheTrackerCouncil", "SMZ3CasSprites");

if (toDownload is not { Count: > 4 })
Expand Down
26 changes: 9 additions & 17 deletions src/TrackerCouncil.Smz3.UI/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,24 @@ private void DisableUpdatesLink_OnClick(object? sender, RoutedEventArgs e)
_service?.DisableUpdates();
}

private void Control_OnLoaded(object? sender, RoutedEventArgs e)
private async void Control_OnLoaded(object? sender, RoutedEventArgs e)
{
if (_model.HasInvalidOptions)
if (_model.HasInvalidOptions && _serviceProvider != null)
{
var messageWindow = new MessageWindow(new MessageWindowRequest()
{
Message = "If this is your first time using the randomizer, there are some required options you need to configure before you can start playing randomized SMZ3 games. Please do so now.",
Title = "SMZ3 Cas’ Randomizer",
Icon = MessageWindowIcon.Info,
Buttons = MessageWindowButtons.OK
});
messageWindow.ShowDialog(this);
messageWindow.Closed += (o, args) =>
{
_serviceProvider?.GetRequiredService<OptionsWindow>().ShowDialog(this);
};
await MessageWindow.ShowInfoDialog(
"If this is your first time using the randomizer, there are some required options you need to configure before you can start playing randomized SMZ3 games. Please do so now.",
"SMZ3 Cas’ Randomizer", this);
await _serviceProvider.GetRequiredService<OptionsWindow>().ShowDialog(this);
}

if (_service == null)
{
return;
}

ITaskService.Run(_service.ValidateTwitchToken);
ITaskService.Run(_service.DownloadConfigsAsync);
ITaskService.Run(_service.DownloadSpritesAsync);
_ = ITaskService.Run(_service.ValidateTwitchToken);
_ = ITaskService.Run(_service.DownloadConfigsAsync);
_ = ITaskService.Run(_service.DownloadSpritesAsync);
}

private void OptionsMenuItem_OnClick(object? sender, RoutedEventArgs e)
Expand Down

0 comments on commit fc539ea

Please sign in to comment.