<commit_before>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Extensions;
using osu.Framework.Input;
using osu.Framework.Graphics.Shapes;

namespace osu.Game.Overlays.Music
{
    public class PlaylistOverlay : OverlayContainer
    {
        private const float transition_duration = 600;

        private const float playlist_height = 510;

        private FilterControl filter;
        private PlaylistList list;

        private TrackManager trackManager;
        private BeatmapDatabase beatmaps;

        private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();

        public IEnumerable<BeatmapSetInfo> BeatmapSets;
        private InputManager inputManager;

        [BackgroundDependencyLoader]
        private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, UserInputManager inputManager)
        {
            this.inputManager = inputManager;
            this.beatmaps = beatmaps;
            trackManager = game.Audio.Track;

            Children = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    CornerRadius = 5,
                    Masking = true,
                    EdgeEffect = new EdgeEffectParameters
                    {
                        Type = EdgeEffectType.Shadow,
                        Colour = Color4.Black.Opacity(40),
                        Radius = 5,
                    },
                    Children = new Drawable[]
                    {
                        new Box
                        {
                            Colour = colours.Gray3,
                            RelativeSizeAxes = Axes.Both,
                        },
                        list = new PlaylistList
                        {
                            RelativeSizeAxes = Axes.Both,
                            Padding = new MarginPadding { Top = 95, Bottom = 10, Right = 10 },
                            OnSelect = itemSelected,
                        },
                        filter = new FilterControl
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes = Axes.Y,
                            ExitRequested = () => State = Visibility.Hidden,
                            FilterChanged = search => list.Filter(search),
                            Padding = new MarginPadding(10),
                        },
                    },
                },
            };

            list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren<BeatmapSetInfo>().ToList();

            beatmapBacking.BindTo(game.Beatmap);

            filter.Search.OnCommit = (sender, newText) => {
                var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault();
                if (beatmap != null) playSpecified(beatmap);
            };
        }

        protected override void LoadComplete()
        {
            base.LoadComplete();
            beatmapBacking.ValueChanged += b => list.SelectedItem = b?.BeatmapSetInfo;
            beatmapBacking.TriggerChange();
        }

        protected override void PopIn()
        {
            filter.Search.HoldFocus = true;
            Schedule(() => inputManager.ChangeFocus(filter.Search));

            ResizeTo(new Vector2(1, playlist_height), transition_duration, EasingTypes.OutQuint);
            FadeIn(transition_duration, EasingTypes.OutQuint);
        }

        protected override void PopOut()
        {
            filter.Search.HoldFocus = false;

            ResizeTo(new Vector2(1, 0), transition_duration, EasingTypes.OutQuint);
            FadeOut(transition_duration);
        }

        private void itemSelected(BeatmapSetInfo set)<commit_msg>Don't show theme song in playlist<commit_after>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Extensions;
using osu.Framework.Input;
using osu.Framework.Graphics.Shapes;

namespace osu.Game.Overlays.Music
{
    public class PlaylistOverlay : OverlayContainer
    {
        private const float transition_duration = 600;

        private const float playlist_height = 510;

        private FilterControl filter;
        private PlaylistList list;

        private TrackManager trackManager;
        private BeatmapDatabase beatmaps;

        private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();

        public IEnumerable<BeatmapSetInfo> BeatmapSets;
        private InputManager inputManager;

        [BackgroundDependencyLoader]
        private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, UserInputManager inputManager)
        {
            this.inputManager = inputManager;
            this.beatmaps = beatmaps;
            trackManager = game.Audio.Track;

            Children = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    CornerRadius = 5,
                    Masking = true,
                    EdgeEffect = new EdgeEffectParameters
                    {
                        Type = EdgeEffectType.Shadow,
                        Colour = Color4.Black.Opacity(40),
                        Radius = 5,
                    },
                    Children = new Drawable[]
                    {
                        new Box
                        {
                            Colour = colours.Gray3,
                            RelativeSizeAxes = Axes.Both,
                        },
                        list = new PlaylistList
                        {
                            RelativeSizeAxes = Axes.Both,
                            Padding = new MarginPadding { Top = 95, Bottom = 10, Right = 10 },
                            OnSelect = itemSelected,
                        },
                        filter = new FilterControl
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes = Axes.Y,
                            ExitRequested = () => State = Visibility.Hidden,
                            FilterChanged = search => list.Filter(search),
                            Padding = new MarginPadding(10),
                        },
                    },
                },
            };

            list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren<BeatmapSetInfo>(b => !b.DeletePending).ToList();

            beatmapBacking.BindTo(game.Beatmap);

            filter.Search.OnCommit = (sender, newText) =>
            {
                var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault();
                if (beatmap != null) playSpecified(beatmap);
            };
        }

        protected override void LoadComplete()
        {
            base.LoadComplete();
            beatmapBacking.ValueChanged += b => list.SelectedItem = b?.BeatmapSetInfo;
            beatmapBacking.TriggerChange();
        }

        protected override void PopIn()
        {
            filter.Search.HoldFocus = true;
            Schedule(() => inputManager.ChangeFocus(filter.Search));

            ResizeTo(new Vector2(1, playlist_height), transition_duration, EasingTypes.OutQuint);
            FadeIn(transition_duration, EasingTypes.OutQuint);
        }

        protected override void PopOut()
        {
            filter.Search.HoldFocus = false;

            ResizeTo(new Vector2(1, 0), transition_duration, EasingTypes.OutQuint);
            FadeOut(transition_duration);
        }

        private void itemSelected(BeatmapSetInfo set)
{'fraction_non_alphanumeric': 0.07816649347650387, 'fraction_numerical': 0.007851287380210138, 'mean_word_length': 1.583358186698479, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 26, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3736864', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2062, 'n_words': 447}