Exemple #1
0
 public void TestReadBeatmaps()
 {
     using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz"))
     {
         var      reader   = new OszArchiveReader(osz);
         string[] expected =
         {
             "Soleily - Renatus (Deif) [Platter].osu",
             "Soleily - Renatus (Deif) [Rain].osu",
             "Soleily - Renatus (Deif) [Salad].osu",
             "Soleily - Renatus (ExPew) [Another].osu",
             "Soleily - Renatus (ExPew) [Hyper].osu",
             "Soleily - Renatus (ExPew) [Normal].osu",
             "Soleily - Renatus (Gamu) [Hard].osu",
             "Soleily - Renatus (Gamu) [Insane].osu",
             "Soleily - Renatus (Gamu) [Normal].osu",
             "Soleily - Renatus (MMzz) [Futsuu].osu",
             "Soleily - Renatus (MMzz) [Muzukashii].osu",
             "Soleily - Renatus (MMzz) [Oni].osu"
         };
         var maps = reader.ReadBeatmaps();
         foreach (var map in expected)
         {
             Assert.Contains(map, maps);
         }
     }
 }
Exemple #2
0
        protected override void Load(BaseGame game)
        {
            base.Load(game);

            OszArchiveReader.Register();
            Beatmaps = new BeatmapDatabase(Host.Storage, Host);

            //this completely overrides the framework default. will need to change once we make a proper FontStore.
            Fonts = new TextureStore()
            {
                ScaleAdjust = 0.01f
            };

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic"));

            API = new APIAccess()
            {
                Username = Config.Get <string>(OsuConfig.Username),
                Password = Config.Get <string>(OsuConfig.Password),
                Token    = Config.Get <string>(OsuConfig.Token)
            };
        }
Exemple #3
0
        private void load()
        {
            Dependencies.Cache(this);
            Dependencies.Cache(LocalConfig);

            SQLiteConnection connection = Host.Storage.GetDatabase(@"client");

            Dependencies.Cache(RulesetDatabase = new RulesetDatabase(Host.Storage, connection));
            Dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, connection, RulesetDatabase, Host));
            Dependencies.Cache(ScoreDatabase   = new ScoreDatabase(Host.Storage, connection, Host, BeatmapDatabase));
            Dependencies.Cache(new OsuColour());

            //this completely overrides the framework default. will need to change once we make a proper FontStore.
            Dependencies.Cache(Fonts = new FontStore {
                ScaleAdjust = 100
            }, true);

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light"));

            var defaultBeatmap = new DummyWorkingBeatmap(this);

            Beatmap = new NonNullableBindable <WorkingBeatmap>(defaultBeatmap);
            BeatmapDatabase.DefaultBeatmap = defaultBeatmap;

            OszArchiveReader.Register();

            Dependencies.Cache(API = new APIAccess
            {
                Username = LocalConfig.Get <string>(OsuSetting.Username),
                Token    = LocalConfig.Get <string>(OsuSetting.Token)
            });

            API.Register(this);
        }
Exemple #4
0
 public void TestReadFile()
 {
     using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz"))
     {
         var reader = new OszArchiveReader(osz);
         using (var stream = new StreamReader(
                    reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
         {
             Assert.AreEqual("osu file format v13", stream.ReadLine().Trim());
         }
     }
 }
Exemple #5
0
        private void load()
        {
            Dependencies.Cache(this);
            Dependencies.Cache(LocalConfig);
            Dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, Host));
            Dependencies.Cache(ScoreDatabase   = new ScoreDatabase(Host.Storage, Host, BeatmapDatabase));
            Dependencies.Cache(new OsuColour());

            //this completely overrides the framework default. will need to change once we make a proper FontStore.
            Dependencies.Cache(Fonts = new FontStore {
                ScaleAdjust = 100
            }, true);

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera"));

            OszArchiveReader.Register();

            Dependencies.Cache(API = new APIAccess
            {
                Username = LocalConfig.Get <string>(OsuConfig.Username),
                Token    = LocalConfig.Get <string>(OsuConfig.Token)
            });

            API.Register(this);
        }
Exemple #6
0
 public void TestReadMetadata()
 {
     using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz"))
     {
         var reader = new OszArchiveReader(osz);
         var meta   = reader.ReadMetadata();
         Assert.AreEqual(241526, meta.BeatmapSetID);
         Assert.AreEqual("Soleily", meta.Artist);
         Assert.AreEqual("Soleily", meta.ArtistUnicode);
         Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
         Assert.AreEqual("Deif", meta.Author);
         Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
         Assert.AreEqual(164471, meta.PreviewTime);
         Assert.AreEqual(string.Empty, meta.Source);
         Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
         Assert.AreEqual("Renatus", meta.Title);
         Assert.AreEqual("Renatus", meta.TitleUnicode);
     }
 }
        static void Main(string[] args)
        {
            LegacyFilesystemReader.Register();
            OszArchiveReader.Register();

            using (var host = Host.GetSuitableHost(@"osu", true))
            {
                if (!host.IsPrimaryInstance)
                {
                    Console.WriteLine("Not launching, there is already an instance of the osu host running");
                    return;
                }

                using (var appController = new AppController(args, host))
                {
                    var Application = SelectApplication(args);

                    Application(args, host, appController.Dependencies);
                }
            }
        }
