Пример #1
0
        private BeatmapSetInfo importBeatmapSet(int importID, IEnumerable <RulesetInfo> difficultyRulesets)
        {
            var metadata = new BeatmapMetadata
            {
                Artist       = "SomeArtist",
                AuthorString = "SomeAuthor",
                Title        = $"import {importID}"
            };

            var beatmapSet = new BeatmapSetInfo
            {
                Hash = Guid.NewGuid().ToString(),
                OnlineBeatmapSetID = importID,
                Metadata           = metadata,
                Beatmaps           = difficultyRulesets.Select((ruleset, difficultyIndex) => new BeatmapInfo
                {
                    OnlineBeatmapID = importID * 1024 + difficultyIndex,
                    Metadata        = metadata,
                    BaseDifficulty  = new BeatmapDifficulty(),
                    Ruleset         = ruleset,
                    RulesetID       = ruleset.ID.GetValueOrDefault(), // workaround for efcore 5 compatibility.
                    StarDifficulty  = difficultyIndex + 1,
                    Version         = $"SR{difficultyIndex + 1}"
                }).ToList()
            };

            return(Game.BeatmapManager.Import(beatmapSet).Result);
        }
Пример #2
0
        protected virtual BeatmapMetadata ParseFile(StreamReader stream)
        {
            var beatmap = new BeatmapMetadata();

            ParseFile(stream, beatmap);
            return(beatmap);
        }
Пример #3
0
        private SetIndex GetOrCreateSet(FileInfo mapFile, BeatmapMetadata mapMetadata)
        {
            SetIndex set;

            if (!setsByFolderName.TryGetValue(mapFile.DirectoryName, out set))
            {
                // Create a new set with the given metadata
                set          = new SetIndex();
                set.Id       = nextSetId++;
                set.Artist   = mapMetadata.Artist;
                set.Creator  = mapMetadata.Creator;
                set.Title    = mapMetadata.Title;
                set.RootPath = mapFile.DirectoryName;

                sets.Add(set.Id, set);
                setsByFolderName.Add(set.RootPath, set);

                // Update database
                sqliteConnection.Insert(set);

                // Notify
                SetChanged?.Invoke(this, new SetChangedEventArgs {
                    Set = set, Type = DatabaseEventType.Added
                });
            }
            return(set);
        }
        private BeatmapSetInfo importBeatmapSet(int importID, IEnumerable <RulesetInfo> difficultyRulesets)
        {
            var metadata = new BeatmapMetadata
            {
                Artist       = "SomeArtist",
                AuthorString = "SomeAuthor",
                Title        = $"import {importID}"
            };

            var beatmapSet = new BeatmapSetInfo
            {
                Hash     = Guid.NewGuid().ToString(),
                OnlineID = importID,
                Metadata = metadata,
                Beatmaps = difficultyRulesets.Select((ruleset, difficultyIndex) => new BeatmapInfo
                {
                    OnlineID       = importID * 1024 + difficultyIndex,
                    Metadata       = metadata,
                    BaseDifficulty = new BeatmapDifficulty(),
                    Ruleset        = ruleset,
                    StarRating     = difficultyIndex + 1,
                    DifficultyName = $"SR{difficultyIndex + 1}"
                }).ToList()
            };

            return(Game.BeatmapManager.Import(beatmapSet).Result.Value);
        }
Пример #5
0
        private void updateDisplay(WorkingBeatmap beatmap, bool?isNext)
        {
            BeatmapMetadata metadata = beatmap.Beatmap.Metadata;

            title.Text  = metadata.TitleUnicode ?? metadata.Title;
            artist.Text = metadata.ArtistUnicode ?? metadata.Artist;

            Sprite newBackground = getScaledSprite(beatmap.Background ?? fallbackTexture);

            Add(newBackground);

            if (isNext == true)
            {
                newBackground.Position = new Vector2(400, 0);
                newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic);
            }
            else if (isNext == false)
            {
                newBackground.Position = new Vector2(-400, 0);
                newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic);
            }
            backgroundSprite.Expire();

            backgroundSprite = newBackground;
        }
