示例#1
0
        /*
         *  Complex DataAttr Implementations
         */

        /// <summary> Combines all difficulties this issue applies to into a condition attribute
        /// (data-condition="difficulty=1,2,3"), which is then returned. </summary>
        protected static string DifficultiesDataAttr(Issue anIssue)
        {
            BeatmapCheckMetadata metadata = anIssue.CheckOrigin.GetMetadata() as BeatmapCheckMetadata;

            List <Beatmap.Difficulty> difficulties = new List <Beatmap.Difficulty>();

            foreach (Beatmap.Difficulty difficulty in Enum.GetValues(typeof(Beatmap.Difficulty)))
            {
                if ((metadata?.Difficulties.Contains(difficulty) ?? true) && (
                        !anIssue.InterpretationPairs.Any(aPair => aPair.Key == "difficulty") ||
                        anIssue.InterpretationPairs.Any(aPair => aPair.Key == "difficulty" && aPair.Value == (int)difficulty)))
                {
                    difficulties.Add(difficulty);
                }
            }

            return(DifficultiesDataAttr(difficulties.ToArray()));
        }
示例#2
0
        private static string RenderBeatmapIssues(IEnumerable <Issue> aCategoryIssues, string aCategory, bool aGeneral = false)
        {
            return
                (String.Concat(
                     CheckerRegistry.GetChecks()
                     .Where(aCheck =>
                            aCheck.GetMetadata().Category == aCategory &&
                            aGeneral == aCheck is GeneralCheck)
                     .Select(aCheck =>
            {
                BeatmapCheckMetadata metadata = aCheck.GetMetadata() as BeatmapCheckMetadata;
                IEnumerable <Issue> issues = aCategoryIssues.Where(anIssue => anIssue.CheckOrigin == aCheck);

                string message = aCheck.GetMetadata().Message;

                return
                DivAttr("card-detail",
                        (metadata != null ? DifficultiesDataAttr(metadata.Difficulties) : "") +
                        " data-check=\"" + Encode(message) + "\"",
                        Div("card-detail-icon " + GetIcon(issues) + "-icon"),
                        (issues.Any() ?
                         Div("",
                             Div("card-detail-text",
                                 message
                                 ),
                             DivAttr("vertical-arrow card-detail-toggle detail-shortcut",
                                     Tooltip("Toggle details")
                                     )
                             ) :
                         Div("card-detail-text",
                             message
                             )),
                        DivAttr("doc-shortcut detail-shortcut",
                                Tooltip("Show documentation")
                                )
                        ) +
                RenderBeatmapDetails(issues);
            })));
        }
示例#3
0
        private static string RenderChecks()
        {
            List <Check> checks = CheckerRegistry.GetChecks();

            IEnumerable <Check> generalChecks = checks.Where(aCheck => aCheck is GeneralCheck);

            IEnumerable <Check> allModeChecks = checks.Where(aCheck =>
            {
                BeatmapCheckMetadata metadata = aCheck.GetMetadata() as BeatmapCheckMetadata;

                if (metadata == null)
                {
                    return(false);
                }

                return
                (metadata.Modes.Contains(Beatmap.Mode.Standard) &&
                 metadata.Modes.Contains(Beatmap.Mode.Taiko) &&
                 metadata.Modes.Contains(Beatmap.Mode.Catch) &&
                 metadata.Modes.Contains(Beatmap.Mode.Mania));
            });

            bool hasMode(Check aCheck, Beatmap.Mode aMode) => (aCheck.GetMetadata() as BeatmapCheckMetadata)?.Modes.Contains(aMode) ?? false;

            IEnumerable <Check> standardChecks = checks.Where(aCheck => hasMode(aCheck, Beatmap.Mode.Standard)).Except(allModeChecks).Except(generalChecks);
            IEnumerable <Check> catchChecks    = checks.Where(aCheck => hasMode(aCheck, Beatmap.Mode.Taiko)).Except(allModeChecks).Except(generalChecks);
            IEnumerable <Check> taikoChecks    = checks.Where(aCheck => hasMode(aCheck, Beatmap.Mode.Catch)).Except(allModeChecks).Except(generalChecks);
            IEnumerable <Check> maniaChecks    = checks.Where(aCheck => hasMode(aCheck, Beatmap.Mode.Mania)).Except(allModeChecks).Except(generalChecks);

            return
                (RenderModeCategory("General", generalChecks) +
                 RenderModeCategory("All Modes", allModeChecks) +
                 RenderModeCategory("Standard", standardChecks) +
                 RenderModeCategory("Taiko", catchChecks) +
                 RenderModeCategory("Catch", taikoChecks) +
                 RenderModeCategory("Mania", maniaChecks));
        }