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

using System;
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.SearchableList;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Screens.Multi.Match.Components
{
    public class RoomSettingsOverlay : FocusedOverlayContainer
    {
        private const float transition_duration = 350;
        private const float field_padding = 45;
        private const float disabled_alpha = 0.2f;

        private readonly RoomBindings bindings = new RoomBindings();

        private readonly Container content;

        private readonly OsuSpriteText typeLabel;

        protected readonly OsuTextBox NameField, MaxParticipantsField;
        protected readonly OsuDropdown<TimeSpan> DurationField;
        protected readonly RoomAvailabilityPicker AvailabilityPicker;
        protected readonly GameTypePicker TypePicker;
        protected readonly TriangleButton ApplyButton;
        protected readonly OsuPasswordTextBox PasswordField;

        private readonly Room room;

        [Resolved(CanBeNull = true)]
        private IRoomManager manager { get; set; }

        public RoomSettingsOverlay(Room room)
        {
            this.room = room;

            bindings.Room = room;

            Masking = true;

            Child = content = new Container
            {
                RelativeSizeAxes = Axes.Both,
                RelativePositionAxes = Axes.Y,
                Children = new Drawable[]
                {
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour = OsuColour.FromHex(@"28242d"),
                    },
                    new ScrollContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        Children = new[]
                        {
                            new Container
                            {
                                Padding = new MarginPadding { Top = 35, Bottom = 75, Horizontal = SearchableListOverlay.WIDTH_PADDING },
                                RelativeSizeAxes = Axes.X,
                                AutoSizeAxes = Axes.Y,
                                Children = new Drawable[]
                                {
                                    new SectionContainer
                                    {
                                        Padding = new MarginPadding { Right = field_padding / 2 },
                                        Children = new[]
                                        {
                                            new Section("Room name")
                                            {
                                                Child = NameField = new SettingsTextBox
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    TabbableContentContainer = this,
                                                    OnCommit = (sender, text) => apply(),
                                                },
                                            },
                                            new Section("Room visibility")
                                            {
                                                Alpha = disabled_alpha,
                                                Child = AvailabilityPicker = new RoomAvailabilityPicker(),
                                            },
                                            new Section("Game type")
                                            {
                                                Alpha = disabled_alpha,
                                                Child = new FillFlowContainer
                                                {
                                                    AutoSizeAxes = Axes.Y,
                                                    RelativeSizeAxes = Axes.X,
                                                    Direction = FillDirection.Vertical,
                                                    Spacing = new Vector2(7),
                                                    Children = new Drawable[]
                                                    {
                                                        TypePicker = new GameTypePicker
                                                        {
                                                            RelativeSizeAxes = Axes.X,
                                                        },
                                                        typeLabel = new OsuSpriteText
                                                        {
                                                            TextSize = 14,
                                                        },
                                                    },
                                                },
                                            },
                                        },
                                    },
                                    new SectionContainer
                                    {
                                        Anchor = Anchor.TopRight,
                                        Origin = Anchor.TopRight,
                                        Padding = new MarginPadding { Left = field_padding / 2 },
                                        Children = new[]
                                        {
                                            new Section("Max participants")
                                            {
                                                Alpha = disabled_alpha,
                                                Child = MaxParticipantsField = new SettingsNumberTextBox
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    TabbableContentContainer = this,
                                                    OnCommit = (sender, text) => apply(),
                                                },
                                            },
                                            new Section("Duration")
                                            {
                                                Child = DurationField = new DurationDropdown
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Items = new[]
                                                    {
                                                        TimeSpan.FromMinutes(1),
                                                        TimeSpan.FromMinutes(30),
                                                        TimeSpan.FromHours(1),
                                                        TimeSpan.FromHours(2),
                                                        TimeSpan.FromHours(4),
                                                        TimeSpan.FromHours(8),
                                                        TimeSpan.FromHours(12),
                                                        TimeSpan.FromHours(16),
                                                        TimeSpan.FromHours(24),
                                                        TimeSpan.FromDays(3),
                                                        TimeSpan.FromDays(7)
                                                    }
                                                }
                                            },
                                            new Section("Password (optional)")
                                            {
                                                Alpha = disabled_alpha,
                                                Child = PasswordField = new SettingsPasswordTextBox
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    TabbableContentContainer = this,
                                                    OnCommit = (sender, text) => apply()
                                                },
                                            },
                                        },
                                    },
                                },
                            }
                        },
                    },
                    new Container
                    {
                        Anchor = Anchor.BottomLeft,
                        Origin = Anchor.BottomLeft,
                        Y = 2,
                        RelativeSizeAxes = Axes.X,
                        Height = 60,
                        Children = new Drawable[]
                        {
                            new Box
                            {
                                RelativeSizeAxes = Axes.Both,
                                Colour = OsuColour.FromHex(@"28242d").Darken(0.5f).Opacity(1f),
                            },
                            ApplyButton = new CreateRoomButton
                            {
                                Anchor = Anchor.Centre,
                                Origin = Anchor.Centre,
                                Size = new Vector2(230, 35),
                                Action = apply,
                            },
                        }
                    }
                },<commit_msg>Fix padding and use grid container for more correctness<commit_after>﻿// Copyright (c) 2007-2018 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays.SearchableList;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Screens.Multi.Match.Components
{
    public class RoomSettingsOverlay : FocusedOverlayContainer
    {
        private const float transition_duration = 350;
        private const float field_padding = 45;
        private const float disabled_alpha = 0.2f;

        private readonly RoomBindings bindings = new RoomBindings();

        private readonly Container content;

        private readonly OsuSpriteText typeLabel;

        protected readonly OsuTextBox NameField, MaxParticipantsField;
        protected readonly OsuDropdown<TimeSpan> DurationField;
        protected readonly RoomAvailabilityPicker AvailabilityPicker;
        protected readonly GameTypePicker TypePicker;
        protected readonly TriangleButton ApplyButton;
        protected readonly OsuPasswordTextBox PasswordField;

        private readonly Room room;

        [Resolved(CanBeNull = true)]
        private IRoomManager manager { get; set; }

        public RoomSettingsOverlay(Room room)
        {
            this.room = room;

            bindings.Room = room;

            Masking = true;

            Child = content = new Container
            {
                RelativeSizeAxes = Axes.Both,
                RelativePositionAxes = Axes.Y,
                Children = new Drawable[]
                {
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour = OsuColour.FromHex(@"28242d"),
                    },
                    new GridContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        RowDimensions = new[]
                        {
                            new Dimension(GridSizeMode.Distributed),
                            new Dimension(GridSizeMode.AutoSize),
                        },
                        Content = new[]
                        {
                            new Drawable[]
                            {
                                new ScrollContainer
                                {
                                    Padding = new MarginPadding { Vertical = 10 },
                                    RelativeSizeAxes = Axes.Both,
                                    Children = new[]
                                    {
                                        new Container
                                        {
                                            Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING },
                                            RelativeSizeAxes = Axes.X,
                                            AutoSizeAxes = Axes.Y,
                                            Children = new Drawable[]
                                            {
                                                new SectionContainer
                                                {
                                                    Padding = new MarginPadding { Right = field_padding / 2 },
                                                    Children = new[]
                                                    {
                                                        new Section("Room name")
                                                        {
                                                            Child = NameField = new SettingsTextBox
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                TabbableContentContainer = this,
                                                                OnCommit = (sender, text) => apply(),
                                                            },
                                                        },
                                                        new Section("Room visibility")
                                                        {
                                                            Alpha = disabled_alpha,
                                                            Child = AvailabilityPicker = new RoomAvailabilityPicker(),
                                                        },
                                                        new Section("Game type")
                                                        {
                                                            Alpha = disabled_alpha,
                                                            Child = new FillFlowContainer
                                                            {
                                                                AutoSizeAxes = Axes.Y,
                                                                RelativeSizeAxes = Axes.X,
                                                                Direction = FillDirection.Vertical,
                                                                Spacing = new Vector2(7),
                                                                Children = new Drawable[]
                                                                {
                                                                    TypePicker = new GameTypePicker
                                                                    {
                                                                        RelativeSizeAxes = Axes.X,
                                                                    },
                                                                    typeLabel = new OsuSpriteText
                                                                    {
                                                                        TextSize = 14,
                                                                    },
                                                                },
                                                            },
                                                        },
                                                    },
                                                },
                                                new SectionContainer
                                                {
                                                    Anchor = Anchor.TopRight,
                                                    Origin = Anchor.TopRight,
                                                    Padding = new MarginPadding { Left = field_padding / 2 },
                                                    Children = new[]
                                                    {
                                                        new Section("Max participants")
                                                        {
                                                            Alpha = disabled_alpha,
                                                            Child = MaxParticipantsField = new SettingsNumberTextBox
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                TabbableContentContainer = this,
                                                                OnCommit = (sender, text) => apply(),
                                                            },
                                                        },
                                                        new Section("Duration")
                                                        {
                                                            Child = DurationField = new DurationDropdown
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Items = new[]
                                                                {
                                                                    TimeSpan.FromMinutes(1),
                                                                    TimeSpan.FromMinutes(30),
                                                                    TimeSpan.FromHours(1),
                                                                    TimeSpan.FromHours(2),
                                                                    TimeSpan.FromHours(4),
                                                                    TimeSpan.FromHours(8),
                                                                    TimeSpan.FromHours(12),
                                                                    TimeSpan.FromHours(16),
                                                                    TimeSpan.FromHours(24),
                                                                    TimeSpan.FromDays(3),
                                                                    TimeSpan.FromDays(7)
                                                                }
                                                            }
                                                        },
                                                        new Section("Password (optional)")
                                                        {
                                                            Alpha = disabled_alpha,
                                                            Child = PasswordField = new SettingsPasswordTextBox
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                TabbableContentContainer = this,
                                                                OnCommit = (sender, text) => apply()
                                                            },
                                                        },
                                                    },
                                                },
                                            },
                                        }
                                    },
                                },
                            },
                            new Drawable[]
                            {
                                new Container
                                {
                                    Anchor = Anchor.BottomLeft,
                                    Origin = Anchor.BottomLeft,
                                    Y = 2,
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes = Axes.Y,
                                    Children = new Drawable[]
                                    {
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour = OsuColour.FromHex(@"28242d").Darken(0.5f).Opacity(1f),
                                        },
                                        ApplyButton = new CreateRoomButton
                                        {
                                            Margin = new MarginPadding { Vertical = 20 },
                                            Anchor = Anchor.Centre,
                                            Origin = Anchor.Centre,
                                            Size = new Vector2(230, 55),
                                            Action = apply,
                                        },
                                    }
                                }
                            }
                        }
                    }
                },
{'fraction_non_alphanumeric': 0.0445806136494827, 'fraction_numerical': 0.005505972203720971, 'mean_word_length': 0.4832718651211802, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 409, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3521422', 'n_tokens_mistral': 3260, 'n_tokens_neox': 2972, 'n_words': 690}