Exemple #1
0
        public ProfileHeader(User user)
        {
            RelativeSizeAxes = Axes.X;
            Height           = cover_height + info_height;

            Children = new Drawable[]
            {
                coverContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    Height           = cover_height,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            ColourInfo       = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f))
                        },
                        new Container
                        {
                            Anchor       = Anchor.BottomLeft,
                            Origin       = Anchor.BottomLeft,
                            X            = UserProfileOverlay.CONTENT_X_MARGIN,
                            Y            = -20,
                            AutoSizeAxes = Axes.Both,
                            Children     = new Drawable[]
                            {
                                new UpdateableAvatar
                                {
                                    User         = user,
                                    Size         = new Vector2(avatar_size),
                                    Anchor       = Anchor.BottomLeft,
                                    Origin       = Anchor.BottomLeft,
                                    Masking      = true,
                                    CornerRadius = 5,
                                    EdgeEffect   = new EdgeEffectParameters
                                    {
                                        Type   = EdgeEffectType.Shadow,
                                        Colour = Color4.Black.Opacity(0.25f),
                                        Radius = 4,
                                    },
                                },
                                new Container
                                {
                                    Anchor       = Anchor.BottomLeft,
                                    Origin       = Anchor.BottomLeft,
                                    X            = avatar_size + 10,
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        supporterTag = new CircularContainer
                                        {
                                            Anchor          = Anchor.BottomLeft,
                                            Origin          = Anchor.BottomLeft,
                                            Y               = -75,
                                            Size            = new Vector2(25, 25),
                                            Masking         = true,
                                            BorderThickness = 3,
                                            BorderColour    = Color4.White,
                                            Alpha           = 0,
                                            Children        = new Drawable[]
                                            {
                                                new Box
                                                {
                                                    RelativeSizeAxes = Axes.Both,
                                                    Alpha            = 0,
                                                    AlwaysPresent    = true
                                                },
                                                new TextAwesome
                                                {
                                                    Icon     = FontAwesome.fa_heart,
                                                    Anchor   = Anchor.Centre,
                                                    Origin   = Anchor.Centre,
                                                    TextSize = 12
                                                }
                                            }
                                        },
                                        new LinkFlowContainer.LinkText
                                        {
                                            Text     = user.Username,
                                            Url      = $@"https://osu.ppy.sh/users/{user.Id}",
                                            TextSize = 30,
                                            Font     = @"Exo2.0-RegularItalic",
                                            Anchor   = Anchor.BottomLeft,
                                            Origin   = Anchor.BottomLeft,
                                            Y        = -48
                                        },
                                        countryFlag = new DrawableFlag(user.Country?.FlagName ?? "__")
                                        {
                                            Anchor = Anchor.BottomLeft,
                                            Origin = Anchor.BottomLeft,
                                            Width  = 30,
                                            Height = 20
                                        }
                                    }
                                }
                            }
                        },
                        colourBar = new Box
                        {
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft,
                            X      = UserProfileOverlay.CONTENT_X_MARGIN,
                            Height = 5,
                            Width  = info_width,
                            Alpha  = 0
                        }
                    }
                },
                infoTextLeft = new OsuTextFlowContainer(t =>
                {
                    t.TextSize = 14;
                    t.Alpha    = 0.8f;
                })
                {
                    X                = UserProfileOverlay.CONTENT_X_MARGIN,
                    Y                = cover_height + 20,
                    Width            = info_width,
                    AutoSizeAxes     = Axes.Y,
                    ParagraphSpacing = 0.8f,
                    LineSpacing      = 0.2f
                },
                infoTextRight = new LinkFlowContainer(t =>
                {
                    t.TextSize = 14;
                    t.Font     = @"Exo2.0-RegularItalic";
                })
                {
                    X                = UserProfileOverlay.CONTENT_X_MARGIN + info_width + 20,
                    Y                = cover_height + 20,
                    Width            = info_width,
                    AutoSizeAxes     = Axes.Y,
                    ParagraphSpacing = 0.8f,
                    LineSpacing      = 0.2f
                },
                new Container
                {
                    X = -UserProfileOverlay.CONTENT_X_MARGIN,
                    RelativeSizeAxes = Axes.Y,
                    Width            = 280,
                    Anchor           = Anchor.TopRight,
                    Origin           = Anchor.TopRight,
                    Children         = new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Y        = level_position,
                            Height   = level_height,
                            Children = new Drawable[]
                            {
                                new Box
                                {
                                    Colour           = Color4.Black.Opacity(0.5f),
                                    RelativeSizeAxes = Axes.Both
                                },
                                levelBadge = new Sprite
                                {
                                    Anchor = Anchor.Centre,
                                    Origin = Anchor.Centre,
                                    Height = 50,
                                    Width  = 50,
                                    Alpha  = 0
                                },
                                levelText = new OsuSpriteText
                                {
                                    Anchor   = Anchor.TopCentre,
                                    Origin   = Anchor.TopCentre,
                                    Y        = 11,
                                    TextSize = 20
                                }
                            }
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Y        = cover_height,
                            Anchor   = Anchor.TopCentre,
                            Origin   = Anchor.BottomCentre,
                            Height   = cover_height - level_height - level_position - 5,
                            Children = new Drawable[]
                            {
                                new Box
                                {
                                    Colour           = Color4.Black.Opacity(0.5f),
                                    RelativeSizeAxes = Axes.Both
                                },
                                scoreText = new FillFlowContainer <SpriteText>
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Direction        = FillDirection.Vertical,
                                    Padding          = new MarginPadding {
                                        Horizontal = 20, Vertical = 18
                                    },
                                    Spacing = new Vector2(0, 2)
                                },
                                scoreNumberText = new FillFlowContainer <SpriteText>
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Direction        = FillDirection.Vertical,
                                    Padding          = new MarginPadding {
                                        Horizontal = 20, Vertical = 18
                                    },
                                    Spacing = new Vector2(0, 2)
                                },
                                new FillFlowContainer <GradeBadge>
                                {
                                    AutoSizeAxes = Axes.Both,
                                    Direction    = FillDirection.Horizontal,
                                    Anchor       = Anchor.BottomCentre,
                                    Origin       = Anchor.BottomCentre,
                                    Y            = -64,
                                    Spacing      = new Vector2(20, 0),
                                    Children     = new[]
                                    {
                                        gradeSSPlus = new GradeBadge("SSPlus")
                                        {
                                            Alpha = 0
                                        },
                                        gradeSS = new GradeBadge("SS")
                                        {
                                            Alpha = 0
                                        },
                                    }
                                },
                                new FillFlowContainer <GradeBadge>
                                {
                                    AutoSizeAxes = Axes.Both,
                                    Direction    = FillDirection.Horizontal,
                                    Anchor       = Anchor.BottomCentre,
                                    Origin       = Anchor.BottomCentre,
                                    Y            = -18,
                                    Spacing      = new Vector2(20, 0),
                                    Children     = new[]
                                    {
                                        gradeSPlus = new GradeBadge("SPlus")
                                        {
                                            Alpha = 0
                                        },
                                        gradeS = new GradeBadge("S")
                                        {
                                            Alpha = 0
                                        },
                                        gradeA = new GradeBadge("A")
                                        {
                                            Alpha = 0
                                        },
                                    }
                                }
                            }
                        },
                        chartContainer = new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Anchor           = Anchor.BottomCentre,
                            Origin           = Anchor.BottomCentre,
                            Height           = info_height - 15,
                            Children         = new Drawable[]
                            {
                                new Box
                                {
                                    Colour           = Color4.Black.Opacity(0.25f),
                                    RelativeSizeAxes = Axes.Both
                                }
                            }
                        }
                    }
                }
            };
        }