Пример #6
0
 public BeatmapMetadata(BeatmapMetadata original = null)
 {
     if (original == null)
     {
         Title        = @"Unknown";
         Artist       = @"Unknown";
         AuthorString = @"Unknown Creator";
     }
 }
Пример #7
0
        protected static BeatmapSetInfo CreateBeatmapSet(RulesetInfo ruleset)
        {
            RealmFile createRealmFile() => new RealmFile
            {
                Hash = Guid.NewGuid().ToString().ComputeSHA2Hash()
            };

            var metadata = new BeatmapMetadata
            {
                Title  = "My Love",
                Artist = "Kuba Oms"
            };

            var beatmapSet = new BeatmapSetInfo
            {
                Beatmaps =
                {
                    new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
                    {
                        DifficultyName = "Easy",
                    },
                    new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
                    {
                        DifficultyName = "Normal",
                    },
                    new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
                    {
                        DifficultyName = "Hard",
                    },
                    new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
                    {
                        DifficultyName = "Insane",
                    }
                },
                Files =
                {
                    new RealmNamedFileUsage(createRealmFile(), "test [easy].osu"),
                    new RealmNamedFileUsage(createRealmFile(), "test [normal].osu"),
                    new RealmNamedFileUsage(createRealmFile(), "test [hard].osu"),
                    new RealmNamedFileUsage(createRealmFile(), "test [insane].osu"),
                }
            };

            for (int i = 0; i < 8; i++)
            {
                beatmapSet.Files.Add(new RealmNamedFileUsage(createRealmFile(), $"hitsound{i}.mp3"));
            }

            foreach (var b in beatmapSet.Beatmaps)
            {
                b.BeatmapSet = beatmapSet;
            }

            return(beatmapSet);
        }
Пример #8
0
        private void load(OsuColour colours, LocalisationEngine localisation)
        {
            BeatmapMetadata metadata = BeatmapSetInfo.Metadata;

            FilterTerms = metadata.SearchableTerms;

            Children = new Drawable[]
            {
                handle = new TextAwesome
                {
                    Anchor   = Anchor.TopLeft,
                    Origin   = Anchor.TopLeft,
                    TextSize = 12,
                    Colour   = colours.Gray5,
                    Icon     = FontAwesome.fa_bars,
                    Alpha    = 0f,
                    Margin   = new MarginPadding {
                        Left = 5
                    },
                    Padding = new MarginPadding {
                        Top = 2
                    },
                },
                new FillFlowContainer <OsuSpriteText>
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Padding          = new MarginPadding {
                        Left = 20
                    },
                    Spacing  = new Vector2(5f, 0f),
                    Children = new []
                    {
                        title = new OsuSpriteText
                        {
                            TextSize = 16,
                            Font     = @"Exo2.0-Regular",
                            Current  = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title),
                        },
                        new OsuSpriteText
                        {
                            TextSize = 14,
                            Font     = @"Exo2.0-Bold",
                            Colour   = colours.Gray9,
                            Padding  = new MarginPadding {
                                Top = 1
                            },
                            Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist),
                        }
                    }
                },
            };

            hoverColour = colours.Yellow;
        }
Пример #9
0
        public void TestRomanisationNoUnicode()
        {
            var metadata = new BeatmapMetadata
            {
                Artist = "Romanised Artist",
                Title  = "Romanised title"
            };
            var romanisableString = metadata.GetDisplayTitleRomanisable();

            Assert.AreEqual(romanisableString.Romanised, romanisableString.Original);
        }
