public async Task Update(int SelectedIndex)
        {
            Gamemode Gamemode    = DisplayGamemodes[SelectedIndex];
            int      CallerIndex = MainWindow?.Gamemodes.IndexOf(Gamemode) ?? -1;
            Release  Release     = GamemodeReleases[Gamemode];

            ReleaseAsset FoundAsset = null;

            foreach (ReleaseAsset Asset in Release.Assets.Where(Asset => Asset.Name.EndsWith(".dll")))
            {
                FoundAsset = Asset;
            }

            if (FoundAsset == null)
            {
                return;
            }

            if (!await Update(MainWindow.GetCurrentLazerPath(), Gamemode, FoundAsset))
            {
                return;
            }

            GamemodeReleases.Remove(Gamemode);
            DisplayGamemodes.RemoveAt(SelectedIndex);
            Title = OriginalTitle.Replace("%%COUNT%%", GamemodeReleases.Count.ToString("N0")).Replace("%%S%%", GamemodeReleases.Count != 1 ? "s" : string.Empty);

            if (CallerIndex >= 0)
            {
                Gamemode GamemodeClone = (Gamemode)Gamemode.Clone();
                GamemodeClone.UpdateStatus     = UpdateStatus.UpToDate;
                GamemodeClone.GitHubTagVersion = Release.TagName ?? GamemodeClone.GitHubTagVersion;
                MainWindow.UpdateGamemode(CallerIndex, GamemodeClone, true);
            }
        }
        //Returns bool specifying whether or not to continue with the process
        public async Task <bool> Update(DirectoryInfo Destination, Gamemode Gamemode, ReleaseAsset Asset)
        {
            if (Destination == null || !Destination.Exists)
            {
                Dispatcher.Invoke(() => {
                    MessageBox.Show("Selected osu!lazer installation path is invalid.", Title, MessageBoxButton.OK, MessageBoxImage.Error);
                }, System.Windows.Threading.DispatcherPriority.Normal);
                MainWindow.UpdateLazerInstallationPath(false);
                return(false);
            }
            Debug.WriteLine("Will Update " + Gamemode.RulesetFilename + " from " + Asset.BrowserDownloadUrl);

            FileInfo DestinationFile = Destination.TryGetRelativeFile(Gamemode.RulesetFilename, out FileInfo File) ? File : null;

            Debug.WriteLine("\tDestination: " + DestinationFile?.FullName);

            if (DestinationFile.Exists())
            {
                RecycleFile(DestinationFile);
            }

            await DownloadFileAsync(new Uri(Asset.BrowserDownloadUrl), DestinationFile);

            return(true);
        }
        public static async Task <Gamemode> GetGamemodeEditor(Gamemode CurrentGamemode = default)
        {
            Debug.WriteLine("Update Status: " + CurrentGamemode.UpdateStatus);
            GamemodeEditor Window = new GamemodeEditor();

            Window.Show();
            return(await Window.GetGamemode(CurrentGamemode));
        }
 public async Task <Gamemode> GetGamemode(Gamemode CurrentGamemode = default)
 {
     if (Result != null)
     {
         Debug.WriteLine("Please do not request multiple gamemodes at once.", "Warning");
         return(default);
Exemplo n.º 5
0
 async void GamemodeListAdd_Click(object Sender, RoutedEventArgs E)
 {
     Gamemode NewGamemode = await GamemodeEditor.GetGamemodeEditor(default);