Exemple #2
0
 protected override Drawable CreateContent() => maskingContainer = new Container
 {
     RelativeSizeAxes = Axes.X,
     Height           = 50,
     Masking          = true,
     CornerRadius     = 10,
     Children         = new Drawable[]
     {
         new Box // A transparent box that forces the border to be drawn if the panel background is opaque
         {
             RelativeSizeAxes = Axes.Both,
             Alpha            = 0,
             AlwaysPresent    = true
         },
         new PanelBackground
         {
             RelativeSizeAxes = Axes.Both,
             Beatmap          = { BindTarget = beatmap }
         },
         new FillFlowContainer
         {
             RelativeSizeAxes = Axes.Both,
             Padding          = new MarginPadding {
                 Left = 8
             },
             Spacing   = new Vector2(8, 0),
             Direction = FillDirection.Horizontal,
             Children  = new Drawable[]
             {
                 difficultyIconContainer = new Container
                 {
                     Anchor       = Anchor.CentreLeft,
                     Origin       = Anchor.CentreLeft,
                     AutoSizeAxes = Axes.Both,
                 },
                 new FillFlowContainer
                 {
                     Anchor       = Anchor.CentreLeft,
                     Origin       = Anchor.CentreLeft,
                     AutoSizeAxes = Axes.Both,
                     Direction    = FillDirection.Vertical,
                     Children     = new Drawable[]
                     {
                         beatmapText = new LinkFlowContainer {
                             AutoSizeAxes = Axes.Both
                         },
                         new FillFlowContainer
                         {
                             AutoSizeAxes = Axes.Both,
                             Direction    = FillDirection.Horizontal,
                             Spacing      = new Vector2(10, 0),
                             Children     = new Drawable[]
                             {
                                 authorText = new LinkFlowContainer {
                                     AutoSizeAxes = Axes.Both
                                 },
                                 modDisplay = new ModDisplay
                                 {
                                     Anchor              = Anchor.CentreLeft,
                                     Origin              = Anchor.CentreLeft,
                                     AutoSizeAxes        = Axes.Both,
                                     Scale               = new Vector2(0.4f),
                                     DisplayUnrankedText = false,
                                     ExpansionMode       = ExpansionMode.AlwaysExpanded
                                 }
                             }
                         }
                     }
                 }
             }
         },
         new Container
         {
             Anchor       = Anchor.CentreRight,
             Origin       = Anchor.CentreRight,
             AutoSizeAxes = Axes.Both,
             X            = -18,
             Children     = new Drawable[]
             {
                 new PlaylistDownloadButton(item.Beatmap.Value.BeatmapSet)
                 {
                     Size = new Vector2(50, 30)
                 },
                 new IconButton
                 {
                     Icon   = FontAwesome.Solid.MinusSquare,
                     Alpha  = allowEdit ? 1 : 0,
                     Action = () => RequestDeletion?.Invoke(Model),
                 },
             }
         }
     }
 };