Пример #10
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            //we might be off-screen when this update comes in.
            //rather than Scheduling, manually handle this to avoid possible memory contention.
            pendingBeatmapSwitch?.Cancel();

            pendingBeatmapSwitch = Schedule(delegate
            {
                // todo: this can likely be replaced with WorkingBeatmap.GetBeatmapAsync()
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
                    {
                        title.Current = null;
                        title.Text    = @"Nothing to play";

                        artist.Current = null;
                        artist.Text    = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Metadata;
                        title.Current            = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title);
                        artist.Current           = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist);
                    }
                });

                LoadComponentAsync(new Background(beatmap)
                {
                    Depth = float.MaxValue
                }, newBackground =>
                {
                    switch (direction)
                    {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(-400, 500, Easing.OutCubic);
                        break;

                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(400, 500, Easing.OutCubic);
                        break;
                    }

                    background.Expire();
                    background = newBackground;

                    playerContainer.Add(newBackground);
                });
            });
        }
Пример #11
0
 public void Load()
 {
     foreach (string dir in Directory.EnumerateDirectories(RootDirectory))
     {
         if (IsValidBeatmap(dir))
         {
             string          metadataPath = Path.Combine(dir, "metadata.if");
             BeatmapMetadata metadata     = InfoFileParser.Deserialize <BeatmapMetadata>(metadataPath);
             m_beatmaps.Add(new BeatmapStoreInfoFile(metadata, dir));
         }
     }
 }
Пример #12
0
        public async Task TestImportWithDuplicateBeatmapIDs()
        {
            // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
            using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(ImportBeatmapTest)))
            {
                try
                {
                    var osu = LoadOsuIntoHost(host);

                    var metadata = new BeatmapMetadata
                    {
                        Artist       = "SomeArtist",
                        AuthorString = "SomeAuthor"
                    };

                    var difficulty = new BeatmapDifficulty();

                    var toImport = new BeatmapSetInfo
                    {
                        OnlineBeatmapSetID = 1,
                        Metadata           = metadata,
                        Beatmaps           = new List <BeatmapInfo>
                        {
                            new BeatmapInfo
                            {
                                OnlineBeatmapID = 2,
                                Metadata        = metadata,
                                BaseDifficulty  = difficulty
                            },
                            new BeatmapInfo
                            {
                                OnlineBeatmapID = 2,
                                Metadata        = metadata,
                                Status          = BeatmapSetOnlineStatus.Loved,
                                BaseDifficulty  = difficulty
                            }
                        }
                    };

                    var manager = osu.Dependencies.Get <BeatmapManager>();

                    var imported = await manager.Import(toImport);

                    Assert.NotNull(imported);
                    Assert.AreEqual(null, imported.Beatmaps[0].OnlineBeatmapID);
                    Assert.AreEqual(null, imported.Beatmaps[1].OnlineBeatmapID);
                }
                finally
                {
                    host.Exit();
                }
            }
        }
Пример #13
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            //we might be off-screen when this update comes in.
            //rather than Scheduling, manually handle this to avoid possible memory contention.
            pendingBeatmapSwitch = () =>
            {
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
                    {
                        title.Current = null;
                        title.Text    = @"Nothing to play";

                        artist.Current = null;
                        artist.Text    = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                        title.Current            = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title);
                        artist.Current           = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist);
                    }
                });

                dragContainer.Add(new AsyncLoadWrapper(new MusicControllerBackground(beatmap)
                {
                    OnLoadComplete = d =>
                    {
                        switch (direction)
                        {
                        case TransformDirection.Next:
                            d.Position = new Vector2(400, 0);
                            d.MoveToX(0, 500, EasingTypes.OutCubic);
                            currentBackground.MoveToX(-400, 500, EasingTypes.OutCubic);
                            break;

                        case TransformDirection.Prev:
                            d.Position = new Vector2(-400, 0);
                            d.MoveToX(0, 500, EasingTypes.OutCubic);
                            currentBackground.MoveToX(400, 500, EasingTypes.OutCubic);
                            break;
                        }
                        currentBackground.Expire();
                        currentBackground = d;
                    }
                })
                {
                    Depth = float.MaxValue,
                });
            };
        }
