public ChangeLogMarkdownContainer(APIChangelogBuild build)
        {
            DocumentUrl = build.DocumentUrl;
            RootUrl     = build.RootUrl;

            using (var httpClient = new HttpClient())
            {
                Text = httpClient.GetStringAsync(build.ReadmeDownloadUrl).Result;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fetches and shows a specific build from a specific update stream.
        /// </summary>
        /// <param name="build">Must contain at least <see cref="APIUpdateStream.Name"/> and
        /// <see cref="APIChangelogBuild.Version"/>. If <see cref="APIUpdateStream.DisplayName"/> and
        /// <see cref="APIChangelogBuild.DisplayVersion"/> are specified, the header will instantly display them.</param>
        public void ShowBuild([NotNull] APIChangelogBuild build)
        {
            if (build == null)
            {
                throw new ArgumentNullException(nameof(build));
            }

            Current.Value = build;
            Show();
        }
Exemplo n.º 3
0
        public Comments(APIChangelogBuild build)
        {
            this.build = build;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;

            Padding = new MarginPadding
            {
                Horizontal = 50,
                Vertical   = 20,
            };
        }
Exemplo n.º 4
0
            public PostButton(APIChangelogBuild post)
            {
                this.post = post;

                RelativeSizeAxes = Axes.X;
                AutoSizeAxes     = Axes.Y;
                Child            = text = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 12))
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Text             = post.DisplayVersion
                };
            }
        private void load(CancellationToken?cancellation, IAPIProvider api, OverlayColourProvider colourProvider)
        {
            bool complete = false;

            var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);

            req.Success += res =>
            {
                build    = res;
                complete = true;
            };
            req.Failure += _ => complete = true;

            api.PerformAsync(req);

            while (!complete)
            {
                if (cancellation?.IsCancellationRequested == true)
                {
                    req.Cancel();
                    return;
                }

                Thread.Sleep(10);
            }

            if (build != null)
            {
                CommentsContainer comments;

                Children = new Drawable[]
                {
                    new ChangelogBuildWithNavigation(build)
                    {
                        SelectBuild = SelectBuild
                    },
                    new Box
                    {
                        RelativeSizeAxes = Axes.X,
                        Height           = 2,
                        Colour           = colourProvider.Background6,
                        Margin           = new MarginPadding {
                            Top = 30
                        },
                    },
                    comments = new CommentsContainer()
                };

                comments.ShowComments(CommentableType.Build, build.Id);
            }
        }
        private void load(CancellationToken?cancellation, IAPIProvider api)
        {
            bool complete = false;

            var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);

            req.Success += res =>
            {
                build    = res;
                complete = true;
            };
            req.Failure += _ => complete = true;

            // This is done on a separate thread to support cancellation below
            Task.Run(() =>
            {
                try
                {
                    req.Perform(api);
                }
                catch
                {
                    complete = true;
                }
            });

            while (!complete)
            {
                if (cancellation?.IsCancellationRequested == true)
                {
                    req.Cancel();
                    return;
                }

                Thread.Sleep(10);
            }

            if (build != null)
            {
                Children = new Drawable[]
                {
                    new ChangelogBuildWithNavigation(build)
                    {
                        SelectBuild = SelectBuild
                    },
                    new Comments(build)
                }
            }
            ;
        }
Exemplo n.º 7
0
            public NavigationIconButton(APIChangelogBuild build)
            {
                Anchor = Anchor.Centre;
                Origin = Anchor.Centre;

                if (build == null)
                {
                    return;
                }

                TooltipText = build.DisplayVersion;

                Action = () =>
                {
                    SelectBuild?.Invoke(build);
                    Enabled.Value = false;
                };
            }
Exemplo n.º 8
0
        public ChangelogBuild(APIChangelogBuild build)
        {
            Build = build;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;
            Direction        = FillDirection.Vertical;
            Padding          = new MarginPadding {
                Horizontal = HORIZONTAL_PADDING
            };

            Children = new Drawable[]
            {
                CreateHeader(),
                ChangelogEntries = new ChangeLogMarkdownContainer(build)
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                },
            };
        }
Exemplo n.º 9
0
        private void load(CancellationToken?cancellation, IAPIProvider api)
        {
            bool complete = false;

            var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);

            req.Success += res =>
            {
                build    = res;
                complete = true;
            };
            req.Failure += _ => complete = true;

            api.PerformAsync(req);

            while (!complete)
            {
                if (cancellation?.IsCancellationRequested == true)
                {
                    req.Cancel();
                    return;
                }

                Thread.Sleep(10);
            }

            if (build != null)
            {
                Children = new Drawable[]
                {
                    new ChangelogBuildWithNavigation(build)
                    {
                        SelectBuild = SelectBuild
                    },
                    new Comments(build)
                };
            }
        }
Exemplo n.º 10
0
 public ChangelogBuildWithNavigation(APIChangelogBuild build)
     : base(build)
 {
 }
Exemplo n.º 11
0
 public ChangelogSingleBuild(APIChangelogBuild build)
 {
     this.build = build;
 }
Exemplo n.º 12
0
        public ChangelogBuild(APIChangelogBuild build)
        {
            Build = build;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;
            Direction        = FillDirection.Vertical;
            Padding          = new MarginPadding {
                Horizontal = HORIZONTAL_PADDING
            };

            Children = new Drawable[]
            {
                CreateHeader(),
                ChangelogEntries = new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Direction        = FillDirection.Vertical,
                },
            };

            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
                        },
                    };

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

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

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

                    title.AddText(" by ", t => t.Font = fontMedium);

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

                    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);
                    }
                }
            }
        }
Exemplo n.º 13
0
 public void SelectBuild(APIChangelogBuild build) => BuildSelected?.Invoke(build);