Exemple #3
0
        private Drawable[] createContent(int index, ScoreInfo score)
        {
            var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: text_size))
            {
                AutoSizeAxes = Axes.Both
            };

            username.AddUserLink(score.User);

            var content = new List <Drawable>
            {
                new OsuSpriteText
                {
                    Text = $"#{index + 1}",
                    Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
                },
                new UpdateableRank(score.Rank)
                {
                    Size = new Vector2(28, 14)
                },
                new OsuSpriteText
                {
                    Margin = new MarginPadding {
                        Right = horizontal_inset
                    },
                    Text = $@"{score.TotalScore:N0}",
                    Font = OsuFont.GetFont(size: text_size, weight: index == 0 ? FontWeight.Bold : FontWeight.Medium)
                },
                new OsuSpriteText
                {
                    Margin = new MarginPadding {
                        Right = horizontal_inset
                    },
                    Text   = score.DisplayAccuracy,
                    Font   = OsuFont.GetFont(size: text_size),
                    Colour = score.Accuracy == 1 ? highAccuracyColour : Color4.White
                },
                new UpdateableFlag(score.User.Country)
                {
                    Size = new Vector2(19, 13),
                    ShowPlaceholderOnNull = false,
                },
                username,
                new OsuSpriteText
                {
                    Text   = $@"{score.MaxCombo:N0}x",
                    Font   = OsuFont.GetFont(size: text_size),
                    Colour = score.MaxCombo == score.Beatmap?.MaxCombo ? highAccuracyColour : Color4.White
                }
            };

            foreach (var kvp in score.SortedStatistics)
            {
                content.Add(new OsuSpriteText
                {
                    Text   = $"{kvp.Value}",
                    Font   = OsuFont.GetFont(size: text_size),
                    Colour = kvp.Value == 0 ? Color4.Gray : Color4.White
                });
            }

            if (showPerformancePoints)
            {
                content.Add(new OsuSpriteText
                {
                    Text = $@"{score.PP:N0}",
                    Font = OsuFont.GetFont(size: text_size)
                });
            }

            content.Add(new FillFlowContainer
            {
                Direction          = FillDirection.Horizontal,
                AutoSizeAxes       = Axes.Both,
                Spacing            = new Vector2(1),
                ChildrenEnumerable = score.Mods.Select(m => new ModIcon(m)
                {
                    AutoSizeAxes = Axes.Both,
                    Scale        = new Vector2(0.3f)
                })
            });

            return(content.ToArray());
        }
Exemple #4
0
        private void load(OsuColour colours, APIAccess api, OsuGame game, TextureStore textures)
        {
            this.api = api;

            if (string.IsNullOrEmpty(api.ProvidedUsername))
            {
                return;
            }

            InternalChildren = new Drawable[]
            {
                new Sprite
                {
                    Anchor  = Anchor.TopCentre,
                    Origin  = Anchor.TopCentre,
                    Texture = textures.Get(@"Menu/dev-build-footer"),
                },
                new Sprite
                {
                    Anchor  = Anchor.BottomCentre,
                    Origin  = Anchor.BottomCentre,
                    Texture = textures.Get(@"Menu/dev-build-footer"),
                },
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Direction        = FillDirection.Vertical,
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    Padding          = new MarginPadding(20),
                    Spacing          = new Vector2(0, 5),
                    Children         = new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 150,
                            Child            = new OsuLogo
                            {
                                Scale     = new Vector2(0.1f),
                                Anchor    = Anchor.Centre,
                                Triangles = false,
                            },
                        },
                        new OsuSpriteText
                        {
                            Anchor = Anchor.TopCentre,
                            Origin = Anchor.TopCentre,
                            Colour = Color4.Red,
                            Font   = OsuFont.GetFont(size: 28, weight: FontWeight.Light),
                            Text   = "Warning! 注意!",
                        },
                        multiAccountExplanationText = new OsuTextFlowContainer(cp => cp.Font = cp.Font.With(size: 12))
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y
                        },
                        new SettingsButton
                        {
                            Text   = "Help, I can't access my account!",
                            Margin = new MarginPadding {
                                Top = 50
                            },
                            Action = () => game?.OpenUrlExternally(help_centre_url)
                        },
                        new DangerousSettingsButton
                        {
                            Text   = "I understand. This account isn't for me.",
                            Action = () => this.Push(new ScreenEntry())
                        },
                        furtherAssistance = new LinkFlowContainer(cp => cp.Font = cp.Font.With(size: 12))
                        {
                            Margin = new MarginPadding {
                                Top = 20
                            },
                            Anchor       = Anchor.TopCentre,
                            Origin       = Anchor.TopCentre,
                            AutoSizeAxes = Axes.Both
                        },
                    }
                }
            };

            multiAccountExplanationText.AddText("Are you ");
            multiAccountExplanationText.AddText(api.ProvidedUsername, cp => cp.Colour = colours.BlueLight);
            multiAccountExplanationText.AddText("? osu! has a policy of ");
            multiAccountExplanationText.AddText("one account per person!", cp => cp.Colour = colours.Yellow);
            multiAccountExplanationText.AddText(" Please be aware that creating more than one account per person may result in ");
            multiAccountExplanationText.AddText("permanent deactivation of accounts", cp => cp.Colour = colours.Yellow);
            multiAccountExplanationText.AddText(".");

            furtherAssistance.AddText("Need further assistance? Contact us via our ");
            furtherAssistance.AddLink("support system", help_centre_url);
            furtherAssistance.AddText(".");
        }