Пример #14
0
        public void TestRomanisation()
        {
            var metadata = new BeatmapMetadata
            {
                Artist        = "Romanised Artist",
                ArtistUnicode = "Unicode Artist",
                Title         = "Romanised title",
                TitleUnicode  = "Unicode Title"
            };
            var romanisableString = metadata.GetDisplayTitleRomanisable();

            Assert.AreEqual(metadata.ToString(), romanisableString.Romanised);
            Assert.AreEqual($"{metadata.ArtistUnicode} - {metadata.TitleUnicode}", romanisableString.Original);
        }
Пример #15
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            //we might be off-screen when this update comes in.
            //rather than Scheduling, manually handle this to avoid possible memory contention.
            pendingBeatmapSwitch = () =>
            {
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null)
                    {
                        title.Text  = @"Nothing to play";
                        artist.Text = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                        title.Text  = unicodeString(metadata.Title, metadata.TitleUnicode);
                        artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
                    }
                });

                dragContainer.Add(new AsyncLoadContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Depth            = float.MaxValue,
                    Children         = new[] { new MusicControllerBackground(beatmap) },
                    FinishedLoading  = d =>
                    {
                        switch (direction)
                        {
                        case TransformDirection.Next:
                            d.Position = new Vector2(400, 0);
                            d.MoveToX(0, 500, EasingTypes.OutCubic);
                            currentBackground.MoveToX(-400, 500, EasingTypes.OutCubic);
                            break;

                        case TransformDirection.Prev:
                            d.Position = new Vector2(-400, 0);
                            d.MoveToX(0, 500, EasingTypes.OutCubic);
                            currentBackground.MoveToX(400, 500, EasingTypes.OutCubic);
                            break;
                        }
                        currentBackground.Expire();
                        currentBackground = d;
                    }
                });
            };
        }
Пример #16
0
        private void trackChanged(WorkingBeatmap beatmap, TrackChangeDirection direction = TrackChangeDirection.None)
        {
            // avoid using scheduler as our scheduler may not be run for a long time, holding references to beatmaps.
            pendingBeatmapSwitch = delegate
            {
                // todo: this can likely be replaced with WorkingBeatmap.GetBeatmapAsync()
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
                    {
                        title.Text  = @"Nothing to play";
                        artist.Text = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Metadata;
                        title.Text  = new LocalisedString((metadata.TitleUnicode, metadata.Title));
                        artist.Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist));
                    }
                });

                LoadComponentAsync(new Background(beatmap)
                {
                    Depth = float.MaxValue
                }, newBackground =>
                {
                    switch (direction)
                    {
                    case TrackChangeDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(-400, 500, Easing.OutCubic);
                        break;

                    case TrackChangeDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, Easing.OutCubic);
                        background.MoveToX(400, 500, Easing.OutCubic);
                        break;
                    }

                    background.Expire();
                    background = newBackground;

                    playerContainer.Add(newBackground);
                });
            };
        }
Пример #17
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            //we might be off-screen when this update comes in.
            //rather than Scheduling, manually handle this to avoid possible memory contention.
            pendingBeatmapSwitch = () =>
            {
                Task.Run(() =>
                {
                    if (beatmap?.Beatmap == null)
                    {
                        title.Text  = @"Nothing to play";
                        artist.Text = @"Nothing to play";
                    }
                    else
                    {
                        BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                        title.Text  = unicodeString(metadata.Title, metadata.TitleUnicode);
                        artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
                    }
                });

                MusicControllerBackground newBackground;

                (newBackground = new MusicControllerBackground(beatmap)).LoadAsync(game, delegate
                {
                    dragContainer.Add(newBackground);

                    switch (direction)
                    {
                    case TransformDirection.Next:
                        newBackground.Position = new Vector2(400, 0);
                        newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                        backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic);
                        break;

                    case TransformDirection.Prev:
                        newBackground.Position = new Vector2(-400, 0);
                        newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                        backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic);
                        break;
                    }

                    backgroundSprite.Expire();
                    backgroundSprite = newBackground;
                });
            };
        }
