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

using System;
using System.Collections.Generic;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
using osu.Game.GameModes.Backgrounds;
using osu.Framework;
using osu.Game.Database;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Drawables;
using System.Linq;
using OpenTK;
using OpenTK.Graphics;

namespace osu.Game.GameModes.Play
{
    public class PlaySongSelect : OsuGameMode
    {
        private Bindable<PlayMode> playMode;
        private BeatmapDatabase beatmaps;
        private BeatmapSet selectedBeatmapSet;

        // TODO: use currently selected track as bg
        protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");

        private ScrollContainer scrollContainer;
        private FlowContainer setList;
        
        private void selectBeatmapSet(BeatmapSet beatmapSet)
        {
            selectedBeatmapSet = beatmapSet;
            foreach (var child in setList.Children)
            {
                var childGroup = child as BeatmapGroup;
                childGroup.Collapsed = childGroup.BeatmapSet != beatmapSet;
            }
        }
        
        private void addBeatmapSet(BeatmapSet beatmapSet)
        {
            var group = new BeatmapGroup(beatmapSet);
            group.SetSelected += (selectedSet) => selectBeatmapSet(selectedSet);
            setList.Add(group);
        }

        private void addBeatmapSets()
        {
            var sets = beatmaps.GetBeatmapSets();
            foreach (var beatmapSet in sets)
                addBeatmapSet(beatmapSet);
        }
        
        public PlaySongSelect()
        {
            const float backgroundWidth = 0.6f;
            const float backgroundSlant = 25;
            Children = new Drawable[]
            {
                new BackgroundBox(backgroundSlant)
                {
                    RelativeSizeAxes = Axes.Both,
                    Size = new Vector2(backgroundWidth, 0.5f),
                    Colour = new Color4(0, 0, 0, 0.5f),
                },
                new BackgroundBox(-backgroundSlant)
                {
                    RelativeSizeAxes = Axes.Both,
                    RelativePositionAxes = Axes.Y,
                    Size = new Vector2(backgroundWidth, 0.5f),
                    Position = new Vector2(0, 0.5f),
                    Colour = new Color4(0, 0, 0, 0.5f),
                },
                scrollContainer = new ScrollContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size = new Vector2(0.5f, 1),
                    Position = new Vector2(0.5f, 0),
                    Children = new Drawable[]
                    {
                        setList = new FlowContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            Size = new Vector2(1, 0),
                            Direction = FlowDirection.VerticalOnly,
                            Spacing = new Vector2(0, 25),
                        }
                    }
                }
            };
        }

        public override void Load(BaseGame game)
        {
            base.Load(game);

            OsuGame osu = game as OsuGame;
            if (osu != null)
            {
                playMode = osu.PlayMode;
                playMode.ValueChanged += PlayMode_ValueChanged;
                // Temporary:
                scrollContainer.Padding = new MarginPadding { Top = osu.Toolbar.Height };
            }
            
            beatmaps = (game as OsuGameBase).Beatmaps;
            beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => addBeatmapSet(bset));
            addBeatmapSets();
            var first = setList.Children.First() as BeatmapGroup;
            first.Collapsed = false;
            selectedBeatmapSet = first.BeatmapSet;
        }

        protected override void Dispose(bool isDisposing)
        {
            base.Dispose(isDisposing);

            playMode.ValueChanged -= PlayMode_ValueChanged;
        }

        private void PlayMode_ValueChanged(object sender, EventArgs e)
        {
        }
        
        class BackgroundBox : Box
        {
            private float wedgeWidth;

            public BackgroundBox(float wedgeWidth)
            {
                this.wedgeWidth = wedgeWidth;
            }

            protected override Quad DrawQuad
            {
                get
                {
                    Quad q = base.DrawQuad;
                    q.TopRight.X += wedgeWidth;
                    q.BottomRight.X -= wedgeWidth;
                    return q;
                }
            }
        
        }
    }
}<commit_msg>Fix up padding on song select<commit_after>﻿//Copyright (c) 2007-2016 ppy Pty Ltd <<EMAIL>>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using System.Collections.Generic;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
using osu.Game.GameModes.Backgrounds;
using osu.Framework;
using osu.Game.Database;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Drawables;
using System.Linq;
using OpenTK;
using OpenTK.Graphics;