Exemple #5
0
        private void load(OsuColour colours)
        {
            foreach (var categoryEntries in Build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key))
            {
                ChangelogEntries.Add(new OsuSpriteText
                {
                    Text   = categoryEntries.Key,
                    Font   = OsuFont.GetFont(weight: FontWeight.Bold, size: 24),
                    Margin = new MarginPadding {
                        Top = 35, Bottom = 15
                    },
                });

                var fontLarge  = OsuFont.GetFont(size: 18);
                var fontMedium = OsuFont.GetFont(size: 14);
                var fontSmall  = OsuFont.GetFont(size: 12);

                foreach (APIChangelogEntry entry in categoryEntries)
                {
                    LinkFlowContainer title = new LinkFlowContainer
                    {
                        Direction        = FillDirection.Full,
                        RelativeSizeAxes = Axes.X,
                        AutoSizeAxes     = Axes.Y,
                        Margin           = new MarginPadding {
                            Vertical = 5
                        },
                    };

                    var entryColour = entry.Major ? colours.YellowLight : Color4.White;

                    title.AddIcon(FontAwesome.Solid.Check, t =>
                    {
                        t.Font    = fontSmall;
                        t.Colour  = entryColour;
                        t.Padding = new MarginPadding {
                            Left = -17, Right = 5
                        };
                    });

                    title.AddText(entry.Title, t =>
                    {
                        t.Font   = fontLarge;
                        t.Colour = entryColour;
                    });

                    if (!string.IsNullOrEmpty(entry.Repository))
                    {
                        title.AddText(" (", t =>
                        {
                            t.Font   = fontLarge;
                            t.Colour = entryColour;
                        });
                        title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External,
                                      creationParameters: t =>
                        {
                            t.Font   = fontLarge;
                            t.Colour = entryColour;
                        });
                        title.AddText(")", t =>
                        {
                            t.Font   = fontLarge;
                            t.Colour = entryColour;
                        });
                    }

                    title.AddText(" by ", t =>
                    {
                        t.Font   = fontMedium;
                        t.Colour = entryColour;
                    });

                    if (entry.GithubUser.UserId != null)
                    {
                        title.AddUserLink(new User
                        {
                            Username = entry.GithubUser.OsuUsername,
                            Id       = entry.GithubUser.UserId.Value
                        }, t =>
                        {
                            t.Font   = fontMedium;
                            t.Colour = entryColour;
                        });
                    }
                    else if (entry.GithubUser.GithubUrl != null)
                    {
                        title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t =>
                        {
                            t.Font   = fontMedium;
                            t.Colour = entryColour;
                        });
                    }
                    else
                    {
                        title.AddText(entry.GithubUser.DisplayName, t =>
                        {
                            t.Font   = fontSmall;
                            t.Colour = entryColour;
                        });
                    }

                    ChangelogEntries.Add(title);

                    if (!string.IsNullOrEmpty(entry.MessageHtml))
                    {
                        TextFlowContainer message = new TextFlowContainer
                        {
                            AutoSizeAxes     = Axes.Y,
                            RelativeSizeAxes = Axes.X,
                        };

                        // todo: use markdown parsing once API returns markdown
                        message.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t =>
                        {
                            t.Font   = fontSmall;
                            t.Colour = new Color4(235, 184, 254, 255);
                        });

                        ChangelogEntries.Add(message);
                    }
                }
            }
        }
