Exemplo n.º 1
0
        /// <summary>
        /// Adds diffBar to the elements to be updated.
        /// </summary>
        protected override void UpdateElements()
        {
            // Don't bother updating if we aren't on screen.
            if (!OnScreen())
            {
                return;
            }

            base.UpdateElements();

            diffBar?.ChangePosition(AnchorUtil.FindDrawablePosition(diffBarStartAnchor, this) + diffBarOffset);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates all the elements on this card to move in the right spot.
        /// Inherited classes can add new elements in an overriden method,
        /// don't forget "base.UpdateElements()"
        /// </summary>
        protected virtual void UpdateElements()
        {
            // Don't bother updating if we aren't on screen.
            if (!OnScreen())
            {
                return;
            }

            for (int i = 0; i < TextElements.Count; i++)
            {
                TextElements[i]?.ChangePosition
                (
                    AnchorUtil.FindDrawablePosition(TextElementStartAnchors[i], this)
                    + TextElementOffsets[i]
                );
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a TextDisplayElement to the Card, using the config to
        /// determine their positioning and other properties.
        /// </summary>
        /// <param name="typeName">The "typeName" of the button, or the prefix in the config.</param>
        protected virtual void AddTextDisplayElement(string typeName)
        {
            // Find variables for TDE
            Anchor  startAnchor;
            Vector2 position = Skin.GetConfigStartPosition(Config, Section, typeName + "StartPos", out startAnchor, this);
            int     fontSize = GetSkinnableInt(typeName + "FontSize");
            Anchor  anchor   = GetSkinnableAnchor(typeName + "Anchor");
            Color   color    = Skin.GetConfigColor(Config, Section, typeName + "Color");

            // Make TDE
            TextDisplayElement text = new TextDisplayElement("", position, fontSize, anchor, color);

            // Offset
            Vector2 offset = new Vector2(
                GetSkinnableInt(typeName + "X"),
                GetSkinnableInt(typeName + "Y"));

            text.Move(offset);

            //Add TDE
            TextElements.Add(text);
            TextElementOffsets.Add(text.Position - AnchorUtil.FindDrawablePosition(startAnchor, this));
            TextElementStartAnchors.Add(startAnchor);
        }
Exemplo n.º 4
0
        private void SetDiffBar()
        {
            float difficulty = (float)Beatmap.Difficulty;

            Anchor  startAnchor;
            Vector2 startPos = Skin.GetConfigStartPosition(Config, Section, "DiffBarStartPos", out startAnchor, this);

            Anchor diffAnchor = GetSkinnableAnchor("DiffBarAnchor");

            diffBar = new BeatmapCardDifficulty
                      (
                startPos,
                // diffbar displayed percentage is 0 if less than 0, and 10 if greater than 10
                difficulty <= 10 ? difficulty >= 0 ? difficulty : 0 : 10,
                diffAnchor
                      );

            int diffBarXOffset = GetSkinnableInt("DiffBarX");
            int diffBarYOffset = GetSkinnableInt("DiffBarY");

            diffBar.Move(diffBarXOffset, diffBarYOffset);
            diffBarOffset      = diffBar.Position - AnchorUtil.FindDrawablePosition(startAnchor, this);
            diffBarStartAnchor = startAnchor;
        }