示例#1
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public DrawableDifficulty(DifficultyScrollContainer container)
        {
            Container = container;

            Size  = new ScalableVector2(410, HEIGHT);
            Image = UserInterface.SelectButtonBackground;

            DifficultyName = new SpriteTextBitmap(FontsBitmap.GothamRegular, " ")
            {
                Parent   = this,
                Position = new ScalableVector2(15, 12),
                FontSize = 18
            };

            TextDifficultyRating = new SpriteTextBitmap(FontsBitmap.GothamRegular, " ")
            {
                Parent   = this,
                Position = new ScalableVector2(DifficultyName.X, DifficultyName.Y + DifficultyName.Height + 4),
                Tint     = ColorHelper.DifficultyToColor(19.12f),
                FontSize = 16
            };

            Creator = new SpriteTextBitmap(FontsBitmap.GothamRegular, " ")
            {
                Parent    = this,
                Alignment = Alignment.TopRight,
                Position  = new ScalableVector2(-5, TextDifficultyRating.Y + TextDifficultyRating.Height + 6),
                FontSize  = 14
            };

            Clicked += OnClicked;
            ModManager.ModsChanged += OnModsChanged;
        }
示例#2
0
        /// <summary>
        ///     Updates the information of the map with a new one.
        /// </summary>
        /// <param name="map"></param>
        public void UpdateWithNewMap(Map map)
        {
            Map = map;

            DifficultyName.Text = map.DifficultyName;

            var difficulty = (float)map.DifficultyFromMods(ModManager.Mods);

            TextDifficultyRating.Text = StringHelper.AccuracyToString(difficulty).Replace("%", "");
            TextDifficultyRating.Tint = ColorHelper.DifficultyToColor(difficulty);
            Creator.Text = $"By: {map.Creator}";
        }
示例#3
0
        /// <summary>
        ///     Called when the activated modifiers have changed.
        ///     Used for updating difficulty values.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnModsChanged(object sender, ModsChangedEventArgs e)
        {
            if (Map == null)
            {
                return;
            }

            var difficulty = (float)Map.DifficultyFromMods(ModManager.Mods);

            var value = StringHelper.AccuracyToString(difficulty).Replace("%", "");

            // Don't bother updating the text if the difficulty value is the same as what's already there
            if (value == TextDifficultyRating.Text)
            {
                return;
            }

            TextDifficultyRating.Text = value;
            TextDifficultyRating.Tint = ColorHelper.DifficultyToColor(difficulty);
        }
示例#4
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public DownloadableMapset(DownloadScrollContainer container, JToken mapset)
        {
            Container = container;
            Mapset    = mapset;
            MapsetId  = (int)Mapset["id"];

            Size  = new ScalableVector2(container.Width - 2, HEIGHT);
            Image = UserInterface.DownloadItem;

            Banner = new Sprite
            {
                Parent    = this,
                X         = 0,
                Size      = new ScalableVector2(900 / 3.6f, Height),
                Alignment = Alignment.MidLeft,
                Alpha     = 0
            };

            AlreadyOwned = new SpriteTextBitmap(FontsBitmap.GothamRegular, "Already Owned")
            {
                Parent    = Banner,
                Alignment = Alignment.MidCenter,
                UsePreviousSpriteBatchOptions = true,
                FontSize = 14
            };

            // Check if the mapset is already owned.
            var set = MapDatabaseCache.FindSet(MapsetId);

            IsAlreadyOwned     = set != null;
            AlreadyOwned.Alpha = IsAlreadyOwned ? 1 : 0;

            Title = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{Mapset["title"]}")
            {
                Parent   = this,
                X        = Banner.X + Banner.Width + 15,
                Y        = 10,
                Alpha    = IsAlreadyOwned ? 0.65f : 1,
                FontSize = 16
            };

            Artist = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{Mapset["artist"]}")
            {
                Parent   = this,
                X        = Title.X,
                Y        = Title.Y + Title.Height + 5,
                Alpha    = IsAlreadyOwned ? 0.65f : 1,
                FontSize = 14
            };

            var gameModes = Mapset["game_modes"].ToList();
            var modes     = new List <string>();

            if (gameModes.Contains(1))
            {
                modes.Add("4K");
            }

            if (gameModes.Contains(2))
            {
                modes.Add("7K");
            }

            Modes = new SpriteTextBitmap(FontsBitmap.GothamRegular, string.Join(" & ", modes) + " | ")
            {
                Parent   = this,
                X        = Artist.X,
                Y        = Artist.Y + Artist.Height + 5,
                Alpha    = IsAlreadyOwned ? 0.65f : 1,
                FontSize = 14
            };

            Creator = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"Created By: {Mapset["creator_username"]}")
            {
                Parent    = this,
                Alignment = Alignment.BotRight,
                Position  = new ScalableVector2(-10, -5),
                Alpha     = IsAlreadyOwned ? 0.65f : 1,
                FontSize  = 14
            };

            var lowestDiff  = Mapset["difficulty_range"].ToList().Min();
            var highestDiff = Mapset["difficulty_range"].ToList().Max();

            // ReSharper disable once ObjectCreationAsStatement
            var low = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{lowestDiff:0.00}")
            {
                Parent   = this,
                X        = Modes.X + Modes.Width + 2,
                Y        = Modes.Y,
                Alpha    = IsAlreadyOwned ? 0.65f : 1,
                FontSize = 14,
                Tint     = ColorHelper.DifficultyToColor((float)lowestDiff)
            };

            if (lowestDiff != highestDiff)
            {
                var high = new SpriteTextBitmap(FontsBitmap.GothamRegular, $" - {highestDiff:0.00}")
                {
                    Parent   = this,
                    X        = low.X + low.Width + 2,
                    Y        = Modes.Y,
                    Alpha    = IsAlreadyOwned ? 0.65f : 1,
                    FontSize = 14,
                    Tint     = ColorHelper.DifficultyToColor((float)highestDiff)
                };
            }
            var badge = new BannerRankedStatus
            {
                Parent    = this,
                Alignment = Alignment.TopRight,
                Position  = new ScalableVector2(-10, 5),
                Alpha     = IsAlreadyOwned ? 0.65f : 1,
            };

            var screen = (DownloadScreen)container.View.Screen;

            badge.UpdateMap(new Map {
                RankedStatus = screen.CurrentRankedStatus
            });
            FetchMapsetBanner();

            // ReSharper disable once ObjectCreationAsStatement
            new Sprite()
            {
                Parent    = this,
                Alignment = Alignment.BotLeft,
                Size      = new ScalableVector2(Width, 1),
                Alpha     = 0.65f
            };

            Progress = new ProgressBar(new Vector2(Width - Banner.Width, Height), 0, 100, 0, Color.Transparent, Colors.MainAccent)
            {
                Parent    = this,
                X         = Banner.X + Banner.Width,
                ActiveBar =
                {
                    UsePreviousSpriteBatchOptions = true,
                    Alpha                         = 0.60f
                },
            };

            Clicked += (sender, args) => OnClicked();
        }