Exemple #6
0
        private void load()
        {
            LinkFlowContainer          username;
            FillFlowContainer          childCommentsContainer;
            DeletedChildrenPlaceholder deletedChildrenPlaceholder;
            FillFlowContainer          info;
            LinkFlowContainer          message;
            GridContainer content;
            VotePill      votePill;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;
            InternalChild    = new FillFlowContainer
            {
                RelativeSizeAxes = Axes.X,
                AutoSizeAxes     = Axes.Y,
                Direction        = FillDirection.Vertical,
                Children         = new Drawable[]
                {
                    new Container
                    {
                        RelativeSizeAxes = Axes.X,
                        AutoSizeAxes     = Axes.Y,
                        Padding          = new MarginPadding(margin)
                        {
                            Left = margin + 5
                        },
                        Child = content = new GridContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            ColumnDimensions = new[]
                            {
                                new Dimension(GridSizeMode.AutoSize),
                                new Dimension(),
                            },
                            RowDimensions = new[]
                            {
                                new Dimension(GridSizeMode.AutoSize)
                            },
                            Content = new[]
                            {
                                new Drawable[]
                                {
                                    new FillFlowContainer
                                    {
                                        AutoSizeAxes = Axes.Both,
                                        Margin       = new MarginPadding {
                                            Horizontal = margin
                                        },
                                        Direction = FillDirection.Horizontal,
                                        Spacing   = new Vector2(5, 0),
                                        Children  = new Drawable[]
                                        {
                                            new Container
                                            {
                                                Anchor       = Anchor.Centre,
                                                Origin       = Anchor.Centre,
                                                Width        = 40,
                                                AutoSizeAxes = Axes.Y,
                                                Child        = votePill = new VotePill(comment)
                                                {
                                                    Anchor = Anchor.CentreRight,
                                                    Origin = Anchor.CentreRight,
                                                }
                                            },
                                            new UpdateableAvatar(comment.User)
                                            {
                                                Anchor         = Anchor.Centre,
                                                Origin         = Anchor.Centre,
                                                Size           = new Vector2(avatar_size),
                                                Masking        = true,
                                                CornerRadius   = avatar_size / 2f,
                                                CornerExponent = 2,
                                            },
                                        }
                                    },
                                    new FillFlowContainer
                                    {
                                        RelativeSizeAxes = Axes.X,
                                        AutoSizeAxes     = Axes.Y,
                                        Spacing          = new Vector2(0, 3),
                                        Children         = new Drawable[]
                                        {
                                            new FillFlowContainer
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Direction    = FillDirection.Horizontal,
                                                Spacing      = new Vector2(7, 0),
                                                Children     = new Drawable[]
                                                {
                                                    username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
                                                    {
                                                        AutoSizeAxes = Axes.Both,
                                                    },
                                                    new ParentUsername(comment),
                                                    new OsuSpriteText
                                                    {
                                                        Alpha = comment.IsDeleted ? 1 : 0,
                                                        Font  = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
                                                        Text  = @"deleted",
                                                    }
                                                }
                                            },
                                            message = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
                                            {
                                                RelativeSizeAxes = Axes.X,
                                                AutoSizeAxes     = Axes.Y,
                                                Padding          = new MarginPadding {
                                                    Right = 40
                                                }
                                            },
                                            info = new FillFlowContainer
                                            {
                                                AutoSizeAxes = Axes.Both,
                                                Direction    = FillDirection.Horizontal,
                                                Spacing      = new Vector2(10, 0),
                                                Colour       = OsuColour.Gray(0.7f),
                                                Children     = new Drawable[]
                                                {
                                                    new OsuSpriteText
                                                    {
                                                        Anchor = Anchor.CentreLeft,
                                                        Origin = Anchor.CentreLeft,
                                                        Font   = OsuFont.GetFont(size: 12),
                                                        Text   = HumanizerUtils.Humanize(comment.CreatedAt)
                                                    },
                                                    new RepliesButton(comment.RepliesCount)
                                                    {
                                                        Expanded = { BindTarget = childrenExpanded }
                                                    },
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    childCommentsVisibilityContainer = new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.X,
                        AutoSizeAxes     = Axes.Y,
                        Direction        = FillDirection.Vertical,
                        Children         = new Drawable[]
                        {
                            childCommentsContainer = new FillFlowContainer
                            {
                                Padding = new MarginPadding {
                                    Left = 20
                                },
                                RelativeSizeAxes = Axes.X,
                                AutoSizeAxes     = Axes.Y,
                                Direction        = FillDirection.Vertical
                            },
                            deletedChildrenPlaceholder = new DeletedChildrenPlaceholder
                            {
                                ShowDeleted = { BindTarget = ShowDeleted }
                            }
                        }
                    }
                }
            };

            deletedChildrenPlaceholder.DeletedCount.Value = comment.DeletedChildrenCount;

            if (comment.UserId.HasValue)
            {
                username.AddUserLink(comment.User);
            }
            else
            {
                username.AddText(comment.LegacyName);
            }

            if (comment.EditedAt.HasValue)
            {
                info.Add(new OsuSpriteText
                {
                    Anchor = Anchor.CentreLeft,
                    Origin = Anchor.CentreLeft,
                    Font   = OsuFont.GetFont(size: 12),
                    Text   = $@"edited {HumanizerUtils.Humanize(comment.EditedAt.Value)} by {comment.EditedUser.Username}"
                });
            }

            if (comment.HasMessage)
            {
                var formattedSource = MessageFormatter.FormatText(comment.GetMessage);
                message.AddLinks(formattedSource.Text, formattedSource.Links);
            }

            if (comment.IsDeleted)
            {
                content.FadeColour(OsuColour.Gray(0.5f));
                votePill.Hide();
            }

            if (comment.IsTopLevel)
            {
                AddInternal(new Container
                {
                    RelativeSizeAxes = Axes.X,
                    Height           = 1.5f,
                    Anchor           = Anchor.BottomCentre,
                    Origin           = Anchor.BottomCentre,
                    Child            = new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour           = OsuColour.Gray(0.1f)
                    }
                });

                if (comment.ChildComments.Any())
                {
                    AddInternal(new ChevronButton(comment)
                    {
                        Anchor = Anchor.TopRight,
                        Origin = Anchor.TopRight,
                        Margin = new MarginPadding {
                            Right = 30, Top = margin
                        },
                        Expanded = { BindTarget = childrenExpanded }
                    });
                }
            }

            comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)
            {
                ShowDeleted = { BindTarget = ShowDeleted }
            }));
        }
Exemple #7
0
        private void load(OverlayColourProvider colourProvider)
        {
            LinkFlowContainer username;
            FillFlowContainer info;
            LinkFlowContainer message;
            GridContainer     content;
            VotePill          votePill;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;
            InternalChildren = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Padding          = getPadding(Comment.IsTopLevel),
                    Child            = new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.X,
                        AutoSizeAxes     = Axes.Y,
                        Direction        = FillDirection.Vertical,
                        Children         = new Drawable[]
                        {
                            content = new GridContainer
                            {
                                RelativeSizeAxes = Axes.X,
                                AutoSizeAxes     = Axes.Y,
                                ColumnDimensions = new[]
                                {
                                    new Dimension(GridSizeMode.Absolute, size: avatar_size + 10),
                                    new Dimension(),
                                },
                                RowDimensions = new[]
                                {
                                    new Dimension(GridSizeMode.AutoSize)
                                },
                                Content = new[]
                                {
                                    new Drawable[]
                                    {
                                        new Container
                                        {
                                            Size     = new Vector2(avatar_size),
                                            Children = new Drawable[]
                                            {
                                                new UpdateableAvatar(Comment.User)
                                                {
                                                    Size           = new Vector2(avatar_size),
                                                    Masking        = true,
                                                    CornerRadius   = avatar_size / 2f,
                                                    CornerExponent = 2,
                                                },
                                                votePill = new VotePill(Comment)
                                                {
                                                    Anchor = Anchor.CentreLeft,
                                                    Origin = Anchor.CentreRight,
                                                    Margin = new MarginPadding
                                                    {
                                                        Right = 5
                                                    }
                                                }
                                            }
                                        },
                                        new FillFlowContainer
                                        {
                                            RelativeSizeAxes = Axes.X,
                                            AutoSizeAxes     = Axes.Y,
                                            Direction        = FillDirection.Vertical,
                                            Spacing          = new Vector2(0, 4),
                                            Margin           = new MarginPadding
                                            {
                                                Vertical = 2
                                            },
                                            Children = new Drawable[]
                                            {
                                                new FillFlowContainer
                                                {
                                                    AutoSizeAxes = Axes.Both,
                                                    Direction    = FillDirection.Horizontal,
                                                    Spacing      = new Vector2(10, 0),
                                                    Children     = new Drawable[]
                                                    {
                                                        username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold))
                                                        {
                                                            AutoSizeAxes = Axes.Both
                                                        },
                                                        new ParentUsername(Comment),
                                                        new OsuSpriteText
                                                        {
                                                            Alpha = Comment.IsDeleted ? 1 : 0,
                                                            Font  = OsuFont.GetFont(size: 14, weight: FontWeight.Bold),
                                                            Text  = new LocalisedString("deleted")
                                                        }
                                                    }
                                                },
                                                message = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    AutoSizeAxes     = Axes.Y
                                                },
                                                info = new FillFlowContainer
                                                {
                                                    AutoSizeAxes = Axes.Both,
                                                    Direction    = FillDirection.Horizontal,
                                                    Spacing      = new Vector2(10, 0),
                                                    Children     = new Drawable[]
                                                    {
                                                        new DrawableDate(Comment.CreatedAt, 12, false)
                                                        {
                                                            Colour = colourProvider.Foreground1
                                                        }
                                                    }
                                                },
                                                new Container
                                                {
                                                    AutoSizeAxes = Axes.Both,
                                                    Children     = new Drawable[]
                                                    {
                                                        showRepliesButton = new ShowRepliesButton(Comment.RepliesCount)
                                                        {
                                                            Expanded = { BindTarget = childrenExpanded }
                                                        },
                                                        loadRepliesButton = new LoadRepliesButton
                                                        {
                                                            Action = () => RepliesRequested(this, ++currentPage)
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                            childCommentsVisibilityContainer = new FillFlowContainer
                            {
                                RelativeSizeAxes = Axes.X,
                                AutoSizeAxes     = Axes.Y,
                                Direction        = FillDirection.Vertical,
                                Padding          = new MarginPadding {
                                    Left = 20
                                },
                                Children = new Drawable[]
                                {
                                    childCommentsContainer = new FillFlowContainer
                                    {
                                        RelativeSizeAxes = Axes.X,
                                        AutoSizeAxes     = Axes.Y,
                                        Direction        = FillDirection.Vertical
                                    },
                                    deletedCommentsCounter = new DeletedCommentsCounter
                                    {
                                        ShowDeleted = { BindTarget = ShowDeleted },
                                        Margin      = new MarginPadding
                                        {
                                            Top = 10
                                        }
                                    },
                                    showMoreButton = new ShowMoreRepliesButton
                                    {
                                        Action = () => RepliesRequested(this, ++currentPage)
                                    }
                                }
                            },
                        }
                    }
                },
                new Container
                {
                    Size   = new Vector2(70, 40),
                    Anchor = Anchor.TopRight,
                    Origin = Anchor.TopRight,
                    Margin = new MarginPadding {
                        Horizontal = 5
                    },
                    Child = chevronButton = new ChevronButton
                    {
                        Anchor   = Anchor.CentreLeft,
                        Origin   = Anchor.CentreLeft,
                        Expanded = { BindTarget = childrenExpanded },
                        Alpha    = 0
                    }
                }
            };

            if (Comment.UserId.HasValue)
            {
                username.AddUserLink(Comment.User);
            }
            else
            {
                username.AddText(Comment.LegacyName);
            }

            if (Comment.EditedAt.HasValue)
            {
                info.Add(new OsuSpriteText
                {
                    Font   = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
                    Text   = $@"edited {HumanizerUtils.Humanize(Comment.EditedAt.Value)} by {Comment.EditedUser.Username}",
                    Colour = colourProvider.Foreground1
                });
            }

            if (Comment.HasMessage)
            {
                var formattedSource = MessageFormatter.FormatText(Comment.Message);
                message.AddLinks(formattedSource.Text, formattedSource.Links);
            }

            if (Comment.IsDeleted)
            {
                content.FadeColour(OsuColour.Gray(0.5f));
                votePill.Hide();
            }

            if (Comment.IsTopLevel)
            {
                AddInternal(new Box
                {
                    Anchor           = Anchor.BottomCentre,
                    Origin           = Anchor.BottomCentre,
                    RelativeSizeAxes = Axes.X,
                    Height           = 1.5f,
                    Colour           = OsuColour.Gray(0.1f)
                });
            }

            if (Replies.Any())
            {
                onRepliesAdded(Replies);
            }

            Replies.CollectionChanged += (_, args) =>
            {
                switch (args.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    onRepliesAdded(args.NewItems.Cast <DrawableComment>());
                    break;

                default:
                    throw new NotSupportedException(@"You can only add replies to this list. Other actions are not supported.");
                }
            };
        }
Exemple #8
0
        public LatencyCertifierScreen()
        {
            InternalChildren = new Drawable[]
            {
                new Box
                {
                    Colour           = overlayColourProvider.Background6,
                    RelativeSizeAxes = Axes.Both,
                },
                mainArea = new Container <LatencyArea>
                {
                    RelativeSizeAxes = Axes.Both,
                },
                // Make sure the edge between the two comparisons can't be used to ascertain latency.
                new Box
                {
                    Name             = "separator",
                    Colour           = ColourInfo.GradientHorizontal(overlayColourProvider.Background6, overlayColourProvider.Background6.Opacity(0)),
                    Width            = 100,
                    RelativeSizeAxes = Axes.Y,
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopLeft,
                },
                new Box
                {
                    Name             = "separator",
                    Colour           = ColourInfo.GradientHorizontal(overlayColourProvider.Background6.Opacity(0), overlayColourProvider.Background6),
                    Width            = 100,
                    RelativeSizeAxes = Axes.Y,
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopRight,
                },
                settings = new FillFlowContainer
                {
                    Name         = "Settings",
                    AutoSizeAxes = Axes.Y,
                    Width        = 800,
                    Padding      = new MarginPadding(10),
                    Spacing      = new Vector2(2),
                    Direction    = FillDirection.Vertical,
                    Anchor       = Anchor.BottomCentre,
                    Origin       = Anchor.BottomCentre,
                    Children     = new Drawable[]
                    {
                        explanatoryText = new LinkFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 20))
                        {
                            AutoSizeAxes     = Axes.Y,
                            RelativeSizeAxes = Axes.X,
                            Anchor           = Anchor.TopCentre,
                            Origin           = Anchor.TopCentre,
                            TextAnchor       = Anchor.TopCentre,
                        },
                        new SettingsSlider <double>
                        {
                            Anchor           = Anchor.TopCentre,
                            Origin           = Anchor.TopCentre,
                            RelativeSizeAxes = Axes.None,
                            Width            = 400,
                            LabelText        = "bpm",
                            Current          = SampleBPM
                        },
                        new SettingsSlider <float>
                        {
                            Anchor           = Anchor.TopCentre,
                            Origin           = Anchor.TopCentre,
                            RelativeSizeAxes = Axes.None,
                            Width            = 400,
                            LabelText        = "visual spacing",
                            Current          = SampleVisualSpacing
                        },
                        new SettingsSlider <double>
                        {
                            Anchor           = Anchor.TopCentre,
                            Origin           = Anchor.TopCentre,
                            RelativeSizeAxes = Axes.None,
                            Width            = 400,
                            LabelText        = "approach rate",
                            Current          = SampleApproachRate
                        },
                    },
                },
                resultsArea = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                statusText = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 40))
                {
                    Anchor           = Anchor.TopCentre,
                    Origin           = Anchor.TopCentre,
                    TextAnchor       = Anchor.TopCentre,
                    Y                = 150,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                },
            };

            explanatoryText.AddParagraph(@"Welcome to the latency certifier!");
            explanatoryText.AddParagraph(@"Do whatever you need to try and perceive the difference in latency, then choose your best side. Read more about the methodology ");
            explanatoryText.AddLink("here", "https://github.com/ppy/osu/wiki/Latency-and-unlimited-frame-rates#methodology");
            explanatoryText.AddParagraph(@"Use the arrow keys or Z/X/F/J to control the display.");
            explanatoryText.AddParagraph(@"Tab key to change focus. Space to change display mode");
        }
