Пример #1
0
        private void load(OverlayColourProvider colourProvider, GameHost host)
        {
            if (post.Slug != null)
            {
                TooltipText = "view in browser";
                Action      = () => host.OpenUrlExternally("https://osu.ppy.sh/home/news/" + post.Slug);
            }

            NewsBackground bg;

            AddRange(new Drawable[]
            {
                background = new Box
                {
                    RelativeSizeAxes = Axes.Both
                },
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Direction        = FillDirection.Vertical,
                    Children         = new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 160,
                            Masking          = true,
                            CornerRadius     = 6,
                            Children         = new Drawable[]
                            {
                                new DelayedLoadWrapper(bg = new NewsBackground(post.FirstImage)
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    FillMode         = FillMode.Fill,
                                    Anchor           = Anchor.Centre,
                                    Origin           = Anchor.Centre,
                                    Alpha            = 0
                                })
                                {
                                    RelativeSizeAxes = Axes.Both
                                },
                                new DateContainer(post.PublishedAt)
                                {
                                    Anchor = Anchor.TopRight,
                                    Origin = Anchor.TopRight,
                                    Margin = new MarginPadding
                                    {
                                        Top   = 10,
                                        Right = 15
                                    }
                                }
                            }
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Padding          = new MarginPadding
                            {
                                Horizontal = 15,
                                Vertical   = 10
                            },
                            Child = main = new TextFlowContainer
                            {
                                RelativeSizeAxes = Axes.X,
                                AutoSizeAxes     = Axes.Y
                            }
                        }
                    }
                }
            });

            IdleColour  = colourProvider.Background4;
            HoverColour = colourProvider.Background3;

            bg.OnLoadComplete += d => d.FadeIn(250, Easing.In);

            main.AddParagraph(post.Title, t => t.Font   = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold));
            main.AddParagraph(post.Preview, t => t.Font = OsuFont.GetFont(size: 12)); // Should use sans-serif font
            main.AddParagraph("by ", t => t.Font        = OsuFont.GetFont(size: 12));
            main.AddText(post.Author, t => t.Font       = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold));
        }
Пример #2
0
        public NewsArticleCover(ArticleInfo info)
        {
            RelativeSizeAxes = Axes.X;
            Masking          = true;
            CornerRadius     = 4;

            NewsBackground bg;

            Children = new Drawable[]
            {
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.1f))
                },
                new DelayedLoadWrapper(bg = new NewsBackground(info.CoverUrl)
                {
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.Both,
                    FillMode         = FillMode.Fill,
                    Alpha            = 0
                })
                {
                    Anchor           = Anchor.Centre,
                    Origin           = Anchor.Centre,
                    RelativeSizeAxes = Axes.Both,
                },
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.6f)),
                    Alpha            = 1f,
                },
                new DateContainer(info.Time)
                {
                    Margin = new MarginPadding
                    {
                        Right = 20,
                        Top   = 20,
                    }
                },
                new OsuSpriteText
                {
                    Anchor = Anchor.BottomLeft,
                    Origin = Anchor.BottomLeft,
                    Margin = new MarginPadding
                    {
                        Left   = 25,
                        Bottom = 50,
                    },
                    Font = OsuFont.GetFont(Typeface.Exo, 24, FontWeight.Bold),
                    Text = info.Title,
                },
                new OsuSpriteText
                {
                    Anchor = Anchor.BottomLeft,
                    Origin = Anchor.BottomLeft,
                    Margin = new MarginPadding
                    {
                        Left   = 25,
                        Bottom = 30,
                    },
                    Font = OsuFont.GetFont(Typeface.Exo, 16, FontWeight.Bold),
                    Text = "by " + info.Author
                }
            };

            bg.OnLoadComplete += d => d.FadeIn(250, Easing.In);
        }
Пример #3
0
        private void load()
        {
            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;
            Masking          = true;
            CornerRadius     = 6;

            NewsBackground bg;

            InternalChildren = new Drawable[]
            {
                background = new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = colourProvider.Background4
                },
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Direction        = FillDirection.Vertical,
                    Children         = new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 160,
                            Masking          = true,
                            CornerRadius     = 6,
                            Children         = new Drawable[]
                            {
                                new DelayedLoadWrapper(bg = new NewsBackground(post.FirstImage)
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    FillMode         = FillMode.Fill,
                                    Anchor           = Anchor.Centre,
                                    Origin           = Anchor.Centre,
                                    Alpha            = 0
                                })
                                {
                                    RelativeSizeAxes = Axes.Both
                                },
                                new DateContainer(post.PublishedAt)
                                {
                                    Anchor = Anchor.TopRight,
                                    Origin = Anchor.TopRight,
                                    Margin = new MarginPadding
                                    {
                                        Top   = 10,
                                        Right = 15
                                    }
                                }
                            }
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Padding          = new MarginPadding
                            {
                                Horizontal = 15,
                                Vertical   = 10
                            },
                            Child = main = new TextFlowContainer
                            {
                                RelativeSizeAxes = Axes.X,
                                AutoSizeAxes     = Axes.Y
                            }
                        }
                    }
                },
                new HoverClickSounds()
            };

            bg.OnLoadComplete += d => d.FadeIn(250, Easing.In);

            main.AddParagraph(post.Title, t => t.Font   = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold));
            main.AddParagraph(post.Preview, t => t.Font = OsuFont.GetFont(size: 12)); // Should use sans-serif font
            main.AddParagraph("by ", t => t.Font        = OsuFont.GetFont(size: 12));
            main.AddText(post.Author, t => t.Font       = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold));
        }