<commit_before>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Online.API;
using osu.Game.Skinning;
using osu.Game.Users;

namespace osu.Game.Screens.Backgrounds
{
    public class BackgroundScreenDefault : BackgroundScreen
    {
        private Background background;

        private int currentDisplay;
        private const int background_count = 7;
        private Bindable<User> user;
        private Bindable<Skin> skin;
        private Bindable<BackgroundSource> mode;
        private Bindable<IntroSequence> introSequence;
        private readonly SeasonalBackgroundLoader seasonalBackgroundLoader = new SeasonalBackgroundLoader();

        [Resolved]
        private IBindable<WorkingBeatmap> beatmap { get; set; }

        public BackgroundScreenDefault(bool animateOnEnter = true)
            : base(animateOnEnter)
        {
        }

        [BackgroundDependencyLoader]
        private void load(IAPIProvider api, SkinManager skinManager, OsuConfigManager config)
        {
            user = api.LocalUser.GetBoundCopy();
            skin = skinManager.CurrentSkin.GetBoundCopy();
            mode = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource);
            introSequence = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence);

            user.ValueChanged += _ => Next();
            skin.ValueChanged += _ => Next();
            mode.ValueChanged += _ => Next();
            beatmap.ValueChanged += _ => Next();
            introSequence.ValueChanged += _ => Next();

            currentDisplay = RNG.Next(0, background_count);

            LoadComponentAsync(seasonalBackgroundLoader, _ => LoadComponentAsync(createBackground(), display));
        }

        private void display(Background newBackground)
        {
            background?.FadeOut(800, Easing.InOutSine);
            background?.Expire();

            AddInternal(background = newBackground);
            currentDisplay++;
        }

        private ScheduledDelegate nextTask;

        public void Next()
        {
            nextTask?.Cancel();
            nextTask = Scheduler.AddDelayed(() => { LoadComponentAsync(createBackground(), display); }, 100);
        }

        private Background createBackground()
        {
            Background newBackground;
            string backgroundName;

            switch (introSequence.Value)
            {
                case IntroSequence.Welcome:
                    backgroundName = "Intro/Welcome/menu-background";
                    break;

                default:
                    backgroundName = $@"Menu/menu-background-{currentDisplay % background_count + 1}";
                    break;
            }

            if (user.Value?.IsSupporter ?? false)
            {
                switch (mode.Value)
                {
                    case BackgroundSource.Beatmap:
                        newBackground = new BeatmapBackground(beatmap.Value, backgroundName);
                        break;

                    default:
                        newBackground = new SkinnedBackground(skin.Value, backgroundName);
                        break;
                }
            }
            else
                newBackground = new Background(backgroundName);

            newBackground.Depth = currentDisplay;

            return newBackground;
        }

        private class SkinnedBackground : Background
        {
            private readonly Skin skin;

            public SkinnedBackground(Skin skin, string fallbackTextureName)
                : base(fallbackTextureName)
            {
                this.skin = skin;
            }

            [BackgroundDependencyLoader]
            private void load()
            {
                Sprite.Texture = skin.GetTexture("menu-background") ?? Sprite.Texture;
            }
        }
    }
}
<commit_msg>Show next Background on showSeasonalBackgrounds.ValueChanged<commit_after>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Online.API;
using osu.Game.Skinning;
using osu.Game.Users;

namespace osu.Game.Screens.Backgrounds
{
    public class BackgroundScreenDefault : BackgroundScreen
    {
        private Background background;

        private int currentDisplay;
        private const int background_count = 7;
        private Bindable<User> user;
        private Bindable<Skin> skin;
        private Bindable<BackgroundSource> mode;
        private Bindable<IntroSequence> introSequence;
        private Bindable<SeasonalBackgrounds> showSeasonalBackgrounds;
        private readonly SeasonalBackgroundLoader seasonalBackgroundLoader = new SeasonalBackgroundLoader();

        [Resolved]
        private IBindable<WorkingBeatmap> beatmap { get; set; }

        public BackgroundScreenDefault(bool animateOnEnter = true)
            : base(animateOnEnter)
        {
        }

        [BackgroundDependencyLoader]
        private void load(IAPIProvider api, SkinManager skinManager, OsuConfigManager config)
        {
            user = api.LocalUser.GetBoundCopy();
            skin = skinManager.CurrentSkin.GetBoundCopy();
            mode = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource);
            introSequence = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence);
            showSeasonalBackgrounds = config.GetBindable<SeasonalBackgrounds>(OsuSetting.SeasonalBackgrounds);

            user.ValueChanged += _ => Next();
            skin.ValueChanged += _ => Next();
            mode.ValueChanged += _ => Next();
            beatmap.ValueChanged += _ => Next();
            introSequence.ValueChanged += _ => Next();
            showSeasonalBackgrounds.ValueChanged += _ => Next();

            currentDisplay = RNG.Next(0, background_count);

            LoadComponentAsync(seasonalBackgroundLoader, _ => LoadComponentAsync(createBackground(), display));
        }

        private void display(Background newBackground)
        {
            background?.FadeOut(800, Easing.InOutSine);
            background?.Expire();

            AddInternal(background = newBackground);
            currentDisplay++;
        }

        private ScheduledDelegate nextTask;

        public void Next()
        {
            nextTask?.Cancel();
            nextTask = Scheduler.AddDelayed(() => { LoadComponentAsync(createBackground(), display); }, 100);
        }

        private Background createBackground()
        {
            Background newBackground;
            string backgroundName;

            switch (introSequence.Value)
            {
                case IntroSequence.Welcome:
                    backgroundName = "Intro/Welcome/menu-background";
                    break;

                default:
                    backgroundName = $@"Menu/menu-background-{currentDisplay % background_count + 1}";
                    break;
            }

            if (user.Value?.IsSupporter ?? false)
            {
                switch (mode.Value)
                {
                    case BackgroundSource.Beatmap:
                        newBackground = new BeatmapBackground(beatmap.Value, backgroundName);
                        break;

                    default:
                        newBackground = new SkinnedBackground(skin.Value, backgroundName);
                        break;
                }
            }
            else
                newBackground = new Background(backgroundName);

            newBackground.Depth = currentDisplay;

            return newBackground;
        }

        private class SkinnedBackground : Background
        {
            private readonly Skin skin;

            public SkinnedBackground(Skin skin, string fallbackTextureName)
                : base(fallbackTextureName)
            {
                this.skin = skin;
            }

            [BackgroundDependencyLoader]
            private void load()
            {
                Sprite.Texture = skin.GetTexture("menu-background") ?? Sprite.Texture;
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.08231777420096574, 'fraction_numerical': 0.002069441250862267, 'mean_word_length': 1.960857726344452, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 38, 'https://': 0, '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': '133155', 'n_tokens_mistral': 2152, 'n_tokens_neox': 2018, 'n_words': 443}