Пример #18
0
        public void TestImportWithDuplicateBeatmapIDs()
        {
            RunTestWithRealm((realm, storage) =>
            {
                using var importer = new BeatmapModelManager(realm, storage);
                using var store    = new RealmRulesetStore(realm, storage);

                var metadata = new BeatmapMetadata
                {
                    Artist = "SomeArtist",
                    Author =
                    {
                        Username = "******"
                    }
                };

                var ruleset = realm.Realm.All <RulesetInfo>().First();

                var toImport = new BeatmapSetInfo
                {
                    OnlineID = 1,
                    Beatmaps =
                    {
                        new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
                        {
                            OnlineID = 2,
                        },
                        new BeatmapInfo(ruleset, new BeatmapDifficulty(), metadata)
                        {
                            OnlineID = 2,
                            Status   = BeatmapOnlineStatus.Loved,
                        }
                    }
                };

                var imported = importer.Import(toImport);

                realm.Run(r => r.Refresh());

                Assert.NotNull(imported);
                Debug.Assert(imported != null);

                Assert.AreEqual(-1, imported.PerformRead(s => s.Beatmaps[0].OnlineID));
                Assert.AreEqual(-1, imported.PerformRead(s => s.Beatmaps[1].OnlineID));
            });
        }
Пример #19
0
        private void load(GameHost host, AudioManager audio)
        {
            Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
            Dependencies.Cache(manager  = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));

            beatmaps = new List <BeatmapInfo>();

            var metadata = new BeatmapMetadata
            {
                Artist       = "Some Artist",
                Title        = "Some Beatmap",
                AuthorString = "Some Author"
            };

            var beatmapSetInfo = new BeatmapSetInfo
            {
                OnlineID  = 10,
                Hash      = Guid.NewGuid().ToString().ComputeMD5Hash(),
                Metadata  = metadata,
                DateAdded = DateTimeOffset.UtcNow
            };

            for (int i = 0; i < 8; ++i)
            {
                int beatmapId = 10 * 10 + i;

                int    length = RNG.Next(30000, 200000);
                double bpm    = RNG.NextSingle(80, 200);

                var beatmap = new BeatmapInfo
                {
                    Ruleset        = rulesets.GetRuleset(i % 4),
                    OnlineID       = beatmapId,
                    Length         = length,
                    BPM            = bpm,
                    Metadata       = metadata,
                    BaseDifficulty = new BeatmapDifficulty()
                };

                beatmaps.Add(beatmap);
                beatmapSetInfo.Beatmaps.Add(beatmap);
            }

            manager.Import(beatmapSetInfo).Wait();
        }
Пример #20
0
        private void displayBeatmap(BeatmapMetadata value)
        {
            if (value != null)
            {
                beatmapTitle.Current  = localisation.GetUnicodePreference(value.TitleUnicode, value.Title);
                beatmapDash.Text      = @" - ";
                beatmapArtist.Current = localisation.GetUnicodePreference(value.ArtistUnicode, value.Artist);
            }
            else
            {
                beatmapTitle.Current  = null;
                beatmapArtist.Current = null;

                beatmapTitle.Text  = @"Changing map";
                beatmapDash.Text   = string.Empty;
                beatmapArtist.Text = string.Empty;
            }
        }
Пример #21
0
        private void handleMetadata(BeatmapMetadata beatmap, string line)
        {
            if (beatmap == null)
            {
                throw new ArgumentNullException(nameof(beatmap));
            }
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }

            var pair = splitKeyVal(line, ':');

            switch (pair.Key)
            {
            case @"Title":
                beatmap.Title = pair.Value;
                break;

            case @"TitleUnicode":
                beatmap.TitleUnicode = pair.Value;
                break;

            case @"Artist":
                beatmap.Artist = pair.Value;
                break;

            case @"ArtistUnicode":
                beatmap.ArtistUnicode = pair.Value;
                break;

            case @"Creator":
                beatmap.AuthorString = pair.Value;
                break;

            case @"Source":
                beatmap.Source = pair.Value;
                break;

            case @"Tags":
                beatmap.Tags = pair.Value;
                break;
            }
        }
