Example #1
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public MapsetSearchContainer(SelectScreenView view)
        {
            View = view;
            Size = new ScalableVector2(620, 90);

            Alpha = 0.80f;
            Image = UserInterface.SelectSearchBackground;

            CreateTextSearch();
            CreateSearchBox();
            CreateTextOrderBy();
            CreateOrderByArtistButton();
            CreateOrderByTitleButton();
            CreateOrderByCreatorButton();
            CreateOrderByDateAddedButton();
            CreateTextMapsetsFound();

            var leftLine = new Sprite()
            {
                Parent = this,
                Size   = new ScalableVector2(2, Height),
            };

            var rightLine = new Sprite()
            {
                Parent    = this,
                Size      = new ScalableVector2(2, Height),
                Alignment = Alignment.TopRight,
            };

            // Line displayed at the bottom of the container.
            var bottomline = new Sprite()
            {
                Parent    = this,
                Size      = new ScalableVector2(Width, 2),
                Alignment = Alignment.BotLeft,
            };

            ConfigManager.SelectOrderMapsetsBy.ValueChanged += OnSelectOrderMapsetsByChanged;
        }
Example #2
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="userGroups"></param>
        public ChatBadge(UserGroups userGroups)
        {
            UserGroups = userGroups;

            var userGroupColor = Colors.GetUserChatColor(UserGroups);

            Tint = new Color((int)(userGroupColor.R * 0.75f), (int)(userGroupColor.G * 0.75f), (int)(userGroupColor.B * 0.75f));

            Icon = new Sprite()
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                Image     = GetIcon(UserGroups),
                X         = 10,
                UsePreviousSpriteBatchOptions = true
            };

            TextUserGroup = new SpriteText(Fonts.Exo2SemiBold, GetUserGroupName(UserGroups), 11, false)
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                UsePreviousSpriteBatchOptions = true
            };

            Icon.Size = new ScalableVector2(TextUserGroup.Height * 0.75f, TextUserGroup.Height * 0.75f);

            TextUserGroup.X = Icon.X + Icon.Width + 5;

            var width = Icon.X + Icon.Width + TextUserGroup.Width + 10 + 4;

            if ((int)width % 2 != 0)
            {
                width += 1;
            }

            Size = new ScalableVector2(width, TextUserGroup.Height + 3);
            AddBorder(new Color(Tint.R / 2, Tint.G / 2, Tint.B / 2), 3);
            Border.Alpha = 0.85f;
            Border.Y     = -1;
        }
Example #3
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="t"></param>
        /// <param name="level"></param>
        public DrawableLog(string t, LogLevel level)
        {
            Text = new SpriteText("Calibri", t, 16, (int)(WindowManager.Width / 0.75f))
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                Y         = 1
            };

            Text.Size = new ScalableVector2(Text.Width * 0.60f, Text.Height * 0.60f);

            Alpha = 0.65f;

            Size = new ScalableVector2(Text.Width + 3, Text.Height + 3);
            X    = -Width;

            switch (level)
            {
            case LogLevel.Debug:
                Tint = Color.Black;
                break;

            case LogLevel.Warning:
                Tint = Color.Gold;
                break;

            case LogLevel.Important:
                Tint = Color.Black;
                break;

            case LogLevel.Error:
                Tint = Color.DarkRed;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(level), level, null);
            }

            Animations.Add(new Animation(AnimationProperty.X, Easing.OutQuint, X, 0, 300));
        }
Example #4
0
        /// <inheritdoc />
        ///  <summary>
        ///  </summary>
        ///  <param name="dialog"></param>
        ///  <param name="modifier"></param>
        public DrawableModifier(ModifiersDialog dialog, IGameplayModifier modifier)
        {
            Dialog   = dialog;
            Modifier = modifier;

            Size = new ScalableVector2(dialog.Width, 60);
            Tint = Color.Black;

            CreateModifierName();
            CreateModifierDescription();

            // ReSharper disable once VirtualMemberCallInConstructor
            Options = CreateModsDialogOptions();

            // ReSharper disable once VirtualMemberCallInConstructor
            ChangeSelectedOptionButton();

            AlignOptions();

            UsePreviousSpriteBatchOptions = true;
            ModManager.ModsChanged       += OnModsChanged;
        }
Example #5
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            if (MouseManager.CurrentState.LeftButton == ButtonState.Pressed)
            {
                // Calculate the new size that the cursor will be when pressed.
                var newSize = MathHelper.Lerp(Width, OriginalSize * ExpandScale, (float)Math.Min(GameBase.Game.TimeSinceLastFrame / 60, 1));
                Size = new ScalableVector2(newSize, newSize);
            }
            else
            {
                // Calculate new size when not pressed.
                var newSize = MathHelper.Lerp(Width, OriginalSize, (float)Math.Min(GameBase.Game.TimeSinceLastFrame / 60, 1));
                Size = new ScalableVector2(newSize, newSize);
            }

            X = MouseManager.CurrentState.X;
            Y = MouseManager.CurrentState.Y;

            PerformShowAndHideAnimations(gameTime);

            base.Update(gameTime);
        }