namespace osu.Game.GameModes.Play
{
    public class PlaySongSelect : OsuGameMode
    {
        private Bindable<PlayMode> playMode;
        private BeatmapDatabase beatmaps;
        private BeatmapSet selectedBeatmapSet;

        // TODO: use currently selected track as bg
        protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");

        private ScrollContainer scrollContainer;
        private FlowContainer setList;

        private void selectBeatmapSet(BeatmapSet beatmapSet)
        {
            selectedBeatmapSet = beatmapSet;
            foreach (var child in setList.Children)
            {
                var childGroup = child as BeatmapGroup;
                childGroup.Collapsed = childGroup.BeatmapSet != beatmapSet;
            }
        }

        private void addBeatmapSet(BeatmapSet beatmapSet)
        {
            var group = new BeatmapGroup(beatmapSet);
            group.SetSelected += (selectedSet) => selectBeatmapSet(selectedSet);
            setList.Add(group);
        }

        private void addBeatmapSets()
        {
            var sets = beatmaps.GetBeatmapSets();
            foreach (var beatmapSet in sets)
                addBeatmapSet(beatmapSet);
        }

        public PlaySongSelect()
        {
            const float backgroundWidth = 0.6f;
            const float backgroundSlant = 25;
            Children = new Drawable[]
            {
                new BackgroundBox(backgroundSlant)
                {
                    RelativeSizeAxes = Axes.Both,
                    Size = new Vector2(backgroundWidth, 0.5f),
                    Colour = new Color4(0, 0, 0, 0.5f),
                },
                new BackgroundBox(-backgroundSlant)
                {
                    RelativeSizeAxes = Axes.Both,
                    RelativePositionAxes = Axes.Y,
                    Size = new Vector2(backgroundWidth, 0.5f),
                    Position = new Vector2(0, 0.5f),
                    Colour = new Color4(0, 0, 0, 0.5f),
                },
                scrollContainer = new ScrollContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    RelativePositionAxes = Axes.Both,
                    Size = new Vector2(0.5f, 1),
                    Position = new Vector2(0.5f, 0),
                    Children = new Drawable[]
                    {
                        setList = new FlowContainer
                        {
                            Padding = new MarginPadding { Top = 25, Bottom = 25 },
                            RelativeSizeAxes = Axes.X,
                            Size = new Vector2(1, 0),
                            Direction = FlowDirection.VerticalOnly,
                            Spacing = new Vector2(0, 25),
                        }
                    }
                }
            };
        }

        public override void Load(BaseGame game)
        {
            base.Load(game);

            OsuGame osu = game as OsuGame;
            if (osu != null)
            {
                playMode = osu.PlayMode;
                playMode.ValueChanged += PlayMode_ValueChanged;
                // Temporary:
                scrollContainer.Padding = new MarginPadding { Top = osu.Toolbar.Height };
            }

            beatmaps = (game as OsuGameBase).Beatmaps;
            beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => addBeatmapSet(bset));
            addBeatmapSets();
            var first = setList.Children.First() as BeatmapGroup;
            first.Collapsed = false;
            selectedBeatmapSet = first.BeatmapSet;
        }

        protected override void Dispose(bool isDisposing)
        {
            base.Dispose(isDisposing);

            playMode.ValueChanged -= PlayMode_ValueChanged;
        }

        private void PlayMode_ValueChanged(object sender, EventArgs e)
        {
        }

        class BackgroundBox : Box
        {
            private float wedgeWidth;

            public BackgroundBox(float wedgeWidth)
            {
                this.wedgeWidth = wedgeWidth;
            }

            protected override Quad DrawQuad
            {
                get
                {
                    Quad q = base.DrawQuad;
                    q.TopRight.X += wedgeWidth;
                    q.BottomRight.X -= wedgeWidth;
                    return q;
                }
            }

        }
    }
}
{'fraction_non_alphanumeric': 0.07626867148085864, 'fraction_numerical': 0.010287862300919973, 'mean_word_length': 1.415193502150024, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '6189761', 'n_tokens_mistral': 2762, 'n_tokens_neox': 2498, 'n_words': 574}