示例#1
0
 private BeatmapCard[] createCardsFor(IEnumerable <APIBeatmapSet> beatmapSets) => beatmapSets.Select(set => BeatmapCard.Create(set, filterControl.CardSize.Value).With(c =>
 {
     c.Anchor = Anchor.TopCentre;
     c.Origin = Anchor.TopCentre;
 })).ToArray();
示例#2
0
        public BeatmapLevelListing()
        {
            RelativeSizeAxes = Axes.Both;
            Strategy         = DrawSizePreservationStrategy.Minimum;

            Children = new Drawable[]
            {
                new ScrollContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding
                    {
                        Top        = 100,
                        Horizontal = 10,
                        Bottom     = 10
                    },
                    Children = new Drawable[]
                    {
                        beatmapContainer = new FillFlowContainer
                        {
                            RelativeSizeAxes = Axes.X,
                            AutoSizeAxes     = Axes.Y,
                            Direction        = FillDirection.Full,
                            Spacing          = new Vector2(10),
                            LayoutDuration   = 100,
                            LayoutEasing     = Easing.Out,
                        }
                    }
                },
            };

            cards = new List <BeatmapCard>();

            for (var i = 0; i < Directory.GetDirectories(@"C:\Program Files (x86)\Steam\steamapps\common\Project Arrhythmia\beatmaps\editor").Length; i++)
            {
                var directoryName = Directory.GetDirectories(@"C:\Program Files (x86)\Steam\steamapps\common\Project Arrhythmia\beatmaps\editor")[i];
                var BeatmapMeta   = JsonConvert.DeserializeObject <PAMetadata>(File.ReadAllText(directoryName + @"\metadata.lsb"));
                var card          = new BeatmapCard(BeatmapMeta);

                card.index     = i;
                card.Directory = directoryName;

                if (File.Exists(directoryName + @"\banner.jpg"))
                {
                    FileStream image = File.OpenRead(directoryName + @"\banner.jpg");
                    card.Background.Texture = Texture.FromStream(image);
                }
                else if (File.Exists(directoryName + @"\level.jpg"))
                {
                    FileStream image = File.OpenRead(directoryName + @"\level.jpg");
                    card.Background.Texture = Texture.FromStream(image);
                }
                else
                {
                    FileStream image = File.OpenRead(@"C:\Program Files (x86)\Steam\steamapps\common\Project Arrhythmia\beatmaps\editor\default.jpg");
                    card.Background.Texture = Texture.FromStream(image);
                }

                cards.Add(card);
            }

            /*foreach (var c in cards)
             * {
             *  beatmapContainer.Add(cards[c.index]);
             *
             *  cards[c.index].Selected.ValueChanged += obj =>
             *  {
             *      if (obj.NewValue)
             *          foreach (var j in cards)
             *              if (j != cards[c.index] && j.Selected.Value)
             *                  j.Selected.Value = false;
             *  };
             * }*/

            beatmapContainer.AddRange(cards);
        }