Пример #22
0
        private Func <BeatmapSetInfo> importBeatmap(int i, RulesetInfo ruleset = null)
        {
            BeatmapSetInfo imported = null;

            AddStep($"import beatmap {i}", () =>
            {
                var difficulty = new BeatmapDifficulty();
                var metadata   = new BeatmapMetadata
                {
                    Artist       = "SomeArtist",
                    AuthorString = "SomeAuthor",
                    Title        = $"import {i}"
                };

                imported = Game.BeatmapManager.Import(new BeatmapSetInfo
                {
                    Hash = Guid.NewGuid().ToString(),
                    OnlineBeatmapSetID = i,
                    Metadata           = metadata,
                    Beatmaps           = new List <BeatmapInfo>
                    {
                        new BeatmapInfo
                        {
                            OnlineBeatmapID = i * 1024,
                            Metadata        = metadata,
                            BaseDifficulty  = difficulty,
                            Ruleset         = ruleset ?? new OsuRuleset().RulesetInfo
                        },
                        new BeatmapInfo
                        {
                            OnlineBeatmapID = i * 2048,
                            Metadata        = metadata,
                            BaseDifficulty  = difficulty,
                            Ruleset         = ruleset ?? new OsuRuleset().RulesetInfo
                        },
                    }
                }).Result;
            });

            AddAssert($"import {i} succeeded", () => imported != null);

            return(() => imported);
        }
Пример #23
0
        protected override void ParseFile(StreamReader stream, BeatmapMetadata beatmap)
        {
            if (beatmap == null)
            {
                throw new ArgumentNullException(nameof(beatmap));
            }
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var section = Section.None;

            string line;

            while ((line = stream.ReadLine()) != null)
            {
                if (string.IsNullOrWhiteSpace(line) ||
                    line.StartsWith(@"//"))
                {
                    continue;
                }

                if (line.StartsWith(@"[") && line.EndsWith(@"]"))
                {
                    if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
                    {
                        //throw new InvalidDataException($@"Unknown osu section {line}");
                        section = Section.None;
                    }
                    continue;
                }

                switch (section)
                {
                case Section.Metadata:
                    handleMetadata(beatmap, line);
                    break;
                }
            }
        }
Пример #24
0
        private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
        {
            Task.Run(() =>
            {
                if (beatmap.Beatmap == null)
                {
                    //todo: we may need to display some default text here (currently in the constructor).
                    return;
                }

                BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
                title.Text  = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode);
                artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode);
            });

            MusicControllerBackground newBackground;

            (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate
            {
                Add(newBackground);

                switch (direction)
                {
                case TransformDirection.Next:
                    newBackground.Position = new Vector2(400, 0);
                    newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                    backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic);
                    break;

                case TransformDirection.Prev:
                    newBackground.Position = new Vector2(-400, 0);
                    newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
                    backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic);
                    break;
                }

                backgroundSprite.Expire();
                backgroundSprite = newBackground;
            });
        }
Пример #25
0
        private void AddDifficulty(FileInfo mapFile, BeatmapMetadata mapMetadata)
        {
            var set      = GetOrCreateSet(mapFile, mapMetadata);
            var existing = set.Difficulties.FirstOrDefault(x => x.Path == mapFile.FullName);

            // Update existing or create new
            DifficultyIndex difficulty = existing ?? new DifficultyIndex();

            if (existing == null)
            {
                difficulty.Id    = nextDifficultyId++;
                difficulty.SetId = set.Id;
                difficulty.Path  = mapFile.FullName;
                difficulties.Add(difficulty.Id, difficulty);
                set.Difficulties.Add(difficulty);
            }

            difficulty.LastWriteTime = mapFile.LastWriteTimeUtc;
            difficulty.MetaData      = mapMetadata;

            if (existing != null)
            {
                // Update database
                sqliteConnection.Update(difficulty);
            }
            else
            {
                // Insert into database
                sqliteConnection.Insert(difficulty);
            }

            // Notify
            DifficultyChanged?.Invoke(this,
                                      new DifficultyChangedEventArgs()
            {
                Difficulty = difficulty,
                Type       = existing != null ? DatabaseEventType.Changed : DatabaseEventType.Added
            });
        }