Example #6
0
        /// <summary>
        ///    Purges messages from a given user.
        /// </summary>
        /// <param name="id"></param>
        public void PurgeUserMessages(int id)
        {
            lock (DrawableChatMessages)
            {
                // A cached version of the muted text, so we don't have to keep creating the same one.
                Texture2D mutedTextImage = null;
                var       mutedTextSize  = new ScalableVector2(0, 0);

                // Scan the previous 50 chat messages.
                for (var i = DrawableChatMessages.Count - 1; i >= 0 && i >= DrawableChatMessages.Count - 50; i--)
                {
                    var msg = DrawableChatMessages[i];

                    if (msg.Message.Sender.OnlineUser.Id != id)
                    {
                        continue;
                    }

                    // If a message is red, then you know it is already past muted.
                    if (msg.TextMessageContent.Tint == Color.Crimson)
                    {
                        break;
                    }

                    if (mutedTextImage != null)
                    {
                        msg.TextMessageContent.Tint  = Color.Crimson;
                        msg.TextMessageContent.Image = mutedTextImage;
                        msg.TextMessageContent.Size  = mutedTextSize;
                        continue;
                    }

                    msg.TextMessageContent.Tint = Color.Crimson;
                    msg.TextMessageContent.Text = "This message has been removed by a moderator.";
                    mutedTextImage = msg.TextMessageContent.Image;
                    mutedTextSize  = msg.TextMessageContent.Size;
                }
            }
        }
Example #7
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="container"></param>
        /// <param name="game"></param>
        public DrawableMultiplayerGameButton(LobbyMatchScrollContainer container, DrawableMultiplayerGame game) : base(UserInterface.BlankBox)
        {
            Container = container;
            Game      = game;
            Tint      = Color.Black;
            Size      = new ScalableVector2(game.Width, game.HEIGHT * 0.95f);
            Alignment = Alignment.MidLeft;
            UsePreviousSpriteBatchOptions = true;

            Clicked += (o, e) =>
            {
                if (game.Item.HasPassword)
                {
                    DialogManager.Show(new JoinPasswordedGameDialog(game.Item));
                }
                else
                {
                    DialogManager.Show(new JoiningGameDialog(JoiningGameDialogType.Joining));
                    ThreadScheduler.RunAfter(() => OnlineManager.Client.JoinGame(game.Item), 800);
                }
            };
        }
Example #8
0
        public Visualizer()
        {
            Alignment = Alignment.MidCenter;
            Size      = new ScalableVector2(WindowManager.Width, 75);
            Tint      = Color.Black;
            Alpha     = 0.45f;
            Y         = -10;

            Bars = new List <Sprite>();

            for (var i = 0; i < 8; i++)
            {
                Bars.Add(new Sprite()
                {
                    Parent    = this,
                    Width     = 20,
                    X         = i * 25,
                    Tint      = Color.Red,
                    Alignment = Alignment.MidCenter
                });
            }
        }