Exemple #8
0
        public void TestReadMetadata()
        {
            using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz"))
            {
                var reader = new OszArchiveReader(osz);

                BeatmapMetadata meta;
                using (var stream = new StreamReader(reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
                    meta = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;

                Assert.AreEqual(241526, meta.OnlineBeatmapSetID);
                Assert.AreEqual("Soleily", meta.Artist);
                Assert.AreEqual("Soleily", meta.ArtistUnicode);
                Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
                Assert.AreEqual("Deif", meta.Author);
                Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
                Assert.AreEqual(164471, meta.PreviewTime);
                Assert.AreEqual(string.Empty, meta.Source);
                Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
                Assert.AreEqual("Renatus", meta.Title);
                Assert.AreEqual("Renatus", meta.TitleUnicode);
            }
        }
Exemple #9
0
        /// <summary>
        /// Downloads a beatmap.
        /// </summary>
        /// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to be downloaded.</param>
        /// <param name="noVideo">Whether the beatmap should be downloaded without video. Defaults to false.</param>
        public void Download(BeatmapSetInfo beatmapSetInfo, bool noVideo = false)
        {
            var existing = GetExistingDownload(beatmapSetInfo);

            if (existing != null || api == null)
            {
                return;
            }

            if (!api.LocalUser.Value.IsSupporter)
            {
                PostNotification?.Invoke(new SimpleNotification
                {
                    Icon = FontAwesome.fa_superpowers,
                    Text = "You gotta be a supporter to download for now 'yo"
                });
                return;
            }

            ProgressNotification downloadNotification = new ProgressNotification
            {
                Text = $"Downloading {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}",
            };

            var request = new DownloadBeatmapSetRequest(beatmapSetInfo, noVideo);

            request.DownloadProgressed += progress =>
            {
                downloadNotification.State    = ProgressNotificationState.Active;
                downloadNotification.Progress = progress;
            };

            request.Success += data =>
            {
                downloadNotification.Text = $"Importing {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}";

                Task.Factory.StartNew(() =>
                {
                    // This gets scheduled back to the update thread, but we want the import to run in the background.
                    using (var stream = new MemoryStream(data))
                        using (var archive = new OszArchiveReader(stream))
                            Import(archive);

                    downloadNotification.State = ProgressNotificationState.Completed;
                }, TaskCreationOptions.LongRunning);

                currentDownloads.Remove(request);
            };

            request.Failure += data =>
            {
                downloadNotification.State = ProgressNotificationState.Completed;
                Logger.Error(data, "Failed to get beatmap download information");
                currentDownloads.Remove(request);
            };

            downloadNotification.CancelRequested += () =>
            {
                request.Cancel();
                currentDownloads.Remove(request);
                downloadNotification.State = ProgressNotificationState.Cancelled;
                return(true);
            };

            currentDownloads.Add(request);
            PostNotification?.Invoke(downloadNotification);

            // don't run in the main api queue as this is a long-running task.
            Task.Factory.StartNew(() => request.Perform(api), TaskCreationOptions.LongRunning);
            BeatmapDownloadBegan?.Invoke(request);
        }
Exemple #10
0
        /// <summary>
        /// Downloads a beatmap.
        /// </summary>
        /// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to be downloaded.</param>
        /// <returns>A new <see cref="DownloadBeatmapSetRequest"/>, or an existing one if a download is already in progress.</returns>
        public DownloadBeatmapSetRequest Download(BeatmapSetInfo beatmapSetInfo)
        {
            var existing = GetExistingDownload(beatmapSetInfo);

            if (existing != null)
            {
                return(existing);
            }

            if (api == null)
            {
                return(null);
            }

            ProgressNotification downloadNotification = new ProgressNotification
            {
                Text = $"Downloading {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}",
            };

            var request = new DownloadBeatmapSetRequest(beatmapSetInfo);

            request.DownloadProgressed += progress =>
            {
                downloadNotification.State    = ProgressNotificationState.Active;
                downloadNotification.Progress = progress;
            };

            request.Success += data =>
            {
                downloadNotification.Text = $"Importing {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}";

                Task.Factory.StartNew(() =>
                {
                    // This gets scheduled back to the update thread, but we want the import to run in the background.
                    using (var stream = new MemoryStream(data))
                        using (var archive = new OszArchiveReader(stream))
                            Import(archive);

                    downloadNotification.State = ProgressNotificationState.Completed;
                }, TaskCreationOptions.LongRunning);

                currentDownloads.Remove(request);
            };

            request.Failure += data =>
            {
                downloadNotification.State = ProgressNotificationState.Completed;
                Logger.Error(data, "Failed to get beatmap download information");
                currentDownloads.Remove(request);
            };

            downloadNotification.CancelRequested += () =>
            {
                request.Cancel();
                currentDownloads.Remove(request);
                downloadNotification.State = ProgressNotificationState.Cancelled;
                return(true);
            };

            currentDownloads.Add(request);
            PostNotification?.Invoke(downloadNotification);

            // don't run in the main api queue as this is a long-running task.
            Task.Factory.StartNew(() => request.Perform(api), TaskCreationOptions.LongRunning);

            return(request);
        }
Exemple #11
0
        protected void StartDownload()
        {
            if (api == null)
            {
                return;
            }

            // we already have an active download running.
            if (downloadRequest != null)
            {
                content.MoveToX(-5, 50, Easing.OutSine).Then()
                .MoveToX(5, 100, Easing.InOutSine).Then()
                .MoveToX(-5, 100, Easing.InOutSine).Then()
                .MoveToX(0, 50, Easing.InSine).Then();
                return;
            }

            if (!api.LocalUser.Value.IsSupporter)
            {
                notifications.Post(new SimpleNotification
                {
                    Icon = FontAwesome.fa_superpowers,
                    Text = "You gotta be a supporter to download for now 'yo"
                });
                return;
            }

            progressBar.FadeIn(400, Easing.OutQuint);
            progressBar.ResizeHeightTo(4, 400, Easing.OutQuint);

            progressBar.Current.Value = 0;

            ProgressNotification downloadNotification = new ProgressNotification
            {
                Text = $"Downloading {SetInfo.Metadata.Artist} - {SetInfo.Metadata.Title}",
            };

            downloadRequest          = new DownloadBeatmapSetRequest(SetInfo);
            downloadRequest.Failure += e =>
            {
                progressBar.Current.Value = 0;
                progressBar.FadeOut(500);
                downloadNotification.State = ProgressNotificationState.Completed;
                Logger.Error(e, "Failed to get beatmap download information");

                downloadRequest = null;
            };

            downloadRequest.Progress += (current, total) =>
            {
                float progress = (float)current / total;

                progressBar.Current.Value = progress;

                downloadNotification.State    = ProgressNotificationState.Active;
                downloadNotification.Progress = progress;
            };

            downloadRequest.Success += data =>
            {
                progressBar.Current.Value = 1;
                progressBar.FadeOut(500);

                downloadNotification.State = ProgressNotificationState.Completed;

                using (var stream = new MemoryStream(data))
                    using (var archive = new OszArchiveReader(stream))
                        beatmaps.Import(archive);
            };

            downloadNotification.CancelRequested += () =>
            {
                downloadRequest.Cancel();
                downloadRequest = null;
                return(true);
            };

            notifications.Post(downloadNotification);

            // don't run in the main api queue as this is a long-running task.
            Task.Run(() => downloadRequest.Perform(api));
        }
Exemple #12
0
 public void SetUp()
 {
     OszArchiveReader.Register();
     Ruleset.Register(new OsuRuleset());
 }
Exemple #13
0
 public void SetUp()
 {
     OszArchiveReader.Register();
 }
Exemple #14
0
        private void load()
        {
            dependencies.Cache(this);
            dependencies.Cache(LocalConfig);

            SQLiteConnection connection = Host.Storage.GetDatabase(@"client");

            dependencies.Cache(RulesetDatabase = new RulesetDatabase(Host.Storage, connection));
            dependencies.Cache(BeatmapDatabase = new BeatmapDatabase(Host.Storage, connection, RulesetDatabase, Host));
            dependencies.Cache(ScoreDatabase   = new ScoreDatabase(Host.Storage, connection, Host, BeatmapDatabase));
            dependencies.Cache(new OsuColour());

            //this completely overrides the framework default. will need to change once we make a proper FontStore.
            dependencies.Cache(Fonts = new FontStore {
                ScaleAdjust = 100
            }, true);

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic"));

            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera"));
            Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light"));

            var defaultBeatmap = new DummyWorkingBeatmap(this);

            Beatmap = new NonNullableBindable <WorkingBeatmap>(defaultBeatmap);
            BeatmapDatabase.DefaultBeatmap = defaultBeatmap;

            OszArchiveReader.Register();

            dependencies.Cache(API = new APIAccess
            {
                Username = LocalConfig.Get <string>(OsuSetting.Username),
                Token    = LocalConfig.Get <string>(OsuSetting.Token)
            });

            Beatmap.ValueChanged += b =>
            {
                // compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
                if (lastBeatmap?.Track != b.Track)
                {
                    // this disposal is done to stop the audio track.
                    // it may not be exactly what we want for cases beatmaps are reused, as it will
                    // trigger a fresh load of contained resources.
                    lastBeatmap?.Dispose();

                    Audio.Track.AddItem(b.Track);
                }

                lastBeatmap = b;
            };

            API.Register(this);
        }