Пример #26
0
 private void trackChanged(WorkingBeatmap beatmap, TrackChangeDirection direction = TrackChangeDirection.None)
 {
     pendingBeatmapSwitch = () =>
     {
         Task.Run(() =>
         {
             if (beatmap?.Beatmap == null)
             {
                 nowPlayingInfo.Title  = DrawableNowPlayingInfo.NULL_TITLE;
                 nowPlayingInfo.Artist = DrawableNowPlayingInfo.NULL_TITLE;
                 nowPlayingInfo.Source = DrawableNowPlayingInfo.NULL_SOURCE;
             }
             else
             {
                 BeatmapMetadata metadata = beatmap.Metadata;
                 nowPlayingInfo.Title     = new RomanisableString(metadata.TitleUnicode, metadata.Title);
                 nowPlayingInfo.Artist    = new RomanisableString(metadata.ArtistUnicode, metadata.Artist);
                 nowPlayingInfo.Source    = new RomanisableString(metadata.Source, null);
             }
         });
     };
 }
Пример #27
0
            private OsuSpriteText[] getMapper(BeatmapMetadata metadata)
            {
                if (string.IsNullOrEmpty(metadata.Author?.Username))
                {
                    return(Array.Empty <OsuSpriteText>());
                }

                return(new[]
                {
                    new OsuSpriteText
                    {
                        Font = @"Exo2.0-Medium",
                        Text = "mapped by ",
                        TextSize = 15,
                    },
                    new OsuSpriteText
                    {
                        Font = @"Exo2.0-Bold",
                        Text = metadata.Author.Username,
                        TextSize = 15,
                    }
                });
            }
        public new void SetUpSteps()
        {
            AddStep("import beatmap", () =>
            {
                var difficulty = new BeatmapDifficulty();
                var metadata   = new BeatmapMetadata
                {
                    Artist       = "SomeArtist",
                    AuthorString = "SomeAuthor",
                    Title        = "import"
                };

                beatmap = Game.BeatmapManager.Import(new BeatmapSetInfo
                {
                    Hash = Guid.NewGuid().ToString(),
                    OnlineBeatmapSetID = 1,
                    Metadata           = metadata,
                    Beatmaps           = new List <BeatmapInfo>
                    {
                        new BeatmapInfo
                        {
                            OnlineBeatmapID = 1 * 1024,
                            Metadata        = metadata,
                            BaseDifficulty  = difficulty,
                            Ruleset         = new OsuRuleset().RulesetInfo
                        },
                        new BeatmapInfo
                        {
                            OnlineBeatmapID = 1 * 2048,
                            Metadata        = metadata,
                            BaseDifficulty  = difficulty,
                            Ruleset         = new OsuRuleset().RulesetInfo
                        },
                    }
                }).Result;
            });
        }
Пример #29
0
            private OsuSpriteText[] getMapper(BeatmapMetadata metadata)
            {
                if (string.IsNullOrEmpty(metadata.Author?.Username))
                {
                    return(Array.Empty <OsuSpriteText>());
                }

                return(new[]
                {
                    new OsuSpriteText
                    {
                        Font = @"Exo2.0-Medium",
                        Text = "mapped by ",
                        TextSize = 15,
                    },
                    new OsuSpriteText
                    {
                        Font = @"Exo2.0-Bold",
                        // ReSharper disable once PossibleNullReferenceException (resharper broken?)
                        Text = metadata.Author.Username,
                        TextSize = 15,
                    }
                });
            }
Пример #30
0
 public Beatmap(BeatmapDifficulty[] difficulties, BeatmapMetadata metadata)
 {
     Difficulties = difficulties;
     Metadata     = metadata;
 }