Example #9
0
        /// <summary>
        /// </summary>
        /// <param name="changer"></param>
        /// <param name="items"></param>
        public EditorMetadataScrollContainer(EditorMetadataChanger changer, List <EditorMetadataItem> items) : base(new ScalableVector2(0, 0), new ScalableVector2(0, 0))
        {
            Changer = changer;
            Items   = items;
            Size    = new ScalableVector2(Changer.Width, Changer.Height - Changer.HeaderBackground.Height - Changer.FooterBackground.Height);
            Alpha   = 0;

            Scrollbar.Tint       = Color.White;
            Scrollbar.Width      = 5;
            Scrollbar.X         += 8;
            ScrollSpeed          = 150;
            EasingType           = Easing.OutQuint;
            TimeToCompleteScroll = 1500;

            var totalHeight = 0f;

            for (var i = 0; i < Items.Count; i++)
            {
                var item = Items[i];
                AddContainedDrawable(item);
                totalHeight += item.Height;

                const int spacing = 13;

                if (i == 0)
                {
                    item.Y = spacing;
                    continue;
                }

                item.Y       = Items[i - 1].Y + Items[i - 1].Height + spacing;
                totalHeight += spacing;
            }

            if (ContentContainer.Height < totalHeight)
            {
                ContentContainer.Height = Height;
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="width"></param>
        /// <param name="label"></param>
        /// <param name="options"></param>
        public LabelledHorizontalSelector(float width, string label, List <string> options, int selectedIndex = 0)
        {
            Size  = new ScalableVector2(width, 62);
            Alpha = 0;

            Label = new SpriteTextBitmap(FontsBitmap.GothamRegular, label)
            {
                Parent   = this,
                FontSize = 17
            };

            Selector = new QuaverHorizontalSelector(options, new ScalableVector2(186, 26), Fonts.SourceSansProSemiBold, 13,
                                                    new ScalableVector2(20, 15), (s, i) => { }, selectedIndex)
            {
                Parent    = this,
                Alignment = Alignment.TopRight,
                X         = 26,
                Y         = -2
            };

            Height = Selector.Height;
        }
Example #11
0
        public SpectatorDialog(SpectatorClient client)
        {
            SpectatorClient = client;

            Image            = UserInterface.WaitingPanel;
            Size             = new ScalableVector2(450, 134);
            Alpha            = 0;
            SetChildrenAlpha = true;

            Icon = new Sprite
            {
                Parent    = this,
                Alignment = Alignment.TopCenter,
                Image     = FontAwesome.Get(FontAwesomeIcon.fa_information_button),
                Y         = 18,
                Size      = new ScalableVector2(24, 24)
            };

            // ReSharper disable once ObjectCreationAsStatement
            Text = new SpriteTextBitmap(FontsBitmap.AllerRegular, "Waiting for host!")
            {
                Parent    = this,
                FontSize  = 20,
                Y         = Icon.Y + Icon.Height + 10,
                Alignment = Alignment.TopCenter
            };

            LoadingWheel = new Sprite()
            {
                Parent    = this,
                Size      = new ScalableVector2(40, 40),
                Image     = UserInterface.LoadingWheel,
                Alignment = Alignment.TopCenter,
                Y         = Text.Y + Text.Height + 10
            };

            OnlineManager.Client.OnUserStatusReceived += OnClientStatusReceived;
        }
Example #12
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public ScrollContainer(ScalableVector2 size, ScalableVector2 contentSize, bool startFromBottom = false)
        {
            Size = size;

            // Create the SpriteBatchOptions with scissor rect enabled.
            SpriteBatchOptions = new SpriteBatchOptions
            {
                SortMode        = SpriteSortMode.Immediate,
                BlendState      = BlendState.NonPremultiplied,
                RasterizerState = new RasterizerState
                {
                    ScissorTestEnable = true,
                },
            };

            // Create container in which all scrolling contents will be children of.
            ContentContainer = new Container(contentSize, new ScalableVector2(0, 0))
            {
                Parent = this,
                UsePreviousSpriteBatchOptions = true
            };

            // Choose starting location of the scroll container
            ContentContainer.Y = startFromBottom ? -ContentContainer.Height : 0;

            // Create the scroll bar.
            Scrollbar = new Sprite
            {
                Parent    = this,
                Alignment = Alignment.BotRight,
                Width     = 15,
                Tint      = Color.Black,
                X         = 1
            };

            TargetY         = ContentContainer.Y;
            PreviousTargetY = TargetY;
        }
Example #13
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="type"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public ResultKeyValueItem(ResultKeyValueItemType type, string key, string value)
        {
            Type  = type;
            Alpha = 0f;
            Tint  = Color.CornflowerBlue;

            CreateTextKey(key);
            CreateTextValue(value);

            switch (Type)
            {
            case ResultKeyValueItemType.Vertical:
                Size = new ScalableVector2(Math.Max(TextKey.Width, TextValue.Width), TextKey.Height + TextValue.Height + 5);
                break;

            case ResultKeyValueItemType.Horizontal:
                Size = new ScalableVector2(TextKey.Width + 5 + TextValue.Width, TextKey.Height);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #14
0
        public override void Update(GameTime gameTime)
        {
            if (IsHeld)
            {
                if (GrabOffset == null)
                {
                    GrabOffset = new Vector2(MouseManager.CurrentState.X - AbsolutePosition.X, MouseManager.CurrentState.Y - AbsolutePosition.Y);
                }

                Alignment = Alignment.TopLeft;

                var x = MathHelper.Clamp(MouseManager.CurrentState.X - GrabOffset.Value.X, 0, WindowManager.Width - Width);
                var y = MathHelper.Clamp(MouseManager.CurrentState.Y - GrabOffset.Value.Y, 0, WindowManager.Height - Height);

                Position = new ScalableVector2(x, y);
            }
            else
            {
                GrabOffset = null;
            }

            base.Update(gameTime);
        }
Example #15
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="buttons"></param>
        /// <param name="icons"></param>
        /// <param name="size"></param>
        internal Toolbar(List <ToolbarItem> buttons, List <ToolbarItem> icons, ScalableVector2 size)
        {
            Buttons = buttons;
            Icons   = icons;
            Size    = size;
            Tint    = Color.Black;
            Y       = 0;
            Alpha   = 0f;

            BottomLine = new Sprite
            {
                Parent    = this,
                Alignment = Alignment.TopCenter,
                Tint      = Color.White,
                Width     = Width - 160,
                Height    = 1,
                Alpha     = 0.3f,
                Y         = Height
            };

            InitializeToolbarItems();
            InitializeIcons();
        }
Example #16
0
        /// <summary>
        /// </summary>
        public ResultMultiplayerScoreboard(List <ScoreboardUser> scoreboardUsers)
        {
            Size = new ScalableVector2(WindowManager.Width - 56, 490);

            if (OnlineManager.CurrentGame.Ruleset == MultiplayerGameRuleset.Team)
            {
                Height -= 46;
            }

            Image = UserInterface.ResultMultiplayerPanel;

            TableHeader = new ResultMultiplayerScoreboardTableHeader((int)Width - 4)
            {
                Parent = this
            };

            ScoreboardList = new ResultMultiplayerScoreboardList(TableHeader, scoreboardUsers, new ScalableVector2(Width - 4, Height - TableHeader.Height - 2))
            {
                Parent = this,
                Y      = TableHeader.Height + 1,
                X      = 2
            };
        }
Example #17
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="banner"></param>
        public BannerMetadata(SelectMapBanner banner)
        {
            Banner    = banner;
            Parent    = Banner;
            Size      = new ScalableVector2(Banner.Width - Banner.Border.Thickness * 2, 34);
            Alignment = Alignment.BotCenter;
            Tint      = Color.Black;
            Y         = -Banner.Border.Thickness;
            Alpha     = 0.45f;

            Mode = new BannerMetadataItem(Fonts.Exo2SemiBold, 13, "Mode", "4K")
            {
                Parent = this, Alignment = Alignment.MidLeft
            };
            Bpm = new BannerMetadataItem(Fonts.Exo2SemiBold, 13, "BPM", "240")
            {
                Parent = this, Alignment = Alignment.MidLeft
            };
            Length = new BannerMetadataItem(Fonts.Exo2SemiBold, 13, "Length", "0:00")
            {
                Parent = this, Alignment = Alignment.MidLeft
            };
            Difficulty = new BannerMetadataItem(Fonts.Exo2SemiBold, 13, "Difficulty", "13.22")
            {
                Parent = this, Alignment = Alignment.MidLeft
            };

            Items = new List <BannerMetadataItem>
            {
                Mode,
                Bpm,
                Length,
                Difficulty
            };

            ModManager.ModsChanged += OnModsChanged;
        }
Example #18
0
        /// <inheritdoc />
        /// <summary>
        ///   Ctor -
        /// </summary>
        /// <param name="type"></param>
        /// <param name="size"></param>
        public HitErrorBar(ScalableVector2 size)
        {
            Size = size;

            MiddleLine = new Sprite()
            {
                Size      = new ScalableVector2(2, 0, 0, 1),
                Alignment = Alignment.MidCenter,
                Parent    = this
            };

            // Create the object pool and initialize all of the sprites.
            LineObjectPool = new List <Sprite>();
            for (var i = 0; i < PoolSize; i++)
            {
                LineObjectPool.Add(new Sprite()
                {
                    Parent    = this,
                    Size      = new ScalableVector2(4, 0, 0, 1),
                    Alignment = Alignment.MidCenter,
                    Alpha     = 0
                });
            }

            // Create the hit chevron.
            var chevronSize = SkinManager.Skin.Keys[MapManager.Selected.Value.Mode].HitErrorChevronSize;

            LastHitCheveron = new Sprite()
            {
                Parent    = this,
                Alignment = Alignment.MidCenter,
                Alpha     = 1,
                Image     = FontAwesome.Get(FontAwesomeIcon.fa_caret_down),
                Y         = -Height - 3,
                Size      = new ScalableVector2(chevronSize, chevronSize)
            };
        }
Example #19
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            ElapsedTime += gameTime.ElapsedGameTime;

            if (ElapsedTime > TimeSpan.FromSeconds(1))
            {
                ElapsedTime -= TimeSpan.FromSeconds(1);

                var oldFrameRate = FrameRate;
                FrameRate    = FrameCounter;
                FrameCounter = 0;
                if (oldFrameRate != FrameRate)
                {
                    TextFps.Text = $"{FrameRate} FPS";
                }

                var oldUpdateRate = UpdateRate;
                UpdateRate    = UpdateCounter;
                UpdateCounter = 0;
                if (oldUpdateRate != UpdateRate)
                {
                    TextUps.Text = $"{UpdateRate} UPS";
                }

                TextUps.Y = TextFps.Y + TextFps.Size.Y.Value;
                Size      = new ScalableVector2(
                    Math.Max(TextFps.Size.X.Value, TextUps.Size.X.Value),
                    TextFps.Size.Y.Value + TextUps.Size.Y.Value
                    );
            }

            // The frame counter updates after the text is refreshed (since Draw happens after Update),
            // so update the update counter after the text is refreshed, too.
            UpdateCounter++;

            base.Update(gameTime);
        }
        public ScoreboardBattleRoyaleBanner(Scoreboard scoreboard)
        {
            Scoreboard = scoreboard;
            Size       = new ScalableVector2(260, 34);
            Image      = UserInterface.BattleRoyalePanel;

            PlayersLeft = new SpriteTextBitmap(FontsBitmap.GothamRegular, Scoreboard.BattleRoyalePlayersLeft + " Left")
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                FontSize  = 18,
                X         = 52
            };

            TimeLeft = new SpriteTextBitmap(FontsBitmap.GothamRegular, "-00:00", false)
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                FontSize  = 18,
                X         = 184
            };

            Scoreboard.BattleRoyalePlayersLeft.ValueChanged += OnBattleRoyaleRoyalePlayersLeftChanged;
        }
Example #21
0
        /// <inheritdoc />
        ///   <summary>
        ///   </summary>
        ///   <param name="width"></param>
        ///   <param name="maxHeight"></param>
        ///   <param name="numBars"></param>
        ///  <param name="barWidth"></param>
        public MenuAudioVisualizer(int width, int maxHeight, int numBars, int barWidth)
        {
            MaxBarHeight = maxHeight;

            Size  = new ScalableVector2(width, maxHeight);
            Alpha = 0f;

            Bars = new List <Sprite>();

            for (var i = 0; i < numBars; i++)
            {
                var bar = new Sprite()
                {
                    Parent    = this,
                    Alignment = Alignment.BotLeft,
                    Tint      = Colors.MainAccentInactive,
                    Width     = barWidth,
                    X         = barWidth * i + i * 5,
                    Alpha     = 0.20f
                };

                Bars.Add(bar);
            }
        }
Example #22
0
        public BattleRoyalePlayerEliminated(GameplayScreen screen)
        {
            Screen = screen;

            Username = new SpriteTextBitmap(FontsBitmap.GothamRegular, " ", false)
            {
                Parent   = this,
                Tint     = Color.Crimson,
                FontSize = 20,
                Alpha    = 0
            };

            Eliminated = new SpriteTextBitmap(FontsBitmap.GothamRegular, " has been eliminated!", false)
            {
                Parent   = this,
                FontSize = 20,
                X        = Username.Width + 1,
                Alpha    = 0
            };

            Size = new ScalableVector2(Username.Width + Eliminated.Width + 1, Eliminated.Height);

            OnlineManager.Client.OnPlayerBattleRoyaleEliminated += OnBattleRoyalePlayerEliminated;
        }
Example #23
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();
        }