Exemple #9
0
        public ProfileHeader(User user)
        {
            RelativeSizeAxes = Axes.X;
            Height           = cover_height + info_height;

            Children = new Drawable[]
            {
                coverContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    Height           = cover_height,
                    Masking          = true,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f))
                        },
                        new Container
                        {
                            Anchor  = Anchor.BottomLeft,
                            Origin  = Anchor.BottomLeft,
                            Padding = new MarginPadding {
                                Left = UserProfileOverlay.CONTENT_X_MARGIN, Bottom = 20, Right = stats_width + UserProfileOverlay.CONTENT_X_MARGIN
                            },
                            AutoSizeAxes     = Axes.Y,
                            RelativeSizeAxes = Axes.X,
                            Children         = new Drawable[]
                            {
                                new UpdateableAvatar
                                {
                                    User         = user,
                                    Size         = new Vector2(avatar_size),
                                    Anchor       = Anchor.BottomLeft,
                                    Origin       = Anchor.BottomLeft,
                                    Masking      = true,
                                    CornerRadius = 5,
                                    OpenOnClick  = { Value = false },
                                    EdgeEffect   = new EdgeEffectParameters
                                    {
                                        Type   = EdgeEffectType.Shadow,
                                        Colour = Color4.Black.Opacity(0.25f),
                                        Radius = 4,
                                    },
                                },
                                new Container
                                {
                                    Anchor       = Anchor.BottomLeft,
                                    Origin       = Anchor.BottomLeft,
                                    X            = avatar_size + 10,
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        SupporterTag = new SupporterIcon
                                        {
                                            Alpha  = 0,
                                            Anchor = Anchor.BottomLeft,
                                            Origin = Anchor.BottomLeft,
                                            Y      = -75,
                                            Size   = new Vector2(25, 25)
                                        },
                                        new FillFlowContainer
                                        {
                                            Direction    = FillDirection.Horizontal,
                                            AutoSizeAxes = Axes.Both,
                                            Anchor       = Anchor.BottomLeft,
                                            Origin       = Anchor.BottomLeft,
                                            Y            = -48,
                                            Children     = new Drawable[]
                                            {
                                                usernameText = new OsuSpriteText
                                                {
                                                    Text     = user.Username,
                                                    Font     = @"Exo2.0-RegularItalic",
                                                    TextSize = 30,
                                                },
                                                new ExternalLinkButton($@"https://osu.ppy.sh/users/{user.Id}")
                                                {
                                                    Anchor = Anchor.BottomLeft,
                                                    Origin = Anchor.BottomLeft,
                                                    Margin = new MarginPadding {
                                                        Left = 3, Bottom = 3
                                                    },                                                   //To better lineup with the font
                                                },
                                            }
                                        },
                                        countryFlag = new DrawableFlag(user.Country)
                                        {
                                            Anchor = Anchor.BottomLeft,
                                            Origin = Anchor.BottomLeft,
                                            Width  = 30,
                                            Height = 20
                                        }
                                    }
                                },
                                badgeContainer = new BadgeContainer
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Origin           = Anchor.BottomLeft,
                                    Margin           = new MarginPadding {
                                        Bottom = 5
                                    },
                                    Alpha = 0,
                                },
                            }
                        },
                        colourBar = new Box
                        {
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft,
                            X      = UserProfileOverlay.CONTENT_X_MARGIN,
                            Height = 5,
                            Width  = info_width,
                            Alpha  = 0
                        }
                    }
                },
                new Box // this is a temporary workaround for incorrect masking behaviour of FillMode.Fill used in UserCoverBackground (see https://github.com/ppy/osu-framework/issues/1675)
                {
                    RelativeSizeAxes = Axes.X,
                    Height           = 1,
                    Y      = cover_height,
                    Colour = OsuColour.Gray(34),
                },
                infoTextLeft = new LinkFlowContainer(t => t.TextSize = 14)
                {
                    X                = UserProfileOverlay.CONTENT_X_MARGIN,
                    Y                = cover_height + 20,
                    Width            = info_width,
                    AutoSizeAxes     = Axes.Y,
                    ParagraphSpacing = 0.8f,
                    LineSpacing      = 0.2f
                },
                infoTextRight = new LinkFlowContainer(t =>
                {
                    t.TextSize = 14;
                    t.Font     = @"Exo2.0-RegularItalic";
                })
                {
                    X                = UserProfileOverlay.CONTENT_X_MARGIN + info_width + 20,
                    Y                = cover_height + 20,
                    Width            = info_width,
                    AutoSizeAxes     = Axes.Y,
                    ParagraphSpacing = 0.8f,
                    LineSpacing      = 0.2f
                },
                new Container
                {
                    X = -UserProfileOverlay.CONTENT_X_MARGIN,
                    RelativeSizeAxes = Axes.Y,
                    Width            = stats_width,
                    Anchor           = Anchor.TopRight,
                    Origin           = Anchor.TopRight,
                    Children         = new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Y        = level_position,
                            Height   = level_height,
                            Children = new Drawable[]
                            {
                                new Box
                                {
                                    Colour           = Color4.Black.Opacity(0.5f),
                                    RelativeSizeAxes = Axes.Both
                                },
                                levelBadge = new Sprite
                                {
                                    Anchor = Anchor.Centre,
                                    Origin = Anchor.Centre,
                                    Height = 50,
                                    Width  = 50,
                                    Alpha  = 0
                                },
                                levelText = new OsuSpriteText
                                {
                                    Anchor   = Anchor.TopCentre,
                                    Origin   = Anchor.TopCentre,
                                    Y        = 11,
                                    TextSize = 20
                                }
                            }
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Y        = cover_height,
                            Anchor   = Anchor.TopCentre,
                            Origin   = Anchor.BottomCentre,
                            Height   = cover_height - level_height - level_position - 5,
                            Children = new Drawable[]
                            {
                                new Box
                                {
                                    Colour           = Color4.Black.Opacity(0.5f),
                                    RelativeSizeAxes = Axes.Both
                                },
                                scoreText = new FillFlowContainer <SpriteText>
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Direction        = FillDirection.Vertical,
                                    Padding          = new MarginPadding {
                                        Horizontal = 20, Vertical = 18
                                    },
                                    Spacing = new Vector2(0, 2)
                                },
                                scoreNumberText = new FillFlowContainer <SpriteText>
                                {
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Direction        = FillDirection.Vertical,
                                    Padding          = new MarginPadding {
                                        Horizontal = 20, Vertical = 18
                                    },
                                    Spacing = new Vector2(0, 2)
                                },
                                new FillFlowContainer <GradeBadge>
                                {
                                    AutoSizeAxes = Axes.Both,
                                    Direction    = FillDirection.Horizontal,
                                    Anchor       = Anchor.BottomCentre,
                                    Origin       = Anchor.BottomCentre,
                                    Y            = -64,
                                    Spacing      = new Vector2(20, 0),
                                    Children     = new[]
                                    {
                                        gradeSSPlus = new GradeBadge("SSPlus")
                                        {
                                            Alpha = 0
                                        },
                                        gradeSS = new GradeBadge("SS")
                                        {
                                            Alpha = 0
                                        },
                                    }
                                },
                                new FillFlowContainer <GradeBadge>
                                {
                                    AutoSizeAxes = Axes.Both,
                                    Direction    = FillDirection.Horizontal,
                                    Anchor       = Anchor.BottomCentre,
                                    Origin       = Anchor.BottomCentre,
                                    Y            = -18,
                                    Spacing      = new Vector2(20, 0),
                                    Children     = new[]
                                    {
                                        gradeSPlus = new GradeBadge("SPlus")
                                        {
                                            Alpha = 0
                                        },
                                        gradeS = new GradeBadge("S")
                                        {
                                            Alpha = 0
                                        },
                                        gradeA = new GradeBadge("A")
                                        {
                                            Alpha = 0
                                        },
                                    }
                                }
                            }
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Anchor           = Anchor.BottomCentre,
                            Origin           = Anchor.BottomCentre,
                            Height           = info_height - 15,
                            Children         = new Drawable[]
                            {
                                new Box
                                {
                                    Colour           = Color4.Black.Opacity(0.25f),
                                    RelativeSizeAxes = Axes.Both
                                },
                                rankGraph = new RankGraph
                                {
                                    RelativeSizeAxes = Axes.Both
                                }
                            }
                        }
                    }
                }
            };
        }