Example #24
0
        /// <inheritdoc />
        /// <summary>
        ///     Ctor
        /// </summary>
        /// <param name="screen"></param>
        /// <param name="type"></param>
        /// <param name="username"></param>
        /// <param name="judgements"></param>
        /// <param name="avatar"></param>
        /// <param name="mods"></param>
        /// <param name="score"></param>
        /// <exception cref="T:System.ComponentModel.InvalidEnumArgumentException"></exception>
        internal ScoreboardUser(GameplayScreen screen, ScoreboardUserType type, string username, List <Judgement> judgements, Texture2D avatar, ModIdentifier mods, Score score = null)
        {
            Screen          = screen;
            LocalScore      = score;
            Judgements      = judgements;
            UsernameRaw     = username;
            RatingProcessor = new RatingProcessorKeys(MapManager.Selected.Value.DifficultyFromMods(mods));
            Type            = type;
            Size            = new ScalableVector2(260, 50);

            // Set position initially to offscreen
            X = -Width - 10;

            // The alpha of the tect - determined by the scoreboard user type.
            float textAlpha;

            // Set props based on the type of scoreboard user this is.
            switch (Type)
            {
            case ScoreboardUserType.Self:
                Image     = SkinManager.Skin.Scoreboard;
                Alpha     = 1f;
                textAlpha = 1f;
                break;

            case ScoreboardUserType.Other:
                Image     = SkinManager.Skin.ScoreboardOther;
                Alpha     = 0.75f;
                textAlpha = 0.65f;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (Screen.Map.Mode)
            {
            case GameMode.Keys4:
            case GameMode.Keys7:
                Processor = Type == ScoreboardUserType.Other ? new ScoreProcessorKeys(Screen.Map, mods) : Screen.Ruleset.ScoreProcessor;
                break;

            default:
                throw new InvalidEnumArgumentException();
            }

            // Create avatar
            Avatar = new Sprite()
            {
                Parent    = this,
                Size      = new ScalableVector2(Height, Height),
                Alignment = Alignment.MidLeft,
                Image     = avatar,
            };

            if (Type != ScoreboardUserType.Self)
            {
                if (LocalScore != null && LocalScore.IsOnline)
                {
                    // Check to see if we have a Steam avatar for this user cached.
                    if (SteamManager.UserAvatars.ContainsKey((ulong)LocalScore.SteamId))
                    {
                        Avatar.Image = SteamManager.UserAvatars[(ulong)LocalScore.SteamId];
                    }
                    else
                    {
                        Avatar.Alpha = 0;
                        Avatar.Image = UserInterface.UnknownAvatar;

                        // Otherwise we need to request for it.
                        SteamManager.SteamUserAvatarLoaded += OnAvatarLoaded;
                        SteamManager.SendAvatarRetrievalRequest((ulong)LocalScore.SteamId);
                    }
                }
                else
                {
                    Avatar.Image = UserInterface.UnknownAvatar;
                }
            }

            // Create username text.
            Username = new SpriteText(Fonts.Exo2Bold, GetUsernameFormatted(), 13)
            {
                Parent    = this,
                Alignment = Alignment.TopLeft,
                Alpha     = textAlpha,
                X         = Avatar.Width + 10,
            };

            // Create score text.
            Score = new SpriteTextBitmap(FontsBitmap.AllerRegular, "0.00")
            {
                Parent    = this,
                Alignment = Alignment.TopLeft,
                Alpha     = textAlpha,
                Y         = Username.Y + Username.Height + 2,
                X         = Username.X,
                FontSize  = 18
            };

            // Create score text.
            Combo = new SpriteTextBitmap(FontsBitmap.AllerRegular, $"{Processor.Combo:N0}x")
            {
                Parent    = this,
                Alignment = Alignment.MidRight,
                Alpha     = textAlpha,
                FontSize  = 18,
                X         = -5
            };
        }
Example #25
0
        /// <summary>
        ///     Ctor -
        /// </summary>
        /// <param name="screen"></param>
        internal SongInformation(GameplayScreen screen)
        {
            Screen = screen;

            Size  = new ScalableVector2(750, 150);
            Tint  = Colors.MainAccentInactive;
            Alpha = 0;

            // Create watching text outside of replay mode because other text relies on it.
            Watching = new SpriteText(Fonts.SourceSansProSemiBold, $"Watching {(screen.InReplayMode ? Screen.LoadedReplay.PlayerName : "")}", 13)
            {
                Parent    = this,
                Alignment = Alignment.TopCenter,
                Y         = 25,
                Alpha     = 0
            };

            Title = new SpriteText(Fonts.SourceSansProSemiBold, $"{Screen.Map.Artist} - {Screen.Map.Title}", 13)
            {
                Parent    = this,
                Alignment = Alignment.TopCenter,
                Y         = Watching.Y + TextYSpacing + TextYSpacing,
                Alpha     = 0,
            };

            Difficulty = new SpriteText(Fonts.SourceSansProSemiBold, $"[{Screen.Map.DifficultyName}]", 13)
            {
                Parent    = this,
                Alignment = Alignment.TopCenter,
                Y         = Title.Y + TextYSpacing + TextYSpacing * 0.85f,
                Alpha     = 0
            };

            Creator = new SpriteText(Fonts.SourceSansProSemiBold, $"Mapped By: \"{Screen.Map.Creator}\"", 13)
            {
                Parent    = this,
                Alignment = Alignment.TopCenter,
                Y         = Difficulty.Y + TextYSpacing + TextYSpacing * 0.80f,
                Alpha     = 0
            };

            var difficulty = (float)MapManager.Selected.Value.DifficultyFromMods(ModManager.Mods);

            Rating = new SpriteText(Fonts.SourceSansProSemiBold,
                                    $"Difficulty: {StringHelper.AccuracyToString(difficulty).Replace("%", "")}",
                                    13)
            {
                Parent    = this,
                Alignment = Alignment.TopCenter,
                Y         = Creator.Y + TextYSpacing + TextYSpacing * 0.75f,
                Alpha     = 0,
                Tint      = ColorHelper.DifficultyToColor(difficulty)
            };

            // Get a formatted string of the activated mods.
            var modsString = "Mods: " + (ModManager.CurrentModifiersList.Count > 0 ? $"{ModHelper.GetModsString(ModManager.Mods)}" : "None");

            Mods = new SpriteText(Fonts.SourceSansProSemiBold, modsString, 13)
            {
                Parent    = this,
                Alignment = Alignment.TopCenter,
                Y         = Rating.Y + TextYSpacing + TextYSpacing * 0.7f,
                Alpha     = 0
            };
        }
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="container"></param>
        /// <param name="item"></param>
        /// <param name="index"></param>
        public DrawableMultiplayerPlayer(PoolableScrollContainer <OnlineUser> container, OnlineUser item, int index) : base(container, item, index)
        {
            Alpha = 0f;
            Tint  = Color.White;
            Size  = new ScalableVector2(container.Width, HEIGHT);

            Button = new DrawableMultiplayerPlayerButton(this)
            {
                Parent = this,
                UsePreviousSpriteBatchOptions = true
            };

            Ready = new Sprite
            {
                Parent    = Button,
                Alignment = Alignment.MidLeft,
                X         = 16,
                Image     = FontAwesome.Get(FontAwesomeIcon.fa_check_mark),
                Size      = new ScalableVector2(18, 18),
                Alpha     = OnlineManager.CurrentGame.PlayersReady.Contains(Item.Id) ? 1 :  0.35f,
                Tint      = Color.LimeGreen,
                UsePreviousSpriteBatchOptions = true
            };

            Avatar = new Sprite
            {
                Parent    = Button,
                Size      = new ScalableVector2(36, 36),
                X         = Ready.X + Ready.Width + 16,
                Alignment = Alignment.MidLeft,
                Alpha     = 0,
                UsePreviousSpriteBatchOptions = true
            };

            Avatar.AddBorder(GetPlayerColor(), 2);

            Flag = new Sprite()
            {
                Parent                      = Button,
                Alignment                   = Alignment.MidLeft,
                X                           = Avatar.X + Avatar.Width + 16,
                Image                       = item.CountryFlag == null?Flags.Get("XX") : Flags.Get(item.CountryFlag),
                                       Size = new ScalableVector2(26, 26),
                                       UsePreviousSpriteBatchOptions = true
            };

            Username = new SpriteTextBitmap(FontsBitmap.GothamRegular, string.IsNullOrEmpty(item.Username) ? $"Loading..." : item.Username)
            {
                Parent    = Flag,
                Alignment = Alignment.MidLeft,
                X         = Flag.Width + 6,
                FontSize  = 16,
                UsePreviousSpriteBatchOptions = true
            };

            HostCrown = new Sprite
            {
                Parent       = Username,
                Alignment    = Alignment.MidLeft,
                X            = Username.Width + 12,
                Y            = 1,
                Size         = new ScalableVector2(16, 16),
                Image        = FontAwesome.Get(FontAwesomeIcon.fa_vintage_key_outline),
                SpriteEffect = SpriteEffects.FlipHorizontally,
                Tint         = Color.Gold,
                UsePreviousSpriteBatchOptions = true
            };

            NoMapIcon = new Sprite()
            {
                Parent    = Button,
                Alignment = Alignment.MidLeft,
                X         = Ready.X,
                Size      = Ready.Size,
                Tint      = Color.Red,
                Visible   = OnlineManager.CurrentGame.PlayersWithoutMap.Contains(Item.Id),
                Image     = FontAwesome.Get(FontAwesomeIcon.fa_times),
                UsePreviousSpriteBatchOptions = true
            };

            Wins = new SpriteTextBitmap(FontsBitmap.GothamRegular, "0 Wins")
            {
                Parent    = this,
                Alignment = Alignment.MidRight,
                X         = -16,
                FontSize  = 16,
                Tint      = Colors.SecondaryAccent,
                Y         = -2,
                UsePreviousSpriteBatchOptions = true
            };

            Mods = new SpriteTextBitmap(FontsBitmap.GothamRegular, "")
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                X         = Avatar.X + Avatar.Width + 16,
                FontSize  = 14,
                Y         = 8,
                UsePreviousSpriteBatchOptions = true,
                Tint = Colors.MainAccent
            };

            Referee = new SpriteTextBitmap(FontsBitmap.GothamRegular, "Referee")
            {
                Parent    = this,
                Alignment = Alignment.MidRight,
                X         = -16,
                FontSize  = 16,
                Y         = -2,
                UsePreviousSpriteBatchOptions = true
            };

            OnlineManager.Client.OnUserInfoReceived       += OnUserInfoReceived;
            OnlineManager.Client.OnGameHostChanged        += OnGameHostChanged;
            OnlineManager.Client.OnGameMapChanged         += OnGameMapChanged;
            OnlineManager.Client.OnGamePlayerNoMap        += OnGamePlayerNoMap;
            OnlineManager.Client.OnGamePlayerHasMap       += OnGamePlayerHasMap;
            OnlineManager.Client.OnPlayerReady            += OnGamePlayerReady;
            OnlineManager.Client.OnPlayerNotReady         += OnGamePlayerNotReady;
            OnlineManager.Client.OnUserStats              += OnUserStats;
            OnlineManager.Client.OnGamePlayerWinCount     += OnGamePlayerWinCount;
            OnlineManager.Client.OnGameTeamWinCount       += OnGameTeamWinCount;
            OnlineManager.Client.OnPlayerChangedModifiers += OnPlayerChangedModifiers;
            OnlineManager.Client.OnChangedModifiers       += OnGameChangedModifiers;
            OnlineManager.Client.OnGameSetReferee         += OnGameSetReferee;

            SteamManager.SteamUserAvatarLoaded += OnSteamAvatarLoaded;

            if (!OnlineManager.OnlineUsers[item.Id].HasUserInfo)
            {
                OnlineManager.Client.RequestUserInfo(new List <int> {
                    item.Id
                });
            }
            else
            {
                if (SteamManager.UserAvatars.ContainsKey((ulong)Item.SteamId))
                {
                    Avatar.Image = SteamManager.UserAvatars[(ulong)Item.SteamId];
                    Avatar.Alpha = 1;
                }
            }

            // Request user stats if necessary
            if (OnlineManager.OnlineUsers[item.Id].Stats.Count == 0)
            {
                OnlineManager.Client.RequestUserStats(new List <int> {
                    item.Id
                });
            }
        }
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="container"></param>
        /// <param name="item"></param>
        /// <param name="index"></param>
        /// <param name="header"></param>
        public ResultMultiplayerScoreboardUser(PoolableScrollContainer <ScoreboardUser> container, ScoreboardUser item, int index, ResultMultiplayerScoreboardTableHeader header)
            : base(container, item, index)
        {
            Header = header;
            Size   = new ScalableVector2(container.Width, HEIGHT);
            Alpha  = 0.85f;

            Button = new ResultMultiplayerScoreboardUserButton(Item, container)
            {
                Parent = this,
                Size   = Size,
                UsePreviousSpriteBatchOptions = true
            };

            // ReSharper disable once ObjectCreationAsStatement
            var rank = new SpriteTextBitmap(FontsBitmap.GothamRegular, $"{item.Rank}.")
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                X         = 20,
                FontSize  = 16,
                Tint      = Item.Type == ScoreboardUserType.Self ? Colors.SecondaryAccent : Color.White,
                UsePreviousSpriteBatchOptions = true
            };

            var avatar = new Sprite
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                Size      = new ScalableVector2(32, 32),
                X         = 56,
                Image     = item.Avatar.Image,
                UsePreviousSpriteBatchOptions = true
            };

            avatar.AddBorder(Color.White, 2);

            var username = new SpriteTextBitmap(FontsBitmap.GothamRegular, item.UsernameRaw)
            {
                Parent    = this,
                Alignment = Alignment.MidLeft,
                X         = avatar.X + avatar.Width + 16,
                FontSize  = 16,
                Tint      = Item.Type == ScoreboardUserType.Self ? Colors.SecondaryAccent : Color.White,
                UsePreviousSpriteBatchOptions = true
            };

            if (item.Processor == null)
            {
                return;
            }

            CreateData(new Dictionary <string, string>
            {
                { "Rating", item.CalculateRating().ToString("00.00") },
                { "Grade", "" },
                { "Accuracy", StringHelper.AccuracyToString(item.Processor.Accuracy) },
                { "Max Combo", item.Processor.MaxCombo + "x" },
                { "Marv", item.Processor.CurrentJudgements[Judgement.Marv].ToString() },
                { "Perf", item.Processor.CurrentJudgements[Judgement.Perf].ToString() },
                { "Great", item.Processor.CurrentJudgements[Judgement.Great].ToString() },
                { "Good", item.Processor.CurrentJudgements[Judgement.Good].ToString() },
                { "Okay", item.Processor.CurrentJudgements[Judgement.Okay].ToString() },
                { "Miss", item.Processor.CurrentJudgements[Judgement.Miss].ToString() },
                { "Mods", item.Processor.Mods <= 0 ? "None" : ModHelper.GetModsString(ModHelper.GetModsFromRate(ModHelper.GetRateFromMods(item.Processor.Mods))) }
            });

            // ReSharper disable once ObjectCreationAsStatement
            new Sprite
            {
                Parent    = this,
                Alignment = Alignment.BotLeft,
                Size      = new ScalableVector2(Width, 1),
                Alpha     = 0.3f
            };
        }
Example #28
0
 /// <inheritdoc />
 /// <summary>
 ///     TODO: Fix this so that it works with every alignment.
 /// </summary>
 /// <param name="gameTime"></param>
 protected override void OnHeld(GameTime gameTime)
 {
     Alignment = Alignment.TopLeft;
     Position  = new ScalableVector2(MouseManager.CurrentState.X, MouseManager.CurrentState.Y);
 }
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="availableItems"></param>
 /// <param name="poolSize"></param>
 /// <param name="poolStartingIndex"></param>
 /// <param name="size"></param>
 /// <param name="contentSize"></param>
 /// <param name="startFromBottom"></param>
 protected PoolableScrollContainer(List <T> availableItems, int poolSize, int poolStartingIndex, ScalableVector2 size, ScalableVector2 contentSize,
                                   bool startFromBottom = false) : base(size, contentSize, startFromBottom)
 {
     AvailableItems    = availableItems;
     PoolSize          = poolSize;
     PoolStartingIndex = poolStartingIndex;
 }
Example #30
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public DownloadableMapset(DownloadScrollContainer container, JToken mapset)
        {
            Container = container;
            Mapset    = mapset;
            MapsetId  = (int)Mapset["id"];

            Size  = new ScalableVector2(container.Width, HEIGHT);
            Tint  = Color.Black;
            Alpha = IsAlreadyOwned ? 0.25f : 0.45f;

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

            AlreadyOwned = new SpriteText(Fonts.SourceSansProBold, "Already Owned", 13)
            {
                Parent    = Banner,
                Alignment = Alignment.MidCenter,
                UsePreviousSpriteBatchOptions = true
            };

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

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

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

            Title = new SpriteText(Fonts.SourceSansProBold, $"{Mapset["title"]}", 13)
            {
                Parent = this,
                X      = Banner.X + Banner.Width + 15,
                Y      = 6,
                Alpha  = IsAlreadyOwned ? 0.65f : 1,
            };

            Artist = new SpriteText(Fonts.SourceSansProBold, $"{Mapset["artist"]}", 12)
            {
                Parent = this,
                X      = Title.X,
                Y      = Title.Y + Title.Height,
                Alpha  = IsAlreadyOwned ? 0.65f : 1,
            };

            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 SpriteText(Fonts.SourceSansProBold, string.Join(" & ", modes), 11)
            {
                Parent = this,
                X      = Artist.X,
                Y      = Artist.Y + Artist.Height + 2,
                Alpha  = IsAlreadyOwned ? 0.65f : 1,
            };

            Creator = new SpriteText(Fonts.SourceSansProSemiBold, $"Created By: {Mapset["creator_username"]}", 11)
            {
                Parent    = this,
                Alignment = Alignment.BotRight,
                Position  = new ScalableVector2(-10, -5),
                Alpha     = IsAlreadyOwned ? 0.65f : 1,
            };

            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();

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